1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
32 namespace svgio
{ namespace svgreader
{
33 class SvgGradientNode
;
36 class SvgClipPathNode
;
55 StrokeLinejoin_notset
,
82 FontStretch_ultra_condensed
,
83 FontStretch_extra_condensed
,
84 FontStretch_condensed
,
85 FontStretch_semi_condensed
,
86 FontStretch_semi_expanded
,
88 FontStretch_extra_expanded
,
89 FontStretch_ultra_expanded
92 FontStretch
getWider(FontStretch aSource
);
93 FontStretch
getNarrower(FontStretch aSource
);
109 FontWeight_400
, // same as FontWeight_normal
112 FontWeight_700
, // same as FontWeight_bold
119 FontWeight
getBolder(FontWeight aSource
);
120 FontWeight
getLighter(FontWeight aSource
);
121 ::FontWeight
getVclFontWeight(FontWeight aSource
);
134 TextDecoration_notset
,
136 TextDecoration_underline
,
137 TextDecoration_overline
,
138 TextDecoration_line_through
,
159 BaselineShift_Baseline
,
162 BaselineShift_Percentage
,
175 class SvgStyleAttributes
179 const SvgStyleAttributes
* mpCssStyleParent
;
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
;
198 SvgNumber maFontSizeNumber
;
199 FontStretch maFontStretch
;
200 FontStyle maFontStyle
;
201 FontWeight maFontWeight
;
202 TextAlign maTextAlign
;
203 TextDecoration maTextDecoration
;
204 TextAnchor maTextAnchor
;
207 Visibility maVisibility
;
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
;
228 // ClipRule setting (only valid when mbIsClipPathContent == true, default is FillRule_nonzero)
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;
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;
262 const basegfx::B2DPolyPolygon
& rPath
,
263 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
264 const basegfx::B2DRange
& rGeoRange
) const;
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;
275 const basegfx::B2DPolyPolygon
& rPath
,
276 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
277 const basegfx::utils::PointIndexSet
* pHelpPointIndices
) const;
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
286 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
287 drawinglayer::primitive2d::Primitive2DContainer
const & rSource
) const;
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
; }
302 void readCssStyle(const OUString
& rCandidate
);
303 const SvgStyleAttributes
* getParentStyle() const;
305 SvgStyleAttributes(SvgNode
& rOwner
);
306 ~SvgStyleAttributes();
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
; }
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;
364 const SvgStringVector
& getFontFamily() const;
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
; }
396 const basegfx::BColor
* getColor() const;
398 /// Resolve current color (defaults to black if no color is specified)
399 const basegfx::BColor
* getCurrentColor() const;
402 SvgNumber
getOpacity() const;
403 void setOpacity(const SvgNumber
& rOpacity
) { maOpacity
= rOpacity
; }
406 Visibility
getVisibility() const;
407 void setVisibility(const Visibility aVisibility
) { maVisibility
= aVisibility
; }
410 const OUString
& getTitle() const { return maTitle
; }
413 const OUString
& getDesc() const { return maDesc
; }
415 // ClipPathXLink content
416 OUString
const & getClipPathXLink() const;
417 const SvgClipPathNode
* accessClipPathXLink() const;
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;
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: */