LibreOffice Module svgio (master) 1
svgstyleattributes.hxx
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
20#pragma once
21
22#include "svgpaint.hxx"
23#include "svgnode.hxx"
24#include "svgtools.hxx"
25#include <tools/fontenum.hxx>
28
29
30// predefines
31
32namespace svgio::svgreader {
33 class SvgGradientNode;
34 class SvgPatternNode;
35 class SvgMarkerNode;
36 class SvgClipPathNode;
37 class SvgFilterNode;
38 class SvgMaskNode;
39}
40
41
42namespace svgio::svgreader
43 {
44 enum class StrokeLinecap
45 {
46 notset,
47 butt,
48 round,
49 square
50 };
51
52 enum class StrokeLinejoin
53 {
54 notset,
55 miter,
56 round,
57 bevel
58 };
59
60 enum class FontSize
61 {
62 notset,
64 x_small,
65 small,
66 smaller,
67 medium,
68 large,
69 larger,
70 x_large,
73 };
74
75 enum class FontStretch
76 {
77 notset,
78 normal,
79 wider,
89 };
90
93
94 enum class FontStyle
95 {
96 notset,
97 normal,
98 italic,
100 };
101
102 enum class FontWeight
103 {
104 notset,
105 N100,
106 N200,
107 N300,
108 N400, // same as normal
109 N500,
110 N600,
111 N700, // same as bold
112 N800,
113 N900,
114 bolder,
115 lighter,
116 };
117
121
122 enum class TextAlign
123 {
124 notset,
125 left,
126 right,
127 center,
128 justify
129 };
130
131 enum class TextDecoration
132 {
133 notset,
134 none,
135 underline,
136 overline,
138 blink
139 };
140
141 enum class TextAnchor
142 {
143 notset,
144 start,
145 middle,
146 end
147 };
148
149 enum class FillRule
150 {
151 notset,
152 nonzero,
153 evenodd
154 };
155
156 enum class BaselineShift
157 {
158 Baseline,
159 Sub,
160 Super,
162 Length
163 };
164
165 enum class Visibility
166 {
167 notset,
168 visible,
169 hidden,
170 collapse,
171 inherit
172 };
173
175 {
176 private:
203 OUString maTitle;
204 OUString maDesc;
205
209 OUString maMaskXLink;
210
215
218
219 // ClipRule setting (only valid when mbIsClipPathContent == true, default is FillRule_nonzero)
221
222 // BaselineShift: Type and number (in case of BaselineShift_Percentage or BaselineShift_Length)
225
226 mutable std::vector<sal_uInt16> maResolvingParent;
227
228 // defines if this attributes are part of a ClipPath. If yes,
229 // rough geometry will be created on decomposition by patching
230 // values for fill, stroke, strokeWidth and others
232
233 // #121221# Defines if evtl. an empty array *is* set
235
236 // tdf#94765 Check id references in gradient/pattern getters
239
241 void add_fillGradient(
242 const basegfx::B2DPolyPolygon& rPath,
244 const SvgGradientNode& rFillGradient,
245 const basegfx::B2DRange& rGeoRange) const;
247 const basegfx::B2DPolyPolygon& rPath,
249 const SvgPatternNode& rFillGradient,
250 const basegfx::B2DRange& rGeoRange) const;
251 void add_fillPattern(
252 const basegfx::B2DPolyPolygon& rPath,
254 const SvgPatternNode& rFillGradient,
255 const basegfx::B2DRange& rGeoRange) const;
256 void add_fill(
257 const basegfx::B2DPolyPolygon& rPath,
259 const basegfx::B2DRange& rGeoRange) const;
260 void add_stroke(
261 const basegfx::B2DPolyPolygon& rPath,
263 const basegfx::B2DRange& rGeoRange) const;
266 basegfx::B2DHomMatrix& rMarkerTransform,
267 basegfx::B2DRange& rClipRange,
268 const SvgMarkerNode& rMarker) const;
269 void add_markers(
270 const basegfx::B2DPolyPolygon& rPath,
272 const basegfx::utils::PointIndexSet* pHelpPointIndices) const;
273
274
275 public:
277 void parseStyleAttribute(SVGToken aSVGToken, const OUString& rContent);
278
280 void add_text(
283 void add_path(
284 const basegfx::B2DPolyPolygon& rPath,
286 const basegfx::utils::PointIndexSet* pHelpPointIndices) const;
287 void add_postProcess(
290 const std::optional<basegfx::B2DHomMatrix>& pTransform) const;
291
295
297 void readCssStyle(std::u16string_view rCandidate);
298 const SvgStyleAttributes* getParentStyle() const;
299
302
304 bool isFillSet() const; // #i125258# ask if fill is a direct hard attribute (no hierarchy)
305 const basegfx::BColor* getFill() const;
306 void setFill(const SvgPaint& rFill) { maFill = rFill; }
307
309 const basegfx::BColor* getStroke() const;
310
312 const basegfx::BColor& getStopColor() const;
313
316
319
322
325
328
331
334
336 FillRule getFillRule() const;
337
339 FillRule getClipRule() const;
340
342 const SvgNumberVector& getStrokeDasharray() const;
343
346
349 void setStrokeLinecap(const StrokeLinecap aStrokeLinecap) { maStrokeLinecap = aStrokeLinecap; }
350
353 void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin) { maStrokeLinejoin = aStrokeLinejoin; }
354
357
360
362 const SvgStringVector& getFontFamily() const;
363
365 void setFontSize(const FontSize aFontSize) { maFontSize = aFontSize; }
367
370 void setFontStretch(const FontStretch aFontStretch) { maFontStretch = aFontStretch; }
371
373 FontStyle getFontStyle() const;
374 void setFontStyle(const FontStyle aFontStyle) { maFontStyle = aFontStyle; }
375
378 void setFontWeight(const FontWeight aFontWeight) { maFontWeight = aFontWeight; }
379
381 TextAlign getTextAlign() const;
382 void setTextAlign(const TextAlign aTextAlign) { maTextAlign = aTextAlign; }
383
387 void setTextDecoration(const TextDecoration aTextDecoration) { maTextDecoration = aTextDecoration; }
388
391 void setTextAnchor(const TextAnchor aTextAnchor) { maTextAnchor = aTextAnchor; }
392
394 const basegfx::BColor* getColor() const;
395
397 const basegfx::BColor* getCurrentColor() const;
398
400 SvgNumber getOpacity() const;
401 void setOpacity(const SvgNumber& rOpacity) { maOpacity = rOpacity; }
402
405 void setVisibility(const Visibility aVisibility) { maVisibility = aVisibility; }
406
407 // Title content
408 const OUString& getTitle() const { return maTitle; }
409
410 // Desc content
411 const OUString& getDesc() const { return maDesc; }
412
413 // ClipPathXLink content
414 OUString getClipPathXLink() const;
416
417 // FilterXLink content
418 OUString getFilterXLink() const;
419 const SvgFilterNode* accessFilterXLink() const;
420
421 // MaskXLink content
422 OUString getMaskXLink() const;
423 const SvgMaskNode* accessMaskXLink() const;
424
425 // MarkerStartXLink content
426 OUString getMarkerStartXLink() const;
428
429 // MarkerMidXLink content
430 OUString getMarkerMidXLink() const;
431 const SvgMarkerNode* accessMarkerMidXLink() const;
432
433 // MarkerEndXLink content
434 OUString getMarkerEndXLink() const;
435 const SvgMarkerNode* accessMarkerEndXLink() const;
436
437 // BaselineShift
438 void setBaselineShift(const BaselineShift aBaselineShift) { maBaselineShift = aBaselineShift; }
441 };
442
443} // end of namespace svgio::svgreader
444
445/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SvgStyleAttributes * getParentStyle() const
OUString maMarkerStartXLink
link to markers. If set, the node can be fetched on demand
void add_fillPatternTransform(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const SvgPatternNode &rFillGradient, const basegfx::B2DRange &rGeoRange) const
void setFontWeight(const FontWeight aFontWeight)
void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin)
void add_fill(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const basegfx::B2DRange &rGeoRange) const
const SvgStyleAttributes * getCssStyleParent() const
SvgNumber getFillOpacity() const
fill opacity content
const SvgStyleAttributes * mpCssStyleParent
SvgNumber getOpacity() const
Opacity content.
const basegfx::BColor * getCurrentColor() const
Resolve current color (defaults to black if no color is specified)
const basegfx::BColor * getColor() const
Color content.
const basegfx::BColor * getFill() const
void add_fillGradient(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const SvgGradientNode &rFillGradient, const basegfx::B2DRange &rGeoRange) const
internal helpers
SvgNumber getStrokeOpacity() const
StrokeOpacity content.
FillRule getFillRule() const
fill rule content
const SvgStyleAttributes * getTextDecorationDefiningSvgStyleAttributes() const
TextDecoration content.
void setTextAlign(const TextAlign aTextAlign)
void add_fillPattern(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const SvgPatternNode &rFillGradient, const basegfx::B2DRange &rGeoRange) const
const SvgFilterNode * accessFilterXLink() const
StrokeLinejoin getStrokeLinejoin() const
StrokeLinejoin content.
SvgNumber getStrokeMiterLimit() const
StrokeMiterLimit content.
const basegfx::BColor * getStroke() const
stroke content
void add_postProcess(drawinglayer::primitive2d::Primitive2DContainer &rTarget, drawinglayer::primitive2d::Primitive2DContainer &&rSource, const std::optional< basegfx::B2DHomMatrix > &pTransform) const
const SvgStringVector & getFontFamily() const
Font content.
SvgNumber getStrokeDashOffset() const
StrokeDashOffset content.
const SvgPatternNode * getSvgPatternNodeFill() const
access to evtl. set fill pattern
void add_path(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const basegfx::utils::PointIndexSet *pHelpPointIndices) const
SvgNumber getStopOpacity() const
stop opacity content
void setVisibility(const Visibility aVisibility)
void setTextAnchor(const TextAnchor aTextAnchor)
const SvgMaskNode * accessMaskXLink() const
TextAlign getTextAlign() const
TextAlign content.
void setFontStyle(const FontStyle aFontStyle)
SvgNumber getStrokeWidth() const
stroke-width content
void add_stroke(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const basegfx::B2DRange &rGeoRange) const
const SvgMarkerNode * accessMarkerStartXLink() const
void setFontStretch(const FontStretch aFontStretch)
FontStyle getFontStyle() const
FontStyle content.
const basegfx::BColor & getStopColor() const
stop color content
const SvgMarkerNode * accessMarkerEndXLink() const
void setFontSize(const FontSize aFontSize)
FontSize content.
void parseStyleAttribute(SVGToken aSVGToken, const OUString &rContent)
local attribute scanner
StrokeLinecap getStrokeLinecap() const
StrokeLinecap content.
void add_markers(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const basegfx::utils::PointIndexSet *pHelpPointIndices) const
void setStrokeLinecap(const StrokeLinecap aStrokeLinecap)
const SvgMarkerNode * accessMarkerMidXLink() const
const SvgGradientNode * getSvgGradientNodeFill() const
access to evtl. set fill gradient
FontWeight getFontWeight() const
FontWeight content.
void setOpacity(const SvgNumber &rOpacity)
Visibility getVisibility() const
Visibility.
const SvgPatternNode * getSvgPatternNodeStroke() const
access to evtl. set stroke pattern
FontStretch getFontStretch() const
FontStretch content.
void setBaselineShift(const BaselineShift aBaselineShift)
void setCssStyleParent(const SvgStyleAttributes *pNew)
helper to set mpCssStyleParent temporarily for CSS style hierarchies
const SvgClipPathNode * accessClipPathXLink() const
const SvgNumberVector & getStrokeDasharray() const
fill StrokeDasharray content
void setTextDecoration(const TextDecoration aTextDecoration)
OUString maClipPathXLink
link to content. If set, the node can be fetched on demand
TextAnchor getTextAnchor() const
TextAnchor content.
FillRule getClipRule() const
clip rule content
bool prepare_singleMarker(drawinglayer::primitive2d::Primitive2DContainer &rMarkerPrimitives, basegfx::B2DHomMatrix &rMarkerTransform, basegfx::B2DRange &rClipRange, const SvgMarkerNode &rMarker) const
void add_text(drawinglayer::primitive2d::Primitive2DContainer &rTarget, drawinglayer::primitive2d::Primitive2DContainer &&rSource) const
helper which does the necessary with a given path
void readCssStyle(std::u16string_view rCandidate)
scan helpers
std::vector< sal_uInt16 > maResolvingParent
const SvgGradientNode * getSvgGradientNodeStroke() const
access to evtl. set stroke gradient
OString right
FontWeight
none
Length
end
FontStretch getWider(FontStretch aSource)
FontWeight getLighter(FontWeight aSource)
::std::vector< OUString > SvgStringVector
Definition: svgtools.hxx:124
::FontWeight getVclFontWeight(FontWeight aSource)
std::vector< SvgNumber > SvgNumberVector
Definition: SvgNumber.hxx:111
FontWeight getBolder(FontWeight aSource)
FontStretch getNarrower(FontStretch aSource)
sal_uInt64 left