diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-05-05 16:30:25 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-05-08 11:06:02 +0200 |
commit | db4b960643832a52000523ca2eb3667e36af52cd (patch) | |
tree | ada8a459513146582a8954c41f7e97c7048e286c /xmloff/source | |
parent | 603934447c19033acc5590c37efffe208b65bbd8 (diff) |
MCGR: Correct import for Gradient presets/templates
Change-Id: I1424ad5deb65f6c72f414a51a40fbd1138c284d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151432
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/style/FillStyleContext.cxx | 62 | ||||
-rw-r--r-- | xmloff/source/style/FillStyleContext.hxx | 12 | ||||
-rw-r--r-- | xmloff/source/style/GradientStyle.cxx | 62 |
3 files changed, 62 insertions, 74 deletions
diff --git a/xmloff/source/style/FillStyleContext.cxx b/xmloff/source/style/FillStyleContext.cxx index cae1bcd0313b..3b0ff9ca2ff8 100644 --- a/xmloff/source/style/FillStyleContext.cxx +++ b/xmloff/source/style/FillStyleContext.cxx @@ -104,68 +104,6 @@ bool XMLGradientStyleContext::IsTransient() const return true; } -XMLGradientStopContext::XMLGradientStopContext( - SvXMLImport& rImport, sal_Int32 nElement, - const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, - std::vector<awt::ColorStop>& rColorStopVec) -: SvXMLStyleContext(rImport) -{ - if(nElement != XML_ELEMENT(LO_EXT, xmloff::token::XML_GRADIENT_STOP)) - return; - - double fOffset = -1.0; - OUString sColorType; - OUString sColorValue; - // First collect all attributes - for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) - { - switch(aIter.getToken()) - { - case XML_ELEMENT(SVG, xmloff::token::XML_OFFSET): // needed?? - case XML_ELEMENT(SVG_COMPAT, xmloff::token::XML_OFFSET): - if (!::sax::Converter::convertDouble(fOffset, aIter.toView())) - return; - break; - case XML_ELEMENT(LO_EXT, xmloff::token::XML_COLOR_VALUE): - sColorValue = aIter.toString(); - if (sColorValue.isEmpty()) - return; - break; - case XML_ELEMENT(LO_EXT, xmloff::token::XML_COLOR_TYPE): - sColorType = aIter.toString(); - if (sColorType.isEmpty()) - return; - break; - default: - XMLOFF_WARN_UNKNOWN("xmloff.style", aIter); - } - } - - // As of LO 7.6.0 only "rgb" is implemented. - if (sColorType != u"rgb") - return; - - // Type "rgb" requires kind color-value="#rrggbb". - ::Color aColor; - if (!::sax::Converter::convertColor(aColor, sColorValue)) - return; - - // All attribute values OK. Generate ColorStop. - css::rendering::RGBColor aRGBColor; - aRGBColor.Red = aColor.GetRed() / 255.0; - aRGBColor.Green = aColor.GetGreen() / 255.0; - aRGBColor.Blue = aColor.GetBlue() / 255.0; - - awt::ColorStop aColorStop; - aColorStop.StopOffset = fOffset; - aColorStop.StopColor = aRGBColor; - rColorStopVec.push_back(aColorStop); -} - -XMLGradientStopContext::~XMLGradientStopContext() -{ -} - XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport& rImport, sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList) : SvXMLStyleContext(rImport) diff --git a/xmloff/source/style/FillStyleContext.hxx b/xmloff/source/style/FillStyleContext.hxx index aee8f6d81038..e3d00ad82486 100644 --- a/xmloff/source/style/FillStyleContext.hxx +++ b/xmloff/source/style/FillStyleContext.hxx @@ -51,18 +51,6 @@ public: virtual bool IsTransient() const override; }; -class XMLGradientStopContext: public SvXMLStyleContext -{ -private: - -public: - - XMLGradientStopContext(SvXMLImport& rImport, sal_Int32 nElement, - const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, - std::vector<css::awt::ColorStop>& rColorStopVec); - virtual ~XMLGradientStopContext() override; -}; - // draw:hatch context class XMLHatchStyleContext: public SvXMLStyleContext diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx index 9f2723078a89..3ab6c422b2c8 100644 --- a/xmloff/source/style/GradientStyle.cxx +++ b/xmloff/source/style/GradientStyle.cxx @@ -145,6 +145,68 @@ void XMLGradientStyleImport::importXML( } } +XMLGradientStopContext::XMLGradientStopContext( + SvXMLImport& rImport, sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + std::vector<awt::ColorStop>& rColorStopVec) +: SvXMLImportContext(rImport) +{ + if(nElement != XML_ELEMENT(LO_EXT, xmloff::token::XML_GRADIENT_STOP)) + return; + + double fOffset = -1.0; + OUString sColorType; + OUString sColorValue; + // First collect all attributes + for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList)) + { + switch(aIter.getToken()) + { + case XML_ELEMENT(SVG, xmloff::token::XML_OFFSET): // needed?? + case XML_ELEMENT(SVG_COMPAT, xmloff::token::XML_OFFSET): + if (!::sax::Converter::convertDouble(fOffset, aIter.toView())) + return; + break; + case XML_ELEMENT(LO_EXT, xmloff::token::XML_COLOR_VALUE): + sColorValue = aIter.toString(); + if (sColorValue.isEmpty()) + return; + break; + case XML_ELEMENT(LO_EXT, xmloff::token::XML_COLOR_TYPE): + sColorType = aIter.toString(); + if (sColorType.isEmpty()) + return; + break; + default: + XMLOFF_WARN_UNKNOWN("xmloff.style", aIter); + } + } + + // As of LO 7.6.0 only "rgb" is implemented. + if (sColorType != u"rgb") + return; + + // Type "rgb" requires kind color-value="#rrggbb". + ::Color aColor; + if (!::sax::Converter::convertColor(aColor, sColorValue)) + return; + + // All attribute values OK. Generate ColorStop. + css::rendering::RGBColor aRGBColor; + aRGBColor.Red = aColor.GetRed() / 255.0; + aRGBColor.Green = aColor.GetGreen() / 255.0; + aRGBColor.Blue = aColor.GetBlue() / 255.0; + + awt::ColorStop aColorStop; + aColorStop.StopOffset = fOffset; + aColorStop.StopColor = aRGBColor; + rColorStopVec.push_back(aColorStop); +} + +XMLGradientStopContext::~XMLGradientStopContext() +{ +} + // Export XMLGradientStyleExport::XMLGradientStyleExport( |