abi#11739 DOCX export: fix validation error, wrong order of some elements
Change-Id: Ic1c0174718ba6853fcc8795324a99b2a332b865e
This commit is contained in:
BIN
sw/qa/extras/ooxmlexport/data/abi11739.docx
Executable file
BIN
sw/qa/extras/ooxmlexport/data/abi11739.docx
Executable file
Binary file not shown.
@@ -96,6 +96,12 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes);
|
void assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the position of the child named rName of the parent node specified by rXPath.
|
||||||
|
* Useful for checking relative order of elements.
|
||||||
|
*/
|
||||||
|
int getXPathPosition(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as the assertXPath(), but don't assert: return the string instead.
|
* Same as the assertXPath(), but don't assert: return the string instead.
|
||||||
*/
|
*/
|
||||||
@@ -189,6 +195,23 @@ void Test::assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNu
|
|||||||
nNumberOfChildNodes, (int)xmlChildElementCount(pXmlNode));
|
nNumberOfChildNodes, (int)xmlChildElementCount(pXmlNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Test::getXPathPosition(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rChildName)
|
||||||
|
{
|
||||||
|
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
|
||||||
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
|
||||||
|
1,
|
||||||
|
xmlXPathNodeSetGetLength(pXmlNodes));
|
||||||
|
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
|
||||||
|
int nRet = 0;
|
||||||
|
for (xmlNodePtr pChild = pXmlNode->children; pChild; pChild = pChild->next)
|
||||||
|
{
|
||||||
|
if (OUString::createFromAscii((const char*)pChild->name) == rChildName)
|
||||||
|
break;
|
||||||
|
++nRet;
|
||||||
|
}
|
||||||
|
return nRet;
|
||||||
|
}
|
||||||
|
|
||||||
OUString Test::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
|
OUString Test::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
|
||||||
{
|
{
|
||||||
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
|
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
|
||||||
@@ -3431,6 +3454,19 @@ DECLARE_OOXMLEXPORT_TEST(testW14TextEffects, "TextEffects.docx")
|
|||||||
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:rPr/w14:glow", "rad").match("228600"));
|
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:rPr/w14:glow", "rad").match("228600"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLARE_OOXMLEXPORT_TEST(testAbi11739, "abi11739.docx")
|
||||||
|
{
|
||||||
|
// Validation test: order of elements were wrong.
|
||||||
|
xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
|
||||||
|
if (!pXmlDoc)
|
||||||
|
return;
|
||||||
|
// Order was: uiPriority, link, basedOn.
|
||||||
|
CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link"));
|
||||||
|
CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "uiPriority"));
|
||||||
|
// Order was: qFormat, unhideWhenUsed.
|
||||||
|
CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "qFormat"));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -3739,7 +3739,18 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
|
|||||||
FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
|
FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
|
||||||
FSEND );
|
FSEND );
|
||||||
|
|
||||||
// Output properties from grab-bag.
|
if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
|
||||||
|
{
|
||||||
|
m_pSerializer->singleElementNS( XML_w, XML_basedOn,
|
||||||
|
FSNS( XML_w, XML_val ), m_rExport.pStyles->GetStyleId(nBase).getStr(),
|
||||||
|
FSEND );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aLink.isEmpty())
|
||||||
|
m_pSerializer->singleElementNS(XML_w, XML_link,
|
||||||
|
FSNS(XML_w, XML_val), OUStringToOString(aLink, RTL_TEXTENCODING_UTF8).getStr(),
|
||||||
|
FSEND);
|
||||||
|
|
||||||
if (!aUiPriority.isEmpty())
|
if (!aUiPriority.isEmpty())
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
|
m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
|
||||||
FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
|
FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
|
||||||
@@ -3750,10 +3761,6 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
|
|||||||
m_pSerializer->singleElementNS(XML_w, XML_semiHidden, FSEND);
|
m_pSerializer->singleElementNS(XML_w, XML_semiHidden, FSEND);
|
||||||
if (bUnhideWhenUsed)
|
if (bUnhideWhenUsed)
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
|
m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
|
||||||
if (!aLink.isEmpty())
|
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_link,
|
|
||||||
FSNS(XML_w, XML_val), OUStringToOString(aLink, RTL_TEXTENCODING_UTF8).getStr(),
|
|
||||||
FSEND);
|
|
||||||
if (bLocked)
|
if (bLocked)
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_locked, FSEND);
|
m_pSerializer->singleElementNS(XML_w, XML_locked, FSEND);
|
||||||
if (!aRsid.isEmpty())
|
if (!aRsid.isEmpty())
|
||||||
@@ -3761,13 +3768,6 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
|
|||||||
FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
|
FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
|
||||||
FSEND);
|
FSEND);
|
||||||
|
|
||||||
if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
|
|
||||||
{
|
|
||||||
m_pSerializer->singleElementNS( XML_w, XML_basedOn,
|
|
||||||
FSNS( XML_w, XML_val ), m_rExport.pStyles->GetStyleId(nBase).getStr(),
|
|
||||||
FSEND );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( nNext != nId && eType != STYLE_TYPE_LIST)
|
if ( nNext != nId && eType != STYLE_TYPE_LIST)
|
||||||
{
|
{
|
||||||
m_pSerializer->singleElementNS( XML_w, XML_next,
|
m_pSerializer->singleElementNS( XML_w, XML_next,
|
||||||
|
@@ -618,12 +618,12 @@ void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>&
|
|||||||
m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
|
m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
|
||||||
FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
|
FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
|
||||||
FSEND);
|
FSEND);
|
||||||
if (bQFormat)
|
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
|
|
||||||
if (bSemiHidden)
|
if (bSemiHidden)
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_semiHidden, FSEND);
|
m_pSerializer->singleElementNS(XML_w, XML_semiHidden, FSEND);
|
||||||
if (bUnhideWhenUsed)
|
if (bUnhideWhenUsed)
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
|
m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
|
||||||
|
if (bQFormat)
|
||||||
|
m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
|
||||||
if (!aRsid.isEmpty())
|
if (!aRsid.isEmpty())
|
||||||
m_pSerializer->singleElementNS(XML_w, XML_rsid,
|
m_pSerializer->singleElementNS(XML_w, XML_rsid,
|
||||||
FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
|
FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
|
||||||
|
Reference in New Issue
Block a user