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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Dec 8 06:04:26 PST 2014


 sw/qa/extras/uiwriter/data/merge-change1.odt |binary
 sw/qa/extras/uiwriter/data/merge-change2.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx           |   31 +++++++++++
 sw/source/core/crsr/viscrs.cxx               |   21 ++++----
 sw/source/core/doc/doccomp.cxx               |   70 ++++++++++-----------------
 5 files changed, 71 insertions(+), 51 deletions(-)

New commits:
commit 8e00e0056e3c3dfdb35206ba5061a647d821edce
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 8 15:01:01 2014 +0100

    coverity#1257107: handle these consistently
    
    Change-Id: I5f432eea235bdca05132cf553d9bc15e2b825509

diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 80af294..13bbd29 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -538,8 +538,12 @@ void SwShellCrsr::FillRects()
 
 void SwShellCrsr::Show()
 {
-    for(SwPaM& rTmp : GetRingContainer())
-        dynamic_cast<SwShellCrsr&>(rTmp).SwSelPaintRects::Show();
+    for(SwPaM& rPaM : GetRingContainer())
+    {
+        SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
+        if(pShCrsr)
+            pShCrsr->SwSelPaintRects::Show();
+    }
 }
 
 // This rectangle gets painted anew, therefore the SSelection in this
@@ -558,13 +562,12 @@ void SwShellCrsr::Invalidate( const SwRect& rRect )
 
 void SwShellCrsr::Hide()
 {
-    SwShellCrsr * pTmp = this;
-    // TODO: this doesnt look sane: if the dynamic_cast ever returns a nullptr,
-    // the next pTmp->GetNext() call is a nullptr deref
-    do {
-        if (pTmp)
-            pTmp->SwSelPaintRects::Hide();
-    } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) );
+    for(SwPaM& rPaM : GetRingContainer())
+    {
+        SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
+        if(pShCrsr)
+            pShCrsr->SwSelPaintRects::Hide();
+    }
 }
 
 SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const
commit df87cec5ad59605d057ade2a0203e590d2aadc8d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 8 15:00:51 2014 +0100

    deque is never used
    
    Change-Id: I223c85999a0ed1a62aece67f0d730b8e2e097ac9

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 156eb08..1fab4e4 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -45,7 +45,6 @@
 #include <vector>
 
 #include <list>
-#include <deque>
 #include <cctype>
 
 #include <boost/scoped_array.hpp>
commit 23c802b85aad6b44da7d7cb630e2e76e6da033a8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 6 03:19:05 2014 +0100

    make InsertRedline() non-static again
    
    Change-Id: I2eda267b56bc1548930add9c5ef83ad268f881a4

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index f9af771..156eb08 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1835,7 +1835,7 @@ namespace
         const SwRangeRedline* pSrcRedl;
         SwRangeRedline* pDestRedl;
         SaveMergeRedline( const SwNode& rDstNd, const SwRangeRedline& rSrcRedl);
-        static sal_uInt16 InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline);
+        sal_uInt16 InsertRedline(SwPaM* pLastDestRedline);
     };
 }
 
@@ -1865,7 +1865,7 @@ SaveMergeRedline::SaveMergeRedline( const SwNode& rDstNd,
     }
 }
 
-sal_uInt16 SaveMergeRedline::InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline)
+sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline)
 {
     sal_uInt16 nIns = 0;
     SwDoc* pDoc = pDestRedl->GetDoc();
@@ -2058,7 +2058,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
             SwPaM* pLastDestRedline(nullptr);
             for(SaveMergeRedline& rRedline: vRedlines)
             {
-                nRet += SaveMergeRedline::InsertRedline(rRedline.pSrcRedl, rRedline.pDestRedl, pLastDestRedline);
+                nRet += rRedline.InsertRedline(pLastDestRedline);
                 pLastDestRedline = rRedline.pDestRedl;
             }
         }
commit a71fb1c911b7104ede9365e7b16513896492ffa8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 6 03:14:36 2014 +0100

    rename to simple SaveMergeRedline and put in namespace
    
    Change-Id: Ibc36dcde1778ee02b9ac173d9da8419b69854af6

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index cdcbdbf..f9af771 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1828,15 +1828,18 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
     return nRet;
 }
 
-struct _SaveMergeRedlines
+namespace
 {
-    const SwRangeRedline* pSrcRedl;
-    SwRangeRedline* pDestRedl;
-    _SaveMergeRedlines( const SwNode& rDstNd, const SwRangeRedline& rSrcRedl);
-    static sal_uInt16 InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline);
-};
+    struct SaveMergeRedline
+    {
+        const SwRangeRedline* pSrcRedl;
+        SwRangeRedline* pDestRedl;
+        SaveMergeRedline( const SwNode& rDstNd, const SwRangeRedline& rSrcRedl);
+        static sal_uInt16 InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline);
+    };
+}
 
-_SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
+SaveMergeRedline::SaveMergeRedline( const SwNode& rDstNd,
                         const SwRangeRedline& rSrcRedl)
     : pSrcRedl( &rSrcRedl )
 {
@@ -1862,7 +1865,7 @@ _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
     }
 }
 
-sal_uInt16 _SaveMergeRedlines::InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline)
+sal_uInt16 SaveMergeRedline::InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline)
 {
     sal_uInt16 nIns = 0;
     SwDoc* pDoc = pDestRedl->GetDoc();
@@ -2021,7 +2024,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
         // we want to get all redlines from the SourceDoc
 
         // look for all insert redlines from the SourceDoc and determine their position in the DestDoc
-        std::list<_SaveMergeRedlines> vRedlines;
+        std::list<SaveMergeRedline> vRedlines;
         const SwRedlineTbl& rSrcRedlTbl = rSrcDoc.getIDocumentRedlineAccess().GetRedlineTbl();
         sal_uLong nEndOfExtra = rSrcDoc.GetNodes().GetEndOfExtras().GetIndex();
         sal_uLong nMyEndOfExtra = GetNodes().GetEndOfExtras().GetIndex();
@@ -2038,7 +2041,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
 
                 // Found the position.
                 // Then we also have to insert the redline to the line in the DestDoc.
-                vRedlines.push_back(_SaveMergeRedlines(*pDstNd, *pRedl));
+                vRedlines.push_back(SaveMergeRedline(*pDstNd, *pRedl));
             }
         }
 
@@ -2053,9 +2056,9 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
                                       nsRedlineMode_t::REDLINE_SHOW_DELETE));
 
             SwPaM* pLastDestRedline(nullptr);
-            for(_SaveMergeRedlines& rRedline: vRedlines)
+            for(SaveMergeRedline& rRedline: vRedlines)
             {
-                nRet += _SaveMergeRedlines::InsertRedline(rRedline.pSrcRedl, rRedline.pDestRedl, pLastDestRedline);
+                nRet += SaveMergeRedline::InsertRedline(rRedline.pSrcRedl, rRedline.pDestRedl, pLastDestRedline);
                 pLastDestRedline = rRedline.pDestRedl;
             }
         }
commit a7afdad2bf1fdae341a914c9ba556324ad72eae0
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 6 03:11:49 2014 +0100

    remove inheritance from Ring<>
    
    Change-Id: Ie1a958b3f3fb5797ec2eb49f6a5fc72da23ca553

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 0ec5442..cdcbdbf 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1828,24 +1828,17 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
     return nRet;
 }
 
-class _SaveMergeRedlines;
-class _SaveMergeRedlines : public sw::Ring<_SaveMergeRedlines>
+struct _SaveMergeRedlines
 {
-public:
     const SwRangeRedline* pSrcRedl;
     SwRangeRedline* pDestRedl;
-    _SaveMergeRedlines( const SwNode& rDstNd,
-                        const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing );
-    _SaveMergeRedlines* GetNext()
-        { return GetNextInRing(); }
-    _SaveMergeRedlines* GetPrev()
-        { return GetPrevInRing(); }
-    static sal_uInt16 InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline);
+    _SaveMergeRedlines( const SwNode& rDstNd, const SwRangeRedline& rSrcRedl);
+    static sal_uInt16 InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline);
 };
 
 _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
-                        const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing )
-    : Ring<_SaveMergeRedlines>( pRing ), pSrcRedl( &rSrcRedl )
+                        const SwRangeRedline& rSrcRedl)
+    : pSrcRedl( &rSrcRedl )
 {
     SwPosition aPos( rDstNd );
 
@@ -1869,7 +1862,7 @@ _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
     }
 }
 
-sal_uInt16 _SaveMergeRedlines::InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline)
+sal_uInt16 _SaveMergeRedlines::InsertRedline(const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline)
 {
     sal_uInt16 nIns = 0;
     SwDoc* pDoc = pDestRedl->GetDoc();
@@ -2045,7 +2038,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
 
                 // Found the position.
                 // Then we also have to insert the redline to the line in the DestDoc.
-                vRedlines.push_back(_SaveMergeRedlines(*pDstNd, *pRedl, nullptr));
+                vRedlines.push_back(_SaveMergeRedlines(*pDstNd, *pRedl));
             }
         }
 
@@ -2062,7 +2055,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
             SwPaM* pLastDestRedline(nullptr);
             for(_SaveMergeRedlines& rRedline: vRedlines)
             {
-                nRet += _SaveMergeRedlines::InsertRedline(&rRedline, rRedline.pSrcRedl, rRedline.pDestRedl, pLastDestRedline);
+                nRet += _SaveMergeRedlines::InsertRedline(rRedline.pSrcRedl, rRedline.pDestRedl, pLastDestRedline);
                 pLastDestRedline = rRedline.pDestRedl;
             }
         }
commit 9d2642d29f6d42633c3b015cae9fc8b0abe17640
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 6 03:02:24 2014 +0100

    use a std::list<> instead of a Ring<>
    
    Change-Id: Ibc1d2deae5b0c7841ec83de880380170eadbd509

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 24b386b..0ec5442 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -44,7 +44,8 @@
 
 #include <vector>
 
-#include <set>
+#include <list>
+#include <deque>
 #include <cctype>
 
 #include <boost/scoped_array.hpp>
@@ -1839,7 +1840,7 @@ public:
         { return GetNextInRing(); }
     _SaveMergeRedlines* GetPrev()
         { return GetPrevInRing(); }
-    static sal_uInt16 InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl);
+    static sal_uInt16 InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline);
 };
 
 _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
@@ -1868,7 +1869,7 @@ _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
     }
 }
 
-sal_uInt16 _SaveMergeRedlines::InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl)
+sal_uInt16 _SaveMergeRedlines::InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl, SwPaM* pLastDestRedline)
 {
     sal_uInt16 nIns = 0;
     SwDoc* pDoc = pDestRedl->GetDoc();
@@ -1896,12 +1897,8 @@ sal_uInt16 _SaveMergeRedlines::InsertRedline(_SaveMergeRedlines* pRing, const Sw
         pDestRedl->GetMark()->nContent.Assign( aSaveNd.GetNode().GetCntntNode(),
                                                 nSaveCnt );
 
-        if( !pRing->unique() )
-        {
-            SwPaM* pTmpPrev = pRing->GetPrev()->pDestRedl;
-            if( pTmpPrev && *pTmpPrev->GetPoint() == *pDestRedl->GetPoint() )
-                *pTmpPrev->GetPoint() = *pDestRedl->GetMark();
-        }
+        if( pLastDestRedline && *pLastDestRedline->GetPoint() == *pDestRedl->GetPoint() )
+            *pLastDestRedline->GetPoint() = *pDestRedl->GetMark();
     }
     else
     {
@@ -2031,7 +2028,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
         // we want to get all redlines from the SourceDoc
 
         // look for all insert redlines from the SourceDoc and determine their position in the DestDoc
-        _SaveMergeRedlines* pRing = 0;
+        std::list<_SaveMergeRedlines> vRedlines;
         const SwRedlineTbl& rSrcRedlTbl = rSrcDoc.getIDocumentRedlineAccess().GetRedlineTbl();
         sal_uLong nEndOfExtra = rSrcDoc.GetNodes().GetEndOfExtras().GetIndex();
         sal_uLong nMyEndOfExtra = GetNodes().GetEndOfExtras().GetIndex();
@@ -2048,32 +2045,26 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
 
                 // Found the position.
                 // Then we also have to insert the redline to the line in the DestDoc.
-                _SaveMergeRedlines* pTmp = new _SaveMergeRedlines(
-                                                    *pDstNd, *pRedl, pRing );
-                if( !pRing )
-                    pRing = pTmp;
+                vRedlines.push_back(_SaveMergeRedlines(*pDstNd, *pRedl, nullptr));
             }
         }
 
-        if( pRing )
+        if( !vRedlines.empty() )
         {
-          // Carry over all into DestDoc
-          rSrcDoc.getIDocumentRedlineAccess().SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE));
+            // Carry over all into DestDoc
+            rSrcDoc.getIDocumentRedlineAccess().SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE));
 
-          getIDocumentRedlineAccess().SetRedlineMode((RedlineMode_t)(
+            getIDocumentRedlineAccess().SetRedlineMode((RedlineMode_t)(
                                       nsRedlineMode_t::REDLINE_ON |
                                       nsRedlineMode_t::REDLINE_SHOW_INSERT |
                                       nsRedlineMode_t::REDLINE_SHOW_DELETE));
 
-            _SaveMergeRedlines* pTmp = pRing;
-
-            do {
-                nRet += pTmp->InsertRedline(pTmp, pTmp->pSrcRedl, pTmp->pDestRedl);
-            } while( pRing != ( pTmp = pTmp->GetNext()) );
-
-            while( pRing != pRing->GetNext() )
-                delete pRing->GetNext();
-            delete pRing;
+            SwPaM* pLastDestRedline(nullptr);
+            for(_SaveMergeRedlines& rRedline: vRedlines)
+            {
+                nRet += _SaveMergeRedlines::InsertRedline(&rRedline, rRedline.pSrcRedl, rRedline.pDestRedl, pLastDestRedline);
+                pLastDestRedline = rRedline.pDestRedl;
+            }
         }
     }
 
commit 29a4edaee6b258f5aa5b887fe745a8dd4c4a5823
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 6 02:26:18 2014 +0100

    use unique
    
    Change-Id: I49b9b69b66f4d8835078056b5681a1bf3760ffc9

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 937430e..24b386b 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1898,7 +1898,7 @@ sal_uInt16 _SaveMergeRedlines::InsertRedline(_SaveMergeRedlines* pRing, const Sw
 
         if( !pRing->unique() )
         {
-            SwPaM* pTmpPrev = static_cast<_SaveMergeRedlines*>(pRing->GetPrev())->pDestRedl;
+            SwPaM* pTmpPrev = pRing->GetPrev()->pDestRedl;
             if( pTmpPrev && *pTmpPrev->GetPoint() == *pDestRedl->GetPoint() )
                 *pTmpPrev->GetPoint() = *pDestRedl->GetMark();
         }
commit 01896d465a885e42d66a33a4cc88e7b1021b1a54
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 6 02:18:45 2014 +0100

    make InsertRedline a static function
    
    Change-Id: I80c7750f88f9b20e3a2be7306c53676d373654df

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 077d460..937430e 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1830,16 +1830,16 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
 class _SaveMergeRedlines;
 class _SaveMergeRedlines : public sw::Ring<_SaveMergeRedlines>
 {
+public:
     const SwRangeRedline* pSrcRedl;
     SwRangeRedline* pDestRedl;
-public:
     _SaveMergeRedlines( const SwNode& rDstNd,
                         const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing );
-    sal_uInt16 InsertRedline();
     _SaveMergeRedlines* GetNext()
         { return GetNextInRing(); }
     _SaveMergeRedlines* GetPrev()
         { return GetPrevInRing(); }
+    static sal_uInt16 InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl);
 };
 
 _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
@@ -1868,7 +1868,7 @@ _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
     }
 }
 
-sal_uInt16 _SaveMergeRedlines::InsertRedline()
+sal_uInt16 _SaveMergeRedlines::InsertRedline(_SaveMergeRedlines* pRing, const SwRangeRedline* pSrcRedl, SwRangeRedline* pDestRedl)
 {
     sal_uInt16 nIns = 0;
     SwDoc* pDoc = pDestRedl->GetDoc();
@@ -1896,9 +1896,9 @@ sal_uInt16 _SaveMergeRedlines::InsertRedline()
         pDestRedl->GetMark()->nContent.Assign( aSaveNd.GetNode().GetCntntNode(),
                                                 nSaveCnt );
 
-        if( GetPrev() != this )
+        if( !pRing->unique() )
         {
-            SwPaM* pTmpPrev = static_cast<_SaveMergeRedlines*>(GetPrev())->pDestRedl;
+            SwPaM* pTmpPrev = static_cast<_SaveMergeRedlines*>(pRing->GetPrev())->pDestRedl;
             if( pTmpPrev && *pTmpPrev->GetPoint() == *pDestRedl->GetPoint() )
                 *pTmpPrev->GetPoint() = *pDestRedl->GetMark();
         }
@@ -2068,7 +2068,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
             _SaveMergeRedlines* pTmp = pRing;
 
             do {
-                nRet += pTmp->InsertRedline();
+                nRet += pTmp->InsertRedline(pTmp, pTmp->pSrcRedl, pTmp->pDestRedl);
             } while( pRing != ( pTmp = pTmp->GetNext()) );
 
             while( pRing != pRing->GetNext() )
commit 60912747087f37f919875677478dbad8165047c6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 8 00:06:36 2014 +0100

    test for document merge
    
    Change-Id: Ic6d10a611d9e9351eb9403e1405ec7b17293e816

diff --git a/sw/qa/extras/uiwriter/data/merge-change1.odt b/sw/qa/extras/uiwriter/data/merge-change1.odt
new file mode 100644
index 0000000..02bd488
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/merge-change1.odt differ
diff --git a/sw/qa/extras/uiwriter/data/merge-change2.odt b/sw/qa/extras/uiwriter/data/merge-change2.odt
new file mode 100644
index 0000000..3644f81
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/merge-change2.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 7352983..4229877 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -62,6 +62,7 @@ public:
     void testFdo85554();
     void testAutoCorr();
     void testFdo87005();
+    void testMergeDoc();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -87,6 +88,7 @@ public:
     CPPUNIT_TEST(testFdo85554);
     CPPUNIT_TEST(testAutoCorr);
     CPPUNIT_TEST(testFdo87005);
+    CPPUNIT_TEST(testMergeDoc);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -631,6 +633,35 @@ void SwUiWriterTest::testFdo87005()
     assertXPath(pXmlDoc, "//Special[@nType='POR_FLY']", 2);
 }
 
+void SwUiWriterTest::testMergeDoc()
+{
+    SwDoc* const pDoc1(createDoc("merge-change1.odt"));
+
+    auto xDoc2Component(loadFromDesktop(
+            getURLFromSrc(DATA_DIRECTORY) + OUString("merge-change2.odt"),
+            "com.sun.star.text.TextDocument"));
+    auto pxDoc2Document(
+            dynamic_cast<SwXTextDocument *>(xDoc2Component.get()));
+    CPPUNIT_ASSERT(pxDoc2Document);
+    SwDoc* const pDoc2(pxDoc2Document->GetDocShell()->GetDoc());
+
+    SwEditShell* const pEditShell(pDoc1->GetEditShell());
+    pEditShell->MergeDoc(*pDoc2);
+
+    // accept all redlines
+    while(pEditShell->GetRedlineCount())
+        pEditShell->AcceptRedline(0);
+
+    CPPUNIT_ASSERT_EQUAL(7, getParagraphs());
+    getParagraph(1, "Para One: Two Three Four Five");
+    getParagraph(2, "Para Two: One Three Four Five");
+    getParagraph(3, "Para Three: One Two Four Five");
+    getParagraph(4, "Para Four: One Two Three Four Five");
+    getParagraph(5, "Para Six: One Three Four Five");
+    getParagraph(6, "");
+    getParagraph(7, "");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 


More information about the Libreoffice-commits mailing list