summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-06-10 15:11:59 +0100
committerMichael Meeks <michael.meeks@novell.com>2011-06-10 15:44:13 +0100
commit0284352c621ef7bad07a8a947ff8f83c55f831fa (patch)
tree33ce075fb16616db8f69e9bebfd50dc82b52a704
parent8a6f36b6da01f9eb7bbcafa22f1ec0de30fe8051 (diff)
simple re-factor to share selection code
-rw-r--r--sfx2/source/dialog/templdlg.cxx17
-rw-r--r--sfx2/source/inc/templdgi.hxx6
2 files changed, 15 insertions, 8 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 39be80a7f8b3..b2aba626123f 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1053,6 +1053,15 @@ const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() con
return 0;
}
+SfxStyleSheetBase *SfxCommonTemplateDialog_Impl::GetSelectedStyle() const
+{
+ if (!IsInitialized() || !pStyleSheetPool || !HasSelectedStyle())
+ return NULL;
+ const String aTemplName( GetSelectedEntry() );
+ const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+ return pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL );
+}
+
//-------------------------------------------------------------------------
void SfxCommonTemplateDialog_Impl::SelectStyle(const String &rStr)
@@ -2002,9 +2011,7 @@ void SfxCommonTemplateDialog_Impl::EditHdl(void *)
{
sal_uInt16 nFilter = nActFilter;
String aTemplName(GetSelectedEntry());
- const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
- const SfxStyleFamily eFam = pItem->GetFamily();
- pStyleSheetPool->Find(aTemplName,eFam,SFXSTYLEBIT_ALL); // -Wall required??
+ GetSelectedStyle(); // -Wall required??
Window* pTmp;
//DefModalDialogParent set for modality of the following dialogs
pTmp = Application::GetDefDialogParent();
@@ -2028,9 +2035,7 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl(void *)
if ( IsInitialized() && HasSelectedStyle() )
{
const String aTemplName( GetSelectedEntry() );
- const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
- SfxStyleSheetBase* pStyle =
- pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL );
+ SfxStyleSheetBase* pStyle = GetSelectedStyle();
if ( pStyle )
{
String aMsg;
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index c7d4e94d7f19..aa4c7a05776b 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -50,6 +50,7 @@ class SfxStyleFamilies;
class SfxStyleFamilyItem;
class SfxTemplateItem;
class SfxBindings;
+class SfxStyleSheetBase;
class SfxStyleSheetBasePool;
class SvTreeListBox ;
class StyleTreeListBox_Impl;
@@ -208,7 +209,7 @@ protected:
void UpdateStyles_Impl(sal_uInt16 nFlags);
const SfxStyleFamilyItem* GetFamilyItem_Impl() const;
- sal_Bool IsInitialized() { return nActFamily != 0xffff; }
+ sal_Bool IsInitialized() const { return nActFamily != 0xffff; }
void ResetFocus();
void EnableDelete();
void Initialize();
@@ -218,7 +219,8 @@ protected:
void SetWaterCanState( const SfxBoolItem* pItem );
void SelectStyle( const String& rStyle );
- sal_Bool HasSelectedStyle() const;
+ sal_Bool HasSelectedStyle() const;
+ SfxStyleSheetBase *GetSelectedStyle() const;
void FillTreeBox();
void Update_Impl();
void UpdateFamily_Impl();