sw/source/uibase/app/appopt.cxx | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
New commits: commit a14247144df99f4888f0038adc79ff7d780d53cb Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Thu Oct 13 17:05:16 2022 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Tue Oct 18 09:49:55 2022 +0200 Fix turning off outline-folding doesn't clear all folded buttons This happens, for unknown reason, when buttons that indicate outline content is folded are near the current cursor position when the options dialog is used to turn outline-folding off. This patch takes a new approach to handle outline-folding options, that doesn't exhibit this anomaly, by using the ShowOutlineContentVisibilityButton UNO function. For the purpose of sanity and to aid understandability of what is going on here, extra effort has been made to provide useful comments and descriptive variable naming. Change-Id: I8c3d4c207791f0ba151d799af22e1998aa7c3768 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141353 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/sw/source/uibase/app/appopt.cxx b/sw/source/uibase/app/appopt.cxx index 86343d2e6651..6e338564e124 100644 --- a/sw/source/uibase/app/appopt.cxx +++ b/sw/source/uibase/app/appopt.cxx @@ -56,6 +56,8 @@ #include <swabstdlg.hxx> #include <swwrtshitem.hxx> +#include <sfx2/dispatch.hxx> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -255,22 +257,32 @@ void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) } // Elements - interpret Item - bool bFlag = true; + bool bReFoldOutlineFolding = false; if( const SwElemItem* pElemItem = rSet.GetItemIfSet( FN_PARAM_ELEM, false ) ) { pElemItem->FillViewOptions( aViewOpt ); + // Outline-folding options SwWrtShell* pWrtShell = GetActiveWrtShell(); - bFlag = pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton(); + bool bIsOutlineFoldingOn = pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton(); bool bTreatSubsChanged = aViewOpt.IsTreatSubOutlineLevelsAsContent() != pWrtShell->GetViewOptions()->IsTreatSubOutlineLevelsAsContent(); - if (bFlag && (!aViewOpt.IsShowOutlineContentVisibilityButton() || bTreatSubsChanged)) + if (bIsOutlineFoldingOn && + (!aViewOpt.IsShowOutlineContentVisibilityButton() || bTreatSubsChanged)) { - // outline mode options have change which require to show all content - pWrtShell->MakeAllFoldedOutlineContentVisible(); - + // Outline-folding options have change which require to show all content. + // Either outline-folding is being switched off or outline-folding is currently on + // and the treat subs option has changed. + pWrtShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON); if (bTreatSubsChanged) - bFlag = false; // folding method changed, set bFlag false to refold below + bReFoldOutlineFolding = true; // folding method changed, set flag to refold below + } + else + { + // Refold needs to be done when outline-folding is being turned on or off + bReFoldOutlineFolding = + pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton() != + aViewOpt.IsShowOutlineContentVisibilityButton(); } } @@ -386,8 +398,11 @@ void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) if (SfxItemState::SET != rSet.GetItemState(FN_PARAM_ELEM, false)) return; - if (!bFlag) - GetActiveWrtShell()->MakeAllFoldedOutlineContentVisible(false); + if (bReFoldOutlineFolding) + { + GetActiveWrtShell()->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON); + GetActiveWrtShell()->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON); + } } std::unique_ptr<SfxTabPage> SwModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet )