Kaydet (Commit) 3b3ec323 authored tarafından Frédéric Wang's avatar Frédéric Wang Kaydeden (comit) Fridrich Strba

fdo#66086 - MathML export: wideslash, widebslash and overstrike

Change-Id: I1e8da340ffdacab133b0cff6d6344fe56da34bf8
Reviewed-on: https://gerrit.libreoffice.org/4465Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst 6231979c
......@@ -295,6 +295,7 @@ namespace xmloff { namespace token {
XML_BELOW,
XML_BETWEEN_DATE_TIMES,
XML_BEVEL,
XML_BEVELLED,
XML_BIBILIOGRAPHIC_TYPE,
XML_BIBLIOGRAPHY,
XML_BIBLIOGRAPHY_CONFIGURATION,
......@@ -941,6 +942,7 @@ namespace xmloff { namespace token {
XML_HIGHLIGHTED_RANGE,
XML_HINT,
XML_HORIZONTAL,
XML_HORIZONTALSTRIKE,
XML_HORIZONTAL_LINES,
// XML_HORIZONTAL_ON_LEFT_PAGES and XML_HORIZONTAL_ON_RIGHT_PAGES
// are replaced by XML_HORIZONTAL_ON_EVEN and XML_HORIZONTAL_ON_ODD.
......@@ -1166,6 +1168,7 @@ namespace xmloff { namespace token {
XML_MEASURE_VERTICAL_ALIGN,
XML_MEDIAN,
XML_MEDIUM,
XML_MENCLOSE,
XML_MERROR,
XML_MESSAGE_TYPE,
XML_META,
......@@ -1262,6 +1265,7 @@ namespace xmloff { namespace token {
XML_NORMALS_KIND,
XML_NOT,
XML_NOT_EQUAL_DATE,
XML_NOTATION,
XML_NOTE,
XML_NOTES,
XML_NOTIN,
......
......@@ -766,6 +766,42 @@ void SmXMLExport::ExportBinaryVertical(const SmNode *pNode, int nLevel)
ExportNodes(pNode->GetSubNode(2), nLevel);
}
void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel)
{
OSL_ENSURE(pNode->GetNumSubNodes()==3, "Bad Slash");
if (pNode->GetToken().eType == TWIDESLASH)
{
// wideslash
// export the node as <mfrac bevelled="true">
AddAttribute(XML_NAMESPACE_MATH, XML_BEVELLED, XML_TRUE);
SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC,
sal_True, sal_True);
ExportNodes(pNode->GetSubNode(0), nLevel);
ExportNodes(pNode->GetSubNode(1), nLevel);
}
else
{
// widebslash
// We can not use <mfrac> to a backslash, so just use <mo>\</mo>
SvXMLElementExport *pRow = new SvXMLElementExport(*this,
XML_NAMESPACE_MATH, XML_MROW, sal_True, sal_True);
ExportNodes(pNode->GetSubNode(0), nLevel);
{ // Scoping for <mo> creation
SvXMLElementExport aMo(*this, XML_NAMESPACE_MATH, XML_MO,
sal_True,sal_True);
sal_Unicode nArse[2] = {MS_BACKSLASH,0x00};
GetDocHandler()->characters(nArse);
}
ExportNodes(pNode->GetSubNode(1), nLevel);
delete pRow;
}
}
void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
{
SvXMLElementExport *pTable=0;
......@@ -1090,7 +1126,14 @@ void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel)
pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER,
sal_True,sal_True);
}
else if (pNode->GetToken().eType != TOVERSTRIKE)
else if (pNode->GetToken().eType == TOVERSTRIKE)
{
// export as <menclose notation="horizontalstrike">
AddAttribute(XML_NAMESPACE_MATH, XML_NOTATION, XML_HORIZONTALSTRIKE);
pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
XML_MENCLOSE, sal_True, sal_True);
}
else
{
AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT,
XML_TRUE);
......@@ -1449,6 +1492,9 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
case NBINVER:
ExportBinaryVertical(pNode, nLevel);
break;
case NBINDIAGONAL:
ExportBinaryDiagonal(pNode, nLevel);
break;
case NSUBSUP:
ExportSubSupScript(pNode, nLevel);
break;
......
......@@ -92,6 +92,7 @@ protected:
void ExportUnaryHorizontal(const SmNode *pNode, int nLevel);
void ExportBrace(const SmNode *pNode, int nLevel);
void ExportBinaryVertical(const SmNode *pNode, int nLevel);
void ExportBinaryDiagonal(const SmNode *pNode, int nLevel);
void ExportSubSupScript(const SmNode *pNode, int nLevel);
void ExportRoot(const SmNode *pNode, int nLevel);
void ExportOperator(const SmNode *pNode, int nLevel);
......
......@@ -837,9 +837,35 @@ public:
////////////////////////////////////////////////////////////
class SmXMLEncloseContext_Impl : public SmXMLRowContext_Impl
{
public:
// TODO/LATER: convert <menclose notation="horizontalstrike"> into
// "overstrike{}" and extend the Math syntax to support more notations
SmXMLEncloseContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
const OUString& rLName)
: SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
void EndElement();
};
void SmXMLEncloseContext_Impl::EndElement()
{
/*
<menclose> accepts any number of arguments; if this number is not 1, its
contents are treated as a single "inferred <mrow>" containing its
arguments
*/
if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
SmXMLRowContext_Impl::EndElement();
}
////////////////////////////////////////////////////////////
class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
{
public:
// TODO/LATER: convert <mfrac bevelled="true"> into "wideslash{}{}"
SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
const OUString& rLName)
: SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
......@@ -1867,6 +1893,7 @@ static SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
{ XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR },
{ XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM },
{ XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW },
{ XML_NAMESPACE_MATH, XML_MENCLOSE, XML_TOK_MENCLOSE },
{ XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC },
{ XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT },
{ XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT },
......@@ -2045,6 +2072,10 @@ SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
xAttrList);
break;
case XML_TOK_MENCLOSE:
pContext = GetSmImport().CreateEncloseContext(nPrefix,rLocalName,
xAttrList);
break;
case XML_TOK_MFRAC:
pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName,
xAttrList);
......@@ -2683,6 +2714,13 @@ SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
}
SvXMLImportContext *SmXMLImport::CreateEncloseContext(sal_uInt16 nPrefix,
const OUString &rLocalName,
const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
{
return new SmXMLEncloseContext_Impl(*this,nPrefix,rLocalName);
}
SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
const OUString &rLocalName,
const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
......
......@@ -114,6 +114,10 @@ public:
const OUString &rLocalName,
const com::sun::star::uno::Reference <
com::sun::star::xml::sax::XAttributeList> &xAttrList);
SvXMLImportContext *CreateEncloseContext(sal_uInt16 nPrefix,
const OUString &rLocalName,
const com::sun::star::uno::Reference <
com::sun::star::xml::sax::XAttributeList> &xAttrList);
SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
const OUString &rLocalName,
const com::sun::star::uno::Reference <
......@@ -272,6 +276,7 @@ enum SmXMLPresLayoutElemTokenMap
XML_TOK_MERROR,
XML_TOK_MPHANTOM,
XML_TOK_MROW,
XML_TOK_MENCLOSE,
XML_TOK_MFRAC,
XML_TOK_MSQRT,
XML_TOK_MROOT,
......
......@@ -300,6 +300,7 @@ namespace xmloff { namespace token {
TOKEN( "below", XML_BELOW ),
TOKEN( "between-date-times", XML_BETWEEN_DATE_TIMES ),
TOKEN( "bevel", XML_BEVEL ),
TOKEN( "bevelled", XML_BEVELLED ),
TOKEN( "bibiliographic-type", XML_BIBILIOGRAPHIC_TYPE ),
TOKEN( "bibliography", XML_BIBLIOGRAPHY ),
TOKEN( "bibliography-configuration", XML_BIBLIOGRAPHY_CONFIGURATION ),
......@@ -946,6 +947,7 @@ namespace xmloff { namespace token {
TOKEN( "highlighted-range", XML_HIGHLIGHTED_RANGE ),
TOKEN( "hint", XML_HINT),
TOKEN( "horizontal", XML_HORIZONTAL ),
TOKEN( "horizontalstrike", XML_HORIZONTALSTRIKE ),
TOKEN( "horizontal-lines", XML_HORIZONTAL_LINES ),
/* XML_HORIZONTAL_ON_LEFT_PAGES and XML_HORIZONTAL_ON_RIGHT_PAGES
are replaced by XML_HORIZONTAL_ON_EVEN and XML_HORIZONTAL_ON_ODD.
......@@ -1172,6 +1174,7 @@ namespace xmloff { namespace token {
TOKEN( "measure-vertical-align", XML_MEASURE_VERTICAL_ALIGN ),
TOKEN( "median", XML_MEDIAN ),
TOKEN( "medium", XML_MEDIUM ),
TOKEN( "menclose", XML_MENCLOSE ),
TOKEN( "merror", XML_MERROR ),
TOKEN( "message-type", XML_MESSAGE_TYPE ),
TOKEN( "meta", XML_META ),
......@@ -1268,6 +1271,7 @@ namespace xmloff { namespace token {
TOKEN( "normals-kind", XML_NORMALS_KIND ),
TOKEN( "not", XML_NOT ),
TOKEN( "not-equal-date", XML_NOT_EQUAL_DATE ),
TOKEN( "notation", XML_NOTATION ),
TOKEN( "note", XML_NOTE ),
TOKEN( "notes", XML_NOTES ),
TOKEN( "notin", XML_NOTIN ),
......
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