summaryrefslogtreecommitdiff
path: root/starmath/source/mathmlexport.cxx
diff options
context:
space:
mode:
authorFrédéric Wang <fred.wang@free.fr>2013-06-27 21:35:28 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-06-28 09:56:36 +0000
commit43cf39adff66d20862956869d11fbcc184eb5702 (patch)
treea0d8ad03ab6b0a9d98efe80288400d667954b8e9 /starmath/source/mathmlexport.cxx
parent4f294a90877d2f91bb88c7d6cd5b74e8e546a025 (diff)
fdo#66088 Export some math symbols as <mi> elements.
Change-Id: Ib08717c3d4d41abc7bce4cd6bc2e63bda7db6086 Reviewed-on: https://gerrit.libreoffice.org/4595 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'starmath/source/mathmlexport.cxx')
-rw-r--r--starmath/source/mathmlexport.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index d23662c47065..fb1e6c365130 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -871,7 +871,26 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
{
const SmMathSymbolNode *pTemp = static_cast<const SmMathSymbolNode *>(pNode);
- SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False);
+ SvXMLElementExport *pMath = 0;
+
+ if (pNode->GetType() == NMATH)
+ {
+ // Export NMATH symbols as <mo> elements
+ pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False);
+ }
+ else
+ {
+ // Export NMATHIDENT and NPLACE symbols as <mi> elements:
+ // - These math symbols should not be drawn slanted. Hence we should
+ // attach a mathvariant="normal" attribute to single-char <mi> elements
+ // that are not mathematical alphanumeric symbol. For simplicity and to
+ // work around browser limitations, we always attach such an attribute.
+ // - The MathML specification suggests to use empty <mi> elements as
+ // placeholders but they won't be visible in most MathML rendering
+ // engines so let's use an empty square for NPLACE instead.
+ AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL);
+ pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False);
+ }
sal_Unicode nArse[2];
nArse[0] = pTemp->GetText()[0];
sal_Unicode cTmp = ConvertMathToMathML( nArse[0] );
@@ -880,6 +899,8 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
OSL_ENSURE(nArse[0] != 0xffff,"Non existent symbol");
nArse[1] = 0;
GetDocHandler()->characters(nArse);
+
+ delete pMath;
}
void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/)
@@ -1520,6 +1541,7 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
}
}
break;
+ case NMATHIDENT :
case NPLACE:
ExportMath(pNode, nLevel);
break;