diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-03-26 17:55:41 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-03-27 09:03:19 +0200 |
commit | 0518bb5c3a98d973c3675fdd4cb8c52a669a3507 (patch) | |
tree | 5fa61324dce8477d194f54032da03f6850259a8d /desktop | |
parent | 862dc17e437f0972223e18555110dc875d2ffa44 (diff) |
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@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 29 |
1 files changed, 13 insertions, 16 deletions
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 |