diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf154703_framePrWrapSpacing.docx | bin | 0 -> 13991 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 21 |
3 files changed, 25 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf154703_framePrWrapSpacing.docx b/sw/qa/extras/ooxmlexport/data/tdf154703_framePrWrapSpacing.docx Binary files differnew file mode 100644 index 000000000000..57a9bea5a174 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf154703_framePrWrapSpacing.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 171826175e0b..72cfe1723870 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -233,6 +233,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePr2, "tdf154703_framePr2.rtf") assertXPath(pXmlDoc, "//w:body/w:p[3]/w:pPr/w:shd", "fill", "800000"); } +DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePrWrapSpacing, "tdf154703_framePrWrapSpacing.docx") +{ + CPPUNIT_ASSERT_EQUAL(2, getPages()); + if (!isExported()) + return; + + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // before the fix, this was half of the correct value. + assertXPath(pXmlDoc, "//w:body/w:p/w:pPr/w:framePr", "hSpace", "2552"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, "tdf153613_anchoredAfterPgBreak.docx") { const auto& pLayout = parseLayoutDump(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 43cfa953a041..94ed8bac2ba9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -933,24 +933,31 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor attrList->add( FSNS( XML_w, XML_x), OString::number(aPos.X)); attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y)); + OString aXAlign = convertToOOXMLHoriOrient(rHoriOrient.GetHoriOrient(), /*bIsPosToggle=*/false); + OString aYAlign = convertToOOXMLVertOrient(rVertOrient.GetVertOrient()); + if (!aXAlign.isEmpty()) + attrList->add(FSNS(XML_w, XML_xAlign), aXAlign); + if (!aYAlign.isEmpty()) + attrList->add(FSNS(XML_w, XML_yAlign), aYAlign); + sal_Int16 nLeft = pFrameFormat->GetLRSpace().GetLeft(); sal_Int16 nRight = pFrameFormat->GetLRSpace().GetRight(); sal_Int16 nUpper = pFrameFormat->GetULSpace().GetUpper(); sal_Int16 nLower = pFrameFormat->GetULSpace().GetLower(); + // To emulate, on import left was ignored (set to zero) if aligned to left, + // so just double up the right spacing in order to prevent cutting in half each round-trip. + if (rHoriOrient.GetHoriOrient() == text::HoriOrientation::LEFT) + nLeft = nRight; + else if (rHoriOrient.GetHoriOrient() == text::HoriOrientation::RIGHT) + nRight = nLeft; + attrList->add(FSNS(XML_w, XML_hSpace), OString::number((nLeft + nRight) / 2)); attrList->add(FSNS(XML_w, XML_vSpace), OString::number((nUpper + nLower) / 2)); OString relativeFromH = convertToOOXMLHoriOrientRel(rHoriOrient.GetRelationOrient()); OString relativeFromV = convertToOOXMLVertOrientRel(rVertOrient.GetRelationOrient()); - OString aXAlign = convertToOOXMLHoriOrient(rHoriOrient.GetHoriOrient(), /*bIsPosToggle=*/false); - OString aYAlign = convertToOOXMLVertOrient(rVertOrient.GetVertOrient()); - if (!aXAlign.isEmpty()) - attrList->add(FSNS(XML_w, XML_xAlign), aXAlign); - if (!aYAlign.isEmpty()) - attrList->add(FSNS(XML_w, XML_yAlign), aYAlign); - switch (pFrameFormat->GetSurround().GetValue()) { case css::text::WrapTextMode_NONE: |