summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-12-17 16:15:59 +0300
committerAndras Timar <andras.timar@collabora.com>2018-12-29 20:24:06 +0100
commit5d4af68bdd2bb167e527d42f21bfe6cfbf3f25b0 (patch)
tree7b696abbe982682e7a94d7e59c3a36ae08263992 /sw
parent9972e23fa2ac292310df86c5b7e7ec4d7d6acea6 (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
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/mailmerge/data/linked-with-condition.odtbin0 -> 9193 bytes
-rw-r--r--sw/qa/extras/mailmerge/mailmerge.cxx81
-rw-r--r--sw/source/core/docnode/section.cxx1
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
new file mode 100644
index 000000000000..17fefa29b6b8
--- /dev/null
+++ b/sw/qa/extras/mailmerge/data/linked-with-condition.odt
Binary files differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 731927e3b77d..b5063d3c6357 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -900,5 +900,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 0a1e5083d4a9..b6376a03a446 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1460,7 +1460,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 );