diff options
author | dante <dante19031999@gmail.com> | 2020-11-08 14:32:57 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-11 06:51:22 +0100 |
commit | f3b52717e85621d3b4ee1c6d69700e2a0cca8efc (patch) | |
tree | aa4df032b1ab661ad19b3ebc2e8e2c59babb4b07 /starmath/source/mathmlimport.cxx | |
parent | 3d90997fb6f232d8008df4d166d7b97b869c200f (diff) |
Improved starmath color
Color.hxx has now documentation ( even if it is quite obvious if you know RGB standar ).
Color.hxx has been reordered in more coherent order, but kept format.
Some changes on Color.hxx dynamics.
Color.hxx starmath colors list
Now colors are managed by starmathdatabse.
The path is open for simple addition of colors, there are no more infinite switches with color tokens here and there.
To add a color, just put it in Color.hxx and register it in starmathdatabse.cxx. Do not forget to change array size in starmathdatabase.hxx.
Now mathml supports RGB colors in #RRGGBB format ( import and export ).
New colors have been added. Only the HTML Css1 are available via UI.
New colors will be added. I intend to finish Css2 and dvipsnames ( latex colors ) on posterior patches.
RGBA command has been unlocked for compatibility reasons. However will be displayed as RGB.
Added color #RRGGBB.
Improved qa color test on mathml to test RGB on mathml.
TODO for someone on the UI team:
- Add a color picker.
- If it is a color with name:
- It will add in the code "color " + starmathdatabase::Identify_Color_DVIPSNAMES( colorvalue ).pIdent +" "
- If not:
- It will add in the code "color " + starmathdatabase::Identify_Color_DVIPSNAMES( colorvalue ).pIdent +" "+ colorvalue.getRed() +" "+ colorvalue.getGreen() +" "+ colorvalue.getBlue() +" "
- Note that those will habe eType with value TRGB or TRGBA.
Change-Id: I47af37bd191b3099e8e6e08e7a5fb1a8a227bbf2
Change-Id: If971473ddcc34739439818dba9a62ca3494a4473
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105526
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source/mathmlimport.cxx')
-rw-r--r-- | starmath/source/mathmlimport.cxx | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 587ba3ca6458..7a3ca34b9a5a 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -694,6 +694,19 @@ void SmXMLContext_Helper::ApplyAttrs() pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack)); rNodeStack.push_front(std::move(pFontNode)); } + if (!sColor.isEmpty()) + { + std::unique_ptr<SmColorTokenTableEntry> aSmColorTokenTableEntry; + aSmColorTokenTableEntry = starmathdatabase::Identify_ColorName_HTML( sColor ); + if( aSmColorTokenTableEntry ) + { + aToken = aSmColorTokenTableEntry; + std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken)); + pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack)); + rNodeStack.push_front(std::move(pFontNode)); + } + // If not known, not implemented yet. Giving up. + } if (!sFontFamily.isEmpty()) { if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED))) @@ -711,21 +724,6 @@ void SmXMLContext_Helper::ApplyAttrs() pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack)); rNodeStack.push_front(std::move(pFontNode)); } - if (sColor.isEmpty()) - return; - - //Again we can only handle a small set of colours in - //StarMath for now. - const SvXMLTokenMap& rTokenMap = - rContext.GetSmImport().GetColorTokenMap(); - sal_uInt16 tok = rTokenMap.Get(XML_NAMESPACE_MATH, sColor); - if (tok != XML_TOK_UNKNOWN) - { - aToken.eType = static_cast<SmTokenType>(tok); - std::unique_ptr<SmFontNode> pFontNode(new SmFontNode(aToken)); - pFontNode->SetSubNodes(nullptr, popOrZero(rNodeStack)); - rNodeStack.push_front(std::move(pFontNode)); - } } namespace { @@ -1980,35 +1978,6 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SmXMLFlatDocContext_Imp } } -const SvXMLTokenMapEntry aColorTokenMap[] = -{ - { XML_NAMESPACE_MATH, XML_BLACK, TBLACK}, - { XML_NAMESPACE_MATH, XML_WHITE, TWHITE}, - { XML_NAMESPACE_MATH, XML_RED, TRED}, - { XML_NAMESPACE_MATH, XML_GREEN, TGREEN}, - { XML_NAMESPACE_MATH, XML_BLUE, TBLUE}, - { XML_NAMESPACE_MATH, XML_AQUA, TAQUA}, - { XML_NAMESPACE_MATH, XML_FUCHSIA, TFUCHSIA}, - { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW}, - { XML_NAMESPACE_MATH, XML_NAVY, TNAVY}, - { XML_NAMESPACE_MATH, XML_TEAL, TTEAL}, - { XML_NAMESPACE_MATH, XML_MAROON, TMAROON}, - { XML_NAMESPACE_MATH, XML_PURPLE, TPURPLE}, - { XML_NAMESPACE_MATH, XML_OLIVE, TOLIVE}, - { XML_NAMESPACE_MATH, XML_GRAY, TGRAY}, - { XML_NAMESPACE_MATH, XML_SILVER, TSILVER}, - { XML_NAMESPACE_MATH, XML_LIME, TLIME}, - XML_TOKEN_MAP_END -}; - - -const SvXMLTokenMap& SmXMLImport::GetColorTokenMap() -{ - if (!pColorTokenMap) - pColorTokenMap.reset(new SvXMLTokenMap(aColorTokenMap)); - return *pColorTokenMap; -} - uno::Reference< xml::sax::XFastContextHandler > SmXMLDocContext_Impl::createFastChildContext( sal_Int32 nElement, const uno::Reference<xml::sax::XFastAttributeList>& /*xAttrList*/) |