summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-07-14 11:07:45 +0200
committerAndras Timar <andras.timar@collabora.com>2022-07-18 15:38:24 +0200
commit70d201c857fe86834f618f8c66df6f19b76c2556 (patch)
treec753c40fda429e262930105e1097b765b0be00cf /sw/qa/extras/uiwriter
parentfe072bf9e52ab4c0bd7b692940092ca296edfe59 (diff)
tdf#54703 fix unhiding at PDF export of cond. hidden sections
The conditionally hidden sections became visible when PDF export is performed. This is due to field update where we temporary made the conditionally hidden section visible (as the frame is needed), but never put them back to hidden. Probably the expectation was that the condition will be recalculated later on, but wasn't. This change fixes this so that the changed sections will be recalculated at the end. Change-Id: Ic6d8a4a38f22ed961b2b37e05aaf3e720fc50ed4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137052 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137162 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/data/HiddenSection.odtbin0 -> 8378 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx50
2 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/HiddenSection.odt b/sw/qa/extras/uiwriter/data/HiddenSection.odt
new file mode 100644
index 000000000000..8358cbc9951a
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/HiddenSection.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index f895b59ba402..6db1b70051fc 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -30,10 +30,12 @@
#include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/configuration.hxx>
+#include <unotools/mediadescriptor.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <i18nlangtag/languagetag.hxx>
#include <vcl/scheduler.hxx>
#include <vcl/settings.hxx>
+#include <vcl/filter/PDFiumLibrary.hxx>
#include <ndtxt.hxx>
#include <swdtflvr.hxx>
#include <wrtsh.hxx>
@@ -6069,6 +6071,54 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126735)
CPPUNIT_ASSERT_EQUAL(OUString("or "), xTextRange->getString());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testConditionalHiddenSectionIssue)
+{
+ // tdf#54703
+ // When exporting the bug document as PDF, the conditional hidden
+ // sections became visible in the PDF and in the document.
+
+ std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+ if (!pPDFium)
+ return;
+
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "HiddenSection.odt");
+
+ // Check section conditional hidden status - all should be hidden (IsCondHidden == true)
+ for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
+ {
+ if (SwSectionNode const* const pNode = pDoc->GetNodes()[i]->GetSectionNode())
+ {
+ CPPUNIT_ASSERT_EQUAL(true, pNode->GetSection().IsCondHidden());
+ }
+ }
+
+ // PDF export
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+ xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
+ SvMemoryStream aMemory;
+ aMemory.WriteStream(aFile);
+ auto pPdfDocument = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize());
+ CPPUNIT_ASSERT(pPdfDocument);
+ auto pPdfPage = pPdfDocument->openPage(0);
+ CPPUNIT_ASSERT(pPdfPage);
+
+ // No PDF object should be present in the page - sections remained hidden
+ CPPUNIT_ASSERT_EQUAL(0, pPdfPage->getObjectCount());
+
+ // Check section conditional hidden status - all should remained hidden (IsCondHidden == true)
+ for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
+ {
+ if (SwSectionNode const* const pNode = pDoc->GetNodes()[i]->GetSectionNode())
+ {
+ CPPUNIT_ASSERT_EQUAL(true, pNode->GetSection().IsCondHidden());
+ }
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */