bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svgio / inc / svgstyleattributes.hxx
blob91eb882135fc194100086916e10e5915c0a9e6d4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
21 #define INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
23 #include "svgpaint.hxx"
24 #include "svgnode.hxx"
25 #include <vcl/vclenum.hxx>
26 #include <tools/fontenum.hxx>
27 #include <basegfx/polygon/b2dpolypolygontools.hxx>
30 // predefines
32 namespace svgio { namespace svgreader {
33 class SvgGradientNode;
34 class SvgPatternNode;
35 class SvgMarkerNode;
36 class SvgClipPathNode;
37 class SvgMaskNode;
41 namespace svgio
43 namespace svgreader
45 enum StrokeLinecap
47 StrokeLinecap_notset,
48 StrokeLinecap_butt,
49 StrokeLinecap_round,
50 StrokeLinecap_square
53 enum StrokeLinejoin
55 StrokeLinejoin_notset,
56 StrokeLinejoin_miter,
57 StrokeLinejoin_round,
58 StrokeLinejoin_bevel
61 enum FontSize
63 FontSize_notset,
64 FontSize_xx_small,
65 FontSize_x_small,
66 FontSize_small,
67 FontSize_smaller,
68 FontSize_medium,
69 FontSize_large,
70 FontSize_larger,
71 FontSize_x_large,
72 FontSize_xx_large,
73 FontSize_initial
76 enum FontStretch
78 FontStretch_notset,
79 FontStretch_normal,
80 FontStretch_wider,
81 FontStretch_narrower,
82 FontStretch_ultra_condensed,
83 FontStretch_extra_condensed,
84 FontStretch_condensed,
85 FontStretch_semi_condensed,
86 FontStretch_semi_expanded,
87 FontStretch_expanded,
88 FontStretch_extra_expanded,
89 FontStretch_ultra_expanded
92 FontStretch getWider(FontStretch aSource);
93 FontStretch getNarrower(FontStretch aSource);
95 enum FontStyle
97 FontStyle_notset,
98 FontStyle_normal,
99 FontStyle_italic,
100 FontStyle_oblique
103 enum FontWeight
105 FontWeight_notset,
106 FontWeight_100,
107 FontWeight_200,
108 FontWeight_300,
109 FontWeight_400, // same as FontWeight_normal
110 FontWeight_500,
111 FontWeight_600,
112 FontWeight_700, // same as FontWeight_bold
113 FontWeight_800,
114 FontWeight_900,
115 FontWeight_bolder,
116 FontWeight_lighter,
119 FontWeight getBolder(FontWeight aSource);
120 FontWeight getLighter(FontWeight aSource);
121 ::FontWeight getVclFontWeight(FontWeight aSource);
123 enum TextAlign
125 TextAlign_notset,
126 TextAlign_left,
127 TextAlign_right,
128 TextAlign_center,
129 TextAlign_justify
132 enum TextDecoration
134 TextDecoration_notset,
135 TextDecoration_none,
136 TextDecoration_underline,
137 TextDecoration_overline,
138 TextDecoration_line_through,
139 TextDecoration_blink
142 enum TextAnchor
144 TextAnchor_notset,
145 TextAnchor_start,
146 TextAnchor_middle,
147 TextAnchor_end
150 enum FillRule
152 FillRule_notset,
153 FillRule_nonzero,
154 FillRule_evenodd
157 enum BaselineShift
159 BaselineShift_Baseline,
160 BaselineShift_Sub,
161 BaselineShift_Super,
162 BaselineShift_Percentage,
163 BaselineShift_Length
166 enum Visibility
168 Visibility_notset,
169 Visibility_visible,
170 Visibility_hidden,
171 Visibility_collapse,
172 Visibility_inherit
175 class SvgStyleAttributes
177 private:
178 SvgNode& mrOwner;
179 const SvgStyleAttributes* mpCssStyleParent;
180 SvgPaint maFill;
181 SvgPaint maStroke;
182 SvgPaint maStopColor;
183 SvgNumber maStrokeWidth;
184 SvgNumber maStopOpacity;
185 const SvgGradientNode* mpSvgGradientNodeFill;
186 const SvgGradientNode* mpSvgGradientNodeStroke;
187 const SvgPatternNode* mpSvgPatternNodeFill;
188 const SvgPatternNode* mpSvgPatternNodeStroke;
189 SvgNumber maFillOpacity;
190 SvgNumberVector maStrokeDasharray;
191 SvgNumber maStrokeDashOffset;
192 StrokeLinecap maStrokeLinecap;
193 StrokeLinejoin maStrokeLinejoin;
194 SvgNumber maStrokeMiterLimit;
195 SvgNumber maStrokeOpacity;
196 SvgStringVector maFontFamily;
197 FontSize maFontSize;
198 SvgNumber maFontSizeNumber;
199 FontStretch maFontStretch;
200 FontStyle maFontStyle;
201 FontWeight maFontWeight;
202 TextAlign maTextAlign;
203 TextDecoration maTextDecoration;
204 TextAnchor maTextAnchor;
205 SvgPaint maColor;
206 SvgNumber maOpacity;
207 Visibility maVisibility;
208 OUString maTitle;
209 OUString maDesc;
211 /// link to content. If set, the node can be fetched on demand
212 OUString maClipPathXLink;
213 const SvgClipPathNode* mpClipPathXLink;
214 OUString maMaskXLink;
215 const SvgMaskNode* mpMaskXLink;
217 /// link to markers. If set, the node can be fetched on demand
218 OUString maMarkerStartXLink;
219 const SvgMarkerNode* mpMarkerStartXLink;
220 OUString maMarkerMidXLink;
221 const SvgMarkerNode* mpMarkerMidXLink;
222 OUString maMarkerEndXLink;
223 const SvgMarkerNode* mpMarkerEndXLink;
225 /// fill rule
226 FillRule maFillRule;
228 // ClipRule setting (only valid when mbIsClipPathContent == true, default is FillRule_nonzero)
229 FillRule maClipRule;
231 // BaselineShift: Type and number (in case of BaselineShift_Percentage or BaselineShift_Length)
232 BaselineShift maBaselineShift;
233 SvgNumber maBaselineShiftNumber;
235 mutable std::vector<sal_uInt16> maResolvingParent;
237 // defines if this attributes are part of a ClipPath. If yes,
238 // rough geometry will be created on decomposition by patching
239 // values for fill, stroke, strokeWidth and others
240 bool mbIsClipPathContent : 1;
242 // #121221# Defines if evtl. an empty array *is* set
243 bool mbStrokeDasharraySet : 1;
245 /// internal helpers
246 void add_fillGradient(
247 const basegfx::B2DPolyPolygon& rPath,
248 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
249 const SvgGradientNode& rFillGradient,
250 const basegfx::B2DRange& rGeoRange) const;
251 void add_fillPatternTransform(
252 const basegfx::B2DPolyPolygon& rPath,
253 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
254 const SvgPatternNode& rFillGradient,
255 const basegfx::B2DRange& rGeoRange) const;
256 void add_fillPattern(
257 const basegfx::B2DPolyPolygon& rPath,
258 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
259 const SvgPatternNode& rFillGradient,
260 const basegfx::B2DRange& rGeoRange) const;
261 void add_fill(
262 const basegfx::B2DPolyPolygon& rPath,
263 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
264 const basegfx::B2DRange& rGeoRange) const;
265 void add_stroke(
266 const basegfx::B2DPolyPolygon& rPath,
267 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
268 const basegfx::B2DRange& rGeoRange) const;
269 bool prepare_singleMarker(
270 drawinglayer::primitive2d::Primitive2DContainer& rMarkerPrimitives,
271 basegfx::B2DHomMatrix& rMarkerTransform,
272 basegfx::B2DRange& rClipRange,
273 const SvgMarkerNode& rMarker) const;
274 void add_markers(
275 const basegfx::B2DPolyPolygon& rPath,
276 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
277 const basegfx::utils::PointIndexSet* pHelpPointIndices) const;
279 public:
280 /// local attribute scanner
281 void parseStyleAttribute(SVGToken aSVGToken, const OUString& rContent,
282 bool bCaseIndependent);
284 /// helper which does the necessary with a given path
285 void add_text(
286 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
287 drawinglayer::primitive2d::Primitive2DContainer const & rSource) const;
288 void add_path(
289 const basegfx::B2DPolyPolygon& rPath,
290 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
291 const basegfx::utils::PointIndexSet* pHelpPointIndices) const;
292 void add_postProcess(
293 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
294 const drawinglayer::primitive2d::Primitive2DContainer& rSource,
295 const basegfx::B2DHomMatrix* pTransform) const;
297 /// helper to set mpCssStyleParent temporarily for CSS style hierarchies
298 void setCssStyleParent(const SvgStyleAttributes* pNew) { mpCssStyleParent = pNew; }
299 const SvgStyleAttributes* getCssStyleParent() const { return mpCssStyleParent; }
301 /// scan helpers
302 void readCssStyle(const OUString& rCandidate);
303 const SvgStyleAttributes* getParentStyle() const;
305 SvgStyleAttributes(SvgNode& rOwner);
306 ~SvgStyleAttributes();
308 /// fill content
309 bool isFillSet() const; // #i125258# ask if fill is a direct hard attribute (no hierarchy)
310 const basegfx::BColor* getFill() const;
311 void setFill(const SvgPaint& rFill) { maFill = rFill; }
313 /// stroke content
314 const basegfx::BColor* getStroke() const;
316 /// stop color content
317 const basegfx::BColor& getStopColor() const;
319 /// stroke-width content
320 SvgNumber getStrokeWidth() const;
322 /// stop opacity content
323 SvgNumber getStopOpacity() const;
325 /// access to evtl. set fill gradient
326 const SvgGradientNode* getSvgGradientNodeFill() const;
328 /// access to evtl. set fill pattern
329 const SvgPatternNode* getSvgPatternNodeFill() const;
331 /// access to evtl. set stroke gradient
332 const SvgGradientNode* getSvgGradientNodeStroke() const;
334 /// access to evtl. set stroke pattern
335 const SvgPatternNode* getSvgPatternNodeStroke() const;
337 /// fill opacity content
338 SvgNumber getFillOpacity() const;
340 /// fill rule content
341 FillRule getFillRule() const;
343 /// fill StrokeDasharray content
344 const SvgNumberVector& getStrokeDasharray() const;
346 /// StrokeDashOffset content
347 SvgNumber getStrokeDashOffset() const;
349 /// StrokeLinecap content
350 StrokeLinecap getStrokeLinecap() const;
351 void setStrokeLinecap(const StrokeLinecap aStrokeLinecap) { maStrokeLinecap = aStrokeLinecap; }
353 /// StrokeLinejoin content
354 StrokeLinejoin getStrokeLinejoin() const;
355 void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin) { maStrokeLinejoin = aStrokeLinejoin; }
357 /// StrokeMiterLimit content
358 SvgNumber getStrokeMiterLimit() const;
360 /// StrokeOpacity content
361 SvgNumber getStrokeOpacity() const;
363 /// Font content
364 const SvgStringVector& getFontFamily() const;
366 /// FontSize content
367 void setFontSize(const FontSize aFontSize) { maFontSize = aFontSize; }
368 SvgNumber getFontSizeNumber() const;
370 /// FontStretch content
371 FontStretch getFontStretch() const;
372 void setFontStretch(const FontStretch aFontStretch) { maFontStretch = aFontStretch; }
374 /// FontStyle content
375 FontStyle getFontStyle() const;
376 void setFontStyle(const FontStyle aFontStyle) { maFontStyle = aFontStyle; }
378 /// FontWeight content
379 FontWeight getFontWeight() const;
380 void setFontWeight(const FontWeight aFontWeight) { maFontWeight = aFontWeight; }
382 /// TextAlign content
383 TextAlign getTextAlign() const;
384 void setTextAlign(const TextAlign aTextAlign) { maTextAlign = aTextAlign; }
386 /// TextDecoration content
387 const SvgStyleAttributes* getTextDecorationDefiningSvgStyleAttributes() const;
388 TextDecoration getTextDecoration() const;
389 void setTextDecoration(const TextDecoration aTextDecoration) { maTextDecoration = aTextDecoration; }
391 /// TextAnchor content
392 TextAnchor getTextAnchor() const;
393 void setTextAnchor(const TextAnchor aTextAnchor) { maTextAnchor = aTextAnchor; }
395 /// Color content
396 const basegfx::BColor* getColor() const;
398 /// Resolve current color (defaults to black if no color is specified)
399 const basegfx::BColor* getCurrentColor() const;
401 /// Opacity content
402 SvgNumber getOpacity() const;
403 void setOpacity(const SvgNumber& rOpacity) { maOpacity = rOpacity; }
405 /// Visibility
406 Visibility getVisibility() const;
407 void setVisibility(const Visibility aVisibility) { maVisibility = aVisibility; }
409 // Title content
410 const OUString& getTitle() const { return maTitle; }
412 // Desc content
413 const OUString& getDesc() const { return maDesc; }
415 // ClipPathXLink content
416 OUString const & getClipPathXLink() const;
417 const SvgClipPathNode* accessClipPathXLink() const;
419 // MaskXLink content
420 OUString getMaskXLink() const;
421 const SvgMaskNode* accessMaskXLink() const;
423 // MarkerStartXLink content
424 OUString getMarkerStartXLink() const;
425 const SvgMarkerNode* accessMarkerStartXLink() const;
427 // MarkerMidXLink content
428 OUString getMarkerMidXLink() const;
429 const SvgMarkerNode* accessMarkerMidXLink() const;
431 // MarkerEndXLink content
432 OUString getMarkerEndXLink() const;
433 const SvgMarkerNode* accessMarkerEndXLink() const;
435 // BaselineShift
436 void setBaselineShift(const BaselineShift aBaselineShift) { maBaselineShift = aBaselineShift; }
437 BaselineShift getBaselineShift() const { return maBaselineShift; }
438 SvgNumber getBaselineShiftNumber() const;
440 } // end of namespace svgreader
441 } // end of namespace svgio
443 #endif // INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
445 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */