tdf#151521 Fix para applied style sub-level remains visible

... when parent outline content is folded

Commit 22757917067d7c4e475228cec2a0dd4d2f900e95, removed making all outline content temporarily visible during style application. But it is needed so that paragraph applied stye sub-levels do not remain visible when outline-folding is set to include sub-levels as outline content. This patch fixes the cause of the bug reported in tdf#151315.

Change-Id: I4b8fd4bdd1ca08d65cf8fbb8c3f73ef7d00dcc2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141357
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 3581cac6..baa2a4c 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1157,6 +1157,11 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa
        }
        case SfxStyleFamily::Para:
        {
            // When outline-folding is enabled, MakeAllOutlineContentTemporarilyVisible makes
            // application of a paragraph style that has an outline-level greater than the previous
            // outline node become folded content of the previous outline node if the previous
            // outline node's content is folded.
            MakeAllOutlineContentTemporarilyVisible a(GetDoc());
            // #i62675#
            // clear also list attributes at affected text nodes, if paragraph
            // style has the list style attribute set.
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index d9374e1..8bbdb86 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -2491,30 +2491,6 @@ void SwWrtShell::InvalidateOutlineContentVisibility()

void SwWrtShell::MakeAllFoldedOutlineContentVisible(bool bMakeVisible)
{
    // deselect any drawing or frame and leave editing mode
    SdrView* pSdrView = GetDrawView();
    if (pSdrView && pSdrView->IsTextEdit() )
    {
        bool bLockView = IsViewLocked();
        LockView(true);
        EndTextEdit();
        LockView(bLockView);
    }

    if (IsSelFrameMode() || IsObjSelected())
    {
        UnSelectFrame();
        LeaveSelFrameMode();
        GetView().LeaveDrawCreate();
        EnterStdMode();
        DrawSelChanged();
        GetView().StopShellTimer();
    }
    else
        EnterStdMode();

    SwOutlineNodes::size_type nPos = GetOutlinePos();

    if (bMakeVisible)
    {
        // make all content visible
@@ -2548,17 +2524,43 @@ void SwWrtShell::MakeAllFoldedOutlineContentVisible(bool bMakeVisible)
    }
    else
    {
        if (SdrView* pSdrView = GetDrawView(); pSdrView && pSdrView->IsTextEdit() )
        {
            bool bLockView = IsViewLocked();
            LockView(true);
            EndTextEdit();
            LockView(bLockView);
        }
        if (IsSelFrameMode() || IsObjSelected())
        {
            UnSelectFrame();
            LeaveSelFrameMode();
            GetView().LeaveDrawCreate();
            EnterStdMode();
        }

        // Get current frame in which the cursor is positioned for use in placing the cursor.
        const SwFrame* pCurrFrame = GetCurrFrame(false);

        SwOutlineNodes::size_type nPos = GetOutlinePos();

        StartAction();
        InvalidateOutlineContentVisibility();
        EndAction();

        // If needed, find visible outline node to place cursor.
        if (nPos != SwOutlineNodes::npos && !IsOutlineContentVisible(nPos))
        // If needed, find visible outline node frame to place cursor.
        if (!pCurrFrame || !pCurrFrame->isFrameAreaDefinitionValid() || pCurrFrame->IsInDtor() ||
                (nPos != SwOutlineNodes::npos &&
                 !GetNodes().GetOutLineNds()[nPos]->GetTextNode()->getLayoutFrame(nullptr)))
        {
            while (nPos != SwOutlineNodes::npos && !GetNodes().GetOutLineNds()[nPos]->GetTextNode()->getLayoutFrame(nullptr))
            while (nPos != SwOutlineNodes::npos &&
                   !GetNodes().GetOutLineNds()[nPos]->GetTextNode()->getLayoutFrame(nullptr))
                --nPos;
            if (nPos != SwOutlineNodes::npos)
            {
                EnterStdMode();
                GotoOutline(nPos);
            }
        }
    }
    GetView().GetDocShell()->Broadcast(SfxHint(SfxHintId::DocChanged));