[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - writerfilter/CppunitTest_writerfilter_dmapper.mk writerfilter/qa writerfilter/source
writerfilter/CppunitTest_writerfilter_dmapper.mk|1 writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx | 88 ++ writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx |binary writerfilter/source/dmapper/DomainMapper_Impl.cxx |4 4 files changed, 92 insertions(+), 1 deletion(-) New commits: commit 58d2d3480018986835384ac12307131a6d30997f Author: Miklos Vajna AuthorDate: Mon Feb 10 21:04:32 2020 +0100 Commit: Miklos Vajna CommitDate: Tue Feb 11 19:45:31 2020 +0100 tdf#129221 DOCX import: fix missing restart of numbering Regression from e49d2b31fb2020d065b4ad940d1031d07b10f32b (fdo#78939 [DOCX] Hang while opening due to incorrect modification of Style, 2014-06-06), the problem was that the 2nd sub-list of the bugdoc was not restarted in Writer, while it was in Word. The PR2 paragraph style inherits from the PR1 one and only that sets the numId; tweaking the bugdoc to state the numId directly in PR2 would work around the problem. Fix the issue by improving DomainMapper_Impl::finishParagraph(), so that it uses lcl_getListId() rather than calling pStyleSheetProperties->GetListId() directly; since the previous knows how to walk up the parent chain if needed. (cherry picked from commit 63d3ac37865460ff51348a6e792bbacf2f7c4653) Conflicts: writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx Change-Id: I1c460919b0389d5b053b4ca1c9210279d6cd183c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88426 Reviewed-by: Michael Stahl Tested-by: Jenkins diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk index 37a3dc5813c5..695dcf95691b 100644 --- a/writerfilter/CppunitTest_writerfilter_dmapper.mk +++ b/writerfilter/CppunitTest_writerfilter_dmapper.mk @@ -18,6 +18,7 @@ $(eval $(call gb_CppunitTest_use_externals,writerfilter_dmapper,\ $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_dmapper, \ writerfilter/qa/cppunittests/dmapper/CellColorHandler \ writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler \ +writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl \ writerfilter/qa/cppunittests/dmapper/PropertyMap \ )) diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx new file mode 100644 index ..a7274c653805 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx @@ -0,0 +1,88 @@ +/* -*- 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 +#include + +#include +#include +#include +#include +#include +#include + +#include + +using namespace ::com::sun::star; + +namespace +{ +/// Tests for writerfilter/source/dmapper/DomainMapper_Impl.cxx. +class Test : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: +uno::Reference mxComponentContext; +uno::Reference mxComponent; + +public: +void setUp() override; +void tearDown() override; +uno::Reference& getComponent() { return mxComponent; } +}; + +void Test::setUp() +{ +test::BootstrapFixture::setUp(); + + mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); +mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void Test::tearDown() +{ +if (mxComponent.is()) +mxComponent->dispose(); + +test::BootstrapFixture::tearDown(); +} + +char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/"; + +CPPUNIT_TEST_FIXTURE(Test, testNumberingRestartStyleParent) +{ +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "num-restart-style-parent.docx"; +getComponent() = loadFromDesktop(aURL); + +// The paragraphs are A 1 2 B 1 2. +uno::Reference xTextDocument(getComponent(), uno::UNO_QUERY); +uno::Reference xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); +uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); +uno::Reference xPara; +OUStringLiteral aProp("ListLabelString"); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("A."), xPara->getPropertyValue(aProp).get()); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("1."), xPara->getPropertyValue(aProp).get()); +xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("2."),
[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - writerfilter/CppunitTest_writerfilter_dmapper.mk writerfilter/qa writerfilter/source
writerfilter/CppunitTest_writerfilter_dmapper.mk |1 writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx | 77 ++ writerfilter/qa/cppunittests/dmapper/data/floating-table-header.docx |binary writerfilter/source/dmapper/DomainMapperTableManager.cxx | 10 - writerfilter/source/dmapper/DomainMapperTableManager.hxx |6 writerfilter/source/dmapper/DomainMapper_Impl.cxx| 11 - writerfilter/source/dmapper/PropertyMap.cxx | 12 + 7 files changed, 98 insertions(+), 19 deletions(-) New commits: commit c1fd8e49f27fba261b5a715426ff5523abf5ac2b Author: Miklos Vajna AuthorDate: Wed Feb 5 16:11:40 2020 +0100 Commit: Xisco FaulĂ CommitDate: Fri Feb 7 17:57:43 2020 +0100 DOCX import: don't give up on floating tables in headers completely This reverts commit 213d6390a2cc59d174173f4359c161625a9c4bdc (tdf#108272 DOCX table-only header: fix SAX parser error, 2020-02-03), except its testcase and replaces it with a better fix that does not import all floating-table-in-header as non-floating tables. See the new testcase, which is 1 pages in Word, it was 3 pages in Writer, and with the better fix it's now 1 pages in Writer as well. Change-Id: Ica3500120f1d7cf766d55c17d78164865026 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88037 Tested-by: Jenkins Reviewed-by: Miklos Vajna Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88098 diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk index 9805e28228a0..37a3dc5813c5 100644 --- a/writerfilter/CppunitTest_writerfilter_dmapper.mk +++ b/writerfilter/CppunitTest_writerfilter_dmapper.mk @@ -18,6 +18,7 @@ $(eval $(call gb_CppunitTest_use_externals,writerfilter_dmapper,\ $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_dmapper, \ writerfilter/qa/cppunittests/dmapper/CellColorHandler \ writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler \ +writerfilter/qa/cppunittests/dmapper/PropertyMap \ )) $(eval $(call gb_CppunitTest_use_libraries,writerfilter_dmapper, \ diff --git a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx new file mode 100644 index ..06c5611afe37 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx @@ -0,0 +1,77 @@ +/* -*- 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace ::com::sun::star; + +namespace +{ +/// Tests for writerfilter/source/dmapper/PropertyMap.cxx. +class Test : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: +uno::Reference mxComponentContext; +uno::Reference mxComponent; + +public: +void setUp() override; +void tearDown() override; +uno::Reference& getComponent() { return mxComponent; } +}; + +void Test::setUp() +{ +test::BootstrapFixture::setUp(); + + mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); +mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void Test::tearDown() +{ +if (mxComponent.is()) +mxComponent->dispose(); + +test::BootstrapFixture::tearDown(); +} + +char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/"; + +CPPUNIT_TEST_FIXTURE(Test, testFloatingTableHeader) +{ +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "floating-table-header.docx"; +getComponent() = loadFromDesktop(aURL); +uno::Reference xModel(getComponent(), uno::UNO_QUERY); +uno::Reference xTextViewCursorSupplier( +xModel->getCurrentController(), uno::UNO_QUERY); +uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), + uno::UNO_QUERY); +xCursor->jumpToLastPage(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 3 +// i.e. a document which is 1 page in Word was imported as a 3 page one. +CPPUNIT_ASSERT_EQUAL(static_cast(1), xCursor->getPage()); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/floating-table-header.docx b/writerfilter/qa/cppunittests/dmapper/data/floating-table-header.docx new file mode 100644 index ..3840b2550d5b Binary files /dev/null and
[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - writerfilter/CppunitTest_writerfilter_dmapper.mk writerfilter/qa writerfilter/source
writerfilter/CppunitTest_writerfilter_dmapper.mk |1 writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx | 75 ++ writerfilter/qa/cppunittests/dmapper/data/tdf129205.docx |binary writerfilter/source/dmapper/CellColorHandler.cxx |2 4 files changed, 77 insertions(+), 1 deletion(-) New commits: commit dfd75ec6d4dcfec57607a8cf7c7a509c33bf2caa Author: Miklos Vajna AuthorDate: Thu Jan 2 09:01:17 2020 +0100 Commit: Adolfo Jayme Barrientos CommitDate: Fri Jan 3 08:11:39 2020 +0100 tdf#129205 DOCX import: handle the paragraph property Reading the spec, "nil" is the opposite of "clear": i.e. if the (background) color is red and the fill (color) is green, then "clear" means green. And you would expect "nil" means red, but it's just nothing in Word. Fix the problem by doing the same: don't set any paragraph property for the "nil" case and keep doing it for the common "clear" case. (cherry picked from commit fbe7612d654be9dfe1ea6f2e67900eb4eec4202a) Change-Id: I30af8a7fb55fb9bab2d12e120069a479fc7ab0a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86098 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk index fbb302297c94..9805e28228a0 100644 --- a/writerfilter/CppunitTest_writerfilter_dmapper.mk +++ b/writerfilter/CppunitTest_writerfilter_dmapper.mk @@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_use_externals,writerfilter_dmapper,\ )) $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_dmapper, \ +writerfilter/qa/cppunittests/dmapper/CellColorHandler \ writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler \ )) diff --git a/writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx b/writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx new file mode 100644 index ..ab3dc7cec6c3 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/CellColorHandler.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 +#include + +#include +#include +#include +#include +#include + +#include + +using namespace ::com::sun::star; + +namespace +{ +/// Tests for writerfilter/source/dmapper/CellColorHandler.cxx. +class Test : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: +uno::Reference mxComponentContext; +uno::Reference mxComponent; + +public: +void setUp() override; +void tearDown() override; +uno::Reference& getComponent() { return mxComponent; } +}; + +void Test::setUp() +{ +test::BootstrapFixture::setUp(); + + mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); +mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void Test::tearDown() +{ +if (mxComponent.is()) +mxComponent->dispose(); + +test::BootstrapFixture::tearDown(); +} + +char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/"; + +CPPUNIT_TEST_FIXTURE(Test, test129205) +{ +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf129205.docx"; +getComponent() = loadFromDesktop(aURL); +uno::Reference xTextDocument(getComponent(), uno::UNO_QUERY); +uno::Reference xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); +uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); +uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); +drawing::FillStyle eFillStyle = drawing::FillStyle::FillStyle_NONE; +xPara->getPropertyValue("FillStyle") >>= eFillStyle; +// Without the accompanying fix in place, this test would have failed with: +// - Expected: drawing::FillStyle_NONE +// - Actual : FillStyle_SOLID +// i.e. the paragraph had a solid fill, making the header image invisible. +CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, eFillStyle); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/tdf129205.docx b/writerfilter/qa/cppunittests/dmapper/data/tdf129205.docx new file mode 100644 index ..4289254d0a97 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/tdf129205.docx differ diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx index b5889742c29a..a830b5783116 100644 --- a/writerfilter/source/dmapper/CellColorHandler.cxx +++ b/writerfilter/source/dmapper/CellColorHandler.cxx @@ -276,7 +276,7 @@