diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-12-17 16:15:59 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-01-23 16:18:30 +0100 |
commit | 0679e01f7ee0b573b6dea3e9b2642cf851e873d2 (patch) | |
tree | 10a01627de1adc8efc763b12b1e1b001fe13bd7f /sw | |
parent | 59d4b488e0d25266f02ca142d18deee7ecc5dc55 (diff) |
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
Reviewed-on: https://gerrit.libreoffice.org/65286
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit fdf4afb25ba38c7be3278bb4bde462c3f9e722fc)
Change-Id: If347008e4cf48ab1327eb04db9fdf69750ce8fa5
Reviewed-on: https://gerrit.libreoffice.org/65316
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/mailmerge/data/linked-with-condition.odt | bin | 0 -> 9193 bytes | |||
-rw-r--r-- | sw/qa/extras/mailmerge/mailmerge.cxx | 81 | ||||
-rw-r--r-- | sw/source/core/docnode/section.cxx | 1 |
3 files changed, 81 insertions, 1 deletions
diff --git a/sw/qa/extras/mailmerge/data/linked-with-condition.odt b/sw/qa/extras/mailmerge/data/linked-with-condition.odt Binary files differnew file mode 100644 index 000000000000..17fefa29b6b8 --- /dev/null +++ b/sw/qa/extras/mailmerge/data/linked-with-condition.odt diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index cb8c705cd8b0..5d2572f40b0c 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -891,5 +891,86 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf121168, "section_ps.odt", "4_v01.ods", "Tabe } } +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 8eecfc5ac4c7..bdd89c7e8b56 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1459,7 +1459,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 ); |