diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-12 15:55:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-13 06:54:23 +0000 |
commit | 8fce16fb573506c24aa06e86b476fa6f42ea60b9 (patch) | |
tree | 2817c8c6ff49b141dcb2dfd38582b7272ecff0f1 /sw | |
parent | b39feae4f12b07a0fdb2c8c2a48d5aae613cd7c9 (diff) |
convert SvxPageUsage to scoped enum
and expand out the bit-tricks some of the code was playing to make it
more obvious what is going on
Change-Id: I9c98334393b939b1d900425f6133556ce88247ae
Reviewed-on: https://gerrit.libreoffice.org/29734
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/frmdlg/colex.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageFormatPanel.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageMarginControl.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageStylesPanel.cxx | 22 | ||||
-rw-r--r-- | sw/source/uibase/utlui/uitool.cxx | 32 |
5 files changed, 34 insertions, 34 deletions
diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx index 60eb0c3abcf3..a71f884dab30 100644 --- a/sw/source/uibase/frmdlg/colex.cxx +++ b/sw/source/uibase/frmdlg/colex.cxx @@ -224,7 +224,7 @@ void SwColExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOr long nL = GetLeft(); long nR = GetRight(); - if (GetUsage() == SVX_PAGE_MIRROR && !bSecond) + if (GetUsage() == SvxPageUsage::Mirror && !bSecond) { // swap for mirrored nL = GetRight(); @@ -545,7 +545,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point long nL = GetLeft(); long nR = GetRight(); - if (GetUsage() == SVX_PAGE_MIRROR && !bSecond) + if (GetUsage() == SvxPageUsage::Mirror && !bSecond) { // rotate for mirrored nL = GetRight(); diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx index 078f5e3f6ad1..2cfe16871fde 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.cxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx @@ -276,9 +276,9 @@ IMPL_LINK_NOARG(PageFormatPanel, PaperModifyMarginHdl, ListBox&, void) { ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin ); ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin ); - if(bMirrored != (mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR)) + if(bMirrored != (mpPageItem->GetPageUsage() == SvxPageUsage::Mirror)) { - mpPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL ); + mpPageItem->SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All ); mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE, SfxCallMode::RECORD, { mpPageItem.get() }); } @@ -337,7 +337,7 @@ void PageFormatPanel::UpdateMarginBox() mnPageTopMargin = mpPageULMarginItem->GetUpper(); mnPageBottomMargin = mpPageULMarginItem->GetLower(); - bool bMirrored = (mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR); + bool bMirrored = (mpPageItem->GetPageUsage() == SvxPageUsage::Mirror); if( IsNone(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(0); diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index 85825ce720c5..897ef69cd18d 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -117,7 +117,7 @@ PageMarginControl::PageMarginControl( sal_uInt16 nId ) { SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>( pItem )->IsLandscape(); - m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SVX_PAGE_MIRROR; + m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SvxPageUsage::Mirror; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem ); pSize = static_cast<const SvxSizeItem*>( pItem ); SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pItem ); @@ -471,7 +471,7 @@ void PageMarginControl::ExecutePageLayoutChange( const bool bMirrored ) if ( SfxViewFrame::Current() ) { std::unique_ptr<SvxPageItem> pPageItem( new SvxPageItem( SID_ATTR_PAGE ) ); - pPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL ); + pPageItem->SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All ); SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE, SfxCallMode::RECORD, { pPageItem.get() } ); pPageItem.reset(); diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx b/sw/source/uibase/sidebar/PageStylesPanel.cxx index 7cc75c5da45c..95985af7ed5a 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.cxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx @@ -41,28 +41,28 @@ using namespace ::com::sun::star; namespace sw { namespace sidebar{ -const sal_uInt16 aArr[] = +const SvxPageUsage aArr[] = { - SVX_PAGE_ALL, - SVX_PAGE_MIRROR, - SVX_PAGE_RIGHT, - SVX_PAGE_LEFT + SvxPageUsage::All, + SvxPageUsage::Mirror, + SvxPageUsage::Right, + SvxPageUsage::Left }; -sal_uInt16 PageUsageToPos_Impl( sal_uInt16 nUsage ) +sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) { for ( sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aArr); ++i ) - if ( aArr[i] == ( nUsage & 0x000f ) ) + if ( aArr[i] == nUsage ) return i; - return SVX_PAGE_ALL; + return 3; } -sal_uInt16 PosToPageUsage_Impl( sal_uInt16 nPos ) +SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos ) { if ( nPos >= SAL_N_ELEMENTS(aArr) ) - return 0; + return SvxPageUsage::NONE; return aArr[nPos]; } @@ -357,7 +357,7 @@ void PageStylesPanel::NotifyItemUpdate( SvxNumType eNumType = mpPageItem->GetNumType(); mpNumberSelectLB->SetSelection(eNumType); - sal_uInt16 nUse = mpPageItem->GetPageUsage(); + SvxPageUsage nUse = mpPageItem->GetPageUsage(); mpLayoutSelectLB->SelectEntryPos( PageUsageToPos_Impl( nUse ) ); } } diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index 571b0ba394f1..a6be386e0be0 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -234,30 +234,30 @@ void FillHdFt(SwFrameFormat* pFormat, const SfxItemSet& rSet) /// Convert from UseOnPage to SvxPageUsage. SvxPageUsage lcl_convertUseToSvx(UseOnPage nUse) { - int nRet = 0; + SvxPageUsage nRet = SvxPageUsage::NONE; if (nUse & UseOnPage::Left) - nRet |= SVX_PAGE_LEFT; + nRet = SvxPageUsage::Left; if (nUse & UseOnPage::Right) - nRet |= SVX_PAGE_RIGHT; + nRet = SvxPageUsage::Right; if ((nUse & UseOnPage::All) == UseOnPage::All) - nRet |= SVX_PAGE_ALL; + nRet = SvxPageUsage::All; if ((nUse & UseOnPage::Mirror) == UseOnPage::Mirror) - nRet |= SVX_PAGE_MIRROR; - return (SvxPageUsage)nRet; + nRet = SvxPageUsage::Mirror; + return nRet; } /// Convert from SvxPageUsage to UseOnPage. UseOnPage lcl_convertUseFromSvx(SvxPageUsage nUse) { UseOnPage nRet = UseOnPage::NONE; - if ((nUse & SVX_PAGE_LEFT) == SVX_PAGE_LEFT) - nRet |= UseOnPage::Left; - if ((nUse & SVX_PAGE_RIGHT) == SVX_PAGE_RIGHT) - nRet |= UseOnPage::Right; - if ((nUse & SVX_PAGE_ALL) == SVX_PAGE_ALL) - nRet |= UseOnPage::All; - if ((nUse & SVX_PAGE_MIRROR) == SVX_PAGE_MIRROR) - nRet |= UseOnPage::Mirror; + if (nUse == SvxPageUsage::Left) + nRet = UseOnPage::Left; + else if (nUse == SvxPageUsage::Right) + nRet = UseOnPage::Right; + else if (nUse == SvxPageUsage::All) + nRet = UseOnPage::All; + else if (nUse == SvxPageUsage::Mirror) + nRet = UseOnPage::Mirror; return nRet; } @@ -276,8 +276,8 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) { const SvxPageItem& rPageItem = static_cast<const SvxPageItem&>(rSet.Get(SID_ATTR_PAGE)); - const SvxPageUsage nUse = (SvxPageUsage)rPageItem.GetPageUsage(); - if(nUse) + const SvxPageUsage nUse = rPageItem.GetPageUsage(); + if(nUse != SvxPageUsage::NONE) rPageDesc.SetUseOn( lcl_convertUseFromSvx(nUse) ); rPageDesc.SetLandscape(rPageItem.IsLandscape()); SvxNumberType aNumType; |