include/svl/hint.hxx             |    1 
 sfx2/source/dialog/StyleList.cxx |   46 +++++++++++++++++++++++++--------------
 sw/source/uibase/uiview/view.cxx |    8 ++++++
 3 files changed, 39 insertions(+), 16 deletions(-)

New commits:
commit 46c749ba793edfc4a5668c86ce1143496e868012
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Dec 12 20:21:40 2024 +0000
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Dec 19 12:21:28 2024 +0100

    Replace workaround of resize to invalidate with an explicit SfxHint
    
    Change-Id: Ic0c8ba5e5f65f7b1e472a667b69e737f4f1d9fbc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178389
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 6002f2777ab9294c1d41ef64863480976f254e43)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178549
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index a1c4ea43ae2f..7a55b0f9de03 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -155,6 +155,7 @@ enum class SfxHintId {
     StyleSheetChanged,  // erased and re-created (replaced)
     StyleSheetErased,  // erased
     StyleSheetInDestruction,  // in the process of being destructed
+    StylesHighlighterModified,  // what styles to highlight in a document 
changed
 
 // STARMATH
     MathFormatChanged,
diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index 60151d2c83ad..82bb545f668b 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -1089,12 +1089,20 @@ void StyleList::FillTreeBox(SfxStyleFamily eFam)
     const sal_uInt16 nCount = aArr.size();
 
     SfxViewShell* pViewShell = m_pCurObjShell->GetViewShell();
+    StylesHighlighterColorMap* pHighlighterColorMap = nullptr;
+    bool bOrigMapHasEntries = false;
     if (pViewShell && m_bModuleHasStylesHighlighterFeature)
     {
         if (eFam == SfxStyleFamily::Para)
-            pViewShell->GetStylesHighlighterParaColorMap().clear();
+            pHighlighterColorMap = 
&pViewShell->GetStylesHighlighterParaColorMap();
         else if (eFam == SfxStyleFamily::Char)
-            pViewShell->GetStylesHighlighterCharColorMap().clear();
+            pHighlighterColorMap = 
&pViewShell->GetStylesHighlighterCharColorMap();
+    }
+
+    if (pHighlighterColorMap && !pHighlighterColorMap->empty())
+    {
+        bOrigMapHasEntries = true;
+        pHighlighterColorMap->clear();
     }
 
     bool blcl_insert = pViewShell && m_bModuleHasStylesHighlighterFeature
@@ -1113,12 +1121,11 @@ void StyleList::FillTreeBox(SfxStyleFamily eFam)
 
     m_xTreeBox->thaw();
 
-    // hack for x11 to make view update
-    if (pViewShell && m_bModuleHasStylesHighlighterFeature)
-    {
-        SfxViewFrame* pViewFrame = 
m_pBindings->GetDispatcher_Impl()->GetFrame();
-        pViewFrame->Resize(true);
-    }
+    // make view update
+    if (pViewShell && pHighlighterColorMap
+        && (!pHighlighterColorMap->empty() || bOrigMapHasEntries))
+        static_cast<SfxListener*>(pViewShell)
+            ->Notify(*m_pStyleSheetPool, 
SfxHint(SfxHintId::StylesHighlighterModified));
 
     std::unique_ptr<weld::TreeIter> xEntry = m_xTreeBox->make_iterator();
     bool bEntry = m_xTreeBox->get_iter_first(*xEntry);
@@ -1280,12 +1287,20 @@ void StyleList::UpdateStyles(StyleFlags nFlags)
     m_xFmtLb->clear();
 
     SfxViewShell* pViewShell = m_pCurObjShell->GetViewShell();
+    StylesHighlighterColorMap* pHighlighterColorMap = nullptr;
+    bool bOrigMapHasEntries = false;
     if (pViewShell && m_bModuleHasStylesHighlighterFeature)
     {
         if (eFam == SfxStyleFamily::Para)
-            pViewShell->GetStylesHighlighterParaColorMap().clear();
+            pHighlighterColorMap = 
&pViewShell->GetStylesHighlighterParaColorMap();
         else if (eFam == SfxStyleFamily::Char)
-            pViewShell->GetStylesHighlighterCharColorMap().clear();
+            pHighlighterColorMap = 
&pViewShell->GetStylesHighlighterCharColorMap();
+    }
+
+    if (pHighlighterColorMap && !pHighlighterColorMap->empty())
+    {
+        bOrigMapHasEntries = true;
+        pHighlighterColorMap->clear();
     }
 
     size_t nCount = aStrings.size();
@@ -1322,12 +1337,11 @@ void StyleList::UpdateStyles(StyleFlags nFlags)
 
     m_xFmtLb->thaw();
 
-    // hack for x11 to make view update
-    if (pViewShell && m_bModuleHasStylesHighlighterFeature)
-    {
-        SfxViewFrame* pViewFrame = 
m_pBindings->GetDispatcher_Impl()->GetFrame();
-        pViewFrame->Resize(true);
-    }
+    // make view update
+    if (pViewShell && pHighlighterColorMap
+        && (!pHighlighterColorMap->empty() || bOrigMapHasEntries))
+        static_cast<SfxListener*>(pViewShell)
+            ->Notify(*m_pStyleSheetPool, 
SfxHint(SfxHintId::StylesHighlighterModified));
 
     // Selects the current style if any
     SfxTemplateItem* pState = m_pFamilyState[m_nActFamily - 1].get();
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 844612148a34..342f889183c7 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1845,6 +1845,14 @@ void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& 
rHint )
                 GetViewFrame().GetBindings().Invalidate(aSlotRedLine);
             }
             break;
+        case SfxHintId::StylesHighlighterModified:
+            {
+                // we need to Invalidate to render with the new set of
+                // highlighted styles
+                if (vcl::Window *pMyWin = GetWrtShell().GetWin())
+                    pMyWin->Invalidate();
+            }
+            break;
         default: break;
     }
 

Reply via email to