Avoid potential negative array index access to cached text.
[LibreOffice.git] / svgio / inc / svgcharacternode.hxx
blob20c60d787cb5d20767ed8d95390af775af75df51
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 <drawinglayer/attribute/fontattribute.hxx>
28 #include "svgtextnode.hxx"
29 #include "svgtextposition.hxx"
31 namespace drawinglayer::primitive2d { class TextSimplePortionPrimitive2D; }
33 namespace svgio::svgreader
35 class SvgCharacterNode final : public SvgNode
37 private:
38 /// the string data
39 OUString maText;
41 SvgTspanNode* mpParentLine;
43 bool mbHadTrailingSpace = false;
45 /// local helpers
46 rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> createSimpleTextPrimitive(
47 SvgTextPosition& rSvgTextPosition,
48 const SvgStyleAttributes& rSvgStyleAttributes) const;
49 void decomposeTextWithStyle(
50 drawinglayer::primitive2d::Primitive2DContainer& rTarget,
51 SvgTextPosition& rSvgTextPosition,
52 const SvgStyleAttributes& rSvgStyleAttributes) const;
54 public:
55 SvgCharacterNode(
56 SvgDocument& rDocument,
57 SvgNode* pParent,
58 OUString aText);
59 virtual ~SvgCharacterNode() override;
61 static drawinglayer::attribute::FontAttribute getFontAttribute(
62 const SvgStyleAttributes& rSvgStyleAttributes);
64 virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
66 void decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, SvgTextPosition& rSvgTextPosition) const;
67 SvgCharacterNode* whiteSpaceHandling(SvgCharacterNode* pPreviousCharacterNode);
68 void concatenate(std::u16string_view rText);
70 /// Text content
71 const OUString& getText() const { return maText; }
73 void setParentLine(SvgTspanNode* pParentLine) { mpParentLine = pParentLine; }
76 } // end of namespace svgio::svgreader
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */