LibreOffice Module svgio (master) 1
svgfecolormatrixnode.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22#include <o3tl/string_view.hxx>
23
24namespace svgio::svgreader
25{
27 : SvgFilterNode(SVGToken::FeColorMatrix, rDocument, pParent)
29{
30}
31
33
34void SvgFeColorMatrixNode::parseAttribute(const OUString& /*rTokenName*/, SVGToken aSVGToken,
35 const OUString& aContent)
36{
37 // parse own
38 switch (aSVGToken)
39 {
40 case SVGToken::Type:
41 {
42 if (!aContent.isEmpty())
43 {
44 if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"luminanceToAlpha"))
45 {
47 }
48 else if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"saturate"))
49 {
51 }
52 else if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"hueRotate"))
53 {
55 }
56 else if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"matrix"))
57 {
59 }
60 }
61 break;
62 }
64 {
65 maValuesContent = aContent;
66 break;
67 }
68 default:
69 {
70 break;
71 }
72 }
73}
74
76{
78 {
81 std::move(rTarget),
82 std::make_shared<basegfx::BColorModifier_luminance_to_alpha>()));
84 }
85 else if (maType == ColorType::Saturate)
86 {
87 SvgNumber aNum(1.0);
89
92 std::move(rTarget),
93 std::make_shared<basegfx::BColorModifier_saturate>(aNum.getNumber())));
95 }
96 else if (maType == ColorType::HueRotate)
97 {
98 SvgNumber aNum(0.0);
102 std::move(rTarget), std::make_shared<basegfx::BColorModifier_hueRotate>(
103 basegfx::deg2rad(aNum.getNumber()))));
105 }
106 else if (maType == ColorType::Matrix)
107 {
108 std::vector<double> aVector = readFilterMatrix(maValuesContent, *this);
109
112 std::move(rTarget), std::make_shared<basegfx::BColorModifier_matrix>(aVector)));
114 }
115}
116
117} // end of namespace svgio::svgreader
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void parseAttribute(const OUString &rTokenName, SVGToken aSVGToken, const OUString &aContent) override
void apply(drawinglayer::primitive2d::Primitive2DContainer &rTarget) const override
SvgFeColorMatrixNode(SvgDocument &rDocument, SvgNode *pParent)
double getNumber() const
Definition: SvgNumber.hxx:85
float u
FilterGroup & rTarget
constexpr double deg2rad(double v)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
std::vector< double > readFilterMatrix(std::u16string_view rCandidate, InfoProvider const &rInfoProvider)
Definition: svgtools.cxx:849
bool readSingleNumber(std::u16string_view rCandidate, SvgNumber &aNum)
Definition: svgtools.cxx:1076
OUString maType