[Libreoffice-commits] core.git: include/sfx2 sc/source sd/source sfx2/source sw/source
Caolán McNamara
caolanm at redhat.com
Fri May 30 03:38:32 PDT 2014
include/sfx2/app.hxx | 3 ---
include/sfx2/templdlg.hxx | 18 +++++-------------
sc/source/ui/view/formatsh.cxx | 17 +++++++++++------
sd/source/ui/view/drviewsf.cxx | 38 ++++++++++++++++++++++++++------------
sd/source/ui/view/outlnvsh.cxx | 8 +++++---
sd/source/ui/view/viewshe3.cxx | 10 +++-------
sfx2/source/appl/appmisc.cxx | 9 ---------
sfx2/source/dialog/templdlg.cxx | 37 +++++++++++++++++++------------------
sfx2/source/inc/templdgi.hxx | 15 ---------------
sw/source/uibase/app/docst.cxx | 11 ++++++++---
10 files changed, 77 insertions(+), 89 deletions(-)
New commits:
commit 7a211e834fc271d3f28d7f8c49197c925242d862
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 30 11:09:59 2014 +0100
Resolves: fdo#79360 impress hangs on using sidebar new style
because those styles are "pseudo-styles" and a new one cannot be
added. The possibility is supposed to be disabled, and it is
disabled in the floating stylelist. The old code assumes there
can only be one of these stylelists and when a stylelist
queries if the "new" should be disabled the callback asks
the stylelist what family is selected, but only asks the floating one.
So, floating closed, sidebar open, the new is not disabled.
Implement the ancient TODO now that we have to. Instead of asking
the stylelist what family is selected, query the frame for what
is the current SID_STYLE_FAMILY as set by whatever is the active
stylelist.
What's disturbing is the SID_STYLE_FAMILY values are not SfxStyleFamily, but
indexes that have to be mapped to SfxStyleFamily. I bet there are a pile of
bugs around that, especially with little islands of different conversion
codesites
Change-Id: I85c8032d7c26ae6eea245685748f89b2a860e767
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index 17b80b9..3f81077 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 bc6cdc7..8c9f2f1 100644
--- a/include/sfx2/templdlg.hxx
+++ b/include/sfx2/templdlg.hxx
@@ -30,19 +30,7 @@
class SfxTemplateDialog_Impl;
-// class ISfxTemplateCommon ----------------------------------------------
-
-class ISfxTemplateCommon
-{
-public:
- virtual SfxStyleFamily GetActualFamily() const = 0;
-
-protected:
- ~ISfxTemplateCommon() {}
-};
-
// class SfxTemplateDialog -----------------------------------------------
-
class SfxTemplateDialog : public SfxDockingWindow
{
private:
@@ -62,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 3522087..045ddf0 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 6c74365..d161d0f 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -486,30 +486,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;
@@ -517,14 +528,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())
{
@@ -532,7 +546,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
{
@@ -541,7 +555,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 291ea39..b78fbfb 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1594,9 +1594,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);
@@ -1607,6 +1608,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 e5205c4..826a394 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 62c7fb9..04e9d4e 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -135,15 +135,6 @@ SfxModule* SfxApplication::GetModule_Impl()
}
}
-ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings )
-{
- 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 011a736..6fcc9de 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() ) &&
@@ -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 e49214b..41328ec 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -139,17 +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(); }
- };
-
- ISfxTemplateCommon_Impl aISfxTemplateCommon;
void ReadResource();
void ClearResource();
@@ -285,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 );
@@ -306,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/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 36e29fc..6ea1f32 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/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)
More information about the Libreoffice-commits
mailing list