[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 21:34:28 UTC 2018


 sw/qa/extras/mailmerge/data/linked-with-condition.odt |binary
 sw/qa/extras/mailmerge/mailmerge.cxx                  |   81 ++++++++++++++++++
 sw/source/core/docnode/section.cxx                    |    1 
 3 files changed, 81 insertions(+), 1 deletion(-)

New commits:
commit b5069baed681d7b60c4aebebfb5a43a5635d5ba8
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Dec 17 16:15:59 2018 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Dec 18 22:34:05 2018 +0100

    tdf#122156: closing a section link should not clear its Hidden flag
    
    If a section is hidden or not does not depend on whether it's linked
    or not. Clearing the Hidden flag made all linked sections not hidden
    in DocumentLinksAdministrationManager::EmbedAllLinks() during mail
    merge.
    
    Existed since commit 84a3db80b4fd66c6854b3135b5f69b61fd828e62
        initial import
    
    Change-Id: If347008e4cf48ab1327eb04db9fdf69750ce8fa5
    Reviewed-on: https://gerrit.libreoffice.org/65286
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit fdf4afb25ba38c7be3278bb4bde462c3f9e722fc)
    Reviewed-on: https://gerrit.libreoffice.org/65315
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/qa/extras/mailmerge/data/linked-with-condition.odt b/sw/qa/extras/mailmerge/data/linked-with-condition.odt
new file mode 100644
index 000000000000..17fefa29b6b8
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/linked-with-condition.odt differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index c1d78685ff24..39005e483c86 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -900,5 +900,86 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf118845, "tdf118845.fodt", "4_v01.ods", "Tabe
     CPPUNIT_ASSERT_EQUAL(OUString(""), xParagraph->getString());
 }
 
+DECLARE_SHELL_MAILMERGE_TEST(testTdf122156_shell, "linked-with-condition.odt", "5-with-blanks.ods",
+                             "names")
+{
+    // A document with a linked section hidden on an "empty field" condition
+    // For combined documents, hidden sections are removed completely
+    executeMailMerge();
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxMMComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    // 5 documents 1 page each, starting at odd page numbers => 9
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(9), pTextDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum());
+    uno::Reference<text::XTextSectionsSupplier> xSectionsSupplier(mxMMComponent,
+                                                                  uno::UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xSections(xSectionsSupplier->getTextSections(),
+                                                      uno::UNO_QUERY_THROW);
+    // 2 out of 5 dataset records have empty "Title" field => no sections in respective documents
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xSections->getCount());
+}
+
+DECLARE_FILE_MAILMERGE_TEST(testTdf122156_file, "linked-with-condition.odt", "5-with-blanks.ods",
+                            "names")
+{
+    // A document with a linked section hidden on an "empty field" condition
+    // For separate documents, the sections are hidden, but not removed
+    executeMailMerge();
+    {
+        loadMailMergeDocument(0);
+        uno::Reference<text::XTextSectionsSupplier> xSectionsSupplier(mxComponent,
+                                                                      uno::UNO_QUERY_THROW);
+        uno::Reference<container::XIndexAccess> xSections(xSectionsSupplier->getTextSections(),
+                                                          uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+        uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY_THROW);
+        // Record 1 has empty "Title" field => section is not shown
+        CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xSect, "IsCurrentlyVisible"));
+    }
+    {
+        loadMailMergeDocument(1);
+        uno::Reference<text::XTextSectionsSupplier> xSectionsSupplier(mxComponent,
+                                                                      uno::UNO_QUERY_THROW);
+        uno::Reference<container::XIndexAccess> xSections(xSectionsSupplier->getTextSections(),
+                                                          uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+        uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY_THROW);
+        // Record 2 has non-empty "Title" field => section is shown
+        CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xSect, "IsCurrentlyVisible"));
+    }
+    {
+        loadMailMergeDocument(2);
+        uno::Reference<text::XTextSectionsSupplier> xSectionsSupplier(mxComponent,
+                                                                      uno::UNO_QUERY_THROW);
+        uno::Reference<container::XIndexAccess> xSections(xSectionsSupplier->getTextSections(),
+                                                          uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+        uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY_THROW);
+        // Record 3 has non-empty "Title" field => section is shown
+        CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xSect, "IsCurrentlyVisible"));
+    }
+    {
+        loadMailMergeDocument(3);
+        uno::Reference<text::XTextSectionsSupplier> xSectionsSupplier(mxComponent,
+                                                                      uno::UNO_QUERY_THROW);
+        uno::Reference<container::XIndexAccess> xSections(xSectionsSupplier->getTextSections(),
+                                                          uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+        uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY_THROW);
+        // Record 4 has empty "Title" field => section is not shown
+        CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xSect, "IsCurrentlyVisible"));
+    }
+    {
+        loadMailMergeDocument(4);
+        uno::Reference<text::XTextSectionsSupplier> xSectionsSupplier(mxComponent,
+                                                                      uno::UNO_QUERY_THROW);
+        uno::Reference<container::XIndexAccess> xSections(xSectionsSupplier->getTextSections(),
+                                                          uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
+        uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY_THROW);
+        // Record 5 has non-empty "Title" field => section is shown
+        CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xSect, "IsCurrentlyVisible"));
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index f7504558e1f8..b77e0f99859d 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1457,7 +1457,6 @@ void SwIntrnlSectRefLink::Closed()
                 SwSectionData aSectionData(*rSectFormat.GetSection());
                 aSectionData.SetType( CONTENT_SECTION );
                 aSectionData.SetLinkFileName( OUString() );
-                aSectionData.SetHidden( false );
                 aSectionData.SetProtectFlag( false );
                 // edit in readonly sections
                 aSectionData.SetEditInReadonlyFlag( false );


More information about the Libreoffice-commits mailing list