sd/source/ui/view/drviews1.cxx                  |    2 +-
 sw/inc/AnnotationWin.hxx                        |    2 +-
 sw/source/core/text/frmform.cxx                 |    3 +--
 sw/source/core/txtnode/txtedt.cxx               |    4 +---
 sw/source/filter/ww8/docxattributeoutput.cxx    |    2 +-
 sw/source/ui/frmdlg/wrap.cxx                    |    2 +-
 sw/source/uibase/docvw/AnnotationMenuButton.cxx |   15 +++++++--------
 sw/source/uibase/docvw/AnnotationWin.cxx        |    2 +-
 sw/source/uibase/docvw/AnnotationWin2.cxx       |    2 +-
 sw/source/uibase/docvw/SidebarTxtControl.cxx    |    4 ++--
 sw/source/uibase/shells/annotsh.cxx             |    2 +-
 sw/source/uibase/utlui/content.cxx              |    4 ++--
 12 files changed, 20 insertions(+), 24 deletions(-)

New commits:
commit 7fe6677dfae8f89da53351fd86adffe6c7d59dc9
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Mar 7 11:26:18 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 7 12:21:27 2023 +0000

    Improve flow of logic in SwAnnotationWin::ToggleHdl
    
    and rename the IsProtected method to more accurately reflect
    what it returns.
    Certainly the initial flow of logic in this method was very
    confusing.
    
    Change-Id: I4a01c00160a896961fcce97831605d3a6e15cd1c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148383
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 2aa641361ebf..e3d6e509d216 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -82,7 +82,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
         sal_uInt32 CalcParent();
         void       InitAnswer(OutlinerParaObject const & rText);
 
-        bool IsProtected() const;
+        bool IsReadOnlyOrProtected() const;
 
         void SetSize( const Size& rNewSize );
         void SetPosSizePixelRect( tools::Long nX,
diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.cxx 
b/sw/source/uibase/docvw/AnnotationMenuButton.cxx
index 1696f7e6d338..fe0143d8c3c3 100644
--- a/sw/source/uibase/docvw/AnnotationMenuButton.cxx
+++ b/sw/source/uibase/docvw/AnnotationMenuButton.cxx
@@ -66,13 +66,9 @@ IMPL_LINK_NOARG(SwAnnotationWin, ToggleHdl, 
weld::Toggleable&, void)
     if (!mxMenuButton->get_active())
         return;
 
-    bool bReplyVis = true;
-
     bool bReadOnly = IsReadOnly();
     if (bReadOnly)
     {
-        mxMenuButton->set_item_visible("reply", false);
-        bReplyVis = false;
         mxMenuButton->set_item_visible("resolve", false);
         mxMenuButton->set_item_visible("unresolve", false);
         mxMenuButton->set_item_visible("resolvethread", false);
@@ -85,7 +81,7 @@ IMPL_LINK_NOARG(SwAnnotationWin, ToggleHdl, 
weld::Toggleable&, void)
         mxMenuButton->set_item_visible("unresolve", IsResolved());
         mxMenuButton->set_item_visible("resolvethread", !IsThreadResolved());
         mxMenuButton->set_item_visible("unresolvethread", IsThreadResolved());
-        mxMenuButton->set_item_visible("delete", !IsProtected());
+        mxMenuButton->set_item_visible("delete", !IsReadOnlyOrProtected());
     }
 
     mxMenuButton->set_item_visible("deletethread", !bReadOnly);
@@ -93,7 +89,10 @@ IMPL_LINK_NOARG(SwAnnotationWin, ToggleHdl, 
weld::Toggleable&, void)
     mxMenuButton->set_item_visible("deleteall", !bReadOnly);
     mxMenuButton->set_item_visible("formatall", !bReadOnly);
 
-    if (IsProtected())
+    bool bReplyVis = true;
+
+    // No answer possible if this note is in a protected section.
+    if (IsReadOnlyOrProtected())
     {
         mxMenuButton->set_item_visible("reply", false);
         bReplyVis = false;
@@ -109,10 +108,10 @@ IMPL_LINK_NOARG(SwAnnotationWin, ToggleHdl, 
weld::Toggleable&, void)
                 sAuthor = SwResId(STR_REDLINE_UNKNOWN_AUTHOR);
             }
         }
-        // do not allow to reply to ourself and no answer possible if this 
note is in a protected section
+        // do not allow to reply to ourself
         bReplyVis = sAuthor != GetAuthor();
-        mxMenuButton->set_item_visible("reply", bReplyVis);
     }
+    mxMenuButton->set_item_visible("reply", bReplyVis);
     mxMenuButton->set_item_visible("sep1", bReplyVis);
 }
 
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index dcaf84550af6..b28c66f03650 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -503,7 +503,7 @@ SvxLanguageItem SwAnnotationWin::GetLanguage() const
     return SvxLanguageItem(mpField->GetLanguage(),nLangWhichId);
 }
 
-bool SwAnnotationWin::IsProtected() const
+bool SwAnnotationWin::IsReadOnlyOrProtected() const
 {
     return mbReadonly ||
            GetLayoutStatus() == SwPostItHelper::DELETED ||
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index a9b1e468acb2..eff0c82571d8 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1067,7 +1067,7 @@ void SwAnnotationWin::DeactivatePostIt()
     if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
         GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT);
 
-    if (!mnDeleteEventId && !IsProtected() && 
mpOutliner->GetEditEngine().GetText().isEmpty())
+    if (!mnDeleteEventId && !IsReadOnlyOrProtected() && 
mpOutliner->GetEditEngine().GetText().isEmpty())
     {
         mnDeleteEventId = Application::PostUserEvent( LINK( this, 
SwAnnotationWin, DeleteHdl), nullptr, true );
     }
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx 
b/sw/source/uibase/docvw/SidebarTxtControl.cxx
index b08758a611a0..7be7fe37c61e 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.cxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx
@@ -325,7 +325,7 @@ bool SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt )
         /// HACK: need to switch off processing of Undo/Redo in Outliner
         if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
         {
-            bool bIsProtected = mrSidebarWin.IsProtected();
+            bool bIsProtected = mrSidebarWin.IsReadOnlyOrProtected();
             if ( !bIsProtected || !EditEngine::DoesKeyChangeText(rKeyEvt) )
             {
                 EditView* pEditView = GetEditView();
@@ -416,7 +416,7 @@ bool SidebarTextControl::Command( const CommandEvent& rCEvt 
)
     {
         if (IsMouseCaptured())
             ReleaseMouse();
-        if ( !mrSidebarWin.IsProtected() &&
+        if ( !mrSidebarWin.IsReadOnlyOrProtected() &&
              pEditView &&
              pEditView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(), 
true ))
         {
diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index 9e9fd0f2c07a..112cf98d3095 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1247,7 +1247,7 @@ void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
 
         if (pPostItMgr && pPostItMgr->HasActiveSidebarWin())
         {
-            if ( (pPostItMgr->GetActiveSidebarWin()->IsProtected()) &&
+            if ( (pPostItMgr->GetActiveSidebarWin()->IsReadOnlyOrProtected()) 
&&
                     ( (nSlotId==FN_DELETE_COMMENT) || (nSlotId==FN_REPLY) ) )
                 rSet.DisableItem( nWhich );
         }
commit 40661d3fcec5f50abcd79975e565cd61cba67f0c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Mar 7 11:15:52 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 7 12:21:18 2023 +0000

    clang-tidy dead-store
    
    Change-Id: Iad8dd9081966193090b0929169da199b47f949a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148380
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index a889ecc6937d..c920b315466e 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -660,7 +660,7 @@ void DrawViewShell::ResetActualPage()
         return;
 
     sal_uInt16 nCurrentPageId = maTabControl->GetCurPageId();
-    sal_uInt16 nNewPageId = nCurrentPageId;
+    sal_uInt16 nNewPageId;
     sal_uInt16 nCurrentPageNum = maTabControl->GetPagePos(nCurrentPageId);
     sal_uInt16 nPageCount   = (meEditMode == 
EditMode::Page)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
 
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index b1e98d9771bc..25bd98bec92e 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1829,7 +1829,6 @@ void SwTextFrame::Format( vcl::RenderContext* 
pRenderContext, const SwBorderAttr
     {
         // If MustFit is set, we shrink to the Upper's bottom edge if needed.
         SwTextLineAccess aAccess( this );
-        tools::Long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
 
         if( aAccess.GetPara()->IsPrepMustFit() )
         {
@@ -1839,7 +1838,7 @@ void SwTextFrame::Format( vcl::RenderContext* 
pRenderContext, const SwBorderAttr
                 Shrink( nDiff );
         }
 
-        nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
+        tools::Long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
         const tools::Long nTop = aRectFnSet.GetTopMargin(*this);
 
         if( nTop > nFrameHeight )
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 8c1d1941b684..d0da99a7986c 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -832,7 +832,6 @@ bool SwScanner::NextWord()
     m_nBegin = m_nBegin + m_nLength;
     Boundary aBound;
 
-    const CharClass* pCC = &GetAppCharClass();
     std::optional<CharClass> xLocalCharClass;
 
     while ( true )
@@ -853,8 +852,7 @@ bool SwScanner::NextWord()
                 if ( m_nWordType != i18n::WordType::WORD_COUNT )
                 {
                     xLocalCharClass.emplace(LanguageTag( 
g_pBreakIt->GetLocale( m_aCurrentLang ) ));
-                    pCC = &*xLocalCharClass;
-                    if ( pCC->isLetterNumeric(OUString(m_aText[m_nBegin])) )
+                    if ( 
xLocalCharClass->isLetterNumeric(OUString(m_aText[m_nBegin])) )
                         break;
                 }
                 else
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 15159e88e602..45121566ec24 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -9169,7 +9169,7 @@ void DocxAttributeOutput::FormatSurround( const 
SwFormatSurround& rSurround )
     }
     else if ( m_rExport.m_bOutFlyFrameAttrs )
     {
-        const char* sWrap( "auto" );
+        const char* sWrap;
         switch ( rSurround.GetSurround( ) )
         {
             case css::text::WrapTextMode_NONE:
diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx
index 457fa346558b..684fe38b22bb 100644
--- a/sw/source/ui/frmdlg/wrap.cxx
+++ b/sw/source/ui/frmdlg/wrap.cxx
@@ -438,7 +438,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet)
                     if (aVal.nVPos <= aVal.nMaxHeight)
                         nTop = aVal.nMaxVPos - aVal.nHeight;
                     else
-                        nTop = nBottom = 0; // no passage
+                        nTop = 0; // no passage
                 }
                 else
                     nTop = aVal.nMaxVPos - aVal.nHeight - aVal.nVPos;
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 6b22c60dd2ed..57b9bffab834 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3535,8 +3535,8 @@ void SwContentTree::ExecCommand(std::string_view rCmd, 
bool bOutlineWithChildren
         // reselect entries
         const SwOutlineNodes::size_type nCurrPos = 
pShell->GetOutlinePos(MAXLEVEL);
         std::unique_ptr<weld::TreeIter> 
xListEntry(m_xTreeView->make_iterator());
-        bool bListEntry = m_xTreeView->get_iter_first(*xListEntry);
-        while ((bListEntry = m_xTreeView->iter_next(*xListEntry)) && 
lcl_IsContent(*xListEntry, *m_xTreeView))
+        m_xTreeView->get_iter_first(*xListEntry);
+        while (m_xTreeView->iter_next(*xListEntry) && 
lcl_IsContent(*xListEntry, *m_xTreeView))
         {
             
assert(dynamic_cast<SwOutlineContent*>(weld::fromId<SwTypeNumber*>(m_xTreeView->get_id(*xListEntry))));
             if 
(weld::fromId<SwOutlineContent*>(m_xTreeView->get_id(*xListEntry))->GetOutlinePos()
 == nCurrPos)

Reply via email to