sw/inc/ndgrf.hxx | 1 sw/inc/ndole.hxx | 2 sw/inc/ndtxt.hxx | 4 + sw/inc/node.hxx | 2 sw/source/core/doc/DocumentContentOperationsManager.cxx | 30 +++++++----- sw/source/core/docnode/ndtbl.cxx | 14 ++++- sw/source/core/docnode/nodes.cxx | 4 - sw/source/core/draw/dcontact.cxx | 8 ++- sw/source/core/graphic/ndgrf.cxx | 5 -- sw/source/core/inc/frmtool.hxx | 2 sw/source/core/layout/atrfrm.cxx | 20 +++++++- sw/source/core/layout/frmtool.cxx | 40 ++++++++++++++++ sw/source/core/ole/ndole.cxx | 7 -- sw/source/core/txtnode/ndtxt.cxx | 13 ++++- sw/source/core/undo/untbl.cxx | 15 ++++-- sw/source/filter/xml/wrtxml.cxx | 13 ++++- 16 files changed, 136 insertions(+), 44 deletions(-)
New commits: commit 4a1f2476610ba7b04048bb27436d4a2655a37dcb Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Aug 8 16:13:58 2018 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Aug 8 16:13:58 2018 +0200 sw_redlinehide_2: fix ordering of SplitNode usage of ContentIdxStore The problem is that now the ctor of SwTextFrame will check the redline positions, but the call to MakeFramesForAdjacentContentNode() happens before the call to ContentIdxStore::Restore() that updates the SwPositions of the redlines, hence they point to the wrong node. Try to fix this by not calling Restore directly but pass in a closure to SwTextNode::SplitContentNode() so that it can call ContentIdxStore::Restore() before frames are created and redline positions are checked. Also remove the useless SwContentNode::SplitContentNode() - only the SwTextNode override actually did anything. Change-Id: I2088fd124d04cf354f4f0f691a50ff5217d778d7 diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx index a5e4e0cc2969..74c46f20b238 100644 --- a/sw/inc/ndgrf.hxx +++ b/sw/inc/ndgrf.hxx @@ -80,7 +80,6 @@ public: const Graphic& GetGrf(bool bWait = false) const; const GraphicObject& GetGrfObj(bool bWait = false) const; const GraphicObject* GetReplacementGrfObj() const; - virtual SwContentNode *SplitContentNode( const SwPosition & ) override; /// isolated only way to set GraphicObject to allow more actions when doing so void SetGraphic(const Graphic& rGraphic); diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx index 4f6f4596736d..93139c986526 100644 --- a/sw/inc/ndole.hxx +++ b/sw/inc/ndole.hxx @@ -111,8 +111,6 @@ public: SwOLEObj& GetOLEObj() { return maOLEObj; } virtual ~SwOLENode() override; - virtual SwContentNode *SplitContentNode( const SwPosition & ) override; - /// Is in ndcopy.cxx. virtual SwContentNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const override; diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index d1a8801eb9c7..a32ea79c310a 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -34,6 +34,7 @@ #include <memory> #include <vector> #include <set> +#include <functional> class SfxHint; class SwNumRule; @@ -347,7 +348,8 @@ public: /// Virtual methods from ContentNode. virtual SwContentFrame *MakeFrame( SwFrame* ) override; - virtual SwContentNode *SplitContentNode( const SwPosition & ) override; + SwTextNode * SplitContentNode(const SwPosition &, + std::function<void (SwTextNode *)> const* pContentIndexRestore); virtual SwContentNode *JoinNext() override; void JoinPrev(); diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 0c5ee9a9f309..2257446b2f9e 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -387,8 +387,6 @@ public: pSib is another SwFrame of the same layout (e.g. the SwRootFrame itself, a sibling, the parent) */ virtual SwContentFrame *MakeFrame( SwFrame* pSib ) = 0; - virtual SwContentNode *SplitContentNode(const SwPosition & ) = 0; - virtual SwContentNode *JoinNext(); /** Is it possible to join two nodes? In pIdx the second position can be returned. */ diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 256fce7bbe4d..acca6b19c0e2 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1991,7 +1991,15 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos, assert(aSavePam.GetPoint()->nNode == rPos.nNode.GetIndex()); assert(rPos.nNode.GetIndex() == pOrigNode->GetIndex()); - pTNd = pTNd->SplitContentNode( rPos )->GetTextNode(); + std::function<void (SwTextNode *)> restoreFunc( + [&](SwTextNode *const) + { + if (!pContentStore->Empty()) + { + pContentStore->Restore(&m_rDoc, pOrigNode->GetIndex()-1, 0, true); + } + }); + pTNd = pTNd->SplitContentNode(rPos, &restoreFunc)->GetTextNode(); //A new node was inserted before the orig pTNd and the content up to //rPos moved into it. The old node is returned with the remainder @@ -2011,9 +2019,6 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos, aSavePam.GetPoint()->nContent.Assign(pOrigNode, 0); rPos = *aSavePam.GetMark() = *aSavePam.GetPoint(); - if( !pContentStore->Empty() ) - pContentStore->Restore( &m_rDoc, rPos.nNode.GetIndex()-1, 0, true ); - // correct the PaM! if( rPos.nNode == rPaM.GetMark()->nNode ) { @@ -2931,15 +2936,18 @@ bool DocumentContentOperationsManager::SplitNode( const SwPosition &rPos, bool b const std::shared_ptr<sw::mark::ContentIdxStore> pContentStore(sw::mark::ContentIdxStore::Create()); pContentStore->Save( &m_rDoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), true ); - // FIXME: only SwTextNode has a valid implementation of SplitContentNode! - OSL_ENSURE(pNode->IsTextNode(), "splitting non-text node?"); - pNode = pNode->SplitContentNode( rPos ); + assert(pNode->IsTextNode()); + std::function<void (SwTextNode *)> restoreFunc( + [&](SwTextNode *const) + { + if (!pContentStore->Empty()) + { // move all bookmarks, TOXMarks, FlyAtCnt + pContentStore->Restore(&m_rDoc, rPos.nNode.GetIndex()-1, 0, true); + } + }); + pNode = pNode->GetTextNode()->SplitContentNode(rPos, &restoreFunc); if (pNode) { - // move all bookmarks, TOXMarks, FlyAtCnt - if( !pContentStore->Empty() ) - pContentStore->Restore( &m_rDoc, rPos.nNode.GetIndex()-1, 0, true ); - // To-Do - add 'SwExtraRedlineTable' also ? if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() || (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() )) { diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index d5b62a198d0a..ed96fae59ee3 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1072,10 +1072,16 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh, if (pTextNd->GetText()[nChPos] == cCh) { aCntPos.nContent = nChPos; - SwContentNode* pNewNd = pTextNd->SplitContentNode( aCntPos ); - - if( !pContentStore->Empty() ) - pContentStore->Restore( *pNewNd, nChPos, nChPos + 1 ); + std::function<void (SwTextNode *)> restoreFunc( + [&](SwTextNode *const pNewNode) + { + if (!pContentStore->Empty()) + { + pContentStore->Restore(*pNewNode, nChPos, nChPos + 1); + } + }); + SwContentNode *const pNewNd = + pTextNd->SplitContentNode(aCntPos, &restoreFunc); // Delete separator and correct search string pTextNd->EraseText( aCntPos.nContent, 1 ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 0747395460d8..b43e9e67d583 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -1512,7 +1512,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) } else { - pDestNd->SplitContentNode( rPos ); + pDestNd->SplitContentNode(rPos, nullptr); } if( rPos.nNode == aEndIdx ) @@ -1577,7 +1577,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) } else { - pDestNd->SplitContentNode( rPos ); + pDestNd->SplitContentNode(rPos, nullptr); } if ( bCorrEnd ) diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 63a0c43d946c..d0f5173645c0 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -401,11 +401,6 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const return mpReplacementGraphic.get(); } -SwContentNode *SwGrfNode::SplitContentNode( const SwPosition & ) -{ - return this; -} - SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere, const OUString& rGrfName, const OUString& rFltName, diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index e4b6115fd0ec..8d59c502817c 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -242,13 +242,6 @@ const Graphic* SwOLENode::GetGraphic() return nullptr; } -SwContentNode *SwOLENode::SplitContentNode( const SwPosition & ) -{ - // Multiply OLE objects? - OSL_FAIL( "OleNode: can't split." ); - return this; -} - /** * Loading a OLE object that has been moved to the Undo Area */ diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 880ce8ea14a3..a1e14f7a732f 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -364,7 +364,8 @@ static void lcl_ChangeFootnoteRef( SwTextNode &rNode ) } } -SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos ) +SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, + std::function<void (SwTextNode *)> const*const pContentIndexRestore) { bool parentIsOutline = IsOutline(); @@ -475,6 +476,11 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos ) } + if (pContentIndexRestore) + { // call before making frames and before RegisterToNode + (*pContentIndexRestore)(pNode); + } + SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*this); for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next()) { @@ -574,6 +580,11 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos ) SetSmartTags( pList2, false ); } + if (pContentIndexRestore) + { // call before making frames + (*pContentIndexRestore)(pNode); + } + if ( HasWriterListeners() ) { MakeFramesForAdjacentContentNode(*pNode); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index f84dca847425..e2912ddb2587 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -556,10 +556,17 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd, SwIndex aCntPos( pTextNd, pSave->m_nContent - 1 ); pTextNd->EraseText( aCntPos, 1 ); - SwContentNode* pNewNd = pTextNd->SplitContentNode( - SwPosition( aSttIdx, aCntPos )); - if( !pContentStore->Empty() ) - pContentStore->Restore( *pNewNd, pSave->m_nContent, pSave->m_nContent + 1 ); + + std::function<void (SwTextNode *)> restoreFunc( + [&](SwTextNode *const pNewNode) + { + if (!pContentStore->Empty()) + { + pContentStore->Restore(*pNewNode, pSave->m_nContent, pSave->m_nContent + 1); + } + }); + pTextNd->SplitContentNode( + SwPosition(aSttIdx, aCntPos), &restoreFunc); } else { commit c181dc24dedd8b2b2b43aa53c167261940bbeaf1 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Aug 8 16:09:38 2018 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Aug 8 16:09:38 2018 +0200 sw_redlinehide_2: store flag in settings.xml too Change-Id: Ifa02f261a7c0b4f08ccf5ca744ab544741d7e225 diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 8006286146cf..8e6c9ccc68fb 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -45,6 +45,7 @@ #include <IDocumentRedlineAccess.hxx> #include <IDocumentStatistics.hxx> #include <IDocumentLayoutAccess.hxx> +#include <rootfrm.hxx> #include <docstat.hxx> #include <docsh.hxx> @@ -181,8 +182,16 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS // save show redline mode ... const OUString sShowChanges("ShowChanges"); RedlineFlags nRedlineFlags = m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags(); - xInfoSet->setPropertyValue( sShowChanges, - makeAny( IDocumentRedlineAccess::IsShowChanges( nRedlineFlags ) ) ); + bool isShowChanges; + if (getenv("SW_REDLINEHIDE")) + { // TODO: ideally this would be stored per-view... + isShowChanges = !m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines(); + } + else + { + isShowChanges = IDocumentRedlineAccess::IsShowChanges(nRedlineFlags); + } + xInfoSet->setPropertyValue(sShowChanges, makeAny(isShowChanges)); // ... and hide redlines for export nRedlineFlags &= ~RedlineFlags::ShowMask; nRedlineFlags |= RedlineFlags::ShowInsert; commit 986ad106908472d60f5c3ddc083a7a8561b4bf86 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Aug 8 13:29:44 2018 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Aug 8 13:29:44 2018 +0200 sw_redlinehide_2: adapt SwFlyFrameFormat::MakeFrames() ... ... and SwDrawFrameFormat::MakeFrames() to do nothing if anchored in hidden redline. Change-Id: Idb0668db81b20ee52cd9c0237c22f8fa72beb7b3 diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 96c0787ae835..100fa538d120 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1837,11 +1837,17 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) // (1) proposed anchor frame isn't a follow and // (2) drawing object isn't a control object to be anchored // in header/footer. - const bool bAdd = ( !pFrame->IsContentFrame() || + bool bAdd = ( !pFrame->IsContentFrame() || !static_cast<SwContentFrame*>(pFrame)->IsFollow() ) && ( !::CheckControlLayer( GetMaster() ) || !pFrame->FindFooterOrHeader() ); + if (bAdd && RndStdIds::FLY_AT_FLY != pAnch->GetAnchorId()) + { + assert(pFrame->IsTextFrame()); + bAdd = IsAnchoredObjShown(*static_cast<SwTextFrame*>(pFrame), *pAnch); + } + if( bAdd ) { if ( RndStdIds::FLY_AT_FLY == pAnch->GetAnchorId() && !pFrame->IsFlyFrame() ) diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 05b2dc237253..fdc014d8a101 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -66,6 +66,8 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode, std::vector<sw::Extent>::const_iterator * pIter, std::vector<sw::Extent>::const_iterator const* pEnd); +bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor); + void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib); // draw background with brush or graphics diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 98e6538d3c61..3e5abda010f0 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -56,6 +56,7 @@ #include <rootfrm.hxx> #include <cntfrm.hxx> #include <notxtfrm.hxx> +#include <txtfrm.hxx> #include <crsrsh.hxx> #include <dflyobj.hxx> #include <dcontact.hxx> @@ -3027,7 +3028,24 @@ void SwFlyFrameFormat::MakeFrames() } } - if( pFrame->GetDrawObjs() ) + if (bAdd) + { + switch (aAnchorAttr.GetAnchorId()) + { + case RndStdIds::FLY_AS_CHAR: + case RndStdIds::FLY_AT_PARA: + case RndStdIds::FLY_AT_CHAR: + { + assert(pFrame->IsTextFrame()); + bAdd = IsAnchoredObjShown(*static_cast<SwTextFrame*>(pFrame), aAnchorAttr); + } + break; + default: + break; + } + } + + if (bAdd && pFrame->GetDrawObjs()) { // #i28701# - new type <SwSortedObjs> SwSortedObjs &rObjs = *pFrame->GetDrawObjs(); diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 11cb79523ba7..b7fec8eac2aa 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1192,6 +1192,46 @@ void AppendObjs(const SwFrameFormats *const pTable, sal_uLong const nIndex, } } +bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor) +{ + assert(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA || + rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR || + rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR); + bool ret(true); + if (auto const pMergedPara = rFrame.GetMergedPara()) + { + ret = false; + auto const pAnchor(rAnchor.GetContentAnchor()); + auto iterFirst(pMergedPara->extents.cbegin()); + auto iter(iterFirst); + SwTextNode const* pNode(pMergedPara->pFirstNode); + for ( ; ; ++iter) + { + if (iter == pMergedPara->extents.end() + || iter->pNode != pNode) + { + assert(pNode->GetRedlineMergeFlag() != SwNode::Merge::Hidden); + if (pNode == &pAnchor->nNode.GetNode()) + { + ret = IsShown(pNode->GetIndex(), rAnchor, &iterFirst, &iter); + break; + } + if (iter == pMergedPara->extents.end()) + { + break; + } + pNode = iter->pNode; + if (pAnchor->nNode.GetIndex() < pNode->GetIndex()) + { + break; + } + iterFirst = iter; + } + } + } + return ret; +} + void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib) { //Connecting of all Objects, which are described in the SpzTable with the _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits