diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2013-12-11 16:29:28 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2013-12-11 17:39:02 +0100 |
commit | ece66b11bd3d294eb27f185c1513744fe28ca523 (patch) | |
tree | 282a0bcc0c68aae7253a275fa0f5d08e98b4540c /writerfilter/source/filter/ImportFilter.cxx | |
parent | 1835074d525d12629008f8a6d5ed27402d18f4b3 (diff) |
fdo#64232: export w:themeFontLang setting to docx
We store the values of themeFontLang tag to the document grab bag so
we can save it back to the document on export time.
Added unit tests to check that the attribute is properly set back and
also that the theme fonts are correctly applied to the text.
Change-Id: Ia54c513796ba38a571396ca7b72dfd28463c15fd
Diffstat (limited to 'writerfilter/source/filter/ImportFilter.cxx')
-rw-r--r-- | writerfilter/source/filter/ImportFilter.cxx | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx index cbbcd3a9b64c..708b9f7283a0 100644 --- a/writerfilter/source/filter/ImportFilter.cxx +++ b/writerfilter/source/filter/ImportFilter.cxx @@ -100,7 +100,8 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes m_sFilterName == "writer_OOXML" || m_sFilterName == "writer_OOXML_Text_Template" ) ? writerfilter::dmapper::DOCUMENT_OOXML : writerfilter::dmapper::DOCUMENT_DOC; - writerfilter::Stream::Pointer_t pStream(new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, uno::Reference<text::XTextRange>())); + writerfilter::dmapper::DomainMapper* aDomainMapper = new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, uno::Reference<text::XTextRange>()); + writerfilter::Stream::Pointer_t pStream(aDomainMapper); //create the tokenizer and domain mapper if( eType == writerfilter::dmapper::DOCUMENT_OOXML ) { @@ -221,6 +222,38 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes SAL_WARN("writerfilter","Failed to save ActiveX dom to documents grab bag"); } + // Adding the saved w:themeFontLang setting to the document's grab bag + if ( aDomainMapper->GetThemeFontLangProperties().hasElements() ) + try + { + uno::Reference<beans::XPropertySet> xDocProps( m_xDstDoc, uno::UNO_QUERY ); + if (xDocProps.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropsInfo = xDocProps->getPropertySetInfo(); + + const OUString aGrabBagPropName = "InteropGrabBag"; + if( xPropsInfo.is() && xPropsInfo->hasPropertyByName( aGrabBagPropName ) ) + { + uno::Sequence< beans::PropertyValue > aGrabBag; + + // We want to keep the previous items + xDocProps->getPropertyValue( aGrabBagPropName ) >>= aGrabBag; + sal_Int32 length = aGrabBag.getLength(); + aGrabBag.realloc( length+1 ); + + beans::PropertyValue* pValue = aGrabBag.getArray(); + pValue[length].Name = "ThemeFontLangProps"; + pValue[length].Value = uno::makeAny( aDomainMapper->GetThemeFontLangProperties() ); + + xDocProps->setPropertyValue( aGrabBagPropName, uno::Any( aGrabBag ) ); + } + } + } + catch(const uno::Exception&) + { + SAL_WARN("writerfilter","Failed to save themeFontLang properties to documents grab bag"); + } + writerfilter::ooxml::OOXMLStream::Pointer_t pVBAProjectStream(writerfilter::ooxml::OOXMLDocumentFactory::createStream( pDocStream, writerfilter::ooxml::OOXMLStream::VBAPROJECT )); oox::StorageRef xVbaPrjStrg( new ::oox::ole::OleStorage( m_xContext, pVBAProjectStream->getDocumentStream(), false ) ); if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() ) |