1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX 28 #define OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX 29 30 #include <boost/shared_ptr.hpp> 31 #include <com/sun/star/uno/XComponentContext.hpp> 32 #include <cppuhelper/implbase1.hxx> 33 #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp> 34 #include "oox/drawingml/graphicshapecontext.hxx" 35 #include "oox/drawingml/shape.hxx" 36 #include "oox/drawingml/theme.hxx" 37 #include "oox/core/fragmenthandler.hxx" 38 #include "oox/core/xmlfilterbase.hxx" 39 #include "ShapeFilterBase.hxx" 40 41 namespace css = ::com::sun::star; 42 43 namespace oox { namespace shape { 44 45 class ShapeFragmentHandler : public core::FragmentHandler 46 { 47 public: 48 typedef boost::shared_ptr<ShapeFragmentHandler> Pointer_t; 49 50 explicit ShapeFragmentHandler(core::XmlFilterBase& rFilter, 51 const ::rtl::OUString& rFragmentPath ) 52 : FragmentHandler(rFilter, rFragmentPath) 53 { 54 } 55 }; 56 57 class ShapeContextHandler: 58 public ::cppu::WeakImplHelper1< 59 css::xml::sax::XFastShapeContextHandler> 60 { 61 public: 62 explicit ShapeContextHandler 63 (css::uno::Reference< css::uno::XComponentContext > const & context); 64 65 virtual ~ShapeContextHandler(); 66 67 // ::com::sun::star::lang::XServiceInfo: 68 virtual ::rtl::OUString SAL_CALL getImplementationName() 69 throw (css::uno::RuntimeException); 70 71 virtual ::sal_Bool SAL_CALL supportsService 72 (const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException); 73 74 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL 75 getSupportedServiceNames() throw (css::uno::RuntimeException); 76 77 // ::com::sun::star::xml::sax::XFastContextHandler: 78 virtual void SAL_CALL startFastElement 79 (::sal_Int32 Element, 80 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) 81 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 82 83 virtual void SAL_CALL startUnknownElement 84 (const ::rtl::OUString & Namespace, 85 const ::rtl::OUString & Name, 86 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) 87 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 88 89 virtual void SAL_CALL endFastElement(::sal_Int32 Element) 90 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 91 92 virtual void SAL_CALL endUnknownElement 93 (const ::rtl::OUString & Namespace, 94 const ::rtl::OUString & Name) 95 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 96 97 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL 98 createFastChildContext 99 (::sal_Int32 Element, 100 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) 101 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 102 103 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL 104 createUnknownChildContext 105 (const ::rtl::OUString & Namespace, 106 const ::rtl::OUString & Name, 107 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) 108 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 109 110 virtual void SAL_CALL characters(const ::rtl::OUString & aChars) 111 throw (css::uno::RuntimeException, css::xml::sax::SAXException); 112 113 // ::com::sun::star::xml::sax::XFastShapeContextHandler: 114 virtual css::uno::Reference< css::drawing::XShape > SAL_CALL getShape() 115 throw (css::uno::RuntimeException); 116 117 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage() 118 throw (css::uno::RuntimeException); 119 120 virtual void SAL_CALL setDrawPage 121 (const css::uno::Reference< css::drawing::XDrawPage > & the_value) 122 throw (css::uno::RuntimeException); 123 124 virtual css::uno::Reference< css::frame::XModel > SAL_CALL getModel() 125 throw (css::uno::RuntimeException); 126 127 virtual void SAL_CALL setModel 128 (const css::uno::Reference< css::frame::XModel > & the_value) 129 throw (css::uno::RuntimeException); 130 131 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL 132 getInputStream() throw (css::uno::RuntimeException); 133 134 virtual void SAL_CALL setInputStream 135 (const css::uno::Reference< css::io::XInputStream > & the_value) 136 throw (css::uno::RuntimeException); 137 138 virtual ::rtl::OUString SAL_CALL getRelationFragmentPath() 139 throw (css::uno::RuntimeException); 140 virtual void SAL_CALL setRelationFragmentPath 141 (const ::rtl::OUString & the_value) 142 throw (css::uno::RuntimeException); 143 144 virtual ::sal_Int32 SAL_CALL getStartToken() throw (::com::sun::star::uno::RuntimeException); 145 virtual void SAL_CALL setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException); 146 147 private: 148 ShapeContextHandler(ShapeContextHandler &); // not defined 149 void operator =(ShapeContextHandler &); // not defined 150 151 ::sal_uInt32 mnStartToken; 152 153 css::uno::Reference< css::uno::XComponentContext > m_xContext; 154 drawingml::ShapePtr mpShape; 155 ::boost::shared_ptr< vml::Drawing > mpDrawing; 156 157 typedef boost::shared_ptr<drawingml::GraphicShapeContext> 158 GraphicShapeContextPtr; 159 css::uno::Reference<XFastContextHandler> mxDrawingFragmentHandler; 160 css::uno::Reference<XFastContextHandler> mxGraphicShapeContext; 161 162 core::XmlFilterRef mxFilterBase; 163 drawingml::ThemePtr mpThemePtr; 164 css::uno::Reference<css::drawing::XDrawPage> mxDrawPage; 165 css::uno::Reference<css::io::XInputStream> mxInputStream; 166 ::rtl::OUString msRelationFragmentPath; 167 168 css::uno::Reference<XFastContextHandler> getGraphicShapeContext(::sal_Int32 Element); 169 css::uno::Reference<XFastContextHandler> getDrawingShapeContext(); 170 css::uno::Reference<XFastContextHandler> getContextHandler(); 171 }; 172 173 }} 174 175 #endif // OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX 176