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_SVGCHARACTERNODE_HXX
21 #define INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
23 #include "svgnode.hxx"
25 namespace drawinglayer::primitive2d
{ class TextSimplePortionPrimitive2D
; }
27 namespace svgio::svgreader
29 class SvgTextPositions
36 SvgNumberVector maRotate
;
37 SvgNumber maTextLength
;
39 bool mbLengthAdjust
: 1; // true = spacing, false = spacingAndGlyphs
44 void parseTextPositionAttributes(SVGToken aSVGToken
, const OUString
& aContent
);
47 const SvgNumberVector
& getX() const { return maX
; }
48 void setX(const SvgNumberVector
& aX
) { maX
= aX
; }
51 const SvgNumberVector
& getY() const { return maY
; }
52 void setY(const SvgNumberVector
& aY
) { maY
= aY
; }
55 const SvgNumberVector
& getDx() const { return maDx
; }
56 void setDx(const SvgNumberVector
& aDx
) { maDx
= aDx
; }
59 const SvgNumberVector
& getDy() const { return maDy
; }
60 void setDy(const SvgNumberVector
& aDy
) { maDy
= aDy
; }
63 const SvgNumberVector
& getRotate() const { return maRotate
; }
64 void setRotate(const SvgNumberVector
& aRotate
) { maRotate
= aRotate
; }
66 /// TextLength content
67 const SvgNumber
& getTextLength() const { return maTextLength
; }
68 void setTextLength(const SvgNumber
& rTextLength
) { maTextLength
= rTextLength
; }
70 /// LengthAdjust content
71 bool getLengthAdjust() const { return mbLengthAdjust
; }
72 void setLengthAdjust(bool bNew
) { mbLengthAdjust
= bNew
; }
75 } // end of namespace svgio::svgreader
78 namespace svgio::svgreader
83 SvgTextPosition
* mpParent
;
84 ::std::vector
< double > maX
;
85 ::std::vector
< double > maY
;
86 ::std::vector
< double > maRotate
;
89 // absolute, current, advancing position
90 basegfx::B2DPoint maPosition
;
92 // advancing rotation index
93 sal_uInt32 mnRotationIndex
;
95 bool mbLengthAdjust
: 1; // true = spacing, false = spacingAndGlyphs
100 SvgTextPosition
* pParent
,
101 const InfoProvider
& rInfoProvider
,
102 const SvgTextPositions
& rSvgTextPositions
);
105 const SvgTextPosition
* getParent() const { return mpParent
; }
106 const ::std::vector
< double >& getX() const { return maX
; }
107 double getTextLength() const { return mfTextLength
; }
108 bool getLengthAdjust() const { return mbLengthAdjust
; }
109 bool getAbsoluteX() const { return mbAbsoluteX
; }
111 // get/set absolute, current, advancing position
112 const basegfx::B2DPoint
& getPosition() const { return maPosition
; }
113 void setPosition(const basegfx::B2DPoint
& rNew
) { maPosition
= rNew
; }
116 bool isRotated() const;
117 double consumeRotation();
120 } // end of namespace svgio::svgreader
123 namespace svgio::svgreader
125 class SvgCharacterNode final
: public SvgNode
132 drawinglayer::primitive2d::TextSimplePortionPrimitive2D
* createSimpleTextPrimitive(
133 SvgTextPosition
& rSvgTextPosition
,
134 const SvgStyleAttributes
& rSvgStyleAttributes
) const;
135 void decomposeTextWithStyle(
136 drawinglayer::primitive2d::Primitive2DContainer
& rTarget
,
137 SvgTextPosition
& rSvgTextPosition
,
138 const SvgStyleAttributes
& rSvgStyleAttributes
) const;
142 SvgDocument
& rDocument
,
144 const OUString
& rText
);
145 virtual ~SvgCharacterNode() override
;
147 virtual const SvgStyleAttributes
* getSvgStyleAttributes() const override
;
148 void decomposeText(drawinglayer::primitive2d::Primitive2DContainer
& rTarget
, SvgTextPosition
& rSvgTextPosition
) const;
149 void whiteSpaceHandling();
151 void concatenate(const OUString
& rText
);
154 const OUString
& getText() const { return maText
; }
157 } // end of namespace svgio::svgreader
159 #endif // INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */