summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/app.hxx3
-rw-r--r--include/sfx2/templdlg.hxx19
-rw-r--r--sc/source/ui/view/formatsh.cxx17
-rw-r--r--sd/source/ui/view/drviewsf.cxx38
-rw-r--r--sd/source/ui/view/outlnvsh.cxx8
-rw-r--r--sd/source/ui/view/viewshe3.cxx10
-rw-r--r--sfx2/source/appl/appmisc.cxx11
-rw-r--r--sfx2/source/dialog/templdlg.cxx41
-rw-r--r--sfx2/source/inc/templdgi.hxx16
-rw-r--r--sw/source/core/uibase/app/docst.cxx11
10 files changed, 79 insertions, 95 deletions
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index 17b80b90ba1f..3f81077d5b43 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -174,9 +174,6 @@ public:
SfxTemplateDialog* GetTemplateDialog();
Window* GetTopWindow() const;
- // TODO/CLEANUP: make currently selected family a view property and so we don't need to query the status from the "TemplateCommon"
- ISfxTemplateCommon* GetCurrentTemplateCommon( SfxBindings& );
-
// members
SfxFilterMatcher& GetFilterMatcher();
SfxProgress* GetProgress() const;
diff --git a/include/sfx2/templdlg.hxx b/include/sfx2/templdlg.hxx
index cc7344c60333..8c9f2f1e47cb 100644
--- a/include/sfx2/templdlg.hxx
+++ b/include/sfx2/templdlg.hxx
@@ -30,20 +30,7 @@
class SfxTemplateDialog_Impl;
-// class ISfxTemplateCommon ----------------------------------------------
-
-class ISfxTemplateCommon
-{
-public:
- virtual SfxStyleFamily GetActualFamily() const = 0;
- virtual OUString GetSelectedEntry() const = 0;
-
-protected:
- ~ISfxTemplateCommon() {}
-};
-
// class SfxTemplateDialog -----------------------------------------------
-
class SfxTemplateDialog : public SfxDockingWindow
{
private:
@@ -63,8 +50,12 @@ public:
virtual void Update();
- ISfxTemplateCommon* GetISfxTemplateCommon();
void SetParagraphFamily();
+
+ // converts from SFX_STYLE_FAMILY Ids to 1-5
+ static sal_uInt16 SFX2_DLLPUBLIC SfxFamilyIdToNId(SfxStyleFamily nFamily);
+ // converts from 1-5 to SFX_STYLE_FAMILY Ids
+ static SfxStyleFamily SFX2_DLLPUBLIC NIdToSfxFamilyId(sal_uInt16 nId);
};
// class SfxTemplateDialogWrapper ----------------------------------------
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 35220871d22a..045ddf066650 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -212,9 +212,12 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
case SID_STYLE_UPDATE_BY_EXAMPLE:
{
- ISfxTemplateCommon* pDesigner = SFX_APP()->
- GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
- bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+ SfxPoolItem* pItem = NULL;
+ pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+
+ bool bPage = pFamilyItem && SFX_STYLE_FAMILY_PAGE == SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue());
+ delete pItem;
if ( bProtected || bPage )
rSet.DisableItem( nSlotId );
@@ -226,9 +229,11 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
case SID_STYLE_HIDE:
case SID_STYLE_SHOW:
{
- ISfxTemplateCommon* pDesigner = SFX_APP()->
- GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
- bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+ SfxPoolItem* pItem = NULL;
+ pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ bool bPage = pFamilyItem && SFX_STYLE_FAMILY_PAGE == SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue());
+ delete pItem;
if ( bProtected && !bPage )
rSet.DisableItem( nSlotId );
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index ea10bdf6bb04..6de7c98887e8 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -485,30 +485,41 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
case SID_STYLE_WATERCAN:
{
- ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
- if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ SfxPoolItem* pItem = NULL;
+ GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
rSet.Put(SfxBoolItem(nWhich,false));
else
{
SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
aAllSet.Put( aItem, aItem.Which());
}
+ delete pItem;
}
break;
case SID_STYLE_NEW:
{
- ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
- if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ SfxPoolItem* pItem = NULL;
+ GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
+ {
rSet.DisableItem(nWhich);
+ }
+ delete pItem;
}
break;
case SID_STYLE_DRAGHIERARCHIE:
{
- ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
- if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ SfxPoolItem* pItem = NULL;
+ GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
rSet.DisableItem(nWhich);
+ delete pItem;
}
break;
@@ -516,14 +527,17 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
{
// It is not possible to create PseudoStyleSheets 'by Example';
// normal style sheets need a selected object for that
- ISfxTemplateCommon* pTemplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
- if (pTemplCommon)
+
+ SfxPoolItem* pItem = NULL;
+ GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ if (pFamilyItem)
{
- if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ if (SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
{
rSet.DisableItem(nWhich);
}
- else if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_GRAPHICS)
+ else if (SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_GRAPHICS)
{
if (!mpDrawView->AreObjectsMarked())
{
@@ -531,7 +545,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
}
}
}
- // if there is no (yet) a designer, we have to go back into the
+ // if there is no (yet) a style designer, we have to go back into the
// view state; an actual set family can not be considered
else
{
@@ -540,7 +554,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
rSet.DisableItem(nWhich);
}
}
-
+ delete pItem;
}
break;
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index fcfb881ec9f4..136fcce3ca48 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1596,9 +1596,10 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
case SID_STYLE_EDIT:
{
- ISfxTemplateCommon* pTmplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
-
- if (pTmplCommon && pTmplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ SfxPoolItem* pItem = NULL;
+ GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
{
SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
GetStatusBarState(aSet);
@@ -1609,6 +1610,7 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
rSet.DisableItem(nWhich);
}
}
+ delete pItem;
}
break;
diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx
index e5205c4c1b54..826a39447b89 100644
--- a/sd/source/ui/view/viewshe3.cxx
+++ b/sd/source/ui/view/viewshe3.cxx
@@ -72,6 +72,7 @@
#include <svx/svxids.hrc>
#include <sfx2/request.hxx>
+#include <sfx2/templdlg.hxx>
#include <svl/aeitem.hxx>
#include <basic/sbstar.hxx>
@@ -102,17 +103,12 @@ void ViewShell::GetMenuState( SfxItemSet &rSet )
if( pStyleSheet )
{
SfxStyleFamily eFamily = pStyleSheet->GetFamily();
- if(eFamily == SD_STYLE_FAMILY_GRAPHICS)
- nFamily = 2;
- else if(eFamily == SD_STYLE_FAMILY_CELL )
- nFamily = 3;
- else // SD_STYLE_FAMILY_PSEUDO
- nFamily = 5;
-
+ nFamily = SfxTemplateDialog::SfxFamilyIdToNId(eFamily);
GetDocSh()->SetStyleFamily(nFamily);
}
}
}
+
rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
}
diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index a301d0ba29dc..04e9d4ecdb9e 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -135,17 +135,6 @@ SfxModule* SfxApplication::GetModule_Impl()
}
}
-ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings )
-{
- if( pAppData_Impl->pTemplateCommon )
- return pAppData_Impl->pTemplateCommon;
- SfxChildWindow *pChild = rBindings.GetWorkWindow_Impl()->GetChildWindow_Impl(
- SfxTemplateDialogWrapper::GetChildWindowId() );
- if ( pChild )
- return ((SfxTemplateDialog*) pChild->GetWindow())->GetISfxTemplateCommon();
- return 0;
-}
-
bool SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; }
SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; }
SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; }
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 58d903adde4c..6fcc9de53ff1 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -150,18 +150,11 @@ SfxTemplateDialog::SfxTemplateDialog
pImpl->updateNonFamilyImages();
}
-
-
SfxTemplateDialog::~SfxTemplateDialog()
{
delete pImpl;
}
-ISfxTemplateCommon* SfxTemplateDialog::GetISfxTemplateCommon()
-{
- return pImpl->GetISfxTemplateCommon();
-}
-
void SfxTemplateDialog::SetParagraphFamily()
{
// first select the paragraph family
@@ -170,8 +163,6 @@ void SfxTemplateDialog::SetParagraphFamily()
pImpl->SetAutomaticFilter();
}
-
-
void SfxTemplateDialog::DataChanged( const DataChangedEvent& _rDCEvt )
{
if ( ( DATACHANGED_SETTINGS == _rDCEvt.GetType() ) &&
@@ -253,8 +244,8 @@ sal_Int8 DropListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
{
// special case: page styles are allowed to create new styles by example
// but not allowed to be created by drag and drop
- if( pDialog->nActFamily == SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE ) ||
- pDialog->bNewByExampleDisabled )
+ if (pDialog->GetActualFamily() == SFX_STYLE_FAMILY_PAGE ||
+ pDialog->bNewByExampleDisabled)
return DND_ACTION_NONE;
else
return DND_ACTION_COPY;
@@ -780,7 +771,6 @@ SvTreeListEntry* FillBox_Impl(SvTreeListBox *pBox,
SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window* pW, bool ) :
mbIgnoreSelect( false ),
- aISfxTemplateCommon ( this ),
pBindings ( pB ),
pWindow ( pW ),
pModule ( NULL ),
@@ -833,7 +823,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Win
sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId)
{
const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nId );
- return SfxFamilyIdToNId(pItem->GetFamily())-1;
+ return SfxTemplateDialog::SfxFamilyIdToNId(pItem->GetFamily())-1;
}
void SfxTemplateDialog_Impl::EnableEdit(bool bEnable)
@@ -928,7 +918,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
for( ; nCount--; )
{
const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nCount );
- sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() );
+ sal_uInt16 nId = SfxTemplateDialog::SfxFamilyIdToNId( pItem->GetFamily() );
InsertFamilyItem( nId, pItem );
}
@@ -1017,9 +1007,7 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
m_pDeletionWatcher->signal();
}
-
-
-sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamily )
+sal_uInt16 SfxTemplateDialog::SfxFamilyIdToNId(SfxStyleFamily nFamily)
{
switch ( nFamily )
{
@@ -1032,6 +1020,19 @@ sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamil
}
}
+SfxStyleFamily SfxTemplateDialog::NIdToSfxFamilyId(sal_uInt16 nId)
+{
+ switch (nId)
+ {
+ case 1: return SFX_STYLE_FAMILY_CHAR;
+ case 2: return SFX_STYLE_FAMILY_PARA;
+ case 3: return SFX_STYLE_FAMILY_FRAME;
+ case 4: return SFX_STYLE_FAMILY_PAGE;
+ case 5: return SFX_STYLE_FAMILY_PSEUDO;
+ default: return SFX_STYLE_FAMILY_ALL;
+ }
+}
+
void SfxCommonTemplateDialog_Impl::SetAutomaticFilter()
{
sal_uInt16 nCount = aFilterLb.GetEntryCount();
@@ -1057,7 +1058,7 @@ const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() con
for(size_t i = 0; i < nCount; ++i)
{
const SfxStyleFamilyItem *pItem = pStyleFamilies->at( i );
- sal_uInt16 nId = SfxFamilyIdToNId(pItem->GetFamily());
+ sal_uInt16 nId = SfxTemplateDialog::SfxFamilyIdToNId(pItem->GetFamily());
if(nId == nActFamily)
return pItem;
}
@@ -2482,7 +2483,7 @@ void SfxTemplateDialog_Impl::updateFamilyImages()
for( ; nLoop--; )
{
const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nLoop );
- sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() );
+ sal_uInt16 nId = SfxTemplateDialog::SfxFamilyIdToNId( pItem->GetFamily() );
m_aActionTbL.SetItemImage( nId, pItem->GetImage() );
}
}
@@ -2880,7 +2881,7 @@ sal_Int8 DropToolBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
}
// special case: page styles are allowed to create new styles by example
// but not allowed to be created by drag and drop
- if ( nItemId != SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&&
+ if ( nItemId != SfxTemplateDialog::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&&
IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) &&
!rParent.bNewByExampleDisabled )
{
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index d313a6bc44ea..41328ec979eb 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -139,18 +139,6 @@ private:
class DeletionWatcher;
friend class DeletionWatcher;
bool mbIgnoreSelect;
- class ISfxTemplateCommon_Impl : public ISfxTemplateCommon
- {
- private:
- SfxCommonTemplateDialog_Impl* pDialog;
- public:
- ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl* pDialogP ) : pDialog( pDialogP ) {}
- virtual ~ISfxTemplateCommon_Impl() {}
- virtual SfxStyleFamily GetActualFamily() const SAL_OVERRIDE { return pDialog->GetActualFamily(); }
- virtual OUString GetSelectedEntry() const SAL_OVERRIDE { return pDialog->GetSelectedEntry(); }
- };
-
- ISfxTemplateCommon_Impl aISfxTemplateCommon;
void ReadResource();
void ClearResource();
@@ -286,7 +274,6 @@ public:
virtual void EnableHide( bool b = true ) { bCanHide = b; }
virtual void EnableShow( bool b = true ) { bCanShow = b; }
- ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; }
Window* GetWindow() { return pWindow; }
void EnableTreeDrag( bool b = true );
@@ -307,9 +294,6 @@ public:
// normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
virtual PopupMenu* CreateContextMenu( void );
- // converts from SFX_STYLE_FAMILY Ids to 1-5
- static sal_uInt16 SfxFamilyIdToNId( SfxStyleFamily nFamily );
-
void SetAutomaticFilter();
};
diff --git a/sw/source/core/uibase/app/docst.cxx b/sw/source/core/uibase/app/docst.cxx
index 75e38c6c1c49..dc5af5c35665 100644
--- a/sw/source/core/uibase/app/docst.cxx
+++ b/sw/source/core/uibase/app/docst.cxx
@@ -100,9 +100,14 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
else
{
SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
- const ISfxTemplateCommon* pCommon = SFX_APP()->GetCurrentTemplateCommon(pFrame->GetBindings());
- if( pCommon )
- nActualFamily = static_cast< sal_uInt16 >(pCommon->GetActualFamily());
+ SfxPoolItem* pItem = NULL;
+ pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ if (pFamilyItem)
+ {
+ nActualFamily = static_cast<sal_uInt16>(SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()));
+ }
+ delete pItem;
}
while (nWhich)