diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2008-01-17 07:06:10 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2008-01-17 07:06:10 +0000 |
commit | 3381981e76873304b171f7df900561dac681d2af (patch) | |
tree | f496d5a2006e8719b5783d5a8966a05858ed3014 /oox/source/vml | |
parent | 90e7bde2a1f3dd8c81e947578f14f40059961740 (diff) |
#i10000# Bring module to HEAD.
Diffstat (limited to 'oox/source/vml')
-rw-r--r-- | oox/source/vml/makefile.mk | 58 | ||||
-rw-r--r-- | oox/source/vml/vmldrawing.cxx | 101 | ||||
-rw-r--r-- | oox/source/vml/vmldrawingfragmenthandler.cxx | 226 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 72 |
4 files changed, 457 insertions, 0 deletions
diff --git a/oox/source/vml/makefile.mk b/oox/source/vml/makefile.mk new file mode 100644 index 000000000000..c49456af8bbd --- /dev/null +++ b/oox/source/vml/makefile.mk @@ -0,0 +1,58 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.2 $ +# +# last change: $Author: rt $ $Date: 2008-01-17 08:06:07 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=oox +TARGET=vml +AUTOSEG=true + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/vmlshape.obj\ + $(SLO)$/vmldrawing.obj\ + $(SLO)$/vmldrawingfragmenthandler.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx new file mode 100644 index 000000000000..482c8756b417 --- /dev/null +++ b/oox/source/vml/vmldrawing.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vmldrawing.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2008-01-17 08:06:07 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "oox/vml/drawing.hxx" +#include "oox/core/namespaces.hxx" +#include "tokens.hxx" + +using namespace ::oox::core; + +namespace oox { namespace vml { + +Drawing::Drawing() +{ +} +Drawing::~Drawing() +{ +} + +ShapePtr Drawing::createShapeById( const rtl::OUString sId ) const +{ + ShapePtr pRet, pRef; + std::vector< ShapePtr >::const_iterator aIter( maShapes.begin() ); + while( aIter != maShapes.end() ) + { + if ( (*aIter)->msId == sId ) + { + pRef = (*aIter); + break; + } + aIter++; + } + if ( pRef ) + { + pRet = ShapePtr( new Shape() ); + if ( pRef->msType.getLength() ) + { + std::vector< ShapePtr >::const_iterator aShapeTypeIter( maShapeTypes.begin() ); + while( aShapeTypeIter != maShapeTypes.end() ) + { + if ( (*aShapeTypeIter)->msType == pRef->msType ) + { + pRet->applyAttributes( *(*aShapeTypeIter).get() ); + break; + } + aShapeTypeIter++; + } + } + pRet->applyAttributes( *pRef.get() ); + } + return pRet; +} + +rtl::OUString Drawing::getGraphicUrlById( const rtl::OUString sId ) const +{ + rtl::OUString sGraphicURL; + std::vector< ShapePtr >::const_iterator aIter( maShapes.begin() ); + while( aIter != maShapes.end() ) + { + if ( (*aIter)->msId == sId ) + { + sGraphicURL = (*aIter)->msGraphicURL; + break; + } + aIter++; + } + return sGraphicURL; +} + +} } diff --git a/oox/source/vml/vmldrawingfragmenthandler.cxx b/oox/source/vml/vmldrawingfragmenthandler.cxx new file mode 100644 index 000000000000..1fd9a4ecbb50 --- /dev/null +++ b/oox/source/vml/vmldrawingfragmenthandler.cxx @@ -0,0 +1,226 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vmldrawingfragmenthandler.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2008-01-17 08:06:07 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "oox/core/context.hxx" +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "oox/vml/drawingfragmenthandler.hxx" +#include "oox/core/namespaces.hxx" +#include "tokens.hxx" + +using ::rtl::OUString; +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::container; + +namespace oox { namespace vml { + +//-------------------------------------------------------------------------------------------------------------- + +class BasicShapeContext : public oox::core::Context +{ +public: + BasicShapeContext( const FragmentHandlerRef& xHandler, + sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const ShapePtr pShapePtr ); + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, RuntimeException); +private: + ShapePtr mpShapePtr; +}; +BasicShapeContext::BasicShapeContext( const FragmentHandlerRef& xHandler, + sal_Int32 /* aElement */, const Reference< XFastAttributeList >& xAttribs, const ShapePtr pShapePtr ) +: Context( xHandler ) +, mpShapePtr( pShapePtr ) +{ + mpShapePtr->msId = xAttribs->getOptionalValue( XML_id ); + mpShapePtr->msType = xAttribs->getOptionalValue( XML_type ); + rtl::OUString aShapeType( xAttribs->getOptionalValue( NMSP_OFFICE|XML_spt ) ); + if ( aShapeType.getLength() ) + mpShapePtr->mnShapeType = aShapeType.toInt32(); + rtl::OUString aCoordSize( xAttribs->getOptionalValue( XML_coordsize ) ); + if ( aCoordSize.getLength() ) + { + sal_Int32 nIndex = 0; + rtl::OUString aCoordWidth ( aCoordSize.getToken( 0, ',', nIndex ) ); + rtl::OUString aCoordHeight( aCoordSize.getToken( 0, ',', nIndex ) ); + if ( aCoordWidth.getLength() ) + mpShapePtr->mnCoordWidth = aCoordWidth.toInt32(); + if ( aCoordHeight.getLength() ) + mpShapePtr->mnCoordHeight = aCoordHeight.toInt32(); + } + mpShapePtr->msPath = xAttribs->getOptionalValue( XML_path ); + mpShapePtr->mnStroked = xAttribs->getOptionalValueToken( XML_stroked, 0 ); + mpShapePtr->mnFilled = xAttribs->getOptionalValueToken( XML_filled, 0 ); +} +Reference< XFastContextHandler > BasicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) + throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + switch( aElementToken ) + { + case NMSP_VML|XML_imagedata: + { + OUString aRelId( xAttribs->getOptionalValue( NMSP_OFFICE|XML_relid ) ); + mpShapePtr->msGraphicURL = getHandler()->getFragmentPathFromRelId( aRelId ); + mpShapePtr->msImageTitle = xAttribs->getOptionalValue( NMSP_OFFICE|XML_title ); + } + break; + default: + break; + } + if( !xRet.is() ) + xRet.set( this ); + return xRet; +} + +//-------------------------------------------------------------------------------------------------------------- +// CT_Shapetype +class ShapeTypeContext : public BasicShapeContext +{ +public: + ShapeTypeContext( const FragmentHandlerRef& xHandler, + sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const ShapePtr pShapePtr ); + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException); + +}; +ShapeTypeContext::ShapeTypeContext( const FragmentHandlerRef& xHandler, + sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const ShapePtr pShapePtr ) +: BasicShapeContext( xHandler, aElement, xAttribs, pShapePtr ) +{ +} +Reference< XFastContextHandler > ShapeTypeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) + throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; +// switch( aElementToken ) +// { +// default: + xRet = BasicShapeContext::createFastChildContext( aElementToken, xAttribs ); +// break; +// } + if( !xRet.is() ) + xRet.set( this ); + return xRet; +} + +//-------------------------------------------------------------------------------------------------------------- +// CT_Shape +class ShapeContext : public BasicShapeContext +{ +public: + ShapeContext( const FragmentHandlerRef& xHandler, + sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const ShapePtr pShapePtr ); + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException); +}; +ShapeContext::ShapeContext( const FragmentHandlerRef& xHandler, + sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs, const ShapePtr pShapePtr ) +: BasicShapeContext( xHandler, aElement, xAttribs, pShapePtr ) +{ +} +Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) + throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; +// switch( aElementToken ) +// { +// default: + xRet = BasicShapeContext::createFastChildContext( aElementToken, xAttribs ); +// break; +// } + if( !xRet.is() ) + xRet.set( this ); + return xRet; +} + +//-------------------------------------------------------------------------------------------------------------- + +DrawingFragmentHandler::DrawingFragmentHandler( const XmlFilterRef& xFilter, const OUString& rFragmentPath, const DrawingPtr pDrawingPtr ) + throw() +: FragmentHandler( xFilter, rFragmentPath ) +, mpDrawingPtr( pDrawingPtr ) +{ +} +DrawingFragmentHandler::~DrawingFragmentHandler() + throw() +{ +} +Reference< XFastContextHandler > DrawingFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) + throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + switch( aElementToken ) + { + case XML_xml: + break; + case NMSP_OFFICE|XML_shapelayout: + break; + case NMSP_VML|XML_shapetype: + { + ShapePtr pShapePtr( new Shape ); + xRet = new ShapeTypeContext( this, aElementToken, xAttribs, pShapePtr ); + mpDrawingPtr->getShapeTypes().push_back( pShapePtr ); + } + break; + case NMSP_VML|XML_shape: + { + ShapePtr pShapePtr( new Shape ); + xRet = new ShapeContext( this, aElementToken, xAttribs, pShapePtr ); + mpDrawingPtr->getShapes().push_back( pShapePtr ); + } + break; + } + if( !xRet.is() ) + xRet.set( this ); + return xRet; +} + +void SAL_CALL DrawingFragmentHandler::endDocument() + throw (SAXException, RuntimeException) +{ +} + +//-------------------------------------------------------------------------------------------------------------- + + + +} } + diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx new file mode 100644 index 000000000000..25e1f2d73c52 --- /dev/null +++ b/oox/source/vml/vmlshape.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vmlshape.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2008-01-17 08:06:07 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include "oox/vml/shape.hxx" + +namespace oox { namespace vml { + +Shape::Shape() +: mnShapeType( 0 ) +, mnCoordWidth( 0 ) +, mnCoordHeight( 0 ) +, mnStroked( 0 ) +, mnFilled( 0 ) +{ +} +Shape::~Shape() +{ +} + +void Shape::applyAttributes( const vml::Shape& rSource ) +{ + if ( rSource.msId.getLength() ) + msId = rSource.msId; + if ( rSource.msType.getLength() ) + msType = rSource.msType; + if ( rSource.mnShapeType ) + mnShapeType = rSource.mnShapeType; + if ( rSource.mnCoordWidth ) + mnCoordWidth = rSource.mnCoordWidth; + if ( rSource.mnCoordHeight ) + mnCoordHeight = rSource.mnCoordHeight; + if ( rSource.mnStroked ) + mnStroked = rSource.mnStroked; + if ( rSource.mnFilled ) + mnFilled = rSource.mnFilled; + if ( rSource.msPath.getLength() ) + msPath = rSource.msPath; +} + +} } |