[Libreoffice-commits] core.git: include/xmloff starmath/source xmloff/source

Frédéric Wang fred.wang at free.fr
Fri Jun 28 02:47:27 PDT 2013


 include/xmloff/xmltoken.hxx      |    4 +++
 starmath/source/mathmlexport.cxx |   48 ++++++++++++++++++++++++++++++++++++++-
 starmath/source/mathmlexport.hxx |    1 
 starmath/source/mathmlimport.cxx |   38 ++++++++++++++++++++++++++++++
 starmath/source/mathmlimport.hxx |    5 ++++
 xmloff/source/core/xmltoken.cxx  |    4 +++
 6 files changed, 99 insertions(+), 1 deletion(-)

New commits:
commit 3b3ec32358aebd81ef5385f48dbf3ee4c93649e8
Author: Frédéric Wang <fred.wang at free.fr>
Date:   Sun Jun 23 21:32:37 2013 +0200

    fdo#66086 - MathML export: wideslash, widebslash and overstrike
    
    Change-Id: I1e8da340ffdacab133b0cff6d6344fe56da34bf8
    Reviewed-on: https://gerrit.libreoffice.org/4465
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index a40da2c..5993b74 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -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,
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 8df9d28..f9e6589 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -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;
diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx
index 52b558e..3cbaaae 100644
--- a/starmath/source/mathmlexport.hxx
+++ b/starmath/source/mathmlexport.hxx
@@ -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);
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index a7133df..608ab7a 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -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*/)
diff --git a/starmath/source/mathmlimport.hxx b/starmath/source/mathmlimport.hxx
index 483256e..76363df 100644
--- a/starmath/source/mathmlimport.hxx
+++ b/starmath/source/mathmlimport.hxx
@@ -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,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 2dfbe31..df208b0 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -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 ),


More information about the Libreoffice-commits mailing list