[Libreoffice-commits] core.git: sw/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 18 19:12:50 UTC 2020
sw/source/core/doc/DocumentContentOperationsManager.cxx | 31 ++++++++
sw/source/uibase/utlui/content.cxx | 59 ----------------
2 files changed, 31 insertions(+), 59 deletions(-)
New commits:
commit 54691ea52a91491ae251473c83b61f9adaf0b581
Author: Jim Raykowski <raykowj at gmail.com>
AuthorDate: Sun Aug 16 11:23:57 2020 -0800
Commit: Jim Raykowski <raykowj at gmail.com>
CommitDate: Tue Aug 18 21:12:12 2020 +0200
Improve location of unfold fold code use in outline move
Change-Id: I299f871c4d6e06f63efaf80e04cb668c52ae8543
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100829
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj at gmail.com>
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 695057d342c2..0049560c4047 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -89,6 +89,9 @@
#include <tuple>
#include <memory>
+#include <editsh.hxx>
+#include <viewopt.hxx>
+#include <wrtsh.hxx>
using namespace ::com::sun::star::i18n;
@@ -2431,6 +2434,27 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos,
bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos,
SwMoveFlags eMvFlags )
{
+ std::vector<SwNode*> aFoldedOutlineNdsArray;
+ SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell*>(m_rDoc.GetEditShell());
+ if (pWrtShell && pWrtShell->GetViewOptions() && pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton())
+ {
+ // unfold all folded outline content
+ SwOutlineNodes rOutlineNds = m_rDoc.GetNodes().GetOutLineNds();
+ for (SwOutlineNodes::size_type nPos = 0; nPos < rOutlineNds.size(); ++nPos)
+ {
+ SwNode* pNd = rOutlineNds[nPos];
+ if (pNd->IsTextNode()) // should always be true
+ {
+ bool bOutlineContentVisibleAttr = true;
+ pNd->GetTextNode()->GetAttrOutlineContentVisible(bOutlineContentVisibleAttr);
+ if (!bOutlineContentVisibleAttr)
+ {
+ aFoldedOutlineNdsArray.push_back(pNd);
+ pWrtShell->ToggleOutlineContentVisibility(nPos);
+ }
+ }
+ }
+ }
// Moves all Nodes to the new position.
// Bookmarks are moved too (currently without Undo support).
@@ -2556,6 +2580,13 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod
m_rDoc.GetFootnoteIdxs().UpdateAllFootnote();
}
+ if (pWrtShell && pWrtShell->GetViewOptions() && pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton())
+ {
+ // fold all outlines that were folded before move
+ for (SwNode* pNd : aFoldedOutlineNdsArray)
+ pWrtShell->ToggleOutlineContentVisibility(pNd, true);
+ }
+
m_rDoc.getIDocumentState().SetModified();
return true;
}
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 061c164cdf1e..cf7329ee267f 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2772,7 +2772,6 @@ void SwContentTree::ExecCommand(const OString& rCmd, bool bOutlineWithChildren)
SwOutlineNodes::difference_type nDirLast = bUp ? -1 : 1;
bool bStartedAction = false;
- std::vector<SwNode*> aFoldedOutlineNdsArray;
for (auto const& pCurrentEntry : selected)
{
assert(pCurrentEntry && lcl_IsContent(*pCurrentEntry, *m_xTreeView));
@@ -2794,28 +2793,6 @@ void SwContentTree::ExecCommand(const OString& rCmd, bool bOutlineWithChildren)
if (!bStartedAction)
{
pShell->StartAllAction();
- if (bUpDown)
- {
- if (pShell->GetViewOptions()->IsShowOutlineContentVisibilityButton())
- {
- // unfold all folded outline content
- SwOutlineNodes rOutlineNds = pShell->GetDoc()->GetNodes().GetOutLineNds();
- for (SwOutlineNodes::size_type nPos = 0; nPos < rOutlineNds.size(); ++nPos)
- {
- SwNode* pNd = rOutlineNds[nPos];
- if (pNd->IsTextNode()) // should always be true
- {
- bool bOutlineContentVisibleAttr = true;
- pNd->GetTextNode()->GetAttrOutlineContentVisible(bOutlineContentVisibleAttr);
- if (!bOutlineContentVisibleAttr)
- {
- aFoldedOutlineNdsArray.push_back(pNd);
- pShell->ToggleOutlineContentVisibility(nPos);
- }
- }
- }
- }
- }
pShell->StartUndo(bLeftRight ? SwUndoId::OUTLINE_LR : SwUndoId::OUTLINE_UD);
bStartedAction = true;
}
@@ -2987,15 +2964,6 @@ void SwContentTree::ExecCommand(const OString& rCmd, bool bOutlineWithChildren)
if (bStartedAction)
{
pShell->EndUndo();
- if (bUpDown)
- {
- if (pShell->GetViewOptions()->IsShowOutlineContentVisibilityButton())
- {
- // fold all outlines that were folded before chapter promote/demote
- for (SwNode* pNd : aFoldedOutlineNdsArray)
- pShell->ToggleOutlineContentVisibility(pNd, true);
- }
- }
pShell->EndAllAction();
if (m_aActiveContentArr[ContentTypeId::OUTLINE])
m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate();
@@ -3171,27 +3139,6 @@ void SwContentTree::MoveOutline(SwOutlineNodes::size_type nTargetPos)
{
SwWrtShell *const pShell = GetWrtShell();
pShell->StartAllAction();
- std::vector<SwNode*> aFoldedOutlineNdsArray;
-
- if (pShell->GetViewOptions()->IsShowOutlineContentVisibilityButton())
- {
- // unfold all folded outline content
- SwOutlineNodes rOutlineNds = pShell->GetDoc()->GetNodes().GetOutLineNds();
- for (SwOutlineNodes::size_type nPos = 0; nPos < rOutlineNds.size(); ++nPos)
- {
- SwNode* pNd = rOutlineNds[nPos];
- if (pNd->IsTextNode()) // should always be true
- {
- bool bOutlineContentVisibleAttr = true;
- pNd->GetTextNode()->GetAttrOutlineContentVisible(bOutlineContentVisibleAttr);
- if (!bOutlineContentVisibleAttr)
- {
- aFoldedOutlineNdsArray.push_back(pNd);
- pShell->ToggleOutlineContentVisibility(nPos);
- }
- }
- }
- }
pShell->StartUndo(SwUndoId::OUTLINE_UD);
SwOutlineNodes::size_type nPrevSourcePos = SwOutlineNodes::npos;
@@ -3242,12 +3189,6 @@ void SwContentTree::MoveOutline(SwOutlineNodes::size_type nTargetPos)
}
pShell->EndUndo();
- if (pShell->GetViewOptions()->IsShowOutlineContentVisibilityButton())
- {
- // fold all outlines that were folded before chapter promote/demote
- for (SwNode* pNd : aFoldedOutlineNdsArray)
- pShell->ToggleOutlineContentVisibility(pNd, true);
- }
pShell->EndAllAction();
m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate();
Display(true);
More information about the Libreoffice-commits
mailing list