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 SvgNumber maFillOpacity
;
186 SvgNumberVector maStrokeDasharray
;
187 SvgNumber maStrokeDashOffset
;
188 StrokeLinecap maStrokeLinecap
;
189 StrokeLinejoin maStrokeLinejoin
;
190 SvgNumber maStrokeMiterLimit
;
191 SvgNumber maStrokeOpacity
;
192 SvgStringVector maFontFamily
;
194 SvgNumber maFontSizeNumber
;
195 FontStretch maFontStretch
;
196 FontStyle maFontStyle
;
197 FontWeight maFontWeight
;
198 TextAlign maTextAlign
;
199 TextDecoration maTextDecoration
;
200 TextAnchor maTextAnchor
;
203 Visibility maVisibility
;
207 /// link to content. If set, the node can be fetched on demand
208 OUString maClipPathXLink
;
209 const SvgClipPathNode
* mpClipPathXLink
;
210 OUString maMaskXLink
;
211 const SvgMaskNode
* mpMaskXLink
;
213 /// link to markers. If set, the node can be fetched on demand
214 OUString maMarkerStartXLink
;
215 const SvgMarkerNode
* mpMarkerStartXLink
;
216 OUString maMarkerMidXLink
;
217 const SvgMarkerNode
* mpMarkerMidXLink
;
218 OUString maMarkerEndXLink
;
219 const SvgMarkerNode
* mpMarkerEndXLink
;
224 // ClipRule setting (only valid when mbIsClipPathContent == true, default is FillRule_nonzero)
227 // BaselineShift: Type and number (in case of BaselineShift_Percentage or BaselineShift_Length)
228 BaselineShift maBaselineShift
;
229 SvgNumber maBaselineShiftNumber
;
231 mutable std::vector
<sal_uInt16
> maResolvingParent
;
233 // defines if this attributes are part of a ClipPath. If yes,
234 // rough geometry will be created on decomposition by patching
235 // values for fill, stroke, strokeWidth and others
236 bool mbIsClipPathContent
: 1;
238 // #121221# Defines if evtl. an empty array *is* set
239 bool mbStrokeDasharraySet
: 1;
241 // tdf#94765 Check id references in gradient/pattern getters
242 OUString maNodeFillURL
;
243 OUString maNodeStrokeURL
;
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;
281 /// local attribute scanner
282 void parseStyleAttribute(SVGToken aSVGToken
, const OUString
& rContent
,
283 bool bCaseIndependent
);
285 /// helper which does the necessary with a given path
287 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
288 drawinglayer::primitive2d::Primitive2DContainer
const & rSource
) const;
290 const basegfx::B2DPolyPolygon
& rPath
,
291 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
292 const basegfx::utils::PointIndexSet
* pHelpPointIndices
) const;
293 void add_postProcess(
294 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
295 const drawinglayer::primitive2d::Primitive2DContainer
& rSource
,
296 const basegfx::B2DHomMatrix
* pTransform
) const;
298 /// helper to set mpCssStyleParent temporarily for CSS style hierarchies
299 void setCssStyleParent(const SvgStyleAttributes
* pNew
) { mpCssStyleParent
= pNew
; }
300 const SvgStyleAttributes
* getCssStyleParent() const { return mpCssStyleParent
; }
303 void readCssStyle(const OUString
& rCandidate
);
304 const SvgStyleAttributes
* getParentStyle() const;
306 SvgStyleAttributes(SvgNode
& rOwner
);
307 ~SvgStyleAttributes();
310 bool isFillSet() const; // #i125258# ask if fill is a direct hard attribute (no hierarchy)
311 const basegfx::BColor
* getFill() const;
312 void setFill(const SvgPaint
& rFill
) { maFill
= rFill
; }
315 const basegfx::BColor
* getStroke() const;
317 /// stop color content
318 const basegfx::BColor
& getStopColor() const;
320 /// stroke-width content
321 SvgNumber
getStrokeWidth() const;
323 /// stop opacity content
324 SvgNumber
getStopOpacity() const;
326 /// access to evtl. set fill gradient
327 const SvgGradientNode
* getSvgGradientNodeFill() const;
329 /// access to evtl. set fill pattern
330 const SvgPatternNode
* getSvgPatternNodeFill() const;
332 /// access to evtl. set stroke gradient
333 const SvgGradientNode
* getSvgGradientNodeStroke() const;
335 /// access to evtl. set stroke pattern
336 const SvgPatternNode
* getSvgPatternNodeStroke() const;
338 /// fill opacity content
339 SvgNumber
getFillOpacity() const;
341 /// fill rule content
342 FillRule
getFillRule() const;
344 /// fill StrokeDasharray content
345 const SvgNumberVector
& getStrokeDasharray() const;
347 /// StrokeDashOffset content
348 SvgNumber
getStrokeDashOffset() const;
350 /// StrokeLinecap content
351 StrokeLinecap
getStrokeLinecap() const;
352 void setStrokeLinecap(const StrokeLinecap aStrokeLinecap
) { maStrokeLinecap
= aStrokeLinecap
; }
354 /// StrokeLinejoin content
355 StrokeLinejoin
getStrokeLinejoin() const;
356 void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin
) { maStrokeLinejoin
= aStrokeLinejoin
; }
358 /// StrokeMiterLimit content
359 SvgNumber
getStrokeMiterLimit() const;
361 /// StrokeOpacity content
362 SvgNumber
getStrokeOpacity() const;
365 const SvgStringVector
& getFontFamily() const;
368 void setFontSize(const FontSize aFontSize
) { maFontSize
= aFontSize
; }
369 SvgNumber
getFontSizeNumber() const;
371 /// FontStretch content
372 FontStretch
getFontStretch() const;
373 void setFontStretch(const FontStretch aFontStretch
) { maFontStretch
= aFontStretch
; }
375 /// FontStyle content
376 FontStyle
getFontStyle() const;
377 void setFontStyle(const FontStyle aFontStyle
) { maFontStyle
= aFontStyle
; }
379 /// FontWeight content
380 FontWeight
getFontWeight() const;
381 void setFontWeight(const FontWeight aFontWeight
) { maFontWeight
= aFontWeight
; }
383 /// TextAlign content
384 TextAlign
getTextAlign() const;
385 void setTextAlign(const TextAlign aTextAlign
) { maTextAlign
= aTextAlign
; }
387 /// TextDecoration content
388 const SvgStyleAttributes
* getTextDecorationDefiningSvgStyleAttributes() const;
389 TextDecoration
getTextDecoration() const;
390 void setTextDecoration(const TextDecoration aTextDecoration
) { maTextDecoration
= aTextDecoration
; }
392 /// TextAnchor content
393 TextAnchor
getTextAnchor() const;
394 void setTextAnchor(const TextAnchor aTextAnchor
) { maTextAnchor
= aTextAnchor
; }
397 const basegfx::BColor
* getColor() const;
399 /// Resolve current color (defaults to black if no color is specified)
400 const basegfx::BColor
* getCurrentColor() const;
403 SvgNumber
getOpacity() const;
404 void setOpacity(const SvgNumber
& rOpacity
) { maOpacity
= rOpacity
; }
407 Visibility
getVisibility() const;
408 void setVisibility(const Visibility aVisibility
) { maVisibility
= aVisibility
; }
411 const OUString
& getTitle() const { return maTitle
; }
414 const OUString
& getDesc() const { return maDesc
; }
416 // ClipPathXLink content
417 OUString
const & getClipPathXLink() const;
418 const SvgClipPathNode
* accessClipPathXLink() const;
421 OUString
getMaskXLink() const;
422 const SvgMaskNode
* accessMaskXLink() const;
424 // MarkerStartXLink content
425 OUString
getMarkerStartXLink() const;
426 const SvgMarkerNode
* accessMarkerStartXLink() const;
428 // MarkerMidXLink content
429 OUString
getMarkerMidXLink() const;
430 const SvgMarkerNode
* accessMarkerMidXLink() const;
432 // MarkerEndXLink content
433 OUString
getMarkerEndXLink() const;
434 const SvgMarkerNode
* accessMarkerEndXLink() const;
437 void setBaselineShift(const BaselineShift aBaselineShift
) { maBaselineShift
= aBaselineShift
; }
438 BaselineShift
getBaselineShift() const { return maBaselineShift
; }
439 SvgNumber
getBaselineShiftNumber() const;
441 } // end of namespace svgreader
442 } // end of namespace svgio
444 #endif // INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
446 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */