sc/source/filter/excel/xestyle.cxx |   26 +++++++++++++-----------
 sfx2/source/doc/docfile.cxx        |   39 +++++++++++++++++++++++++++++++------
 sfx2/source/doc/objstor.cxx        |    4 ++-
 sw/source/filter/xml/swxml.cxx     |    2 -
 4 files changed, 51 insertions(+), 20 deletions(-)

New commits:
commit 4a5ab80057ca832693a4cf49e653dbbd985ebaaf
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Wed Mar 27 18:01:49 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Aug 28 14:04:36 2024 +0200

    lok: avoid perturbing parent background save process' temp file.
    
    The temporary file that typically contains the content of thes
    currently open document is re-written, and deleted on save. Avoid
    deleting the original when we are background save worker.
    
    Change-Id: Ibbb3a963cb3420088623994c067115ff77b96f54
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165408
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit 53316a6b8228885a17bf53c4fae6fe9d8ef80d2d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172519
    Tested-by: Jenkins

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index c9631f64cbde..3a5fa149d786 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -76,6 +76,7 @@
 #include <tools/fileutil.hxx>
 #include <unotools/configmgr.hxx>
 #include <unotools/tempfile.hxx>
+#include <comphelper/lok.hxx>
 #include <comphelper/fileurl.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertyvalue.hxx>
@@ -343,6 +344,32 @@ 
CheckReadOnlyTaskTerminateListener::notifyTermination(const css::lang::EventObje
     lock.unlock();
     mCond.notify_one();
 }
+
+/// Temporary file wrapper to handle tmp file lifecyle
+/// for lok fork a background saving worker issues.
+class MediumTempFile : public ::utl::TempFileNamed
+{
+    bool m_bWasChild;
+public:
+    MediumTempFile(const OUString *pParent )
+        : ::utl::TempFileNamed(pParent)
+        , m_bWasChild(comphelper::LibreOfficeKit::isForkedChild())
+    {
+    }
+
+    MediumTempFile(const MediumTempFile &rFrom ) = delete;
+
+    ~MediumTempFile()
+    {
+        bool isForked = comphelper::LibreOfficeKit::isForkedChild();
+
+        // avoid deletion of files created by the parent
+        if (isForked && ! m_bWasChild)
+        {
+            EnableKillingFile(false);
+        }
+    }
+};
 }
 
 class SfxMedium_Impl
@@ -405,7 +432,7 @@ public:
 
     uno::Sequence < util::RevisionTag > aVersions;
 
-    std::unique_ptr<::utl::TempFileNamed> pTempFile;
+    std::unique_ptr<MediumTempFile> pTempFile;
 
     uno::Reference<embed::XStorage> xStorage;
     uno::Reference<embed::XStorage> m_xZipStorage;
@@ -3525,7 +3552,7 @@ void SfxMedium::CompleteReOpen()
     bool bUseInteractionHandler = pImpl->bUseInteractionHandler;
     pImpl->bUseInteractionHandler = false;
 
-    std::unique_ptr<::utl::TempFileNamed> pTmpFile;
+    std::unique_ptr<MediumTempFile> pTmpFile;
     if ( pImpl->pTempFile )
     {
         pTmpFile = std::move(pImpl->pTempFile);
@@ -4037,9 +4064,9 @@ void SfxMedium::CreateTempFile( bool bReplace )
     }
 
     OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl);
-    pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase));
+    pImpl->pTempFile.reset(new MediumTempFile(&aLogicBase));
     if (!aLogicBase.isEmpty() && pImpl->pTempFile->GetFileName().isEmpty())
-        pImpl->pTempFile.reset(new ::utl::TempFileNamed());
+        pImpl->pTempFile.reset(new MediumTempFile(nullptr));
     pImpl->pTempFile->EnableKillingFile();
     pImpl->m_aName = pImpl->pTempFile->GetFileName();
     OUString aTmpURL = pImpl->pTempFile->GetURL();
@@ -4135,9 +4162,9 @@ void SfxMedium::CreateTempFileNoCopy()
     pImpl->pTempFile.reset();
 
     OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl);
-    pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase));
+    pImpl->pTempFile.reset(new MediumTempFile(&aLogicBase));
     if (!aLogicBase.isEmpty() && pImpl->pTempFile->GetFileName().isEmpty())
-        pImpl->pTempFile.reset(new ::utl::TempFileNamed());
+        pImpl->pTempFile.reset(new MediumTempFile(nullptr));
     pImpl->pTempFile->EnableKillingFile();
     pImpl->m_aName = pImpl->pTempFile->GetFileName();
     if ( pImpl->m_aName.isEmpty() )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index fe00764a6bee..4da5ab63b7e5 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1741,7 +1741,9 @@ bool SfxObjectShell::SaveTo_Impl
     // TODO/LATER: error handling
     if( rMedium.GetErrorCode() || pMedium->GetErrorCode() || GetErrorCode() )
     {
-        SAL_WARN("sfx.doc", "SfxObjectShell::SaveTo_Impl: very early error 
return");
+        SAL_WARN("sfx.doc", "SfxObjectShell::SaveTo_Impl: "
+                 " very early error return " << rMedium.GetErrorCode() << " "
+                 << pMedium->GetErrorCode() << " " << GetErrorCode());
         return false;
     }
 
commit cf9ff60833fbae0e7101dc7ee470b4c506018957
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Aug 28 09:25:20 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Aug 28 14:04:28 2024 +0200

    cid#1556212 COPY_INSTEAD_OF_MOVE
    
    and
    
    cid#1555768 COPY_INSTEAD_OF_MOVE
    
    Change-Id: I587f47cefc30eeb53dc7a42d865f242d6986d615
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172518
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index 7d7e4bb0e71c..bea89f7d23ad 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3021,18 +3021,20 @@ void XclExpXFBuffer::InsertDefaultRecords()
     maBuiltInMap[ EXC_XF_DEFAULTCELL ].mbPredefined = true;
 
     // index 16-20: other built-in styles
-    XclExpDefaultXF aFormatStyle( GetRoot(), false );
-    aFormatStyle.SetFont( 1 );
-    aFormatStyle.SetNumFmt( 43 );
-    AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_COMMA );
-    aFormatStyle.SetNumFmt( 41 );
-    AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_COMMA_0 );
-    aFormatStyle.SetNumFmt( 44 );
-    AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_CURRENCY );
-    aFormatStyle.SetNumFmt( 42 );
-    AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_CURRENCY_0 );
-    aFormatStyle.SetNumFmt( 9 );
-    AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_PERCENT );
+    {
+        XclExpDefaultXF aFormatStyle( GetRoot(), false );
+        aFormatStyle.SetFont( 1 );
+        aFormatStyle.SetNumFmt( 43 );
+        AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_COMMA );
+        aFormatStyle.SetNumFmt( 41 );
+        AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_COMMA_0 );
+        aFormatStyle.SetNumFmt( 44 );
+        AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_CURRENCY );
+        aFormatStyle.SetNumFmt( 42 );
+        AppendBuiltInXFWithStyle( new XclExpDefaultXF( aFormatStyle ), 
EXC_STYLE_CURRENCY_0 );
+        aFormatStyle.SetNumFmt( 9 );
+        AppendBuiltInXFWithStyle( new XclExpDefaultXF( std::move(aFormatStyle) 
), EXC_STYLE_PERCENT );
+    }
 
     // other built-in style XF records (i.e. Hyperlink styles) are created on 
demand
 
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 9d16fdaa3602..7ea6f034cc48 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -866,7 +866,7 @@ ErrCodeMsg XMLReader::Read( SwDoc &rDoc, const OUString& 
rBaseURL, SwPaM &rPaM,
         if (nWarn)
             nRet = nWarn;
         else if (nWarn2)
-            nRet = nWarn2;
+            nRet = std::move(nWarn2);
         else
             nRet = nWarnRDF;
     }

Reply via email to