[Libreoffice-commits] core.git: starmath/source
Frédéric Wang
fred.wang at free.fr
Fri Jun 28 02:49:51 PDT 2013
starmath/source/mathmlexport.cxx | 19 ++++++++++++++++---
starmath/source/mathmlimport.cxx | 2 ++
2 files changed, 18 insertions(+), 3 deletions(-)
New commits:
commit 1418694edad8720dcd4884fd3e759c05a1f4cae9
Author: Frédéric Wang <fred.wang at free.fr>
Date: Sun Jun 23 13:28:36 2013 +0200
fdo#66075 - Formula editor: export blanks as MathML <mspace> elements.
Change-Id: I5cc0ed9a1273b5fb59d5dbaf63a382c844820ff9
Reviewed-on: https://gerrit.libreoffice.org/4454
Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index f9e6589..e18a69e 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -882,15 +882,28 @@ void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/)
delete pText;
}
-void SmXMLExport::ExportBlank(const SmNode * /*pNode*/, int /*nLevel*/)
+void SmXMLExport::ExportBlank(const SmNode *pNode, int /*nLevel*/)
{
- //!! exports an empty <mi> tag since for example "~_~" is allowed in
+ const SmBlankNode *pTemp = static_cast<const SmBlankNode *>(pNode);
+ //!! exports an <mspace> element. Note that for example "~_~" is allowed in
//!! Math (so it has no sense at all) but must not result in an empty
//!! <msub> tag in MathML !!
+ if (pTemp->GetBlankNum() != 0)
+ {
+ // Attach a width attribute. We choose the (somewhat arbitrary) values
+ // ".5em" for a small gap '`' and "2em" for a large gap '~'.
+ // (see SmBlankNode::IncreaseBy for how pTemp->nNum is set).
+ OUStringBuffer sStrBuf;
+ ::sax::Converter::convertDouble(sStrBuf, pTemp->GetBlankNum() * .5);
+ sStrBuf.append(OUString("em"));
+ AddAttribute(XML_NAMESPACE_MATH, XML_WIDTH, sStrBuf.getStr());
+ }
+
SvXMLElementExport *pText;
- pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False);
+ pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSPACE,
+ sal_True, sal_False);
GetDocHandler()->characters( OUString() );
delete pText;
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 608ab7a..beaaf3d 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -1418,6 +1418,8 @@ public:
void SmXMLSpaceContext_Impl::StartElement(
const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ )
{
+ // There is not any syntax in Math to specify blank nodes of arbitrary
+ // size. Hence we always interpret an <mspace> as a large gap "~".
SmToken aToken;
aToken.cMathChar = '\0';
aToken.eType = TBLANK;
More information about the Libreoffice-commits
mailing list