summaryrefslogtreecommitdiff
path: root/desktop/source
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-02-10 13:26:50 +0100
committerJan Holesovsky <kendy@collabora.com>2016-02-11 15:14:21 +0100
commita121074cbd07939713e169586469b934aedbe594 (patch)
tree21276e70136dba84d114c326cb3757c7dc210477 /desktop/source
parentd11bf83b3f28fccdaac4c90dfb283b47f3617a7d (diff)
lok: Introduce a "TakeOwnership" filter option for saveAs().
It is consumed by the saveAs() itself, and when provided, the document identity changes to the provided pUrl - meaning that '.uno:ModifiedStatus' is triggered as with the "Save As..." in the UI. This mode must not be used when saving to PNG or PDF. Change-Id: I11b5aa814476a8dcab9eac5202bd052828ebbd96
Diffstat (limited to 'desktop/source')
-rw-r--r--desktop/source/lib/init.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4e7525838c97..c6e288ed418b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -658,6 +658,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;
@@ -675,7 +699,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;
}