diff options
Diffstat (limited to 'desktop/source/lib/init.cxx')
-rw-r--r-- | desktop/source/lib/init.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 507e4f828b20..d5bec92870e3 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -674,6 +674,30 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha OUString aFilterOptions = getUString(pFilterOptions); + // 'TakeOwnership' == this is a 'real' SaveAs (that is, the document + // gets a new name). When this is not provided, the meaning of + // 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. + bool bTakeOwnership = false; + int nIndex = -1; + if (aFilterOptions == "TakeOwnership") + { + bTakeOwnership = true; + aFilterOptions = ""; + } + else if ((nIndex = aFilterOptions.indexOf(",TakeOwnership")) >= 0 || (nIndex = aFilterOptions.indexOf("TakeOwnership,")) >= 0) + { + 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; + } + MediaDescriptor aSaveMediaDescriptor; aSaveMediaDescriptor["Overwrite"] <<= sal_True; aSaveMediaDescriptor["FilterName"] <<= aFilterName; @@ -691,7 +715,11 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha } uno::Reference<frame::XStorable> xStorable(pDocument->mxComponent, uno::UNO_QUERY_THROW); - xStorable->storeToURL(aURL, aSaveMediaDescriptor.getAsConstPropertyValueList()); + + if (bTakeOwnership) + xStorable->storeAsURL(aURL, aSaveMediaDescriptor.getAsConstPropertyValueList()); + else + xStorable->storeToURL(aURL, aSaveMediaDescriptor.getAsConstPropertyValueList()); return true; } |