Rebased ref, commits from common ancestor: commit abe212d752a0668e06f17d6c8a26771fa5fdaf7a Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Nov 5 18:32:31 2018 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Nov 5 18:58:20 2018 +0100
sw_redlinehide_3: hide deleted numbered nodes in field dialog This reuses the IDocumentOutlineNodes code for IDocumentListItems; the only client of it is the field dialog cross reference page. Adapt SwCursorShell::GetContentAtPos() too. Change-Id: I9a9ed464b176dd26bf39969ba94041f995ba8c7e diff --git a/sw/inc/IDocumentListItems.hxx b/sw/inc/IDocumentListItems.hxx index e8573e59879f..b5d1e8083b48 100644 --- a/sw/inc/IDocumentListItems.hxx +++ b/sw/inc/IDocumentListItems.hxx @@ -22,6 +22,8 @@ #include <vector> #include <rtl/ustring.hxx> + +class SwRootFrame; class SwNodeNum; /** Provides numbered items of a document. @@ -34,7 +36,11 @@ public: virtual void addListItem( const SwNodeNum& rNodeNum ) = 0; virtual void removeListItem( const SwNodeNum& rNodeNum ) = 0; - virtual OUString getListItemText( const SwNodeNum& rNodeNum ) const = 0; + virtual OUString getListItemText(const SwNodeNum& rNodeNum, + SwRootFrame const& rLayout) const = 0; + + virtual bool isNumberedInLayout(SwNodeNum const& rNodeNum, + SwRootFrame const& rLayout) const = 0; /** get vector of all list items, which are numbered */ diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index a00a35ec6f77..5220dd4f8071 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1291,7 +1291,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt, if( pONd ) { rContentAtPos.eContentAtPos = IsAttrAtPos::Outline; - rContentAtPos.sStr = pONd->GetExpandText( 0, -1, true, true ); + rContentAtPos.sStr = sw::GetExpandTextMerged(GetLayout(), *pONd, true, false, ExpandMode(0)); bRet = true; } } diff --git a/sw/source/core/doc/DocumentListItemsManager.cxx b/sw/source/core/doc/DocumentListItemsManager.cxx index edb859a6e57a..8d88fba75cf1 100644 --- a/sw/source/core/doc/DocumentListItemsManager.cxx +++ b/sw/source/core/doc/DocumentListItemsManager.cxx @@ -18,7 +18,9 @@ */ #include <DocumentListItemsManager.hxx> + #include <SwNodeNum.hxx> +#include <txtfrm.hxx> #include <ndtxt.hxx> #include <osl/diagnose.h> @@ -66,12 +68,19 @@ void DocumentListItemsManager::removeListItem( const SwNodeNum& rNodeNum ) } } -OUString DocumentListItemsManager::getListItemText( const SwNodeNum& rNodeNum ) const +OUString DocumentListItemsManager::getListItemText(const SwNodeNum& rNodeNum, + SwRootFrame const& rLayout) const +{ + SwTextNode const*const pNode(rNodeNum.GetTextNode()); + assert(pNode); + return sw::GetExpandTextMerged(&rLayout, *pNode, true, true, ExpandMode(0)); +} + +bool DocumentListItemsManager::isNumberedInLayout( + SwNodeNum const& rNodeNum, // note: this is the non-hidden Num ... + SwRootFrame const& rLayout) const { - return rNodeNum.GetTextNode() - ? rNodeNum.GetTextNode()->GetExpandText( 0, -1, true/*bWithNumber*/, - true/*bWithNumber*/, true/*bWithSpacesForLevel*/ ) - : OUString(); + return sw::IsParaPropsNode(rLayout, *rNodeNum.GetTextNode()); } void DocumentListItemsManager::getNumItems( tSortedNodeNumList& orNodeNumList ) const diff --git a/sw/source/core/doc/DocumentOutlineNodesManager.cxx b/sw/source/core/doc/DocumentOutlineNodesManager.cxx index 3654c5032eb4..12945c76ae6e 100644 --- a/sw/source/core/doc/DocumentOutlineNodesManager.cxx +++ b/sw/source/core/doc/DocumentOutlineNodesManager.cxx @@ -41,36 +41,31 @@ int DocumentOutlineNodesManager::getOutlineLevel( const tSortedOutlineNodeList:: GetTextNode()->GetAttrOutlineLevel()-1; } -OUString DocumentOutlineNodesManager::getOutlineText( - const tSortedOutlineNodeList::size_type nIdx, - SwRootFrame const*const pLayout, - const bool bWithNumber, - const bool bWithSpacesForLevel, - const bool bWithFootnote ) const +OUString GetExpandTextMerged(SwRootFrame const*const pLayout, + SwTextNode const& rNode, bool const bWithNumber, + bool const bWithSpacesForLevel, ExpandMode const i_mode) { - SwTextNode const*const pNode(m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode()); if (pLayout && pLayout->IsHideRedlines()) { - SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(pNode->getLayoutFrame(pLayout))); + SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(rNode.getLayoutFrame(pLayout))); if (pFrame) { sw::MergedPara const*const pMerged = pFrame->GetMergedPara(); if (pMerged) { - if (pNode != pMerged->pParaPropsNode) + if (&rNode != pMerged->pParaPropsNode) { return OUString(); } else { - ExpandMode const mode(ExpandMode::HideDeletions | - (bWithFootnote ? ExpandMode::ExpandFootnote : ExpandMode(0))); - OUStringBuffer ret(pNode->GetExpandText(0, -1, bWithNumber, + ExpandMode const mode(ExpandMode::HideDeletions | i_mode); + OUStringBuffer ret(rNode.GetExpandText(0, -1, bWithNumber, bWithNumber, bWithSpacesForLevel, mode)); - for (sal_uLong i = pNode->GetIndex() + 1; + for (sal_uLong i = rNode.GetIndex() + 1; i <= pMerged->pLastNode->GetIndex(); ++i) { - SwNode *const pTmp(pNode->GetNodes()[i]); + SwNode *const pTmp(rNode.GetNodes()[i]); if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst) { ret.append(pTmp->GetTextNode()->GetExpandText( @@ -82,9 +77,21 @@ OUString DocumentOutlineNodesManager::getOutlineText( } } } - return pNode->GetExpandText( 0, -1, bWithNumber, - bWithNumber, bWithSpacesForLevel, - bWithFootnote ? ExpandMode::ExpandFootnote : ExpandMode(0)); + return rNode.GetExpandText( 0, -1, bWithNumber, + bWithNumber, bWithSpacesForLevel, i_mode); +} + +OUString DocumentOutlineNodesManager::getOutlineText( + const tSortedOutlineNodeList::size_type nIdx, + SwRootFrame const*const pLayout, + const bool bWithNumber, + const bool bWithSpacesForLevel, + const bool bWithFootnote ) const +{ + SwTextNode const*const pNode(m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->GetTextNode()); + return GetExpandTextMerged(pLayout, *pNode, + bWithNumber, bWithSpacesForLevel, + (bWithFootnote ? ExpandMode::ExpandFootnote : ExpandMode(0))); } SwTextNode* DocumentOutlineNodesManager::getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const diff --git a/sw/source/core/inc/DocumentListItemsManager.hxx b/sw/source/core/inc/DocumentListItemsManager.hxx index 36e56e015d7a..7508a2b5df41 100644 --- a/sw/source/core/inc/DocumentListItemsManager.hxx +++ b/sw/source/core/inc/DocumentListItemsManager.hxx @@ -36,7 +36,11 @@ public: void addListItem( const SwNodeNum& rNodeNum ) override; void removeListItem( const SwNodeNum& rNodeNum ) override; - OUString getListItemText( const SwNodeNum& rNodeNum ) const override; + OUString getListItemText(const SwNodeNum& rNodeNum, + SwRootFrame const& rLayout) const override; + + bool isNumberedInLayout(SwNodeNum const& rNodeNum, + SwRootFrame const& rLayout) const override; void getNumItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const override; diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index 6870d721e5a0..9ecc04e38218 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -44,6 +44,7 @@ struct SwCursorMoveState; struct SwFillData; class SwPortionHandler; class SwScriptInfo; +enum class ExpandMode; #define NON_PRINTING_CHARACTER_COLOR Color(0x26, 0x8b, 0xd2) @@ -124,6 +125,10 @@ void AddRemoveFlysAnchoredToFrameStartingAtNode( SwTextFrame & rFrame, SwTextNode & rTextNode, std::set<sal_uLong> *pSkipped); +OUString GetExpandTextMerged(SwRootFrame const* pLayout, + SwTextNode const& rNode, bool bWithNumber, + bool bWithSpacesForLevel, ExpandMode i_mode); + } // namespace sw /// Represents the visualization of a paragraph. Typical upper is an diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index cd3919294a41..dfdb141f2d47 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -626,11 +626,15 @@ void SwFieldRefPage::UpdateSubType(const OUString& filterString) bool bCertainTextNodeSelected( false ); for ( size_t nNumItemIdx = 0; nNumItemIdx < maNumItems.size(); ++nNumItemIdx ) { - bool isSubstring = MatchSubstring(pIDoc->getListItemText( *maNumItems[nNumItemIdx] ), filterString); + if (!pIDoc->isNumberedInLayout(*maNumItems[nNumItemIdx], *pSh->GetLayout())) + { + continue; // skip it + } + bool isSubstring = MatchSubstring(pIDoc->getListItemText(*maNumItems[nNumItemIdx], *pSh->GetLayout()), filterString); if(isSubstring) { SvTreeListEntry* pEntry = m_pSelectionToolTipLB->InsertEntry( - pIDoc->getListItemText( *maNumItems[nNumItemIdx] ) ); + pIDoc->getListItemText(*maNumItems[nNumItemIdx], *pSh->GetLayout())); pEntry->SetUserData( reinterpret_cast<void*>(nNumItemIdx) ); if ( ( IsFieldEdit() && pRefField->GetReferencedTextNode() == maNumItems[nNumItemIdx]->GetTextNode() ) || commit 2dfef08c8bc4f2d0bc240966897cea1639b9a052 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Nov 5 15:50:43 2018 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Nov 5 15:59:14 2018 +0100 sw_redlinehide_3: fix footnotes not being removed when deleted If there already is a merged SwTextFrame and a footnote is being deleted in a non-first node hence UpdateFramesForAddDeleteRedline() is called, the SwFootnoteFrame isn't removed unless by some accident. Just let CheckParaRedlineMerge iterate all top-level nodes. Change-Id: I65ac90636a283d5178b4c0323bcc0ae28b3f1196 diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 598c0bc321da..ecdd22eff44b 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -216,29 +216,36 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode, if (eMode == FrameMode::Existing) { // remove existing footnote frames for first node; - // for non-first notes, DelFrames will remove all + // for non-first nodes with own frames, DelFrames will remove all // (could possibly call lcl_ChangeFootnoteRef, not sure if worth it) // note: must be done *before* changing listeners! - sal_Int32 nLast(0); - std::vector<std::pair<sal_Int32, sal_Int32>> hidden; - for (auto const& rExtent : extents) + // for non-first nodes that are already merged with this frame, + // need to remove here too, otherwise footnotes can be removed only + // by lucky accident, e.g. TruncLines(). + auto itExtent(extents.begin()); + for (auto const pTextNode : nodes) { - if (rExtent.pNode != &rTextNode) + sal_Int32 nLast(0); + std::vector<std::pair<sal_Int32, sal_Int32>> hidden; + for ( ; itExtent != extents.end(); ++itExtent) { - break; + if (itExtent->pNode != pTextNode) + { + break; + } + if (itExtent->nStart != 0) + { + assert(itExtent->nStart != nLast); + hidden.emplace_back(nLast, itExtent->nStart); + } + nLast = itExtent->nEnd; } - if (rExtent.nStart != 0) + if (nLast != pTextNode->Len()) { - assert(rExtent.nStart != nLast); - hidden.emplace_back(nLast, rExtent.nStart); + hidden.emplace_back(nLast, pTextNode->Len()); } - nLast = rExtent.nEnd; - } - if (nLast != rTextNode.Len()) - { - hidden.emplace_back(nLast, rTextNode.Len()); + sw::RemoveFootnotesForNode(rFrame, *pTextNode, &hidden); } - sw::RemoveFootnotesForNode(rFrame, rTextNode, &hidden); // unfortunately DelFrames() must be done before StartListening too, // otherwise footnotes cannot be deleted by SwTextFootnote::DelFrames! for (auto iter = ++nodes.begin(); iter != nodes.end(); ++iter) commit 6e137a16b870f4a8ee7ddeaa51859036c7e1a63c Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Nov 5 13:41:29 2018 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Nov 5 13:41:29 2018 +0100 sw: fix crash in SwContentTree::HasContentChanged() Remove() will remove the node including its children, but SvTreeList::Next() will actually return the first child, so the pChild points to an entry that has been deleted. Change-Id: Ia4bd75d64c8436ea03c0727a8d49ee0c34fda16f diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index b465975a385a..ba2255d07d63 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -2213,14 +2213,11 @@ bool SwContentTree::HasContentChanged() } if(bRemoveChildren) { - SvTreeListEntry* pChild = FirstChild(pEntry); - SvTreeListEntry* pRemove = pChild; for(size_t j = 0; j < nChildCount; ++j) { - pChild = Next(pRemove); + SvTreeListEntry *const pRemove = FirstChild(pEntry); assert(pRemove); GetModel()->Remove(pRemove); - pRemove = pChild; } } if(!nChildCount) commit dd3622905ee3fdbeb81686abbeeb0fd50bc7f1e3 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Nov 5 11:51:00 2018 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Nov 5 11:51:00 2018 +0100 sw_redlinehide_3: move assert in SwContentNode::DelFrames() This is happening in MoveParagraph; the UpdateMergedParaForDelete will reset the pParaPropsNode pointer so move assert below that. Change-Id: I31069578a9bfdb05f01ea778bbe9e9ae43c865c6 diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index fa30b94a25a8..6971e30774c9 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1364,8 +1364,6 @@ void SwContentNode::DelFrames(SwRootFrame const*const pLayout) { if (this != pMerged->pFirstNode) { - // pointer should have been updated to a different node - assert(this != pMerged->pParaPropsNode); // SwNodes::RemoveNode iterates *backwards* - so // ensure there are no more extents pointing to this // node as SwFrame::InvalidatePage() will access them. @@ -1373,6 +1371,8 @@ void SwContentNode::DelFrames(SwRootFrame const*const pLayout) // because that would access deleted wrong-lists sw::UpdateMergedParaForDelete(*pMerged, true, *static_cast<SwTextNode*>(this), 0, Len()); + // pointer should have been updated to a different node + assert(this != pMerged->pParaPropsNode); if (this == pMerged->pLastNode) { pMerged->pLastNode = GetNodes()[GetIndex()-1]->GetTextNode(); commit 9fe02e664cb09fef7d1c5f2fac8f494f5a781a4d Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Fri Nov 2 19:26:19 2018 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Nov 5 11:07:22 2018 +0100 sw_redlinehide_3: update frames in MoveParagraph() ... if redlining is disabled and MoveNodeRange is called. Change-Id: I8c4e35b1b783446ab9bd888599bcce44222857e8 diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 8dcec0a9fd15..4854afde55c1 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -826,6 +826,10 @@ namespace { rSvRedLine.SetPos( nInsPos ); pDoc->getIDocumentRedlineAccess().AppendRedline( rSvRedLine.pRedl, true ); + if (rSvRedLine.pRedl->GetType() == nsRedlineType_t::REDLINE_DELETE) + { + UpdateFramesForAddDeleteRedline(*pDoc, *rSvRedLine.pRedl); + } } pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits