diff options
Diffstat (limited to 'oox/source/shape')
-rw-r--r-- | oox/source/shape/FastTokenHandlerService.cxx | 116 | ||||
-rw-r--r-- | oox/source/shape/FastTokenHandlerService.hxx | 81 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 373 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.hxx | 191 | ||||
-rw-r--r-- | oox/source/shape/ShapeFilterBase.cxx | 74 | ||||
-rw-r--r-- | oox/source/shape/ShapeFilterBase.hxx | 78 | ||||
-rw-r--r-- | oox/source/shape/makefile.mk | 50 |
7 files changed, 963 insertions, 0 deletions
diff --git a/oox/source/shape/FastTokenHandlerService.cxx b/oox/source/shape/FastTokenHandlerService.cxx new file mode 100644 index 000000000000..6c6fcfa53d6e --- /dev/null +++ b/oox/source/shape/FastTokenHandlerService.cxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include <com/sun/star/beans/XPropertySet.hpp> +#include "FastTokenHandlerService.hxx" + +namespace oox { +namespace shape { + +using namespace ::com::sun::star; + +FastTokenHandlerService::FastTokenHandlerService(uno::Reference< uno::XComponentContext > const & context) : + m_xContext(context) +{} + +// com.sun.star.uno.XServiceInfo: +::rtl::OUString SAL_CALL FastTokenHandlerService::getImplementationName() throw (uno::RuntimeException) +{ + return FastTokenHandlerService_getImplementationName(); +} + +::sal_Bool SAL_CALL FastTokenHandlerService::supportsService(::rtl::OUString const & serviceName) throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > serviceNames = FastTokenHandlerService_getSupportedServiceNames(); + for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) { + if (serviceNames[i] == serviceName) + return sal_True; + } + return sal_False; +} + +uno::Sequence< ::rtl::OUString > SAL_CALL FastTokenHandlerService::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return FastTokenHandlerService_getSupportedServiceNames(); +} + +::sal_Int32 SAL_CALL FastTokenHandlerService::getToken(const ::rtl::OUString & Identifier) throw (::com::sun::star::uno::RuntimeException) +{ + return mFastTokenHandler.getToken(Identifier); +} + +::rtl::OUString SAL_CALL FastTokenHandlerService::getIdentifier(::sal_Int32 Token) throw (::com::sun::star::uno::RuntimeException) +{ + return mFastTokenHandler.getIdentifier(Token); +} + +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL FastTokenHandlerService::getUTF8Identifier( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException) +{ + return mFastTokenHandler.getUTF8Identifier(Token); +} + +::sal_Int32 SAL_CALL FastTokenHandlerService::getTokenFromUTF8(const ::com::sun::star::uno::Sequence< ::sal_Int8 > & Identifier) throw (::com::sun::star::uno::RuntimeException) +{ + return mFastTokenHandler.getTokenFromUTF8(Identifier); +} + +::rtl::OUString SAL_CALL FastTokenHandlerService_getImplementationName() { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.oox.FastTokenHandlerService")); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL FastTokenHandlerService_getSupportedServiceNames() +{ + uno::Sequence< ::rtl::OUString > s(1); + s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.xml.sax.FastTokenHandler")); + return s; +} + +uno::Reference< uno::XInterface > SAL_CALL FastTokenHandlerService_create( + const uno::Reference< uno::XComponentContext > & context) + SAL_THROW((uno::Exception)) +{ + return static_cast< ::cppu::OWeakObject * >(new FastTokenHandlerService(context)); +} + +uno::Reference< uno::XInterface > SAL_CALL +FastTokenHandlerService_createInstance +( const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + uno::Reference<beans::XPropertySet> + xPropertySet(rSMgr, uno::UNO_QUERY_THROW); + uno::Any aDefaultContext = xPropertySet->getPropertyValue + (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))); + + uno::Reference<uno::XComponentContext> xContext; + aDefaultContext >>= xContext; + + return FastTokenHandlerService_create(xContext); +} + +}} diff --git a/oox/source/shape/FastTokenHandlerService.hxx b/oox/source/shape/FastTokenHandlerService.hxx new file mode 100644 index 000000000000..b822654fdcfb --- /dev/null +++ b/oox/source/shape/FastTokenHandlerService.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_SHAPE_FASTTOKENHANDLERSERVICE_HXX +#define OOX_SHAPE_FASTTOKENHANDLERSERVICE_HXX + +#include <sal/config.h> +#include <cppuhelper/factory.hxx> +#include <cppuhelper/implementationentry.hxx> +#include <cppuhelper/implbase2.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "oox/core/fasttokenhandler.hxx" + +namespace css = ::com::sun::star; + +namespace oox { +namespace shape { + +class FastTokenHandlerService: + public ::cppu::WeakImplHelper2< + css::lang::XServiceInfo, + css::xml::sax::XFastTokenHandler> +{ +public: + explicit FastTokenHandlerService(css::uno::Reference< css::uno::XComponentContext > const & context); + + // ::com::sun::star::lang::XServiceInfo: + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException); + + // ::com::sun::star::xml::sax::XFastTokenHandler: + virtual ::sal_Int32 SAL_CALL getToken(const ::rtl::OUString & Identifier) throw (css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifier(::sal_Int32 Token) throw (css::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getTokenFromUTF8(const css::uno::Sequence< ::sal_Int8 > & Identifier) throw (css::uno::RuntimeException); + +private: + FastTokenHandlerService(FastTokenHandlerService &); // not defined + void operator =(FastTokenHandlerService &); // not defined + + virtual ~FastTokenHandlerService() {} + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + ::oox::core::FastTokenHandler mFastTokenHandler; +}; + +::rtl::OUString SAL_CALL FastTokenHandlerService_getImplementationName(); + +css::uno::Sequence< ::rtl::OUString > SAL_CALL FastTokenHandlerService_getSupportedServiceNames(); + +css::uno::Reference< css::uno::XInterface > SAL_CALL _FastTokenHandlerService_create( + const css::uno::Reference< css::uno::XComponentContext > & context) + SAL_THROW((css::uno::Exception)); + +}} +#endif // OOX_SHAPE_FAST_TOKEN_HANDLER_SERVICE_HXX diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx new file mode 100644 index 000000000000..e253d43e56e7 --- /dev/null +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -0,0 +1,373 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ShapeContextHandler.hxx" +#include "oox/vml/vmldrawingfragment.hxx" +#include "oox/vml/vmlshape.hxx" +#include "oox/vml/vmlshapecontainer.hxx" +#include "tokens.hxx" + +namespace oox { namespace shape { + +using namespace ::com::sun::star; +using namespace core; +using namespace drawingml; + +ShapeContextHandler::ShapeContextHandler +(uno::Reference< uno::XComponentContext > const & context) : +mnStartToken(0), m_xContext(context) +{ + try + { + uno::Reference<lang::XMultiServiceFactory> + xFactory(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); + mxFilterBase.set( new ShapeFilterBase(xFactory) ); + } + catch( uno::Exception& ) + { + } +} + +ShapeContextHandler::~ShapeContextHandler() +{ +} + +uno::Reference<xml::sax::XFastContextHandler> +ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element ) +{ + if (! mxGraphicShapeContext.is()) + { + FragmentHandlerRef rFragmentHandler + (new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath)); + ShapePtr pMasterShape; + + switch (Element & 0xffff) + { + case XML_graphic: + mpShape.reset(new Shape("com.sun.star.drawing.OLE2Shape" )); + mxGraphicShapeContext.set + (new GraphicalObjectFrameContext(*rFragmentHandler, pMasterShape, mpShape, true)); + break; + case XML_pic: + mpShape.reset(new Shape("com.sun.star.drawing.GraphicObjectShape" )); + mxGraphicShapeContext.set + (new GraphicShapeContext(*rFragmentHandler, pMasterShape, mpShape)); + break; + default: + break; + } + } + + return mxGraphicShapeContext; +} + +uno::Reference<xml::sax::XFastContextHandler> +ShapeContextHandler::getDrawingShapeContext() +{ + if (!mxDrawingFragmentHandler.is()) + { + mpDrawing.reset( new oox::vml::Drawing( *mxFilterBase, mxDrawPage, oox::vml::VMLDRAWING_WORD ) ); + mxDrawingFragmentHandler.set + (dynamic_cast<ContextHandler *> + (new oox::vml::DrawingFragment + ( *mxFilterBase, msRelationFragmentPath, *mpDrawing ))); + } + + return mxDrawingFragmentHandler; +} + +uno::Reference<xml::sax::XFastContextHandler> +ShapeContextHandler::getContextHandler() +{ + uno::Reference<xml::sax::XFastContextHandler> xResult; + + switch (mnStartToken & NMSP_MASK) + { + case NMSP_DOC: + case NMSP_VML: + xResult.set(getDrawingShapeContext()); + break; + default: + xResult.set(getGraphicShapeContext(mnStartToken)); + break; + } + + return xResult; +} + +// ::com::sun::star::xml::sax::XFastContextHandler: +void SAL_CALL ShapeContextHandler::startFastElement +(::sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList > & Attribs) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + static const ::rtl::OUString sInputStream + (RTL_CONSTASCII_USTRINGPARAM ("InputStream")); + + uno::Sequence<beans::PropertyValue> aSeq(1); + aSeq[0].Name = sInputStream; + aSeq[0].Value <<= mxInputStream; + mxFilterBase->filter(aSeq); + + mpThemePtr.reset(new Theme()); + + uno::Reference<XFastContextHandler> xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + xContextHandler->startFastElement(Element, Attribs); +} + +void SAL_CALL ShapeContextHandler::startUnknownElement +(const ::rtl::OUString & Namespace, const ::rtl::OUString & Name, + const uno::Reference< xml::sax::XFastAttributeList > & Attribs) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + uno::Reference<XFastContextHandler> xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + xContextHandler->startUnknownElement(Namespace, Name, Attribs); +} + +void SAL_CALL ShapeContextHandler::endFastElement(::sal_Int32 Element) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + uno::Reference<XFastContextHandler> xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + xContextHandler->endFastElement(Element); +} + +void SAL_CALL ShapeContextHandler::endUnknownElement +(const ::rtl::OUString & Namespace, + const ::rtl::OUString & Name) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + uno::Reference<XFastContextHandler> xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + xContextHandler->endUnknownElement(Namespace, Name); +} + +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL +ShapeContextHandler::createFastChildContext +(::sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList > & Attribs) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + uno::Reference< xml::sax::XFastContextHandler > xResult; + uno::Reference< xml::sax::XFastContextHandler > xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + xResult.set(xContextHandler->createFastChildContext + (Element, Attribs)); + + return xResult; +} + +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL +ShapeContextHandler::createUnknownChildContext +(const ::rtl::OUString & Namespace, + const ::rtl::OUString & Name, + const uno::Reference< xml::sax::XFastAttributeList > & Attribs) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + uno::Reference<XFastContextHandler> xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + return xContextHandler->createUnknownChildContext + (Namespace, Name, Attribs); + + return uno::Reference< xml::sax::XFastContextHandler >(); +} + +void SAL_CALL ShapeContextHandler::characters(const ::rtl::OUString & aChars) + throw (uno::RuntimeException, xml::sax::SAXException) +{ + uno::Reference<XFastContextHandler> xContextHandler(getContextHandler()); + + if (xContextHandler.is()) + xContextHandler->characters(aChars); +} + +// ::com::sun::star::xml::sax::XFastShapeContextHandler: +uno::Reference< drawing::XShape > SAL_CALL +ShapeContextHandler::getShape() throw (uno::RuntimeException) +{ + uno::Reference< drawing::XShape > xResult; + uno::Reference< drawing::XShapes > xShapes( mxDrawPage, uno::UNO_QUERY ); + + if (mxFilterBase.is() && xShapes.is()) + { + if (mpDrawing.get() != NULL) + { + mpDrawing->finalizeFragmentImport(); + if( const ::oox::vml::ShapeBase* pShape = mpDrawing->getShapes().getFirstShape() ) + xResult = pShape->convertAndInsert( xShapes ); + } + else if (mpShape.get() != NULL) + { + mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes); + xResult.set(mpShape->getXShape()); + mxGraphicShapeContext.clear( ); + } + } + + return xResult; +} + +css::uno::Reference< css::drawing::XDrawPage > SAL_CALL +ShapeContextHandler::getDrawPage() throw (css::uno::RuntimeException) +{ + return mxDrawPage; +} + +void SAL_CALL ShapeContextHandler::setDrawPage +(const css::uno::Reference< css::drawing::XDrawPage > & the_value) + throw (css::uno::RuntimeException) +{ + mxDrawPage = the_value; +} + +css::uno::Reference< css::frame::XModel > SAL_CALL +ShapeContextHandler::getModel() throw (css::uno::RuntimeException) +{ + if( !mxFilterBase.is() ) + throw uno::RuntimeException(); + return mxFilterBase->getModel(); +} + +void SAL_CALL ShapeContextHandler::setModel +(const css::uno::Reference< css::frame::XModel > & the_value) + throw (css::uno::RuntimeException) +{ + if( !mxFilterBase.is() ) + throw uno::RuntimeException(); + uno::Reference<lang::XComponent> xComp(the_value, uno::UNO_QUERY_THROW); + mxFilterBase->setTargetDocument(xComp); +} + +uno::Reference< io::XInputStream > SAL_CALL +ShapeContextHandler::getInputStream() throw (uno::RuntimeException) +{ + return mxInputStream; +} + +void SAL_CALL ShapeContextHandler::setInputStream +(const uno::Reference< io::XInputStream > & the_value) + throw (uno::RuntimeException) +{ + mxInputStream = the_value; +} + +::rtl::OUString SAL_CALL ShapeContextHandler::getRelationFragmentPath() + throw (uno::RuntimeException) +{ + return msRelationFragmentPath; +} + +void SAL_CALL ShapeContextHandler::setRelationFragmentPath +(const ::rtl::OUString & the_value) + throw (uno::RuntimeException) +{ + msRelationFragmentPath = the_value; +} + +::sal_Int32 SAL_CALL ShapeContextHandler::getStartToken() throw (::com::sun::star::uno::RuntimeException) +{ + return mnStartToken; +} + +void SAL_CALL ShapeContextHandler::setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException) +{ + mnStartToken = _starttoken; + + +} + +::rtl::OUString ShapeContextHandler::getImplementationName() + throw (css::uno::RuntimeException) +{ + return ShapeContextHandler_getImplementationName(); +} + +uno::Sequence< ::rtl::OUString > ShapeContextHandler::getSupportedServiceNames() + throw (css::uno::RuntimeException) +{ + return ShapeContextHandler_getSupportedServiceNames(); +} + +::rtl::OUString SAL_CALL ShapeContextHandler_getImplementationName() { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.oox.ShapeContextHandler")); +} + +::sal_Bool SAL_CALL ShapeContextHandler::supportsService +(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aSeq = getSupportedServiceNames(); + + if (aSeq[0].equals(ServiceName)) + return sal_True; + + return sal_False; +} + +uno::Sequence< ::rtl::OUString > SAL_CALL +ShapeContextHandler_getSupportedServiceNames() +{ + uno::Sequence< ::rtl::OUString > s(1); + s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.xml.sax.FastShapeContextHandler")); + return s; +} + +uno::Reference< uno::XInterface > SAL_CALL +ShapeContextHandler_create( + const uno::Reference< uno::XComponentContext > & context) + SAL_THROW((uno::Exception)) +{ + return static_cast< ::cppu::OWeakObject * > + (new ShapeContextHandler(context)); +} + +uno::Reference< uno::XInterface > SAL_CALL +ShapeContextHandler_createInstance +( const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + uno::Reference<beans::XPropertySet> + xPropertySet(rSMgr, uno::UNO_QUERY_THROW); + uno::Any aDefaultContext = xPropertySet->getPropertyValue + (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))); + + uno::Reference<uno::XComponentContext> xContext; + aDefaultContext >>= xContext; + + return ShapeContextHandler_create(xContext); +} + +}} diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx new file mode 100644 index 000000000000..c9cf67283c37 --- /dev/null +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -0,0 +1,191 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX +#define OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX + +#include <boost/shared_ptr.hpp> +#include "sal/config.h" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "cppuhelper/implbase1.hxx" +#include "com/sun/star/xml/sax/XFastShapeContextHandler.hpp" +#include "oox/drawingml/graphicshapecontext.hxx" +#include "oox/drawingml/shape.hxx" +#include "oox/drawingml/theme.hxx" +#include "oox/core/fragmenthandler.hxx" +#include "oox/core/xmlfilterbase.hxx" +#include "ShapeFilterBase.hxx" + +namespace css = ::com::sun::star; + +namespace oox { namespace shape { + +// component and service helper functions: +::rtl::OUString SAL_CALL ShapeContextHandler_getImplementationName(); + +css::uno::Sequence< ::rtl::OUString > SAL_CALL +ShapeContextHandler_getSupportedServiceNames(); + +css::uno::Reference< css::uno::XInterface > SAL_CALL +ShapeContextHandler_create +( css::uno::Reference< css::uno::XComponentContext > const & context ); + +css::uno::Reference< css::uno::XInterface > SAL_CALL +ShapeContextHandler_createInstance +( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr) +throw( css::uno::Exception ); + +class ShapeFragmentHandler : public core::FragmentHandler +{ +public: + typedef boost::shared_ptr<ShapeFragmentHandler> Pointer_t; + + explicit ShapeFragmentHandler(core::XmlFilterBase& rFilter, + const ::rtl::OUString& rFragmentPath ) + : FragmentHandler(rFilter, rFragmentPath) + { + } +}; + +class ShapeContextHandler: + public ::cppu::WeakImplHelper1< + css::xml::sax::XFastShapeContextHandler> +{ +public: + explicit ShapeContextHandler + (css::uno::Reference< css::uno::XComponentContext > const & context); + + virtual ~ShapeContextHandler(); + + // ::com::sun::star::lang::XServiceInfo: + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException); + + virtual ::sal_Bool SAL_CALL supportsService + (const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException); + + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException); + + // ::com::sun::star::xml::sax::XFastContextHandler: + virtual void SAL_CALL startFastElement + (::sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + virtual void SAL_CALL startUnknownElement + (const ::rtl::OUString & Namespace, + const ::rtl::OUString & Name, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + virtual void SAL_CALL endFastElement(::sal_Int32 Element) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + virtual void SAL_CALL endUnknownElement + (const ::rtl::OUString & Namespace, + const ::rtl::OUString & Name) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext + (::sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createUnknownChildContext + (const ::rtl::OUString & Namespace, + const ::rtl::OUString & Name, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + virtual void SAL_CALL characters(const ::rtl::OUString & aChars) + throw (css::uno::RuntimeException, css::xml::sax::SAXException); + + // ::com::sun::star::xml::sax::XFastShapeContextHandler: + virtual css::uno::Reference< css::drawing::XShape > SAL_CALL getShape() + throw (css::uno::RuntimeException); + + virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage() + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setDrawPage + (const css::uno::Reference< css::drawing::XDrawPage > & the_value) + throw (css::uno::RuntimeException); + + virtual css::uno::Reference< css::frame::XModel > SAL_CALL getModel() + throw (css::uno::RuntimeException); + + virtual void SAL_CALL setModel + (const css::uno::Reference< css::frame::XModel > & the_value) + throw (css::uno::RuntimeException); + + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL + getInputStream() throw (css::uno::RuntimeException); + + virtual void SAL_CALL setInputStream + (const css::uno::Reference< css::io::XInputStream > & the_value) + throw (css::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getRelationFragmentPath() + throw (css::uno::RuntimeException); + virtual void SAL_CALL setRelationFragmentPath + (const ::rtl::OUString & the_value) + throw (css::uno::RuntimeException); + + virtual ::sal_Int32 SAL_CALL getStartToken() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStartToken( ::sal_Int32 _starttoken ) throw (::com::sun::star::uno::RuntimeException); + +private: + ShapeContextHandler(ShapeContextHandler &); // not defined + void operator =(ShapeContextHandler &); // not defined + + ::sal_uInt32 mnStartToken; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + drawingml::ShapePtr mpShape; + ::boost::shared_ptr< vml::Drawing > mpDrawing; + + typedef boost::shared_ptr<drawingml::GraphicShapeContext> + GraphicShapeContextPtr; + css::uno::Reference<XFastContextHandler> mxDrawingFragmentHandler; + css::uno::Reference<XFastContextHandler> mxGraphicShapeContext; + + core::XmlFilterRef mxFilterBase; + drawingml::ThemePtr mpThemePtr; + css::uno::Reference<css::drawing::XDrawPage> mxDrawPage; + css::uno::Reference<css::io::XInputStream> mxInputStream; + ::rtl::OUString msRelationFragmentPath; + + css::uno::Reference<XFastContextHandler> getGraphicShapeContext(::sal_Int32 Element); + css::uno::Reference<XFastContextHandler> getDrawingShapeContext(); + css::uno::Reference<XFastContextHandler> getContextHandler(); +}; + +}} + +#endif // OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX diff --git a/oox/source/shape/ShapeFilterBase.cxx b/oox/source/shape/ShapeFilterBase.cxx new file mode 100644 index 000000000000..7ed001ffc96c --- /dev/null +++ b/oox/source/shape/ShapeFilterBase.cxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ShapeFilterBase.hxx" +#include "oox/drawingml/chart/chartconverter.hxx" + +namespace oox { +namespace shape { + +using namespace ::com::sun::star; + +ShapeFilterBase::ShapeFilterBase +(const uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& + rxFactory) +: XmlFilterBase(rxFactory) +, mxChartConv( new ::oox::drawingml::chart::ChartConverter ) +{ +} + +ShapeFilterBase::~ShapeFilterBase() +{ +} + +const ::oox::drawingml::Theme* ShapeFilterBase::getCurrentTheme() const +{ + return 0; +} + +::oox::vml::Drawing* ShapeFilterBase::getVmlDrawing() +{ + return 0; +} + +const ::oox::drawingml::table::TableStyleListPtr ShapeFilterBase::getTableStyles() +{ + return ::oox::drawingml::table::TableStyleListPtr(); +} + +::oox::drawingml::chart::ChartConverter& ShapeFilterBase::getChartConverter() +{ + return *mxChartConv; +} + +::rtl::OUString ShapeFilterBase::implGetImplementationName() const +{ + return ::rtl::OUString(); +} + +} +} diff --git a/oox/source/shape/ShapeFilterBase.hxx b/oox/source/shape/ShapeFilterBase.hxx new file mode 100644 index 000000000000..09cbc75e01aa --- /dev/null +++ b/oox/source/shape/ShapeFilterBase.hxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_SHAPE_SHAPEFILTERBASE_HXX +#define OOX_SHAPE_SHAPEFILTERBASE_HXX + +#include <boost/shared_ptr.hpp> +#include <rtl/ref.hxx> +#include "oox/vml/vmldrawing.hxx" +#include "oox/drawingml/table/tablestylelist.hxx" +#include "oox/core/xmlfilterbase.hxx" + +namespace oox { +namespace shape { + +// ============================================================================ + +class ShapeFilterBase : public core::XmlFilterBase +{ +public: + typedef boost::shared_ptr<ShapeFilterBase> Pointer_t; + + explicit ShapeFilterBase( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); + + virtual ~ShapeFilterBase(); + + /** Has to be implemented by each filter, returns the current theme. */ + virtual const ::oox::drawingml::Theme* getCurrentTheme() const; + + /** Has to be implemented by each filter to return the collection of VML shapes. */ + virtual ::oox::vml::Drawing* getVmlDrawing(); + + /** Has to be implemented by each filter to return TableStyles. */ + virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles(); + + virtual ::oox::drawingml::chart::ChartConverter& getChartConverter(); + + virtual rtl::OUString implGetImplementationName() const; + + virtual bool importDocument() { return true; } + virtual bool exportDocument() { return true; } + +private: + ::boost::shared_ptr< ::oox::drawingml::chart::ChartConverter > mxChartConv; +}; + +// ============================================================================ + +} // namespace shape +} // namespace oox + +#endif + diff --git a/oox/source/shape/makefile.mk b/oox/source/shape/makefile.mk new file mode 100644 index 000000000000..f5a3af5542c0 --- /dev/null +++ b/oox/source/shape/makefile.mk @@ -0,0 +1,50 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=oox +TARGET=shape +AUTOSEG=true + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/ShapeContextHandler.obj \ + $(SLO)$/ShapeFilterBase.obj \ + $(SLO)$/FastTokenHandlerService.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk |