summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-10 17:34:23 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-10 17:43:23 +0100
commit7c9f080aca4665980e8cf25ee42ad1b5ec64624b (patch)
tree6f93989ae614f7e4b11eacfa632d0cd4d7c0c8b1 /sd
parent275443f052887f67a6d459d443293690daa3ae24 (diff)
sd: copy doc metadata to clipboard document
Just like in sw, doc metadata wasn't copied to the document. As a start, copy the user-defined doc properties. Note that this just takes care of the source -> clipboard part, it's still up to the clipboard -> destination code to decide how to merge the properties at the end. Change-Id: Ic506e25ab598f4748d443d65664a193d589acd3c
Diffstat (limited to 'sd')
-rw-r--r--sd/source/core/drawdoc.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 62235b5bca5f..286c9240bab4 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -23,6 +23,9 @@
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
#include <editeng/forbiddencharacterstable.hxx>
#include <svx/svxids.hrc>
@@ -438,6 +441,33 @@ SdrModel* SdDrawDocument::AllocModel() const
return AllocSdDrawDocument();
}
+namespace
+{
+
+/// Copies all user-defined properties from pSource to pDestination.
+void lcl_copyUserDefinedProperties(SfxObjectShell* pSource, SfxObjectShell* pDestination)
+{
+ if (!pSource || !pDestination)
+ return;
+
+ uno::Reference<document::XDocumentProperties> xSource = pSource->getDocProperties();
+ uno::Reference<document::XDocumentProperties> xDestination = pDestination->getDocProperties();
+ uno::Reference<beans::XPropertyContainer> xSourcePropertyContainer = xSource->getUserDefinedProperties();
+ uno::Reference<beans::XPropertyContainer> xDestinationPropertyContainer = xDestination->getUserDefinedProperties();
+ uno::Reference<beans::XPropertySet> xSourcePropertySet(xSourcePropertyContainer, uno::UNO_QUERY);
+ uno::Sequence<beans::Property> aProperties = xSourcePropertySet->getPropertySetInfo()->getProperties();
+
+ for (const beans::Property& rProperty : aProperties)
+ {
+ const OUString& rKey = rProperty.Name;
+ uno::Any aValue = xSourcePropertySet->getPropertyValue(rKey);
+ // We know that pDestination was just created, so has no properties: addProperty() will never throw.
+ xDestinationPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aValue);
+ }
+}
+
+}
+
// This method creates a new document (SdDrawDocument) and returns a pointer to
// said document. The drawing engine uses this method to put the document (or
// parts of it) into the clipboard/DragServer.
@@ -481,6 +511,8 @@ SdDrawDocument* SdDrawDocument::AllocSdDrawDocument() const
pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets );
}
+ lcl_copyUserDefinedProperties(GetDocSh(), pNewDocSh);
+
pNewModel->NewOrLoadCompleted( DOC_LOADED ); // loaded from source document
}
else if( mbAllocDocSh )