summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-08-23 14:06:45 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-08-23 14:06:45 +0200
commit2b5953a19e36a02040f2ff08bc87efe4785f80bd (patch)
tree10c7d1cbf66788f992ddeed0d390674fb750babe /writerfilter
parentc5d5e06c1578f8ecae9e4e6fb55f1bdb529feb7d (diff)
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.
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/Library_writerfilter.mk1
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx9
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx9
3 files changed, 15 insertions, 4 deletions
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 <comphelper/embeddedobjectcontainer.hxx>
#include <tools/globname.hxx>
#include <comphelper/classids.hxx>
+#include <sfx2/sfxbasemodel.hxx>
#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 <tools/globname.hxx>
#include <comphelper/classids.hxx>
#include <comphelper/embeddedobjectcontainer.hxx>
+#include <sfx2/sfxbasemodel.hxx>
#include <oox/mathml/import.hxx>
#include <doctok/sprmids.hxx> // NS_sprm namespace
@@ -3635,8 +3636,12 @@ int RTFDocumentImpl::popState()
OUString aName;
uno::Reference<embed::XEmbeddedObject> xObject = aContainer.CreateEmbeddedObject(aGlobalName.GetByteSequence(), aName);
uno::Reference<util::XCloseable> xComponent(xObject->getComponent(), uno::UNO_QUERY);
- if( oox::FormulaImportBase* pImport = dynamic_cast<oox::FormulaImportBase*>(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<oox::FormulaImportBase*>(dynamic_cast<SfxBaseModel*>(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);