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 /writerfilter/source | |
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 'writerfilter/source')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 15 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 |
3 files changed, 17 insertions, 13 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 4804131ebd49..df682c7dae85 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2799,10 +2799,18 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) 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_citation") || (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); + { + PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_CHARACTER); + + if (m_pImpl->IsOpenField()) + // We have a field, insert the SDT properties to the field's grab-bag, so they won't be lost. + pContext = m_pImpl->GetTopFieldContext()->getProperties(); + + pContext->Insert(PROP_SDTPR, uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, CHAR_GRAB_BAG); + } else m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Insert(PROP_SDTPR, uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, PARA_GRAB_BAG); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 9983b99c9d9f..d3c5d7551fde 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2486,6 +2486,7 @@ FieldContext::FieldContext(uno::Reference< text::XTextRange > xStart) : m_bFieldCommandCompleted( false ) ,m_xStartRange( xStart ) { + m_pProperties.reset(new PropertyMap()); } @@ -3838,17 +3839,9 @@ void DomainMapper_Impl::CloseFieldCommand() uno::makeAny(aValues)); } uno::Reference< text::XTextContent > xToInsert( xTC, uno::UNO_QUERY ); - uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend; - if (xTextAppend.is()) - { - uno::Reference< text::XTextCursor > xCrsr = xTextAppend->getText()->createTextCursor(); - uno::Reference< text::XText > xText = xTextAppend->getText(); - if(xCrsr.is() && xText.is()) - { - xCrsr->gotoEnd(false); - xText->insertTextContent(uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ), xToInsert, sal_False); - } - } + + uno::Sequence<beans::PropertyValue> aValues = m_aFieldStack.top()->getProperties()->GetPropertyValues(); + appendTextContent(xToInsert, aValues); m_bSetCitation = true; } break; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 60c8c654b979..f374edec4e6c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -132,6 +132,8 @@ class FieldContext OUString m_sHyperlinkURL; FFDataHandler::Pointer_t m_pFFDataHandler; FormControlHelper::Pointer_t m_pFormControlHelper; + /// (Character) properties of the field itself. + PropertyMapPtr m_pProperties; public: FieldContext(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xStart); @@ -169,6 +171,7 @@ public: void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper) { m_pFormControlHelper = pFormControlHelper; } FormControlHelper::Pointer_t getFormControlHelper() const { return m_pFormControlHelper; } + PropertyMapPtr getProperties() { return m_pProperties; } ::std::vector<OUString> GetCommandParts() const; }; |