[Libreoffice-commits] core.git: desktop/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Mar 27 07:03:44 UTC 2018


 desktop/source/lib/init.cxx |   29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

New commits:
commit 0518bb5c3a98d973c3675fdd4cb8c52a669a3507
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Mar 26 17:55:41 2018 +0200

    desktop lok: handle NoFileSync in saveAs()
    
    Similar to TakeOwnership: detect this, remove it from FilterOptions and
    turn it into its own sequence element. Online uses this for its
    convert-to functionality.
    
    The new cost for converting a small ODT file into PDF is 84% of the
    original (when opting in for this flag).
    
    Change-Id: Id2fcf5dd8b40eed04e0bc37f33519fd7691a9e5a
    Reviewed-on: https://gerrit.libreoffice.org/51909
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 44d07125835a..40709157357b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1564,28 +1564,25 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
         // saveAs() is more like save-a-copy, which allows saving to any
         // random format like PDF or PNG.
         // It is not a real filter option, so we have to filter it out.
+        uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(aFilterOptions);
+        std::vector<OUString> aFilteredOptionVec;
         bool bTakeOwnership = false;
-        int nIndex = -1;
-        if (aFilterOptions == "TakeOwnership")
-        {
-            bTakeOwnership = true;
-            aFilterOptions.clear();
-        }
-        else if ((nIndex = aFilterOptions.indexOf(",TakeOwnership")) >= 0 || (nIndex = aFilterOptions.indexOf("TakeOwnership,")) >= 0)
+        MediaDescriptor aSaveMediaDescriptor;
+        for (const auto& rOption : aOptionSeq)
         {
-            OUString aFiltered;
-            if (nIndex > 0)
-                aFiltered = aFilterOptions.copy(0, nIndex);
-            if (nIndex + 14 < aFilterOptions.getLength())
-                aFiltered = aFiltered + aFilterOptions.copy(nIndex + 14);
-
-            bTakeOwnership = true;
-            aFilterOptions = aFiltered;
+            if (rOption == "TakeOwnership")
+                bTakeOwnership = true;
+            else if (rOption == "NoFileSync")
+                aSaveMediaDescriptor["NoFileSync"] <<= true;
+            else
+                aFilteredOptionVec.push_back(rOption);
         }
 
-        MediaDescriptor aSaveMediaDescriptor;
         aSaveMediaDescriptor["Overwrite"] <<= true;
         aSaveMediaDescriptor["FilterName"] <<= aFilterName;
+
+        auto aFilteredOptionSeq = comphelper::containerToSequence<OUString>(aFilteredOptionVec);
+        aFilterOptions = comphelper::string::convertCommaSeparated(aFilteredOptionSeq);
         aSaveMediaDescriptor[MediaDescriptor::PROP_FILTEROPTIONS()] <<= aFilterOptions;
 
         // add interaction handler too


More information about the Libreoffice-commits mailing list