Line data Source code
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 : #ifndef INCLUDED_SVGIO_SVGREADER_SVGCHARACTERNODE_HXX
21 : #define INCLUDED_SVGIO_SVGREADER_SVGCHARACTERNODE_HXX
22 :
23 : #include <svgio/svgreader/svgnode.hxx>
24 :
25 :
26 : // predefines
27 :
28 : namespace drawinglayer { namespace primitive2d { class TextSimplePortionPrimitive2D; }}
29 :
30 :
31 :
32 : namespace svgio
33 : {
34 : namespace svgreader
35 : {
36 0 : class SvgTextPositions
37 : {
38 : private:
39 : SvgNumberVector maX;
40 : SvgNumberVector maY;
41 : SvgNumberVector maDx;
42 : SvgNumberVector maDy;
43 : SvgNumberVector maRotate;
44 : SvgNumber maTextLength;
45 :
46 : /// bitfield
47 : bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
48 :
49 : public:
50 : SvgTextPositions();
51 :
52 : void parseTextPositionAttributes(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent);
53 :
54 : /// X content
55 0 : const SvgNumberVector& getX() const { return maX; }
56 0 : void setX(const SvgNumberVector& aX) { maX = aX; }
57 :
58 : /// Y content
59 0 : const SvgNumberVector& getY() const { return maY; }
60 0 : void setY(const SvgNumberVector& aY) { maY = aY; }
61 :
62 : /// Dx content
63 0 : const SvgNumberVector& getDx() const { return maDx; }
64 0 : void setDx(const SvgNumberVector& aDx) { maDx = aDx; }
65 :
66 : /// Dy content
67 0 : const SvgNumberVector& getDy() const { return maDy; }
68 0 : void setDy(const SvgNumberVector& aDy) { maDy = aDy; }
69 :
70 : /// Rotate content
71 0 : const SvgNumberVector& getRotate() const { return maRotate; }
72 0 : void setRotate(const SvgNumberVector& aRotate) { maRotate = aRotate; }
73 :
74 : /// TextLength content
75 0 : const SvgNumber& getTextLength() const { return maTextLength; }
76 0 : void setTextLength(const SvgNumber& rTextLength = SvgNumber()) { maTextLength = rTextLength; }
77 :
78 : /// LengthAdjust content
79 0 : bool getLengthAdjust() const { return mbLengthAdjust; }
80 0 : void setLengthAdjust(bool bNew) { mbLengthAdjust = bNew; }
81 : };
82 : } // end of namespace svgreader
83 : } // end of namespace svgio
84 :
85 :
86 :
87 : namespace svgio
88 : {
89 : namespace svgreader
90 : {
91 0 : class SvgTextPosition
92 : {
93 : private:
94 : SvgTextPosition* mpParent;
95 : ::std::vector< double > maX;
96 : ::std::vector< double > maY;
97 : ::std::vector< double > maRotate;
98 : double mfTextLength;
99 :
100 : // absolute, current, advancing position
101 : basegfx::B2DPoint maPosition;
102 :
103 : // advancing rotation index
104 : sal_uInt32 mnRotationIndex;
105 :
106 : /// bitfield
107 : bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
108 : bool mbAbsoluteX : 1;
109 : bool mbAbsoluteY : 1;
110 :
111 : public:
112 : SvgTextPosition(
113 : SvgTextPosition* pParent,
114 : const InfoProvider& rInfoProvider,
115 : const SvgTextPositions& rSvgTextPositions);
116 :
117 : // data read access
118 0 : const SvgTextPosition* getParent() const { return mpParent; }
119 0 : const ::std::vector< double >& getX() const { return maX; }
120 : const ::std::vector< double >& getY() const { return maY; }
121 0 : double getTextLength() const { return mfTextLength; }
122 0 : bool getLengthAdjust() const { return mbLengthAdjust; }
123 0 : bool getAbsoluteX() const { return mbAbsoluteX; }
124 : bool getAbsoluteY() const { return mbAbsoluteY; }
125 :
126 : // get/set absolute, current, advancing position
127 0 : const basegfx::B2DPoint& getPosition() const { return maPosition; }
128 0 : void setPosition(const basegfx::B2DPoint& rNew) { maPosition = rNew; }
129 :
130 : // rotation handling
131 : bool isRotated() const;
132 : double consumeRotation();
133 : };
134 : } // end of namespace svgreader
135 : } // end of namespace svgio
136 :
137 :
138 :
139 : namespace svgio
140 : {
141 : namespace svgreader
142 : {
143 : class SvgCharacterNode : public SvgNode
144 : {
145 : private:
146 : /// the string data
147 : OUString maText;
148 :
149 : /// local helpers
150 : drawinglayer::primitive2d::TextSimplePortionPrimitive2D* createSimpleTextPrimitive(
151 : SvgTextPosition& rSvgTextPosition,
152 : const SvgStyleAttributes& rSvgStyleAttributes) const;
153 : void decomposeTextWithStyle(
154 : drawinglayer::primitive2d::Primitive2DSequence& rTarget,
155 : SvgTextPosition& rSvgTextPosition,
156 : const SvgStyleAttributes& rSvgStyleAttributes) const;
157 :
158 : public:
159 : SvgCharacterNode(
160 : SvgDocument& rDocument,
161 : SvgNode* pParent,
162 : const OUString& rText);
163 : virtual ~SvgCharacterNode();
164 :
165 : virtual const SvgStyleAttributes* getSvgStyleAttributes() const SAL_OVERRIDE;
166 : virtual void decomposeText(drawinglayer::primitive2d::Primitive2DSequence& rTarget, SvgTextPosition& rSvgTextPosition) const;
167 : void whiteSpaceHandling();
168 : void addGap();
169 : void concatenate(const OUString& rText);
170 :
171 : /// Text content
172 0 : const OUString& getText() const { return maText; }
173 : };
174 : } // end of namespace svgreader
175 : } // end of namespace svgio
176 :
177 :
178 :
179 : #endif //INCLUDED_SVGIO_SVGREADER_SVGCHARACTERNODE_HXX
180 :
181 : // eof
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|