compilerplugins/clang/test/unusedfields.cxx                   |   44 ++++++++++
 compilerplugins/clang/unusedfields.cxx                        |   44 +++++++---
 dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx             |    1 
 sd/source/filter/eppt/pptx-animations-nodectx.cxx             |    5 -
 sd/source/filter/eppt/pptx-animations-nodectx.hxx             |    1 
 sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx |    3 
 sd/source/ui/slidesorter/controller/SlsProperties.cxx         |    3 
 sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx  |   18 ----
 sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx     |    6 -
 sfx2/source/control/recentdocsviewitem.cxx                    |    3 
 sfx2/source/control/recentdocsviewitem.hxx                    |    1 
 svx/source/dialog/framelinkarray.cxx                          |    5 -
 sw/source/uibase/docvw/edtwin.cxx                             |    3 
 sw/source/uibase/inc/shdwcrsr.hxx                             |    5 -
 14 files changed, 88 insertions(+), 54 deletions(-)

New commits:
commit 3d24564ef01396f1a66dcd971f11e34d84d65d7d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jun 29 13:01:07 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jun 29 17:33:40 2023 +0200

    mbIsUIReadOnly is dead
    
    after I removed SetUIReadOnly in
        commit e2c7a6bd572644b928704f6cb3696b568ac0aba1
        loplugin::unusedmethods
    
    and that was dead because of
        commit cb32938d572777c9a5d75007cc76ba50c5a698eb
        [API CHANGE] remove unused SlideSorterService
    
    Change-Id: Ib0e170794e0f448b094b3d1ca5d309deab4c1bf7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153744
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx 
b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx
index f447c565639e..b635accc5535 100644
--- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx
@@ -74,9 +74,6 @@ void DragAndDropContext::UpdatePosition (
     if (mpTargetSlideSorter == nullptr)
         return;
 
-    if (mpTargetSlideSorter->GetProperties()->IsUIReadOnly())
-        return;
-
     // Convert window coordinates into model coordinates (we need the
     // window coordinates for auto-scrolling because that remains
     // constant while scrolling.)
diff --git a/sd/source/ui/slidesorter/controller/SlsProperties.cxx 
b/sd/source/ui/slidesorter/controller/SlsProperties.cxx
index 908f3031d2be..cbe0d6e0ea7a 100644
--- a/sd/source/ui/slidesorter/controller/SlsProperties.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsProperties.cxx
@@ -25,8 +25,7 @@ namespace sd::slidesorter::controller {
 
 Properties::Properties()
     : 
maBackgroundColor(Application::GetSettings().GetStyleSettings().GetWindowColor()),
-      
maSelectionColor(Application::GetSettings().GetStyleSettings().GetHighlightColor()),
-      mbIsUIReadOnly(false)
+      
maSelectionColor(Application::GetSettings().GetStyleSettings().GetHighlightColor())
 {
 }
 
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx 
b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
index 450fdd294a55..f8376ec409fd 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
@@ -466,9 +466,6 @@ bool SelectionFunction::KeyInput (const KeyEvent& rEvent)
         case KEY_DELETE:
         case KEY_BACKSPACE:
         {
-            if (mrSlideSorter.GetProperties()->IsUIReadOnly())
-                break;
-
             
mrController.GetSelectionManager()->DeleteSelectedPages(rCode.GetCode()==KEY_DELETE);
 
             mnShiftKeySelectionAnchor = -1;
@@ -560,10 +557,7 @@ void SelectionFunction::MoveFocus (
 
 void SelectionFunction::DoCut()
 {
-    if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly())
-    {
-        mrController.GetClipboard().DoCut();
-    }
+    mrController.GetClipboard().DoCut();
 }
 
 void SelectionFunction::DoCopy()
@@ -573,10 +567,7 @@ void SelectionFunction::DoCopy()
 
 void SelectionFunction::DoPaste()
 {
-    if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly())
-    {
-        mrController.GetClipboard().DoPaste();
-    }
+    mrController.GetClipboard().DoPaste();
 }
 
 bool SelectionFunction::cancel()
@@ -950,10 +941,7 @@ void SelectionFunction::ModeHandler::StartDrag (
     if (SD_MOD()->pTransferDrag != nullptr)
         return;
 
-    if ( ! mrSlideSorter.GetProperties()->IsUIReadOnly())
-    {
-        mrSelectionFunction.SwitchToDragAndDropMode(rMousePosition);
-    }
+    mrSelectionFunction.SwitchToDragAndDropMode(rMousePosition);
 }
 
 //===== NormalModeHandler =====================================================
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx 
b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx
index cd1914fe07a7..479185f53658 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsProperties.hxx
@@ -45,15 +45,9 @@ public:
     const Color& GetSelectionColor() const { return maSelectionColor; }
     void SetSelectionColor(const Color& rColor);
 
-    /** The UI can be set to be read only independently from the model status.
-        Used for instance in the presenter view.
-    */
-    bool IsUIReadOnly() const { return mbIsUIReadOnly; }
-
 private:
     Color maBackgroundColor;
     Color maSelectionColor;
-    bool mbIsUIReadOnly;
 };
 
 } // end of namespace ::sd::slidesorter::controller
commit 62d9d507fc8739722df2e45483b29910f2743699
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jun 29 12:32:13 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jun 29 17:33:30 2023 +0200

    loplugin:unusedfields make it a little smarter
    
    around dealing with operator[] on map data-types
    
    Change-Id: Idd6654948ae2d03d634fcf30a8d98530a78ab4ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153740
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/compilerplugins/clang/test/unusedfields.cxx 
b/compilerplugins/clang/test/unusedfields.cxx
index b545f4b1a89f..c936460bbea5 100644
--- a/compilerplugins/clang/test/unusedfields.cxx
+++ b/compilerplugins/clang/test/unusedfields.cxx
@@ -11,6 +11,7 @@
 // expected-no-diagnostics
 #else
 
+#include <map>
 #include <memory>
 #include <vector>
 #include <ostream>
@@ -377,6 +378,49 @@ namespace TouchFromOutsideAnalysis1
     };
 };
 
+namespace WriteOnlyAnalysis4
+{
+    struct ImplTabCtrlData
+    // expected-error@-1 {{read maLayoutLineToPageId [loplugin:unusedfields]}}
+    // expected-error@-2 {{outside maLayoutLineToPageId 
[loplugin:unusedfields]}}
+    {
+        std::map< int, int > maLayoutLineToPageId;
+    };
+    class TabControl
+    // expected-error@-1 {{read mpTabCtrlData [loplugin:unusedfields]}}
+    // expected-error@-2 {{outside-constructor mpTabCtrlData 
[loplugin:unusedfields]}}
+    {
+        std::unique_ptr<ImplTabCtrlData> mpTabCtrlData;
+
+        void foo(int nLine, int& rPageId)
+        {
+            rPageId = mpTabCtrlData->maLayoutLineToPageId[ nLine ];
+        }
+    };
+}
+
+namespace WriteOnlyAnalysis5
+{
+    struct ImplTabCtrlData
+    // expected-error@-1 {{read maLayoutLineToPageId [loplugin:unusedfields]}}
+    // expected-error@-2 {{write maLayoutLineToPageId [loplugin:unusedfields]}}
+    // expected-error@-3 {{outside maLayoutLineToPageId 
[loplugin:unusedfields]}}
+    {
+        std::map< int, int > maLayoutLineToPageId;
+    };
+    class TabControl
+    // expected-error@-1 {{read mpTabCtrlData [loplugin:unusedfields]}}
+    // expected-error@-2 {{outside-constructor mpTabCtrlData 
[loplugin:unusedfields]}}
+    {
+        std::unique_ptr<ImplTabCtrlData> mpTabCtrlData;
+
+        void foo(int nLine, int nPageId)
+        {
+            mpTabCtrlData->maLayoutLineToPageId[ nLine ] = nPageId;
+        }
+    };
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/compilerplugins/clang/unusedfields.cxx 
b/compilerplugins/clang/unusedfields.cxx
index 68588cd7c694..ca5eb3eb00b3 100644
--- a/compilerplugins/clang/unusedfields.cxx
+++ b/compilerplugins/clang/unusedfields.cxx
@@ -168,6 +168,7 @@ private:
     void checkIfWrittenTo(const FieldDecl* fieldDecl, const Expr* memberExpr);
     bool isSomeKindOfZero(const Expr* arg);
     bool checkForWriteWhenUsingCollectionType(const CXXMethodDecl * 
calleeMethodDecl);
+    bool checkForUsingMap(const CXXMethodDecl * calleeMethodDecl);
     bool IsPassedByNonConst(const FieldDecl* fieldDecl, const Stmt * child, 
CallerWrapper callExpr,
                                         CalleeWrapper calleeFunctionDecl);
     compat::optional<CalleeWrapper> getCallee(CallExpr const *);
@@ -831,6 +832,7 @@ void UnusedFields::checkIfWrittenTo(const FieldDecl* 
fieldDecl, const Expr* memb
         }
         else if (auto operatorCallExpr = dyn_cast<CXXOperatorCallExpr>(parent))
         {
+            bool walk = false;
             auto callee = getCallee(operatorCallExpr);
             if (callee)
             {
@@ -839,16 +841,24 @@ void UnusedFields::checkIfWrittenTo(const FieldDecl* 
fieldDecl, const Expr* memb
                 if (calleeMethodDecl && operatorCallExpr->getArg(0) == child)
                 {
                     if (!calleeMethodDecl->isConst())
-                        bPotentiallyWrittenTo = 
checkForWriteWhenUsingCollectionType(calleeMethodDecl);
+                    {
+                        // If we are accessing a map entry, we want to keep 
walking up to determine
+                        // if it is written to.
+                        if (checkForUsingMap(calleeMethodDecl))
+                            walk = true;
+                        else
+                            bPotentiallyWrittenTo = 
checkForWriteWhenUsingCollectionType(calleeMethodDecl);
+                    }
                 }
                 else if (IsPassedByNonConst(fieldDecl, child, 
operatorCallExpr, *callee))
-                {
                     bPotentiallyWrittenTo = true;
-                }
             }
             else
                 bPotentiallyWrittenTo = true; // conservative, could improve
-            break;
+            if (walk)
+                walkUp();
+            else
+                break;
         }
         else if (auto cxxMemberCallExpr = dyn_cast<CXXMemberCallExpr>(parent))
         {
@@ -980,20 +990,20 @@ bool 
UnusedFields::checkForWriteWhenUsingCollectionType(const CXXMethodDecl * ca
 {
     auto const tc = loplugin::TypeCheck(calleeMethodDecl->getParent());
     bool listLike = false, setLike = false, mapLike = false, cssSequence = 
false;
-    if (tc.Class("deque").StdNamespace()
-        || tc.Class("list").StdNamespace()
-        || tc.Class("queue").StdNamespace()
-        || tc.Class("vector").StdNamespace())
+    // Noting that I am deliberately not calling StdNamespace() on these 
checks, the loplugin::TypeCheck
+    // code seems to be unreliable when dealing with 
ClassTemplateSpecializationDecl.
+    if (tc.Class("deque")
+        || tc.Class("list")
+        || tc.Class("queue")
+        || tc.Class("vector"))
     {
         listLike = true;
     }
-    else if (tc.Class("set").StdNamespace()
-        || tc.Class("unordered_set").StdNamespace())
+    else if (tc.Class("set") || tc.Class("unordered_set"))
     {
         setLike = true;
     }
-    else if (tc.Class("map").StdNamespace()
-        || tc.Class("unordered_map").StdNamespace())
+    else if (tc.Class("map") || tc.Class("unordered_map"))
     {
         mapLike = true;
     }
@@ -1040,6 +1050,16 @@ bool 
UnusedFields::checkForWriteWhenUsingCollectionType(const CXXMethodDecl * ca
     return true;
 }
 
+bool UnusedFields::checkForUsingMap(const CXXMethodDecl * calleeMethodDecl)
+{
+    auto const tc = loplugin::TypeCheck(calleeMethodDecl->getParent());
+    if (!(tc.Class("map") || tc.Class("unordered_map")))
+        return false;
+    if (!calleeMethodDecl->isOverloadedOperator())
+        return false;
+    return calleeMethodDecl->getOverloadedOperator() == OO_Subscript;
+}
+
 bool UnusedFields::IsPassedByNonConst(const FieldDecl* fieldDecl, const Stmt * 
child, CallerWrapper callExpr,
                                          CalleeWrapper calleeFunctionDecl)
 {
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx 
b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
index 543bd3e80d09..776337ebacb1 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
@@ -236,7 +236,6 @@ namespace dbaui
 
         TypedWhichId<SfxInt32Item> m_nPortId;
 
-        std::unique_ptr<weld::Label> m_xHeaderText;
         std::unique_ptr<weld::Entry> m_xETDatabasename;
         std::unique_ptr<weld::Entry> m_xETHostname;
         std::unique_ptr<weld::SpinButton> m_xNFPortNumber;
diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.cxx 
b/sd/source/filter/eppt/pptx-animations-nodectx.cxx
index 585917b4f864..9efd07d6a665 100644
--- a/sd/source/filter/eppt/pptx-animations-nodectx.cxx
+++ b/sd/source/filter/eppt/pptx-animations-nodectx.cxx
@@ -97,7 +97,6 @@ bool initCondList(const Any& rAny, std::vector<Cond>& rList, 
bool bIsMainSeqChil
 NodeContext::NodeContext(const Reference<XAnimationNode>& xNode, bool 
bMainSeqChild,
                          bool bIsIterateChild)
     : mxNode(xNode)
-    , mbMainSeqChild(bMainSeqChild)
     , mbValid(true)
     , mbOnSubTnLst(false)
     , mnEffectNodeType(-1)
@@ -111,10 +110,10 @@ NodeContext::NodeContext(const Reference<XAnimationNode>& 
xNode, bool bMainSeqCh
 
     // Put event triggered Audio time nodes to SubTnLst.
     // Add other types of nodes once we find more test cases.
-    mbOnSubTnLst = initCondList(getNodeForCondition()->getBegin(), 
maBeginCondList, mbMainSeqChild)
+    mbOnSubTnLst = initCondList(getNodeForCondition()->getBegin(), 
maBeginCondList, bMainSeqChild)
                    && mxNode->getType() == AnimationNodeType::AUDIO;
 
-    initCondList(getNodeForCondition()->getEnd(), maEndCondList, 
mbMainSeqChild);
+    initCondList(getNodeForCondition()->getEnd(), maEndCondList, 
bMainSeqChild);
 }
 
 void NodeContext::initUserData()
diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.hxx 
b/sd/source/filter/eppt/pptx-animations-nodectx.hxx
index 14aeacd45c99..c25991a85a23 100644
--- a/sd/source/filter/eppt/pptx-animations-nodectx.hxx
+++ b/sd/source/filter/eppt/pptx-animations-nodectx.hxx
@@ -22,7 +22,6 @@ typedef std::unique_ptr<NodeContext> NodeContextPtr;
 class NodeContext
 {
     const css::uno::Reference<css::animations::XAnimationNode> mxNode;
-    const bool mbMainSeqChild;
 
     std::vector<NodeContextPtr> maChildNodes;
     std::vector<Cond> maBeginCondList;
diff --git a/sfx2/source/control/recentdocsviewitem.cxx 
b/sfx2/source/control/recentdocsviewitem.cxx
index 57a670b37c53..240ef0c32d9d 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -128,7 +128,6 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView 
&rView, const OUStri
       mrParentView(rView),
       maURL(rURL),
       m_isReadOnly(isReadOnly),
-      m_isPinned(isPinned),
       m_bRemoveIconHighlighted(false),
       m_aRemoveRecentBitmap(BMP_RECENTDOC_REMOVE),
       m_aRemoveRecentBitmapHighlighted(BMP_RECENTDOC_REMOVE_HIGHLIGHTED)
@@ -231,7 +230,7 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView 
&rView, const OUStri
 
     maTitle = aTitle;
     maPreview1 = aThumbnail;
-    mbPinned = m_isPinned;
+    mbPinned = isPinned;
 }
 
 ::tools::Rectangle RecentDocsViewItem::updateHighlight(bool bVisible, const 
Point& rPoint)
diff --git a/sfx2/source/control/recentdocsviewitem.hxx 
b/sfx2/source/control/recentdocsviewitem.hxx
index 0fe399a1fe3b..792e78ab9e05 100644
--- a/sfx2/source/control/recentdocsviewitem.hxx
+++ b/sfx2/source/control/recentdocsviewitem.hxx
@@ -52,7 +52,6 @@ private:
     OUString maURL;
 
     bool m_isReadOnly = false;
-    bool m_isPinned = false;
 
     OUString m_sHelpText;
 
diff --git a/svx/source/dialog/framelinkarray.cxx 
b/svx/source/dialog/framelinkarray.cxx
index 5ad6c03c770d..80a245a0f27c 100644
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -289,7 +289,6 @@ struct ArrayImpl
 {
     // used to reduce the memory consumption of cells
     rtl::Reference<SfxItemPool> mxPool;
-    const Cell*         mpDefaultCell;
     CellVec             maCells;
     std::vector<sal_Int32>   maWidths;
     std::vector<sal_Int32>   maHeights;
@@ -357,9 +356,9 @@ ArrayImpl::ArrayImpl( sal_Int32 nWidth, sal_Int32 nHeight ) 
:
     mbYCoordsDirty( false ),
     mbMayHaveCellRotation( false )
 {
-    mpDefaultCell = &mxPool->Put(Cell());
+    const Cell* pDefaultCell = &mxPool->Put(Cell());
     // default-construct all vectors
-    maCells.resize( mnWidth * mnHeight, mpDefaultCell );
+    maCells.resize( mnWidth * mnHeight, pDefaultCell );
     maWidths.resize( mnWidth, 0 );
     maHeights.resize( mnHeight, 0 );
     maXCoords.resize( mnWidth + 1, 0 );
diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 65ec052affff..4f83a8f52ba8 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4550,8 +4550,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
                     if( rSh.GetShadowCursorPos( aDocPt, eMode, aRect, 
m_eOrient ))
                     {
                         if( !m_pShadCursor )
-                            m_pShadCursor.reset( new SwShadowCursor( *this,
-                                rSh.GetViewOptions()->GetDirectCursorColor() ) 
);
+                            m_pShadCursor.reset( new SwShadowCursor( *this ) );
                         if( text::HoriOrientation::RIGHT != m_eOrient && 
text::HoriOrientation::CENTER != m_eOrient )
                             m_eOrient = text::HoriOrientation::LEFT;
                         m_pShadCursor->SetPos( aRect.Pos(), aRect.Height(), 
static_cast< sal_uInt16 >(m_eOrient) );
diff --git a/sw/source/uibase/inc/shdwcrsr.hxx 
b/sw/source/uibase/inc/shdwcrsr.hxx
index ec8a5f55f89b..4118b3965a99 100644
--- a/sw/source/uibase/inc/shdwcrsr.hxx
+++ b/sw/source/uibase/inc/shdwcrsr.hxx
@@ -28,7 +28,6 @@
 class SwShadowCursor
 {
     VclPtr<vcl::Window> m_pWin;
-    Color m_aCol;
     Point m_aOldPt;
     tools::Long m_nOldHeight;
     sal_uInt16 m_nOldMode;
@@ -36,8 +35,8 @@ class SwShadowCursor
     void DrawCursor( sal_uInt16 nMode );
 
 public:
-    SwShadowCursor( vcl::Window& rWin, const Color& rCol )
-        : m_pWin( &rWin ), m_aCol( rCol ), m_nOldHeight(0), m_nOldMode( 
USHRT_MAX ) {}
+    SwShadowCursor( vcl::Window& rWin )
+        : m_pWin( &rWin ), m_nOldHeight(0), m_nOldMode( USHRT_MAX ) {}
     ~SwShadowCursor();
 
     void SetPos( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode );

Reply via email to