summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-08-16 16:58:37 +0200
committerLuboš Luňák <l.lunak@suse.cz>2011-08-18 15:33:46 +0200
commitc0bcff297b9282baa6de998804e451d66e2863b7 (patch)
tree01d741965d8741ad7667bcdb22192a82b63102ee /starmath
parent1ea4a6658517d27e7d5e26fc33fca9e49af6ddf7 (diff)
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"
Diffstat (limited to 'starmath')
-rw-r--r--starmath/Library_sm.mk1
-rw-r--r--starmath/inc/document.hxx3
-rw-r--r--starmath/inc/unomodel.hxx2
-rw-r--r--starmath/source/document.cxx4
-rw-r--r--starmath/source/ooxml.cxx12
-rw-r--r--starmath/source/ooxml.hxx4
-rw-r--r--starmath/source/unomodel.cxx4
7 files changed, 22 insertions, 8 deletions
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index 98d792da9c6d..6c6033724850 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_Library_add_linked_libs,sm,\
editeng \
i18npaper \
msfilter \
+ oox \
sal \
sax \
sfx \
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
index d8e042c3e230..99f0d8b4cc79 100644
--- a/starmath/inc/document.hxx
+++ b/starmath/inc/document.hxx
@@ -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();
diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx
index 15ada7b3a152..a55cac884158 100644
--- a/starmath/inc/unomodel.hxx
+++ b/starmath/inc/unomodel.hxx
@@ -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();
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index b9db1f5db35e..90da132a385a 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -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 );
}
diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 10b576deb281..5bf642696936 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -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());
diff --git a/starmath/source/ooxml.hxx b/starmath/source/ooxml.hxx
index 70de500ebff5..22aa91f61375 100644
--- a/starmath/source/ooxml.hxx
+++ b/starmath/source/ooxml.hxx
@@ -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;
};
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index d44485a605cb..4ac92976567e 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -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: */