Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / svgio / inc / svgcharacternode.hxx
blob042a412d3ebd5cb0f41fc9bee7d5bdaabd3f0fff
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_SVGCHARACTERNODE_HXX
21 #define INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
23 #include "svgnode.hxx"
25 namespace drawinglayer { namespace primitive2d { class TextSimplePortionPrimitive2D; }}
27 namespace svgio
29 namespace svgreader
31 class SvgTextPositions
33 private:
34 SvgNumberVector maX;
35 SvgNumberVector maY;
36 SvgNumberVector maDx;
37 SvgNumberVector maDy;
38 SvgNumberVector maRotate;
39 SvgNumber maTextLength;
41 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
43 public:
44 SvgTextPositions();
46 void parseTextPositionAttributes(SVGToken aSVGToken, const OUString& aContent);
48 /// X content
49 const SvgNumberVector& getX() const { return maX; }
50 void setX(const SvgNumberVector& aX) { maX = aX; }
52 /// Y content
53 const SvgNumberVector& getY() const { return maY; }
54 void setY(const SvgNumberVector& aY) { maY = aY; }
56 /// Dx content
57 const SvgNumberVector& getDx() const { return maDx; }
58 void setDx(const SvgNumberVector& aDx) { maDx = aDx; }
60 /// Dy content
61 const SvgNumberVector& getDy() const { return maDy; }
62 void setDy(const SvgNumberVector& aDy) { maDy = aDy; }
64 /// Rotate content
65 const SvgNumberVector& getRotate() const { return maRotate; }
66 void setRotate(const SvgNumberVector& aRotate) { maRotate = aRotate; }
68 /// TextLength content
69 const SvgNumber& getTextLength() const { return maTextLength; }
70 void setTextLength(const SvgNumber& rTextLength) { maTextLength = rTextLength; }
72 /// LengthAdjust content
73 bool getLengthAdjust() const { return mbLengthAdjust; }
74 void setLengthAdjust(bool bNew) { mbLengthAdjust = bNew; }
76 } // end of namespace svgreader
77 } // end of namespace svgio
80 namespace svgio
82 namespace svgreader
84 class SvgTextPosition
86 private:
87 SvgTextPosition* mpParent;
88 ::std::vector< double > maX;
89 ::std::vector< double > maY;
90 ::std::vector< double > maRotate;
91 double mfTextLength;
93 // absolute, current, advancing position
94 basegfx::B2DPoint maPosition;
96 // advancing rotation index
97 sal_uInt32 mnRotationIndex;
99 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
100 bool mbAbsoluteX : 1;
102 public:
103 SvgTextPosition(
104 SvgTextPosition* pParent,
105 const InfoProvider& rInfoProvider,
106 const SvgTextPositions& rSvgTextPositions);
108 // data read access
109 const SvgTextPosition* getParent() const { return mpParent; }
110 const ::std::vector< double >& getX() const { return maX; }
111 double getTextLength() const { return mfTextLength; }
112 bool getLengthAdjust() const { return mbLengthAdjust; }
113 bool getAbsoluteX() const { return mbAbsoluteX; }
115 // get/set absolute, current, advancing position
116 const basegfx::B2DPoint& getPosition() const { return maPosition; }
117 void setPosition(const basegfx::B2DPoint& rNew) { maPosition = rNew; }
119 // rotation handling
120 bool isRotated() const;
121 double consumeRotation();
123 } // end of namespace svgreader
124 } // end of namespace svgio
127 namespace svgio
129 namespace svgreader
131 class SvgCharacterNode : public SvgNode
133 private:
134 /// the string data
135 OUString maText;
137 /// local helpers
138 drawinglayer::primitive2d::TextSimplePortionPrimitive2D* createSimpleTextPrimitive(
139 SvgTextPosition& rSvgTextPosition,
140 const SvgStyleAttributes& rSvgStyleAttributes) const;
141 void decomposeTextWithStyle(
142 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
143 SvgTextPosition& rSvgTextPosition,
144 const SvgStyleAttributes& rSvgStyleAttributes) const;
146 public:
147 SvgCharacterNode(
148 SvgDocument& rDocument,
149 SvgNode* pParent,
150 const OUString& rText);
151 virtual ~SvgCharacterNode() override;
153 virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
154 void decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, SvgTextPosition& rSvgTextPosition) const;
155 void whiteSpaceHandling();
156 void addGap();
157 void concatenate(const OUString& rText);
159 /// Text content
160 const OUString& getText() const { return maText; }
162 } // end of namespace svgreader
163 } // end of namespace svgio
165 #endif // INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */