sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 11 ++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 37 +++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-)
New commits: commit ba5aa1e7ddf0e538132bacae059a66a3802f5693 Author: Patrick Jaap <patrick.j...@tu-dresden.de> AuthorDate: Thu Feb 14 10:00:36 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 10 11:52:26 2019 +0200 FIX: Use correct table x/y postion in docx export Until now we exported the original x/y position values of the table from the grabbag. Ignoring users actions like moving the table around. Now, we compute the position from the parent frame and write the actual position in the docx file. Change-Id: I25a09f9c7c8fbe49acbd19e2b1440c7fa90b8aff Reviewed-on: https://gerrit.libreoffice.org/67969 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 4f30b2ab729eb7f024e8078acbc099b25f588e9f) Reviewed-on: https://gerrit.libreoffice.org/70306 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 70fb4a16a73e..f3faf8cfab15 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1219,6 +1219,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(6736947), getProperty<sal_Int32>(xStyle, "CharColor")); } +DECLARE_OOXMLEXPORT_TEST(testDocxTablePosition, "floating-table-position.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + // the exported positions were wrong due to some missing shifting in the export code + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpX", "3494"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", "4611"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index dfb12d1cc25e..7d6a618b554f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3848,6 +3848,8 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t { FastAttributeList *attrListTablePos = FastSerializerHelper::createAttrList( ); uno::Sequence<beans::PropertyValue> aTablePosition = rGrabBagElement.second.get<uno::Sequence<beans::PropertyValue> >(); + // look for a surrounding frame and take it's position values + const ww8::Frame* pFrame = m_rExport.GetFloatingTableFrame(); for (sal_Int32 i = 0; i < aTablePosition.getLength(); ++i) { if (aTablePosition[i].Name == "vertAnchor" && !aTablePosition[i].Value.get<OUString>().isEmpty()) @@ -3888,11 +3890,42 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t } else if (aTablePosition[i].Name == "tblpX") { - attrListTablePos->add( FSNS( XML_w, XML_tblpX ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + sal_Int32 nValue = 0; + if (pFrame) + { + nValue = pFrame->GetFrameFormat().GetHoriOrient().GetPos(); + // we need to revert the additional shift introduced by + // lcl_DecrementHoriOrientPosition() in writerfilter + // 1st: left distance of the table + const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); + const SwFrameFormat * pFrameFormat = pTabBox->GetFrameFormat(); + const SvxBoxItem& rBox = pFrameFormat->GetBox( ); + sal_uInt16 nLeftDistance = rBox.GetDistance(SvxBoxItemLine::LEFT); + nValue += nLeftDistance; + + // 2nd: if a left border is given, revert the shift by half the width + // from lcl_DecrementHoriOrientPosition() in writerfilter + if (const editeng::SvxBorderLine* pLeftBorder = rBox.GetLeft()) + { + long nWidth = pLeftBorder->GetWidth(); + nValue += (nWidth / 2); + } + } + else + nValue = aTablePosition[i].Value.get<sal_Int32>(); + + attrListTablePos->add( FSNS( XML_w, XML_tblpX ), OString::number( nValue ) ); } else if (aTablePosition[i].Name == "tblpY") { - attrListTablePos->add( FSNS( XML_w, XML_tblpY ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) ); + sal_Int32 nValue = 0; + if (pFrame) + // no additional shift occur (like in the tblpX case) + nValue = pFrame->GetFrameFormat().GetVertOrient().GetPos(); + else + nValue = aTablePosition[i].Value.get<sal_Int32>(); + + attrListTablePos->add( FSNS( XML_w, XML_tblpY ), OString::number( nValue ) ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits