Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #ifndef INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSDRIMPORT_HXX
11 : #define INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSDRIMPORT_HXX
12 :
13 : #include <stack>
14 :
15 : #include <com/sun/star/drawing/XShapes.hpp>
16 :
17 : #include <dmapper/GraphicZOrderHelper.hxx>
18 : #include <rtfdocumentimpl.hxx>
19 :
20 : namespace writerfilter
21 : {
22 : namespace rtftok
23 : {
24 : /// Handles the import of drawings using RTF markup.
25 : class RTFSdrImport
26 : {
27 : public:
28 : RTFSdrImport(RTFDocumentImpl& rImport, css::uno::Reference<css::lang::XComponent> const& xDstDoc);
29 : virtual ~RTFSdrImport();
30 :
31 : enum ShapeOrPict { SHAPE, PICT };
32 : void resolve(RTFShape& rShape, bool bClose, ShapeOrPict shapeOrPict);
33 : void close();
34 : void append(const OUString& aKey, const OUString& aValue);
35 : /// Append property on the current parent.
36 : void appendGroupProperty(const OUString& aKey, const OUString& aValue);
37 : void resolveDhgt(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, sal_Int32 nZOrder, bool bOldStyle);
38 : /// Set line color and line width on the shape, using the relevant API depending on if the shape is a text frame or not.
39 : static void resolveLineColorAndWidth(bool bTextFrame, const css::uno::Reference<css::beans::XPropertySet>& xPropertySet, css::uno::Any& rLineColor, css::uno::Any& rLineWidth);
40 : static void resolveFLine(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, sal_Int32 nFLine);
41 : /**
42 : * These are the default in Word, but not in Writer.
43 : *
44 : * @param bNew if the frame is new-style or old-style.
45 : */
46 : static std::vector<css::beans::PropertyValue> getTextFrameDefaults(bool bNew);
47 : /// Push a new group shape to the parent stack.
48 : void pushParent(css::uno::Reference<css::drawing::XShapes> const& xParent);
49 : /// Pop the current group shape from the parent stack.
50 : void popParent();
51 19 : css::uno::Reference<css::drawing::XShape> const& getCurrentShape()
52 : {
53 19 : return m_xShape;
54 : }
55 21 : bool isFakePict()
56 : {
57 21 : return m_bFakePict;
58 : }
59 : private:
60 : void createShape(const OUString& aService, css::uno::Reference<css::drawing::XShape>& xShape, css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
61 : void applyProperty(css::uno::Reference<css::drawing::XShape> const& xShape, const OUString& aKey, const OUString& aValue);
62 : int initShape(css::uno::Reference<css::drawing::XShape>& o_xShape,
63 : css::uno::Reference<css::beans::XPropertySet>& o_xPropSet,
64 : bool& o_rIsCustomShape,
65 : RTFShape const& rShape, bool bClose, ShapeOrPict const shapeOrPict);
66 :
67 : RTFDocumentImpl& m_rImport;
68 : std::stack< css::uno::Reference<css::drawing::XShapes> > m_aParents;
69 : css::uno::Reference<css::drawing::XShape> m_xShape;
70 : /// If m_xShape is imported as a Writer text frame (instead of a drawinglayer rectangle).
71 : bool m_bTextFrame;
72 : /// If m_xShape is imported as a Writer text graphic object (instead of a drawinglayer shape).
73 : bool m_bTextGraphicObject;
74 : /// if inside \pict, but actually it's a shape (not a picture)
75 : bool m_bFakePict;
76 : writerfilter::dmapper::GraphicZOrderHelper m_aGraphicZOrderHelper;
77 : };
78 : } // namespace rtftok
79 : } // namespace writerfilter
80 :
81 : #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSDRIMPORT_HXX
82 :
83 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|