[Libreoffice-commits] core.git: 2 commits - include/vcl sw/inc sw/source vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 24 12:18:56 UTC 2020


 include/vcl/scrbar.hxx               |    2 -
 sw/inc/crstate.hxx                   |   12 +++++------
 sw/inc/viewopt.hxx                   |    7 +++---
 sw/source/core/crsr/crstrvl.cxx      |   14 ++++++-------
 sw/source/core/text/frmcrsr.cxx      |   12 +++++------
 sw/source/ui/config/optpage.cxx      |   11 ++++------
 sw/source/ui/dbui/mmlayoutpage.cxx   |    2 -
 sw/source/uibase/config/cfgitems.cxx |    2 -
 sw/source/uibase/config/usrpref.cxx  |    2 -
 sw/source/uibase/config/viewopt.cxx  |    2 -
 sw/source/uibase/docvw/edtwin.cxx    |    4 +--
 sw/source/uibase/inc/cfgitems.hxx    |    7 +++---
 vcl/source/control/slider.cxx        |   36 +----------------------------------
 13 files changed, 41 insertions(+), 72 deletions(-)

New commits:
commit a910081e0634120118d6f32996591928677d504f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 24 12:06:55 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 24 14:18:23 2020 +0200

    convert SwFillMode to scoped enum
    
    Change-Id: I03230496aac57f8855ce8d3dcd8576d265060aa6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92845
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx
index 845e98da8dff..fea6d265df31 100644
--- a/sw/inc/crstate.hxx
+++ b/sw/inc/crstate.hxx
@@ -25,13 +25,13 @@
 
 #include <memory>
 
-enum SwFillMode
+enum class SwFillMode
 {
-    FILL_TAB,       ///< default, fill with tabs
-    FILL_TAB_SPACE, ///< fill with spaces and tabs
-    FILL_SPACE,     ///< fill with spaces
-    FILL_MARGIN,    ///< only align left, center, right
-    FILL_INDENT     ///< by left paragraph indention
+    Tab,       ///< default, fill with tabs
+    TabSpace,  ///< fill with spaces and tabs
+    Space,     ///< fill with spaces
+    Margin,    ///< only align left, center, right
+    Indent     ///< by left paragraph indention
 };
 
 struct SwFillCursorPos
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 6455832a27e4..f5add2b728d1 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -33,6 +33,7 @@ namespace vcl { class Window; }
 class OutputDevice;
 class SwDocShell;
 namespace svtools{ class ColorConfig;}
+enum class SwFillMode;
 
 enum class ViewOptFlags1 : sal_uInt32 {
     UseHeaderFooterMenu = 0x00000001,
@@ -157,7 +158,7 @@ class SW_DLLPUBLIC SwViewOption
     short           m_nDivisionY;
     sal_uInt8       m_nPagePreviewRow;       // Page Preview Row/Columns.
     sal_uInt8       m_nPagePreviewCol;       // Page Preview Row/Columns.
-    sal_uInt8       m_nShadowCursorFillMode;  // FillMode for ShadowCursor.
+    SwFillMode      m_nShadowCursorFillMode;  // FillMode for ShadowCursor.
     bool            m_bReadonly : 1;      // Readonly-Doc.
     bool            m_bStarOneSetting : 1;// Prevent from UI automatics (no scrollbars in readonly documents).
     bool            m_bIsPagePreview : 1; // The preview mustn't print field/footnote/... shadings.
@@ -607,8 +608,8 @@ public:
     bool            IsPagePreview() const {return m_bIsPagePreview; }
     void            SetPagePreview(bool bSet) { m_bIsPagePreview= bSet; }
 
-    sal_uInt8           GetShdwCursorFillMode() const { return m_nShadowCursorFillMode; }
-    void            SetShdwCursorFillMode( sal_uInt8 nMode ) { m_nShadowCursorFillMode = nMode; };
+    SwFillMode      GetShdwCursorFillMode() const { return m_nShadowCursorFillMode; }
+    void            SetShdwCursorFillMode( SwFillMode nMode ) { m_nShadowCursorFillMode = nMode; };
 
     bool        IsShowPlaceHolderFields() const { return m_bShowPlaceHolderFields; }
     void            SetShowPlaceHolderFields(bool bSet) { m_bShowPlaceHolderFields = bSet; }
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index c9ced018ee83..dd0d50c58d2c 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -2101,7 +2101,7 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode )
             // If only the paragraph attributes "Adjust" or "LRSpace" are set,
             // then the following should not delete those again.
             if( 0 == aFPos.nParaCnt + aFPos.nColumnCnt &&
-                ( FILL_INDENT == aFPos.eMode ||
+                ( SwFillMode::Indent == aFPos.eMode ||
                   ( text::HoriOrientation::NONE != aFPos.eOrient &&
                     0 == aFPos.nTabCnt + aFPos.nSpaceCnt )) &&
                 pCNd && pCNd->Len() )
@@ -2147,7 +2147,7 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode )
             *m_pCurrentCursor->GetPoint() = aPos;
             switch( aFPos.eMode )
             {
-            case FILL_INDENT:
+            case SwFillMode::Indent:
                 if( nullptr != (pCNd = aPos.nNode.GetNode().GetContentNode() ))
                 {
                     SfxItemSet aSet(
@@ -2173,12 +2173,12 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode )
                 }
                 break;
 
-            case FILL_TAB:
-            case FILL_TAB_SPACE:
-            case FILL_SPACE:
+            case SwFillMode::Tab:
+            case SwFillMode::TabSpace:
+            case SwFillMode::Space:
                 {
                     OUStringBuffer sInsert;
-                    if (aFPos.eMode == FILL_SPACE)
+                    if (aFPos.eMode == SwFillMode::Space)
                     {
                         comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceOnlyCnt, ' ');
                     }
@@ -2193,7 +2193,7 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode )
                         GetDoc()->getIDocumentContentOperations().InsertString( *m_pCurrentCursor, sInsert.makeStringAndClear());
                 }
                 [[fallthrough]]; // still need to set orientation
-            case FILL_MARGIN:
+            case SwFillMode::Margin:
                 if( text::HoriOrientation::NONE != aFPos.eOrient )
                 {
                     SvxAdjustItem aAdj( SvxAdjust::Left, RES_PARATR_ADJUST );
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 23ee0cd34106..fe268232b1c1 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -1438,7 +1438,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
             SwTwips nRight = rFill.Right() - rLRSpace.GetRight();
             SwTwips nCenter = ( nLeft + nRight ) / 2;
             rRect.Left( nLeft );
-            if( FILL_MARGIN == rFill.Mode() )
+            if( SwFillMode::Margin == rFill.Mode() )
             {
                 if( rFill.bEmpty )
                 {
@@ -1468,7 +1468,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
             else
             {
                 SwTwips nSpace = 0;
-                if( FILL_TAB != rFill.Mode() )
+                if( SwFillMode::Tab != rFill.Mode() )
                 {
                     const OUString aTmp("  ");
                     SwDrawTextInfo aDrawInf( pSh, *pOut, aTmp, 0, 2 );
@@ -1476,7 +1476,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                 }
                 if( rFill.X() >= nRight )
                 {
-                    if( FILL_INDENT != rFill.Mode() && ( rFill.bEmpty ||
+                    if( SwFillMode::Indent != rFill.Mode() && ( rFill.bEmpty ||
                         rFill.X() > rFill.nLineWidth + FILL_MIN_DIST ) )
                     {
                         rFill.SetOrient( text::HoriOrientation::RIGHT );
@@ -1485,7 +1485,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                     else
                         bFill = false;
                 }
-                else if( FILL_INDENT == rFill.Mode() )
+                else if( SwFillMode::Indent == rFill.Mode() )
                 {
                     SwTwips nIndent = rFill.X();
                     if( !rFill.bEmpty || nIndent > nRight )
@@ -1555,7 +1555,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                     }
                     while( rFill.X() > nRightTab );
                     --nTabCnt;
-                    if( FILL_TAB_SPACE == rFill.Mode() )
+                    if( SwFillMode::TabSpace == rFill.Mode() )
                     {
                         if( nSpace > 0 )
                         {
@@ -1606,7 +1606,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
                             }
                         }
                     }
-                    else if( FILL_SPACE == rFill.Mode() )
+                    else if( SwFillMode::Space == rFill.Mode() )
                     {
                         SwTwips nLeftSpace = nLeft;
                         while( nLeftSpace < rFill.X() )
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 0d51258fb730..7c6140ea3a6c 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1202,7 +1202,7 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, w
     , m_xMathBaselineAlignmentCB(m_xBuilder->weld_check_button("mathbaseline"))
 {
     const SfxPoolItem* pItem = nullptr;
-    sal_uInt8 eMode = SwFillMode::FILL_TAB;
+    SwFillMode eMode = SwFillMode::Tab;
     bool bIsOn = false;
 
     if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_SHADOWCURSOR, false, &pItem ))
@@ -1213,7 +1213,7 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, w
     }
     m_xOnOffCB->set_active( bIsOn );
 
-    m_xDirectCursorFillMode->set_active( eMode );
+    m_xDirectCursorFillMode->set_active( static_cast<int>(eMode) );
     if(SfxItemState::SET != rSet.GetItemState(SID_HTML_MODE, false, &pItem )
         || !(static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON))
         return;
@@ -1252,8 +1252,7 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* rSet )
     SwShadowCursorItem aOpt;
     aOpt.SetOn( m_xOnOffCB->get_active() );
 
-    sal_uInt8 eMode;
-    eMode = m_xDirectCursorFillMode->get_active();
+    SwFillMode eMode = static_cast<SwFillMode>(m_xDirectCursorFillMode->get_active());
     aOpt.SetMode( eMode );
 
     bool bRet = false;
@@ -1301,7 +1300,7 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* rSet )
 void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
 {
     const SfxPoolItem* pItem = nullptr;
-    sal_uInt8 eMode = SwFillMode::FILL_TAB;
+    SwFillMode eMode = SwFillMode::Tab;
     bool bIsOn = false;
 
     if( SfxItemState::SET == rSet->GetItemState( FN_PARAM_SHADOWCURSOR, false, &pItem ))
@@ -1312,7 +1311,7 @@ void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
     }
     m_xOnOffCB->set_active( bIsOn );
 
-    m_xDirectCursorFillMode->set_active( eMode );
+    m_xDirectCursorFillMode->set_active( static_cast<int>(eMode) );
     if (m_pWrtShell) {
         m_xMathBaselineAlignmentCB->set_active( m_pWrtShell->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ) );
         m_xMathBaselineAlignmentCB->save_state();
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 537a60e5ad69..bd8070c5ea0f 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -394,7 +394,7 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
     const SwRect& rPageRect = rShell.GetAnyCurRect(CurRectType::Page);
     const Point aGreetingPos( DEFAULT_LEFT_DISTANCE + rPageRect.Left(), GREETING_TOP_DISTANCE );
 
-    const bool bRet = rShell.SetShadowCursorPos( aGreetingPos, FILL_TAB_SPACE );
+    const bool bRet = rShell.SetShadowCursorPos( aGreetingPos, SwFillMode::TabSpace );
 
     if(!bRet)
     {
diff --git a/sw/source/uibase/config/cfgitems.cxx b/sw/source/uibase/config/cfgitems.cxx
index 0f26565c10d1..41ce1246072d 100644
--- a/sw/source/uibase/config/cfgitems.cxx
+++ b/sw/source/uibase/config/cfgitems.cxx
@@ -185,7 +185,7 @@ bool SwAddPrinterItem::operator==( const SfxPoolItem& rAttr ) const
 // Item for Settings dialog, ShadowCursorPage
 SwShadowCursorItem::SwShadowCursorItem()
     : SfxPoolItem( FN_PARAM_SHADOWCURSOR ),
-    eMode( FILL_TAB )
+    eMode( SwFillMode::Tab )
     ,bOn( false )
 {
 }
diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx
index ab771b8b45e3..77790b82c220 100644
--- a/sw/source/uibase/config/usrpref.cxx
+++ b/sw/source/uibase/config/usrpref.cxx
@@ -534,7 +534,7 @@ void SwCursorConfig::Load()
                 switch(nProp)
                 {
                     case  0: rParent.SetShadowCursor(bSet);                  break; // "DirectCursor/UseDirectCursor",
-                    case  1: rParent.SetShdwCursorFillMode(static_cast<sal_uInt8>(nSet)); break; // "DirectCursor/Insert",
+                    case  1: rParent.SetShdwCursorFillMode(static_cast<SwFillMode>(nSet)); break; // "DirectCursor/Insert",
                     case  2: rParent.SetCursorInProtectedArea(bSet);         break; // "Option/ProtectedArea"
                 }
             }
diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx
index 6335cde55dbc..194c89bbac51 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -152,7 +152,7 @@ SwViewOption::SwViewOption() :
     mnViewLayoutColumns( 0 ),
     m_nPagePreviewRow( 1 ),
     m_nPagePreviewCol( 2 ),
-    m_nShadowCursorFillMode( FILL_TAB ),
+    m_nShadowCursorFillMode( SwFillMode::Tab ),
     m_bReadonly(false),
     m_bStarOneSetting(false),
     m_bIsPagePreview(false),
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index d039be4f2047..bdabfc6def76 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4218,7 +4218,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
                 {
                     SwRect aRect;
                     sal_Int16 eOrient;
-                    SwFillMode eMode = static_cast<SwFillMode>(rSh.GetViewOptions()->GetShdwCursorFillMode());
+                    SwFillMode eMode = rSh.GetViewOptions()->GetShdwCursorFillMode();
                     if( rSh.GetShadowCursorPos( aDocPt, eMode, aRect, eOrient ))
                     {
                         if( !m_pShadCursor )
@@ -4712,7 +4712,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                                     rSh.Undo();
                                 }
                             }
-                            SwFillMode eMode = static_cast<SwFillMode>(rSh.GetViewOptions()->GetShdwCursorFillMode());
+                            SwFillMode eMode = rSh.GetViewOptions()->GetShdwCursorFillMode();
                             rSh.SetShadowCursorPos( aDocPt, eMode );
                         }
                     }
diff --git a/sw/source/uibase/inc/cfgitems.hxx b/sw/source/uibase/inc/cfgitems.hxx
index fab7cd59e66e..bf50b8f105f0 100644
--- a/sw/source/uibase/inc/cfgitems.hxx
+++ b/sw/source/uibase/inc/cfgitems.hxx
@@ -35,6 +35,7 @@ class SwViewShell;
 class SwViewOption;
 class SwContentOptPage;
 class SwShdwCursorOptionsTabPage;
+enum class SwFillMode;
 
 // OS 12.01.95
 // Item for settings dialog - document view
@@ -111,7 +112,7 @@ public:
 // Item for settings dialog, ShadowCursorPage
 class SW_DLLPUBLIC SwShadowCursorItem : public SfxPoolItem
 {
-    sal_uInt8 eMode;
+    SwFillMode eMode;
     bool bOn;
 public:
     SwShadowCursorItem();
@@ -122,10 +123,10 @@ public:
 
     void FillViewOptions( SwViewOption& rVOpt) const;
 
-    sal_uInt8 GetMode() const               { return eMode; }
+    SwFillMode GetMode() const          { return eMode; }
     bool IsOn() const                   { return bOn; }
 
-    void SetMode( sal_uInt8 eM )            { eMode = eM; }
+    void SetMode( SwFillMode eM )       { eMode = eM; }
     void SetOn( bool bFlag )            { bOn = bFlag; }
 };
 
commit 2be4afe53a94fc051aae9ba9b20443f7a350fb18
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 24 11:32:45 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 24 14:18:16 2020 +0200

    loplugin:unusedenumconstants ScrollType
    
    Change-Id: I996bd987169caa60c63832e62e210a8c62e6a0e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92843
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx
index 1c1fd94c8aa5..68fdf08b49da 100644
--- a/include/vcl/scrbar.hxx
+++ b/include/vcl/scrbar.hxx
@@ -30,7 +30,7 @@ enum class ScrollType
     DontKnow,
     LineUp, LineDown,
     PageUp, PageDown,
-    Drag, Set
+    Drag
 };
 
 
diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx
index 0fdc49441bbb..61841ef4c216 100644
--- a/vcl/source/control/slider.cxx
+++ b/vcl/source/control/slider.cxx
@@ -530,9 +530,6 @@ long Slider::ImplDoAction()
             nDelta = ImplSlide( mnThumbPos+mnPageSize );
             break;
 
-        case ScrollType::Set:
-            nDelta = ImplSlide( ImplCalcThumbPos( GetPointerPosPixel().X() ) );
-            break;
         default:
             break;
     }
@@ -547,20 +544,6 @@ void Slider::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
 
     switch ( meScrollType )
     {
-        case ScrollType::Set:
-        {
-            const bool bUp = ImplIsPageUp( rMousePos ), bDown = ImplIsPageDown( rMousePos );
-
-            if ( bUp || bDown )
-            {
-                bAction = bCallAction;
-                mnStateFlags |= ( bUp ? SLIDER_STATE_CHANNEL1_DOWN : SLIDER_STATE_CHANNEL2_DOWN );
-            }
-            else
-                mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN );
-            break;
-        }
-
         case ScrollType::PageUp:
             if ( ImplIsPageUp( rMousePos ) )
             {
@@ -653,31 +636,16 @@ void Slider::MouseButtonDown( const MouseEvent& rMEvt )
         {
             // store Start position for cancel and EndScroll delta
             mnStartPos = mnThumbPos;
-            ImplDoMouseAction( rMousePos, meScrollType != ScrollType::Set );
+            ImplDoMouseAction( rMousePos, /*bCallAction*/true );
             PaintImmediately();
 
-            if( meScrollType != ScrollType::Set )
-                StartTracking( nTrackFlags );
+            StartTracking( nTrackFlags );
         }
     }
 }
 
 void Slider::MouseButtonUp( const MouseEvent& )
 {
-    if( ScrollType::Set == meScrollType )
-    {
-        // reset Button and PageRect state
-        const sal_uInt16 nOldStateFlags = mnStateFlags;
-
-        mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN | SLIDER_STATE_THUMB_DOWN );
-
-        if ( nOldStateFlags != mnStateFlags )
-        {
-            Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase);
-        }
-        ImplDoAction();
-        meScrollType = ScrollType::DontKnow;
-    }
 }
 
 void Slider::Tracking( const TrackingEvent& rTEvt )


More information about the Libreoffice-commits mailing list