Kaydet (Commit) bc51be7e authored tarafından Frédéric Wang's avatar Frédéric Wang Kaydeden (comit) Bosdonnat Cedric

#fdo66277 - Add support for alignment in MathML export.

Change-Id: I78352ff93da5b4e912040c4019fcea924f7b0c20
Reviewed-on: https://gerrit.libreoffice.org/4625Reviewed-by: 's avatarBosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: 's avatarBosdonnat Cedric <cedric.bosdonnat@free.fr>
üst 30213582
......@@ -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,
......
......@@ -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);
}
......
......@@ -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 ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment