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

Miklos Vajna vmiklos at collabora.co.uk
Fri Apr 10 04:18:46 PDT 2015


 sw/qa/extras/mailmerge/data/empty.odt |binary
 sw/qa/extras/mailmerge/mailmerge.cxx  |    6 ++++++
 sw/source/core/doc/docbm.cxx          |    2 ++
 sw/source/core/doc/docnew.cxx         |   26 ++++++++++++++++++++++++++
 4 files changed, 34 insertions(+)

New commits:
commit 2819ee71da631116662401f14f8a0fb78c2a7f3a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Apr 10 11:54:03 2015 +0200

    tdf#90230 SwDoc::AppendDoc: take care of marks when inserting page break
    
    SwDoc::AppendDoc() inserts nodes from an other document, and before
    doing that, it inserts a page break at the end of the document. In case
    there are marks at the end of the last paragraph, the insertion of the
    page break moves them to the next page. This is a rare situation, but
    happens e.g. when the source document is an empty one: then MM puts a
    mark at the first paragraph of each inserted MM part, and then the first
    paragraph == the last paragraph, so the mark of the only paragraph in
    the document gets moved to the next page.
    
    This is a problem on its own, but is detected by the SwIndexReg dtor
    when that empty paragraph gets deleted later in SwNodes::Delete() called
    by SwDoc::AppendDoc(), resulting in an assertion failure.
    
    Triggered by commit a305a2c91420652db450b7f8edd140e1d69f42cf (use
    bookmarks to mark mailmerge parts in a mailmerge document (fdo#80823),
    2014-10-20), these not adjusted bookmarks were not detected before.
    
    Change-Id: I89775b477a2fd3182b2bc87144aed2bfe7912aff

diff --git a/sw/qa/extras/mailmerge/data/empty.odt b/sw/qa/extras/mailmerge/data/empty.odt
new file mode 100644
index 0000000..311cb06
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/empty.odt differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 319bf93..2c9e164 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -406,5 +406,11 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf89214, "tdf89214.odt", "10-testing-addresses
     CPPUNIT_ASSERT(!getProperty<OUString>(xParagraph, "ListId").isEmpty());
 }
 
+DECLARE_SHELL_MAILMERGE_TEST(testTdf90230, "empty.odt", "10-testing-addresses.ods", "testing-addresses")
+{
+    // MM of an empty document caused an assertion in the SwIndexReg dtor.
+    executeMailMerge();
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index ec05f9a..05ec76d 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -946,6 +946,32 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
         if ( pTargetPageDesc ) {
             OUString name = pTargetPageDesc->GetName();
             pTargetShell->InsertPageBreak( &name, nStartPageNumber );
+
+            // There is now a new empty text node on the new page. If it has
+            // any marks, those are from the previous page: move them back
+            // there, otherwise later we can't delete that empty text node.
+            SwNodeIndex aNodeIndex(GetNodes().GetEndOfContent(), -1);
+            if (SwTxtNode* pTxtNode = aNodeIndex.GetNode().GetTxtNode())
+            {
+                // Position of the last paragraph on the previous page.
+                --aNodeIndex;
+                SwPaM aPaM(aNodeIndex);
+                // Collect the marks starting or ending at this text node.
+                std::set<sw::mark::IMark*> aSeenMarks;
+                IDocumentMarkAccess* pMarkAccess = getIDocumentMarkAccess();
+                for (const SwIndex* pIndex = pTxtNode->GetFirstIndex(); pIndex; pIndex = pIndex->GetNext())
+                {
+                    sw::mark::IMark* pMark = const_cast<sw::mark::IMark*>(pIndex->GetMark());
+                    if (!pMark)
+                        continue;
+                    if (aSeenMarks.find(pMark) != aSeenMarks.end())
+                        continue;
+                    aSeenMarks.insert(pMark);
+                }
+                // And move them back.
+                for (sw::mark::IMark* pMark : aSeenMarks)
+                    pMarkAccess->repositionMark(pMark, aPaM);
+            }
         }
     }
 #ifdef DBG_UTIL
commit 0ab3275d8d3d31e50249ec253167c9d394892b04
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Apr 10 08:38:04 2015 +0200

    sw::mark::MarkManager::dumpAsXml(): show UNO marks
    
    Change-Id: Ic19ef6465036050b3b72949af65e23f8dde3afcf

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 2efece0..a7ed67a 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1144,6 +1144,8 @@ void MarkManager::dumpAsXml(xmlTextWriterPtr pWriter) const
         const container_t* pContainer;
     } aContainers[] =
     {
+        // UNO marks are only part of all marks.
+        {"allmarks", &m_vAllMarks},
         {"bookmarks", &m_vBookmarks},
         {"fieldmarks", &m_vFieldmarks},
         {"annotationmarks", &m_vAnnotationMarks}


More information about the Libreoffice-commits mailing list