summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-22 21:11:33 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-22 23:58:16 +0100
commit8931ab3fc27acb0665fa636eb6390034cbb3eec6 (patch)
tree75ba94d916c9cc0579e4995ae3bd5d644caecbc0 /writerfilter
parent452469f1b825ac4dfa2b9b096175f7cfc9a1aa36 (diff)
ooxml: preserve rich text sdt controls
These controls don't have a special property, like for example unformatted text controls have. So we use the id property as a marker; we will grab-bag it together with other sdt properties and use the existing mechanism to write the sdt block on export. A grab bag that only contains an id property is for sure a rich text control so we add it to the character props and not to the paragraph props, like in the case of the unformatted text control. Word doesn't allow us to write an empty <w:id/> tag, so we fill it with a random number. Finally, modified an existing unit test to add a rich text control and check it is exported correctly. Change-Id: If403a4a2393d4ee069a628645e364d21f104a859
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx5
-rw-r--r--writerfilter/source/dmapper/SdtHelper.cxx5
-rw-r--r--writerfilter/source/dmapper/SdtHelper.hxx1
3 files changed, 10 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index ed3dc13953b5..f36db6570a0b 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2251,6 +2251,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
case NS_ooxml::LN_CT_SdtPr_citation:
case NS_ooxml::LN_CT_SdtPr_group:
case NS_ooxml::LN_CT_SdtPr_text:
+ case NS_ooxml::LN_CT_SdtPr_id:
{
// this is an unsupported SDT property, create a grab bag for it
OUString sName = OUString::createFromAscii((*QNameToString::Instance())(nSprmId).c_str());
@@ -2669,7 +2670,9 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
// save them in the paragraph interop grab bag
if(m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_checkbox") ||
m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_text") ||
- m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_dataBinding"))
+ m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_dataBinding") ||
+ (m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_id") &&
+ m_pImpl->m_pSdtHelper->getInteropGrabBagSize() == 1))
m_pImpl->GetTopContextOfType(CONTEXT_CHARACTER)->Insert(PROP_SDTPR,
uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, CHAR_GRAB_BAG);
else
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index daf9b81455da..22f11986fef7 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -215,6 +215,11 @@ bool SdtHelper::isInteropGrabBagEmpty()
return m_aGrabBag.getLength() == 0;
}
+sal_Int32 SdtHelper::getInteropGrabBagSize()
+{
+ return m_aGrabBag.getLength();
+}
+
bool SdtHelper::containedInInteropGrabBag(OUString rValueName)
{
for (sal_Int32 i=0; i < m_aGrabBag.getLength(); ++i)
diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx
index a69628729ad2..cfdd875e7b6b 100644
--- a/writerfilter/source/dmapper/SdtHelper.hxx
+++ b/writerfilter/source/dmapper/SdtHelper.hxx
@@ -88,6 +88,7 @@ public:
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getInteropGrabBagAndClear();
bool isInteropGrabBagEmpty();
bool containedInInteropGrabBag(OUString rValueName);
+ sal_Int32 getInteropGrabBagSize();
};
} // namespace dmapper