Update ooo320-m1
[ooovba.git] / oox / source / drawingml / diagram / diagramdefinitioncontext.cxx
blob9c512dc43a5f7e6434b2428a08167dbf376a200a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: diagramdefinitioncontext.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "diagramdefinitioncontext.hxx"
32 #include "oox/core/namespaces.hxx"
33 #include "oox/helper/helper.hxx"
34 #include "layoutnodecontext.hxx"
35 #include "oox/drawingml/diagram/datamodelcontext.hxx"
36 #include "tokens.hxx"
38 using namespace ::oox::core;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::xml::sax;
41 using ::rtl::OUString;
43 namespace oox { namespace drawingml {
46 // CT_DiagramDefinition
47 DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler& rParent,
48 const Reference< XFastAttributeList >& xAttributes,
49 const DiagramLayoutPtr &pLayout )
50 : ContextHandler( rParent )
51 , mpLayout( pLayout )
53 OSL_TRACE( "OOX: DiagramDefinitionContext::DiagramDefinitionContext()" );
54 mpLayout->setDefStyle( xAttributes->getOptionalValue( XML_defStyle ) );
55 OUString sValue = xAttributes->getOptionalValue( XML_minVer );
56 if( sValue.getLength() == 0 )
58 sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" );
60 mpLayout->setMinVer( sValue );
61 mpLayout->setUniqueId( xAttributes->getOptionalValue( XML_uniqueId ) );
65 DiagramDefinitionContext::~DiagramDefinitionContext()
67 mpLayout->getNode()->dump(0);
70 void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 )
71 throw (SAXException, RuntimeException)
77 Reference< XFastContextHandler > SAL_CALL
78 DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement,
79 const Reference< XFastAttributeList >& xAttribs )
80 throw (SAXException, RuntimeException)
82 Reference< XFastContextHandler > xRet;
84 switch( aElement )
86 case NMSP_DIAGRAM|XML_title:
87 mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) );
88 break;
89 case NMSP_DIAGRAM|XML_desc:
90 mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) );
91 break;
92 case NMSP_DIAGRAM|XML_layoutNode:
93 mpLayout->getNode().reset( new LayoutNode() );
94 xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) );
95 break;
96 case NMSP_DIAGRAM|XML_clrData:
97 // TODO, does not matter for the UI. skip.
98 return xRet;
99 case NMSP_DIAGRAM|XML_sampData:
100 mpLayout->getSampData().reset( new DiagramData );
101 xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) );
102 break;
103 case NMSP_DIAGRAM|XML_styleData:
104 mpLayout->getStyleData().reset( new DiagramData );
105 xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) );
106 break;
107 case NMSP_DIAGRAM|XML_cat:
108 case NMSP_DIAGRAM|XML_catLst:
109 // TODO, does not matter for the UI
110 default:
111 break;
113 if( !xRet.is() )
114 xRet.set(this);
116 return xRet;