From 83ab72efe7dbb9047e89ba2775228b2d81f96bc9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 22 Apr 2015 14:59:54 +0200 Subject: convert SW_BORDER_MODE constants to scoped enum Change-Id: I7b2e03a5cacf5d2a706ba8e2d3b276fcb3f7e88b --- cui/source/inc/border.hxx | 2 +- cui/source/tabpages/border.cxx | 18 +++++++++--------- include/svx/flagsdef.hxx | 16 +++++++++++++--- sw/inc/swabstdlg.hxx | 3 ++- sw/source/ui/chrdlg/pardlg.cxx | 2 +- sw/source/ui/dialog/swdlgfact.cxx | 2 +- sw/source/ui/dialog/swdlgfact.hxx | 2 +- sw/source/ui/fmtui/tmpdlg.cxx | 4 ++-- sw/source/ui/frmdlg/frmdlg.cxx | 2 +- sw/source/ui/frmdlg/uiborder.cxx | 6 +++--- sw/source/ui/table/tabledlg.cxx | 2 +- sw/source/uibase/inc/uiborder.hxx | 2 +- sw/source/uibase/shells/basesh.cxx | 6 +++--- 13 files changed, 39 insertions(+), 28 deletions(-) diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx index 8f129977a546..75b438b1962a 100644 --- a/cui/source/inc/border.hxx +++ b/cui/source/inc/border.hxx @@ -103,7 +103,7 @@ private: ImageList aBorderImgLst; long nMinValue; ///< minimum distance - int nSWMode; ///< table, textframe, paragraph + SwBorderModes nSWMode; ///< table, textframe, paragraph bool mbHorEnabled; ///< true = Inner horizontal border enabled. bool mbVerEnabled; ///< true = Inner vertical border enabled. diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 387e003402c3..b304afa3955a 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -93,7 +93,7 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)), aBorderImgLst( CUI_RES(IL_PRE_BITMAPS)), nMinValue(0), - nSWMode(0), + nSWMode(SwBorderModes::NONE), mbHorEnabled( false ), mbVerEnabled( false ), mbTLBREnabled( false ), @@ -581,7 +581,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) // there are no shadows in Html-mode and only complete borders m_pShadowFrame->Disable(); - if( !(nSWMode & SW_BORDER_MODE_TABLE) ) + if( !(nSWMode & SwBorderModes::TABLE) ) { m_pUserDefFT->Disable(); m_pFrameSel->Disable(); @@ -666,7 +666,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) if( !m_pLeftMF->GetText().isEmpty() || !m_pRightMF->GetText().isEmpty() || !m_pTopMF->GetText().isEmpty() || !m_pBottomMF->GetText().isEmpty() ) { - if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SW_BORDER_MODE_TABLE)) && + if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SwBorderModes::TABLE)) && (m_pLeftMF->IsModified()||m_pRightMF->IsModified()|| m_pTopMF->IsModified()||m_pBottomMF->IsModified()) )|| m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_HIDE @@ -1107,7 +1107,7 @@ IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl) if(!mbUseMarginItem && m_pLeftMF->IsVisible()) { bool bLineSet = m_pFrameSel->IsAnyBorderVisible(); - bool bMinAllowed = 0 != (nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_TABLE)); + bool bMinAllowed = bool(nSWMode & (SwBorderModes::FRAME|SwBorderModes::TABLE)); bool bSpaceModified = m_pLeftMF->IsModified()|| m_pRightMF->IsModified()|| m_pTopMF->IsModified()|| @@ -1152,7 +1152,7 @@ IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl) SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::TOP|SvxBoxInfoItemValidFlags::BOTTOM|SvxBoxInfoItemValidFlags::LEFT|SvxBoxInfoItemValidFlags::RIGHT; // for other objects (paragraph, page, frame, character) the edit is disabled, if there's no border set - if(!(nSWMode & SW_BORDER_MODE_TABLE)) + if(!(nSWMode & SwBorderModes::TABLE)) { if(bLineSet) { @@ -1217,16 +1217,16 @@ void SvxBorderTabPage::PageCreated(const SfxAllItemSet& aSet) SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false); if (pSWModeItem) { - nSWMode = pSWModeItem->GetValue(); + nSWMode = static_cast(pSWModeItem->GetValue()); // #i43593# // show checkbox for format.paragraph - if ( nSWMode == SW_BORDER_MODE_PARA ) + if ( nSWMode == SwBorderModes::PARA ) { m_pMergeWithNextCB->Show(); m_pPropertiesFrame->Show(); } // show checkbox for format.paragraph - else if ( nSWMode == SW_BORDER_MODE_TABLE ) + else if ( nSWMode == SwBorderModes::TABLE ) { m_pMergeAdjacentBordersCB->Show(); m_pPropertiesFrame->Show(); @@ -1239,7 +1239,7 @@ void SvxBorderTabPage::PageCreated(const SfxAllItemSet& aSet) void SvxBorderTabPage::SetTableMode() { - nSWMode = SW_BORDER_MODE_TABLE; + nSWMode = SwBorderModes::TABLE; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/flagsdef.hxx b/include/svx/flagsdef.hxx index a3e637bea94f..86a8f3480364 100644 --- a/include/svx/flagsdef.hxx +++ b/include/svx/flagsdef.hxx @@ -19,13 +19,23 @@ #ifndef INCLUDED_SVX_FLAGSDEF_HXX #define INCLUDED_SVX_FLAGSDEF_HXX +#include + // defines --------------------------------------------------------------- // copy from border.hxx // Border-Modes for SvxBorderTabPage -#define SW_BORDER_MODE_PARA 0x01 -#define SW_BORDER_MODE_TABLE 0x02 -#define SW_BORDER_MODE_FRAME 0x04 +enum class SwBorderModes +{ + NONE = 0x00, + PARA = 0x01, + TABLE = 0x02, + FRAME = 0x04, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} // flags for SvxBackgroundTabPage #define SVX_SHOW_SELECTOR 0x01 diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 64b0f2c759f3..a4fa8d788185 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -72,6 +72,7 @@ class SwChildWinWrapper; struct SfxChildWinInfo; class SwTOXMark; struct SwDocStat; +enum class SwBorderModes; #include namespace com{namespace sun{namespace star{ @@ -373,7 +374,7 @@ public: virtual AbstractSwAutoFormatDlg * CreateSwAutoFormatDlg( vcl::Window* pParent, SwWrtShell* pShell, bool bSetAutoFmt = true, const SwTableAutoFmt* pSelFmt = 0 ) = 0; - virtual SfxAbstractDialog * CreateSwBorderDlg ( vcl::Window* pParent, SfxItemSet& rSet, sal_uInt16 nType, int nResId ) = 0; + virtual SfxAbstractDialog * CreateSwBorderDlg ( vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType, int nResId ) = 0; virtual SfxAbstractDialog * CreateSwWrapDlg ( vcl::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, bool bDrawMode, int nResId ) = 0; virtual VclAbstractDialog * CreateSwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rFnc) = 0; diff --git a/sw/source/ui/chrdlg/pardlg.cxx b/sw/source/ui/chrdlg/pardlg.cxx index f132d66135e8..1601db38d557 100644 --- a/sw/source/ui/chrdlg/pardlg.cxx +++ b/sw/source/ui/chrdlg/pardlg.cxx @@ -180,7 +180,7 @@ void SwParaDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) // Table borders cannot get any shade in Writer if (nId == m_nParaBorder) { - aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA)); + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast(SwBorderModes::PARA))); rPage.PageCreated(aSet); } else if( nId == m_nParaStd ) diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index ebc76da20d73..a372be0067d2 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -847,7 +847,7 @@ AbstractSwAutoFormatDlg * SwAbstractDialogFactory_Impl::CreateSwAutoFormatDlg(vc return new AbstractSwAutoFormatDlg_Impl(pDlg); } -SfxAbstractDialog * SwAbstractDialogFactory_Impl::CreateSwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, sal_uInt16 nType, int nResId ) +SfxAbstractDialog * SwAbstractDialogFactory_Impl::CreateSwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType, int nResId ) { VclPtr pDlg; switch ( nResId ) diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 4ec9fa68ad33..8384f03b98c3 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -420,7 +420,7 @@ public: virtual AbstractSwAutoFormatDlg * CreateSwAutoFormatDlg( vcl::Window* pParent, SwWrtShell* pShell, bool bSetAutoFmt = true, const SwTableAutoFmt* pSelFmt = 0 ) SAL_OVERRIDE; - virtual SfxAbstractDialog * CreateSwBorderDlg (vcl::Window* pParent, SfxItemSet& rSet, sal_uInt16 nType, int nResId ) SAL_OVERRIDE; + virtual SfxAbstractDialog * CreateSwBorderDlg (vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType, int nResId ) SAL_OVERRIDE; virtual SfxAbstractDialog * CreateSwWrapDlg ( vcl::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh, bool bDrawMode, int nResId ) SAL_OVERRIDE; virtual VclAbstractDialog * CreateSwTableWidthDlg(vcl::Window *pParent, SwTableFUNC &rFnc) SAL_OVERRIDE; diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx index 11dccd075cc9..d8d1aa37b320 100644 --- a/sw/source/ui/fmtui/tmpdlg.cxx +++ b/sw/source/ui/fmtui/tmpdlg.cxx @@ -594,11 +594,11 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) { if( SFX_STYLE_FAMILY_PARA == nType ) { - aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA)); + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast(SwBorderModes::PARA))); } else if( SFX_STYLE_FAMILY_FRAME == nType ) { - aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME)); + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast(SwBorderModes::FRAME))); } rPage.PageCreated(aSet); } diff --git a/sw/source/ui/frmdlg/frmdlg.cxx b/sw/source/ui/frmdlg/frmdlg.cxx index 99dcd41a47bf..df93bfbe0bde 100644 --- a/sw/source/ui/frmdlg/frmdlg.cxx +++ b/sw/source/ui/frmdlg/frmdlg.cxx @@ -193,7 +193,7 @@ void SwFrmDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) //} else if (nId == m_nBorderId) { - aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME)); + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast(SwBorderModes::FRAME))); rPage.PageCreated(aSet); } //UUUU inits for Area and Transparency TabPages diff --git a/sw/source/ui/frmdlg/uiborder.cxx b/sw/source/ui/frmdlg/uiborder.cxx index b5201b62a553..5108a122832f 100644 --- a/sw/source/ui/frmdlg/uiborder.cxx +++ b/sw/source/ui/frmdlg/uiborder.cxx @@ -29,7 +29,7 @@ #include "uiborder.hxx" #include "frmui.hrc" -SwBorderDlg::SwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, sal_uInt16 nType) : +SwBorderDlg::SwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType) : SfxSingleTabDialog(pParent, rSet) { @@ -43,8 +43,8 @@ SwBorderDlg::SwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, sal_uInt16 nTyp { SfxTabPage* pNewPage = (*fnCreatePage)( get_content_area(), &rSet ); SfxAllItemSet aSet(*(rSet.GetPool())); - aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,nType)); - if(SW_BORDER_MODE_TABLE == nType) + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE, static_cast(nType))); + if(SwBorderModes::TABLE == nType) aSet.Put (SfxUInt32Item(SID_FLAG_TYPE,SVX_HIDESHADOWCTL)); pNewPage->PageCreated(aSet); SetTabPage(pNewPage); diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx index e6636d1b2c5b..c76dc0fe477c 100644 --- a/sw/source/ui/table/tabledlg.cxx +++ b/sw/source/ui/table/tabledlg.cxx @@ -1266,7 +1266,7 @@ void SwTableTabDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) } else if (nId == m_nBorderId) { - aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_TABLE)); + aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE, static_cast(SwBorderModes::TABLE))); rPage.PageCreated(aSet); } else if (nId == m_nTextFlowId) diff --git a/sw/source/uibase/inc/uiborder.hxx b/sw/source/uibase/inc/uiborder.hxx index 4dc694736840..71d11d48c740 100644 --- a/sw/source/uibase/inc/uiborder.hxx +++ b/sw/source/uibase/inc/uiborder.hxx @@ -32,7 +32,7 @@ public: // SW_BORDER_MODE_TABLE // SW_BORDER_MODE_FRAME - SwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, sal_uInt16 nType); + SwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes nType); virtual ~SwBorderDlg(); }; diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 27a25d569fe1..5e724117f2d2 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -2413,7 +2413,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG )); + pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SwBorderModes::TABLE, RC_DLG_SWBORDERDLG )); OSL_ENSURE(pDlg, "Dialog creation failed!"); if ( pDlg->Execute() == RET_OK ) { @@ -2430,7 +2430,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG )); + pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SwBorderModes::FRAME, RC_DLG_SWBORDERDLG )); OSL_ENSURE(pDlg, "Dialog creation failed!"); if ( pDlg->Execute() == RET_OK ) { @@ -2448,7 +2448,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG )); + pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SwBorderModes::PARA, RC_DLG_SWBORDERDLG )); OSL_ENSURE(pDlg, "Dialog creation failed!"); if ( pDlg->Execute() == RET_OK ) { -- cgit v1.2.3