[Libreoffice-commits] core.git: sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 4 11:21:08 UTC 2019


 sw/source/core/crsr/bookmrk.cxx                         |   16 +++------------
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   17 ++++++++++++++++
 sw/source/core/inc/DocumentContentOperationsManager.hxx |    2 +
 3 files changed, 23 insertions(+), 12 deletions(-)

New commits:
commit 453847e817bc43cff52fcab9de104a12571a330f
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Sep 25 16:43:48 2019 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Oct 4 13:20:30 2019 +0200

    sw: add DocumentContentOperationsManager::DeleteDummyChar()
    
    ... and lcl_RemoveFieldMarks() uses it; this avoids the problem that
    lcl_CalcBreaks() would of course remove the dummy character from the
    deletion range.
    
    Change-Id: Iba0f7901b9efe4af273e17c58c6b40d4fd783efd
    Reviewed-on: https://gerrit.libreoffice.org/80069
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index c6b6af26d12b..ae735607f631 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -122,27 +122,19 @@ namespace
         assert(pStartTextNode);
         if (aEndMark != CH_TXT_ATR_FORMELEMENT)
         {
-            (void) aStartMark;
             (void) pStartTextNode;
-            assert(pStartTextNode->GetText()[rStart.nContent.GetIndex()] == aStartMark);
-            SwPaM aStart(rStart, rStart);
-            ++aStart.End()->nContent;
-            io_pDoc->getIDocumentContentOperations().DeleteRange(aStart);
+            io_pDoc->GetDocumentContentOperationsManager().DeleteDummyChar(rStart, aStartMark);
         }
 
         const SwPosition& rEnd = pField->GetMarkEnd();
-        SwTextNode const*const pEndTextNode = rEnd.nNode.GetNode().GetTextNode();
+        SwTextNode *const pEndTextNode = rEnd.nNode.GetNode().GetTextNode();
         assert(pEndTextNode);
         const sal_Int32 nEndPos = (rEnd == rStart)
                                    ? rEnd.nContent.GetIndex()
                                    : rEnd.nContent.GetIndex() - 1;
         assert(pEndTextNode->GetText()[nEndPos] == aEndMark);
-        (void) pEndTextNode;
-        (void) nEndPos;
-        SwPaM aEnd(rEnd, rEnd);
-        if (aEnd.Start()->nContent > 0)
-            --aEnd.Start()->nContent;
-        io_pDoc->getIDocumentContentOperations().DeleteRange(aEnd);
+        SwPosition const aEnd(*pEndTextNode, nEndPos);
+        io_pDoc->GetDocumentContentOperationsManager().DeleteDummyChar(aEnd, aEndMark);
 
         io_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::UI_REPLACE, nullptr);
     };
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 05a497016ce7..513656a65251 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1817,6 +1817,23 @@ void DocumentContentOperationsManager::DeleteSection( SwNode *pNode )
     m_rDoc.GetNodes().DelNodes( aSttIdx, aEndIdx.GetIndex() - aSttIdx.GetIndex() + 1 );
 }
 
+void DocumentContentOperationsManager::DeleteDummyChar(
+        SwPosition const& rPos, sal_Unicode const cDummy)
+{
+    SwPaM aPam(rPos, rPos);
+    ++aPam.GetPoint()->nContent;
+    assert(aPam.GetText().getLength() == 1 && aPam.GetText()[0] == cDummy);
+    (void) cDummy;
+
+    DeleteRangeImpl(aPam);
+
+    if (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline()
+        && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty())
+    {
+        m_rDoc.getIDocumentRedlineAccess().CompressRedlines();
+    }
+}
+
 void DocumentContentOperationsManager::DeleteRange( SwPaM & rPam )
 {
     lcl_DoWithBreaks( *this, rPam, &DocumentContentOperationsManager::DeleteRangeImpl );
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx
index d6f8f8eb2a09..d96df4b9e8fe 100644
--- a/sw/source/core/inc/DocumentContentOperationsManager.hxx
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -101,6 +101,8 @@ public:
 
     //Non-Interface methods
 
+    void DeleteDummyChar(SwPosition const& rPos, sal_Unicode cDummy);
+
     void CopyWithFlyInFly( const SwNodeRange& rRg,
                             const SwNodeIndex& rInsPos,
                             const std::pair<const SwPaM&, const SwPosition&> * pCopiedPaM = nullptr,


More information about the Libreoffice-commits mailing list