sw/qa/extras/ooxmlexport/data/tdf112287B.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 9 +++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-)
New commits: commit 630732bfd8ed531e9d412a36a083f33763def054 Author: Justin Luth <[email protected]> AuthorDate: Sat Mar 11 13:16:56 2023 -0500 Commit: Justin Luth <[email protected]> CommitDate: Tue Mar 14 12:02:24 2023 +0000 tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default This patch depends on previous patches for tdf#154129. yAlign takes precedence over w:y. HOWEVER, there is a clause in the documentation that complicates everything. "If [yAlign is] specified, the position for this attribute supersedes any value which is specified in the y attribute, and that value is ignored, UNLESS the vAnchor is set to 'text', in which case any relative positioning is not allowed, and [yAlign] is itself ignored" So if vAnchor is not defined, it defaults to text (FRAME), but if yAlign is defined then it should mean margin (or else yAlign has no meaning), unless of course w:y is also defined, in which case "text" anchor has meaning again and this unit test shows that w:y wins out in this case. The anchor is not affected by wrapping. [P.S. This was already set correctly in the code, but worth noting: "The standard states that the default value for the vAnchor attribute is page. Word uses a default value of 'text' for this attribute."] make CppunitTest_sw_ooxmlexport5 CPPUNIT_TEST_NAME=testTdf112287 make CppunitTest_sw_ooxmlexport5 CPPUNIT_TEST_NAME=testTdf112287B Change-Id: I953afa89e3c0974a16d43500ce590e1a481c2251 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148691 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf112287B.docx b/sw/qa/extras/ooxmlexport/data/tdf112287B.docx new file mode 100644 index 000000000000..945d3d026b19 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf112287B.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index f33013413a1c..adfaca7aaf0f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -1418,6 +1418,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf112287) assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf112287B) +{ + loadAndSave("tdf112287B.docx"); + xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); + + assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","text"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[1]/w:pPr/w:framePr","hAnchor","text"); +} + CPPUNIT_TEST_FIXTURE(Test, testZOrderInHeader) { loadAndSave("tdf120760_ZOrderInHeader.docx"); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index fad1efd9ead3..3fcabf1ccb37 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1718,8 +1718,9 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( ) //Default the anchor in case FramePr_vAnchor is missing ECMA 17.3.1.11 sal_Int16 nVAnchor = text::RelOrientation::FRAME; // 'text' - if (rAppendContext.pLastParagraphProperties->GetWrap() != text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE || - pStyleProperties->props().GetWrap() != text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE) + // 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' }
