summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-08-31 23:36:19 +0200
committerMichael Stahl <mstahl@redhat.com>2016-08-31 23:45:58 +0200
commit75c39b903f06b656293edf20ec4a5173a0755fb6 (patch)
treefa9972a4f9e3553fda5307c4fe1d1f0807f46237 /sfx2
parentfa8db4cb890ffbbd20790eff2e295dfbc048b7b4 (diff)
let's make Impress crash less - SfxStyleFamily edition
Commit bcb41235deaf4b7ca90522bda3ba21a686819e6e - in addition to introducing the enum SfxStyleFamily - inconsistently converted one call of DrawDocShell::SetStyleFamily to use enum SfxStyleFamily instead of a mysterious "5", but did not adapt all of the code that extracts the SfxUInt16Item that subsequently extracts this value and expects a number 0-5. Since it's clearly inexcusably stupid to have 2 different public sets of integers identifying styles, make the usage of the second "array index" integers private to templdlg.cxx; the SfxUInt16 item now always contains enum SfxStyleFamily. (regression from bcb41235deaf4b7ca90522bda3ba21a686819e6e) Change-Id: I333575c504277c2046f8f5a6b36ae3f86b3b3201
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/templdlg.cxx73
-rw-r--r--sfx2/source/dialog/tplcitem.cxx4
-rw-r--r--sfx2/source/inc/templdgi.hxx2
3 files changed, 44 insertions, 35 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 8e0d421978b2..4aca5b74dc5e 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -639,6 +639,40 @@ SvTreeListEntry* FillBox_Impl(SvTreeListBox* pBox,
return pTreeListEntry;
}
+
+namespace SfxTemplate
+{
+ // converts from SFX_STYLE_FAMILY Ids to 1-6
+ sal_uInt16 SfxFamilyIdToNId(SfxStyleFamily nFamily)
+ {
+ switch ( nFamily )
+ {
+ case SfxStyleFamily::Char: return 1;
+ case SfxStyleFamily::Para: return 2;
+ case SfxStyleFamily::Frame: return 3;
+ case SfxStyleFamily::Page: return 4;
+ case SfxStyleFamily::Pseudo: return 5;
+ case SfxStyleFamily::Table: return 6;
+ default: return 0;
+ }
+ }
+
+ // converts from 1-6 to SFX_STYLE_FAMILY Ids
+ SfxStyleFamily NIdToSfxFamilyId(sal_uInt16 nId)
+ {
+ switch (nId)
+ {
+ case 1: return SfxStyleFamily::Char;
+ case 2: return SfxStyleFamily::Para;
+ case 3: return SfxStyleFamily::Frame;
+ case 4: return SfxStyleFamily::Page;
+ case 5: return SfxStyleFamily::Pseudo;
+ case 6: return SfxStyleFamily::Table;
+ default: return SfxStyleFamily::All;
+ }
+ }
+}
+
// Constructor
SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl::Window* pW, bool )
@@ -887,37 +921,6 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
aPreviewCheckbox.disposeAndClear();
}
-namespace SfxTemplate
-{
- sal_uInt16 SfxFamilyIdToNId(SfxStyleFamily nFamily)
- {
- switch ( nFamily )
- {
- case SfxStyleFamily::Char: return 1;
- case SfxStyleFamily::Para: return 2;
- case SfxStyleFamily::Frame: return 3;
- case SfxStyleFamily::Page: return 4;
- case SfxStyleFamily::Pseudo: return 5;
- case SfxStyleFamily::Table: return 6;
- default: return 0;
- }
- }
-
- SfxStyleFamily NIdToSfxFamilyId(sal_uInt16 nId)
- {
- switch (nId)
- {
- case 1: return SfxStyleFamily::Char;
- case 2: return SfxStyleFamily::Para;
- case 3: return SfxStyleFamily::Frame;
- case 4: return SfxStyleFamily::Page;
- case 5: return SfxStyleFamily::Pseudo;
- case 6: return SfxStyleFamily::Table;
- default: return SfxStyleFamily::All;
- }
- }
-}
-
// Helper function: Access to the current family item
const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const
{
@@ -1701,12 +1704,14 @@ IMPL_LINK_TYPED( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox&, rBox,
// Select-Handler for the Toolbox
void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry, bool bPreviewRefresh)
{
+ assert((0 < nEntry && nEntry <= MAX_FAMILIES) || 0xffff == nEntry);
if( nEntry != nActFamily || bPreviewRefresh )
{
CheckItem( nActFamily, false );
nActFamily = nEntry;
SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl();
- SfxUInt16Item aItem( SID_STYLE_FAMILY, nEntry );
+ SfxUInt16Item const aItem(SID_STYLE_FAMILY,
+ static_cast<sal_uInt16>(SfxTemplate::NIdToSfxFamilyId(nEntry)));
pDispat->ExecuteList(SID_STYLE_FAMILY, SfxCallMode::SYNCHRON, { &aItem });
pBindings->Invalidate( SID_STYLE_FAMILY );
pBindings->Update( SID_STYLE_FAMILY );
@@ -2563,8 +2568,10 @@ IMPL_LINK_TYPED( SfxTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu, bool)
return false;
}
-void SfxCommonTemplateDialog_Impl::SetFamily( sal_uInt16 nId )
+void SfxCommonTemplateDialog_Impl::SetFamily(SfxStyleFamily const nFamily)
{
+ sal_uInt16 const nId(SfxTemplate::SfxFamilyIdToNId(nFamily));
+ assert((0 < nId && nId <= MAX_FAMILIES) || 0xffff == nId);
if ( nId != nActFamily )
{
if ( nActFamily != 0xFFFF )
diff --git a/sfx2/source/dialog/tplcitem.cxx b/sfx2/source/dialog/tplcitem.cxx
index e0916ba64450..bf66c33b88fe 100644
--- a/sfx2/source/dialog/tplcitem.cxx
+++ b/sfx2/source/dialog/tplcitem.cxx
@@ -148,7 +148,9 @@ void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID, SfxItemState eSta
{
const SfxUInt16Item *pStateItem = dynamic_cast< const SfxUInt16Item* >(pItem);
if (pStateItem)
- rTemplateDlg.SetFamily( pStateItem->GetValue() );
+ {
+ rTemplateDlg.SetFamily(static_cast<SfxStyleFamily>(pStateItem->GetValue()));
+ }
break;
}
}
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index cf403d7d83b0..8300daa13a1d 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -274,7 +274,7 @@ protected:
void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
void FamilySelect( sal_uInt16 nId, bool bPreviewRefresh = false );
- void SetFamily( sal_uInt16 nId );
+ void SetFamily(SfxStyleFamily nFamily);
void ActionSelect( sal_uInt16 nId );
sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh );