[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - kit/ChildSession.cpp

Jan Holesovsky kendy at collabora.com
Tue Nov 7 16:27:36 UTC 2017


 kit/ChildSession.cpp |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit a64eebb6ae70b34ed691f1b94e64c73ed98a4fec
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 7 14:30:52 2017 +0100

    Save As: If the LOK's saveAs failed, try under a different name.
    
    This helps when the caller omitted the extension...
    
    Change-Id: Ib7602ce8fa88bc867198dbba36b2582145bd0994
    Reviewed-on: https://gerrit.libreoffice.org/44405
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index ec439918..8103f998 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -947,6 +947,27 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const std::vec
         success = getLOKitDocument()->saveAs(url.c_str(),
                 format.size() == 0 ? nullptr :format.c_str(),
                 filterOptions.size() == 0 ? nullptr : filterOptions.c_str());
+
+        if (!success)
+        {
+            // a desperate try - add an extension hoping that it'll help
+            bool retry = true;
+            switch (getLOKitDocument()->getDocumentType())
+            {
+                case LOK_DOCTYPE_TEXT:         url += ".odt"; wopiFilename += ".odt"; break;
+                case LOK_DOCTYPE_SPREADSHEET:  url += ".ods"; wopiFilename += ".ods"; break;
+                case LOK_DOCTYPE_PRESENTATION: url += ".odp"; wopiFilename += ".odp"; break;
+                case LOK_DOCTYPE_DRAWING:      url += ".odg"; wopiFilename += ".odg"; break;
+                default:                       retry = false; break;
+            }
+
+            if (retry)
+            {
+                success = getLOKitDocument()->saveAs(url.c_str(),
+                        format.size() == 0 ? nullptr :format.c_str(),
+                        filterOptions.size() == 0 ? nullptr : filterOptions.c_str());
+            }
+        }
     }
 
     std::string encodedURL, encodedWopiFilename;


More information about the Libreoffice-commits mailing list