[Libreoffice-commits] core.git: cui/source include/svx sc/source sd/source svx/source sw/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Oct 13 06:57:27 UTC 2016


 cui/source/tabpages/page.cxx                   |   26 ++++++++---------
 include/svx/pagectrl.hxx                       |    7 ++--
 include/svx/pageitem.hxx                       |   19 ++++++------
 sc/source/filter/starcalc/scflt.cxx            |    2 -
 sc/source/ui/docshell/docsh4.cxx               |   10 +++---
 sc/source/ui/inc/printfun.hxx                  |    2 -
 sc/source/ui/inc/tphf.hxx                      |    2 -
 sc/source/ui/pagedlg/hfedtdlg.cxx              |    3 --
 sc/source/ui/pagedlg/tphf.cxx                  |    4 +-
 sc/source/ui/view/printfun.cxx                 |    8 ++---
 sd/source/ui/func/fupage.cxx                   |    2 -
 svx/source/dialog/hdft.cxx                     |    8 ++---
 svx/source/dialog/pagectrl.cxx                 |   12 ++++----
 svx/source/items/pageitem.cxx                  |   37 ++++++++++++-------------
 sw/source/uibase/frmdlg/colex.cxx              |    4 +-
 sw/source/uibase/sidebar/PageFormatPanel.cxx   |    6 ++--
 sw/source/uibase/sidebar/PageMarginControl.cxx |    4 +-
 sw/source/uibase/sidebar/PageStylesPanel.cxx   |   22 +++++++-------
 sw/source/uibase/utlui/uitool.cxx              |   32 ++++++++++-----------
 19 files changed, 105 insertions(+), 105 deletions(-)

New commits:
commit 8fce16fb573506c24aa06e86b476fa6f42ea60b9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Oct 12 15:55:27 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index a6097ea..b15879f 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -79,28 +79,28 @@ const sal_uInt16 SvxPageDescPage::pRanges[] =
 };
 // ------- Mapping page layout ------------------------------------------
 
-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];
 }
 
@@ -468,7 +468,7 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
     // general page data
     SvxNumType eNumType = css::style::NumberingType::ARABIC;
     bLandscape = ( mpDefPrinter->GetOrientation() == Orientation::Landscape );
-    sal_uInt16 nUse = (sal_uInt16)SVX_PAGE_ALL;
+    SvxPageUsage nUse = SvxPageUsage::All;
     pItem = GetItem( *rSet, SID_ATTR_PAGE );
 
     if ( pItem )
@@ -894,9 +894,9 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet )
 IMPL_LINK_NOARG(SvxPageDescPage, LayoutHdl_Impl, ListBox&, void)
 {
     // switch inside outside
-    const sal_uInt16 nPos = PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() );
+    const SvxPageUsage nUsage = PosToPageUsage_Impl( m_pLayoutBox->GetSelectEntryPos() );
 
-    if ( nPos == SVX_PAGE_MIRROR )
+    if ( nUsage == SvxPageUsage::Mirror )
     {
         m_pLeftMarginLbl->Hide();
         m_pRightMarginLbl->Hide();
diff --git a/include/svx/pagectrl.hxx b/include/svx/pagectrl.hxx
index 82225f4..50095f6 100644
--- a/include/svx/pagectrl.hxx
+++ b/include/svx/pagectrl.hxx
@@ -24,6 +24,7 @@
 #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
 
 class SvxBoxItem;
+enum class SvxPageUsage;
 
 class SVX_DLLPUBLIC SvxPageWindow : public vcl::Window
 {
@@ -66,7 +67,7 @@ private:
     bool bHorz : 1;
     bool bVert : 1;
 
-    sal_uInt16 eUsage;
+    SvxPageUsage eUsage;
 
 protected:
     virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
@@ -143,8 +144,8 @@ public:
     long GetFtDist() const { return nFtDist; }
     long GetFtHeight() const { return nFtHeight; }
 
-    void SetUsage(sal_uInt16 eU) { eUsage = eU; }
-    sal_uInt16 GetUsage() const { return eUsage; }
+    void SetUsage(SvxPageUsage eU) { eUsage = eU; }
+    SvxPageUsage GetUsage() const { return eUsage; }
 
     void SetHeader( bool bNew ) { bHeader = bNew; }
     void SetFooter( bool bNew ) { bFooter = bNew; }
diff --git a/include/svx/pageitem.hxx b/include/svx/pageitem.hxx
index 227cc39..5849473 100644
--- a/include/svx/pageitem.hxx
+++ b/include/svx/pageitem.hxx
@@ -28,12 +28,13 @@ using SvxNumType = sal_Int16; // css::style::NumberingType constants
   usage of the page
  --------------------------------------------------------------------*/
 
-enum SvxPageUsage
+enum class SvxPageUsage
 {
-    SVX_PAGE_LEFT           = 0x0001,
-    SVX_PAGE_RIGHT          = 0x0002,
-    SVX_PAGE_ALL            = 0x0003,
-    SVX_PAGE_MIRROR         = 0x0007
+    NONE           = 0,
+    Left           = 1,
+    Right          = 2,
+    All            = 3,
+    Mirror         = 7
 };
 
 /*--------------------------------------------------------------------
@@ -51,7 +52,7 @@ private:
     OUString            aDescName;          // name of the template
     SvxNumType          eNumType;           // enumeration
     bool                bLandscape;         // Portrait / Landscape
-    sal_uInt16          eUse;               // Layout
+    SvxPageUsage        eUse;               // Layout
 
 public:
 
@@ -75,8 +76,8 @@ public:
     virtual SvStream&        Store( SvStream& , sal_uInt16 nItemVersion ) const override;
 
     // orientation
-    sal_uInt16          GetPageUsage() const                { return eUse;       }
-    void            SetPageUsage(sal_uInt16 eU)             { eUse= eU;          }
+    SvxPageUsage    GetPageUsage() const                { return eUse;       }
+    void            SetPageUsage(SvxPageUsage eU)       { eUse= eU;          }
 
     bool            IsLandscape() const                 { return bLandscape; }
     void            SetLandscape(bool bL)               { bLandscape = bL;   }
@@ -86,7 +87,7 @@ public:
     void            SetNumType(SvxNumType eNum)         { eNumType = eNum;   }
 
     // name of the descriptor
-    void            SetDescName(const OUString& rStr)     { aDescName = rStr;  }
+    void            SetDescName(const OUString& rStr)   { aDescName = rStr;  }
 };
 
 
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx
index 79ffdb9..2a82b82 100644
--- a/sc/source/filter/starcalc/scflt.cxx
+++ b/sc/source/filter/starcalc/scflt.cxx
@@ -859,7 +859,7 @@ void Sc10PageCollection::PutToDoc( ScDocument* pDoc )
         }
 
         SvxPageItem aPageItem(ATTR_PAGE);
-        aPageItem.SetPageUsage( SVX_PAGE_ALL );
+        aPageItem.SetPageUsage( SvxPageUsage::All );
         aPageItem.SetLandscape( pPage->Orientation != 1 );
         aPageItem.SetNumType( css::style::NumberingType::ARABIC );
         pSet->Put(aPageItem);
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 26ac1ab..e9a362c 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1651,12 +1651,12 @@ void ScDocShell::ExecutePageStyle( SfxViewShell& rCaller,
 
                         switch ( eUsage )
                         {
-                            case SVX_PAGE_LEFT:
-                            case SVX_PAGE_RIGHT:
+                            case SvxPageUsage::Left:
+                            case SvxPageUsage::Right:
                             {
                                 if ( bHeaderOn && bFooterOn )
                                     nResId = RID_SCDLG_HFEDIT;
-                                else if ( SVX_PAGE_RIGHT == eUsage )
+                                else if ( SvxPageUsage::Right == eUsage )
                                 {
                                     if ( !bHeaderOn && bFooterOn )
                                         nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
@@ -1678,8 +1678,8 @@ void ScDocShell::ExecutePageStyle( SfxViewShell& rCaller,
                             }
                             break;
 
-                            case SVX_PAGE_MIRROR:
-                            case SVX_PAGE_ALL:
+                            case SvxPageUsage::Mirror:
+                            case SvxPageUsage::All:
                             default:
                             {
                                 if ( !bShareHeader && !bShareFooter )
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 000d589..3271aa9 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -162,7 +162,7 @@ private:
     bool                bLandscape;
     bool                bSourceRangeValid;
 
-    sal_uInt16              nPageUsage;
+    SvxPageUsage        nPageUsage;
     Size                aPageSize;          // Printer Twips
     const SvxBoxItem*   pBorderItem;
     const SvxBrushItem* pBackgroundItem;
diff --git a/sc/source/ui/inc/tphf.hxx b/sc/source/ui/inc/tphf.hxx
index 06544a0..eadfedd 100644
--- a/sc/source/ui/inc/tphf.hxx
+++ b/sc/source/ui/inc/tphf.hxx
@@ -50,7 +50,7 @@ private:
     VclPtr<PushButton>   m_pBtnEdit;
     SfxItemSet           aDataSet;
     OUString             aStrPageStyle;
-    sal_uInt16           nPageUsage;
+    SvxPageUsage         nPageUsage;
     VclPtr<ScStyleDlg>   pStyleDlg;
 
     DECL_LINK( BtnHdl, Button*, void );
diff --git a/sc/source/ui/pagedlg/hfedtdlg.cxx b/sc/source/ui/pagedlg/hfedtdlg.cxx
index 6375322..0b0d99f 100644
--- a/sc/source/ui/pagedlg/hfedtdlg.cxx
+++ b/sc/source/ui/pagedlg/hfedtdlg.cxx
@@ -166,8 +166,7 @@ ScHFEditActiveDlg::ScHFEditActiveDlg(
                 rCoreSet.Get(
                     rCoreSet.GetPool()->GetWhich(SID_ATTR_PAGE) ));
 
-    bool bRightPage = ( SVX_PAGE_LEFT !=
-                        SvxPageUsage(rPageItem.GetPageUsage()) );
+    bool bRightPage = SvxPageUsage::Left != rPageItem.GetPageUsage();
 
     if ( bRightPage )
     {
diff --git a/sc/source/ui/pagedlg/tphf.cxx b/sc/source/ui/pagedlg/tphf.cxx
index a5cb711..c67cebb 100644
--- a/sc/source/ui/pagedlg/tphf.cxx
+++ b/sc/source/ui/pagedlg/tphf.cxx
@@ -46,7 +46,7 @@ ScHFPage::ScHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSe
         aDataSet    ( *rSet.GetPool(),
                        ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT,
                        ATTR_PAGE, ATTR_PAGE, 0 ),
-        nPageUsage  ( (sal_uInt16)SVX_PAGE_ALL ),
+        nPageUsage  ( SvxPageUsage::All ),
         pStyleDlg   ( nullptr )
 {
     get(m_pBtnEdit, "buttonEdit");
@@ -201,7 +201,7 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl, void*, void)
         VclPtrInstance< SfxSingleTabDialog > pDlg(this, aDataSet);
         const int nSettingsId = 42;
         bool bRightPage =   m_pCntSharedBox->IsChecked()
-                         || ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) );
+                         || ( SvxPageUsage::Left != nPageUsage );
 
         if ( nId == SID_ATTR_PAGE_HEADERSET )
         {
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 83d7634..9b99d7a 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -1651,17 +1651,15 @@ void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
 
 bool ScPrintFunc::IsMirror( long nPageNo )          // Mirror margins?
 {
-    SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
-    return ( eUsage == SVX_PAGE_MIRROR && (nPageNo & 1) );
+    return nPageUsage == SvxPageUsage::Mirror && (nPageNo & 1);
 }
 
 bool ScPrintFunc::IsLeft( long nPageNo )            // left foot notes?
 {
-    SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
     bool bLeft;
-    if (eUsage == SVX_PAGE_LEFT)
+    if (nPageUsage == SvxPageUsage::Left)
         bLeft = true;
-    else if (eUsage == SVX_PAGE_RIGHT)
+    else if (nPageUsage == SvxPageUsage::Right)
         bLeft = false;
     else
         bLeft = (nPageNo & 1) != 0;
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 6110674..8e97080 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -238,7 +238,7 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
 
     SvxPageItem aPageItem( SID_ATTR_PAGE );
     aPageItem.SetDescName( mpPage->GetName() );
-    aPageItem.SetPageUsage( (SvxPageUsage) SVX_PAGE_ALL );
+    aPageItem.SetPageUsage( SvxPageUsage::All );
     aPageItem.SetLandscape( mpPage->GetOrientation() == Orientation::Landscape );
     aPageItem.SetNumType( mpDoc->GetPageNumType() );
     aNewAttr.Put( aPageItem );
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index 20c634c..583e80e 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -510,9 +510,9 @@ IMPL_LINK( SvxHFPage, TurnOnHdl, Button *, pButton, void )
         m_pRMLbl->Enable();
         m_pRMEdit->Enable();
 
-        sal_uInt16 nUsage = m_pBspWin->GetUsage();
+        SvxPageUsage nUsage = m_pBspWin->GetUsage();
 
-        if( nUsage == SVX_PAGE_RIGHT || nUsage == SVX_PAGE_LEFT )
+        if( nUsage == SvxPageUsage::Right || nUsage == SvxPageUsage::Left )
             m_pCntSharedBox->Disable();
         else
         {
@@ -917,7 +917,7 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
         m_pBspWin->SetBottom( 0 );
     }
 
-    sal_uInt16 nUsage = SVX_PAGE_ALL;
+    SvxPageUsage nUsage = SvxPageUsage::All;
     pItem = GetItem( rSet, SID_ATTR_PAGE );
 
     if ( pItem )
@@ -925,7 +925,7 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
 
     m_pBspWin->SetUsage( nUsage );
 
-    if ( SVX_PAGE_RIGHT == nUsage || SVX_PAGE_LEFT == nUsage )
+    if ( SvxPageUsage::Right == nUsage || SvxPageUsage::Left == nUsage )
         m_pCntSharedBox->Disable();
     else
     {
diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx
index fcff957..5e18bee 100644
--- a/svx/source/dialog/pagectrl.cxx
+++ b/svx/source/dialog/pagectrl.cxx
@@ -73,7 +73,7 @@ SvxPageWindow::SvxPageWindow(vcl::Window* pParent)
     bTable(false),
     bHorz(false),
     bVert(false),
-    eUsage(SVX_PAGE_ALL)
+    eUsage(SvxPageUsage::All)
 {
     // Count in Twips by default
     SetMapMode(MapMode(MapUnit::MapTwip));
@@ -119,7 +119,7 @@ void SvxPageWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
     Size aSz(rRenderContext.PixelToLogic(GetSizePixel()));
     long nYPos = (aSz.Height() - aSize.Height()) / 2;
 
-    if (eUsage == SVX_PAGE_ALL)
+    if (eUsage == SvxPageUsage::All)
     {
         // all pages are equal -> draw one page
         if (aSize.Width() > aSize.Height())
@@ -145,8 +145,10 @@ void SvxPageWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
     else
     {
         // Left and right page are different -> draw two pages if possible
-        DrawPage(rRenderContext, Point(0, nYPos), false, (eUsage & SVX_PAGE_LEFT) != 0);
-        DrawPage(rRenderContext, Point(aSize.Width() + aSize.Width() / 8, nYPos), true, (eUsage & SVX_PAGE_RIGHT) != 0);
+        DrawPage(rRenderContext, Point(0, nYPos), false,
+                 eUsage == SvxPageUsage::Left || eUsage == SvxPageUsage::All || eUsage == SvxPageUsage::Mirror);
+        DrawPage(rRenderContext, Point(aSize.Width() + aSize.Width() / 8, nYPos), true,
+                 eUsage == SvxPageUsage::Right || eUsage == SvxPageUsage::All || eUsage == SvxPageUsage::Mirror);
     }
 }
 
@@ -187,7 +189,7 @@ void SvxPageWindow::DrawPage(vcl::RenderContext& rRenderContext, const Point& rO
     long nL = nLeft;
     long nR = nRight;
 
-    if (eUsage == SVX_PAGE_MIRROR && !bSecond)
+    if (eUsage == SvxPageUsage::Mirror && !bSecond)
     {
         // turn for mirrored
         nL = nRight;
diff --git a/svx/source/items/pageitem.cxx b/svx/source/items/pageitem.cxx
index 379b65c..7371ef1 100644
--- a/svx/source/items/pageitem.cxx
+++ b/svx/source/items/pageitem.cxx
@@ -39,7 +39,7 @@ SvxPageItem::SvxPageItem( const sal_uInt16 nId ) : SfxPoolItem( nId ),
 
     eNumType    ( css::style::NumberingType::ARABIC ),
     bLandscape  ( false ),
-    eUse        ( SVX_PAGE_ALL )
+    eUse        ( SvxPageUsage::All )
 {
 }
 
@@ -70,14 +70,14 @@ bool SvxPageItem::operator==( const SfxPoolItem& rAttr ) const
              eUse       == rItem.eUse );
 }
 
-inline OUString GetUsageText( const sal_uInt16 eU )
+inline OUString GetUsageText( const SvxPageUsage eU )
 {
-    switch( eU & 0x000f )
+    switch( eU )
     {
-        case SVX_PAGE_LEFT  : return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT);
-        case SVX_PAGE_RIGHT : return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT);
-        case SVX_PAGE_ALL   : return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL);
-        case SVX_PAGE_MIRROR: return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR);
+        case SvxPageUsage::Left  : return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT);
+        case SvxPageUsage::Right : return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT);
+        case SvxPageUsage::All   : return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL);
+        case SvxPageUsage::Mirror: return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR);
         default:              return OUString();
     }
 }
@@ -160,12 +160,12 @@ bool SvxPageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
         case MID_PAGE_LAYOUT     :
         {
             style::PageStyleLayout eRet;
-            switch(eUse & 0x0f)
+            switch(eUse)
             {
-                case SVX_PAGE_LEFT  : eRet = style::PageStyleLayout_LEFT;      break;
-                case SVX_PAGE_RIGHT : eRet = style::PageStyleLayout_RIGHT;     break;
-                case SVX_PAGE_ALL   : eRet = style::PageStyleLayout_ALL;       break;
-                case SVX_PAGE_MIRROR: eRet = style::PageStyleLayout_MIRRORED; break;
+                case SvxPageUsage::Left  : eRet = style::PageStyleLayout_LEFT;      break;
+                case SvxPageUsage::Right : eRet = style::PageStyleLayout_RIGHT;     break;
+                case SvxPageUsage::All   : eRet = style::PageStyleLayout_ALL;       break;
+                case SvxPageUsage::Mirror: eRet = style::PageStyleLayout_MIRRORED; break;
                 default:
                     OSL_FAIL("what layout is this?");
                     return false;
@@ -204,13 +204,12 @@ bool SvxPageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
                     return false;
                 eLayout = (style::PageStyleLayout)nValue;
             }
-            eUse &= 0xfff0;
             switch( eLayout )
             {
-                case style::PageStyleLayout_LEFT     : eUse |= SVX_PAGE_LEFT ; break;
-                case style::PageStyleLayout_RIGHT   : eUse |= SVX_PAGE_RIGHT; break;
-                case style::PageStyleLayout_ALL     : eUse |= SVX_PAGE_ALL  ; break;
-                case style::PageStyleLayout_MIRRORED: eUse |= SVX_PAGE_MIRROR;break;
+                case style::PageStyleLayout_LEFT    : eUse = SvxPageUsage::Left ; break;
+                case style::PageStyleLayout_RIGHT   : eUse = SvxPageUsage::Right; break;
+                case style::PageStyleLayout_ALL     : eUse = SvxPageUsage::All  ; break;
+                case style::PageStyleLayout_MIRRORED: eUse = SvxPageUsage::Mirror;break;
                 default: ;//prevent warning
             }
         }
@@ -237,7 +236,7 @@ SfxPoolItem* SvxPageItem::Create( SvStream& rStream, sal_uInt16 ) const
     pPage->SetDescName( sStr );
     pPage->SetNumType( (SvxNumType)eType );
     pPage->SetLandscape( bLand );
-    pPage->SetPageUsage( nUse );
+    pPage->SetPageUsage( (SvxPageUsage)nUse );
     return pPage;
 }
 
@@ -247,7 +246,7 @@ SvStream& SvxPageItem::Store( SvStream &rStrm, sal_uInt16 /*nItemVersion*/ ) con
     // UNICODE: rStrm << aDescName;
     rStrm.WriteUniOrByteString(aDescName, rStrm.GetStreamCharSet());
 
-    rStrm.WriteUChar( eNumType ).WriteBool( bLandscape ).WriteUInt16( eUse );
+    rStrm.WriteUChar( eNumType ).WriteBool( bLandscape ).WriteUInt16( (sal_uInt16)eUse );
     return rStrm;
 }
 
diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx
index 60eb0c3..a71f884 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 078f5e3..2cfe168 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 85825ce..897ef69 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 7cc75c5..95985af 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 571b0ba..a6be386e0 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;


More information about the Libreoffice-commits mailing list