LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / writerfilter / source / rtftok / rtfsdrimport.hxx
blobc9bfd6ffa216baf9d4f491ae3001e828e3c107ff
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, const OUString& aValue);
57 /// Append property on the current parent.
58 void appendGroupProperty(std::u16string_view aKey, const OUString& 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; }
81 private:
82 void createShape(const OUString& rService, css::uno::Reference<css::drawing::XShape>& xShape,
83 css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
84 void applyProperty(css::uno::Reference<css::drawing::XShape> const& xShape,
85 std::u16string_view aKey, const OUString& aValue) const;
86 int initShape(css::uno::Reference<css::drawing::XShape>& o_xShape,
87 css::uno::Reference<css::beans::XPropertySet>& o_xPropSet, bool& o_rIsCustomShape,
88 RTFShape const& rShape, bool bClose, ShapeOrPict shapeOrPict);
90 RTFDocumentImpl& m_rImport;
91 std::stack<css::uno::Reference<css::drawing::XShapes>> m_aParents;
92 css::uno::Reference<css::drawing::XShape> m_xShape;
93 /// If m_xShape is imported as a Writer text frame (instead of a drawinglayer rectangle).
94 bool m_bTextFrame;
95 /// If m_xShape is imported as a Writer text graphic object (instead of a drawinglayer shape).
96 bool m_bTextGraphicObject;
97 /// if inside \pict, but actually it's a shape (not a picture)
98 bool m_bFakePict;
99 std::stack<writerfilter::dmapper::GraphicZOrderHelper> m_aGraphicZOrderHelpers;
101 } // namespace writerfilter::rtftok
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */