Kaydet (Commit) c0bcff29 authored tarafından Luboš Luňák's avatar Luboš Luňák

hack: make msoffice 2k7 be able to read ooxml formulas

It seems that it doesn't read characters unless the font is explicitly
specified as "Cambria Math"
üst 1ea4a665
......@@ -29,6 +29,7 @@
#define _OOXMLEXPORT_HXX
#include <sax/fshelper.hxx>
#include <oox/core/filterbase.hxx>
#include "filter/msfilter/msfilterdllapi.h"
/**
......@@ -38,7 +39,7 @@
class MSFILTER_DLLPUBLIC OoxmlFormulaExportBase
{
public:
virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer ) = 0;
virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version ) = 0;
};
#endif
......
......@@ -48,6 +48,7 @@ $(eval $(call gb_Library_add_linked_libs,sm,\
editeng \
i18npaper \
msfilter \
oox \
sal \
sax \
sfx \
......
......@@ -40,6 +40,7 @@
#include <vcl/jobset.hxx>
#include <vcl/virdev.hxx>
#include <sax/fshelper.hxx>
#include <oox/core/filterbase.hxx>
#include <set>
......@@ -173,7 +174,7 @@ class SmDocShell : public SfxObjectShell, public SfxListener
*/
void InvalidateCursor();
bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer );
bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version );
public:
TYPEINFO();
......
......@@ -103,7 +103,7 @@ public:
virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xParent ) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException );
// OoxmlFormulaExportBase
virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer );
virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version );
static ::com::sun::star::uno::Sequence< rtl::OUString > getSupportedServiceNames_Static();
static ::rtl::OUString getImplementationName_Static();
......
......@@ -991,7 +991,7 @@ sal_Bool SmDocShell::ConvertTo( SfxMedium &rMedium )
return bRet;
}
bool SmDocShell::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer )
bool SmDocShell::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version )
{
RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::writeFormulaOoxml" );
......@@ -999,7 +999,7 @@ bool SmDocShell::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer
Parse();
if( pTree && !IsFormulaArranged() )
ArrangeFormula();
SmOoxml aEquation( aText, pTree );
SmOoxml aEquation( aText, pTree, version );
return aEquation.ConvertFromStarMath( m_pSerializer );
}
......
......@@ -34,6 +34,7 @@
#include <oox/token/tokens.hxx>
using namespace oox;
using namespace oox::core;
// TODO duped from MathType
......@@ -70,9 +71,10 @@ static sal_Unicode Convert(sal_Unicode nIn)
return nIn;
}
SmOoxml::SmOoxml(String &rIn,SmNode *pIn)
SmOoxml::SmOoxml(String &rIn,SmNode *pIn,OoxmlVersion v)
: str( rIn )
, pTree( pIn )
, version( v )
{
}
......@@ -222,6 +224,14 @@ void SmOoxml::HandleTable(SmNode *pNode,int nLevel)
void SmOoxml::HandleText(SmNode *pNode, int /*nLevel*/)
{
m_pSerializer->startElementNS( XML_m, XML_r, FSEND );
if( version == ECMA_DIALECT )
{ // HACK: MSOffice2007 does not import characters properly unless this font is explicitly given
m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
m_pSerializer->singleElementNS( XML_w, XML_rFonts, FSNS( XML_w, XML_ascii ), "Cambria Math",
FSNS( XML_w, XML_hAnsi ), "Cambria Math", FSEND );
m_pSerializer->endElementNS( XML_w, XML_rPr );
}
m_pSerializer->startElementNS( XML_m, XML_t, FSEND );
SmTextNode *pTemp=(SmTextNode *)pNode;
fprintf(stderr, "T %s\n", rtl::OUStringToOString( pTemp->GetText(), RTL_TEXTENCODING_UTF8 ).getStr());
......
......@@ -32,6 +32,7 @@
#include "node.hxx"
#include <sax/fshelper.hxx>
#include <oox/core/filterbase.hxx>
/**
Class implementing writing of formulas to OOXML.
......@@ -39,7 +40,7 @@
class SmOoxml
{
public:
SmOoxml(String &rIn,SmNode *pIn);
SmOoxml(String &rIn,SmNode *pIn, oox::core::OoxmlVersion version);
bool ConvertFromStarMath( ::sax_fastparser::FSHelperPtr m_pSerializer );
private:
void HandleNodes(SmNode *pNode,int nLevel);
......@@ -49,6 +50,7 @@ private:
String str;
SmNode *pTree;
::sax_fastparser::FSHelperPtr m_pSerializer;
oox::core::OoxmlVersion version;
};
......
......@@ -1132,9 +1132,9 @@ void SAL_CALL SmModel::setParent( const uno::Reference< uno::XInterface >& xPare
}
}
void SmModel::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer )
void SmModel::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version )
{
static_cast< SmDocShell* >( GetObjectShell())->writeFormulaOoxml( m_pSerializer );
static_cast< SmDocShell* >( GetObjectShell())->writeFormulaOoxml( m_pSerializer, version );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -2319,7 +2319,7 @@ void DocxAttributeOutput::WritePostponedMath()
uno::Reference< uno::XInterface > xInterface( aObjRef->getComponent(), uno::UNO_QUERY );
if( OoxmlFormulaExportBase* formulaexport = dynamic_cast< OoxmlFormulaExportBase* >( xInterface.get()))
formulaexport->writeFormulaOoxml( m_pSerializer );
formulaexport->writeFormulaOoxml( m_pSerializer, GetExport().GetFilter().getVersion());
else
OSL_FAIL( "Math OLE object cannot write out OOXML" );
m_postponedMath = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment