diff options
author | Frédéric Wang <fred.wang@free.fr> | 2013-06-23 13:28:36 +0200 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-06-28 09:49:30 +0000 |
commit | 1418694edad8720dcd4884fd3e759c05a1f4cae9 (patch) | |
tree | ed00af0eae8c75086f6b72b97b595b564ae76517 /starmath | |
parent | 3b3ec32358aebd81ef5385f48dbf3ee4c93649e8 (diff) |
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@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/mathmlexport.cxx | 19 | ||||
-rw-r--r-- | starmath/source/mathmlimport.cxx | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index f9e658998df3..e18a69ec78cf 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 608ab7ac92ad..beaaf3d59548 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; |