Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / writerfilter / source / rtftok / rtfsdrimport.hxx
blob57ce69e6d2e822ef9b9ae4aba427f94508e00be1
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 #ifndef INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSDRIMPORT_HXX
11 #define INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSDRIMPORT_HXX
13 #include <stack>
14 #include <vector>
16 #include <dmapper/GraphicZOrderHelper.hxx>
17 #include <tools/ref.hxx>
19 namespace com
21 namespace sun
23 namespace star
25 namespace beans
27 class XPropertySet;
28 struct PropertyValue;
30 namespace drawing
32 class XShape;
33 class XShapes;
35 namespace lang
37 class XComponent;
43 namespace writerfilter
45 namespace rtftok
47 class RTFDocumentImpl;
48 class RTFShape;
50 /// Handles the import of drawings using RTF markup.
51 class RTFSdrImport final : public virtual SvRefBase
53 public:
54 RTFSdrImport(RTFDocumentImpl& rDocument,
55 css::uno::Reference<css::lang::XComponent> const& xDstDoc);
56 ~RTFSdrImport() override;
58 enum ShapeOrPict
60 SHAPE,
61 PICT
63 void resolve(RTFShape& rShape, bool bClose, ShapeOrPict shapeOrPict);
64 void close();
65 void append(const OUString& aKey, const OUString& aValue);
66 /// Append property on the current parent.
67 void appendGroupProperty(const OUString& aKey, const OUString& aValue);
68 void resolveDhgt(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
69 sal_Int32 nZOrder, bool bOldStyle);
70 /// Set line color and line width on the shape, using the relevant API depending on if the shape is a text frame or not.
71 static void
72 resolveLineColorAndWidth(bool bTextFrame,
73 const css::uno::Reference<css::beans::XPropertySet>& xPropertySet,
74 css::uno::Any const& rLineColor, css::uno::Any const& rLineWidth);
75 static void resolveFLine(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
76 sal_Int32 nFLine);
77 /**
78 * These are the default in Word, but not in Writer.
80 * @param bNew if the frame is new-style or old-style.
82 static std::vector<css::beans::PropertyValue> getTextFrameDefaults(bool bNew);
83 /// Push a new group shape to the parent stack.
84 void pushParent(css::uno::Reference<css::drawing::XShapes> const& xParent);
85 /// Pop the current group shape from the parent stack.
86 void popParent();
87 css::uno::Reference<css::drawing::XShape> const& getCurrentShape() const { return m_xShape; }
88 bool isFakePict() const { return m_bFakePict; }
90 private:
91 void createShape(const OUString& rService, css::uno::Reference<css::drawing::XShape>& xShape,
92 css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
93 void applyProperty(css::uno::Reference<css::drawing::XShape> const& xShape,
94 const OUString& aKey, const OUString& aValue);
95 int initShape(css::uno::Reference<css::drawing::XShape>& o_xShape,
96 css::uno::Reference<css::beans::XPropertySet>& o_xPropSet, bool& o_rIsCustomShape,
97 RTFShape const& rShape, bool bClose, ShapeOrPict shapeOrPict);
99 RTFDocumentImpl& m_rImport;
100 std::stack<css::uno::Reference<css::drawing::XShapes>> m_aParents;
101 css::uno::Reference<css::drawing::XShape> m_xShape;
102 /// If m_xShape is imported as a Writer text frame (instead of a drawinglayer rectangle).
103 bool m_bTextFrame;
104 /// If m_xShape is imported as a Writer text graphic object (instead of a drawinglayer shape).
105 bool m_bTextGraphicObject;
106 /// if inside \pict, but actually it's a shape (not a picture)
107 bool m_bFakePict;
108 std::stack<writerfilter::dmapper::GraphicZOrderHelper> m_aGraphicZOrderHelpers;
110 } // namespace rtftok
111 } // namespace writerfilter
113 #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSDRIMPORT_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */