Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / source / rtftok / rtfvalue.hxx
blob6c87c61a1d05df857bc392f6f00d617644e194c1
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/.
8 */
10 #pragma once
12 #include <dmapper/resourcemodel.hxx>
14 #include <com/sun/star/text/GraphicCrop.hpp>
16 #include <optional>
18 namespace com::sun::star
20 namespace embed
22 class XEmbeddedObject;
24 namespace io
26 class XInputStream;
30 namespace writerfilter::rtftok
32 class RTFSprms;
33 class RTFShape;
34 class RTFPicture;
35 /// Value of an RTF keyword
36 class RTFValue : public Value
38 RTFValue(int nValue, OUString sValue, const RTFSprms* pAttributes, const RTFSprms* pSprms,
39 css::uno::Reference<css::drawing::XShape> xShape,
40 css::uno::Reference<css::io::XInputStream> xStream,
41 css::uno::Reference<css::embed::XEmbeddedObject> xObject, bool bForceString,
42 const RTFShape* pShape, const RTFPicture* pPicture);
44 public:
45 using Pointer_t = tools::SvRef<RTFValue>;
46 RTFValue();
47 explicit RTFValue(int nValue);
48 RTFValue(OUString sValue, bool bForce = false);
49 explicit RTFValue(const RTFSprms& rAttributes);
50 RTFValue(const RTFSprms& rAttributes, const RTFSprms& rSprms);
51 explicit RTFValue(css::uno::Reference<css::drawing::XShape> xShape);
52 explicit RTFValue(css::uno::Reference<css::io::XInputStream> xStream);
53 explicit RTFValue(css::uno::Reference<css::embed::XEmbeddedObject> xObject);
54 explicit RTFValue(const RTFShape& aShape);
55 explicit RTFValue(const RTFPicture& rPicture);
56 explicit RTFValue(css::text::GraphicCrop const& rCrop);
57 ~RTFValue() override;
58 void setString(const OUString& sValue);
59 int getInt() const override;
60 OUString getString() const override;
61 css::uno::Any getAny() const override;
62 writerfilter::Reference<Properties>::Pointer_t getProperties() override;
63 writerfilter::Reference<BinaryObj>::Pointer_t getBinary() override;
64 #ifdef DBG_UTIL
65 std::string toString() const override;
66 #endif
67 RTFValue* Clone() const;
68 RTFValue* CloneWithSprms(RTFSprms const& rAttributes, RTFSprms const& rSprms) const;
69 RTFSprms& getAttributes() const;
70 RTFSprms& getSprms() const;
71 RTFShape& getShape() const;
72 RTFPicture& getPicture() const;
73 bool equals(const RTFValue& rOther) const;
74 RTFValue& operator=(RTFValue const& rOther) = delete;
76 private:
77 int m_nValue = 0;
78 OUString m_sValue;
79 mutable tools::SvRef<RTFSprms> m_pAttributes;
80 mutable tools::SvRef<RTFSprms> m_pSprms;
81 css::uno::Reference<css::drawing::XShape> m_xShape;
82 css::uno::Reference<css::io::XInputStream> m_xStream;
83 css::uno::Reference<css::embed::XEmbeddedObject> m_xObject;
84 bool m_bForceString = false;
85 mutable tools::SvRef<RTFShape> m_pShape;
86 mutable tools::SvRef<RTFPicture> m_pPicture;
87 ::std::optional<css::text::GraphicCrop> m_oCrop;
89 } // namespace writerfilter::rtftok
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */