[Libreoffice-commits] core.git: 2 commits - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 24 09:17:27 UTC 2018


 sc/source/core/tool/scmatrix.cxx  |   90 +++++++++++++++++++++-----------------
 sc/source/ui/attrdlg/tabpages.cxx |   87 ++++++++++++++++--------------------
 sc/source/ui/inc/tabpages.hxx     |   15 ++----
 3 files changed, 96 insertions(+), 96 deletions(-)

New commits:
commit d5d2a33e7e7e202f4b0c35423cfd94c054d1d424
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Sep 22 20:11:40 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Sep 24 11:17:18 2018 +0200

    weld ScTabPageProtection
    
    Change-Id: I85fa703ebe73987822f85ff722f02627751937ec
    Reviewed-on: https://gerrit.libreoffice.org/60909
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/attrdlg/tabpages.cxx b/sc/source/ui/attrdlg/tabpages.cxx
index b260542ab3af..e74191ac2314 100644
--- a/sc/source/ui/attrdlg/tabpages.cxx
+++ b/sc/source/ui/attrdlg/tabpages.cxx
@@ -35,25 +35,23 @@ const sal_uInt16 ScTabPageProtection::pProtectionRanges[] =
 
 // Zellschutz-Tabpage:
 
-ScTabPageProtection::ScTabPageProtection(vcl::Window* pParent, const SfxItemSet& rCoreAttrs)
-    : SfxTabPage(pParent, "CellProtectionPage",
-        "modules/scalc/ui/cellprotectionpage.ui", &rCoreAttrs)
+ScTabPageProtection::ScTabPageProtection(TabPageParent pParent, const SfxItemSet& rCoreAttrs)
+    : SfxTabPage(pParent, "modules/scalc/ui/cellprotectionpage.ui", "CellProtectionPage", &rCoreAttrs)
+    , m_xBtnHideCell(m_xBuilder->weld_check_button("checkHideAll"))
+    , m_xBtnProtect(m_xBuilder->weld_check_button("checkProtected"))
+    , m_xBtnHideFormula(m_xBuilder->weld_check_button("checkHideFormula"))
+    , m_xBtnHidePrint(m_xBuilder->weld_check_button("checkHidePrinting"))
 {
-    get(m_pBtnHideCell,"checkHideAll");
-    get(m_pBtnProtect,"checkProtected");
-    get(m_pBtnHideFormula,"checkHideFormula");
-    get(m_pBtnHidePrint,"checkHidePrinting");
-
     // This Page need ExchangeSupport
     SetExchangeSupport();
 
     //  States will be set in Reset
     bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = false;
 
-    m_pBtnProtect->SetClickHdl(     LINK( this, ScTabPageProtection, ButtonClickHdl ) );
-    m_pBtnHideCell->SetClickHdl(    LINK( this, ScTabPageProtection, ButtonClickHdl ) );
-    m_pBtnHideFormula->SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
-    m_pBtnHidePrint->SetClickHdl(   LINK( this, ScTabPageProtection, ButtonClickHdl ) );
+    m_xBtnProtect->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
+    m_xBtnHideCell->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
+    m_xBtnHideFormula->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
+    m_xBtnHidePrint->connect_toggled(LINK(this, ScTabPageProtection, ButtonClickHdl));
 }
 
 ScTabPageProtection::~ScTabPageProtection()
@@ -61,18 +59,9 @@ ScTabPageProtection::~ScTabPageProtection()
     disposeOnce();
 }
 
-void ScTabPageProtection::dispose()
-{
-    m_pBtnHideCell.clear();
-    m_pBtnProtect.clear();
-    m_pBtnHideFormula.clear();
-    m_pBtnHidePrint.clear();
-    SfxTabPage::dispose();
-}
-
-VclPtr<SfxTabPage> ScTabPageProtection::Create( TabPageParent pParent, const SfxItemSet* rAttrSet )
+VclPtr<SfxTabPage> ScTabPageProtection::Create(TabPageParent pParent, const SfxItemSet* rAttrSet)
 {
-    return VclPtr<ScTabPageProtection>::Create( pParent.pParent, *rAttrSet );
+    return VclPtr<ScTabPageProtection>::Create(pParent, *rAttrSet);
 }
 
 void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs )
@@ -109,11 +98,13 @@ void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs )
     }
 
     //  Start Controls
-
-    m_pBtnProtect->EnableTriState( bTriEnabled );
-    m_pBtnHideCell->EnableTriState( bTriEnabled );
-    m_pBtnHideFormula->EnableTriState( bTriEnabled );
-    m_pBtnHidePrint->EnableTriState( bTriEnabled );
+    if (bTriEnabled)
+    {
+        m_xBtnProtect->set_state(TRISTATE_INDET);
+        m_xBtnHideCell->set_state(TRISTATE_INDET);
+        m_xBtnHideFormula->set_state(TRISTATE_INDET);
+        m_xBtnHidePrint->set_state(TRISTATE_INDET);
+    }
 
     UpdateButtons();
 }
@@ -156,23 +147,23 @@ DeactivateRC ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
     return DeactivateRC::LeavePage;
 }
 
-IMPL_LINK( ScTabPageProtection, ButtonClickHdl, Button*, pBox, void )
+IMPL_LINK(ScTabPageProtection, ButtonClickHdl, weld::ToggleButton&, rBox, void)
 {
-    TriState eState = static_cast<TriStateBox*>(pBox)->GetState();
-    if ( eState == TRISTATE_INDET )
+    TriState eState = rBox.get_state();
+    if (eState == TRISTATE_INDET)
         bDontCare = true;                           // everything combined at DontCare
     else
     {
         bDontCare = false;                          // DontCare from everywhere
-        bool bOn = ( eState == TRISTATE_TRUE );       // from a selected value
+        bool bOn = eState == TRISTATE_TRUE;         // from a selected value
 
-        if ( pBox == m_pBtnProtect )
+        if (&rBox == m_xBtnProtect.get())
             bProtect = bOn;
-        else if ( pBox == m_pBtnHideCell )
+        else if (&rBox == m_xBtnHideCell.get())
             bHideCell = bOn;
-        else if ( pBox == m_pBtnHideFormula )
+        else if (&rBox == m_xBtnHideFormula.get())
             bHideForm = bOn;
-        else if ( pBox == m_pBtnHidePrint )
+        else if (&rBox == m_xBtnHidePrint.get())
             bHidePrint = bOn;
         else
         {
@@ -185,25 +176,25 @@ IMPL_LINK( ScTabPageProtection, ButtonClickHdl, Button*, pBox, void )
 
 void ScTabPageProtection::UpdateButtons()
 {
-    if ( bDontCare )
+    if (bDontCare)
     {
-        m_pBtnProtect->SetState( TRISTATE_INDET );
-        m_pBtnHideCell->SetState( TRISTATE_INDET );
-        m_pBtnHideFormula->SetState( TRISTATE_INDET );
-        m_pBtnHidePrint->SetState( TRISTATE_INDET );
+        m_xBtnProtect->set_state(TRISTATE_INDET);
+        m_xBtnHideCell->set_state(TRISTATE_INDET);
+        m_xBtnHideFormula->set_state(TRISTATE_INDET);
+        m_xBtnHidePrint->set_state(TRISTATE_INDET);
     }
     else
     {
-        m_pBtnProtect->SetState( bProtect ? TRISTATE_TRUE : TRISTATE_FALSE );
-        m_pBtnHideCell->SetState( bHideCell ? TRISTATE_TRUE : TRISTATE_FALSE );
-        m_pBtnHideFormula->SetState( bHideForm ? TRISTATE_TRUE : TRISTATE_FALSE );
-        m_pBtnHidePrint->SetState( bHidePrint ? TRISTATE_TRUE : TRISTATE_FALSE );
+        m_xBtnProtect->set_state(bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
+        m_xBtnHideCell->set_state(bHideCell ? TRISTATE_TRUE : TRISTATE_FALSE);
+        m_xBtnHideFormula->set_state(bHideForm ? TRISTATE_TRUE : TRISTATE_FALSE);
+        m_xBtnHidePrint->set_state(bHidePrint ? TRISTATE_TRUE : TRISTATE_FALSE);
     }
 
-    bool bEnable = ( m_pBtnHideCell->GetState() != TRISTATE_TRUE );
+    bool bEnable = (m_xBtnHideCell->get_state() != TRISTATE_TRUE);
     {
-        m_pBtnProtect->Enable( bEnable );
-        m_pBtnHideFormula->Enable( bEnable );
+        m_xBtnProtect->set_sensitive(bEnable);
+        m_xBtnHideFormula->set_sensitive(bEnable);
     }
 }
 
diff --git a/sc/source/ui/inc/tabpages.hxx b/sc/source/ui/inc/tabpages.hxx
index cb5373537438..e7a9936bfa15 100644
--- a/sc/source/ui/inc/tabpages.hxx
+++ b/sc/source/ui/inc/tabpages.hxx
@@ -35,20 +35,14 @@ public:
     virtual void        Reset           ( const SfxItemSet* ) override;
 
     virtual ~ScTabPageProtection() override;
-    virtual void dispose() override;
 
 protected:
     using SfxTabPage::DeactivatePage;
     virtual DeactivateRC   DeactivatePage  ( SfxItemSet* pSet ) override;
 
 private:
-                ScTabPageProtection( vcl::Window*            pParent,
-                                     const SfxItemSet&  rCoreAttrs );
+    ScTabPageProtection(TabPageParent pParent, const SfxItemSet& rCoreAttrs);
 private:
-    VclPtr<TriStateBox>    m_pBtnHideCell;
-    VclPtr<TriStateBox>    m_pBtnProtect;
-    VclPtr<TriStateBox>    m_pBtnHideFormula;
-    VclPtr<TriStateBox>    m_pBtnHidePrint;
                                         // current status:
     bool            bTriEnabled;        //  if before - DontCare
     bool            bDontCare;          //  all in  TriState
@@ -57,8 +51,13 @@ private:
     bool            bHideCell;
     bool            bHidePrint;
 
+    std::unique_ptr<weld::CheckButton> m_xBtnHideCell;
+    std::unique_ptr<weld::CheckButton> m_xBtnProtect;
+    std::unique_ptr<weld::CheckButton> m_xBtnHideFormula;
+    std::unique_ptr<weld::CheckButton> m_xBtnHidePrint;
+
     // Handler:
-    DECL_LINK( ButtonClickHdl, Button*, void );
+    DECL_LINK(ButtonClickHdl, weld::ToggleButton&, void);
     void        UpdateButtons();
 };
 
commit 0314b3e22b155b83036b83b9d365f596ea8064e8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Sep 23 21:36:36 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Sep 24 11:17:05 2018 +0200

    coverity#1438870 Big parameter passed by value
    
    Change-Id: I6ade72ed19b63b7f68c8f58c57bb409eab55e55c
    Reviewed-on: https://gerrit.libreoffice.org/60919
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 3c983cd2ecc8..d9b500d1146d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -2506,11 +2506,9 @@ std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const s
 
 namespace {
 
-class WalkElementBlockOperation
+struct ElementBlock
 {
-public:
-
-    WalkElementBlockOperation(size_t nRowSize,
+    ElementBlock(size_t nRowSize,
             ScFullMatrix::DoubleOpFunction const & aDoubleFunc,
             ScFullMatrix::BoolOpFunction const & aBoolFunc,
             ScFullMatrix::StringOpFunction const & aStringFunc,
@@ -2525,6 +2523,25 @@ public:
     {
     }
 
+    size_t mnRowSize;
+    size_t mnRowPos;
+    size_t mnColPos;
+
+    ScFullMatrix::DoubleOpFunction maDoubleFunc;
+    ScFullMatrix::BoolOpFunction maBoolFunc;
+    ScFullMatrix::StringOpFunction maStringFunc;
+    ScFullMatrix::EmptyOpFunction maEmptyFunc;
+};
+
+class WalkElementBlockOperation
+{
+public:
+
+    WalkElementBlockOperation(ElementBlock& rElementBlock)
+        : mrElementBlock(rElementBlock)
+    {
+    }
+
     void operator()(const MatrixImplType::element_block_node_type& node)
     {
         switch (node.type)
@@ -2539,12 +2556,12 @@ public:
                 std::advance(itEnd, node.size);
                 for (auto itr = it; itr != itEnd; ++itr)
                 {
-                    maDoubleFunc(mnRowPos, mnColPos, *itr);
-                    ++mnRowPos;
-                    if (mnRowPos >= mnRowSize)
+                    mrElementBlock.maDoubleFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos, *itr);
+                    ++mrElementBlock.mnRowPos;
+                    if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize)
                     {
-                        mnRowPos = 0;
-                        ++mnColPos;
+                        mrElementBlock.mnRowPos = 0;
+                        ++mrElementBlock.mnColPos;
                     }
                 }
             }
@@ -2559,12 +2576,12 @@ public:
                 std::advance(itEnd, node.size);
                 for (auto itr = it; itr != itEnd; ++itr)
                 {
-                    maStringFunc(mnRowPos, mnColPos, *itr);
-                    ++mnRowPos;
-                    if (mnRowPos >= mnRowSize)
+                    mrElementBlock.maStringFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos, *itr);
+                    ++mrElementBlock.mnRowPos;
+                    if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize)
                     {
-                        mnRowPos = 0;
-                        ++mnColPos;
+                        mrElementBlock.mnRowPos = 0;
+                        ++mrElementBlock.mnColPos;
                     }
                 }
             }
@@ -2579,12 +2596,12 @@ public:
                 std::advance(itEnd, node.size);
                 for (auto itr = it; itr != itEnd; ++itr)
                 {
-                    maBoolFunc(mnRowPos, mnColPos, *itr);
-                    ++mnRowPos;
-                    if (mnRowPos >= mnRowSize)
+                    mrElementBlock.maBoolFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos, *itr);
+                    ++mrElementBlock.mnRowPos;
+                    if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize)
                     {
-                        mnRowPos = 0;
-                        ++mnColPos;
+                        mrElementBlock.mnRowPos = 0;
+                        ++mrElementBlock.mnColPos;
                     }
                 }
             }
@@ -2593,12 +2610,12 @@ public:
             {
                 for (size_t i=0; i < node.size; ++i)
                 {
-                    maEmptyFunc(mnRowPos, mnColPos);
-                    ++mnRowPos;
-                    if (mnRowPos >= mnRowSize)
+                    mrElementBlock.maEmptyFunc(mrElementBlock.mnRowPos, mrElementBlock.mnColPos);
+                    ++mrElementBlock.mnRowPos;
+                    if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize)
                     {
-                        mnRowPos = 0;
-                        ++mnColPos;
+                        mrElementBlock.mnRowPos = 0;
+                        ++mrElementBlock.mnColPos;
                     }
                 }
             }
@@ -2607,12 +2624,12 @@ public:
             {
                 SAL_WARN("sc.core","WalkElementBlockOperation - unhandled element_integer");
                 // No function (yet?), but advance row and column count.
-                mnColPos += node.size / mnRowSize;
-                mnRowPos += node.size % mnRowSize;
-                if (mnRowPos >= mnRowSize)
+                mrElementBlock.mnColPos += node.size / mrElementBlock.mnRowSize;
+                mrElementBlock.mnRowPos += node.size % mrElementBlock.mnRowSize;
+                if (mrElementBlock.mnRowPos >= mrElementBlock.mnRowSize)
                 {
-                    mnRowPos = 0;
-                    ++mnColPos;
+                    mrElementBlock.mnRowPos = 0;
+                    ++mrElementBlock.mnColPos;
                 }
             }
             break;
@@ -2621,14 +2638,7 @@ public:
 
 private:
 
-    size_t mnRowSize;
-    size_t mnRowPos;
-    size_t mnColPos;
-
-    ScFullMatrix::DoubleOpFunction maDoubleFunc;
-    ScFullMatrix::BoolOpFunction maBoolFunc;
-    ScFullMatrix::StringOpFunction maStringFunc;
-    ScFullMatrix::EmptyOpFunction maEmptyFunc;
+    ElementBlock& mrElementBlock;
 };
 
 }
@@ -2638,10 +2648,10 @@ void ScMatrixImpl::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos,
         const ScMatrix::BoolOpFunction& aBoolFunc, const ScMatrix::StringOpFunction& aStringFunc,
         const ScMatrix::EmptyOpFunction& aEmptyFunc) const
 {
-    WalkElementBlockOperation aFunc(maMat.size().row,
-            aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc);
+    ElementBlock aPayload(maMat.size().row, aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc);
+    WalkElementBlockOperation aFunc(aPayload);
     maMat.walk(
-        std::move(aFunc),
+        aFunc,
         MatrixImplType::size_pair_type(rStartPos.first, rStartPos.second),
         MatrixImplType::size_pair_type(rEndPos.first, rEndPos.second));
 }


More information about the Libreoffice-commits mailing list