sfx2/source/doc/guisaveas.cxx |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit fcf4dd4f09018874ad25a035815f46705db0740a
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Sat Feb 22 08:42:58 2025 -0500
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Feb 24 09:39:55 2025 +0100

    lok: handle saveas as export
    
    SaveAs saves the document to a new path.
    In the jail, this is unhelpful, since
    we upload the document after saving
    from a specific path.
    
    Instead, we do SaveACopy, or export,
    which saves the given document as a
    copy, retaining the original path
    for subsequent saves.
    
    This fixes a serious issue where
    after hitting Ctrl+Shift+S, the
    document would no longer store any
    further changes (in fact, it was
    saving the changes to a different
    path, which was not used for
    uploading).
    
    Signed-off-by: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
    Change-Id: I6ba72df6a0a908d181786c02cb7c060177cd0302
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182071
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 80cc3256f7bf..8790ea05052a 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -1770,8 +1770,12 @@ bool 
SfxStoringHelper::FinishGUIStoreModel(::comphelper::SequenceAsHashMap::cons
     aArgsSequence = aModelData.GetMediaDescr().getAsConstPropertyValueList();
 
     // store the document and handle it's docinfo
-
-    DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), 
aModelData.IsRecommendReadOnly(), nStoreMode & EXPORT_REQUESTED );
+    // Restore when exporting (which is also done when LoKit is enable, see 
below).
+    const bool bRestore
+        = (nStoreMode & EXPORT_REQUESTED)
+          || ((nStoreMode & SAVEAS_REQUESTED) && 
comphelper::LibreOfficeKit::isActive());
+    DocumentSettingsGuard aSettingsGuard(aModelData.GetModel(), 
aModelData.IsRecommendReadOnly(),
+                                         bRestore);
 
     // Treat attempted PDF export like a print: update document print 
statistics
     if ((nStoreMode & PDFEXPORT_REQUESTED) && SfxViewShell::Current())
@@ -1867,7 +1871,10 @@ bool 
SfxStoringHelper::FinishGUIStoreModel(::comphelper::SequenceAsHashMap::cons
         try
         {
 #endif
-            if ( nStoreMode & EXPORT_REQUESTED )
+            // SaveAs in LoKit is unhelpful. It saves the document to a new 
path, which
+            // breaks the link with the storage, so new modifications can't be 
uploaded.
+            if ((nStoreMode & EXPORT_REQUESTED)
+                || ((nStoreMode & SAVEAS_REQUESTED) && 
comphelper::LibreOfficeKit::isActive()))
                 aModelData.GetStorable()->storeToURL( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
             else
                 aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), aArgsSequence );

Reply via email to