writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx | 24 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/follow-page-top-margin.docx |binary writerfilter/source/dmapper/PropertyMap.cxx | 9 --- 3 files changed, 24 insertions(+), 9 deletions(-)
New commits: commit d6674aaa23b34af702681beb4c0f219e6f50069c Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Dec 7 21:02:12 2020 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Dec 8 15:02:40 2020 +0100 tdf#135217 DOCX import: remove no longer needed top/bottom margin sync Regression from commit b7ae863efeb082816cc4fe660527a9650d90e186 (tdf#117503 DOCX import: fix out of sync first/later top margin, 2018-05-28), which adjusted the import so that the export can pair first/follow page styles and write them into a single Word section. But changing the import for pairing purposes is not a good idea after all, as it also affects the layout of the imported document. In the meantime, commit 51534ac2b9747975945acb6a1e1ba5cc6d73f5c2 (tdf#127778 DOCX import: fix unexpected heading on non-first page when the first page has a heading, 2020-05-11) already fixed the export side, so this is not even necessary, just remove it. (cherry picked from commit 29993781ac991e85bfbd61f9e076c9d8088cd3ab) Change-Id: I94c02517ae1e0804547f81c43bb5890327d32376 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107400 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx index 71b3ab80e50b..2c7586649c01 100644 --- a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx +++ b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx @@ -13,6 +13,8 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/text/XPageCursor.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> using namespace ::com::sun::star; @@ -63,6 +65,28 @@ CPPUNIT_TEST_FIXTURE(Test, testFloatingTableHeader) // i.e. a document which is 1 page in Word was imported as a 3 page one. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), xCursor->getPage()); } + +CPPUNIT_TEST_FIXTURE(Test, testFollowPageTopMargin) +{ + // Load a document with 2 pages: first page has larger top margin, second page has smaller top + // margin. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "follow-page-top-margin.docx"; + getComponent() = loadFromDesktop(aURL); + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(getComponent(), + uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies + = xStyleFamiliesSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName("Standard"), uno::UNO_QUERY); + auto nTopMargin = xStyle->getPropertyValue("TopMargin").get<sal_Int32>(); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 250 + // - Actual : 1249 + // i.e. the top margin on page 2 was too large. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(250), nTopMargin); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/follow-page-top-margin.docx b/writerfilter/qa/cppunittests/dmapper/data/follow-page-top-margin.docx new file mode 100644 index 000000000000..ceae0b784e18 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/follow-page-top-margin.docx differ diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index acdcede9d6f9..b7457fa418b7 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1037,15 +1037,6 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage ) //now set the top/bottom margin for the follow page style Insert( PROP_TOP_MARGIN, uno::makeAny( std::max<sal_Int32>(nTopMargin, 0) ) ); Insert( PROP_BOTTOM_MARGIN, uno::makeAny( std::max<sal_Int32>(nBottomMargin, 0) ) ); - - if (bCopyFirstToFollow) - { - if (HasHeader(/*bFirstPage=*/true)) - m_aFollowPageStyle->setPropertyValue("TopMargin", getProperty(PROP_TOP_MARGIN)->second); - if (HasFooter(/*bFirstPage=*/true)) - m_aFollowPageStyle->setPropertyValue("BottomMargin", - getProperty(PROP_BOTTOM_MARGIN)->second); - } } static uno::Reference< beans::XPropertySet > lcl_GetRangeProperties( bool bIsFirstSection, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits