diff options
author | dante <dante19031999@gmail.com> | 2021-08-13 19:51:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-15 09:10:13 +0200 |
commit | ffaaec23ad94f9bec5fd0fcb02603270eb660b81 (patch) | |
tree | b0ddcff0d02ae0ddddd04888674cf1c00fae4525 /starmath/source | |
parent | 73b6462b81080c63e6668979f4a9cd00242925e9 (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/source')
-rw-r--r-- | starmath/source/mathml/attribute.cxx | 18 | ||||
-rw-r--r-- | starmath/source/mathml/element.cxx | 15 | ||||
-rw-r--r-- | starmath/source/mathml/export.cxx | 3 |
3 files changed, 34 insertions, 2 deletions
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: |