nss: upgrade to release 3.73
[LibreOffice.git] / svgio / inc / svgcharacternode.hxx
blob988c30001df901652324d30670de232b3cbfe521
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::primitive2d { class TextSimplePortionPrimitive2D; }
27 namespace svgio::svgreader
29 class SvgTextPositions
31 private:
32 SvgNumberVector maX;
33 SvgNumberVector maY;
34 SvgNumberVector maDx;
35 SvgNumberVector maDy;
36 SvgNumberVector maRotate;
37 SvgNumber maTextLength;
39 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
41 public:
42 SvgTextPositions();
44 void parseTextPositionAttributes(SVGToken aSVGToken, const OUString& aContent);
46 /// X content
47 const SvgNumberVector& getX() const { return maX; }
48 void setX(const SvgNumberVector& aX) { maX = aX; }
50 /// Y content
51 const SvgNumberVector& getY() const { return maY; }
52 void setY(const SvgNumberVector& aY) { maY = aY; }
54 /// Dx content
55 const SvgNumberVector& getDx() const { return maDx; }
56 void setDx(const SvgNumberVector& aDx) { maDx = aDx; }
58 /// Dy content
59 const SvgNumberVector& getDy() const { return maDy; }
60 void setDy(const SvgNumberVector& aDy) { maDy = aDy; }
62 /// Rotate content
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
80 class SvgTextPosition
82 private:
83 SvgTextPosition* mpParent;
84 ::std::vector< double > maX;
85 ::std::vector< double > maY;
86 ::std::vector< double > maRotate;
87 double mfTextLength;
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
96 bool mbAbsoluteX : 1;
98 public:
99 SvgTextPosition(
100 SvgTextPosition* pParent,
101 const InfoProvider& rInfoProvider,
102 const SvgTextPositions& rSvgTextPositions);
104 // data read access
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; }
115 // rotation handling
116 bool isRotated() const;
117 double consumeRotation();
120 } // end of namespace svgio::svgreader
123 namespace svgio::svgreader
125 class SvgCharacterNode final : public SvgNode
127 private:
128 /// the string data
129 OUString maText;
131 /// local helpers
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;
140 public:
141 SvgCharacterNode(
142 SvgDocument& rDocument,
143 SvgNode* pParent,
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();
150 void addGap();
151 void concatenate(const OUString& rText);
153 /// Text content
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: */