[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sw/source writerfilter/Library_ooxml.mk writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 23 23:56:16 PDT 2012


 sw/source/filter/ww8/docxattributeoutput.cxx          |   11 +++++++----
 writerfilter/Library_ooxml.mk                         |    1 +
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    9 +++++++--
 3 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit a2d8a3364fac34d14c6f82cf65004a07e91640b7
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Aug 23 14:06:45 2012 +0200

    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.
    
    Change-Id: I870d51fff00ee4dfc74c4f872ad8eeac28b374d2
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 036ddb4..100a1e1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -95,6 +95,7 @@
 #include <editeng/opaqitem.hxx>
 #include <svx/svdmodel.hxx>
 #include <svx/svdobj.hxx>
+#include <sfx2/sfxbasemodel.hxx>
 
 #include <anchoredobject.hxx>
 #include <docufld.hxx>
@@ -2318,10 +2319,12 @@ void DocxAttributeOutput::WritePostponedMath()
         return;
     uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode*>(m_postponedMath)->GetOLEObj().GetOleRef());
     uno::Reference< uno::XInterface > xInterface( xObj->getComponent(), uno::UNO_QUERY );
-    if( oox::FormulaExportBase* formulaexport = dynamic_cast< oox::FormulaExportBase* >( xInterface.get()))
-        formulaexport->writeFormulaOoxml( m_pSerializer, GetExport().GetFilter().getVersion());
-    else
-        OSL_FAIL( "Math OLE object cannot write out OOXML" );
+// 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::FormulaExportBase* formulaexport = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xInterface.get()));
+    assert( formulaexport != NULL );
+    formulaexport->writeFormulaOoxml( m_pSerializer, GetExport().GetFilter().getVersion());
     m_postponedMath = NULL;
 }
 
diff --git a/writerfilter/Library_ooxml.mk b/writerfilter/Library_ooxml.mk
index f4a1fe2..f30f58a 100644
--- a/writerfilter/Library_ooxml.mk
+++ b/writerfilter/Library_ooxml.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_Library_add_linked_libs,ooxml,\
     oox \
 	resourcemodel \
     sal \
+    sfx \
     tl \
     $(gb_STDLIBS) \
 ))
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 9716e6a..54712f9 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -42,6 +42,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"
@@ -2449,8 +2450,12 @@ void OOXMLFastContextHandlerMath::process()
     rtl::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();


More information about the Libreoffice-commits mailing list