[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 29 19:18:09 UTC 2018


 sw/qa/extras/mailmerge/data/section_ps.odt |binary
 sw/qa/extras/mailmerge/mailmerge.cxx       |   33 +++++++++++++++++++++++++++++
 sw/source/uibase/dbui/dbmgr.cxx            |    9 +++++++
 3 files changed, 42 insertions(+)

New commits:
commit 81dc538bdebf7e2c8c0b259eed3b3f8b77309c59
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Dec 19 00:35:32 2018 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 29 20:17:43 2018 +0100

    tdf#121168: Ensure page descriptions are correct in work document
    
    When first node on a page is a section, then creation of a copy with
    lcl_CreateWorkingDocument initially produces a document with layout
    frames having wrong page descriptions applied (set to "Default Style").
    The reason is that when SfxViewFrame::LoadHiddenDocument indirectly
    calls SwRootFrame::Init, the sections in the document have hidden
    flag set, which causes SwNodes::GoNextSection return the first node
    after the first section. The returned node naturally doesn't have a
    page description set, thus the initialized page frame doesn't get it.
    
    This makes following copy to destination document use that wrong style;
    if the correct page style had header/footer, then it would not be
    properly copied per record in single-document output; headers/footers
    would be wrong/absent.
    
    This change forces check of page descriptions after the work document
    had been created and initialized.
    
    Change-Id: Ic196eb7fac0241f002eddd2c1d1b66dfb489bc60
    Reviewed-on: https://gerrit.libreoffice.org/65383
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit ec928ac5d84273b4bc1f923c545834dc59d3e394)
    Reviewed-on: https://gerrit.libreoffice.org/65408
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/qa/extras/mailmerge/data/section_ps.odt b/sw/qa/extras/mailmerge/data/section_ps.odt
new file mode 100644
index 000000000000..dd9704845fac
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/section_ps.odt differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index ba4c5dd401bd..731927e3b77d 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -867,5 +867,38 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf118845, "tdf118845.fodt", "4_v01.ods", "Tabe
     CPPUNIT_ASSERT_EQUAL(OUString(""), xParagraph->getString());
 }
 
+DECLARE_SHELL_MAILMERGE_TEST(testTdf121168, "section_ps.odt", "4_v01.ods", "Tabelle1")
+{
+    // A document starting with a section on a page with non-default page style with header
+    executeMailMerge();
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxMMComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    // 4 documents 1 page each, starting at odd page numbers => 7
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(7), pTextDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum());
+
+    SwDoc* pDocMM = pTextDoc->GetDocShell()->GetDoc();
+    sal_uLong nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex()
+                        - pDocMM->GetNodes().GetEndOfExtras().GetIndex() - 2;
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(16), nSizeMM);
+
+    // All even pages should be empty, all sub-documents have one page
+    const SwRootFrame* pLayout = pDocMM->getIDocumentLayoutAccess().GetCurrentLayout();
+    const SwPageFrame* pPageFrm = static_cast<const SwPageFrame*>(pLayout->Lower());
+    while (pPageFrm)
+    {
+        sal_uInt16 nPageNum = pPageFrm->GetPhyPageNum();
+        bool bOdd = (1 == (nPageNum % 2));
+        CPPUNIT_ASSERT_EQUAL(!bOdd, pPageFrm->IsEmptyPage());
+        CPPUNIT_ASSERT_EQUAL(sal_uInt16(bOdd ? 1 : 2), pPageFrm->GetVirtPageNum());
+        if (bOdd)
+        {
+            const SwPageDesc* pDesc = pPageFrm->GetPageDesc();
+            CPPUNIT_ASSERT_EQUAL(OUString("Teststyle" + OUString::number(nPageNum / 2 + 1)),
+                                 pDesc->GetName());
+        }
+        pPageFrm = static_cast<const SwPageFrame*>(pPageFrm->GetNext());
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 51f0dde9ae05..55e82e50e8f0 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1421,6 +1421,15 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                 // ExpFields update during printing, generation of preview, etc.
                 pWorkShell->LockExpFields();
                 pWorkShell->CalcLayout();
+                // tdf#121168: Now force correct page descriptions applied to page frames. Without
+                // this, e.g., page frames starting with sections could have page descriptions set
+                // wrong. This would lead to wrong page styles applied in SwDoc::AppendDoc below.
+                pWorkShell->GetViewOptions()->SetIdle(true);
+                for (auto aLayout : pWorkShell->GetDoc()->GetAllLayouts())
+                {
+                    aLayout->FreezeLayout(false);
+                    aLayout->AllCheckPageDescs();
+                }
             }
 
             lcl_emitEvent(SfxEventHintId::SwEventFieldMerge, STR_SW_EVENT_FIELD_MERGE, xWorkDocSh);


More information about the Libreoffice-commits mailing list