sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 3 --- sw/qa/extras/rtfexport/rtfexport.cxx | 3 --- sw/source/filter/ww8/docxattributeoutput.cxx | 11 +++++++---- sw/source/filter/ww8/rtfattributeoutput.cxx | 18 +++++++++--------- writerfilter/Library_writerfilter.mk | 1 + writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 9 +++++++-- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 +++++++-- 7 files changed, 31 insertions(+), 23 deletions(-)
New commits: commit 2b5953a19e36a02040f2ff08bc87efe4785f80bd Author: LuboÅ¡ LuÅák <l.lu...@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. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 6615343..076eedc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -49,10 +49,7 @@ public: CPPUNIT_TEST(testZoom); CPPUNIT_TEST(defaultTabStopNotInStyles); CPPUNIT_TEST(testFdo38244); - // See rtfexport test on why this is blacklisted. -#if !(__GNUC__ == 4 && __GNUC_MINOR__ == 4) CPPUNIT_TEST(testMathEscape); -#endif CPPUNIT_TEST(testFdo51034); #endif CPPUNIT_TEST_SUITE_END(); diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index de705d2..67b6242 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -81,8 +81,6 @@ public: CPPUNIT_TEST(testFdo50831); CPPUNIT_TEST(testFdo48335); CPPUNIT_TEST(testFdo38244); - // With gcc-4.4, the dynamic_cast in RtfAttributeOutput::FlyFrameOLEMath() fails, strange. -#if !(__GNUC__ == 4 && __GNUC_MINOR__ == 4) CPPUNIT_TEST(testMathAccents); CPPUNIT_TEST(testMathEqarray); CPPUNIT_TEST(testMathD); @@ -100,7 +98,6 @@ public: CPPUNIT_TEST(testMathSubscripts); CPPUNIT_TEST(testMathVerticalstacks); CPPUNIT_TEST(testMathRuns); -#endif CPPUNIT_TEST(testFdo53113); #endif CPPUNIT_TEST_SUITE_END(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 71c1915..b5165e7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -87,6 +87,7 @@ #include <editeng/editobj.hxx> #include <svx/svdmodel.hxx> #include <svx/svdobj.hxx> +#include <sfx2/sfxbasemodel.hxx> #include <anchoredobject.hxx> #include <docufld.hxx> @@ -2287,10 +2288,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/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index a152e6e..15f15b7 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -80,6 +80,7 @@ #include <filter/msfilter/msoleexp.hxx> #include <filter/msfilter/rtfutil.hxx> #include <svtools/miscopt.hxx> +#include <sfx2/sfxbasemodel.hxx> #include <docufld.hxx> #include <fmtclds.hxx> @@ -3362,15 +3363,14 @@ bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENod m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATH " "); uno::Reference<util::XCloseable> xClosable(xObj->getComponent(), uno::UNO_QUERY); - oox::FormulaExportBase* pBase = dynamic_cast<oox::FormulaExportBase*>(xClosable.get()); - SAL_WARN_IF(!pBase, "sw.rtf", "Math OLE object cannot write out RTF"); - if (pBase) - { - OStringBuffer aBuf; - pBase->writeFormulaRtf(aBuf, m_rExport.eCurrentEncoding); - m_aRunText->append(aBuf.makeStringAndClear()); - } - +// 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* pBase = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xClosable.get())); + assert( pBase != NULL ); + OStringBuffer aBuf; + pBase->writeFormulaRtf(aBuf, m_rExport.eCurrentEncoding); + m_aRunText->append(aBuf.makeStringAndClear()); // Replacement graphic. m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATHPICT " "); FlyFrameOLEReplacement(pFlyFrmFmt, rOLENode, rSize); diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index 3c30b36..202990d 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 680109b..a4803a9 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 f27050a..8120540 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);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits