include/xmloff/xmltoken.hxx | 3 ++ starmath/source/mathmlexport.cxx | 42 +++++++++++++++++++++++++++++++++++++-- xmloff/source/core/xmltoken.cxx | 3 ++ 3 files changed, 46 insertions(+), 2 deletions(-)
New commits: commit bc51be7e7f2fc55456e1ce7dcdc70e6a15c53c0e Author: Frédéric Wang <fred.w...@free.fr> Date: Sat Jun 29 22:51:58 2013 +0200 #fdo66277 - Add support for alignment in MathML export. Change-Id: I78352ff93da5b4e912040c4019fcea924f7b0c20 Reviewed-on: https://gerrit.libreoffice.org/4625 Reviewed-by: Bosdonnat Cedric <cedric.bosdon...@free.fr> Tested-by: Bosdonnat Cedric <cedric.bosdon...@free.fr> diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 5993b74..690aad0 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -430,6 +430,7 @@ namespace xmloff { namespace token { XML_COLUMN_NAME, XML_COLUMN_SEP, XML_COLUMN_WIDTH, + XML_COLUMNALIGN, XML_COLUMNS, XML_COLUMNSPLIT_AUTO, XML_COLUMNSPLIT_AVOID, @@ -590,6 +591,7 @@ namespace xmloff { namespace token { XML_DELAY, XML_DELETION, XML_DELETIONS, + XML_DENOMALIGN, XML_DENOMINATOR_VALUE, XML_DEPENDENCE, XML_DEPENDENCES, @@ -1276,6 +1278,7 @@ namespace xmloff { namespace token { XML_NUM_LETTER_SYNC, XML_NUM_PREFIX, XML_NUM_SUFFIX, + XML_NUMALIGN, XML_NUMBER, XML_NUMBER_AND_NAME, XML_NUMBER_COLUMNS_REPEATED, diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index fbc1e97..34c6050 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -799,9 +799,25 @@ void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel) void SmXMLExport::ExportBinaryVertical(const SmNode *pNode, int nLevel) { OSL_ENSURE(pNode->GetNumSubNodes()==3,"Bad Fraction"); + const SmNode *pNum = pNode->GetSubNode(0); + const SmNode *pDenom = pNode->GetSubNode(2); + if (pNum->GetType() == NALIGN && pNum->GetToken().eType != TALIGNC) + { + // A left or right alignment is specified on the numerator: + // attach the corresponding numalign attribute. + AddAttribute(XML_NAMESPACE_MATH, XML_NUMALIGN, + pNum->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); + } + if (pDenom->GetType() == NALIGN && pDenom->GetToken().eType != TALIGNC) + { + // A left or right alignment is specified on the denominator: + // attach the corresponding denomalign attribute. + AddAttribute(XML_NAMESPACE_MATH, XML_DENOMALIGN, + pDenom->GetToken().eType == TALIGNL ? XML_LEFT : XML_RIGHT); + } SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, sal_True, sal_True); - ExportNodes(pNode->GetSubNode(0), nLevel); - ExportNodes(pNode->GetSubNode(2), nLevel); + ExportNodes(pNum, nLevel); + ExportNodes(pDenom, nLevel); } void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel) @@ -866,6 +882,19 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) if (pTable) { pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True); + if (pTemp->GetNumSubNodes() > 0) + { + const SmNode *pFirstChild = pTemp->GetSubNode(0); + if (pFirstChild->GetType() == NALIGN && + pFirstChild->GetToken().eType != TALIGNC) + { + // If a left or right alignment is specified on this line, + // attach the corresponding columnalign attribute. + AddAttribute(XML_NAMESPACE_MATH, XML_COLUMNALIGN, + pFirstChild->GetToken().eType == TALIGNL ? + XML_LEFT : XML_RIGHT); + } + } pCell = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True); } ExportNodes(pTemp, nLevel+1); @@ -1481,6 +1510,15 @@ void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel) for (sal_uLong x = 0; x < pMatrix->GetNumCols(); x++) if (const SmNode *pTemp = pNode->GetSubNode(i++)) { + if (pTemp->GetType() == NALIGN && + pTemp->GetToken().eType != TALIGNC) + { + // A left or right alignment is specified on this cell, + // attach the corresponding columnalign attribute. + AddAttribute(XML_NAMESPACE_MATH, XML_COLUMNALIGN, + pTemp->GetToken().eType == TALIGNL ? + XML_LEFT : XML_RIGHT); + } SvXMLElementExport aCell(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True); ExportNodes(pTemp, nLevel+1); } diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index df208b0..164f03c 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -435,6 +435,7 @@ namespace xmloff { namespace token { TOKEN( "column-name", XML_COLUMN_NAME ), TOKEN( "column-sep", XML_COLUMN_SEP ), TOKEN( "column-width", XML_COLUMN_WIDTH ), + TOKEN( "columnalign", XML_COLUMNALIGN ), TOKEN( "columns", XML_COLUMNS ), TOKEN( "auto", XML_COLUMNSPLIT_AUTO ), TOKEN( "avoid", XML_COLUMNSPLIT_AVOID ), @@ -595,6 +596,7 @@ namespace xmloff { namespace token { TOKEN( "delay", XML_DELAY ), TOKEN( "deletion", XML_DELETION ), TOKEN( "deletions", XML_DELETIONS ), + TOKEN( "denomalign" , XML_DENOMALIGN ), TOKEN( "denominator-value", XML_DENOMINATOR_VALUE ), TOKEN( "dependence", XML_DEPENDENCE ), TOKEN( "dependences", XML_DEPENDENCES ), @@ -1282,6 +1284,7 @@ namespace xmloff { namespace token { TOKEN( "num-letter-sync", XML_NUM_LETTER_SYNC ), TOKEN( "num-prefix", XML_NUM_PREFIX ), TOKEN( "num-suffix", XML_NUM_SUFFIX ), + TOKEN( "numalign", XML_NUMALIGN ), TOKEN( "number", XML_NUMBER ), TOKEN( "number-and-name", XML_NUMBER_AND_NAME ), TOKEN( "number-columns-repeated", XML_NUMBER_COLUMNS_REPEATED ),
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits