From 2b5953a19e36a02040f2ff08bc87efe4785f80bd Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 23 Aug 2012 14:06:45 +0200 Subject: fix math export/import in docx/rtf For some reason older gcc versions don't manage to dynamic_cast to the necessary cast. I'm not quite sure why, forcing sal/osl/unx/module.cxx to always use RTLD_GLOBAL does not seem to help. Most probably compiler bug. Changing the cast to two simpler ones helps. --- writerfilter/Library_writerfilter.mk | 1 + writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 9 +++++++-- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index 3c30b36892b5..202990d6472d 100644 --- a/writerfilter/Library_writerfilter.mk +++ b/writerfilter/Library_writerfilter.mk @@ -74,6 +74,7 @@ $(eval $(call gb_Library_use_libraries,writerfilter,\ msfilter \ oox \ sal \ + sfx \ sot \ svt \ tl \ diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 680109b225c5..a4803a948b18 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include "OOXMLFastContextHandler.hxx" #include "OOXMLFactory.hxx" #include "Handler.hxx" @@ -2441,8 +2442,12 @@ void OOXMLFastContextHandlerMath::process() OUString aName; uno::Reference< embed::XEmbeddedObject > ref = container.CreateEmbeddedObject( name.GetByteSequence(), aName ); uno::Reference< uno::XInterface > component( ref->getComponent(), uno::UNO_QUERY ); - if( oox::FormulaImportBase* import = dynamic_cast< oox::FormulaImportBase* >( component.get())) - import->readFormulaOoxml( buffer ); +// gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class, +// so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated +// to RTLD_GLOBAL, so most probably a gcc bug. + oox::FormulaImportBase* import = dynamic_cast< oox::FormulaImportBase* >( dynamic_cast< SfxBaseModel* >(component.get())); + assert( import != NULL ); + import->readFormulaOoxml( buffer ); if (isForwardEvents()) { OOXMLPropertySet * pProps = new OOXMLPropertySetImpl(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index f27050a9915c..812054003135 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include // NS_sprm namespace @@ -3635,8 +3636,12 @@ int RTFDocumentImpl::popState() OUString aName; uno::Reference xObject = aContainer.CreateEmbeddedObject(aGlobalName.GetByteSequence(), aName); uno::Reference xComponent(xObject->getComponent(), uno::UNO_QUERY); - if( oox::FormulaImportBase* pImport = dynamic_cast(xComponent.get())) - pImport->readFormulaOoxml(m_aMathBuffer); +// gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class, +// so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated +// to RTLD_GLOBAL, so most probably a gcc bug. + oox::FormulaImportBase* pImport = dynamic_cast(dynamic_cast(xComponent.get())); + assert( pImport != NULL ); + pImport->readFormulaOoxml(m_aMathBuffer); RTFValue::Pointer_t pValue(new RTFValue(xObject)); RTFSprms aMathAttributes; aMathAttributes.set(NS_ooxml::LN_starmath, pValue); -- cgit