summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ooxmlexport/data/table-position-15.docxbin13683 -> 12264 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docxbin0 -> 4698 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport10.cxx26
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx3
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx13
6 files changed, 39 insertions, 11 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/table-position-15.docx b/sw/qa/extras/ooxmlexport/data/table-position-15.docx
index d3dcaec40e78..91fbdbef00a2 100644
--- a/sw/qa/extras/ooxmlexport/data/table-position-15.docx
+++ b/sw/qa/extras/ooxmlexport/data/table-position-15.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx b/sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx
new file mode 100644
index 000000000000..0456fe206edb
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf119760_tableInTablePosition.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 1057ab93485c..f19a95342714 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1192,7 +1192,8 @@ DECLARE_OOXMLEXPORT_TEST(testTableMarginAdjustment, "table.fodt")
// (old) Word: margin 0 means paragraph in table starts at 0
auto const xTable(getParagraphOrTable(1));
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTable, "LeftMargin"));
+ // shifted very slightly to account for half of the thin border width, so 4, not 0.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), getProperty<sal_Int32>(xTable, "LeftMargin"));
// Now that compatibilityMode is set to 2013's 15 (new), expect the new values,
// since LO is exporting in the NEW way now instead of the OLD way.
@@ -1204,6 +1205,24 @@ DECLARE_OOXMLEXPORT_TEST(testTableMarginAdjustment, "table.fodt")
assertXPath(pXmlDoc, "//w:tbl[1]/w:tblPr[1]/w:tblInd[1]", "w", "0");
}
+DECLARE_OOXMLEXPORT_TEST(testTdf119760_tableInTablePosition, "tdf119760_tableInTablePosition.docx")
+{
+ if ( mbExported )
+ {
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+
+ assertXPath(pXmlDoc, "//w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tblPr[1]/w:tblInd[1]", "type", "dxa");
+ assertXPath(pXmlDoc, "//w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]//w:tblPr[1]/w:tblInd[1]", "w", "0");
+ }
+
+ uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY );
+ uno::Reference< container::XIndexAccess > xTables( xTablesSupplier->getTextTables(), uno::UNO_QUERY );
+ uno::Reference< text::XTextTable > xTable( xTables->getByIndex(0), uno::UNO_QUERY );
+ // For compatibilityMode 15: margin 0 means table border starts at 0,
+ // shifted to account for half of the thick border width, so 106, not 0.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(106), getProperty<sal_Int32>(xTable, "LeftMargin"));
+}
+
DECLARE_OOXMLEXPORT_TEST( testTableCellMargin, "table-cell-margin.docx" )
{
sal_Int32 const cellLeftMarginFromOffice[] = { 250, 100, 0, 0 };
@@ -1268,10 +1287,11 @@ DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" )
}
}
-// tdf#106742 for DOCX with compatibility level > 14 (MS Word since ver.2013), we should NOT use cell margins when calculating table left border position
+// tdf#106742 for DOCX with compatibility level > 14 (MS Word since ver.2013),
+// we should NOT use cell margins when calculating table left border position. But we do need to use border width.
DECLARE_OOXMLEXPORT_TEST( testTablePosition15, "table-position-15.docx" )
{
- sal_Int32 const aXCoordsFromOffice[] = { 2751, -899, 1, 106 };
+ sal_Int32 const aXCoordsFromOffice[] = { 2751, -899, 1, 212 };
uno::Reference< text::XTextTablesSupplier > xTablesSupplier( mxComponent, uno::UNO_QUERY );
uno::Reference< frame::XModel > xModel( mxComponent, uno::UNO_QUERY );
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 5e758f642624..7369dac8f1a7 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -495,8 +495,9 @@ DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx")
uno::Any aValue = xTableProperties->getPropertyValue("LeftMargin");
sal_Int32 nLeftMargin;
aValue >>= nLeftMargin;
+ // only border width considered.
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Left margin shouldn't take tableCellMar into account in nested tables",
- sal_Int32(0), nLeftMargin);
+ sal_Int32(9), nLeftMargin);
/*
* Another problem tested with this document is the unnecessary loading of the shapes
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8505571f545d..a8ed8e88a47d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4091,11 +4091,13 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
// LO uses a higher compatibility than 2010's 14.
sal_Int32 nMode = lcl_getWordCompatibilityMode( *m_rExport.m_pDoc );
+ const SwFrameFormat* pFrameFormat = pTableTextNodeInfoInner->getTableBox()->GetFrameFormat();
if ((0 < nMode && nMode <= 14) && m_tableReference->m_nTableDepth == 0)
+ nIndent += pFrameFormat->GetBox().GetDistance( SvxBoxItemLine::LEFT );
+ else
{
- const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
- const SwFrameFormat* pFrameFormat = pTabBox->GetFrameFormat();
- nIndent += sal_Int32( pFrameFormat->GetBox().GetDistance( SvxBoxItemLine::LEFT ) );
+ // adjust for SW considering table to start mid-border instead of nested/2013's left-side-of-border.
+ nIndent -= pFrameFormat->GetBox().CalcLineWidth( SvxBoxItemLine::LEFT ) / 2;
}
break;
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index b5a737d626b7..b7151f26cb9f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -595,8 +595,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
// - nested tables: the goal is to have left-most border starting at table_indent pos
// Only top level table position depends on border width of Column A.
- // TODO: Position based on last row (at least in MSOffice 2016), but first row in Office 2003.
- // Export code is also based on first cell, so using first row here...
if ( !m_aCellProperties.empty() && !m_aCellProperties[0].empty() )
{
// aLeftBorder already contains tblBorder; overwrite if cell is different.
@@ -623,11 +621,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
if (((nMode < 0) || (0 < nMode && nMode <= 14)) && rInfo.nNestLevel == 1)
{
- m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance ) );
+ const sal_Int32 nAdjustedMargin = nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance;
+ m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nAdjustedMargin ) );
}
else
{
- m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf ) );
+ // Writer starts a table in the middle of the border.
+ // Word starts a table at the left edge of the border,
+ // so emulate that by adding the half the width. (also see docxattributeoutput)
+ if ( rInfo.nNestLevel > 1 && nLeftMargin < 0 )
+ nLeftMargin = 0;
+ const sal_Int32 nAdjustedMargin = nLeftMargin - nGapHalf + (aLeftBorder.LineWidth / 2);
+ m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nAdjustedMargin ) );
}
sal_Int32 nTableWidth = 0;