[Libreoffice-commits] .: 4 commits - comphelper/source framework/source sd/prj sd/source svx/inc svx/source xmloff/inc xmloff/Package_inc.mk xmloff/source
Michael Meeks
michael at kemper.freedesktop.org
Sun Sep 11 00:26:47 PDT 2011
comphelper/source/misc/storagehelper.cxx | 3
framework/source/services/substitutepathvars.cxx | 5
sd/prj/build.lst | 2
sd/source/ui/unoidl/UnoDocumentSettings.cxx | 495 +++++++++++++----------
svx/inc/svx/xtable.hxx | 64 ++
svx/source/inc/xmlxtexp.hxx | 10
svx/source/inc/xmlxtimp.hxx | 5
svx/source/xml/xmlxtexp.cxx | 186 +++++---
svx/source/xml/xmlxtimp.cxx | 126 +++--
svx/source/xoutdev/xtabbtmp.cxx | 11
svx/source/xoutdev/xtabcolr.cxx | 12
svx/source/xoutdev/xtabdash.cxx | 7
svx/source/xoutdev/xtabgrdt.cxx | 8
svx/source/xoutdev/xtabhtch.cxx | 9
svx/source/xoutdev/xtable.cxx | 88 ++--
svx/source/xoutdev/xtablend.cxx | 9
xmloff/Package_inc.mk | 1
xmloff/inc/xmloff/settingsstore.hxx | 56 ++
xmloff/source/draw/sdxmlexp.cxx | 5
xmloff/source/draw/sdxmlimp.cxx | 11
20 files changed, 696 insertions(+), 417 deletions(-)
New commits:
commit 59b36fc62e21cce62fd63f0dcc79ff9cb66b35b8
Author: Michael Meeks <michael.meeks at novell.com>
Date: Sun Sep 11 09:19:40 2011 +0200
Don't let the PathSubstitution service null relative paths
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index bded3d5..afcd1e0 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -1007,7 +1007,6 @@ throw ( NoSuchElementException, RuntimeException )
rtl::OUString SubstitutePathVariables::impl_reSubstituteVariables( const ::rtl::OUString& rURL )
throw ( RuntimeException )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen at sun.com", "SubstitutePathVariables::impl_reSubstituteVariables" );
rtl::OUString aURL;
INetURLObject aUrl( rURL );
@@ -1021,7 +1020,11 @@ throw ( RuntimeException )
{
aTemp = ConvertOSLtoUCBURL( aTemp );
if ( aTemp.getLength() )
+ {
aURL = INetURLObject( aTemp ).GetMainURL( INetURLObject::NO_DECODE );
+ if( !aURL.getLength() )
+ return rURL;
+ }
else
return rURL;
}
commit 0f690c3495fe66b22aa224ca229ca7b46941deac
Author: Michael Meeks <michael.meeks at novell.com>
Date: Sat Sep 10 14:47:28 2011 +0100
Initial DocumentSettingsSerializer implementation
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 7e8bdec..2684d94 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -593,8 +593,9 @@ uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
splitPath( aElems, rPath );
rtl::OUString aName( aElems.back() );
aElems.pop_back();
+ sal_uInt32 nStorageMode = nOpenMode & ~embed::ElementModes::TRUNCATE;
uno::Reference< embed::XStorage > xStorage(
- LookupStorageAtPath( xParentStorage, aElems, nOpenMode, rNastiness ),
+ LookupStorageAtPath( xParentStorage, aElems, nStorageMode, rNastiness ),
uno::UNO_QUERY_THROW );
return xStorage->openStreamElement( aName, nOpenMode );
}
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index a4aa2b1..ffd645e 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -31,6 +31,8 @@
#include <vector>
#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
@@ -125,6 +127,8 @@ namespace sd
virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
private:
+ bool LoadList( XPropertyListType t, const rtl::OUString &rPath,
+ const uno::Reference< embed::XStorage > &xStorage );
void AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged );
void ExtractURL( XPropertyListType t, Any* pValue );
Reference< XModel > mxModel;
@@ -233,7 +237,7 @@ DocumentSettings::~DocumentSettings() throw()
{
}
-static bool SetPropertyList( SdDrawDocument *pDoc, XPropertyListType t, XPropertyList *pList )
+static inline bool SetPropertyList( SdDrawDocument *pDoc, XPropertyListType t, XPropertyList *pList )
{
switch (t) {
case XCOLOR_LIST: pDoc->SetColorTable( static_cast<XColorList *>(pList) ); break;
@@ -248,7 +252,7 @@ static bool SetPropertyList( SdDrawDocument *pDoc, XPropertyListType t, XPropert
return true;
}
-static XPropertyList *GetPropertyList( SdDrawDocument *pDoc, XPropertyListType t)
+static inline XPropertyList *GetPropertyList( SdDrawDocument *pDoc, XPropertyListType t)
{
switch (t) {
case XCOLOR_LIST: return pDoc->GetColorTable();
@@ -262,31 +266,73 @@ static XPropertyList *GetPropertyList( SdDrawDocument *pDoc, XPropertyListType t
}
}
-void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged )
+bool DocumentSettings::LoadList( XPropertyListType t, const rtl::OUString &rInPath,
+ const uno::Reference< embed::XStorage > &xStorage )
{
- OUString aURL;
- if( !(bool)( *pValue >>= aURL ) )
- return;
-
SdDrawDocument* pDoc = mpModel->GetDoc();
- sal_Int32 nSlash = aURL.lastIndexOf('/');
+ sal_Int32 nSlash = rInPath.lastIndexOf('/');
rtl::OUString aPath, aName;
if (nSlash < -1)
- aName = aURL;
+ aName = rInPath;
else {
- aName = aURL.copy( nSlash + 1 );
- aPath = aURL.copy( 0, nSlash );
+ aName = rInPath.copy( nSlash + 1 );
+ aPath = rInPath.copy( 0, nSlash );
}
XPropertyList *pList = XPropertyList::CreatePropertyList(
t, aPath, (XOutdevItemPool*)&pDoc->GetPool() );
pList->SetName( aName );
- if( pList->Load() )
- *pOk = *pChanged = SetPropertyList( pDoc, t, pList );
+ if( pList->LoadFrom( xStorage, rInPath ) )
+ return SetPropertyList( pDoc, t, pList );
else
delete pList;
+
+ return false;
+}
+
+void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue,
+ bool *pOk, bool *pChanged )
+{
+ OUString aURL;
+ if( !(bool)( *pValue >>= aURL ) )
+ return;
+
+ if( LoadList( t, aURL, uno::Reference< embed::XStorage >() ) )
+ *pOk = *pChanged = true;
+}
+
+static struct {
+ const char *pName;
+ XPropertyListType t;
+} aURLPropertyNames[] = {
+ { "ColorTableURL", XCOLOR_LIST },
+ { "DashTableURL", XDASH_LIST },
+ { "LineEndTableURL", XLINE_END_LIST },
+ { "HatchTableURL", XHATCH_LIST },
+ { "GradientTableURL", XGRADIENT_LIST },
+ { "BitmapTableURL", XBITMAP_LIST }
+};
+
+static XPropertyListType getTypeOfName( const rtl::OUString &aName )
+{
+ for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
+ if( aName.equalsAscii( aURLPropertyNames[i].pName ) )
+ return aURLPropertyNames[i].t;
+ }
+ return (XPropertyListType) -1;
+}
+
+static rtl::OUString getNameOfType( XPropertyListType t )
+{
+ for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
+ if( t == aURLPropertyNames[i].t )
+ return rtl::OUString( aURLPropertyNames[i].pName,
+ strlen( aURLPropertyNames[i].pName ) - 3,
+ RTL_TEXTENCODING_UTF8 );
+ }
+ return rtl::OUString();
}
uno::Sequence<beans::PropertyValue>
@@ -294,9 +340,22 @@ uno::Sequence<beans::PropertyValue>
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> aRet( aConfigProps.getLength() );
+ int nRet = 0;
+ for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
+ {
+ XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
+ if (t < 0)
+ aRet[nRet++] = aConfigProps[i];
+ else
+ {
+ rtl::OUString aURL;
+ aConfigProps[i].Value >>= aURL;
+ LoadList( t, aURL, xStorage );
+ }
+ }
+ aRet.realloc( nRet );
+ return aRet;
}
uno::Sequence<beans::PropertyValue>
@@ -304,9 +363,70 @@ uno::Sequence<beans::PropertyValue>
const uno::Reference< embed::XStorage > &xStorage,
const uno::Sequence<beans::PropertyValue>& aConfigProps )
{
- (void) xStorage;
-// fprintf( stderr, "filter streams to storage\n" );
- return aConfigProps;
+ uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
+
+ bool bHasEmbed = false;
+ SdDrawDocument* pDoc = mpModel->GetDoc();
+ for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ )
+ {
+ XPropertyListType t = (XPropertyListType) i;
+ XPropertyList *pList = GetPropertyList( pDoc, t );
+ if( ( bHasEmbed = pList && pList->IsEmbedInDocument() ) )
+ break;
+ }
+ if( !bHasEmbed )
+ return aConfigProps;
+
+ try {
+ // create Settings/ sub storage.
+ uno::Reference< embed::XStorage > xSubStorage;
+ xSubStorage = xStorage->openStorageElement(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings" ) ),
+ embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
+ if( !xSubStorage.is() )
+ return aRet;
+
+ // now populate it
+ for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
+ {
+ XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
+ aRet[i] = aConfigProps[i];
+ if (t >= 0) {
+ XPropertyList *pList = GetPropertyList( pDoc, t );
+ if( !pList || !pList->IsEmbedInDocument() )
+ continue; // no change ...
+ else
+ {
+ // Such specific path construction is grim.
+ rtl::OUString aValue;
+ aRet[i].Value >>= aValue;
+
+ rtl::OUStringBuffer aName( getNameOfType( t ) );
+ rtl::OUString aResult;
+ if( pList->SaveTo( xSubStorage, aName.makeStringAndClear(), &aResult ) )
+ {
+ rtl::OUString aRealPath( RTL_CONSTASCII_USTRINGPARAM( "Settings/" ) );
+ aRealPath += aResult;
+ aRet[i].Value <<= aRealPath;
+ }
+ }
+ }
+ }
+
+ // surprisingly difficult to make it really exist
+ uno::Reference< embed::XTransactedObject > xTrans( xSubStorage, UNO_QUERY );
+ if( xTrans.is() )
+ xTrans->commit();
+ uno::Reference< lang::XComponent > xComp( xSubStorage, UNO_QUERY );
+ if( xComp.is() )
+ xSubStorage->dispose();
+ } catch (const uno::Exception &e) {
+ (void)e;
+// fprintf (stderr, "saving etc. exception '%s'\n",
+// rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
+ }
+
+ return aRet;
}
void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
diff --git a/svx/inc/svx/xtable.hxx b/svx/inc/svx/xtable.hxx
index 79bdfbe..00c0cb4 100644
--- a/svx/inc/svx/xtable.hxx
+++ b/svx/inc/svx/xtable.hxx
@@ -43,6 +43,7 @@
#include <tools/table.hxx>
#include "svx/svxdllapi.h"
+#include <com/sun/star/embed/XStorage.hpp>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -215,9 +216,10 @@ protected:
XPropertyEntryList_impl aList;
BitmapList_impl* pBmpList;
- sal_Bool bListDirty;
- sal_Bool bBitmapsDirty;
- sal_Bool bOwnPool;
+ bool bListDirty;
+ bool bBitmapsDirty;
+ bool bOwnPool;
+ bool bEmbedInDocument;
XPropertyList( XPropertyListType t,
const char *pDefaultExtension,
@@ -248,11 +250,20 @@ public:
sal_Bool IsDirty() const { return bListDirty && bBitmapsDirty; }
void SetDirty( sal_Bool bDirty = sal_True )
{ bListDirty = bDirty; bBitmapsDirty = bDirty; }
+ bool IsEmbedInDocument() const { return bEmbedInDocument; }
+ void SetEmbedInDocument(bool b) { bEmbedInDocument = b; }
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
createInstance() = 0;
- sal_Bool Load();
- sal_Bool Save();
+ bool Load();
+ bool LoadFrom( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::embed::XStorage > &xStorage,
+ const rtl::OUString &rURL );
+ bool Save();
+ bool SaveTo ( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::embed::XStorage > &xStorage,
+ const rtl::OUString &rURL,
+ rtl::OUString *pOptName );
virtual sal_Bool Create() = 0;
virtual sal_Bool CreateBitmapsForUI() = 0;
virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True ) = 0;
diff --git a/svx/source/inc/xmlxtexp.hxx b/svx/source/inc/xmlxtexp.hxx
index 703454d..d2f01a0 100644
--- a/svx/source/inc/xmlxtexp.hxx
+++ b/svx/source/inc/xmlxtexp.hxx
@@ -54,9 +54,12 @@ public:
~SvxXMLXTableExportComponent();
- static sal_Bool save( const rtl::OUString& rURL, const com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xTable ) throw();
-
- sal_Bool exportTable() throw();
+ static bool save( const rtl::OUString& rURL,
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer >& xTable,
+ const ::com::sun::star::uno::Reference <
+ ::com::sun::star::embed::XStorage > &xStorage,
+ rtl::OUString *pOptName ) throw();
// methods without content:
virtual void _ExportAutoStyles();
@@ -64,6 +67,7 @@ public:
virtual void _ExportContent();
private:
+ bool exportTable() throw();
const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > & mxTable;
};
diff --git a/svx/source/inc/xmlxtimp.hxx b/svx/source/inc/xmlxtimp.hxx
index d57680f..463f2d5 100644
--- a/svx/source/inc/xmlxtimp.hxx
+++ b/svx/source/inc/xmlxtimp.hxx
@@ -51,7 +51,10 @@ public:
virtual ~SvxXMLXTableImport() throw ();
- static sal_Bool load( const rtl::OUString& rUrl, const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xTable ) throw();
+ static bool load( const rtl::OUString &rPath,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage > &xStorage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xTable,
+ bool *bOptLoadedFromStorage ) throw();
protected:
virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
const ::rtl::OUString& rLocalName,
diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
index 7f01b78..4e61362 100644
--- a/svx/source/xml/xmlxtexp.cxx
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -29,6 +29,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
#include <tools/debug.hxx>
+#include <tools/urlobj.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/uno/Sequence.hxx>
@@ -179,101 +180,168 @@ SvxXMLXTableExportComponent::~SvxXMLXTableExportComponent()
{
}
-sal_Bool SvxXMLXTableExportComponent::save( const OUString& rURL, const uno::Reference<container::XNameContainer >& xTable ) throw()
+static void initializeStreamMetadata( const uno::Reference< uno::XInterface > &xOut )
{
- uno::Reference < embed::XStorage > xStorage;
- SfxMedium* pMedium = NULL;
- sal_Bool bRet = sal_False;
-
- uno::Reference< XGraphicObjectResolver > xGrfResolver;
- SvXMLGraphicHelper* pGraphicHelper = 0;
+ uno::Reference< beans::XPropertySet > xProps( xOut, uno::UNO_QUERY );
+ if( !xProps.is() )
+ {
+ OSL_FAIL( "Missing stream metadata interface" );
+ return;
+ }
try
{
- do
- {
- uno::Reference < io::XOutputStream > xOut;
- uno::Reference < io::XStream > xStream;
+ xProps->setPropertyValue(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
+ uno::makeAny( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/xml" ) ) ) );
+
+ // use stock encryption
+ xProps->setPropertyValue(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) ),
+ uno::makeAny( sal_True ) );
+ } catch ( const uno::Exception & )
+ {
+ OSL_FAIL( "exception setting stream metadata" );
+ }
+}
- sal_Bool bNeedStorage = xTable->getElementType() == ::getCppuType((const OUString*)0);
+static void createStorageStream( uno::Reference < io::XOutputStream > *xOut,
+ SvXMLGraphicHelper **ppGraphicHelper,
+ uno::Reference < embed::XStorage > xSubStorage )
+{
+ uno::Reference < io::XStream > xStream;
+ xStream = xSubStorage->openStreamElement(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) ),
+ embed::ElementModes::WRITE );
+ *ppGraphicHelper = SvXMLGraphicHelper::Create( xSubStorage, GRAPHICHELPER_MODE_WRITE );
+ initializeStreamMetadata( xStream );
+ *xOut = xStream->getOutputStream();
+}
- uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
- if( !xServiceFactory.is() )
- {
- OSL_FAIL( "got no service manager" );
- return sal_False;
- }
+bool SvxXMLXTableExportComponent::save(
+ const OUString& rURL,
+ const uno::Reference<container::XNameContainer >& xTable,
+ const uno::Reference<embed::XStorage >& xStorage,
+ rtl::OUString *pOptName ) throw()
+{
+ bool bRet = false;
+ SfxMedium* pMedium = NULL;
+ SvXMLGraphicHelper* pGraphicHelper = NULL;
+ sal_Int32 eCreate = embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE;
- uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) );
- if( !xWriter.is() )
- {
- OSL_FAIL( "com.sun.star.xml.sax.Writer service missing" );
- return sal_False;
- }
+ INetURLObject aURLObj( rURL );
+ bool bToStorage = aURLObj.GetProtocol() == INET_PROT_NOT_VALID; // a relative path
- uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY );
+ sal_Bool bSaveAsStorage = xTable->getElementType() == ::getCppuType((const OUString*)0);
- if( bNeedStorage )
- {
- xStorage =
- ::comphelper::OStorageHelper::GetStorageFromURL( rURL, embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
+ if( pOptName )
+ *pOptName = rURL;
- if( !xStorage.is() )
- {
- OSL_FAIL( "no storage!" );
- break;
- }
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
+ if( !xServiceFactory.is() )
+ {
+ OSL_FAIL( "got no service manager" );
+ return false;
+ }
- OUString sMetaName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
- xStream = xStorage->openStreamElement( sMetaName, embed::ElementModes::WRITE );
- pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_WRITE );
- xGrfResolver = pGraphicHelper;
- xOut = xStream->getOutputStream();
- }
+ uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) );
+ if( !xWriter.is() )
+ {
+ OSL_FAIL( "com.sun.star.xml.sax.Writer service missing" );
+ return false;
+ }
+
+ uno::Reference < io::XStream > xStream;
+ uno::Reference < io::XOutputStream > xOut;
+ uno::Reference<embed::XStorage > xSubStorage;
+ uno::Reference< XGraphicObjectResolver > xGrfResolver;
+
+ uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY );
+
+ if( !bToStorage || !xStorage.is() )
+ { // local URL -> SfxMedium route
+ if( bSaveAsStorage )
+ xSubStorage = ::comphelper::OStorageHelper::GetStorageFromURL( rURL, eCreate );
else
{
pMedium = new SfxMedium( rURL, STREAM_WRITE | STREAM_TRUNC, sal_True );
pMedium->IsRemote();
SvStream* pStream = pMedium->GetOutStream();
- if( NULL == pStream )
+ if( !pStream )
{
OSL_FAIL( "no output stream!" );
- break;
+ return false;
}
xOut = new utl::OOutputStreamWrapper( *pStream );
}
+ }
+ else // save into the xSubStorage
+ {
+ rtl::OUString aPath = rURL;
- uno::Reference<io::XActiveDataSource> xMetaSrc( xWriter, uno::UNO_QUERY );
- xMetaSrc->setOutputStream( xOut );
-
- const OUString aName;
+ if( bSaveAsStorage )
+ {
+ try {
+ xSubStorage = xStorage->openStorageElement( aPath, eCreate );
+ } catch (uno::Exception &e) {
+ OSL_FAIL( "no output storage!" );
+ return false;
+ }
+ }
+ else
+ {
+ aPath += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".xml" ) );
+ try {
+ xStream = xStorage->openStreamElement( aPath, eCreate );
+ if( !xStream.is() )
+ return false;
+ initializeStreamMetadata( xStream );
+ xOut = xStream->getOutputStream();
+ } catch (uno::Exception &e) {
+ OSL_FAIL( "no output stream!" );
+ return false;
+ }
+ if( pOptName )
+ *pOptName = aPath;
+ }
+ }
- SvxXMLXTableExportComponent aExporter( xServiceFactory, aName, xHandler, xTable, xGrfResolver );
+ if( !xOut.is() && xSubStorage.is() )
+ createStorageStream( &xOut, &pGraphicHelper, xSubStorage );
+ if( !xOut.is() )
+ return false;
- bRet = aExporter.exportTable();
+ uno::Reference<io::XActiveDataSource> xMetaSrc( xWriter, uno::UNO_QUERY );
+ xMetaSrc->setOutputStream( xOut );
+ if( pGraphicHelper )
+ xGrfResolver = pGraphicHelper;
- }
- while( 0 );
+ // Finally do the export
+ const OUString aName;
+ SvxXMLXTableExportComponent aExporter( xServiceFactory, aName, xHandler, xTable, xGrfResolver );
+ bRet = aExporter.exportTable();
if( pGraphicHelper )
SvXMLGraphicHelper::Destroy( pGraphicHelper );
- if( xStorage.is() )
+ if( xSubStorage.is() )
{
- uno::Reference< XTransactedObject > xTrans( xStorage, UNO_QUERY );
+ uno::Reference< XTransactedObject > xTrans( xSubStorage, UNO_QUERY );
if( xTrans.is() )
xTrans->commit();
- uno::Reference< XComponent > xComp( xStorage, UNO_QUERY );
+ uno::Reference< XComponent > xComp( xSubStorage, UNO_QUERY );
if( xComp.is() )
- xStorage->dispose();
+ xSubStorage->dispose();
}
}
catch( uno::Exception& )
{
- bRet = sal_False;
+ bRet = false;
}
if( pMedium )
@@ -285,9 +353,9 @@ sal_Bool SvxXMLXTableExportComponent::save( const OUString& rURL, const uno::Ref
return bRet;
}
-sal_Bool SvxXMLXTableExportComponent::exportTable() throw()
+bool SvxXMLXTableExportComponent::exportTable() throw()
{
- sal_Bool bRet = sal_False;
+ bool bRet = false;
try
{
@@ -362,7 +430,7 @@ sal_Bool SvxXMLXTableExportComponent::exportTable() throw()
pExporter->exportEntry( *pNames, aAny );
}
- bRet = sal_True;
+ bRet = true;
}
while(0);
@@ -370,7 +438,7 @@ sal_Bool SvxXMLXTableExportComponent::exportTable() throw()
}
catch( Exception const& )
{
- bRet = sal_False;
+ bRet = false;
}
return bRet;
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index 2b1304d..a276d0b 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -29,6 +29,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
#include <tools/debug.hxx>
+#include <tools/urlobj.hxx>
#include <com/sun/star/document/XGraphicObjectResolver.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/io/XActiveDataControl.hpp>
@@ -44,6 +45,7 @@
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XSeekable.hdl>
#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
#include <unotools/streamwrap.hxx>
#include <rtl/ustrbuf.hxx>
#include <sfx2/docfile.hxx>
@@ -361,82 +363,108 @@ SvxXMLXTableImport::~SvxXMLXTableImport() throw ()
{
}
-sal_Bool SvxXMLXTableImport::load( const OUString& rUrl, const uno::Reference< XNameContainer >& xTable ) throw()
+static void openStorageStream( xml::sax::InputSource *pParserInput,
+ SvXMLGraphicHelper **ppGraphicHelper,
+ uno::Reference < embed::XStorage > xStorage )
{
- sal_Bool bRet = sal_True;
+ uno::Reference < io::XStream > xIStm;
+ const String aContentStmName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
+ xIStm.set( xStorage->openStreamElement( aContentStmName, embed::ElementModes::READ ), uno::UNO_QUERY_THROW );
+ if( !xIStm.is() )
+ {
+ OSL_FAIL( "could not open Content stream" );
+ return;
+ }
+ pParserInput->aInputStream = xIStm->getInputStream();
+ *ppGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
+}
- uno::Reference< XGraphicObjectResolver > xGrfResolver;
+bool SvxXMLXTableImport::load( const rtl::OUString &rPath,
+ const uno::Reference < embed::XStorage > &xStorage,
+ const uno::Reference< XNameContainer >& xTable,
+ bool *bOptLoadedFromStorage ) throw()
+{
+ bool bRet = true;
SvXMLGraphicHelper* pGraphicHelper = 0;
+ INetURLObject aURLObj( rPath );
+ bool bUseStorage = aURLObj.GetProtocol() == INET_PROT_NOT_VALID; // a relative path
+
try
{
- do
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
+ if( !xServiceFactory.is() )
{
- SfxMedium aMedium( rUrl, STREAM_READ | STREAM_NOCREATE, sal_True );
+ OSL_FAIL( "SvxXMLXTableImport::load: got no service manager" );
+ return false;
+ }
- uno::Reference<lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
- if( !xServiceFactory.is() )
- {
- OSL_FAIL( "SvxXMLXTableImport::load: got no service manager" );
- break;
- }
+ uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY_THROW );
- uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY_THROW );
- uno::Reference < io::XStream > xIStm;
- uno::Reference< io::XActiveDataSource > xSource;
+ xml::sax::InputSource aParserInput;
+ comphelper::OStorageHelper::LifecycleProxy aNasty;
- xml::sax::InputSource aParserInput;
+ if( !bUseStorage || !xStorage.is() )
+ {
+ SfxMedium aMedium( rPath, STREAM_READ | STREAM_NOCREATE, sal_True );
aParserInput.sSystemId = aMedium.GetName();
if( aMedium.IsStorage() )
{
- uno::Reference < embed::XStorage > xStorage( aMedium.GetStorage( sal_False ), uno::UNO_QUERY_THROW );
-
- const String aContentStmName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
- xIStm.set( xStorage->openStreamElement( aContentStmName, embed::ElementModes::READ ), uno::UNO_QUERY_THROW );
- if( !xIStm.is() )
- {
- OSL_FAIL( "could not open Content stream" );
- break;
- }
-
- aParserInput.aInputStream = xIStm->getInputStream();
- pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
- xGrfResolver = pGraphicHelper;
+ uno::Reference < embed::XStorage > xMediumStorage( aMedium.GetStorage( sal_False ), uno::UNO_QUERY_THROW );
+ openStorageStream( &aParserInput, &pGraphicHelper, xMediumStorage );
}
else
- {
aParserInput.aInputStream = aMedium.GetInputStream();
- uno::Reference< io::XSeekable > xSeek( aParserInput.aInputStream, uno::UNO_QUERY_THROW );
- xSeek->seek( 0 );
+ }
+ else // relative URL into a storage
+ {
+ uno::Reference< embed::XStorage > xSubStorage;
+ try {
+ xSubStorage = comphelper::OStorageHelper::GetStorageAtPath(
+ xStorage, rPath, embed::ElementModes::READ, aNasty );
+ } catch (uno::Exception &e) {
}
-
- if( xSource.is() )
+ if( xSubStorage.is() )
+ openStorageStream( &aParserInput, &pGraphicHelper, xSubStorage );
+ else
{
- uno::Reference< io::XActiveDataControl > xSourceControl( xSource, UNO_QUERY_THROW );
- xSourceControl->start();
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xStream;
+ xStream = comphelper::OStorageHelper::GetStreamAtPath(
+ xStorage, rPath, embed::ElementModes::READ, aNasty );
+ if( !xStream.is() )
+ return false;
+ aParserInput.aInputStream = xStream->getInputStream();
}
+ if( bOptLoadedFromStorage )
+ *bOptLoadedFromStorage = true;
+ }
- // #110680#
- // uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTableImport( xTable, xGrfResolver ) );
- uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTableImport( xServiceFactory, xTable, xGrfResolver ) );
+ uno::Reference< XGraphicObjectResolver > xGrfResolver;
+ if (pGraphicHelper)
+ xGrfResolver = pGraphicHelper;
- xParser->setDocumentHandler( xHandler );
- xParser->parseStream( aParserInput );
- }
- while(0);
+ try {
+ uno::Reference< io::XSeekable > xSeek( aParserInput.aInputStream, uno::UNO_QUERY_THROW );
+ xSeek->seek( 0 );
+ } catch( uno::Exception &) {}
+
+ uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTableImport( xServiceFactory, xTable, xGrfResolver ) );
+ xParser->setDocumentHandler( xHandler );
+ xParser->parseStream( aParserInput );
if( pGraphicHelper )
SvXMLGraphicHelper::Destroy( pGraphicHelper );
}
- catch( uno::Exception& )
+ catch( uno::Exception& e )
{
-// CL: I disabled this assertion since its an error, but it happens
-// each time you load a document with property tables that are not
-// on the current machine. Maybe a better fix would be to place
-// a file exists check before importing...
-// OSL_FAIL("svx::SvxXMLXTableImport::load(), exception caught!");
- bRet = sal_False;
+ (void)e;
+// thrown each time you load a document with property tables that are not
+// on the current machine. FIXME: would be better to check a file exists
+// before importing ...
+ fprintf (stderr, "parsing etc. exception '%s'\n",
+ rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
+ bRet = false;
}
return bRet;
diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx
index a95663b..8418560 100644
--- a/svx/source/xoutdev/xtable.cxx
+++ b/svx/source/xoutdev/xtable.cxx
@@ -57,13 +57,14 @@ XPropertyList::XPropertyList(
pXPool ( pInPool ),
pDefaultExt ( pDefaultExtension ),
pBmpList ( NULL ),
- bListDirty ( sal_True ),
- bBitmapsDirty ( sal_True ),
- bOwnPool ( sal_False )
+ bListDirty ( true ),
+ bBitmapsDirty ( true ),
+ bOwnPool ( false ),
+ bEmbedInDocument( false )
{
if( !pXPool )
{
- bOwnPool = sal_True;
+ bOwnPool = true;
pXPool = new XOutdevItemPool;
DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" );
}
@@ -149,7 +150,7 @@ Bitmap* XPropertyList::GetBitmap( long nIndex ) const
{
if( bBitmapsDirty )
{
- ( (XPropertyList*) this )->bBitmapsDirty = sal_False;
+ ( (XPropertyList*) this )->bBitmapsDirty = false;
( (XPropertyList*) this )->CreateBitmapsForUI();
}
if( (size_t)nIndex < pBmpList->size() )
@@ -228,18 +229,18 @@ void XPropertyList::SetName( const String& rString )
}
}
-sal_Bool XPropertyList::Load()
+bool XPropertyList::Load()
{
if( bListDirty )
{
- bListDirty = sal_False;
+ bListDirty = false;
INetURLObject aURL( aPath );
if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
{
DBG_ASSERT( !aPath.Len(), "invalid URL" );
- return sal_False;
+ return false;
}
aURL.Append( aName );
@@ -247,20 +248,31 @@ sal_Bool XPropertyList::Load()
if( !aURL.getExtension().getLength() )
aURL.setExtension( rtl::OUString::createFromAscii( pDefaultExt ) );
- return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), createInstance() );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ),
+ uno::Reference < embed::XStorage >(),
+ createInstance(), NULL );
}
- return sal_False;
+ return false;
}
-sal_Bool XPropertyList::Save()
+bool XPropertyList::LoadFrom( const uno::Reference < embed::XStorage > &xStorage,
+ const rtl::OUString &rURL )
+{
+ if( !bListDirty )
+ return false;
+ bListDirty = false;
+ return SvxXMLXTableImport::load( rURL, xStorage, createInstance(), &bEmbedInDocument );
+}
+
+bool XPropertyList::Save()
{
INetURLObject aURL( aPath );
if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
{
DBG_ASSERT( !aPath.Len(), "invalid URL" );
- return sal_False;
+ return false;
}
aURL.Append( aName );
@@ -268,7 +280,15 @@ sal_Bool XPropertyList::Save()
if( !aURL.getExtension().getLength() )
aURL.setExtension( rtl::OUString::createFromAscii( pDefaultExt ) );
- return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), createInstance() );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ),
+ createInstance(),
+ uno::Reference< embed::XStorage >(), NULL );
+}
+
+bool XPropertyList::SaveTo( const uno::Reference< embed::XStorage > &xStorage,
+ const rtl::OUString &rURL, rtl::OUString *pOptName )
+{
+ return SvxXMLXTableExportComponent::save( rURL, createInstance(), xStorage, pOptName );
}
XPropertyList *XPropertyList::CreatePropertyList( XPropertyListType t,
commit 313b8b0db3b68b7938f5cd138c6a226d00a47b67
Author: Michael Meeks <michael.meeks at novell.com>
Date: Sat Sep 10 09:36:23 2011 +0100
initial DocumentSettingsSerializer interface impl.
diff --git a/sd/prj/build.lst b/sd/prj/build.lst
index cc8eca8..e1dc016 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 24c9332..a4aa2b1 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 3bcdc39..4c62e7e 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 0000000..af9ac08
--- /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 at 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 dc6bc8f..67a007c 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 9da00b9..2bc5245 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
commit cbcfda9b2079ea4ef83b2a42828408b5f70f7692
Author: Michael Meeks <michael.meeks at novell.com>
Date: Mon Sep 5 17:22:24 2011 +0100
add XPropertyList enum, factory, and associated cleanup
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index b09c4c4..24c9332 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -30,6 +30,7 @@
#include "precompiled_sd.hxx"
#include <vector>
+#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
@@ -98,7 +99,6 @@ namespace sd
virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
// XMultiPropertySet
- // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
@@ -115,6 +115,8 @@ namespace sd
virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
private:
+ void AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged );
+ void ExtractURL( XPropertyListType t, Any* pValue );
Reference< XModel > mxModel;
SdXImpressDocument* mpModel;
};
@@ -221,6 +223,62 @@ DocumentSettings::~DocumentSettings() throw()
{
}
+static bool SetPropertyList( SdDrawDocument *pDoc, XPropertyListType t, XPropertyList *pList )
+{
+ switch (t) {
+ case XCOLOR_LIST: pDoc->SetColorTable( static_cast<XColorList *>(pList) ); break;
+ case XDASH_LIST: pDoc->SetDashList( static_cast<XDashList *>(pList) ); break;
+ case XLINE_END_LIST: pDoc->SetLineEndList( static_cast<XLineEndList *>(pList) ); break;
+ case XHATCH_LIST: pDoc->SetHatchList( static_cast<XHatchList *>(pList) ); break;
+ case XGRADIENT_LIST: pDoc->SetGradientList( static_cast<XGradientList *>(pList) ); break;
+ case XBITMAP_LIST: pDoc->SetBitmapList( static_cast<XBitmapList *>(pList) ); break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+static XPropertyList *GetPropertyList( SdDrawDocument *pDoc, XPropertyListType t)
+{
+ switch (t) {
+ case XCOLOR_LIST: return pDoc->GetColorTable();
+ case XDASH_LIST: return pDoc->GetDashList();
+ case XLINE_END_LIST: return pDoc->GetLineEndList();
+ case XHATCH_LIST: return pDoc->GetHatchList();
+ case XGRADIENT_LIST: return pDoc->GetGradientList();
+ case XBITMAP_LIST: return pDoc->GetBitmapList();
+ default:
+ return NULL;
+ }
+}
+
+void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged )
+{
+ OUString aURL;
+ if( !(bool)( *pValue >>= aURL ) )
+ return;
+
+ SdDrawDocument* pDoc = mpModel->GetDoc();
+
+ sal_Int32 nSlash = aURL.lastIndexOf('/');
+ rtl::OUString aPath, aName;
+ if (nSlash < -1)
+ aName = aURL;
+ else {
+ aName = aURL.copy( nSlash + 1 );
+ aPath = aURL.copy( 0, nSlash );
+ }
+
+ XPropertyList *pList = XPropertyList::CreatePropertyList(
+ t, aPath, (XOutdevItemPool*)&pDoc->GetPool() );
+ pList->SetName( aName );
+
+ if( pList->Load() )
+ *pOk = *pChanged = SetPropertyList( pDoc, t, pList );
+ else
+ delete pList;
+}
+
void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
{
::SolarMutexGuard aGuard;
@@ -230,7 +288,8 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
if( NULL == pDoc || NULL == pDocSh )
throw UnknownPropertyException();
- sal_Bool bOk, bChanged = sal_False, bValue = sal_False, bOptionsChanged = false;
+ sal_Bool bValue = sal_False;
+ bool bOk, bChanged = false, bOptionsChanged = false;
SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
@@ -249,147 +308,38 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
for( ; *ppEntries; ppEntries++, pValues++ )
{
- bOk = sal_False;
+ bOk = false;
switch( (*ppEntries)->mnHandle )
{
case HANDLE_COLORTABLEURL:
- {
- OUString aURLString;
- if( *pValues >>= aURLString )
- {
- INetURLObject aURL( aURLString );
- INetURLObject aPathURL( aURL );
-
- aPathURL.removeSegment();
- aPathURL.removeFinalSlash();
-
- XColorList* pColTab = new XColorList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), (XOutdevItemPool*)&pDoc->GetPool() );
- pColTab->SetName( aURL.getName() );
- if( pColTab->Load() )
- {
- pDoc->SetColorTable( pColTab );
- bOk = sal_True;
- bChanged = sal_True;
- }
- }
- }
+ AssignURL( XCOLOR_LIST, pValues, &bOk, &bChanged );
break;
- case HANDLE_DASHTABLEURL:
- {
- OUString aURLString;
- if( *pValues >>= aURLString )
- {
- INetURLObject aURL( aURLString );
- INetURLObject aPathURL( aURL );
- aPathURL.removeSegment();
- aPathURL.removeFinalSlash();
-
- XDashList* pDashTab = new XDashList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), (XOutdevItemPool*)&pDoc->GetPool() );
- pDashTab->SetName( aURL.getName() );
- if( pDashTab->Load() )
- {
- pDoc->SetDashList( pDashTab );
- bOk = sal_True;
- bChanged = sal_True;
- }
- }
- }
+ case HANDLE_DASHTABLEURL:
+ AssignURL( XDASH_LIST, pValues, &bOk, &bChanged );
break;
- case HANDLE_LINEENDTABLEURL:
- {
- OUString aURLString;
- if( *pValues >>= aURLString )
- {
- INetURLObject aURL( aURLString );
- INetURLObject aPathURL( aURL );
- aPathURL.removeSegment();
- aPathURL.removeFinalSlash();
-
- XLineEndList* pTab = new XLineEndList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), (XOutdevItemPool*)&pDoc->GetPool() );
- pTab->SetName( aURL.getName() );
- if( pTab->Load() )
- {
- pDoc->SetLineEndList( pTab );
- bOk = sal_True;
- bChanged = sal_True;
- }
- }
- }
+ case HANDLE_LINEENDTABLEURL:
+ AssignURL( XLINE_END_LIST, pValues, &bOk, &bChanged );
break;
- case HANDLE_HATCHTABLEURL:
- {
- OUString aURLString;
- if( *pValues >>= aURLString )
- {
- INetURLObject aURL( aURLString );
- INetURLObject aPathURL( aURL );
-
- aPathURL.removeSegment();
- aPathURL.removeFinalSlash();
- XHatchList* pTab = new XHatchList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), (XOutdevItemPool*)&pDoc->GetPool() );
- pTab->SetName( aURL.getName() );
- if( pTab->Load() )
- {
- pDoc->SetHatchList( pTab );
- bOk = sal_True;
- bChanged = sal_True;
- }
- }
- }
+ case HANDLE_HATCHTABLEURL:
+ AssignURL( XHATCH_LIST, pValues, &bOk, &bChanged );
break;
- case HANDLE_GRADIENTTABLEURL:
- {
- OUString aURLString;
- if( *pValues >>= aURLString )
- {
- INetURLObject aURL( aURLString );
- INetURLObject aPathURL( aURL );
-
- aPathURL.removeSegment();
- aPathURL.removeFinalSlash();
- XGradientList* pTab = new XGradientList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), (XOutdevItemPool*)&pDoc->GetPool() );
- pTab->SetName( aURL.getName() );
- if( pTab->Load() )
- {
- pDoc->SetGradientList( pTab );
- bOk = sal_True;
- bChanged = sal_True;
- }
- }
- }
+ case HANDLE_GRADIENTTABLEURL:
+ AssignURL( XGRADIENT_LIST, pValues, &bOk, &bChanged );
break;
- case HANDLE_BITMAPTABLEURL:
- {
- OUString aURLString;
- if( *pValues >>= aURLString )
- {
- INetURLObject aURL( aURLString );
- INetURLObject aPathURL( aURL );
-
- aPathURL.removeSegment();
- aPathURL.removeFinalSlash();
- XBitmapList* pTab = new XBitmapList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), (XOutdevItemPool*)&pDoc->GetPool() );
- pTab->SetName( aURL.getName() );
- if( pTab->Load() )
- {
- pDoc->SetBitmapList( pTab );
- bOk = sal_True;
- bChanged = sal_True;
- }
- }
- }
+ case HANDLE_BITMAPTABLEURL:
+ AssignURL( XBITMAP_LIST, pValues, &bOk, &bChanged );
break;
+
case HANDLE_FORBIDDENCHARS:
- {
- bOk = sal_True;
- }
+ bOk = true;
break;
+
case HANDLE_APPLYUSERDATA:
{
sal_Bool bApplyUserData = sal_False;
@@ -397,7 +347,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
bChanged = ( bApplyUserData != pDocSh->IsUseUserData() );
pDocSh->SetUseUserData( bApplyUserData );
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -410,7 +360,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTNOTES:
@@ -422,7 +372,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTHANDOUT:
@@ -434,7 +384,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTOUTLINE:
@@ -445,7 +395,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetOutline( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_SLIDESPERHANDOUT:
@@ -458,7 +408,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetHandoutPages( static_cast< sal_uInt16 >( nValue ) );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -470,7 +420,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetHandoutHorizontal( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
@@ -482,7 +432,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetPagename( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTDATE:
@@ -493,7 +443,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetDate( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTTIME:
@@ -504,7 +454,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetTime( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTHIDENPAGES:
@@ -515,7 +465,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetHiddenPages( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTFITPAGE:
@@ -526,7 +476,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetPagesize( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTTILEPAGE:
@@ -537,7 +487,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetPagetile( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTBOOKLET:
@@ -548,7 +498,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetBooklet( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTBOOKLETFRONT:
@@ -559,7 +509,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetFrontPage( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTBOOKLETBACK:
@@ -570,7 +520,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetBackPage( bValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
break;
case HANDLE_PRINTQUALITY:
@@ -583,7 +533,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
aPrintOpts.SetOutputQuality( (sal_uInt16)nValue );
bOptionsChanged = true;
}
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -596,7 +546,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
{
pDoc->SetUIUnit((FieldUnit)nFieldUnit );
- bOk = sal_True;
+ bOk = true;
}
}
}
@@ -608,8 +558,8 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() );
pDoc->SetUIScale( aFract );
- bOk = sal_True;
- bChanged = sal_True;
+ bOk = true;
+ bChanged = true;
}
}
break;
@@ -620,8 +570,8 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
Fraction aFract( pDoc->GetUIScale().GetNumerator(), nValue );
pDoc->SetUIScale( aFract );
- bOk = sal_True;
- bChanged = sal_True;
+ bOk = true;
+ bChanged = true;
}
}
break;
@@ -632,8 +582,8 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
if( (*pValues >>= nValue) && (nValue >= 0) )
{
pDoc->SetDefaultTabulator((sal_uInt16)nValue);
- bOk = sal_True;
- bChanged = sal_True;
+ bOk = true;
+ bChanged = true;
}
}
break;
@@ -643,8 +593,8 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
if( (*pValues >>= nValue ) && (nValue >= SVX_CHARS_UPPER_LETTER ) && (nValue <= SVX_PAGEDESC) )
{
pDoc->SetPageNumType((SvxNumType)nValue);
- bOk = sal_True;
- bChanged = sal_True;
+ bOk = true;
+ bChanged = true;
}
}
break;
@@ -653,7 +603,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
OUString aPrinterName;
if( *pValues >>= aPrinterName )
{
- bOk = sal_True;
+ bOk = true;
if( aPrinterName.getLength() && pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
{
SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_True );
@@ -671,7 +621,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
Sequence < sal_Int8 > aSequence;
if ( *pValues >>= aSequence )
{
- bOk = sal_True;
+ bOk = true;
sal_uInt32 nSize = aSequence.getLength();
if( nSize )
{
@@ -711,8 +661,8 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
sal_Bool bIsSummationOfParagraphs = sal_False;
if ( *pValues >>= bIsSummationOfParagraphs )
{
- bOk = sal_True;
- bChanged = sal_True;
+ bOk = true;
+ bChanged = true;
if ( pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
{
sal_uInt32 nSum = bIsSummationOfParagraphs ? EE_CNTRL_ULSPACESUMMATION : 0;
@@ -745,7 +695,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
sal_Int16 nCharCompressType = 0;
if( *pValues >>= nCharCompressType )
{
- bOk = sal_True;
+ bOk = true;
pDoc->SetCharCompressType( (sal_uInt16)nCharCompressType );
SdDrawDocument* pDocument = pDocSh->GetDoc();
@@ -770,7 +720,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
sal_Bool bAsianPunct = sal_False;
if( *pValues >>= bAsianPunct )
{
- bOk = sal_True;
+ bOk = true;
pDoc->SetKernAsianPunctuation( bAsianPunct );
SdDrawDocument* pDocument = pDocSh->GetDoc();
@@ -797,7 +747,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
bChanged = ( value != pDocSh->IsQueryLoadTemplate() );
pDocSh->SetQueryLoadTemplate( value );
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -814,7 +764,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
pDoc->SetPrinterIndependentLayout (nValue);
bChanged = (nValue != nOldValue);
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -827,7 +777,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
bChanged = ( pDocSh->IsLoadReadonly() != bNewValue );
pDocSh->SetLoadReadonly( bNewValue );
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -839,7 +789,7 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
{
bChanged = ( pDocSh->IsSaveVersionOnClose() != bNewValue );
pDocSh->SetSaveVersionOnClose( bNewValue );
- bOk = sal_True;
+ bOk = true;
}
}
break;
@@ -865,6 +815,19 @@ void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, c
mpModel->SetModified( sal_True );
}
+void DocumentSettings::ExtractURL( XPropertyListType t, Any* pValue )
+{
+ XPropertyList *pList = GetPropertyList( mpModel->GetDoc(), t );
+ if( !pList )
+ return;
+
+ INetURLObject aPathURL( pList->GetPath() );
+ aPathURL.insertName( pList->GetName() );
+ aPathURL.setExtension( pList->GetDefaultExt() );
+ OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ *pValue <<= aPath;
+}
+
void DocumentSettings::_getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValue ) throw(UnknownPropertyException, WrappedTargetException )
{
::SolarMutexGuard aGuard;
@@ -894,73 +857,29 @@ void DocumentSettings::_getPropertyValues( const PropertyMapEntry** ppEntries, A
switch( (*ppEntries)->mnHandle )
{
case HANDLE_COLORTABLEURL:
- {
- INetURLObject aPathURL( pDoc->GetColorTable()->GetPath() );
- aPathURL.insertName( pDoc->GetColorTable()->GetName() );
- String aExt( RTL_CONSTASCII_USTRINGPARAM("soc") );
- aPathURL.setExtension( aExt );
- OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
- *pValue <<= aPath;
- }
+ ExtractURL( XCOLOR_LIST, pValue );
break;
case HANDLE_DASHTABLEURL:
- {
- INetURLObject aPathURL( pDoc->GetDashList()->GetPath() );
- aPathURL.insertName( pDoc->GetDashList()->GetName() );
- String aExt( RTL_CONSTASCII_USTRINGPARAM("sod") );
- aPathURL.setExtension( aExt );
- OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
- *pValue <<= aPath;
- }
+ ExtractURL( XDASH_LIST, pValue );
break;
case HANDLE_LINEENDTABLEURL:
- {
- INetURLObject aPathURL( pDoc->GetLineEndList()->GetPath() );
- aPathURL.insertName( pDoc->GetLineEndList()->GetName() );
- String aExt( RTL_CONSTASCII_USTRINGPARAM("soe") );
- aPathURL.setExtension( aExt );
- OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
- *pValue <<= aPath;
- }
+ ExtractURL( XLINE_END_LIST, pValue );
break;
case HANDLE_HATCHTABLEURL:
- {
- INetURLObject aPathURL( pDoc->GetHatchList()->GetPath() );
- aPathURL.insertName( pDoc->GetHatchList()->GetName() );
- String aExt( RTL_CONSTASCII_USTRINGPARAM("soh") );
- aPathURL.setExtension( aExt );
- OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
- *pValue <<= aPath;
- }
+ ExtractURL( XHATCH_LIST, pValue );
break;
case HANDLE_GRADIENTTABLEURL:
- {
- INetURLObject aPathURL( pDoc->GetGradientList()->GetPath() );
- aPathURL.insertName( pDoc->GetGradientList()->GetName() );
- String aExt( RTL_CONSTASCII_USTRINGPARAM("sog") );
- aPathURL.setExtension( aExt );
- OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
- *pValue <<= aPath;
- }
+ ExtractURL( XGRADIENT_LIST, pValue );
break;
case HANDLE_BITMAPTABLEURL:
- {
- INetURLObject aPathURL( pDoc->GetBitmapList()->GetPath() );
- aPathURL.insertName( pDoc->GetBitmapList()->GetName() );
- String aExt( RTL_CONSTASCII_USTRINGPARAM("sob") );
- aPathURL.setExtension( aExt );
- OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
- *pValue <<= aPath;
- }
+ ExtractURL( XBITMAP_LIST, pValue );
break;
case HANDLE_FORBIDDENCHARS:
*pValue <<= mpModel->getForbiddenCharsTable();
break;
-
case HANDLE_APPLYUSERDATA:
*pValue <<= pDocSh->IsUseUserData();
break;
-
case HANDLE_PRINTDRAWING:
*pValue <<= (sal_Bool)aPrintOpts.IsDraw();
break;
diff --git a/svx/inc/svx/xtable.hxx b/svx/inc/svx/xtable.hxx
index ff0caf8..79bdfbe 100644
--- a/svx/inc/svx/xtable.hxx
+++ b/svx/inc/svx/xtable.hxx
@@ -191,12 +191,22 @@ public:
// class XPropertyList
// --------------------
+enum XPropertyListType {
+ XCOLOR_LIST,
+ XLINE_END_LIST,
+ XDASH_LIST,
+ XHATCH_LIST,
+ XGRADIENT_LIST,
+ XBITMAP_LIST,
+};
+
class SVX_DLLPUBLIC XPropertyList
{
protected:
typedef ::std::vector< XPropertyEntry* > XPropertyEntryList_impl;
typedef ::std::vector< Bitmap* > BitmapList_impl;
+ XPropertyListType eType;
String aName; // not persistent
String aPath;
XOutdevItemPool* pXPool;
@@ -209,11 +219,10 @@ protected:
sal_Bool bBitmapsDirty;
sal_Bool bOwnPool;
- XPropertyList(
- const char *_pDefaultExtension,
- const String& rPath,
- XOutdevItemPool* pXPool = NULL
- );
+ XPropertyList( XPropertyListType t,
+ const char *pDefaultExtension,
+ const String& rPath,
+ XOutdevItemPool* pXPool = NULL );
void Clear();
public:
@@ -235,6 +244,7 @@ public:
void SetName( const String& rString );
const String& GetPath() const { return aPath; }
void SetPath( const String& rString ) { aPath = rString; }
+ String GetDefaultExt() const { return rtl::OUString::createFromAscii( pDefaultExt ); }
sal_Bool IsDirty() const { return bListDirty && bBitmapsDirty; }
void SetDirty( sal_Bool bDirty = sal_True )
{ bListDirty = bDirty; bBitmapsDirty = bDirty; }
@@ -246,6 +256,11 @@ public:
virtual sal_Bool Create() = 0;
virtual sal_Bool CreateBitmapsForUI() = 0;
virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True ) = 0;
+
+ // Factory method for sub-classes
+ static XPropertyList *CreatePropertyList( XPropertyListType t,
+ const String& rPath,
+ XOutdevItemPool* pXPool = NULL );
};
// ------------------
@@ -255,11 +270,10 @@ public:
class SVX_DLLPUBLIC XColorList : public XPropertyList
{
public:
- explicit XColorList(
- const String& rPath,
- XOutdevItemPool* pXPool = NULL
- );
- virtual ~XColorList();
+ explicit XColorList( const String& rPath,
+ XOutdevItemPool* pXInPool = NULL ) :
+ XPropertyList( XCOLOR_LIST, "soc", rPath, pXInPool ) {}
+ virtual ~XColorList() {}
using XPropertyList::Replace;
using XPropertyList::Remove;
@@ -414,11 +428,10 @@ public:
class SVX_DLLPUBLIC XBitmapList : public XPropertyList
{
public:
- explicit XBitmapList(
- const String& rPath,
- XOutdevItemPool* pXPool = NULL
- );
- virtual ~XBitmapList();
+ explicit XBitmapList( const String& rPath,
+ XOutdevItemPool* pXInPool = NULL )
+ : XPropertyList( XBITMAP_LIST, "sob", rPath, pXInPool ) {}
+ virtual ~XBitmapList() {}
using XPropertyList::Replace;
using XPropertyList::Remove;
diff --git a/svx/source/xoutdev/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx
index ffcd72d..3379e26 100644
--- a/svx/source/xoutdev/xtabbtmp.cxx
+++ b/svx/source/xoutdev/xtabbtmp.cxx
@@ -41,17 +41,6 @@
using namespace com::sun::star;
-XBitmapList::XBitmapList(
- const String& rPath,
- XOutdevItemPool* pInPool
- ) : XPropertyList( "sob", rPath, pInPool )
-{
-}
-
-XBitmapList::~XBitmapList()
-{
-}
-
XBitmapEntry* XBitmapList::Remove(long nIndex)
{
return (XBitmapEntry*) XPropertyList::Remove(nIndex);
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
index f24d0e7..ab11883 100644
--- a/svx/source/xoutdev/xtabcolr.cxx
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -39,18 +39,6 @@
using namespace com::sun::star;
-XColorList::XColorList(
- const String& rPath,
- XOutdevItemPool* pInPool
-) :
- XPropertyList( "soc", rPath, pInPool )
-{
-}
-
-XColorList::~XColorList()
-{
-}
-
XColorList& XColorList::GetStdColorTable()
{
static XColorList aTable(SvtPathOptions().GetPalettePath());
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index c0fbf25..a8e9c6b 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -137,10 +137,9 @@ void XDashList::impDestroy()
mpData = 0;
}
-XDashList::XDashList(
- const String& rPath,
- XOutdevItemPool* pInPool
- ) : XPropertyList( "sod", rPath, pInPool ),
+XDashList::XDashList( const String& rPath,
+ XOutdevItemPool* pInPool) :
+ XPropertyList( XDASH_LIST, "sod", rPath, pInPool ),
mpData(0)
{
pBmpList = new BitmapList_impl();
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
index 91c83c4..41f1e28 100644
--- a/svx/source/xoutdev/xtabgrdt.cxx
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -121,11 +121,9 @@ void XGradientList::impDestroy()
}
}
-XGradientList::XGradientList(
- const String& rPath,
- XOutdevItemPool* pInPool
- ) : XPropertyList( "sog", rPath, pInPool ),
- mpData(0)
+XGradientList::XGradientList( const String& rPath, XOutdevItemPool* pInPool ) :
+ XPropertyList( XGRADIENT_LIST, "sog", rPath, pInPool ),
+ mpData( NULL )
{
pBmpList = new BitmapList_impl();
}
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
index be426f8..060f405 100644
--- a/svx/source/xoutdev/xtabhtch.cxx
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -130,11 +130,10 @@ void XHatchList::impDestroy()
mpData = NULL;
}
-XHatchList::XHatchList(
- const String& rPath,
- XOutdevItemPool* pInPool
- ) : XPropertyList( "soh", rPath, pInPool )
- , mpData(NULL)
+XHatchList::XHatchList( const String& rPath,
+ XOutdevItemPool* pInPool )
+ : XPropertyList( XHATCH_LIST, "soh", rPath, pInPool ),
+ mpData( NULL )
{
pBmpList = new BitmapList_impl();
}
diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx
index 66eb750..a95663b 100644
--- a/svx/source/xoutdev/xtable.cxx
+++ b/svx/source/xoutdev/xtable.cxx
@@ -38,11 +38,7 @@
using namespace com::sun::star;
-// Vergleichsstrings
-sal_Unicode pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 };
-
-// Konvertiert in echte RGB-Farben, damit in den Listboxen
-// endlich mal richtig selektiert werden kann.
+// Helper for other sub-classes to have easy-to-read constructors
Color RGB_Color( ColorData nColorName )
{
Color aColor( nColorName );
@@ -50,15 +46,13 @@ Color RGB_Color( ColorData nColorName )
return aRGBColor;
}
-// --------------------
-// class XPropertyList
-// --------------------
-
XPropertyList::XPropertyList(
+ XPropertyListType type,
const char *pDefaultExtension,
const String& rPath,
XOutdevItemPool* pInPool
-) : aName ( pszStandard, 8 ),
+) : eType ( type ),
+ aName ( RTL_CONSTASCII_USTRINGPARAM( "standard" ) ),
aPath ( rPath ),
pXPool ( pInPool ),
pDefaultExt ( pDefaultExtension ),
@@ -117,7 +111,6 @@ long XPropertyList::Count() const
{
if( bListDirty )
{
- // ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load()
if( !( (XPropertyList*) this )->Load() )
( (XPropertyList*) this )->Create();
}
@@ -128,7 +121,6 @@ XPropertyEntry* XPropertyList::Get( long nIndex, sal_uInt16 /*nDummy*/) const
{
if( bListDirty )
{
- // ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load()
if( !( (XPropertyList*) this )->Load() )
( (XPropertyList*) this )->Create();
}
@@ -139,7 +131,6 @@ long XPropertyList::Get(const XubString& rName)
{
if( bListDirty )
{
- //bListDirty = sal_False;
if( !Load() )
Create();
}
@@ -280,4 +271,29 @@ sal_Bool XPropertyList::Save()
return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), createInstance() );
}
+XPropertyList *XPropertyList::CreatePropertyList( XPropertyListType t,
+ const String& rPath,
+ XOutdevItemPool* pXPool )
+{
+ XPropertyList *pRet = NULL;
+
+#define MAP(e,c) \
+ case e: pRet = new c( rPath, pXPool ); break
+ switch (t) {
+ MAP( XCOLOR_LIST, XColorList );
+ MAP( XLINE_END_LIST, XLineEndList );
+ MAP( XDASH_LIST, XDashList );
+ MAP( XHATCH_LIST, XHatchList );
+ MAP( XGRADIENT_LIST, XGradientList );
+ MAP( XBITMAP_LIST, XBitmapList );
+ default:
+ OSL_FAIL("unknown xproperty type");
+ break;
+ }
+#undef MAP
+ OSL_ASSERT( !pRet || pRet->eType == t );
+
+ return pRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
index 4c44920..312a1c1 100644
--- a/svx/source/xoutdev/xtablend.cxx
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -142,12 +142,9 @@ void XLineEndList::impDestroy()
mpData = NULL;
}
-XLineEndList::XLineEndList(
- const String& rPath,
- XOutdevItemPool* _pXPool
-)
- : XPropertyList( "soe", rPath, _pXPool )
- , mpData(NULL)
+XLineEndList::XLineEndList( const String& rPath, XOutdevItemPool* _pXPool )
+ : XPropertyList( XLINE_END_LIST, "soe", rPath, _pXPool ),
+ mpData(NULL)
{
pBmpList = new BitmapList_impl();
}
More information about the Libreoffice-commits
mailing list