Kaydet (Commit) c2cc6333 authored tarafından Joren De Cuyper's avatar Joren De Cuyper

Don't write empty vertAnchor, HorzAnchor, tblpYSpec and tblpXSpec attributes

This attributes needs a value from the enumeration.
See http://dev-builds.libreoffice.org/crashtest/6183a945de03dcd5fe0b967d5814a0add954a8c8/validation/docx/fdo43632-1.docx.log :

(word/document.xml:2 col:70,187) cvc-enumeration-valid: Value '' is not facet-valid with respect to enumeration
'[inline, top, center, bottom, inside, outside]'. It must be a value from the enumeration.
(word/document.xml:2 col:70,187) cvc-attribute.3: The value '' of attribute 'w:tblpYSpec' on element 'w:tblpPr'
is not valid with respect to its type, 'ST_YAlign'.

Change-Id: Ibe4ccdf1c273e2ede22dc8865ec91af4de162e10
Reviewed-on: https://gerrit.libreoffice.org/15693Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJoren De Cuyper <jorendc@libreoffice.org>
üst 1f43eab4
...@@ -234,6 +234,8 @@ DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx") ...@@ -234,6 +234,8 @@ DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx")
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266"); assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266");
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page"); assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page");
//make sure not to write empty attributes which requires enumeration
assertXPathNoAttribute(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpYSpec");
} }
DECLARE_OOXMLEXPORT_TEST(testOldComplexMergeRight, "tdf90681-1.odt") DECLARE_OOXMLEXPORT_TEST(testOldComplexMergeRight, "tdf90681-1.odt")
......
...@@ -3224,22 +3224,22 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t ...@@ -3224,22 +3224,22 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
uno::Sequence<beans::PropertyValue> aTablePosition = aGrabBagElement->second.get<uno::Sequence<beans::PropertyValue> >(); uno::Sequence<beans::PropertyValue> aTablePosition = aGrabBagElement->second.get<uno::Sequence<beans::PropertyValue> >();
for (sal_Int32 i = 0; i < aTablePosition.getLength(); ++i) for (sal_Int32 i = 0; i < aTablePosition.getLength(); ++i)
{ {
if (aTablePosition[i].Name == "vertAnchor") if (aTablePosition[i].Name == "vertAnchor" && aTablePosition[i].Value.get<OUString>() != "")
{ {
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_vertAnchor ), strTemp.getStr() ); attrListTablePos->add( FSNS( XML_w, XML_vertAnchor ), strTemp.getStr() );
} }
else if (aTablePosition[i].Name == "tblpYSpec") else if (aTablePosition[i].Name == "tblpYSpec" && aTablePosition[i].Value.get<OUString>() != "")
{ {
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), strTemp.getStr() ); attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), strTemp.getStr() );
} }
else if (aTablePosition[i].Name == "horzAnchor") else if (aTablePosition[i].Name == "horzAnchor" && aTablePosition[i].Value.get<OUString>() != "")
{ {
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), strTemp.getStr() ); attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), strTemp.getStr() );
} }
else if (aTablePosition[i].Name == "tblpXSpec") else if (aTablePosition[i].Name == "tblpXSpec" && aTablePosition[i].Value.get<OUString>() != "")
{ {
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8); OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), strTemp.getStr() ); attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), strTemp.getStr() );
......
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