1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
15 #include <dmapper/GraphicZOrderHelper.hxx>
16 #include <tools/ref.hxx>
18 namespace com::sun::star
36 namespace writerfilter::rtftok
38 class RTFDocumentImpl
;
41 /// Handles the import of drawings using RTF markup.
42 class RTFSdrImport final
: public virtual SvRefBase
45 RTFSdrImport(RTFDocumentImpl
& rDocument
,
46 css::uno::Reference
<css::lang::XComponent
> const& xDstDoc
);
47 ~RTFSdrImport() override
;
54 void resolve(RTFShape
& rShape
, bool bClose
, ShapeOrPict shapeOrPict
);
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.
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
,
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.
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
; }
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).
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)
100 std::stack
<writerfilter::dmapper::GraphicZOrderHelper
> m_aGraphicZOrderHelpers
;
102 } // namespace writerfilter::rtftok
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */