summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Wang <fred.wang@free.fr>2013-06-30 16:15:14 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2013-07-03 06:58:12 +0000
commitc61f35275c613cf7ba6f1aa7bc8235340f9df8f7 (patch)
tree5a1af645ded07495f46334cf9fba10485a47a6cd
parentf45c47af72369859d1937cb8b46cba370031509a (diff)
fdo#66282 - MathML export: improve ExportBrace
Change-Id: If15038f8942c649703659e05868162c31785c762 Reviewed-on: https://gerrit.libreoffice.org/4632 Reviewed-by: Khaled Hosny <khaledhosny@eglug.org> Tested-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r--include/xmloff/xmltoken.hxx1
-rw-r--r--starmath/source/mathmlexport.cxx56
-rw-r--r--xmloff/source/core/xmltoken.cxx1
3 files changed, 31 insertions, 27 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 690aad07140c..2523ad1bcda4 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -736,6 +736,7 @@ namespace xmloff { namespace token {
XML_FALSE,
XML_FAMILY,
XML_FAST,
+ XML_FENCE,
XML_FIELD_NUMBER,
XML_FILE_NAME,
XML_FILL,
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index a523693f7b30..1dd16344bb3f 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -1144,51 +1144,53 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
const SmNode *pTemp;
const SmNode *pLeft=pNode->GetSubNode(0);
const SmNode *pRight=pNode->GetSubNode(2);
- SvXMLElementExport *pFences=0,*pRow=0;
- if ( ((pLeft) && (pLeft->GetToken().eType != TNONE)) &&
- ((pRight) && (pRight->GetToken().eType != TNONE)) &&
- (pNode->GetScaleMode() == SCALE_HEIGHT))
- {
- sal_Unicode nArse[2];
- nArse[1] = 0;
- nArse[0] = static_cast<
- const SmMathSymbolNode* >(pLeft)->GetText()[0];
- OSL_ENSURE(nArse[0] != 0xffff,"Non existent symbol");
- AddAttribute(XML_NAMESPACE_MATH, XML_OPEN,nArse);
- nArse[0] = static_cast<
- const SmMathSymbolNode* >(pRight)->GetText()[0];
- OSL_ENSURE(nArse[0] != 0xffff,"Non existent symbol");
- AddAttribute(XML_NAMESPACE_MATH, XML_CLOSE,nArse);
- pFences = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MFENCED,
- sal_True,sal_True);
- }
- else if (pLeft && (pLeft->GetToken().eType != TNONE))
+ SvXMLElementExport *pRow=0;
+
+ // This used to generate <mfenced> or <mrow>+<mo> elements according to
+ // the stretchiness of fences. The MathML recommendation defines an
+ // <mrow>+<mo> construction that is equivalent to the <mfenced> element:
+ // http://www.w3.org/TR/MathML3/chapter3.html#presm.mfenced
+ // To simplify our code and avoid issues with mfenced implementations in
+ // MathML rendering engines, we now always generate <mrow>+<mo> elements.
+ // See #fdo 66282.
+
+ // <mrow>
+ pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
+ sal_True, sal_True);
+
+ // <mo fence="true"> opening-fence </mo>
+ if (pLeft && (pLeft->GetToken().eType != TNONE))
{
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
- sal_True, sal_True);
+ AddAttribute(XML_NAMESPACE_MATH, XML_FENCE, XML_TRUE);
if (pNode->GetScaleMode() == SCALE_HEIGHT)
AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
else
AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
ExportNodes(pLeft, nLevel+1);
}
- else
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
- sal_True, sal_True);
if (NULL != (pTemp = pNode->GetSubNode(1)))
+ {
+ // <mrow>
+ SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW,
+ sal_True, sal_True);
ExportNodes(pTemp, nLevel+1);
- if (pFences)
- delete pFences;
- else if (pRight && (pRight->GetToken().eType != TNONE))
+ // </mrow>
+ }
+
+ // <mo fence="true"> closing-fence </mo>
+ if (pRight && (pRight->GetToken().eType != TNONE))
{
+ AddAttribute(XML_NAMESPACE_MATH, XML_FENCE, XML_TRUE);
if (pNode->GetScaleMode() == SCALE_HEIGHT)
AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
else
AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
ExportNodes(pRight, nLevel+1);
}
+
delete pRow;
+ // </mrow>
}
void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel)
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 164f03c4b5f7..1de31799cfbf 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -741,6 +741,7 @@ namespace xmloff { namespace token {
TOKEN( "false", XML_FALSE ),
TOKEN( "family", XML_FAMILY ),
TOKEN( "fast", XML_FAST ),
+ TOKEN( "fence", XML_FENCE ),
TOKEN( "field-number", XML_FIELD_NUMBER ),
TOKEN( "file-name", XML_FILE_NAME ),
TOKEN( "fill", XML_FILL ),