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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_OOX_SOURCE_SHAPE_SHAPECONTEXTHANDLER_HXX
20 : #define INCLUDED_OOX_SOURCE_SHAPE_SHAPECONTEXTHANDLER_HXX
21 :
22 : #include <boost/shared_ptr.hpp>
23 : #include <com/sun/star/uno/XComponentContext.hpp>
24 : #include <cppuhelper/implbase2.hxx>
25 : #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp>
26 : #include "oox/drawingml/graphicshapecontext.hxx"
27 : #include "oox/drawingml/shape.hxx"
28 : #include "oox/drawingml/theme.hxx"
29 : #include "oox/core/fragmenthandler2.hxx"
30 : #include "oox/core/xmlfilterbase.hxx"
31 : #include "ShapeFilterBase.hxx"
32 : #include <com/sun/star/lang/XServiceInfo.hpp>
33 :
34 : namespace oox { namespace shape {
35 :
36 0 : class ShapeFragmentHandler : public core::FragmentHandler2
37 : {
38 : public:
39 : typedef boost::shared_ptr<ShapeFragmentHandler> Pointer_t;
40 :
41 0 : explicit ShapeFragmentHandler(core::XmlFilterBase& rFilter,
42 : const OUString& rFragmentPath )
43 0 : : FragmentHandler2(rFilter, rFragmentPath)
44 : {
45 0 : }
46 : };
47 :
48 : class ShapeContextHandler:
49 : public ::cppu::WeakImplHelper2< css::xml::sax::XFastShapeContextHandler,
50 : css::lang::XServiceInfo >
51 : {
52 : public:
53 : explicit ShapeContextHandler
54 : (css::uno::Reference< css::uno::XComponentContext > const & context);
55 :
56 : virtual ~ShapeContextHandler();
57 :
58 : // ::com::sun::star::lang::XServiceInfo:
59 : virtual OUString SAL_CALL getImplementationName()
60 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
61 :
62 : virtual sal_Bool SAL_CALL supportsService
63 : (const OUString & ServiceName) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 :
65 : virtual css::uno::Sequence< OUString > SAL_CALL
66 : getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 :
68 : // ::com::sun::star::xml::sax::XFastContextHandler:
69 : virtual void SAL_CALL startFastElement
70 : (::sal_Int32 Element,
71 : const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
72 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
73 :
74 : virtual void SAL_CALL startUnknownElement
75 : (const OUString & Namespace,
76 : const OUString & Name,
77 : const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
78 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
79 :
80 : virtual void SAL_CALL endFastElement(::sal_Int32 Element)
81 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
82 :
83 : virtual void SAL_CALL endUnknownElement
84 : (const OUString & Namespace,
85 : const OUString & Name)
86 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
87 :
88 : virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
89 : createFastChildContext
90 : (::sal_Int32 Element,
91 : const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
92 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
93 :
94 : virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
95 : createUnknownChildContext
96 : (const OUString & Namespace,
97 : const OUString & Name,
98 : const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
99 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
100 :
101 : virtual void SAL_CALL characters(const OUString & aChars)
102 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
103 :
104 : // ::com::sun::star::xml::sax::XFastShapeContextHandler:
105 : virtual css::uno::Reference< css::drawing::XShape > SAL_CALL getShape()
106 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 :
108 : virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage()
109 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 : virtual void SAL_CALL setDrawPage
112 : (const css::uno::Reference< css::drawing::XDrawPage > & the_value)
113 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 :
115 : virtual css::uno::Reference< css::frame::XModel > SAL_CALL getModel()
116 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 :
118 : virtual void SAL_CALL setModel
119 : (const css::uno::Reference< css::frame::XModel > & the_value)
120 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 :
122 : virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
123 : getInputStream() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 :
125 : virtual void SAL_CALL setInputStream
126 : (const css::uno::Reference< css::io::XInputStream > & the_value)
127 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 :
129 : virtual OUString SAL_CALL getRelationFragmentPath()
130 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : virtual void SAL_CALL setRelationFragmentPath
132 : (const OUString & the_value)
133 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 :
135 : virtual ::sal_Int32 SAL_CALL getStartToken() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 : virtual void SAL_CALL setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 :
138 : virtual css::awt::Point SAL_CALL getPosition() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 : virtual void SAL_CALL setPosition(const css::awt::Point& rPosition) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 :
141 : private:
142 : ShapeContextHandler(ShapeContextHandler &); // not defined
143 : void operator =(ShapeContextHandler &); // not defined
144 :
145 : ::sal_uInt32 mnStartToken;
146 : css::awt::Point maPosition;
147 :
148 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
149 : drawingml::ShapePtr mpShape;
150 : ::boost::shared_ptr< vml::Drawing > mpDrawing;
151 :
152 : typedef boost::shared_ptr<drawingml::GraphicShapeContext>
153 : GraphicShapeContextPtr;
154 : css::uno::Reference<XFastContextHandler> mxDrawingFragmentHandler;
155 : css::uno::Reference<XFastContextHandler> mxGraphicShapeContext;
156 : css::uno::Reference<XFastContextHandler> mxDiagramShapeContext;
157 : css::uno::Reference<XFastContextHandler> mxLockedCanvasContext;
158 : css::uno::Reference<XFastContextHandler> mxWpsContext;
159 : css::uno::Reference<css::drawing::XShape> mxSavedShape;
160 : css::uno::Reference<XFastContextHandler> mxWpgContext;
161 : css::uno::Reference<XFastContextHandler> mxChartShapeContext;
162 :
163 : core::XmlFilterRef mxFilterBase;
164 : drawingml::ThemePtr mpThemePtr;
165 : css::uno::Reference<css::drawing::XDrawPage> mxDrawPage;
166 : css::uno::Reference<css::io::XInputStream> mxInputStream;
167 : OUString msRelationFragmentPath;
168 :
169 : css::uno::Reference<XFastContextHandler> getGraphicShapeContext(::sal_Int32 Element);
170 : css::uno::Reference<XFastContextHandler> getChartShapeContext(::sal_Int32 Element);
171 : css::uno::Reference<XFastContextHandler> getDrawingShapeContext();
172 : css::uno::Reference<XFastContextHandler> getDiagramShapeContext();
173 : css::uno::Reference<XFastContextHandler> getLockedCanvasContext(sal_Int32 nElement);
174 : css::uno::Reference<XFastContextHandler> getWpsContext(sal_Int32 nStartElement, sal_Int32 nElement);
175 : css::uno::Reference<XFastContextHandler> getWpgContext(sal_Int32 nElement);
176 : css::uno::Reference<XFastContextHandler> getContextHandler(sal_Int32 nElement = 0);
177 : };
178 :
179 : }}
180 :
181 : #endif // INCLUDED_OOX_SOURCE_SHAPE_SHAPECONTEXTHANDLER_HXX
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|