diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-12-12 20:21:40 +0000 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-12-19 12:21:28 +0100 |
commit | 46c749ba793edfc4a5668c86ce1143496e868012 (patch) | |
tree | a1d018d7fed8b94a9832aedabee3f19b4c2e2b01 | |
parent | 11c286c83cb576951f33af241be6b828a7dc75c2 (diff) |
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 <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
(cherry picked from commit 6002f2777ab9294c1d41ef64863480976f254e43)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178549
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | include/svl/hint.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/StyleList.cxx | 46 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 8 |
3 files changed, 39 insertions, 16 deletions
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; } |