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 .
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
40 SvgNumberVector maRotate
;
41 SvgNumber maTextLength
;
43 bool mbLengthAdjust
: 1; // true = spacing, false = spacingAndGlyphs
48 void parseTextPositionAttributes(SVGToken aSVGToken
, const OUString
& aContent
);
51 const SvgNumberVector
& getX() const { return maX
; }
52 void setX(const SvgNumberVector
& aX
) { maX
= aX
; }
55 const SvgNumberVector
& getY() const { return maY
; }
56 void setY(const SvgNumberVector
& aY
) { maY
= aY
; }
59 const SvgNumberVector
& getDx() const { return maDx
; }
60 void setDx(const SvgNumberVector
& aDx
) { maDx
= aDx
; }
63 const SvgNumberVector
& getDy() const { return maDy
; }
64 void setDy(const SvgNumberVector
& aDy
) { maDy
= aDy
; }
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
; }
82 SvgTextPosition
* mpParent
;
83 ::std::vector
< double > maX
;
84 ::std::vector
< double > maY
;
85 ::std::vector
< double > maRotate
;
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
99 SvgTextPosition
* pParent
,
100 const InfoProvider
& rInfoProvider
,
101 const SvgTextPositions
& rSvgTextPositions
);
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
; }
115 bool isRotated() const;
116 double consumeRotation();
119 class SvgCharacterNode final
: public SvgNode
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;
136 SvgDocument
& rDocument
,
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();
145 void concatenate(std::u16string_view rText
);
148 const OUString
& getText() const { return maText
; }
151 } // end of namespace svgio::svgreader
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */