1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ShapeContextHandler.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX
31 #define OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX
33 #include <boost/shared_ptr.hpp>
34 #include "sal/config.h"
35 #include "com/sun/star/uno/XComponentContext.hpp"
36 #include "cppuhelper/implbase1.hxx"
37 #include "com/sun/star/xml/sax/XFastShapeContextHandler.hpp"
38 #include "oox/drawingml/graphicshapecontext.hxx"
39 #include "oox/drawingml/shape.hxx"
40 #include "oox/drawingml/theme.hxx"
41 #include "oox/core/fragmenthandler.hxx"
42 #include "oox/core/xmlfilterbase.hxx"
43 #include "ShapeFilterBase.hxx"
45 namespace css
= ::com::sun::star
;
47 namespace oox
{ namespace shape
{
49 // component and service helper functions:
50 ::rtl::OUString SAL_CALL
ShapeContextHandler_getImplementationName();
52 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
53 ShapeContextHandler_getSupportedServiceNames();
55 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
56 ShapeContextHandler_create
57 ( css::uno::Reference
< css::uno::XComponentContext
> const & context
);
59 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
60 ShapeContextHandler_createInstance
61 ( const css::uno::Reference
< css::lang::XMultiServiceFactory
> & rSMgr
)
62 throw( css::uno::Exception
);
64 class ShapeFragmentHandler
: public core::FragmentHandler
67 typedef boost::shared_ptr
<ShapeFragmentHandler
> Pointer_t
;
69 explicit ShapeFragmentHandler(core::XmlFilterBase
& rFilter
,
70 const ::rtl::OUString
& rFragmentPath
)
71 : FragmentHandler(rFilter
, rFragmentPath
)
76 class ShapeContextHandler
:
77 public ::cppu::WeakImplHelper1
<
78 css::xml::sax::XFastShapeContextHandler
>
81 explicit ShapeContextHandler
82 (css::uno::Reference
< css::uno::XComponentContext
> const & context
);
84 virtual ~ShapeContextHandler();
86 // ::com::sun::star::lang::XServiceInfo:
87 virtual ::rtl::OUString SAL_CALL
getImplementationName()
88 throw (css::uno::RuntimeException
);
90 virtual ::sal_Bool SAL_CALL supportsService
91 (const ::rtl::OUString
& ServiceName
) throw (css::uno::RuntimeException
);
93 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
94 getSupportedServiceNames() throw (css::uno::RuntimeException
);
96 // ::com::sun::star::xml::sax::XFastContextHandler:
97 virtual void SAL_CALL startFastElement
99 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
)
100 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
102 virtual void SAL_CALL startUnknownElement
103 (const ::rtl::OUString
& Namespace
,
104 const ::rtl::OUString
& Name
,
105 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
)
106 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
108 virtual void SAL_CALL
endFastElement(::sal_Int32 Element
)
109 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
111 virtual void SAL_CALL endUnknownElement
112 (const ::rtl::OUString
& Namespace
,
113 const ::rtl::OUString
& Name
)
114 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
116 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
117 createFastChildContext
118 (::sal_Int32 Element
,
119 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
)
120 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
122 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
123 createUnknownChildContext
124 (const ::rtl::OUString
& Namespace
,
125 const ::rtl::OUString
& Name
,
126 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
)
127 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
129 virtual void SAL_CALL
characters(const ::rtl::OUString
& aChars
)
130 throw (css::uno::RuntimeException
, css::xml::sax::SAXException
);
132 // ::com::sun::star::xml::sax::XFastShapeContextHandler:
133 virtual css::uno::Reference
< css::drawing::XShape
> SAL_CALL
getShape()
134 throw (css::uno::RuntimeException
);
136 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getDrawPage()
137 throw (css::uno::RuntimeException
);
139 virtual void SAL_CALL setDrawPage
140 (const css::uno::Reference
< css::drawing::XDrawPage
> & the_value
)
141 throw (css::uno::RuntimeException
);
143 virtual css::uno::Reference
< css::frame::XModel
> SAL_CALL
getModel()
144 throw (css::uno::RuntimeException
);
146 virtual void SAL_CALL setModel
147 (const css::uno::Reference
< css::frame::XModel
> & the_value
)
148 throw (css::uno::RuntimeException
);
150 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
151 getInputStream() throw (css::uno::RuntimeException
);
153 virtual void SAL_CALL setInputStream
154 (const css::uno::Reference
< css::io::XInputStream
> & the_value
)
155 throw (css::uno::RuntimeException
);
157 virtual ::rtl::OUString SAL_CALL
getRelationFragmentPath()
158 throw (css::uno::RuntimeException
);
159 virtual void SAL_CALL setRelationFragmentPath
160 (const ::rtl::OUString
& the_value
)
161 throw (css::uno::RuntimeException
);
163 virtual ::sal_Int32 SAL_CALL
getStartToken() throw (::com::sun::star::uno::RuntimeException
);
164 virtual void SAL_CALL
setStartToken( ::sal_Int32 _starttoken
) throw (::com::sun::star::uno::RuntimeException
);
167 ShapeContextHandler(ShapeContextHandler
&); // not defined
168 void operator =(ShapeContextHandler
&); // not defined
170 ::sal_uInt32 mnStartToken
;
172 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
173 drawingml::ShapePtr mpShape
;
174 ::boost::shared_ptr
< vml::Drawing
> mpDrawing
;
176 typedef boost::shared_ptr
<drawingml::GraphicShapeContext
>
177 GraphicShapeContextPtr
;
178 css::uno::Reference
<XFastContextHandler
> mxDrawingFragmentHandler
;
179 css::uno::Reference
<XFastContextHandler
> mxGraphicShapeContext
;
181 core::XmlFilterRef mxFilterBase
;
182 drawingml::ThemePtr mpThemePtr
;
183 css::uno::Reference
<css::drawing::XDrawPage
> mxDrawPage
;
184 css::uno::Reference
<css::io::XInputStream
> mxInputStream
;
185 ::rtl::OUString msRelationFragmentPath
;
187 css::uno::Reference
<XFastContextHandler
> getGraphicShapeContext(::sal_Int32 Element
);
188 css::uno::Reference
<XFastContextHandler
> getDrawingShapeContext();
189 css::uno::Reference
<XFastContextHandler
> getContextHandler();
194 #endif // OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX