bump product version to 7.2.5.1
[LibreOffice.git] / svgio / inc / svgcharacternode.hxx
blobf663cf9d9d0e6d850979316da03acae986eeef9b
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 #pragma once
22 #include <sal/config.h>
23 #include <rtl/ref.hxx>
25 #include <string_view>
27 #include "svgnode.hxx"
29 namespace drawinglayer::primitive2d { class TextSimplePortionPrimitive2D; }
31 namespace svgio::svgreader
33 class SvgTextPositions
35 private:
36 SvgNumberVector maX;
37 SvgNumberVector maY;
38 SvgNumberVector maDx;
39 SvgNumberVector maDy;
40 SvgNumberVector maRotate;
41 SvgNumber maTextLength;
43 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
45 public:
46 SvgTextPositions();
48 void parseTextPositionAttributes(SVGToken aSVGToken, const OUString& aContent);
50 /// X content
51 const SvgNumberVector& getX() const { return maX; }
52 void setX(const SvgNumberVector& aX) { maX = aX; }
54 /// Y content
55 const SvgNumberVector& getY() const { return maY; }
56 void setY(const SvgNumberVector& aY) { maY = aY; }
58 /// Dx content
59 const SvgNumberVector& getDx() const { return maDx; }
60 void setDx(const SvgNumberVector& aDx) { maDx = aDx; }
62 /// Dy content
63 const SvgNumberVector& getDy() const { return maDy; }
64 void setDy(const SvgNumberVector& aDy) { maDy = aDy; }
66 /// Rotate content
67 const SvgNumberVector& getRotate() const { return maRotate; }
68 void setRotate(const SvgNumberVector& aRotate) { maRotate = aRotate; }
70 /// TextLength content
71 const SvgNumber& getTextLength() const { return maTextLength; }
72 void setTextLength(const SvgNumber& rTextLength) { maTextLength = rTextLength; }
74 /// LengthAdjust content
75 bool getLengthAdjust() const { return mbLengthAdjust; }
76 void setLengthAdjust(bool bNew) { mbLengthAdjust = bNew; }
79 class SvgTextPosition
81 private:
82 SvgTextPosition* mpParent;
83 ::std::vector< double > maX;
84 ::std::vector< double > maY;
85 ::std::vector< double > maRotate;
86 double mfTextLength;
88 // absolute, current, advancing position
89 basegfx::B2DPoint maPosition;
91 // advancing rotation index
92 sal_uInt32 mnRotationIndex;
94 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
95 bool mbAbsoluteX : 1;
97 public:
98 SvgTextPosition(
99 SvgTextPosition* pParent,
100 const InfoProvider& rInfoProvider,
101 const SvgTextPositions& rSvgTextPositions);
103 // data read access
104 const SvgTextPosition* getParent() const { return mpParent; }
105 const ::std::vector< double >& getX() const { return maX; }
106 double getTextLength() const { return mfTextLength; }
107 bool getLengthAdjust() const { return mbLengthAdjust; }
108 bool getAbsoluteX() const { return mbAbsoluteX; }
110 // get/set absolute, current, advancing position
111 const basegfx::B2DPoint& getPosition() const { return maPosition; }
112 void setPosition(const basegfx::B2DPoint& rNew) { maPosition = rNew; }
114 // rotation handling
115 bool isRotated() const;
116 double consumeRotation();
119 class SvgCharacterNode final : public SvgNode
121 private:
122 /// the string data
123 OUString maText;
125 /// local helpers
126 rtl::Reference<drawinglayer::primitive2d::TextSimplePortionPrimitive2D> createSimpleTextPrimitive(
127 SvgTextPosition& rSvgTextPosition,
128 const SvgStyleAttributes& rSvgStyleAttributes) const;
129 void decomposeTextWithStyle(
130 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
131 SvgTextPosition& rSvgTextPosition,
132 const SvgStyleAttributes& rSvgStyleAttributes) const;
134 public:
135 SvgCharacterNode(
136 SvgDocument& rDocument,
137 SvgNode* pParent,
138 const OUString& rText);
139 virtual ~SvgCharacterNode() override;
141 virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
142 void decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, SvgTextPosition& rSvgTextPosition) const;
143 void whiteSpaceHandling();
144 void addGap();
145 void concatenate(std::u16string_view rText);
147 /// Text content
148 const OUString& getText() const { return maText; }
151 } // end of namespace svgio::svgreader
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */