sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 11 ++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 16 ++++++------ 3 files changed, 20 insertions(+), 7 deletions(-)
New commits: commit e86d30e8bbabeb5e4a5a74d3fe439218a35cce8d Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Oct 3 13:44:15 2023 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Oct 5 08:42:04 2023 +0200 tdf#157572 tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default Fixes LO 7.6 regression commit 630732bfd8ed531e9d412a36a083f33763def054 See bug 157572 for the documentation. To test this, I used ooxmlexport5's tdf112287B.docx with Word 2010: -changed vertical relative to Paragraph - exported w:vAnchor="text" -changed vertical relative to Page - exported w:vAnchor="page" -changed vertical relative to Margin - did not export w:vAnchor So, obviously the default is "margin" Note that it always exports w:y=1 For importing, the default vAnchor changed depending on whether w:y=0 (text) or w:y=1 (margin) * an exception is when w:y=0 and vAlign is defined - then 'margin' make CppunitTest_sw_ooxmlexport5 \ CPPUNIT_TEST_NAME=testTdf157572_defaultVAnchor Change-Id: I126094eafc43a83e3a4efdd1ebc8d9cab9d49759 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157527 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins (cherry picked from commit cfa744f49e9e18dfa8888b6a0f5930304898dc98) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157544 Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx b/sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx new file mode 100644 index 000000000000..9f63950693f7 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf157572_defaultVAnchor.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index ceb6bdff9c06..71cea9fa2964 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -1429,6 +1429,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112287) assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","yAlign","bottom"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf157572_defaultVAnchor) +{ + loadAndSave("tdf157572_defaultVAnchor.docx"); + xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); + + // vAnchor wasn't defined on import. It should default to 'margin' when w:y=non-zero + assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin"); + // yAlign=something is not compatible with w:y=non-zero" - don't write anything out + // assertXPathNoAttribute(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf112287B) { loadAndSave("tdf112287B.docx"); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 1758f7662c49..2bf742d3bf1c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1874,13 +1874,15 @@ DomainMapper_Impl::MakeFrameProperties(const ParagraphProperties& rProps) aFrameProperties.push_back( comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT), nVertOrient)); - //Default the anchor in case FramePr_vAnchor is missing ECMA 17.3.1.11 - sal_Int16 nVAnchor = text::RelOrientation::FRAME; // 'text' - // vAlign is ignored if vAnchor is set to 'text'. So, if w:y is not defined, - // but there is a defined vAlign, then a missing vAnchor should become 'margin'. - if (!bValidY && nVertOrient) - { - nVAnchor = text::RelOrientation::PAGE_PRINT_AREA; // 'margin' + // Default the anchor in case FramePr_vAnchor is missing. + // ECMA 17.3.1.11 says "page", + // but errata documentation MS-OE376 2.1.48 Section 2.3.1.11 says "text" + // while actual testing usually indicates "margin" tdf#157572 tdf#112287 + sal_Int16 nVAnchor = text::RelOrientation::PAGE_PRINT_AREA; // 'margin' + if (!nY && (bValidY || nVertOrient == text::VertOrientation::NONE)) + { + // special cases? "auto" position defaults to "paragraph" based on testing when w:y=0 + nVAnchor = text::RelOrientation::FRAME; // 'text' } for (const auto pProp : vProps) {