sw/source/core/doc/DocumentContentOperationsManager.cxx | 73 +++++++++++++++- sw/source/core/inc/DocumentContentOperationsManager.hxx | 5 - 2 files changed, 74 insertions(+), 4 deletions(-)
New commits: commit 4dc1615c80e8e66d339dc86fa95bbc76e884d988 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Sep 25 18:39:38 2019 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 23 12:57:43 2019 +0200 sw: DocumentContentOperationsManager::CopyImpl() Change-Id: I1a6ce9f439be9b8f863f3981fb9fd7ef1123e6c7 diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 816468cb1368..baff9f898f4d 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -480,7 +480,7 @@ namespace namespace { void - lcl_CalcBreaks(std::vector<std::pair<sal_uLong, sal_Int32>> & rBreaks, SwPaM const & rPam) + lcl_CalcBreaks(std::vector<std::pair<sal_uLong, sal_Int32>> & rBreaks, SwPaM const & rPam, bool const isOnlyFieldmarks = false) { sal_uLong const nStartNode(rPam.Start()->nNode.GetIndex()); sal_uLong const nEndNode(rPam.End()->nNode.GetIndex()); @@ -513,7 +513,7 @@ namespace { // META hints only have dummy char at the start, not // at the end, so no need to check in nStartNode - if (n == nEndNode) + if (n == nEndNode && !isOnlyFieldmarks) { SwTextAttr const*const pAttr(rTextNode.GetTextAttrForCharAt(i)); if (pAttr && pAttr->End() && (nEnd < *pAttr->End())) @@ -4420,7 +4420,74 @@ static void lcl_PopNumruleState( } } -bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, +bool DocumentContentOperationsManager::CopyImpl(SwPaM& rPam, SwPosition& rPos, + const bool bCopyAll, + SwPaM *const pCopyRange) const +{ + std::vector<std::pair<sal_uLong, sal_Int32>> Breaks; + + lcl_CalcBreaks(Breaks, rPam, true); + + if (Breaks.empty()) + { + return CopyImplImpl(rPam, rPos, bMakeNewFrames, bCopyAll, pCopyRange); + } + + SwPosition const & rSelectionEnd( *rPam.End() ); + + bool bRet(true); + bool bFirst(true); + // iterate from end to start, ... don't think it's necessary here? + auto iter( Breaks.rbegin() ); + sal_uLong nOffset(0); + SwNodes const& rNodes(rPam.GetPoint()->nNode.GetNodes()); + SwPaM aPam( rSelectionEnd, rSelectionEnd ); // end node! + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + SwPaM copyRange(rPos, rPos); + + while (iter != Breaks.rend()) + { + rStart = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); + if (rStart < rEnd) // check if part is empty + { + // pass in copyRange member as rPos; should work ... + bRet &= CopyImplImpl(aPam, *copyRange.Start(), bMakeNewFrames, bCopyAll, ©Range); + nOffset = iter->first - rStart.nNode.GetIndex(); // fly nodes... + if (pCopyRange) + { + if (bFirst) + { + pCopyRange->SetMark(); + *pCopyRange->GetMark() = *copyRange.End(); + } + *pCopyRange->GetPoint() = *copyRange.Start(); + } + bFirst = false; + } + rEnd = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); + ++iter; + } + + rStart = *rPam.Start(); // set to original start + if (rStart < rEnd) // check if part is empty + { + bRet &= CopyImplImpl(aPam, *copyRange.Start(), bMakeNewFrames, bCopyAll, ©Range); + if (pCopyRange) + { + if (bFirst) + { + pCopyRange->SetMark(); + *pCopyRange->GetMark() = *copyRange.End(); + } + *pCopyRange->GetPoint() = *copyRange.Start(); + } + } + + return bRet; +} + +bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPos, const bool bCopyAll, SwPaM *const pCpyRange ) const { diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx index 020f41911eb0..3de0b68282bc 100644 --- a/sw/source/core/inc/DocumentContentOperationsManager.hxx +++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx @@ -168,7 +168,10 @@ private: SwFrameFormat* ); /* Copy a range within the same or to another document. Position may not lie within range! */ - bool CopyImpl( SwPaM&, SwPosition&, bool bCopyAll, SwPaM *const pCpyRng /*= 0*/ ) const; + bool CopyImpl( SwPaM&, SwPosition&, + const bool bCopyAll, SwPaM *const pCpyRng /*= 0*/ ) const; + bool CopyImplImpl(SwPaM&, SwPosition&, + const bool bCopyAll, SwPaM *const pCpyRng /*= 0*/) const; DocumentContentOperationsManager(DocumentContentOperationsManager const&) = delete; DocumentContentOperationsManager& operator=(DocumentContentOperationsManager const&) = delete; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits