Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / source / rtftok / rtfsdrimport.hxx
blobb06803bd0f64e5ec1e9e076c53f19e9464cc79f5
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 <stack>
13 #include <vector>
15 #include <dmapper/GraphicZOrderHelper.hxx>
16 #include <tools/ref.hxx>
18 namespace com::sun::star
20 namespace beans
22 class XPropertySet;
23 struct PropertyValue;
25 namespace drawing
27 class XShape;
28 class XShapes;
30 namespace lang
32 class XComponent;
36 namespace writerfilter::rtftok
38 class RTFDocumentImpl;
39 class RTFShape;
41 /// Handles the import of drawings using RTF markup.
42 class RTFSdrImport final : public virtual SvRefBase
44 public:
45 RTFSdrImport(RTFDocumentImpl& rDocument,
46 css::uno::Reference<css::lang::XComponent> const& xDstDoc);
47 ~RTFSdrImport() override;
49 enum ShapeOrPict
51 SHAPE,
52 PICT
54 void resolve(RTFShape& rShape, bool bClose, ShapeOrPict shapeOrPict);
55 void close();
56 void append(std::u16string_view aKey, std::u16string_view aValue);
57 /// Append property on the current parent.
58 void appendGroupProperty(std::u16string_view aKey, std::u16string_view aValue);
59 void resolveDhgt(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
60 sal_Int32 nZOrder, bool bOldStyle);
61 /// Set line color and line width on the shape, using the relevant API depending on if the shape is a text frame or not.
62 static void
63 resolveLineColorAndWidth(bool bTextFrame,
64 const css::uno::Reference<css::beans::XPropertySet>& xPropertySet,
65 css::uno::Any const& rLineColor, css::uno::Any const& rLineWidth);
66 static void resolveFLine(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
67 sal_Int32 nFLine);
68 /**
69 * These are the default in Word, but not in Writer.
71 * @param bNew if the frame is new-style or old-style.
73 static std::vector<css::beans::PropertyValue> getTextFrameDefaults(bool bNew);
74 /// Push a new group shape to the parent stack.
75 void pushParent(css::uno::Reference<css::drawing::XShapes> const& xParent);
76 /// Pop the current group shape from the parent stack.
77 void popParent();
78 css::uno::Reference<css::drawing::XShape> const& getCurrentShape() const { return m_xShape; }
79 bool isFakePict() const { return m_bFakePict; }
80 bool isTextGraphicObject() const { return m_bTextGraphicObject; }
82 private:
83 void createShape(const OUString& rService, css::uno::Reference<css::drawing::XShape>& xShape,
84 css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
85 void applyProperty(css::uno::Reference<css::drawing::XShape> const& xShape,
86 std::u16string_view aKey, std::u16string_view aValue) const;
87 int initShape(css::uno::Reference<css::drawing::XShape>& o_xShape,
88 css::uno::Reference<css::beans::XPropertySet>& o_xPropSet, bool& o_rIsCustomShape,
89 RTFShape const& rShape, bool bClose, ShapeOrPict shapeOrPict);
91 RTFDocumentImpl& m_rImport;
92 std::stack<css::uno::Reference<css::drawing::XShapes>> m_aParents;
93 css::uno::Reference<css::drawing::XShape> m_xShape;
94 /// If m_xShape is imported as a Writer text frame (instead of a drawinglayer rectangle).
95 bool m_bTextFrame;
96 /// If m_xShape is imported as a Writer text graphic object (instead of a drawinglayer shape).
97 bool m_bTextGraphicObject;
98 /// if inside \pict, but actually it's a shape (not a picture)
99 bool m_bFakePict;
100 std::stack<writerfilter::dmapper::GraphicZOrderHelper> m_aGraphicZOrderHelpers;
102 } // namespace writerfilter::rtftok
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */