summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2021-03-16 20:21:51 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-21 10:25:26 +0200
commit565bbd2e46e57117eb401344689858c3d749dc5c (patch)
treee12674204be6e0fdaf37cc8a4782a0687f21a512 /starmath
parent3c230b0a440ab4d434c4ddabd6959fb1654b6eff (diff)
Add mathml structures
Change-Id: I8324456b9a6775842f39e984c569c068381dc952 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112593 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/Library_sm.mk3
-rw-r--r--starmath/inc/mathml/attribute.hxx190
-rw-r--r--starmath/inc/mathml/def.hxx333
-rw-r--r--starmath/inc/mathml/element.hxx236
-rw-r--r--starmath/source/mathml/attribute.cxx450
-rw-r--r--starmath/source/mathml/def.cxx132
-rw-r--r--starmath/source/mathml/element.cxx134
7 files changed, 1478 insertions, 0 deletions
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index 89f9f34c59bf..2e3cc035ec5f 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -103,6 +103,9 @@ $(eval $(call gb_Library_add_exception_objects,sm,\
starmath/source/mathml/mathmlexport \
starmath/source/mathml/mathmlimport \
starmath/source/mathml/mathmlMo \
+ starmath/source/mathml/attribute \
+ starmath/source/mathml/element \
+ starmath/source/mathml/def \
starmath/source/mathml/starmathdatabase \
))
diff --git a/starmath/inc/mathml/attribute.hxx b/starmath/inc/mathml/attribute.hxx
new file mode 100644
index 000000000000..c30053c9d037
--- /dev/null
+++ b/starmath/inc/mathml/attribute.hxx
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include "def.hxx"
+
+/* All possible data needed to do the job outside mathml limits */
+// Ml prefix means it is part of mathml standar
+// NMl means it is not part of mathml standar but needed info to work
+
+/* Union for storing the mathml attribute value */
+/*************************************************************************************************/
+
+union SmMlAttributeValue {
+ SmMlAttributeValue(){};
+
+ struct SmMlAccent m_aAccent;
+ struct SmMlDir m_aDir;
+ struct SmMlDisplaystyle m_aDisplaystyle;
+ struct SmMlFence m_aFence;
+ struct SmMlHref m_aHref;
+ struct SmMlLspace m_aLspace;
+ struct SmMlMathbackground m_aMathbackground;
+ struct SmMlMathcolor m_aMathcolor;
+ struct SmMlMathsize m_aMathsize;
+ struct SmMlMathvariant m_aMathvariant;
+ struct SmMlMaxsize m_aMaxsize;
+ struct SmMlMinsize m_aMinsize;
+ struct SmMlMovablelimits m_aMovablelimits;
+ struct SmMlRspace m_aRspace;
+ struct SmMlSeparator m_aSeparator;
+ struct SmMlStretchy m_aStretchy;
+ struct SmMlSymmetric m_aSymmetric;
+};
+
+/* Class managing the attribute value */
+/*************************************************************************************************/
+
+class SmMlAttribute
+{
+private:
+ SmMlAttributeValueType m_aSmMlAttributeValueType;
+ SmMlAttributeValue m_aAttributeValue;
+
+private:
+ void clearPreviousAttributeValue();
+ void setDefaultAttributeValue();
+ void setAttributeValue(const SmMlAttribute* aMlAttribute);
+
+public:
+ SmMlAttribute() { m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty; };
+
+ virtual ~SmMlAttribute() { clearPreviousAttributeValue(); };
+
+ SmMlAttribute(SmMlAttributeValueType)
+ {
+ m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
+ setDefaultAttributeValue();
+ };
+
+ SmMlAttribute(const SmMlAttribute& aMlAttribute)
+ {
+ m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
+ setAttributeValue(&aMlAttribute);
+ }
+
+ SmMlAttribute(const SmMlAttribute* aMlAttribute)
+ {
+ m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
+ setAttributeValue(aMlAttribute);
+ }
+
+public:
+ /**
+ * Returns the type of attribute we are dealing with.
+ * Attribute Value Type
+ */
+ SmMlAttributeValueType getMlAttributeValueType() const { return m_aSmMlAttributeValueType; };
+
+ /**
+ * Checks if the attribute contains information.
+ * Attribute Value Type
+ */
+ bool isNullAttribute() const
+ {
+ return m_aSmMlAttributeValueType == SmMlAttributeValueType::NMlEmpty;
+ };
+
+ /**
+ * Compares the type of attribute with a given one.
+ * Attribute Value Type
+ */
+ bool isMlAttributeValueType(SmMlAttributeValueType aAttributeValueType) const
+ {
+ return m_aSmMlAttributeValueType == aAttributeValueType;
+ };
+
+ /**
+ * Set the type of attribute we are dealing with.
+ * @param Attribute Value Type
+ */
+ void setMlAttributeValueType(SmMlAttributeValueType aAttributeValueType)
+ {
+ clearPreviousAttributeValue();
+ m_aSmMlAttributeValueType = aAttributeValueType;
+ setDefaultAttributeValue();
+ }
+
+ void setMlAttributeValue(const SmMlAttribute& aMlAttribute)
+ {
+ setAttributeValue(&aMlAttribute);
+ }
+
+ void setMlAttributeValue(const SmMlAttribute* aMlAttribute) { setAttributeValue(aMlAttribute); }
+
+public:
+ // Get values
+ const struct SmMlAccent* getMlAccent() const;
+ const struct SmMlDir* getMlDir() const;
+ const struct SmMlDisplaystyle* getMlDisplaystyle() const;
+ const struct SmMlFence* getMlFence() const;
+ const struct SmMlHref* getMlHref() const;
+ const struct SmMlLspace* getMlLspace() const;
+ const struct SmMlMathbackground* getMlMathbackground() const;
+ const struct SmMlMathcolor* getMlMathcolor() const;
+ const struct SmMlMathsize* getMlMathsize() const;
+ const struct SmMlMathvariant* getMlMathvariant() const;
+ const struct SmMlMaxsize* getMlMaxsize() const;
+ const struct SmMlMinsize* getMlMinsize() const;
+ const struct SmMlMovablelimits* getMlMovablelimits() const;
+ const struct SmMlRspace* getMlRspace() const;
+ const struct SmMlSeparator* getMlSeparator() const;
+ const struct SmMlStretchy* getMlStretchy() const;
+ const struct SmMlSymmetric* getMlSymmetric() const;
+
+ // Set values
+ // Note that content is copied.
+ void setMlAccent(const SmMlAccent* aAccent);
+ void setMlDir(const SmMlDir* aDir);
+ void setMlDisplaystyle(const SmMlDisplaystyle* aDisplaystyle);
+ void setMlFence(const SmMlFence* aFence);
+ void setMlHref(const SmMlHref* aHref);
+ void setMlLspace(const SmMlLspace* aLspace);
+ void setMlMathbackground(const SmMlMathbackground* aMathbackground);
+ void setMlMathcolor(const SmMlMathcolor* aMathcolor);
+ void setMlMathsize(const SmMlMathsize* aMathsize);
+ void setMlMathvariant(const SmMlMathvariant* aMathvariant);
+ void setMlMaxsize(const SmMlMaxsize* aMaxsize);
+ void setMlMinsize(const SmMlMinsize* aMinSize);
+ void setMlMovablelimits(const SmMlMovablelimits* aMovablelimits);
+ void setMlRspace(const SmMlRspace* aRspace);
+ void setMlSeparator(const SmMlSeparator* aSeparator);
+ void setMlStretchy(const SmMlStretchy* aStretchy);
+ void setMlSymmetric(const SmMlSymmetric* aSymmetric);
+};
+
+/* element's attributes */
+/*************************************************************************************************/
+
+namespace starmathdatabase
+{
+extern SmMlAttributePos MlAttributeListEmpty[1];
+extern SmMlAttributePos MlAttributeListMath[1];
+extern SmMlAttributePos MlAttributeListMi[7];
+extern SmMlAttributePos MlAttributeListMerror[4];
+extern SmMlAttributePos MlAttributeListMn[7];
+extern SmMlAttributePos MlAttributeListMo[17];
+extern SmMlAttributePos MlAttributeListMrow[4];
+extern SmMlAttributePos MlAttributeListMtext[7];
+extern SmMlAttributePos MlAttributeListMstyle[17];
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/mathml/def.hxx b/starmath/inc/mathml/def.hxx
new file mode 100644
index 000000000000..6fccf79d6fab
--- /dev/null
+++ b/starmath/inc/mathml/def.hxx
@@ -0,0 +1,333 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <tools/color.hxx>
+
+/* All possible data needed to do the job outside mathml limits */
+// Ml prefix means it is part of mathml standar
+// NMl means it is not part of mathml standar but needed info to work
+
+/* For now empty, don't know yet what's needed besides default font size. */
+struct SmGlobalData
+{
+};
+
+/* Mthml length tools */
+/*************************************************************************************************/
+
+enum class SmLengthUnit : uint_fast8_t
+{
+ MlEm,
+ MlEx,
+ MlPx,
+ MlIn,
+ MlCm,
+ MlMM,
+ MlPt,
+ MlPc,
+ MlP // Percent
+};
+
+struct SmLengthValue
+{
+ SmLengthUnit m_aLengthUnit;
+ double m_aLengthValue;
+ // Keeps original text value to avoid numerial error data loss
+ OUString* m_aOriginalText;
+};
+
+/* Possible mathml elements */
+/*************************************************************************************************/
+
+enum class SmMlElementType : uint_fast8_t
+{
+ // Used for base element. Means no information contained.
+ NMlEmpty,
+ // Used for structural dependencies. Means no information contained.
+ NMlStructural,
+ NMlSmNode,
+ // Mathml real elements
+ MlMath,
+ MlMi,
+ MlMerror,
+ MlMn,
+ MlMo,
+ MlMrow,
+ MlMtext,
+ MlMstyle
+};
+
+/* Possible mathml attributes */
+/*************************************************************************************************/
+
+enum class SmMlAttributeValueType : uint_fast8_t
+{
+ NMlEmpty,
+ MlAccent,
+ MlDir,
+ MlDisplaystyle,
+ MlFence,
+ MlHref,
+ MlLspace,
+ MlMathbackground,
+ MlMathcolor,
+ MlMathsize,
+ MlMathvariant,
+ MlMaxsize,
+ MlMinsize,
+ MlMovablelimits,
+ MlRspace,
+ MlSeparator,
+ MlStretchy,
+ MlSymmetric
+};
+
+/* Possible values of mathml attributes */
+/*************************************************************************************************/
+
+enum class SmMlAttributeValueEmpty : uint_fast8_t
+{
+ MlEmpty = 0x00
+};
+
+enum class SmMlAttributeValueAccent : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+enum class SmMlAttributeValueDir : uint_fast8_t
+{
+ MlLtr = 0x00,
+ MlRtl = 0x01
+};
+
+enum class SmMlAttributeValueDisplaystyle : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+enum class SmMlAttributeValueFence : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+enum class SmMlAttributeValueHref : uint_fast8_t
+{
+ NMlEmpty = 0x00,
+ NMlValie = 0x01
+};
+
+enum class SmMlAttributeValueLspace : uint_fast8_t
+{
+ NMlEmpty = 0x00
+};
+
+enum class SmMlAttributeValueMathbackground : uint_fast32_t
+{
+ MlTransparent = 0x00,
+ MlRgb = 0x01
+};
+
+enum class SmMlAttributeValueMathcolor : uint_fast8_t
+{
+ MlDefault = 0x00,
+ MlRgb = 0x01
+};
+
+enum class SmMlAttributeValueMathsize : uint_fast8_t
+{
+ NMlEmpty = 0x00,
+};
+
+enum class SmMlAttributeValueMathvariant : uint_fast16_t
+{
+ normal = 0x000,
+ bold = 0x001,
+ italic = 0x002,
+ double_struck = 0x004,
+ script = 0x008,
+ fraktur = 0x010,
+ sans_serif = 0x020,
+ monospace = 0x040,
+ bold_italic = 0x001 | 0x002,
+ bold_fraktur = 0x001 | 0x010,
+ bold_script = 0x001 | 0x008,
+ bold_sans_serif = 0x001 | 0x020,
+ sans_serif_italic = 0x001 | 0x002 | 0x20,
+ sans_serif_bold_italic = 0x001 | 0x002 | 0x020,
+ // Non english
+ initial = 0x080,
+ tailed = 0x100,
+ looped = 0x200,
+ stretched = 0x400
+};
+
+enum class SmMlAttributeValueMaxsize : uint_fast8_t
+{
+ MlInfinity = 0x00,
+ MlFinite = 0x01
+};
+
+enum class SmMlAttributeValueMinsize : uint_fast8_t
+{
+ MlInfinity = 0x00,
+ MlFinite = 0x01
+};
+
+/*
+ * Specifies whether attached under- and overscripts move to sub- and superscript positions when displaystyle is false.
+ * Source: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
+ */
+enum class SmMlAttributeValueMovablelimits : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+enum class SmMlAttributeValueRspace : uint_fast8_t
+{
+ NMlEmpty = 0x00
+};
+
+enum class SmMlAttributeValueSeparator : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+enum class SmMlAttributeValueStretchy : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+enum class SmMlAttributeValueSymmetric : uint_fast8_t
+{
+ MlFalse = 0x00,
+ MlTrue = 0x01
+};
+
+/* Structures for all possible attributes */
+/*************************************************************************************************/
+
+struct SmMlAccent
+{
+ SmMlAttributeValueAccent m_aAccent;
+};
+
+struct SmMlDir
+{
+ SmMlAttributeValueDir m_aDir;
+};
+
+struct SmMlDisplaystyle
+{
+ SmMlAttributeValueDisplaystyle m_aDisplaystyle;
+};
+
+struct SmMlFence
+{
+ SmMlAttributeValueFence m_aFence;
+};
+
+struct SmMlHref
+{
+ SmMlAttributeValueHref m_aHref;
+ OUString* m_aLnk;
+};
+
+struct SmMlLspace
+{
+ SmLengthValue m_aLengthValue;
+};
+
+struct SmMlMathbackground
+{
+ SmMlAttributeValueMathbackground m_aMathbackground;
+ Color m_aCol;
+};
+
+struct SmMlMathcolor
+{
+ SmMlAttributeValueMathcolor m_aMathcolor;
+ Color m_aCol;
+};
+
+struct SmMlMathsize
+{
+ SmLengthValue m_aLengthValue;
+};
+
+struct SmMlMathvariant
+{
+ SmMlAttributeValueMathvariant m_aMathvariant;
+};
+
+struct SmMlMaxsize
+{
+ SmMlAttributeValueMaxsize m_aMaxsize;
+ SmLengthValue m_aLengthValue;
+};
+
+struct SmMlMinsize
+{
+ SmMlAttributeValueMinsize m_aMinsize;
+ SmLengthValue m_aLengthValue;
+};
+
+struct SmMlMovablelimits
+{
+ SmMlAttributeValueMovablelimits m_aMovablelimits;
+};
+
+struct SmMlRspace
+{
+ SmLengthValue m_aLengthValue;
+};
+
+struct SmMlSeparator
+{
+ SmMlAttributeValueSeparator m_aSeparator;
+};
+
+struct SmMlStretchy
+{
+ SmMlAttributeValueStretchy m_aStretchy;
+};
+
+struct SmMlSymmetric
+{
+ SmMlAttributeValueSymmetric m_aSymmetric;
+};
+
+/* order attributes */
+/*************************************************************************************************/
+
+struct SmMlAttributePos
+{
+ SmMlAttributeValueType m_aAttributeValueType;
+ uint_fast8_t m_nPos;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/mathml/element.hxx b/starmath/inc/mathml/element.hxx
new file mode 100644
index 000000000000..e58506077e33
--- /dev/null
+++ b/starmath/inc/mathml/element.hxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include "attribute.hxx"
+#include <rect.hxx>
+
+#include <editeng/editdata.hxx>
+
+class SmMlElement : public SmRect
+{
+ /* Technical stuff */
+
+public:
+ SmMlElement()
+ : m_aElementType(SmMlElementType::NMlEmpty)
+ , m_aText(u"")
+ , m_aESelection(0, 0, 0, 0)
+ , m_aAttributeList(0)
+ , m_aAttributePosList(0)
+ , m_aSubElements(0)
+ , m_aParentElement(nullptr)
+ {
+ SmImplAttributeType();
+ };
+ /* Mathml stuff */
+
+protected:
+ SmMlElement(SmMlElementType aElementType)
+ : m_aElementType(aElementType)
+ , m_aText(u"\u00B6")
+ , m_aESelection(0, 0, 0, 0)
+ , m_aSubElements(0)
+ , m_aParentElement(nullptr)
+ {
+ SmImplAttributeType();
+ };
+
+private:
+ // Type of element
+ SmMlElementType m_aElementType;
+
+ // Element text
+ OUString m_aText;
+
+ // Location in source code
+ ESelection m_aESelection;
+
+ // Attribute list
+ std::vector<SmMlAttribute> m_aAttributeList;
+
+ // Attribute position list
+ std::vector<SmMlAttributePos> m_aAttributePosList;
+
+ // Sub elements
+ std::vector<SmMlElement*> m_aSubElements;
+
+ // Parent element
+ SmMlElement* m_aParentElement;
+
+private:
+ void SmImplAttributeType();
+
+public: // Element type
+ /**
+ * Returns the mathml element type
+ * @return mathml element type
+ */
+ SmMlElementType getMlElementType() const { return m_aElementType; };
+
+ /**
+ * Check if the mathml element is of a given type
+ * @param aElementType
+ * @return is mathml element type
+ */
+ bool isMlElementType(SmMlElementType aElementType) const
+ {
+ return m_aElementType == aElementType;
+ };
+
+public: // location in the source
+ /**
+ * Returns the location in the source code of the node type
+ * @return selection
+ */
+ ESelection getESelection() const { return m_aESelection; };
+
+ /**
+ * Sets the location in the source code of the node type
+ * @param aESelection
+ */
+ void setESelection(ESelection aESelection) { m_aESelection = aESelection; };
+
+ /**
+ * Gets the line in the text where the node is located.
+ * It is used to do the visual <-> text correspondence.
+ * @return line
+ */
+ sal_Int32 GetSourceCodeRow() const { return m_aESelection.nStartPara; }
+
+ /**
+ * Gets the column of the line in the text where the node is located.
+ * It is used to do the visual <-> text correspondence.
+ * @return column
+ */
+ sal_Int32 GetSourceCodeColumn() const { return m_aESelection.nStartPos; }
+
+public: // attributes
+ /**
+ * Returns the amount of available attributes
+ * @return attribute count
+ */
+ size_t getAttributeCount() const { return m_aAttributeList.size(); };
+
+ /**
+ * Get's a given attribute.
+ * If no available returns empty attribute.
+ * @param nAttributePos
+ * @return given attribute.
+ */
+ SmMlAttribute getAttribute(size_t nAttributePos) const
+ {
+ return nAttributePos < m_aAttributeList.size() ? m_aAttributeList[nAttributePos]
+ : SmMlAttribute();
+ }
+
+ /**
+ * Get's a given attribute.
+ * If no available returns empty attribute.
+ * @param nAttributePos
+ * @return given attribute.
+ */
+ SmMlAttribute getAttribute(SmMlAttributeValueType aElementType) const;
+
+ /**
+ * Set's a given attribute.
+ * If no available does nothing.
+ * @param nAttributePos
+ * @return given attribute.
+ */
+ void setAttribute(const SmMlAttribute* aAttribute);
+
+public: // sub elements
+ /**
+ * Returns the sub elements count
+ * @return sub elements count
+ */
+ size_t getSubElementsCount() const { return m_aSubElements.size(); };
+
+ /**
+ * Returns a given sub element
+ * @param nPos
+ * @return sub elements
+ */
+ SmMlElement* getSubElement(size_t nPos)
+ {
+ return nPos < m_aSubElements.size() ? m_aSubElements[nPos] : nullptr;
+ };
+
+ /**
+ * Returns a given sub element
+ * @param nPos
+ * @return sub elements
+ */
+ const SmMlElement* getSubElement(size_t nPos) const
+ {
+ return nPos < m_aSubElements.size() ? m_aSubElements[nPos] : nullptr;
+ };
+
+ /**
+ * Sets a given sub element
+ * @param nPos
+ * @param aElement
+ */
+ void setSubElement(size_t nPos, SmMlElement* aElement);
+
+public: // parent elements
+ /**
+ * Returns the parent element
+ * @return parent element
+ */
+ SmMlElement* getParentElement() { return m_aParentElement; };
+
+ /**
+ * Returns the parent element
+ * @return parent element
+ */
+ const SmMlElement* getParentElement() const { return m_aParentElement; };
+
+ /**
+ * Sets the parent element
+ * No allocation / free is done.
+ * @param aParentElement
+ */
+ void setParentElement(SmMlElement* aParentElement) { m_aParentElement = aParentElement; };
+
+public: // text elements
+ /**
+ * Returns the element text
+ */
+ OUString getText() const { return m_aText; };
+
+ /**
+ * Returns the element text
+ */
+ void setText(OUString aText) { m_aText = aText; };
+};
+
+namespace starmathdatabase
+{
+/**
+ * Generates an attribute vector of default values from an attribute position list.
+ * @param aAttributePosList
+ * @return attribute vector
+ */
+std::vector<SmMlAttribute> makeMlAttributeList(std::vector<SmMlAttributePos> aAttributePosList);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/mathml/attribute.cxx b/starmath/source/mathml/attribute.cxx
new file mode 100644
index 000000000000..dac917de9874
--- /dev/null
+++ b/starmath/source/mathml/attribute.cxx
@@ -0,0 +1,450 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <mathml/attribute.hxx>
+
+void SmMlAttribute::clearPreviousAttributeValue()
+{
+ switch (m_aSmMlAttributeValueType)
+ {
+ case SmMlAttributeValueType::NMlEmpty:
+ break;
+ case SmMlAttributeValueType::MlHref:
+ if (m_aAttributeValue.m_aHref.m_aLnk)
+ delete m_aAttributeValue.m_aHref.m_aLnk;
+ break;
+ case SmMlAttributeValueType::MlLspace:
+ if (m_aAttributeValue.m_aLspace.m_aLengthValue.m_aOriginalText)
+ delete m_aAttributeValue.m_aLspace.m_aLengthValue.m_aOriginalText;
+ break;
+ case SmMlAttributeValueType::MlMathsize:
+ if (m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aOriginalText)
+ delete m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aOriginalText;
+ break;
+ case SmMlAttributeValueType::MlMaxsize:
+ if (m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aOriginalText)
+ delete m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aOriginalText;
+ break;
+ case SmMlAttributeValueType::MlMinsize:
+ if (m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aOriginalText)
+ delete m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aOriginalText;
+ break;
+ case SmMlAttributeValueType::MlRspace:
+ if (m_aAttributeValue.m_aRspace.m_aLengthValue.m_aOriginalText)
+ delete m_aAttributeValue.m_aRspace.m_aLengthValue.m_aOriginalText;
+ break;
+ default:
+ break;
+ }
+}
+
+void SmMlAttribute::setDefaultAttributeValue()
+{
+ switch (m_aSmMlAttributeValueType)
+ {
+ case SmMlAttributeValueType::NMlEmpty:
+ break;
+ case SmMlAttributeValueType::MlAccent:
+ m_aAttributeValue.m_aAccent.m_aAccent = SmMlAttributeValueAccent::MlFalse;
+ break;
+ case SmMlAttributeValueType::MlDir:
+ m_aAttributeValue.m_aDir.m_aDir = SmMlAttributeValueDir::MlLtr;
+ break;
+ case SmMlAttributeValueType::MlDisplaystyle:
+ m_aAttributeValue.m_aDisplaystyle.m_aDisplaystyle
+ = SmMlAttributeValueDisplaystyle::MlFalse;
+ break;
+ case SmMlAttributeValueType::MlFence:
+ m_aAttributeValue.m_aFence.m_aFence = SmMlAttributeValueFence::MlFalse;
+ break;
+ case SmMlAttributeValueType::MlHref:
+ m_aAttributeValue.m_aHref.m_aHref = SmMlAttributeValueHref::NMlEmpty;
+ m_aAttributeValue.m_aHref.m_aLnk = new OUString(u"");
+ break;
+ case SmMlAttributeValueType::MlLspace:
+ m_aAttributeValue.m_aLspace.m_aLengthValue.m_aLengthUnit = SmLengthUnit::MlEm;
+ m_aAttributeValue.m_aLspace.m_aLengthValue.m_aLengthValue = 5.0 / 18;
+ m_aAttributeValue.m_aLspace.m_aLengthValue.m_aOriginalText = new OUString(u"5/18em");
+ break;
+ case SmMlAttributeValueType::MlMathbackground:
+ m_aAttributeValue.m_aMathbackground.m_aMathbackground
+ = SmMlAttributeValueMathbackground::MlTransparent;
+ break;
+ case SmMlAttributeValueType::MlMathcolor:
+ m_aAttributeValue.m_aMathcolor.m_aMathcolor = SmMlAttributeValueMathcolor::MlDefault;
+ break;
+ case SmMlAttributeValueType::MlMathsize:
+ m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aLengthUnit = SmLengthUnit::MlP;
+ m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aLengthValue = 100;
+ m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aOriginalText = new OUString(u"100%");
+ break;
+ case SmMlAttributeValueType::MlMathvariant:
+ m_aAttributeValue.m_aMathvariant.m_aMathvariant = SmMlAttributeValueMathvariant::normal;
+ break;
+ case SmMlAttributeValueType::MlMaxsize:
+ m_aAttributeValue.m_aMaxsize.m_aMaxsize = SmMlAttributeValueMaxsize::MlInfinity;
+ m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aLengthUnit = SmLengthUnit::MlP;
+ m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aLengthValue = 10000;
+ m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aOriginalText = new OUString(u"10000%");
+ break;
+ case SmMlAttributeValueType::MlMinsize:
+ m_aAttributeValue.m_aMinsize.m_aMinsize = SmMlAttributeValueMinsize::MlInfinity;
+ m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aLengthUnit = SmLengthUnit::MlP;
+ m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aLengthValue = 1;
+ m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aOriginalText = new OUString(u"1%");
+ break;
+ case SmMlAttributeValueType::MlMovablelimits:
+ m_aAttributeValue.m_aMovablelimits.m_aMovablelimits
+ = SmMlAttributeValueMovablelimits::MlFalse;
+ break;
+ case SmMlAttributeValueType::MlRspace:
+ m_aAttributeValue.m_aRspace.m_aLengthValue.m_aLengthUnit = SmLengthUnit::MlEm;
+ m_aAttributeValue.m_aRspace.m_aLengthValue.m_aLengthValue = 5.0 / 18;
+ m_aAttributeValue.m_aRspace.m_aLengthValue.m_aOriginalText = new OUString(u"5/18em");
+ break;
+ case SmMlAttributeValueType::MlSeparator:
+ m_aAttributeValue.m_aSeparator.m_aSeparator = SmMlAttributeValueSeparator::MlFalse;
+ break;
+ case SmMlAttributeValueType::MlStretchy:
+ m_aAttributeValue.m_aStretchy.m_aStretchy = SmMlAttributeValueStretchy::MlFalse;
+ break;
+ case SmMlAttributeValueType::MlSymmetric:
+ m_aAttributeValue.m_aSymmetric.m_aSymmetric = SmMlAttributeValueSymmetric::MlFalse;
+ break;
+ }
+}
+
+void SmMlAttribute::setAttributeValue(const SmMlAttribute* aAttribute)
+{
+ switch (aAttribute->getMlAttributeValueType())
+ {
+ case SmMlAttributeValueType::NMlEmpty:
+ clearPreviousAttributeValue();
+ m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
+ break;
+ case SmMlAttributeValueType::MlAccent:
+ setMlAccent(aAttribute->getMlAccent());
+ break;
+ case SmMlAttributeValueType::MlDir:
+ setMlDir(aAttribute->getMlDir());
+ break;
+ case SmMlAttributeValueType::MlDisplaystyle:
+ setMlDisplaystyle(aAttribute->getMlDisplaystyle());
+ break;
+ case SmMlAttributeValueType::MlFence:
+ setMlFence(aAttribute->getMlFence());
+ break;
+ case SmMlAttributeValueType::MlHref:
+ setMlHref(aAttribute->getMlHref());
+ break;
+ case SmMlAttributeValueType::MlLspace:
+ setMlLspace(aAttribute->getMlLspace());
+ break;
+ case SmMlAttributeValueType::MlMathbackground:
+ setMlMathbackground(aAttribute->getMlMathbackground());
+ break;
+ case SmMlAttributeValueType::MlMathcolor:
+ setMlMathcolor(aAttribute->getMlMathcolor());
+ break;
+ case SmMlAttributeValueType::MlMathsize:
+ setMlMathsize(aAttribute->getMlMathsize());
+ break;
+ case SmMlAttributeValueType::MlMathvariant:
+ setMlMathvariant(aAttribute->getMlMathvariant());
+ break;
+ case SmMlAttributeValueType::MlMaxsize:
+ setMlMaxsize(aAttribute->getMlMaxsize());
+ break;
+ case SmMlAttributeValueType::MlMinsize:
+ setMlMinsize(aAttribute->getMlMinsize());
+ break;
+ case SmMlAttributeValueType::MlMovablelimits:
+ setMlMovablelimits(aAttribute->getMlMovablelimits());
+ break;
+ case SmMlAttributeValueType::MlRspace:
+ setMlRspace(aAttribute->getMlRspace());
+ break;
+ case SmMlAttributeValueType::MlSeparator:
+ setMlSeparator(aAttribute->getMlSeparator());
+ break;
+ case SmMlAttributeValueType::MlStretchy:
+ setMlStretchy(aAttribute->getMlStretchy());
+ break;
+ case SmMlAttributeValueType::MlSymmetric:
+ setMlSymmetric(aAttribute->getMlSymmetric());
+ break;
+ }
+}
+
+/* get values */
+/*************************************************************************************************/
+
+const struct SmMlAccent* SmMlAttribute::getMlAccent() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlAccent)
+ return &m_aAttributeValue.m_aAccent;
+ return nullptr;
+}
+
+const struct SmMlDir* SmMlAttribute::getMlDir() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlDir)
+ return &m_aAttributeValue.m_aDir;
+ return nullptr;
+}
+
+const struct SmMlDisplaystyle* SmMlAttribute::getMlDisplaystyle() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlDisplaystyle)
+ return &m_aAttributeValue.m_aDisplaystyle;
+ return nullptr;
+}
+
+const struct SmMlFence* SmMlAttribute::getMlFence() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlFence)
+ return &m_aAttributeValue.m_aFence;
+ return nullptr;
+}
+
+const struct SmMlHref* SmMlAttribute::getMlHref() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlHref)
+ return &m_aAttributeValue.m_aHref;
+ return nullptr;
+}
+
+const struct SmMlLspace* SmMlAttribute::getMlLspace() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlLspace)
+ return &m_aAttributeValue.m_aLspace;
+ return nullptr;
+}
+
+const struct SmMlMathbackground* SmMlAttribute::getMlMathbackground() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlMathbackground)
+ return &m_aAttributeValue.m_aMathbackground;
+ return nullptr;
+}
+
+const struct SmMlMathcolor* SmMlAttribute::getMlMathcolor() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlMathcolor)
+ return &m_aAttributeValue.m_aMathcolor;
+ return nullptr;
+}
+
+const struct SmMlMathsize* SmMlAttribute::getMlMathsize() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlAccent)
+ return &m_aAttributeValue.m_aMathsize;
+ return nullptr;
+}
+
+const struct SmMlMathvariant* SmMlAttribute::getMlMathvariant() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlMathvariant)
+ return &m_aAttributeValue.m_aMathvariant;
+ return nullptr;
+}
+
+const struct SmMlMaxsize* SmMlAttribute::getMlMaxsize() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlMaxsize)
+ return &m_aAttributeValue.m_aMaxsize;
+ return nullptr;
+}
+
+const struct SmMlMinsize* SmMlAttribute::getMlMinsize() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlMinsize)
+ return &m_aAttributeValue.m_aMinsize;
+ return nullptr;
+}
+
+const struct SmMlMovablelimits* SmMlAttribute::getMlMovablelimits() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlMovablelimits)
+ return &m_aAttributeValue.m_aMovablelimits;
+ return nullptr;
+}
+
+const struct SmMlRspace* SmMlAttribute::getMlRspace() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlRspace)
+ return &m_aAttributeValue.m_aRspace;
+ return nullptr;
+}
+
+const struct SmMlSeparator* SmMlAttribute::getMlSeparator() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlSeparator)
+ return &m_aAttributeValue.m_aSeparator;
+ return nullptr;
+}
+
+const struct SmMlStretchy* SmMlAttribute::getMlStretchy() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlStretchy)
+ return &m_aAttributeValue.m_aStretchy;
+ return nullptr;
+}
+
+const struct SmMlSymmetric* SmMlAttribute::getMlSymmetric() const
+{
+ if (m_aSmMlAttributeValueType == SmMlAttributeValueType::MlSymmetric)
+ return &m_aAttributeValue.m_aSymmetric;
+ return nullptr;
+}
+
+/* set values */
+/*************************************************************************************************/
+
+void SmMlAttribute::setMlAccent(const SmMlAccent* aAccent)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aAccent.m_aAccent = aAccent->m_aAccent;
+}
+
+void SmMlAttribute::setMlDir(const SmMlDir* aDir)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aDir.m_aDir = aDir->m_aDir;
+}
+
+void SmMlAttribute::setMlDisplaystyle(const SmMlDisplaystyle* aDisplaystyle)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aDisplaystyle.m_aDisplaystyle = aDisplaystyle->m_aDisplaystyle;
+}
+
+void SmMlAttribute::setMlFence(const SmMlFence* aFence)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aFence.m_aFence = aFence->m_aFence;
+}
+
+void SmMlAttribute::setMlHref(const SmMlHref* aHref)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aHref.m_aHref = aHref->m_aHref;
+ m_aAttributeValue.m_aHref.m_aLnk = new OUString(*aHref->m_aLnk);
+}
+
+void SmMlAttribute::setMlLspace(const SmMlLspace* aLspace)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aLspace.m_aLengthValue.m_aLengthUnit
+ = aLspace->m_aLengthValue.m_aLengthUnit;
+ m_aAttributeValue.m_aLspace.m_aLengthValue.m_aLengthValue
+ = aLspace->m_aLengthValue.m_aLengthValue;
+ m_aAttributeValue.m_aLspace.m_aLengthValue.m_aOriginalText
+ = new OUString(*aLspace->m_aLengthValue.m_aOriginalText);
+}
+
+void SmMlAttribute::setMlMathbackground(const SmMlMathbackground* aMathbackground)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMathbackground.m_aMathbackground = aMathbackground->m_aMathbackground;
+}
+
+void SmMlAttribute::setMlMathcolor(const SmMlMathcolor* aMathcolor)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMathcolor.m_aMathcolor = aMathcolor->m_aMathcolor;
+}
+
+void SmMlAttribute::setMlMathsize(const SmMlMathsize* aMathsize)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aLengthUnit
+ = aMathsize->m_aLengthValue.m_aLengthUnit;
+ m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aLengthValue
+ = aMathsize->m_aLengthValue.m_aLengthValue;
+ m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aOriginalText
+ = new OUString(*aMathsize->m_aLengthValue.m_aOriginalText);
+}
+
+void SmMlAttribute::setMlMathvariant(const SmMlMathvariant* aMathvariant)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMathvariant.m_aMathvariant = aMathvariant->m_aMathvariant;
+}
+
+void SmMlAttribute::setMlMaxsize(const SmMlMaxsize* aMaxsize)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMaxsize.m_aMaxsize = aMaxsize->m_aMaxsize;
+ m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aLengthUnit
+ = aMaxsize->m_aLengthValue.m_aLengthUnit;
+ m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aLengthValue
+ = aMaxsize->m_aLengthValue.m_aLengthValue;
+ m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aOriginalText
+ = new OUString(*aMaxsize->m_aLengthValue.m_aOriginalText);
+}
+
+void SmMlAttribute::setMlMinsize(const SmMlMinsize* aMinsize)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMinsize.m_aMinsize = aMinsize->m_aMinsize;
+ m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aLengthUnit
+ = aMinsize->m_aLengthValue.m_aLengthUnit;
+ m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aLengthValue
+ = aMinsize->m_aLengthValue.m_aLengthValue;
+ m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aOriginalText
+ = new OUString(*aMinsize->m_aLengthValue.m_aOriginalText);
+}
+
+void SmMlAttribute::setMlMovablelimits(const SmMlMovablelimits* aMovablelimits)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aMovablelimits.m_aMovablelimits = aMovablelimits->m_aMovablelimits;
+}
+
+void SmMlAttribute::setMlRspace(const SmMlRspace* aRspace)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aRspace.m_aLengthValue.m_aLengthUnit
+ = aRspace->m_aLengthValue.m_aLengthUnit;
+ m_aAttributeValue.m_aRspace.m_aLengthValue.m_aLengthValue
+ = aRspace->m_aLengthValue.m_aLengthValue;
+ m_aAttributeValue.m_aRspace.m_aLengthValue.m_aOriginalText
+ = new OUString(*aRspace->m_aLengthValue.m_aOriginalText);
+}
+
+void SmMlAttribute::setMlSeparator(const SmMlSeparator* aSeparator)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aSeparator.m_aSeparator = aSeparator->m_aSeparator;
+}
+
+void SmMlAttribute::setMlStretchy(const SmMlStretchy* aStretchy)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aStretchy.m_aStretchy = aStretchy->m_aStretchy;
+}
+
+void SmMlAttribute::setMlSymmetric(const SmMlSymmetric* aSymmetric)
+{
+ clearPreviousAttributeValue();
+ m_aAttributeValue.m_aSymmetric.m_aSymmetric = aSymmetric->m_aSymmetric;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/mathml/def.cxx b/starmath/source/mathml/def.cxx
new file mode 100644
index 000000000000..fe4c70299dc9
--- /dev/null
+++ b/starmath/source/mathml/def.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <mathml/attribute.hxx>
+
+SmMlAttributePos starmathdatabase::MlAttributeListEmpty[] = {
+ // clang-format off
+ { SmMlAttributeValueType::NMlEmpty, 0 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMath[] = {
+ // clang-format off
+ { SmMlAttributeValueType::NMlEmpty, 0 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMi[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlDir, 1 },
+ { SmMlAttributeValueType::MlMathbackground, 2 },
+ { SmMlAttributeValueType::MlMathcolor, 3 },
+ { SmMlAttributeValueType::MlDisplaystyle, 4 },
+ { SmMlAttributeValueType::MlMathsize, 5 },
+ { SmMlAttributeValueType::MlMathvariant, 6 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMerror[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlMathbackground, 1 },
+ { SmMlAttributeValueType::MlMathcolor, 2 },
+ { SmMlAttributeValueType::MlDisplaystyle, 3 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMn[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlDir, 1 },
+ { SmMlAttributeValueType::MlMathbackground, 2 },
+ { SmMlAttributeValueType::MlMathcolor, 3 },
+ { SmMlAttributeValueType::MlDisplaystyle, 4 },
+ { SmMlAttributeValueType::MlMathsize, 5 },
+ { SmMlAttributeValueType::MlMathvariant, 6 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMo[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlDir, 1 },
+ { SmMlAttributeValueType::MlMathbackground, 2 },
+ { SmMlAttributeValueType::MlMathcolor, 3 },
+ { SmMlAttributeValueType::MlDisplaystyle, 4 },
+ { SmMlAttributeValueType::MlMathsize, 5 },
+ { SmMlAttributeValueType::MlMathvariant, 6 },
+ { SmMlAttributeValueType::MlFence, 7 },
+ { SmMlAttributeValueType::MlMaxsize, 8 },
+ { SmMlAttributeValueType::MlMinsize, 9 },
+ { SmMlAttributeValueType::MlMovablelimits, 10 },
+ { SmMlAttributeValueType::MlLspace, 11 },
+ { SmMlAttributeValueType::MlRspace, 12 },
+ { SmMlAttributeValueType::MlAccent, 13 },
+ { SmMlAttributeValueType::MlStretchy, 14 },
+ { SmMlAttributeValueType::MlSeparator, 15 },
+ { SmMlAttributeValueType::MlSymmetric, 16 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMrow[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlDir, 1 },
+ { SmMlAttributeValueType::MlMathbackground, 2 },
+ { SmMlAttributeValueType::MlMathcolor, 3 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMtext[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlDir, 1 },
+ { SmMlAttributeValueType::MlMathbackground, 2 },
+ { SmMlAttributeValueType::MlMathcolor, 3 },
+ { SmMlAttributeValueType::MlDisplaystyle, 4 },
+ { SmMlAttributeValueType::MlMathsize, 5 },
+ { SmMlAttributeValueType::MlMathvariant, 6 }
+ // clang-format on
+};
+
+SmMlAttributePos starmathdatabase::MlAttributeListMstyle[] = {
+ // clang-format off
+ { SmMlAttributeValueType::MlHref, 0 },
+ { SmMlAttributeValueType::MlDir, 1 },
+ { SmMlAttributeValueType::MlMathbackground, 2 },
+ { SmMlAttributeValueType::MlMathcolor, 3 },
+ { SmMlAttributeValueType::MlDisplaystyle, 4 },
+ { SmMlAttributeValueType::MlMathsize, 5 },
+ { SmMlAttributeValueType::MlMathvariant, 6 },
+ { SmMlAttributeValueType::MlFence, 7 },
+ { SmMlAttributeValueType::MlMaxsize, 8 },
+ { SmMlAttributeValueType::MlMinsize, 9 },
+ { SmMlAttributeValueType::MlMovablelimits, 10 },
+ { SmMlAttributeValueType::MlLspace, 11 },
+ { SmMlAttributeValueType::MlRspace, 12 },
+ { SmMlAttributeValueType::MlAccent, 13 },
+ { SmMlAttributeValueType::MlStretchy, 14 },
+ { SmMlAttributeValueType::MlSeparator, 15 },
+ { SmMlAttributeValueType::MlSymmetric, 16 }
+ // clang-format on
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/mathml/element.cxx b/starmath/source/mathml/element.cxx
new file mode 100644
index 000000000000..32ac040e0f2e
--- /dev/null
+++ b/starmath/source/mathml/element.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <mathml/element.hxx>
+
+void SmMlElement::SmImplAttributeType()
+{
+ switch (m_aElementType)
+ {
+ case SmMlElementType::NMlEmpty:
+ m_aAttributePosList = std::vector<SmMlAttributePos>(0);
+ break;
+ case SmMlElementType::NMlStructural:
+ m_aAttributePosList = std::vector<SmMlAttributePos>(0);
+ break;
+ case SmMlElementType::NMlSmNode:
+ m_aAttributePosList = std::vector<SmMlAttributePos>(0);
+ break;
+ case SmMlElementType::MlMath:
+ m_aAttributePosList = std::vector<SmMlAttributePos>(0);
+ //m_aAttributePosList = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMath), std::end(starmathdatabase::MlAttributeListMath));
+ break;
+ case SmMlElementType::MlMi:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMi),
+ std::end(starmathdatabase::MlAttributeListMi));
+ break;
+ case SmMlElementType::MlMerror:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMerror),
+ std::end(starmathdatabase::MlAttributeListMerror));
+ break;
+ case SmMlElementType::MlMn:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMn),
+ std::end(starmathdatabase::MlAttributeListMn));
+ break;
+ case SmMlElementType::MlMo:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMo),
+ std::end(starmathdatabase::MlAttributeListMo));
+ break;
+ case SmMlElementType::MlMrow:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMrow),
+ std::end(starmathdatabase::MlAttributeListMrow));
+ break;
+ case SmMlElementType::MlMtext:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMtext),
+ std::end(starmathdatabase::MlAttributeListMtext));
+ break;
+ case SmMlElementType::MlMstyle:
+ m_aAttributePosList
+ = std::vector<SmMlAttributePos>(std::begin(starmathdatabase::MlAttributeListMstyle),
+ std::end(starmathdatabase::MlAttributeListMstyle));
+ break;
+ default:
+ break;
+ }
+ // Create attribute vector with given pattern
+ m_aAttributeList = starmathdatabase::makeMlAttributeList(m_aAttributePosList);
+}
+
+SmMlAttribute SmMlElement::getAttribute(SmMlAttributeValueType aElementType) const
+{
+ // Look for the attribute position and return if exists
+ for (size_t i = 0; i < m_aAttributePosList.size(); ++i)
+ {
+ if (m_aAttributePosList[i].m_aAttributeValueType == aElementType)
+ return m_aAttributeList[m_aAttributePosList[i].m_nPos];
+ }
+ return SmMlAttribute();
+}
+
+void SmMlElement::setAttribute(const SmMlAttribute* aAttribute)
+{
+ // Look for the attribute position and assign if exists
+ for (size_t i = 0; i < m_aAttributePosList.size(); ++i)
+ {
+ if (m_aAttributePosList[i].m_aAttributeValueType == aAttribute->getMlAttributeValueType())
+ {
+ m_aAttributeList[m_aAttributePosList[i].m_nPos].setMlAttributeValue(aAttribute);
+ break;
+ }
+ }
+}
+
+void SmMlElement::setSubElement(size_t nPos, SmMlElement* aElement)
+{
+ // This is the new parent element
+ aElement->setParentElement(this);
+ // Check if the vector is long enought
+ // Careful nOldSize can be 0 and -1 will underflow
+ // We must put something on the empty locations
+ size_t nOldSize = m_aSubElements.size();
+ if (nPos + 1 > nOldSize)
+ {
+ m_aSubElements.resize(nPos + 1);
+ for (; nOldSize < nPos; ++nOldSize)
+ m_aSubElements[nOldSize] = nullptr;
+ }
+ // Assign value
+ m_aSubElements[nPos] = aElement;
+}
+
+std::vector<SmMlAttribute>
+starmathdatabase::makeMlAttributeList(std::vector<SmMlAttributePos> aAttributePosList)
+{
+ std::vector<SmMlAttribute> aAttributeList(aAttributePosList.size());
+ for (size_t i = 0; i < aAttributePosList.size(); ++i)
+ {
+ aAttributeList[i].setMlAttributeValueType(aAttributePosList[i].m_aAttributeValueType);
+ }
+ return aAttributeList;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */