diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-16 10:46:38 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-16 11:29:35 +0200 |
commit | b2bc4ea8ddae6b01f344469d988e21fed3143c42 (patch) | |
tree | 2a9adbab7706d1b79d78b173a8724cfcbb921340 /sw | |
parent | 1fcbc55b284463a3613849caa43c2e9c82aced1c (diff) |
DOCX import: handle SDT around citation field
There were two problems here:
1) Citation field was around a run, but was exported as around the
paragraph.
2) The SDT properties were discarded, as they were inserted into a
character context that was thrown away. To fix this, add a (character
properties) context to the field state, so when it's inserted, it can
have the requested properties.
Change-Id: Ic36deff616060f049147874633c6c7264ae8ecf2
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx | bin | 0 -> 12817 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 23 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 2 |
3 files changed, 19 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx b/sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx Binary files differnew file mode 100644 index 000000000000..cd97f934a1ca --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 646bf57601a1..0e69a541540c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2903,7 +2903,7 @@ DECLARE_OOXMLEXPORT_TEST(test_FieldType, "99_Fields.docx") // Checking for three field types (BIBLIOGRAPHY, BIDIOUTLINE, CITATION) in sequence assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:r[2]/w:instrText[1]",1); assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[5]/w:r[2]/w:instrText[1]",1); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:sdt/w:sdtContent/w:p/w:r[2]/w:instrText[1]",1); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p/w:sdt/w:sdtContent/w:r[2]/w:instrText[1]",1); } DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx") @@ -3002,8 +3002,8 @@ DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx") xmlDocPtr pXmlDoc = parseExport(); if (!pXmlDoc) return; - assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText", " CITATION Kra06 \\l 1033 "); - assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[5]/w:t", "(Kramer & Chen, 2006)"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:sdt/w:sdtContent/w:r[2]/w:instrText", " CITATION Kra06 \\l 1033 "); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:sdt/w:sdtContent/w:r[4]/w:t", "(Kramer & Chen, 2006)"); } DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx") @@ -3101,11 +3101,11 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx") if (!pXmlDoc) return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:text", 1); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:id", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:sdt/w:sdtPr/w:text", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:sdt/w:sdtPr/w:id", 1); assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:picture", 1); assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:group", 1); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:citation", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:citation", 1); } @@ -3799,6 +3799,17 @@ DECLARE_OOXMLEXPORT_TEST(testfdo81031, "fdo81031.docx") CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(148), xBitmap->getSize().Height ); } +DECLARE_OOXMLEXPORT_TEST(testSdtCitationRun, "sdt-citation-run.docx") +{ + // The problem was that the SDT was around the whole paragraph, not only around the citation field. + if (xmlDocPtr pXmlDoc = parseExport()) + { + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:t", "Before sdt."); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:instrText", " CITATION BBC11 \\l 1033 "); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:t", "After sdt."); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 30179bbc74b7..92e4a963a198 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7828,6 +7828,8 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem ) else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id" && m_nRunSdtPrToken == 0) // only write id token as a marker if no other exist m_nRunSdtPrToken = FSNS( XML_w, XML_id ); + else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation") + m_nRunSdtPrToken = FSNS( XML_w, XML_citation ); } } else |