summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/diagram
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source/drawingml/diagram')
-rw-r--r--oox/source/drawingml/diagram/datamodelcontext.cxx337
-rw-r--r--oox/source/drawingml/diagram/diagram.cxx299
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.cxx117
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.hxx51
-rw-r--r--oox/source/drawingml/diagram/diagramfragmenthandler.cxx224
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx141
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx357
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.hxx52
-rw-r--r--oox/source/drawingml/diagram/makefile.mk53
9 files changed, 1631 insertions, 0 deletions
diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx
new file mode 100644
index 000000000000..901b9267df36
--- /dev/null
+++ b/oox/source/drawingml/diagram/datamodelcontext.cxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * 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 "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/shapepropertiescontext.hxx"
+#include "oox/drawingml/textbodycontext.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+
+
+// CL_Cxn
+class CxnContext
+ : public ContextHandler
+{
+public:
+ CxnContext( ContextHandler& rParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ const dgm::ConnectionPtr & pConnection )
+ : ContextHandler( rParent )
+ , mpConnection( pConnection )
+ {
+ sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, XML_parOf );
+ pConnection->mnType = nType;
+ pConnection->msModelId = xAttribs->getOptionalValue( XML_modelId );
+ pConnection->msSourceId = xAttribs->getOptionalValue( XML_srcId );
+ pConnection->msDestId = xAttribs->getOptionalValue( XML_destId );
+ pConnection->msPresId = xAttribs->getOptionalValue( XML_presId );
+ pConnection->msSibTransId = xAttribs->getOptionalValue( XML_sibTransId );
+ AttributeList attribs( xAttribs );
+ pConnection->mnSourceOrder = attribs.getInteger( XML_srcOrd, 0 );
+ pConnection->mnDestOrder = attribs.getInteger( XML_destOrd, 0 );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& /*xAttribs*/ )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_extLst:
+ return xRet;
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+private:
+ dgm::ConnectionPtr mpConnection;
+};
+
+
+// CT_CxnList
+class CxnListContext
+ : public ContextHandler
+{
+public:
+ CxnListContext( ContextHandler& rParent, dgm::Connections & aConnections )
+ : ContextHandler( rParent )
+ , maConnections( aConnections )
+ {
+ }
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_cxn:
+ {
+ dgm::ConnectionPtr pConnection( new dgm::Connection() );
+ maConnections.push_back( pConnection );
+ xRet.set( new CxnContext( *this, xAttribs, pConnection ) );
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+private:
+ dgm::Connections & maConnections;
+};
+
+
+
+// CL_Pt
+class PtContext
+ : public ContextHandler
+{
+public:
+ PtContext( ContextHandler& rParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ const dgm::PointPtr & pPoint)
+ : ContextHandler( rParent )
+ , mpPoint( pPoint )
+ {
+ mpPoint->setModelId( xAttribs->getOptionalValue( XML_modelId ) );
+ //
+ // the default type is XML_node
+ sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, XML_node );
+ mpPoint->setType( nType );
+
+ // ignore the cxnId unless it is this type. See 5.15.3.1.3 in Primer
+ if( ( nType == XML_parTrans ) || ( nType == XML_sibTrans ) )
+ {
+ mpPoint->setCnxId( xAttribs->getOptionalValue( XML_cxnId ) );
+ }
+ }
+
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& /*xAttribs*/ )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_extLst:
+ return xRet;
+ case NMSP_DIAGRAM|XML_prSet:
+ // TODO
+ // CT_ElemPropSet
+ break;
+ case NMSP_DIAGRAM|XML_spPr:
+ OSL_TRACE( "shape props for point");
+ xRet = new ShapePropertiesContext( *this, *mpPoint->getShape() );
+ break;
+ case NMSP_DIAGRAM|XML_t:
+ {
+ OSL_TRACE( "shape text body for point");
+ TextBodyPtr xTextBody( new TextBody );
+ mpPoint->getShape()->setTextBody( xTextBody );
+ xRet = new TextBodyContext( *this, *xTextBody );
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+private:
+ dgm::PointPtr mpPoint;
+};
+
+
+
+// CT_PtList
+class PtListContext
+ : public ContextHandler
+{
+public:
+ PtListContext( ContextHandler& rParent, dgm::Points & aPoints)
+ : ContextHandler( rParent )
+ , maPoints( aPoints )
+ {
+ }
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_pt:
+ {
+ // CT_Pt
+ dgm::PointPtr pPoint( new dgm::Point() );
+ maPoints.push_back( pPoint );
+ xRet.set( new PtContext( *this, xAttribs, pPoint ) );
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+private:
+ dgm::Points & maPoints;
+};
+
+// CT_BackgroundFormatting
+class BackgroundFormattingContext
+ : public ContextHandler
+{
+public:
+ BackgroundFormattingContext( ContextHandler& rParent, DiagramDataPtr & pModel )
+ : ContextHandler( rParent )
+ , mpDataModel( pModel )
+ {
+ OSL_ENSURE( pModel, "the data model MUST NOT be NULL" );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_blipFill:
+ case NMSP_DRAWINGML|XML_gradFill:
+ case NMSP_DRAWINGML|XML_grpFill:
+ case NMSP_DRAWINGML|XML_noFill:
+ case NMSP_DRAWINGML|XML_pattFill:
+ case NMSP_DRAWINGML|XML_solidFill:
+ // EG_FillProperties
+ xRet.set( FillPropertiesContext::createFillContext(
+ *this, aElementToken, xAttribs, *mpDataModel->getFillProperties() ) );
+ break;
+ case NMSP_DRAWINGML|XML_effectDag:
+ case NMSP_DRAWINGML|XML_effectLst:
+ // TODO
+ // EG_EffectProperties
+ break;
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+private:
+ DiagramDataPtr mpDataModel;
+};
+
+
+
+DataModelContext::DataModelContext( ContextHandler& rParent,
+ const DiagramDataPtr & pDataModel )
+ : ContextHandler( rParent )
+ , mpDataModel( pDataModel )
+{
+ OSL_ENSURE( pDataModel, "Data Model must not be NULL" );
+}
+
+
+DataModelContext::~DataModelContext()
+{
+ // some debug
+ mpDataModel->dump();
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DataModelContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& /*xAttribs*/ )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_cxnLst:
+ // CT_CxnList
+ xRet.set( new CxnListContext( *this, mpDataModel->getConnections() ) );
+ break;
+ case NMSP_DIAGRAM|XML_ptLst:
+ // CT_PtList
+ xRet.set( new PtListContext( *this, mpDataModel->getPoints() ) );
+ break;
+ case NMSP_DIAGRAM|XML_bg:
+ // CT_BackgroundFormatting
+ xRet.set( new BackgroundFormattingContext( *this, mpDataModel ) );
+ break;
+ case NMSP_DIAGRAM|XML_whole:
+ // CT_WholeE2oFormatting
+ // TODO
+ return xRet;
+ case NMSP_DIAGRAM|XML_extLst:
+ return xRet;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
new file mode 100644
index 000000000000..516d6bfb231c
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -0,0 +1,299 @@
+/*************************************************************************
+ *
+ * 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 <functional>
+#include <boost/bind.hpp>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include "oox/drawingml/diagram/diagram.hxx"
+#include "oox/drawingml/fillproperties.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace ::com::sun::star;
+
+namespace oox { namespace drawingml {
+
+namespace dgm {
+
+
+void Connection::dump()
+{
+ OSL_TRACE("dgm: cnx modelId %s, srcId %s, dstId %s",
+ OUSTRING_TO_CSTR( msModelId ),
+ OUSTRING_TO_CSTR( msSourceId ),
+ OUSTRING_TO_CSTR( msDestId ) );
+}
+
+Point::Point()
+ : mpShape( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) )
+ , mnType( 0 )
+{
+}
+
+void Point::dump()
+{
+ OSL_TRACE( "dgm: pt cnxId %s, modelId %s",
+ OUSTRING_TO_CSTR( msCnxId ),
+ OUSTRING_TO_CSTR( msModelId ) );
+}
+
+void Point::setModelId( const ::rtl::OUString & sModelId )
+{
+ msModelId = sModelId;
+ mpShape->setName( msModelId );
+}
+
+
+bool PointsTree::addChild( const PointsTreePtr & pChild )
+{
+ bool added = false;
+
+ OSL_ENSURE( pChild->mpParent.expired(), "can't add, has already a parent" );
+ OSL_ENSURE( mpNode, "has no node" );
+ if( mpNode && pChild->mpParent.expired() )
+ {
+ pChild->mpParent = shared_from_this();
+ maChildrens.push_back( pChild );
+ added = true;
+ }
+
+ return added;
+}
+
+PointsTreePtr PointsTree::getParent() const
+{
+ if( !mpParent.expired() )
+ {
+ return mpParent.lock() ;
+ }
+ return PointsTreePtr();
+}
+
+
+} // dgm namespace
+
+DiagramData::DiagramData()
+ : mpFillProperties( new FillProperties )
+{
+}
+
+void DiagramData::dump()
+{
+ OSL_TRACE("Dgm: DiagramData # of cnx: %d", maConnections.size() );
+ std::for_each( maConnections.begin(), maConnections.end(),
+ boost::bind( &dgm::Connection::dump, _1 ) );
+ OSL_TRACE("Dgm: DiagramData # of pt: %d", maPoints.size() );
+ std::for_each( maPoints.begin(), maPoints.end(),
+ boost::bind( &dgm::Point::dump, _1 ) );
+}
+
+static void setPosition( const dgm::PointPtr & pPoint, const awt::Point & pt )
+{
+ ShapePtr pShape = pPoint->getShape();
+ awt::Size sz;
+ sz.Width = 50;
+ sz.Height = 50;
+ pShape->setPosition( pt );
+ pShape->setSize( sz );
+}
+
+void DiagramLayout::layout( const dgm::PointsTreePtr & pTree, const awt::Point & pt )
+{
+ setPosition( pTree->getPoint(), pt );
+ awt::Point nextPt = pt;
+ nextPt.Y += 50;
+ dgm::PointsTree::Childrens::const_iterator iter;
+ for( iter = pTree->beginChild(); iter != pTree->endChild(); iter++ )
+ {
+ layout( *iter, nextPt );
+ nextPt.X += 50;
+ }
+}
+
+void Diagram::setData( const DiagramDataPtr & pData)
+{
+ mpData = pData;
+}
+
+
+void Diagram::setLayout( const DiagramLayoutPtr & pLayout)
+{
+ mpLayout = pLayout;
+}
+
+void Diagram::setQStyles( const DiagramQStylesPtr & pStyles)
+{
+ mpQStyles = pStyles;
+}
+
+
+void Diagram::setColors( const DiagramColorsPtr & pColors)
+{
+ mpColors = pColors;
+}
+
+void Diagram::build( )
+{
+ OSL_TRACE( "building diagram" );
+ typedef std::map< OUString, dgm::PointPtr > PointsMap;
+ PointsMap aPointsMap;
+ dgm::Points::iterator aPointsIter( mpData->getPoints( ).begin() );
+ for( ; aPointsIter != mpData->getPoints( ).end() ; aPointsIter++ )
+ {
+ const OUString & sName((*aPointsIter)->getModelId());
+ if( sName.getLength() > 0 )
+ {
+ aPointsMap[ sName ] = *aPointsIter;
+ }
+ }
+
+ typedef std::map< OUString, dgm::PointsTreePtr > PointsTreeMap;
+ PointsTreeMap aTreeMap;
+ PointsTreeMap aRoots;
+
+ dgm::Connections & aConnections(mpData->getConnections( ) );
+ dgm::Connections::iterator aCnxIter;
+ for( aCnxIter = aConnections.begin(); aCnxIter != aConnections.end(); ++aCnxIter )
+ {
+ OSL_ENSURE( *aCnxIter, "NULL connection found" );
+ if( (*aCnxIter)->mnType != XML_parOf )
+ {
+// OSL_TRACE( "ignoring relation %s", OUSTRING_TO_CSTR( (*aCnxIter)->msModelId ) );
+ continue;
+ }
+ dgm::PointPtr pDest;
+ dgm::PointsTreePtr pSource;
+ PointsMap::iterator iterP;
+ OUString & srcId( (*aCnxIter)->msSourceId );
+ OUString & dstId( (*aCnxIter)->msDestId );
+ OSL_TRACE( "connexion %s -> %s", OUSTRING_TO_CSTR( srcId ),
+ OUSTRING_TO_CSTR( dstId ) );
+
+ PointsTreeMap::iterator iterT = aTreeMap.find( srcId );
+ if( iterT != aTreeMap.end() )
+ {
+ pSource = iterT->second;
+ }
+ else
+ {
+ // this tree node is not found. create it with the source
+ // and make it the root node.
+ iterP = aPointsMap.find( srcId );
+ if( iterP != aPointsMap.end() )
+ {
+ pSource.reset( new dgm::PointsTree( iterP->second ) );
+ aRoots[ srcId ] = pSource;
+ aTreeMap[ srcId ] = pSource;
+ }
+ else
+ {
+ OSL_TRACE("parent node not found !");
+ }
+ }
+ iterP = aPointsMap.find( dstId );
+ if( iterP != aPointsMap.end() )
+ {
+ pDest = iterP->second;
+ }
+ OSL_ENSURE( pDest, "destination not found" );
+ OSL_ENSURE( pSource, "source not found" );
+ if(pDest && pSource)
+ {
+ dgm::PointsTreePtr pNode( new dgm::PointsTree( pDest ) );
+ bool added = pSource->addChild( pNode );
+ (void)added;
+ aRoots.erase( dstId );
+ OSL_ENSURE( added, "add child failed" );
+ aTreeMap[ dstId ] = pNode;
+ }
+ }
+ // check bounds
+ OSL_ENSURE( aRoots.size() == 1, "more than one root" );
+ // #i92239# roots may be empty
+ if( !aRoots.empty() )
+ {
+ mpRoot = aRoots.begin()->second;
+ OSL_TRACE( "root is %s", OUSTRING_TO_CSTR( mpRoot->getPoint()->getModelId() ) );
+ for( PointsTreeMap::iterator iter = aTreeMap.begin();
+ iter != aTreeMap.end(); iter++ )
+ {
+ if(! iter->second->getParent() )
+ {
+ OSL_TRACE("node without parent %s", OUSTRING_TO_CSTR( iter->first ) );
+ }
+ }
+ }
+}
+
+
+void Diagram::addTo( const ShapePtr & pParentShape )
+{
+ dgm::Points & aPoints( mpData->getPoints( ) );
+ dgm::Points::iterator aPointsIter;
+ build( );
+ if( mpRoot.get() )
+ mpLayout->layout( mpRoot, awt::Point( 0, 0 ) );
+
+ for( aPointsIter = aPoints.begin(); aPointsIter != aPoints.end(); ++aPointsIter )
+ {
+ if( ( *aPointsIter )->getType() != XML_node )
+ {
+ continue;
+ }
+ ShapePtr pShape = ( *aPointsIter )->getShape( );
+ if( pShape->getName( ).getLength() > 0 )
+ {
+ maShapeMap[ pShape->getName( ) ] = pShape;
+ OSL_TRACE( "Dgm: added shape %s to map", OUSTRING_TO_CSTR( pShape->getName() ) );
+ }
+ pParentShape->addChild( pShape );
+ }
+
+ OSL_TRACE( "Dgm: addTo() # of childs %d", pParentShape->getChildren().size() );
+ for( std::vector< ShapePtr >::iterator iter = pParentShape->getChildren().begin();
+ iter != pParentShape->getChildren().end(); ++iter)
+ {
+ OSL_TRACE( "Dgm: shape name %s", OUSTRING_TO_CSTR( (*iter)->getName() ) );
+ }
+}
+
+OUString Diagram::getLayoutId() const
+{
+ OUString sLayoutId;
+ if( mpLayout )
+ {
+ sLayoutId = mpLayout->getUniqueId();
+ }
+ return sLayoutId;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
new file mode 100644
index 000000000000..53477211848e
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * 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 "diagramdefinitioncontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/helper/helper.hxx"
+#include "layoutnodecontext.hxx"
+#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "tokens.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+
+// CT_DiagramDefinition
+DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler& rParent,
+ const Reference< XFastAttributeList >& xAttributes,
+ const DiagramLayoutPtr &pLayout )
+ : ContextHandler( rParent )
+ , mpLayout( pLayout )
+{
+ OSL_TRACE( "OOX: DiagramDefinitionContext::DiagramDefinitionContext()" );
+ mpLayout->setDefStyle( xAttributes->getOptionalValue( XML_defStyle ) );
+ OUString sValue = xAttributes->getOptionalValue( XML_minVer );
+ if( sValue.getLength() == 0 )
+ {
+ sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" );
+ }
+ mpLayout->setMinVer( sValue );
+ mpLayout->setUniqueId( xAttributes->getOptionalValue( XML_uniqueId ) );
+}
+
+
+DiagramDefinitionContext::~DiagramDefinitionContext()
+{
+ mpLayout->getNode()->dump(0);
+}
+
+void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 )
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_title:
+ mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) );
+ break;
+ case NMSP_DIAGRAM|XML_desc:
+ mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) );
+ break;
+ case NMSP_DIAGRAM|XML_layoutNode:
+ mpLayout->getNode().reset( new LayoutNode() );
+ xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) );
+ break;
+ case NMSP_DIAGRAM|XML_clrData:
+ // TODO, does not matter for the UI. skip.
+ return xRet;
+ case NMSP_DIAGRAM|XML_sampData:
+ mpLayout->getSampData().reset( new DiagramData );
+ xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) );
+ break;
+ case NMSP_DIAGRAM|XML_styleData:
+ mpLayout->getStyleData().reset( new DiagramData );
+ xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) );
+ break;
+ case NMSP_DIAGRAM|XML_cat:
+ case NMSP_DIAGRAM|XML_catLst:
+ // TODO, does not matter for the UI
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
new file mode 100644
index 000000000000..99407aed80d3
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * 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_DRAWINGML_DIAGRAMDEFINITIONCONTEXT_HXX
+#define OOX_DRAWINGML_DIAGRAMDEFINITIONCONTEXT_HXX
+
+#include "oox/core/contexthandler.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
+
+namespace oox { namespace drawingml {
+
+class DiagramDefinitionContext : public ::oox::core::ContextHandler
+{
+public:
+ DiagramDefinitionContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, const DiagramLayoutPtr &pLayout );
+ virtual ~DiagramDefinitionContext();
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+
+private:
+ DiagramLayoutPtr mpLayout;
+};
+
+} }
+
+#endif
diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
new file mode 100644
index 000000000000..ac2e755bee40
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * 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 <osl/diagnose.h>
+
+#include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
+#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "diagramdefinitioncontext.hxx"
+#include "tokens.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+DiagramDataFragmentHandler::DiagramDataFragmentHandler( XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ const DiagramDataPtr pDataPtr )
+ throw( )
+ : FragmentHandler( rFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramDataFragmentHandler::~DiagramDataFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramDataFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramDataFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_dataModel:
+ xRet.set( new DataModelContext( *this, mpDataPtr ) );
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet = getFastContextHandler();
+
+ return xRet;
+}
+
+///////////////////
+
+DiagramLayoutFragmentHandler::DiagramLayoutFragmentHandler( XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ const DiagramLayoutPtr pDataPtr )
+ throw( )
+ : FragmentHandler( rFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramLayoutFragmentHandler::~DiagramLayoutFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramLayoutFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramLayoutFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_layoutDef:
+ xRet.set( new DiagramDefinitionContext( *this, xAttribs, mpDataPtr ) );
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet = getFastContextHandler();
+
+ return xRet;
+}
+
+///////////////////////
+
+DiagramQStylesFragmentHandler::DiagramQStylesFragmentHandler( XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ const DiagramQStylesPtr pDataPtr )
+ throw( )
+ : FragmentHandler( rFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramQStylesFragmentHandler::~DiagramQStylesFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramQStylesFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramQStylesFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_styleDef:
+ // TODO
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet = getFastContextHandler();
+
+ return xRet;
+}
+
+/////////////////////
+
+DiagramColorsFragmentHandler::DiagramColorsFragmentHandler( XmlFilterBase& rFilter,
+ const OUString& rFragmentPath,
+ const DiagramColorsPtr pDataPtr )
+ throw( )
+ : FragmentHandler( rFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramColorsFragmentHandler::~DiagramColorsFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramColorsFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramColorsFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_colorsDef:
+ // TODO
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet = getFastContextHandler();
+
+ return xRet;
+}
+
+
+
+
+} }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
new file mode 100644
index 000000000000..a351189f3067
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * 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 "oox/drawingml/diagram/diagramlayoutatoms.hxx"
+
+#include <functional>
+#include <boost/bind.hpp>
+
+#include "oox/helper/attributelist.hxx"
+#include "layoutnodecontext.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::oox::core;
+
+namespace oox { namespace drawingml {
+
+
+IteratorAttr::IteratorAttr( )
+ : mnAxis( 0 )
+ , mnCnt( 0 )
+ , mbHideLastTrans( false )
+ , mnPtType( 0 )
+ , mnSt( 0 )
+ , mnStep( 1 )
+{
+}
+
+void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
+{
+ AttributeList attr( xAttr );
+ mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
+ mnCnt = attr.getInteger( XML_cnt, 0 );
+ mbHideLastTrans = attr.getBool( XML_hideLastTrans, false );
+ mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
+ mnSt = attr.getInteger( XML_st, 0 );
+ mnStep = attr.getInteger( XML_step, 1 );
+}
+
+
+
+ConditionAttr::ConditionAttr()
+ : mnFunc( 0 )
+ , mnArg( 0 )
+ , mnOp( 0 )
+{
+
+}
+
+
+void ConditionAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
+{
+ mnFunc = xAttr->getOptionalValueToken( XML_func, 0 );
+ // mnArg will be -1 for "none" or any other unknown value
+ mnArg = LayoutNodeContext::tagToVarIdx( xAttr->getOptionalValueToken( XML_arg, XML_none ) );
+ mnOp = xAttr->getOptionalValueToken( XML_op, 0 );
+ msVal = xAttr->getOptionalValue( XML_val );
+}
+
+
+void LayoutAtom::dump(int level)
+{
+ OSL_TRACE( "level = %d - %s of type %s", level,
+ OUSTRING_TO_CSTR( msName ),
+ typeid(*this).name() );
+ std::for_each( mpChildNodes.begin(), mpChildNodes.end(),
+ boost::bind( &LayoutAtom::dump, _1, level + 1 ) );
+}
+
+
+void ForEachAtom::processAtom()
+{
+ // TODO there is likely some conditions
+ std::for_each( mpChildNodes.begin(), mpChildNodes.end(),
+ boost::bind( &LayoutAtom::processAtom, _1 ) );
+}
+
+/** call ConditionAtom::test() if pAtom is one
+ * if it is not a ConditionAtom, then return false.
+ */
+static bool _test_atom( const LayoutAtomPtr & pAtom)
+{
+ try {
+ bool bResult = false;
+ const ConditionAtomPtr pCond = boost::dynamic_pointer_cast< ConditionAtom >(pAtom);
+ if( pCond )
+ {
+ bResult = pCond->test();
+ }
+ return bResult;
+ }
+ catch(...)
+ {
+ }
+ return false;
+}
+
+void ChooseAtom::processAtom()
+{
+ std::vector< LayoutAtomPtr >::iterator
+ iter = std::find_if( mpChildNodes.begin(), mpChildNodes.end(),
+ boost::bind( &_test_atom, _1 ) );
+ if( iter != mpChildNodes.end() )
+ {
+ // TODO do something
+ (*iter)->processAtom();
+ }
+}
+
+bool ConditionAtom::test()
+{
+ // TODO
+ return false;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
new file mode 100644
index 000000000000..4d430bb6ba36
--- /dev/null
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -0,0 +1,357 @@
+/*************************************************************************
+ *
+ * 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 "layoutnodecontext.hxx"
+
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
+#include "oox/drawingml/shapecontext.hxx"
+#include "diagramdefinitioncontext.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+class IfContext
+ : public LayoutNodeContext
+{
+public:
+ IfContext( ContextHandler& rParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ const LayoutAtomPtr & pNode )
+ : LayoutNodeContext( rParent, xAttribs, pNode )
+ {
+ ConditionAtomPtr pAtom( boost::dynamic_pointer_cast< ConditionAtom >(pNode) );
+ OSL_ENSURE( pAtom, "Must pass a ConditionAtom" );
+
+ pAtom->iterator().loadFromXAttr( xAttribs );
+ pAtom->cond().loadFromXAttr( xAttribs );
+ }
+};
+
+
+
+class AlgorithmContext
+ : public ContextHandler
+{
+public:
+ AlgorithmContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ : ContextHandler( rParent )
+ , mnRevision( 0 )
+ , mnType( 0 )
+ , mpNode( pNode )
+ {
+ AttributeList aAttribs( xAttribs );
+ mnRevision = aAttribs.getInteger( XML_rev, 0 );
+ mnType = xAttribs->getOptionalValueToken( XML_type, 0 );
+ }
+
+private:
+ sal_Int32 mnRevision;
+ sal_Int32 mnType;
+ LayoutAtomPtr mpNode;
+};
+
+
+class ChooseContext
+ : public ContextHandler
+{
+public:
+ ChooseContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ : ContextHandler( rParent )
+ , mbHasElse( false )
+ , mpNode( pNode )
+ {
+ msName = xAttribs->getOptionalValue( XML_name );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case XML_if:
+ {
+ // CT_When
+ LayoutAtomPtr pAtom( new ConditionAtom( false ) );
+ mpNode->addChild( pAtom );
+ xRet.set( new IfContext( *this, xAttribs, pAtom ) );
+ break;
+ }
+ case XML_else:
+ // CT_Otherwise
+ if( !mbHasElse )
+ {
+ LayoutAtomPtr pAtom( new ConditionAtom( true ) );
+ mpNode->addChild( pAtom );
+ xRet.set( new IfContext( *this, xAttribs, pAtom ) );
+ mbHasElse = true;
+ }
+ else
+ {
+ OSL_TRACE( "ignoring second else clause" );
+ }
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+ }
+private:
+ bool mbHasElse;
+ OUString msName;
+ LayoutAtomPtr mpNode;
+};
+
+
+
+
+class ForEachContext
+ : public LayoutNodeContext
+{
+public:
+ ForEachContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ : LayoutNodeContext( rParent, xAttribs, pNode )
+ {
+ ForEachAtomPtr pAtom( boost::dynamic_pointer_cast< ForEachAtom >(pNode) );
+ OSL_ENSURE( pAtom, "Must pass a ForEachAtom" );
+ xAttribs->getOptionalValue( XML_ref );
+
+ pAtom->iterator().loadFromXAttr( xAttribs );
+ }
+};
+
+
+// CT_LayoutVariablePropertySet
+class LayoutVariablePropertySetContext
+ : public ContextHandler
+{
+public:
+ LayoutVariablePropertySetContext( ContextHandler& rParent, LayoutNode::VarMap & aVar )
+ : ContextHandler( rParent )
+ , mVariables( aVar )
+ {
+ }
+
+ virtual ~LayoutVariablePropertySetContext()
+ {
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ sal_Int32 nIdx = LayoutNodeContext::tagToVarIdx( getToken( aElement ) );
+ if( nIdx != -1 )
+ {
+ mVariables[ nIdx ] = makeAny( xAttribs->getOptionalValue( XML_val ) );
+ }
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+ }
+private:
+ LayoutNode::VarMap & mVariables;
+};
+
+
+// CT_LayoutNode
+LayoutNodeContext::LayoutNodeContext( ContextHandler& rParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ const LayoutAtomPtr &pNode )
+ : ContextHandler( rParent )
+ , mpNode( pNode )
+{
+ OSL_ENSURE( pNode, "Node must NOT be NULL" );
+ mpNode->setName( xAttribs->getOptionalValue( XML_name ) );
+ // TODO shall we even bother?
+ // b or t
+// sal_Int32 nChOrder = xAttributes->getOptionalValueToken( XML_chOrder, XML_b );
+// OUString sMoveWith = xAttributes->getOptionalValue( XML_moveWith );
+// OUString sStyleLbl = xAttributes->getOptionalValue( XML_styleLbl );
+}
+
+
+LayoutNodeContext::~LayoutNodeContext()
+{
+}
+
+void SAL_CALL LayoutNodeContext::endFastElement( ::sal_Int32 )
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+/** convert the XML tag to a variable index in the array
+ * @param aTag the tag, wihout namespace
+ * @return the variable index. -1 is an error
+ */
+sal_Int32 LayoutNodeContext::tagToVarIdx( sal_Int32 aTag )
+{
+ sal_Int32 nIdx = -1;
+ switch( aTag )
+ {
+ case NMSP_DIAGRAM|XML_animLvl:
+ nIdx = LayoutNode::VAR_animLvl;
+ break;
+ case NMSP_DIAGRAM|XML_animOne:
+ nIdx = LayoutNode::VAR_animOne;
+ break;
+ case NMSP_DIAGRAM|XML_bulletEnabled:
+ nIdx = LayoutNode::VAR_bulletEnabled;
+ break;
+ case NMSP_DIAGRAM|XML_chMax:
+ nIdx = LayoutNode::VAR_chMax;
+ break;
+ case NMSP_DIAGRAM|XML_chPref:
+ nIdx = LayoutNode::VAR_chPref;
+ break;
+ case NMSP_DIAGRAM|XML_dir:
+ nIdx = LayoutNode::VAR_dir;
+ break;
+ case NMSP_DIAGRAM|XML_hierBranch:
+ nIdx = LayoutNode::VAR_hierBranch;
+ break;
+ case NMSP_DIAGRAM|XML_orgChart:
+ nIdx = LayoutNode::VAR_orgChart;
+ break;
+ case NMSP_DIAGRAM|XML_resizeHandles:
+ nIdx = LayoutNode::VAR_resizeHandles;
+ break;
+ default:
+ break;
+ }
+ return nIdx;
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_layoutNode:
+ {
+ LayoutNodePtr pNode( new LayoutNode() );
+ mpNode->addChild( pNode );
+ xRet.set( new LayoutNodeContext( *this, xAttribs, pNode ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_shape:
+ {
+ ShapePtr pShape( new Shape() );
+ xRet.set( new ShapeContext( *this, ShapePtr(), pShape ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_extLst:
+ return xRet;
+ case NMSP_DIAGRAM|XML_alg:
+ {
+ // CT_Algorithm
+ LayoutAtomPtr pAtom( new AlgAtom );
+ mpNode->addChild( pAtom );
+ xRet.set( new AlgorithmContext( *this, xAttribs, pAtom ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_choose:
+ {
+ // CT_Choose
+ LayoutAtomPtr pAtom( new ChooseAtom );
+ mpNode->addChild( pAtom );
+ xRet.set( new ChooseContext( *this, xAttribs, pAtom ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_forEach:
+ {
+ // CT_ForEach
+ LayoutAtomPtr pAtom( new ForEachAtom );
+ mpNode->addChild( pAtom );
+ xRet.set( new ForEachContext( *this, xAttribs, pAtom ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_constrLst:
+ // CT_Constraints
+ // TODO
+ break;
+ case NMSP_DIAGRAM|XML_presOf:
+ {
+ // CT_PresentationOf
+ // TODO
+ xAttribs->getOptionalValue( XML_axis );
+ xAttribs->getOptionalValue( XML_cnt );
+ xAttribs->getOptionalValue( XML_hideLastTrans );
+ xAttribs->getOptionalValue( XML_ptType );
+ xAttribs->getOptionalValue( XML_st );
+ xAttribs->getOptionalValue( XML_step );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_ruleLst:
+ // CT_Rules
+ // TODO
+ break;
+ case NMSP_DIAGRAM|XML_varLst:
+ {
+ LayoutNodePtr pNode( boost::dynamic_pointer_cast< LayoutNode >( mpNode ) );
+ if( pNode )
+ {
+ xRet.set( new LayoutVariablePropertySetContext( *this, pNode->variables() ) );
+ }
+ else
+ {
+ OSL_TRACE( "OOX: encountered a varLst in a non layoutNode context" );
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.hxx b/oox/source/drawingml/diagram/layoutnodecontext.hxx
new file mode 100644
index 000000000000..19cb19aa602d
--- /dev/null
+++ b/oox/source/drawingml/diagram/layoutnodecontext.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * 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_DRAWINGML_LAYOUTNODECONTEXT_HXX
+#define OOX_DRAWINGML_LAYOUTNODECONTEXT_HXX
+
+#include "oox/core/contexthandler.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
+
+namespace oox { namespace drawingml {
+
+class LayoutNodeContext : public ::oox::core::ContextHandler
+{
+public:
+ LayoutNodeContext( ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, const LayoutAtomPtr &pNode );
+ virtual ~LayoutNodeContext();
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+
+ static ::sal_Int32 tagToVarIdx( ::sal_Int32 aTag );
+private:
+ LayoutAtomPtr mpNode;
+};
+
+} }
+
+#endif
diff --git a/oox/source/drawingml/diagram/makefile.mk b/oox/source/drawingml/diagram/makefile.mk
new file mode 100644
index 000000000000..9d526ed3d3fb
--- /dev/null
+++ b/oox/source/drawingml/diagram/makefile.mk
@@ -0,0 +1,53 @@
+#*************************************************************************
+#
+# 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=diagram
+AUTOSEG=true
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/diagram.obj \
+ $(SLO)$/diagramfragmenthandler.obj \
+ $(SLO)$/diagramdefinitioncontext.obj \
+ $(SLO)$/diagramlayoutatoms.obj \
+ $(SLO)$/datamodelcontext.obj \
+ $(SLO)$/layoutnodecontext.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk