summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-08-27 21:22:01 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-09-14 09:07:36 +0200
commit65c43d97f3f03e944c6bc35eb44a1ebcde31094e (patch)
treee850e64e182f4b8bc84f87fa7e8eca23a367d04f
parent515f97e3dd279ca8487f6f6038045511f0e1db51 (diff)
tdf#82177 docx export: eliminate invalid tbl insideV/H borders
Inherited from OOo, these insideV/H borders incorrectly assume that every inside border will match the bottom/right border of cell A1. For the most part this error is harmless since every cell specifies every border anyway (that doesn't match a table-style default). The only time it is visible is when insideV/H specifies a border, but none is set on the cell. The problem is that these pseudo-defaults are not passed to the cellborders function as defaults, so cells have no idea whether they need to override these values or not. Since the implementation is completely flawed and unnecessary, simply eliminate it. (TODO: In fact, the entire tblBorders output is flawed, as demonstrated by the outside borders in the unit test.) One unit test is removed since insideV/H is no longer being written (this was just a "lets specify what we see being written out" test, not one concerned specifically with insideV/H. Not enforcing the absence of insideV/H because theoretically someone could legitimately add zero-width borders to the table borders and still be valid. The ordering of the borders test was moved from a table borders test (no longer created) to a styles border (which is still valid - a grabbag dump.) Change-Id: Ie6786a66fe88d2c7e3bdcff8fda3b4f77cb988d7 Reviewed-on: https://gerrit.libreoffice.org/59675 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf82177_tblBorders.docxbin0 -> 9673 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx10
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx11
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx10
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx10
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx27
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx1
7 files changed, 20 insertions, 49 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf82177_tblBorders.docx b/sw/qa/extras/ooxmlexport/data/tdf82177_tblBorders.docx
new file mode 100644
index 000000000000..88a237cf69c2
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf82177_tblBorders.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 35209c0cecc3..c7400b974394 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -527,6 +527,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82177_insideCellBorders, "tdf82177_insideCellBor
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "LeftBorder").LineWidth);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf82177_tblBorders, "tdf82177_tblBorders.docx")
+{
+ 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 );
+ uno::Reference< table::XCell > xCell = xTable->getCellByName( "E5" );
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "TopBorder").LineWidth);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), getProperty<table::BorderLine2>(xCell, "LeftBorder").LineWidth);
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx")
{
// This was 0, relative size of shape after bitmap was ignored.
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 6da4c52fb83d..5e1ce6a70ffe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -345,17 +345,6 @@ DECLARE_OOXMLEXPORT_TEST(testMathVerticalStacks, "math-vertical_stacks.docx")
DECLARE_OOXMLEXPORT_TEST(testTable, "table.odt")
{
- // Validation test: order of elements were wrong.
- xmlDocPtr pXmlDoc = parseExport("word/document.xml");
- if (!pXmlDoc)
- return;
- // Order was: insideH, end, insideV.
- int nEnd = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "end");
- int nInsideH = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideH");
- int nInsideV = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideV");
- CPPUNIT_ASSERT(nEnd < nInsideH);
- CPPUNIT_ASSERT(nInsideH < nInsideV);
-
// Make sure we write qFormat for well-known style names.
assertXPath(parseExport("word/styles.xml"), "//w:style[@w:styleId='Normal']/w:qFormat", 1);
}
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 809ff6ecb88f..858f20d0e3b9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -680,16 +680,6 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx")
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:space = 0]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:color = '000000']", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:val = 'single']",1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:sz = 4]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:color = '000000']", 1);
-
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:val = 'single']",1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:sz = 4]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:color = '000000']", 1);
-
//Table Cell Borders
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:sz = 4]", 1);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index fbe0c2339b6b..750a3cc24e07 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -172,6 +172,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf79272_strictDxa, "tdf79272_strictDxa.docx")
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(4318), getProperty<sal_Int32>(xTables->getByIndex(0), "Width"));
+
+ xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
+ if (!pXmlDoc)
+ return;
+ // Validation test: order of elements was wrong. Order was: insideH, end, insideV.
+ int nEnd = getXPathPosition(pXmlDoc, "/w:styles/w:style[@w:styleId='TableGrid']/w:tblPr/w:tblBorders", "end");
+ int nInsideH = getXPathPosition(pXmlDoc, "/w:styles/w:style[@w:styleId='TableGrid']/w:tblPr/w:tblBorders", "insideH");
+ int nInsideV = getXPathPosition(pXmlDoc, "/w:styles/w:style[@w:styleId='TableGrid']/w:tblPr/w:tblBorders", "insideV");
+ CPPUNIT_ASSERT(nEnd < nInsideH);
+ CPPUNIT_ASSERT(nInsideH < nInsideV);
}
DECLARE_OOXMLEXPORT_TEST(testTdf109306, "tdf109306.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2d4816c50b66..505ea1b74f8a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3031,7 +3031,6 @@ static OutputBorderOptions lcl_getTableDefaultBorderOptions(bool bEcma)
rOptions.tag = XML_tblBorders;
rOptions.bUseStartEnd = !bEcma;
rOptions.bWriteTag = true;
- rOptions.bWriteInsideHV = true;
rOptions.bWriteDistance = false;
return rOptions;
@@ -3044,7 +3043,6 @@ static OutputBorderOptions lcl_getTableCellBorderOptions(bool bEcma)
rOptions.tag = XML_tcBorders;
rOptions.bUseStartEnd = !bEcma;
rOptions.bWriteTag = true;
- rOptions.bWriteInsideHV = false;
rOptions.bWriteDistance = false;
return rOptions;
@@ -3057,7 +3055,6 @@ static OutputBorderOptions lcl_getBoxBorderOptions()
rOptions.tag = XML_pBdr;
rOptions.bUseStartEnd = false;
rOptions.bWriteTag = false;
- rOptions.bWriteInsideHV = false;
rOptions.bWriteDistance = true;
return rOptions;
@@ -3084,8 +3081,6 @@ static void impl_borders( FSHelperPtr const & pSerializer,
bool tagWritten = false;
const SvxBoxItemLine* pBrd = aBorders;
- bool bWriteInsideH = false;
- bool bWriteInsideV = false;
for( int i = 0; i < 4; ++i, ++pBrd )
{
const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
@@ -3150,28 +3145,6 @@ static void impl_borders( FSHelperPtr const & pSerializer,
}
impl_borderLine( pSerializer, aXmlElements[i], pLn, nDist, bWriteShadow, aStyleProps );
-
- // When exporting default borders, we need to export these 2 attr
- if ( rOptions.bWriteInsideHV) {
- if ( i == 2 )
- bWriteInsideH = true;
- else if ( i == 3 )
- bWriteInsideV = true;
- }
- }
- if (bWriteInsideH)
- {
- const table::BorderLine2 *aStyleProps = nullptr;
- if( rTableStyleConf.find( SvxBoxItemLine::BOTTOM ) != rTableStyleConf.end() )
- aStyleProps = &rTableStyleConf[ SvxBoxItemLine::BOTTOM ];
- impl_borderLine( pSerializer, XML_insideH, rBox.GetLine(SvxBoxItemLine::BOTTOM), 0, false, aStyleProps );
- }
- if (bWriteInsideV)
- {
- const table::BorderLine2 *aStyleProps = nullptr;
- if( rTableStyleConf.find( SvxBoxItemLine::RIGHT ) != rTableStyleConf.end() )
- aStyleProps = &rTableStyleConf[ SvxBoxItemLine::RIGHT ];
- impl_borderLine( pSerializer, XML_insideV, rBox.GetLine(SvxBoxItemLine::RIGHT), 0, false, aStyleProps );
}
if (tagWritten && rOptions.bWriteTag) {
pSerializer->endElementNS( XML_w, rOptions.tag );
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 89263c239d6a..7f647ed52973 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -84,7 +84,6 @@ struct OutputBorderOptions
sal_Int32 tag = 0;
bool bUseStartEnd = false;
bool bWriteTag = true;
- bool bWriteInsideHV = false;
bool bWriteDistance = false;
SvxShadowLocation aShadowLocation = SvxShadowLocation::NONE;
std::shared_ptr<editeng::WordBorderDistances> pDistances;