LibreOffice Module svgio (master) 1
svgcharacternode.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23#include <rtl/ref.hxx>
24
25#include <string_view>
26
27#include "svgnode.hxx"
28
29namespace drawinglayer::primitive2d { class TextSimplePortionPrimitive2D; }
30
31namespace svgio::svgreader
32 {
34 {
35 private:
42
43 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
44
45 public:
47
48 void parseTextPositionAttributes(SVGToken aSVGToken, std::u16string_view aContent);
49
51 const SvgNumberVector& getX() const { return maX; }
52 void setX(SvgNumberVector&& aX) { maX = std::move(aX); }
53
55 const SvgNumberVector& getY() const { return maY; }
56 void setY(SvgNumberVector&& aY) { maY = std::move(aY); }
57
59 const SvgNumberVector& getDx() const { return maDx; }
60 void setDx(SvgNumberVector&& aDx) { maDx = std::move(aDx); }
61
63 const SvgNumberVector& getDy() const { return maDy; }
64 void setDy(SvgNumberVector&& aDy) { maDy = std::move(aDy); }
65
67 const SvgNumberVector& getRotate() const { return maRotate; }
68 void setRotate(SvgNumberVector&& aRotate) { maRotate = std::move(aRotate); }
69
71 const SvgNumber& getTextLength() const { return maTextLength; }
72 void setTextLength(const SvgNumber& rTextLength) { maTextLength = rTextLength; }
73
75 bool getLengthAdjust() const { return mbLengthAdjust; }
76 void setLengthAdjust(bool bNew) { mbLengthAdjust = bNew; }
77 };
78
80 {
81 private:
83 ::std::vector< double > maX;
84 ::std::vector< double > maY;
85 ::std::vector< double > maRotate;
87
88 // absolute, current, advancing position
90
91 // advancing rotation index
92 sal_uInt32 mnRotationIndex;
93
94 bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
95 bool mbAbsoluteX : 1;
96
97 public:
99 SvgTextPosition* pParent,
100 const InfoProvider& rInfoProvider,
101 const SvgTextPositions& rSvgTextPositions);
102
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; }
109
110 // get/set absolute, current, advancing position
111 const basegfx::B2DPoint& getPosition() const { return maPosition; }
112 void setPosition(const basegfx::B2DPoint& rNew) { maPosition = rNew; }
113
114 // rotation handling
115 bool isRotated() const;
116 double consumeRotation();
117 };
118
119 class SvgCharacterNode final : public SvgNode
120 {
121 private:
123 OUString maText;
124
125 // keep a copy of string data before space handling
127
130 SvgTextPosition& rSvgTextPosition,
131 const SvgStyleAttributes& rSvgStyleAttributes) const;
134 SvgTextPosition& rSvgTextPosition,
135 const SvgStyleAttributes& rSvgStyleAttributes) const;
136
137 public:
139 SvgDocument& rDocument,
140 SvgNode* pParent,
141 OUString aText);
142 virtual ~SvgCharacterNode() override;
143
144 virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
146 void whiteSpaceHandling();
147 void addGap();
148 void concatenate(std::u16string_view rText);
149
151 const OUString& getText() const { return maText; }
152
153 const OUString& getTextBeforeSpaceHandling() const { return maTextBeforeSpaceHandling; }
154 };
155
156} // end of namespace svgio::svgreader
157
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void decomposeTextWithStyle(drawinglayer::primitive2d::Primitive2DContainer &rTarget, SvgTextPosition &rSvgTextPosition, const SvgStyleAttributes &rSvgStyleAttributes) const
void concatenate(std::u16string_view rText)
const OUString & getTextBeforeSpaceHandling() const
SvgCharacterNode(SvgDocument &rDocument, SvgNode *pParent, OUString aText)
virtual const SvgStyleAttributes * getSvgStyleAttributes() const override
void decomposeText(drawinglayer::primitive2d::Primitive2DContainer &rTarget, SvgTextPosition &rSvgTextPosition) const
const OUString & getText() const
Text content.
rtl::Reference< drawinglayer::primitive2d::BasePrimitive2D > createSimpleTextPrimitive(SvgTextPosition &rSvgTextPosition, const SvgStyleAttributes &rSvgStyleAttributes) const
local helpers
::std::vector< double > maRotate
const SvgTextPosition * getParent() const
const ::std::vector< double > & getX() const
void setPosition(const basegfx::B2DPoint &rNew)
const basegfx::B2DPoint & getPosition() const
SvgTextPosition(SvgTextPosition *pParent, const InfoProvider &rInfoProvider, const SvgTextPositions &rSvgTextPositions)
const SvgNumberVector & getY() const
Y content.
void setDx(SvgNumberVector &&aDx)
const SvgNumberVector & getX() const
X content.
void setY(SvgNumberVector &&aY)
const SvgNumberVector & getRotate() const
Rotate content.
const SvgNumberVector & getDy() const
Dy content.
void parseTextPositionAttributes(SVGToken aSVGToken, std::u16string_view aContent)
const SvgNumber & getTextLength() const
TextLength content.
void setX(SvgNumberVector &&aX)
void setDy(SvgNumberVector &&aDy)
void setTextLength(const SvgNumber &rTextLength)
bool getLengthAdjust() const
LengthAdjust content.
void setRotate(SvgNumberVector &&aRotate)
const SvgNumberVector & getDx() const
Dx content.
std::vector< SvgNumber > SvgNumberVector
Definition: SvgNumber.hxx:111