diff options
-rw-r--r-- | cui/source/tabpages/tpcolor.cxx | 29 | ||||
-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 |
7 files changed, 68 insertions, 34 deletions
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 0626e35bfda1..9e9daa727b9e 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -170,38 +170,28 @@ IMPL_LINK( SvxLoadSaveEmbed, ClickLoadHdl_Impl, void *, EMPTYARG ) ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 ); - String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soc" ) ); + String aStrFilterType( XPropertyList::GetDefaultExtFilter( meType ) ); aDlg.AddFilter( aStrFilterType, aStrFilterType ); + INetURLObject aFile( SvtPathOptions().GetPalettePath() ); aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); if ( aDlg.Execute() == ERRCODE_NONE ) { - INetURLObject aURL( aDlg.GetPath() ); - INetURLObject aPathURL( aURL ); - - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); - - XColorListRef pList = XPropertyList::CreatePropertyList( - meType, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), mpXPool )->AsColorList(); - pList->SetName( aURL.getName() ); + XColorListRef pList = XPropertyList::CreatePropertyListFromURL( + meType, aDlg.GetPath(), mpXPool )->AsColorList(); if( pList->Load() ) { // Pruefen, ob Tabelle geloescht werden darf: SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( mpTopDlg ); SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( mpTopDlg ); - pList->SetName( aURL.getName() ); - // FIXME: want to have a generic set and get method by type ... if( pArea ) pArea->SetNewColorList( pList ); else if( pLine ) pLine->SetNewColorList( pList ); - - bLoaded = true; UpdateTableName(); @@ -236,7 +226,8 @@ IMPL_LINK( SvxLoadSaveEmbed, ClickSaveHdl_Impl, void *, EMPTYARG ) { ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 ); - String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soc" ) ); + + String aStrFilterType( XPropertyList::GetDefaultExtFilter( meType ) ); aDlg.AddFilter( aStrFilterType, aStrFilterType ); INetURLObject aFile( SvtPathOptions().GetPalettePath() ); @@ -249,7 +240,7 @@ IMPL_LINK( SvxLoadSaveEmbed, ClickSaveHdl_Impl, void *, EMPTYARG ) aFile.Append( pList->GetName() ); if( !aFile.getExtension().getLength() ) - aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soc" ) ) ); + aFile.SetExtension( XPropertyList::GetDefaultExt( meType ) ); } aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); @@ -500,12 +491,10 @@ long SvxColorTabPage::CheckChanges_Impl() ResMgr& rMgr = CUI_MGR(); Image aWarningBoxImage = WarningBox::GetStandardImage(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialogdiet fail!"); AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( GetParentDialog(), RID_SVXDLG_MESSBOX, SVX_RESSTR( RID_SVXSTR_COLOR ), String( ResId( RID_SVXSTR_ASK_CHANGE_COLOR, rMgr ) ), &aWarningBoxImage ); - DBG_ASSERT(aMessDlg, "Dialogdiet fail!"); aMessDlg->SetButtonText( MESS_BTN_1, String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) ); aMessDlg->SetButtonText( MESS_BTN_2, @@ -674,9 +663,7 @@ IMPL_LINK( SvxColorTabPage, ClickAddHdl_Impl, void *, EMPTYARG ) aWarningBox.Execute(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialogdiet fail!"); AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ); - DBG_ASSERT(pDlg, "Dialogdiet fail!"); sal_Bool bLoop = sal_True; while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) @@ -751,9 +738,7 @@ IMPL_LINK( SvxColorTabPage, ClickModifyHdl_Impl, void *, EMPTYARG ) aWarningBox.Execute(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialogdiet fail!"); AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ); - DBG_ASSERT(pDlg, "Dialogdiet fail!"); sal_Bool bLoop = sal_True; while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) 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(); |