summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2021-08-13 19:51:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-15 09:10:13 +0200
commitffaaec23ad94f9bec5fd0fcb02603270eb660b81 (patch)
treeb0ddcff0d02ae0ddddd04888674cf1c00fae4525 /starmath
parent73b6462b81080c63e6668979f4a9cd00242925e9 (diff)
Add the possibility to check if a mathml attribute is manually set
Change-Id: I9c5eaee8e2cce47d9286306031e807ca2c0eed57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120473 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/mathml/attribute.hxx30
-rw-r--r--starmath/inc/mathml/element.hxx7
-rw-r--r--starmath/source/mathml/attribute.cxx18
-rw-r--r--starmath/source/mathml/element.cxx15
-rw-r--r--starmath/source/mathml/export.cxx3
5 files changed, 65 insertions, 8 deletions
diff --git a/starmath/inc/mathml/attribute.hxx b/starmath/inc/mathml/attribute.hxx
index cbe042827d85..946e9f463e9c 100644
--- a/starmath/inc/mathml/attribute.hxx
+++ b/starmath/inc/mathml/attribute.hxx
@@ -49,6 +49,7 @@ class SmMlAttribute
private:
SmMlAttributeValueType m_aSmMlAttributeValueType;
SmMlAttributeValue m_aAttributeValue;
+ bool m_bSet;
private:
void clearPreviousAttributeValue();
@@ -56,29 +57,43 @@ private:
void setAttributeValue(const SmMlAttribute* aMlAttribute);
public:
- SmMlAttribute() { m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty; };
+ SmMlAttribute()
+ : m_aSmMlAttributeValueType(SmMlAttributeValueType::NMlEmpty)
+ , m_bSet(false){};
~SmMlAttribute() { clearPreviousAttributeValue(); };
SmMlAttribute(SmMlAttributeValueType)
+ : m_aSmMlAttributeValueType(SmMlAttributeValueType::NMlEmpty)
+ , m_bSet(false)
{
- m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
setDefaultAttributeValue();
};
SmMlAttribute(const SmMlAttribute& aMlAttribute)
+ : m_aSmMlAttributeValueType(SmMlAttributeValueType::NMlEmpty)
+ , m_bSet(aMlAttribute.isSet())
{
- m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
setAttributeValue(&aMlAttribute);
}
SmMlAttribute(const SmMlAttribute* aMlAttribute)
+ : m_aSmMlAttributeValueType(SmMlAttributeValueType::NMlEmpty)
+ , m_bSet(aMlAttribute->isSet())
{
- m_aSmMlAttributeValueType = SmMlAttributeValueType::NMlEmpty;
setAttributeValue(aMlAttribute);
}
public:
+ /** Check if the attribute has been set
+ */
+ bool isSet() const { return m_bSet; }
+
+ /** Set if the attribute has been set
+ */
+ void setSet(bool bSet) { m_bSet = bSet; }
+
+public:
/**
* Returns the type of attribute we are dealing with.
* Attribute Value Type
@@ -116,10 +131,15 @@ public:
void setMlAttributeValue(const SmMlAttribute& aMlAttribute)
{
+ m_bSet = true;
setAttributeValue(&aMlAttribute);
}
- void setMlAttributeValue(const SmMlAttribute* aMlAttribute) { setAttributeValue(aMlAttribute); }
+ void setMlAttributeValue(const SmMlAttribute* aMlAttribute)
+ {
+ m_bSet = true;
+ setAttributeValue(aMlAttribute);
+ }
public:
// Get values
diff --git a/starmath/inc/mathml/element.hxx b/starmath/inc/mathml/element.hxx
index 2c5ec40ab019..513b5d84b7ea 100644
--- a/starmath/inc/mathml/element.hxx
+++ b/starmath/inc/mathml/element.hxx
@@ -164,7 +164,7 @@ public: // attributes
* @param nAttributePos
* @return given attribute.
*/
- SmMlAttribute getAttribute(SmMlAttributeValueType aElementType) const;
+ SmMlAttribute getAttribute(SmMlAttributeValueType aAttributeType) const;
/**
* Set's a given attribute.
@@ -174,6 +174,11 @@ public: // attributes
*/
void setAttribute(const SmMlAttribute* aAttribute);
+ /** Checks if an attribute has been manually set
+ * @param aElementType
+ */
+ bool isAttributeSet(SmMlAttributeValueType aAttributeType) const;
+
protected: // attributes
/**
* Get's a given attribute.
diff --git a/starmath/source/mathml/attribute.cxx b/starmath/source/mathml/attribute.cxx
index 61c4df609452..a1be708ae656 100644
--- a/starmath/source/mathml/attribute.cxx
+++ b/starmath/source/mathml/attribute.cxx
@@ -321,36 +321,42 @@ const struct SmMlSymmetric* SmMlAttribute::getMlSymmetric() const
void SmMlAttribute::setMlAccent(const SmMlAccent* aAccent)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aAccent.m_aAccent = aAccent->m_aAccent;
}
void SmMlAttribute::setMlDir(const SmMlDir* aDir)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aDir.m_aDir = aDir->m_aDir;
}
void SmMlAttribute::setMlDisplaystyle(const SmMlDisplaystyle* aDisplaystyle)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aDisplaystyle.m_aDisplaystyle = aDisplaystyle->m_aDisplaystyle;
}
void SmMlAttribute::setMlFence(const SmMlFence* aFence)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aFence.m_aFence = aFence->m_aFence;
}
void SmMlAttribute::setMlForm(const SmMlForm* aForm)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aForm.m_aForm = aForm->m_aForm;
}
void SmMlAttribute::setMlHref(const SmMlHref* aHref)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aHref.m_aHref = aHref->m_aHref;
m_aAttributeValue.m_aHref.m_aLnk = new OUString(*aHref->m_aLnk);
@@ -358,6 +364,7 @@ void SmMlAttribute::setMlHref(const SmMlHref* aHref)
void SmMlAttribute::setMlLspace(const SmMlLspace* aLspace)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aLspace.m_aLengthValue.m_aLengthUnit
= aLspace->m_aLengthValue.m_aLengthUnit;
@@ -369,18 +376,21 @@ void SmMlAttribute::setMlLspace(const SmMlLspace* aLspace)
void SmMlAttribute::setMlMathbackground(const SmMlMathbackground* aMathbackground)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMathbackground.m_aMathbackground = aMathbackground->m_aMathbackground;
}
void SmMlAttribute::setMlMathcolor(const SmMlMathcolor* aMathcolor)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMathcolor.m_aMathcolor = aMathcolor->m_aMathcolor;
}
void SmMlAttribute::setMlMathsize(const SmMlMathsize* aMathsize)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMathsize.m_aLengthValue.m_aLengthUnit
= aMathsize->m_aLengthValue.m_aLengthUnit;
@@ -392,12 +402,14 @@ void SmMlAttribute::setMlMathsize(const SmMlMathsize* aMathsize)
void SmMlAttribute::setMlMathvariant(const SmMlMathvariant* aMathvariant)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMathvariant.m_aMathvariant = aMathvariant->m_aMathvariant;
}
void SmMlAttribute::setMlMaxsize(const SmMlMaxsize* aMaxsize)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMaxsize.m_aMaxsize = aMaxsize->m_aMaxsize;
m_aAttributeValue.m_aMaxsize.m_aLengthValue.m_aLengthUnit
@@ -410,6 +422,7 @@ void SmMlAttribute::setMlMaxsize(const SmMlMaxsize* aMaxsize)
void SmMlAttribute::setMlMinsize(const SmMlMinsize* aMinsize)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMinsize.m_aLengthValue.m_aLengthUnit
= aMinsize->m_aLengthValue.m_aLengthUnit;
@@ -421,12 +434,14 @@ void SmMlAttribute::setMlMinsize(const SmMlMinsize* aMinsize)
void SmMlAttribute::setMlMovablelimits(const SmMlMovablelimits* aMovablelimits)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aMovablelimits.m_aMovablelimits = aMovablelimits->m_aMovablelimits;
}
void SmMlAttribute::setMlRspace(const SmMlRspace* aRspace)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aRspace.m_aLengthValue.m_aLengthUnit
= aRspace->m_aLengthValue.m_aLengthUnit;
@@ -438,18 +453,21 @@ void SmMlAttribute::setMlRspace(const SmMlRspace* aRspace)
void SmMlAttribute::setMlSeparator(const SmMlSeparator* aSeparator)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aSeparator.m_aSeparator = aSeparator->m_aSeparator;
}
void SmMlAttribute::setMlStretchy(const SmMlStretchy* aStretchy)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aStretchy.m_aStretchy = aStretchy->m_aStretchy;
}
void SmMlAttribute::setMlSymmetric(const SmMlSymmetric* aSymmetric)
{
+ m_bSet = true;
clearPreviousAttributeValue();
m_aAttributeValue.m_aSymmetric.m_aSymmetric = aSymmetric->m_aSymmetric;
}
diff --git a/starmath/source/mathml/element.cxx b/starmath/source/mathml/element.cxx
index e1109c267c7d..4f8f2a64ff95 100644
--- a/starmath/source/mathml/element.cxx
+++ b/starmath/source/mathml/element.cxx
@@ -68,17 +68,28 @@ void SmMlElement::SmImplAttributeType()
m_aAttributeList = starmathdatabase::makeMlAttributeList(m_aAttributePosList);
}
-SmMlAttribute SmMlElement::getAttribute(SmMlAttributeValueType aElementType) const
+SmMlAttribute SmMlElement::getAttribute(SmMlAttributeValueType aAttributeType) 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)
+ if (m_aAttributePosList[i].m_aAttributeValueType == aAttributeType)
return m_aAttributeList[m_aAttributePosList[i].m_nPos];
}
return SmMlAttribute();
}
+bool SmMlElement::isAttributeSet(SmMlAttributeValueType aAttributeType) 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 == aAttributeType)
+ return m_aAttributeList[m_aAttributePosList[i].m_nPos].isSet();
+ }
+ return false;
+}
+
void SmMlElement::setAttribute(const SmMlAttribute* aAttribute)
{
// Look for the attribute position and assign if exists
diff --git a/starmath/source/mathml/export.cxx b/starmath/source/mathml/export.cxx
index 9287df360fa6..dc8458aaafd2 100644
--- a/starmath/source/mathml/export.cxx
+++ b/starmath/source/mathml/export.cxx
@@ -683,6 +683,9 @@ void SmMlExport::exportMlAttributtes(const SmMlElement* pMlElement)
for (size_t i = 0; i < nAttributeCount; ++i)
{
SmMlAttribute aAttribute = pMlElement->getAttribute(i);
+ if (!aAttribute.isSet())
+ continue;
+
switch (aAttribute.getMlAttributeValueType())
{
case SmMlAttributeValueType::MlAccent: