summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-17 20:53:35 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-17 21:09:35 +0100
commit6820dec8903b182260340c638c35b5a5ca207a85 (patch)
tree031e66f44cb120e023791dced4fbe29d0e3c9a6d
parentde226dcfaeedf7f77de4f0242a713bc7e4462a0a (diff)
ooxml: preserve several simple types of sdt
This patch is to preserve the sdt blocks for several simple sdt types: equation, picture, citation and group. This patch reuses the infrastructure created at commit 55211e612d2cbed03dd81c039d07ea4e936c2804 to grab-bag the properties of the sdt block and write them back on export, with small modifications in particular related with the fact that these tags don't have children. The type of the property tags equation, picture, citation and group was modified in the ooxml model file to be able to process them. They were previously empty. A unit test was added to check the preservation of these fields. Another had to be modified. Change-Id: Ica1a340f589f5d6c85c1a35d2a3a4bf930eb2d8a
-rw-r--r--sw/qa/extras/ooxmlexport/data/simple-sdts.docxbin0 -> 25212 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx16
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx31
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx4
-rw-r--r--writerfilter/source/ooxml/model.xml8
5 files changed, 46 insertions, 13 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/simple-sdts.docx b/sw/qa/extras/ooxmlexport/data/simple-sdts.docx
new file mode 100644
index 000000000000..294ae7934870
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/simple-sdts.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ed5eb9654c2c..3b0728f08ef1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2805,7 +2805,7 @@ DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx")
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
- xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[3]/w:instrText");
+ xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText");
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
CPPUNIT_ASSERT(contents.match(" CITATION [Kra06]"));
@@ -2862,6 +2862,20 @@ DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx")
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin");
}
+DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+
+ if (!pXmlDoc)
+ return;
+
+ assertXPath(pXmlDoc, "/w:body/w:sdt/w:sdtPr/w:picture", 0);
+ assertXPath(pXmlDoc, "/w:body/w:sdt/w:sdtPr/w:group", 0);
+ assertXPath(pXmlDoc, "/w:body/w:sdt/w:sdtPr/w:citation", 0);
+
+}
+
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 42ca6bdbf7f5..f3c97d0b558e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -382,16 +382,23 @@ void DocxAttributeOutput::WriteParagraphSdt()
// output sdt properties
m_pSerializer->startElementNS( XML_w, XML_sdtPr, FSEND );
- m_pSerializer->startElement( m_nSdtPrToken, FSEND );
- uno::Sequence<xml::FastAttribute> aChildren = m_pSdtPrTokenChildren->getFastAttributes();
- for( sal_Int32 i=0; i < aChildren.getLength(); ++i )
- m_pSerializer->singleElement( aChildren[i].Token,
- FSNS(XML_w, XML_val),
- rtl::OUStringToOString( aChildren[i].Value, RTL_TEXTENCODING_UTF8 ).getStr(),
- FSEND );
+ if( m_pSdtPrTokenChildren )
+ {
+ m_pSerializer->startElement( m_nSdtPrToken, FSEND );
+
+ uno::Sequence<xml::FastAttribute> aChildren = m_pSdtPrTokenChildren->getFastAttributes();
+ for( sal_Int32 i=0; i < aChildren.getLength(); ++i )
+ m_pSerializer->singleElement( aChildren[i].Token,
+ FSNS(XML_w, XML_val),
+ rtl::OUStringToOString( aChildren[i].Value, RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSEND );
+
+ m_pSerializer->endElement( m_nSdtPrToken );
+ }
+ else
+ m_pSerializer->singleElement( m_nSdtPrToken, FSEND );
- m_pSerializer->endElement( m_nSdtPrToken );
m_pSerializer->endElementNS( XML_w, XML_sdtPr );
// sdt contents start tag
@@ -6889,6 +6896,14 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
AddToAttrList( m_pSdtPrTokenChildren, FSNS( XML_w, XML_docPartUnique ), "" );
}
}
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_equation")
+ m_nSdtPrToken = FSNS( XML_w, XML_equation );
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_picture")
+ m_nSdtPrToken = FSNS( XML_w, XML_picture );
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation")
+ m_nSdtPrToken = FSNS( XML_w, XML_citation );
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_group")
+ m_nSdtPrToken = FSNS( XML_w, XML_group );
}
else
SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unhandled grab bag property " << i->first );
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 7c259917dc8a..435919ec3a62 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2229,7 +2229,11 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
m_pImpl->m_pSdtHelper->getLocale().append(sStringValue);
}
break;
+ case NS_ooxml::LN_CT_SdtPr_equation:
case NS_ooxml::LN_CT_SdtPr_docPartObj:
+ case NS_ooxml::LN_CT_SdtPr_picture:
+ case NS_ooxml::LN_CT_SdtPr_citation:
+ case NS_ooxml::LN_CT_SdtPr_group:
{
// this is an unsupported SDT property, create a grab bag for it
OUString sName = OUString::createFromAscii((*QNameToString::Instance())(nSprmId).c_str());
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 417a0de7e42c..d80f2e2d1a3e 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -18855,7 +18855,7 @@
<optional>
<choice>
<element name="equation">
- <ref name="CT_Empty"/>
+ <ref name="CT_OnOff"/>
</element>
<element name="comboBox">
<ref name="CT_SdtComboBox"/>
@@ -18873,7 +18873,7 @@
<ref name="CT_SdtDropDownList"/>
</element>
<element name="picture">
- <ref name="CT_Empty"/>
+ <ref name="CT_OnOff"/>
</element>
<element name="richText">
<ref name="CT_Empty"/>
@@ -18882,10 +18882,10 @@
<ref name="CT_SdtText"/>
</element>
<element name="citation">
- <ref name="CT_Empty"/>
+ <ref name="CT_OnOff"/>
</element>
<element name="group">
- <ref name="CT_Empty"/>
+ <ref name="CT_OnOff"/>
</element>
<element name="bibliography">
<ref name="CT_Empty"/>