summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2021-02-14 17:50:02 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-14 20:09:56 +0100
commit8957cf1cc041839d7d1e96b4d2617a82777692d4 (patch)
treef439347d483ca487f8ca86a65cc7fbb03b0ea586 /starmath
parent1fa83df607b9721c8f12125942de1c586a624bd0 (diff)
Reorganize starmath color data flow
This will make possible to edit structure nodes with graphic UI. Change-Id: I37500958dbd684d239d615fc1d8df562a0c5b486 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110490 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/token.hxx12
-rw-r--r--starmath/source/mathml/mathmlexport.cxx4
-rw-r--r--starmath/source/node.cxx2
-rw-r--r--starmath/source/parse.cxx8
-rw-r--r--starmath/source/visitors.cxx10
5 files changed, 19 insertions, 17 deletions
diff --git a/starmath/inc/token.hxx b/starmath/inc/token.hxx
index 5b903cc7bc1c..650884471aa5 100644
--- a/starmath/inc/token.hxx
+++ b/starmath/inc/token.hxx
@@ -267,9 +267,9 @@ struct SmToken
void operator=(const SmColorTokenTableEntry& aTokenTableEntry)
{
- aText = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry.cColor), 16);
+ aText = u"";
eType = aTokenTableEntry.eType;
- cMathChar = u"";
+ cMathChar = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry.cColor), 16);
nGroup = TG::Color;
nLevel = 0;
nRow = 0;
@@ -278,9 +278,9 @@ struct SmToken
void operator=(const SmColorTokenTableEntry* aTokenTableEntry)
{
- aText = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry->cColor), 16);
+ aText = u"";
eType = aTokenTableEntry->eType;
- cMathChar = u"";
+ cMathChar = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry->cColor), 16);
nGroup = TG::Color;
nLevel = 0;
nRow = 0;
@@ -289,9 +289,9 @@ struct SmToken
void operator=(const std::unique_ptr<SmColorTokenTableEntry>& aTokenTableEntry)
{
- aText = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry->cColor), 16);
+ aText = u"";
eType = aTokenTableEntry->eType;
- cMathChar = u"";
+ cMathChar = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry->cColor), 16);
nGroup = TG::Color;
nLevel = 0;
nRow = 0;
diff --git a/starmath/source/mathml/mathmlexport.cxx b/starmath/source/mathml/mathmlexport.cxx
index c70ef936ea9f..f9d7affd02e3 100644
--- a/starmath/source/mathml/mathmlexport.cxx
+++ b/starmath/source/mathml/mathmlexport.cxx
@@ -1146,7 +1146,7 @@ void SmXMLExport::ExportFont(const SmNode* pNode, int nLevel)
break;
case TMATHMLCOL:
{
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
OUString sssStr
= OUString::createFromAscii(starmathdatabase::Identify_Color_MATHML(nc).pIdent);
AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, sssStr);
@@ -1161,7 +1161,7 @@ void SmXMLExport::ExportFont(const SmNode* pNode, int nLevel)
{
OUStringBuffer sStrBuf(7);
sStrBuf.append('#');
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
sStrBuf.append(Color(ColorTransparency, nc).AsRGBHEXString());
OUString ssStr(sStrBuf.makeStringAndClear());
AddAttribute(XML_NAMESPACE_MATH, XML_MATHCOLOR, ssStr);
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 7dd72829b47f..e5916a094224 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -1725,7 +1725,7 @@ void SmFontNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
case TDVIPSNAMESCOL:
case TICONICCOL :
case THEX :
- nc = GetToken().aText.toUInt32(16);
+ nc = GetToken().cMathChar.toUInt32(16);
SetColor(Color(ColorTransparency, nc));
break;
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 8e3afd989b1e..80922cfdf6e3 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2084,6 +2084,7 @@ std::unique_ptr<SmStructureNode> SmParser::DoColor()
DepthProtect aDepthGuard(m_nParseDepth);
assert(m_aCurToken.eType == TCOLOR);
+ sal_Int32 nBufferIndex = m_nBufferIndex;
NextTokenColor(TCOLOR);
SmToken aToken;
@@ -2111,7 +2112,7 @@ std::unique_ptr<SmStructureNode> SmParser::DoColor()
nb = m_aCurToken.aText.toUInt32();
if( nb > 255 )return DoError(SmParseError::ColorExpected);
nc = nb | ng << 8 | nr << 16 | sal_uInt32(0) << 24;
- aToken.aText = OUString::number(nc, 16);
+ aToken.cMathChar = OUString::number(nc, 16);
}
else if( m_aCurToken.eType == TRGBA ) //loads r, g and b
{
@@ -2137,7 +2138,7 @@ std::unique_ptr<SmStructureNode> SmParser::DoColor()
na = m_aCurToken.aText.toUInt32();
if( na > 255 )return DoError(SmParseError::ColorExpected);
nc = nb | ng << 8 | nr << 16 | na << 24;
- aToken.aText = OUString::number(nc, 16);
+ aToken.cMathChar = OUString::number(nc, 16);
}
else if( m_aCurToken.eType == THEX ) //loads hex code
{
@@ -2146,8 +2147,9 @@ std::unique_ptr<SmStructureNode> SmParser::DoColor()
if( lcl_IsNotWholeNumber16(m_aCurToken.aText) )
return DoError(SmParseError::ColorExpected);
nc = m_aCurToken.aText.toUInt32(16);
- aToken.aText = OUString::number(nc, 16);
+ aToken.cMathChar = OUString::number(nc, 16);
}
+ aToken.aText = m_aBufferString.subView(nBufferIndex, m_nBufferIndex - nBufferIndex);
NextToken();
}
else return DoError(SmParseError::ColorExpected);
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index e1e79c324198..2d71df50c7bc 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2136,18 +2136,18 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode )
case TDVIPSNAMESCOL:
Append(u"color dvip ");
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
Append( starmathdatabase::Identify_Color_Parser( nc ).pIdent );
break;
case THTMLCOL:
case TMATHMLCOL:
case TICONICCOL:
Append(u"color ");
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
Append( starmathdatabase::Identify_Color_Parser( nc ).pIdent );
break;
case TRGB:
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
Append(u"color rgb ");
nb = nc % 256;
nc /= 256;
@@ -2163,7 +2163,7 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode )
break;
case TRGBA:
Append(u"color rgba ");
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
nb = nc % 256;
nc /= 256;
ng = nc % 256;
@@ -2181,7 +2181,7 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode )
break;
case THEX:
Append(u"color hex ");
- nc = pNode->GetToken().aText.toUInt32(16);
+ nc = pNode->GetToken().cMathChar.toUInt32(16);
Append(OUString::number(nc,16));
Separate();
break;