diff options
author | Michael Meeks <michael.meeks@suse.com> | 2011-09-28 09:08:44 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2011-09-28 09:09:12 +0100 |
commit | 7e276c3e0fa333348fa82e385feba3f5e61acdd0 (patch) | |
tree | 3a3b5c11b13cbf38ae32a2660f8ea7b68766335a /svx | |
parent | 05bee2028291190e3413fa5815897f54b6060fd6 (diff) |
re-work XPropertyList default extension handling to increase re-use
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/xtable.hxx | 17 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabdash.cxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabgrdt.cxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabhtch.cxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xtable.cxx | 48 | ||||
-rw-r--r-- | svx/source/xoutdev/xtablend.cxx | 2 |
6 files changed, 61 insertions, 12 deletions
diff --git a/svx/inc/svx/xtable.hxx b/svx/inc/svx/xtable.hxx index e2ba7271fd3d..3cab49561625 100644 --- a/svx/inc/svx/xtable.hxx +++ b/svx/inc/svx/xtable.hxx @@ -238,9 +238,7 @@ protected: bool bOwnPool; bool bEmbedInDocument; - XPropertyList( XPropertyListType t, - const char *pDefaultExtension, - const String& rPath, + XPropertyList( XPropertyListType t, const String& rPath, XOutdevItemPool* pXPool = NULL ); void Clear(); @@ -264,13 +262,16 @@ 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; } bool IsEmbedInDocument() const { return bEmbedInDocument; } void SetEmbedInDocument(bool b) { bEmbedInDocument = b; } + static rtl::OUString GetDefaultExt(XPropertyListType t); + static rtl::OUString GetDefaultExtFilter(XPropertyListType t); + rtl::OUString GetDefaultExt() const { return GetDefaultExt( eType ); } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() = 0; bool Load(); @@ -290,6 +291,10 @@ public: static XPropertyListRef CreatePropertyList( XPropertyListType t, const String& rPath, XOutdevItemPool* pXPool = NULL ); + // as above but initializes name as expected + static XPropertyListRef CreatePropertyListFromURL( XPropertyListType t, + const rtl::OUString & rUrl, + XOutdevItemPool* pXPool = NULL ); // helper accessors inline XDashListRef AsDashList(); @@ -309,7 +314,7 @@ class SVX_DLLPUBLIC XColorList : public XPropertyList public: explicit XColorList( const String& rPath, XOutdevItemPool* pXInPool = NULL ) : - XPropertyList( XCOLOR_LIST, "soc", rPath, pXInPool ) {} + XPropertyList( XCOLOR_LIST, rPath, pXInPool ) {} using XPropertyList::Replace; using XPropertyList::Remove; @@ -464,7 +469,7 @@ class SVX_DLLPUBLIC XBitmapList : public XPropertyList public: explicit XBitmapList( const String& rPath, XOutdevItemPool* pXInPool = NULL ) - : XPropertyList( XBITMAP_LIST, "sob", rPath, pXInPool ) {} + : XPropertyList( XBITMAP_LIST, rPath, pXInPool ) {} using XPropertyList::Replace; using XPropertyList::Remove; diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx index a8e9c6b2bc3e..1c5109d84202 100644 --- a/svx/source/xoutdev/xtabdash.cxx +++ b/svx/source/xoutdev/xtabdash.cxx @@ -139,7 +139,7 @@ void XDashList::impDestroy() XDashList::XDashList( const String& rPath, XOutdevItemPool* pInPool) : - XPropertyList( XDASH_LIST, "sod", rPath, pInPool ), + XPropertyList( XDASH_LIST, rPath, pInPool ), mpData(0) { pBmpList = new BitmapList_impl(); diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx index 41f1e2891c8c..01365bdf922b 100644 --- a/svx/source/xoutdev/xtabgrdt.cxx +++ b/svx/source/xoutdev/xtabgrdt.cxx @@ -122,7 +122,7 @@ void XGradientList::impDestroy() } XGradientList::XGradientList( const String& rPath, XOutdevItemPool* pInPool ) : - XPropertyList( XGRADIENT_LIST, "sog", rPath, pInPool ), + XPropertyList( XGRADIENT_LIST, rPath, pInPool ), mpData( NULL ) { pBmpList = new BitmapList_impl(); diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx index 060f4059215e..0f88610e975e 100644 --- a/svx/source/xoutdev/xtabhtch.cxx +++ b/svx/source/xoutdev/xtabhtch.cxx @@ -132,7 +132,7 @@ void XHatchList::impDestroy() XHatchList::XHatchList( const String& rPath, XOutdevItemPool* pInPool ) - : XPropertyList( XHATCH_LIST, "soh", rPath, pInPool ), + : XPropertyList( XHATCH_LIST, rPath, pInPool ), mpData( NULL ) { pBmpList = new BitmapList_impl(); diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx index 100dbe439c0b..7dafb736ba81 100644 --- a/svx/source/xoutdev/xtable.cxx +++ b/svx/source/xoutdev/xtable.cxx @@ -50,14 +50,12 @@ Color RGB_Color( ColorData nColorName ) XPropertyList::XPropertyList( XPropertyListType type, - const char *pDefaultExtension, const String& rPath, XOutdevItemPool* pInPool ) : eType ( type ), aName ( RTL_CONSTASCII_USTRINGPARAM( "standard" ) ), aPath ( rPath ), pXPool ( pInPool ), - pDefaultExt ( pDefaultExtension ), pBmpList ( NULL ), bListDirty ( true ), bBitmapsDirty ( true ), @@ -318,6 +316,24 @@ XPropertyListRef XPropertyList::CreatePropertyList( XPropertyListType t, return pRet; } +XPropertyListRef +XPropertyList::CreatePropertyListFromURL( XPropertyListType t, + const rtl::OUString & rURLStr, + XOutdevItemPool* pXPool ) +{ + INetURLObject aURL( rURLStr ); + INetURLObject aPathURL( aURL ); + + aPathURL.removeSegment(); + aPathURL.removeFinalSlash(); + + XPropertyListRef pList = XPropertyList::CreatePropertyList( + t, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool ); + pList->SetName( aURL.getName() ); + + return pList; +} + // catch people being silly with ref counting ... void* XPropertyList::operator new (size_t nCount) @@ -330,4 +346,32 @@ void XPropertyList::operator delete(void *pPtr) return rtl_freeMemory( pPtr ); } +static struct { + XPropertyListType t; + const char *pExt; +} pExtnMap[] = { + { XCOLOR_LIST, "soc" }, + { XLINE_END_LIST, "soe" }, + { XDASH_LIST, "sod" }, + { XHATCH_LIST, "soh" }, + { XGRADIENT_LIST, "sog" }, + { XBITMAP_LIST, "sob" } +}; + +rtl::OUString XPropertyList::GetDefaultExt( XPropertyListType t ) +{ + for (size_t i = 0; i < SAL_N_ELEMENTS (pExtnMap); i++) + { + if( pExtnMap[i].t == t ) + return rtl::OUString::createFromAscii( pExtnMap[ i ].pExt ); + } + return rtl::OUString(); +} + +rtl::OUString XPropertyList::GetDefaultExtFilter( XPropertyListType t ) +{ + rtl::OUString aFilter( RTL_CONSTASCII_USTRINGPARAM( "*." ) ); + return aFilter + GetDefaultExt( t ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx index 312a1c1cc77d..7f2e9adcafca 100644 --- a/svx/source/xoutdev/xtablend.cxx +++ b/svx/source/xoutdev/xtablend.cxx @@ -143,7 +143,7 @@ void XLineEndList::impDestroy() } XLineEndList::XLineEndList( const String& rPath, XOutdevItemPool* _pXPool ) - : XPropertyList( XLINE_END_LIST, "soe", rPath, _pXPool ), + : XPropertyList( XLINE_END_LIST, rPath, _pXPool ), mpData(NULL) { pBmpList = new BitmapList_impl(); |