Kaydet (Commit) fdf4afb2 authored tarafından Mike Kaganski's avatar Mike Kaganski

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 84a3db80
    initial import

Change-Id: If347008e4cf48ab1327eb04db9fdf69750ce8fa5
Reviewed-on: https://gerrit.libreoffice.org/65286
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 5bc0cbc7
...@@ -974,5 +974,86 @@ DECLARE_FILE_MAILMERGE_TEST(testTd78611_file, "tdf78611.odt", "10-testing-addres ...@@ -974,5 +974,86 @@ DECLARE_FILE_MAILMERGE_TEST(testTd78611_file, "tdf78611.odt", "10-testing-addres
} }
} }
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(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1455,7 +1455,6 @@ void SwIntrnlSectRefLink::Closed() ...@@ -1455,7 +1455,6 @@ void SwIntrnlSectRefLink::Closed()
SwSectionData aSectionData(*rSectFormat.GetSection()); SwSectionData aSectionData(*rSectFormat.GetSection());
aSectionData.SetType( CONTENT_SECTION ); aSectionData.SetType( CONTENT_SECTION );
aSectionData.SetLinkFileName( OUString() ); aSectionData.SetLinkFileName( OUString() );
aSectionData.SetHidden( false );
aSectionData.SetProtectFlag( false ); aSectionData.SetProtectFlag( false );
// edit in readonly sections // edit in readonly sections
aSectionData.SetEditInReadonlyFlag( false ); aSectionData.SetEditInReadonlyFlag( false );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment