From 0518bb5c3a98d973c3675fdd4cb8c52a669a3507 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 26 Mar 2018 17:55:41 +0200 Subject: 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 Tested-by: Jenkins --- desktop/source/lib/init.cxx | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'desktop') 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 aOptionSeq = comphelper::string::convertCommaSeparated(aFilterOptions); + std::vector 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(aFilteredOptionVec); + aFilterOptions = comphelper::string::convertCommaSeparated(aFilteredOptionSeq); aSaveMediaDescriptor[MediaDescriptor::PROP_FILTEROPTIONS()] <<= aFilterOptions; // add interaction handler too -- cgit v1.2.3