diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-09-10 09:36:23 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-09-11 09:27:02 +0200 |
commit | 313b8b0db3b68b7938f5cd138c6a226d00a47b67 (patch) | |
tree | b91fd3b443dc6b0d914a032fce96c4d22f6e8cbd | |
parent | cbcfda9b2079ea4ef83b2a42828408b5f70f7692 (diff) |
initial DocumentSettingsSerializer interface impl.
-rw-r--r-- | sd/prj/build.lst | 2 | ||||
-rw-r--r-- | sd/source/ui/unoidl/UnoDocumentSettings.cxx | 32 | ||||
-rw-r--r-- | xmloff/Package_inc.mk | 1 | ||||
-rw-r--r-- | xmloff/inc/xmloff/settingsstore.hxx | 56 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp.cxx | 11 |
6 files changed, 105 insertions, 2 deletions
diff --git a/sd/prj/build.lst b/sd/prj/build.lst index cc8eca8ddc07..e1dc016c5080 100644 --- a/sd/prj/build.lst +++ b/sd/prj/build.lst @@ -1,3 +1,3 @@ -sd sd : filter TRANSLATIONS:translations animations svx sfx2 stoc canvas LIBXSLT:libxslt oox ure test NULL +sd sd : filter TRANSLATIONS:translations animations svx sfx2 stoc canvas LIBXSLT:libxslt oox ure test xmloff NULL sd sd usr1 - all sd_mkout NULL sd sd\prj nmake - all sd_prj NULL diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx index 24c9332e3756..a4aa2b196b63 100644 --- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx +++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx @@ -55,6 +55,7 @@ #include "../inc/ViewShell.hxx" #include "../inc/FrameView.hxx" #include "Outliner.hxx" +#include <xmloff/settingsstore.hxx> #include <editeng/editstat.hxx> #include <svx/unoapi.hxx> @@ -78,7 +79,8 @@ using namespace ::com::sun::star::i18n; namespace sd { class DocumentSettings : public WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >, - public comphelper::PropertySetHelper + public comphelper::PropertySetHelper, + public DocumentSettingsSerializer { public: DocumentSettings( SdXImpressDocument* pModel ); @@ -110,6 +112,14 @@ namespace sd virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); + // DocumentSettingsSerializer cf. xmloff + virtual uno::Sequence<beans::PropertyValue> + filterStreamsFromStorage(const uno::Reference< embed::XStorage > &xStorage, + const uno::Sequence<beans::PropertyValue>& aConfigProps ); + virtual uno::Sequence<beans::PropertyValue> + filterStreamsToStorage(const uno::Reference< embed::XStorage > &xStorage, + const uno::Sequence<beans::PropertyValue>& aConfigProps ); + protected: virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ); virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException ); @@ -279,6 +289,26 @@ void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue, bool * delete pList; } +uno::Sequence<beans::PropertyValue> + DocumentSettings::filterStreamsFromStorage( + const uno::Reference< embed::XStorage > &xStorage, + const uno::Sequence<beans::PropertyValue>& aConfigProps ) +{ + (void) xStorage; +// fprintf( stderr, "filter streams from storage\n" ); + return aConfigProps; +} + +uno::Sequence<beans::PropertyValue> + DocumentSettings::filterStreamsToStorage( + const uno::Reference< embed::XStorage > &xStorage, + const uno::Sequence<beans::PropertyValue>& aConfigProps ) +{ + (void) xStorage; +// fprintf( stderr, "filter streams to storage\n" ); + return aConfigProps; +} + void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ) { ::SolarMutexGuard aGuard; diff --git a/xmloff/Package_inc.mk b/xmloff/Package_inc.mk index 3bcdc39367bf..4c62e7e65a63 100644 --- a/xmloff/Package_inc.mk +++ b/xmloff/Package_inc.mk @@ -85,6 +85,7 @@ $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/numehelp.hxx,xmloff/nume $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/odffields.hxx,xmloff/odffields.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/prhdlfac.hxx,xmloff/prhdlfac.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/prstylei.hxx,xmloff/prstylei.hxx)) +$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/settingsstore.hxx,xmloff/settingsstore.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/shapeexport.hxx,xmloff/shapeexport.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/shapeimport.hxx,xmloff/shapeimport.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/styleexp.hxx,xmloff/styleexp.hxx)) diff --git a/xmloff/inc/xmloff/settingsstore.hxx b/xmloff/inc/xmloff/settingsstore.hxx new file mode 100644 index 000000000000..af9ac084d20f --- /dev/null +++ b/xmloff/inc/xmloff/settingsstore.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Novell, Inc. <michael.meeks@novell.com> (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +// Simple interface to allow serialization of document settings + +#ifndef _XMLOFF_SETTINGS_STORE_HXX +#define _XMLOFF_SETTINGS_STORE_HXX + +#include <vector> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/embed/XStorage.hpp> + +// Scans list of properties for certain URL properties that could refer +// to internal objects, and initializes from these. +class DocumentSettingsSerializer { +public: + // Import objects and update properties (eliding URLs) + virtual com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> + filterStreamsFromStorage( + const com::sun::star::uno::Reference< com::sun::star::embed::XStorage > &xStorage, + const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps ) = 0; + // Export objects and update properties with relative URLs into this storage + virtual com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> + filterStreamsToStorage( + const com::sun::star::uno::Reference< com::sun::star::embed::XStorage > &xStorage, + const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps ) = 0; +}; + +#endif // _XMLOFF_SETTINGS_STORE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index dc6bc8fe73a6..67a007c88d56 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -64,6 +64,7 @@ #include <xmloff/xmlaustp.hxx> #include <xmloff/families.hxx> #include <xmloff/styleexp.hxx> +#include <xmloff/settingsstore.hxx> #include "sdpropls.hxx" #include <xmloff/xmlexppr.hxx> #include <com/sun/star/beans/XPropertyState.hpp> @@ -2654,6 +2655,10 @@ void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& Reference< beans::XPropertySet > xProps( xFac->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), UNO_QUERY ); if( xProps.is() ) SvXMLUnitConverter::convertPropertySet( rProps, xProps ); + DocumentSettingsSerializer *pFilter; + pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get()); + if( pFilter ) + rProps = pFilter->filterStreamsToStorage( GetTargetStorage(), rProps ); } } diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 9da00b9b2eb6..2bc5245c3740 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -50,6 +50,7 @@ #include <xmloff/xmlexppr.hxx> #include "xmloff/xmlerror.hxx" #include <tools/debug.hxx> +#include <xmloff/settingsstore.hxx> #include <com/sun/star/style/XStyle.hpp> #include <xmloff/XMLFontStylesContext.hxx> @@ -925,6 +926,16 @@ void SdXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<c sal_Int32 nCount = aConfigProps.getLength(); const beans::PropertyValue* pValues = aConfigProps.getConstArray(); + DocumentSettingsSerializer *pFilter; + pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get()); + uno::Sequence<beans::PropertyValue> aFiltered; + if( pFilter ) + { + aFiltered = pFilter->filterStreamsFromStorage( GetSourceStorage(), aConfigProps ); + nCount = aFiltered.getLength(); + pValues = aFiltered.getConstArray(); + } + while( nCount-- ) { try |