diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-10 15:55:44 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-10 17:53:36 +0200 |
commit | ef01eef6165defc6850fda6a557549e6d34c43f1 (patch) | |
tree | 945d43c21c251f47aa30bb1c8ccb3ffe4aa840a3 /sw | |
parent | 06a39e43296d76097ad5288c0e8b9e2869e6644e (diff) |
DOCX export: handle character format of dateTime SDT
The trick is that this logic has been already implemented for table
styles, so just reuse that.
Change-Id: I5b094fece244da8cf0857ce829a54aa7c124e280
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx | bin | 0 -> 12924 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxtablestyleexport.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxtablestyleexport.hxx | 7 |
5 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx b/sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx Binary files differnew file mode 100644 index 000000000000..22c4d4e1f8c3 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/sdt-date-charformat.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d15680545afc..796439c3d929 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3760,6 +3760,13 @@ DECLARE_OOXMLEXPORT_TEST(testSdtAlias, "sdt-alias.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:alias", "val", "Subtitle"); } +DECLARE_OOXMLEXPORT_TEST(testSdtDateCharformat, "sdt-date-charformat.docx") +{ + if (xmlDocPtr pXmlDoc = parseExport()) + // character formatting (bold) was missing, this was 0 + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:rPr/w:b", 1); +} + 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 2026ddd19028..ddd23790ec58 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4204,6 +4204,7 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) OUString sLocale("en-US"); uno::Sequence<beans::PropertyValue> aGrabBag; uno::Reference<beans::XPropertySet> xShapePropertySet(pFormObj->getUnoShape(), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aCharFormat; if (xShapePropertySet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= aGrabBag) { for (sal_Int32 i=0; i < aGrabBag.getLength(); ++i) @@ -4222,6 +4223,8 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) aOriginalDate.SetMonth(aUNODate.Month); aOriginalDate.SetYear(aUNODate.Year); } + else if (aGrabBag[i].Name == "CharFormat") + aGrabBag[i].Value >>= aCharFormat; } } uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); @@ -4282,6 +4285,13 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) m_pSerializer->startElementNS(XML_w, XML_sdtContent, FSEND); m_pSerializer->startElementNS(XML_w, XML_r, FSEND); + + if (aCharFormat.hasElements()) + { + m_pTableStyleExport->SetSerializer(m_pSerializer); + m_pTableStyleExport->CharFormat(aCharFormat); + } + RunText(aContentText); m_pSerializer->endElementNS(XML_w, XML_r); m_pSerializer->endElementNS(XML_w, XML_sdtContent); diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx index c080ba0660b7..e431da9420fb 100644 --- a/sw/source/filter/ww8/docxtablestyleexport.cxx +++ b/sw/source/filter/ww8/docxtablestyleexport.cxx @@ -67,6 +67,11 @@ struct DocxTableStyleExport::Impl void tableStyleRColor(uno::Sequence<beans::PropertyValue>& rColor); }; +void DocxTableStyleExport::CharFormat(css::uno::Sequence<css::beans::PropertyValue>& rRPr) +{ + m_pImpl->tableStyleRPr(rRPr); +} + void DocxTableStyleExport::TableStyles(sal_uInt16 nCountStylesToWrite) { // Do we have table styles from InteropGrabBag available? diff --git a/sw/source/filter/ww8/docxtablestyleexport.hxx b/sw/source/filter/ww8/docxtablestyleexport.hxx index f506ae3254ca..78d520951aca 100644 --- a/sw/source/filter/ww8/docxtablestyleexport.hxx +++ b/sw/source/filter/ww8/docxtablestyleexport.hxx @@ -11,6 +11,9 @@ #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXTABLESTYLEEXPORT_HXX #include <boost/shared_ptr.hpp> + +#include <com/sun/star/beans/PropertyValue.hpp> + #include <sax/fshelper.hxx> class SwDoc; @@ -22,6 +25,10 @@ class DocxTableStyleExport boost::shared_ptr<Impl> m_pImpl; public: void TableStyles(sal_uInt16 nCountStylesToWrite); + + /// Writes <w:rPr>...</w:rPr> based on grab-bagged character properties. + void CharFormat(css::uno::Sequence<css::beans::PropertyValue>& rRPr); + void SetSerializer(sax_fastparser::FSHelperPtr pSerializer); DocxTableStyleExport(SwDoc* pDoc, sax_fastparser::FSHelperPtr pSerializer); ~DocxTableStyleExport(); |