Kaydet (Commit) ba5aa1e7 authored tarafından Patrick Jaap's avatar Patrick Jaap Kaydeden (comit) Miklos Vajna

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: 's avatarMiklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 4f30b2ab)
Reviewed-on: https://gerrit.libreoffice.org/70306
üst c74d2bdf
...@@ -1219,6 +1219,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") ...@@ -1219,6 +1219,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(6736947), getProperty<sal_Int32>(xStyle, "CharColor")); 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(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -3848,6 +3848,8 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t ...@@ -3848,6 +3848,8 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
{ {
FastAttributeList *attrListTablePos = FastSerializerHelper::createAttrList( ); FastAttributeList *attrListTablePos = FastSerializerHelper::createAttrList( );
uno::Sequence<beans::PropertyValue> aTablePosition = rGrabBagElement.second.get<uno::Sequence<beans::PropertyValue> >(); 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) for (sal_Int32 i = 0; i < aTablePosition.getLength(); ++i)
{ {
if (aTablePosition[i].Name == "vertAnchor" && !aTablePosition[i].Value.get<OUString>().isEmpty()) if (aTablePosition[i].Name == "vertAnchor" && !aTablePosition[i].Value.get<OUString>().isEmpty())
...@@ -3888,11 +3890,42 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t ...@@ -3888,11 +3890,42 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
} }
else if (aTablePosition[i].Name == "tblpX") 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") 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 ) );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment