sw/CppunitTest_sw_pdf_test.mk | 66 ++++++++ sw/Module_sw.mk | 1 sw/inc/docsh.hxx | 3 sw/qa/extras/pdf/HybridPdfTest.cxx | 75 ++++++++++ sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsAndPDFAttachedFile.pdf |binary sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsOnly.pdf |binary sw/qa/extras/pdf/data/PDFOnly.pdf |binary sw/source/uibase/app/docst.cxx | 13 + 8 files changed, 158 insertions(+)
New commits: commit cae93bc7a401cb6ddaf33b7a23e2ff3c3bfada40 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jan 25 16:55:14 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Jan 25 14:56:34 2023 +0000 sw: support theme colors in color picker in writer Implements SfxDocumentShell::GetThemeColors, which allows the color picker to use the theme colors and change them in Writer. Change-Id: Ic13d2086d4ff037b377b475630b02ed1509fdf3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146120 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 8d051b4fb54a..74fa2225ae93 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -253,6 +253,9 @@ public: bool bTemplate = false ) const override; virtual std::set<Color> GetDocColors() override; + + virtual std::vector<Color> GetThemeColors() override; + sfx::AccessibilityIssueCollection runAccessibilityCheck() override; virtual void LoadStyles( SfxObjectShell& rSource ) override; diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index f13b90b70af6..e3cc7b0f6b6e 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -81,6 +81,8 @@ #include <SwUndoFmt.hxx> #include <strings.hrc> #include <AccessibilityCheck.hxx> +#include <svx/ColorSets.hxx> +#include <svx/svdpage.hxx> using namespace ::com::sun::star; @@ -1575,6 +1577,17 @@ std::set<Color> SwDocShell::GetDocColors() return m_xDoc->GetDocColors(); } +std::vector<Color> SwDocShell::GetThemeColors() +{ + SdrPage* pPage = m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + if (!pPage) + return {}; + svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + if (!pTheme) + return {}; + return pTheme->GetColors(); +} + void SwDocShell::LoadStyles( SfxObjectShell& rSource ) { LoadStyles_(rSource, false); commit 8640e24b12c7df3170c9f3e7ff3edced81fd0838 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Jan 24 22:16:08 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Jan 25 14:56:26 2023 +0000 tdf#66580 added hybrid PDF test cases Change-Id: I2a58e6cd5b40266b3c55729febb7006c7a7b4170 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146068 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sw/CppunitTest_sw_pdf_test.mk b/sw/CppunitTest_sw_pdf_test.mk new file mode 100644 index 000000000000..09c79df57ec9 --- /dev/null +++ b/sw/CppunitTest_sw_pdf_test.mk @@ -0,0 +1,66 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_pdf_test)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_pdf_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_pdf_test, \ + sw/qa/extras/pdf/HybridPdfTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_pdf_test, \ + comphelper \ + cppu \ + cppuhelper \ + i18nlangtag \ + msfilter \ + sal \ + sfx \ + sot \ + subsequenttest \ + sw \ + swqahelper \ + svl \ + svt \ + test \ + tl \ + unotest \ + utl \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_pdf_test,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_pdf_test,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/source/filter/inc \ + -I$(SRCDIR)/sw/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_pdf_test,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_pdf_test)) +$(eval $(call gb_CppunitTest_use_vcl,sw_pdf_test)) +$(eval $(call gb_CppunitTest_use_rdb,sw_pdf_test,services)) +$(eval $(call gb_CppunitTest_use_configuration,sw_pdf_test)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 44d5bc4e8d22..2b99d0bff22a 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -156,6 +156,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_filter_html \ CppunitTest_sw_a11y \ CppunitTest_sw_core_theme \ + CppunitTest_sw_pdf_test \ )) ifneq ($(DISABLE_GUI),TRUE) diff --git a/sw/qa/extras/pdf/HybridPdfTest.cxx b/sw/qa/extras/pdf/HybridPdfTest.cxx new file mode 100644 index 000000000000..fda2b409fbaa --- /dev/null +++ b/sw/qa/extras/pdf/HybridPdfTest.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> + +class HybridPdfTest : public SwModelTestBase +{ +public: + HybridPdfTest() + : SwModelTestBase("/sw/qa/extras/pdf/data/") + { + } + + void testNoHybridDataInPDF(); + void testHybridWithAdditionalStreams(); + void testHybridWithAdditionalStreamsAndAttachedFile(); + + CPPUNIT_TEST_SUITE(HybridPdfTest); + CPPUNIT_TEST(testNoHybridDataInPDF); + CPPUNIT_TEST(testHybridWithAdditionalStreams); + CPPUNIT_TEST(testHybridWithAdditionalStreamsAndAttachedFile); + CPPUNIT_TEST_SUITE_END(); +}; + +void HybridPdfTest::testNoHybridDataInPDF() +{ + // Load PDF document without attached ODT document + UnoApiXmlTest::load(createFileURL(u"PDFOnly.pdf"), nullptr); + CPPUNIT_ASSERT(mxComponent.is()); + uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY_THROW); + // Draw document is expected in this case - default when importing PDF + CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument")); +} + +void HybridPdfTest::testHybridWithAdditionalStreams() +{ + // Load PDF document with an embedded ODT document + // The ODT document is embedded in "/AdditionalStreams" structure that is in the PDF trailer + createSwDoc("Hybrid_AdditionalStreamsOnly.pdf"); + SwDoc* pDoc = getSwDoc(); + CPPUNIT_ASSERT(pDoc); + + // We can access the document text in a single paragraph that spans multiple rows + // This wouldn't be possible with a PDF, so the opened document has to be ODT + CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. \nThat didn't bode well."), + getParagraph(1)->getString()); +} + +void HybridPdfTest::testHybridWithAdditionalStreamsAndAttachedFile() +{ + // Load PDF document with an embedded ODT document + // The ODT document is embedded in "/AdditionalStreams" structure that is in the PDF trailer + // and is included as an attached file conforming to the PDF specs + createSwDoc("Hybrid_AdditionalStreamsAndPDFAttachedFile.pdf"); + SwDoc* pDoc = getSwDoc(); + CPPUNIT_ASSERT(pDoc); + + // We can access the document text in a single paragraph that spans multiple rows + // This wouldn't be possible with a PDF, so the opened document has to be ODT + CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. \nThat didn't bode well."), + getParagraph(1)->getString()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(HybridPdfTest); +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsAndPDFAttachedFile.pdf b/sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsAndPDFAttachedFile.pdf new file mode 100644 index 000000000000..fc05d01ba06a Binary files /dev/null and b/sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsAndPDFAttachedFile.pdf differ diff --git a/sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsOnly.pdf b/sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsOnly.pdf new file mode 100644 index 000000000000..6e95a17d4770 Binary files /dev/null and b/sw/qa/extras/pdf/data/Hybrid_AdditionalStreamsOnly.pdf differ diff --git a/sw/qa/extras/pdf/data/PDFOnly.pdf b/sw/qa/extras/pdf/data/PDFOnly.pdf new file mode 100644 index 000000000000..53f24b33136e Binary files /dev/null and b/sw/qa/extras/pdf/data/PDFOnly.pdf differ