[Libreoffice-commits] core.git: filter/source starmath/source

Frédéric Wang fred.wang at free.fr
Mon Jul 1 06:41:57 PDT 2013


 filter/source/xslt/odf2xhtml/export/xhtml/body.xsl |   12 +++++++---
 starmath/source/mathmlexport.cxx                   |   24 ++++++++++++++-------
 2 files changed, 24 insertions(+), 12 deletions(-)

New commits:
commit 1ef63d0842dab4154c5ca2fc42e416950bd7459a
Author: Frédéric Wang <fred.wang at free.fr>
Date:   Fri Jun 28 17:07:11 2013 +0200

     fdo#66278 - MathML export: distinguish inline/display equations.
    
    Change-Id: Ia764c2fd64ab772342ce86f67ee290ab38dc4a83
    Reviewed-on: https://gerrit.libreoffice.org/4607
    Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>
    Tested-by: Bosdonnat Cedric <cedric.bosdonnat at free.fr>

diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index d9de0e9..e83195c 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
@@ -2949,9 +2949,7 @@
 -->
 	<!-- MathML -->
 	<xsl:template match="draw:object[math:math]">
-		<math xmlns="http://www.w3.org/1998/Math/MathML">
-			<xsl:apply-templates select="math:math/math:semantics/*" mode="math"/>
-		</math>
+		<xsl:apply-templates select="math:math" mode="math"/>
 	</xsl:template>
 
 	<xsl:template match="*" mode="math">
@@ -2966,6 +2964,12 @@
 		</xsl:attribute>
 	</xsl:template>
 
-	<xsl:template match="math:annotation" mode="math"/>
+	<!-- Ignore semantic annotations -->
+	<xsl:template match="math:semantics" mode="math">
+		<xsl:apply-templates select="*[1]" mode="math"/>
+	</xsl:template>
+
+	<!-- Ignore the replacement image -->
+	<xsl:template match="draw:frame/draw:image[preceding-sibling::*[1]/math:math]"/>
 
 </xsl:stylesheet>
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index fb1e6c3..fbc1e97 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -599,6 +599,22 @@ sal_uInt32 SmXMLExport::exportDoc(enum XMLTokenEnum eClass)
 
 void SmXMLExport::_ExportContent()
 {
+    uno::Reference <frame::XModel> xModel = GetModel();
+    uno::Reference <lang::XUnoTunnel> xTunnel;
+    xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+    SmModel *pModel = reinterpret_cast<SmModel *>
+        (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+    SmDocShell *pDocShell = pModel ?
+        static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
+    OSL_ENSURE( pDocShell, "doc shell missing" );
+
+    if (pDocShell && !pDocShell->GetFormat().IsTextmode())
+    {
+        // If the Math equation is not in text mode, we attach a display="block"
+        // attribute on the <math> root. We don't do anything if it is in
+        // text mode, the default display="inline" value will be used.
+        AddAttribute(XML_NAMESPACE_MATH, XML_DISPLAY, XML_BLOCK);
+    }
     SvXMLElementExport aEquation(*this, XML_NAMESPACE_MATH, XML_MATH, sal_True, sal_True);
     SvXMLElementExport *pSemantics=0;
 
@@ -613,14 +629,6 @@ void SmXMLExport::_ExportContent()
     if (aText.Len())
     {
         // Convert symbol names
-        uno::Reference <frame::XModel> xModel = GetModel();
-        uno::Reference <lang::XUnoTunnel> xTunnel;
-        xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
-        SmModel *pModel = reinterpret_cast<SmModel *>
-            (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-        SmDocShell *pDocShell = pModel ?
-            static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
-        OSL_ENSURE( pDocShell, "doc shell missing" );
         if (pDocShell)
         {
             SmParser &rParser = pDocShell->GetParser();


More information about the Libreoffice-commits mailing list