diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-09-05 17:22:24 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-09-11 09:26:59 +0200 |
commit | cbcfda9b2079ea4ef83b2a42828408b5f70f7692 (patch) | |
tree | fabe2bd09b1aff1edc079e8216c6714d68c0e65b /svx | |
parent | 64bc62f77a0783b40583c4f6e7a4e1a935e1695a (diff) |
add XPropertyList enum, factory, and associated cleanup
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/xtable.hxx | 43 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabbtmp.cxx | 11 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabcolr.cxx | 12 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabdash.cxx | 7 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabgrdt.cxx | 8 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabhtch.cxx | 9 | ||||
-rw-r--r-- | svx/source/xoutdev/xtable.cxx | 42 | ||||
-rw-r--r-- | svx/source/xoutdev/xtablend.cxx | 9 |
8 files changed, 70 insertions, 71 deletions
diff --git a/svx/inc/svx/xtable.hxx b/svx/inc/svx/xtable.hxx index ff0caf82f0fa..79bdfbe1a83e 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 ffcd72d8534f..3379e2607051 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 f24d0e7b5419..ab11883e7ba8 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 c0fbf2581482..a8e9c6b2bc3e 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 91c83c499027..41f1e2891c8c 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 be426f85ab93..060f4059215e 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 66eb7505e2ce..a95663b5c164 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 4c4492015cb5..312a1c1cc77d 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(); } |