1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "diagramdefinitioncontext.hxx" 29 #include "oox/helper/helper.hxx" 30 #include "layoutnodecontext.hxx" 31 #include "oox/drawingml/diagram/datamodelcontext.hxx" 32 33 using namespace ::oox::core; 34 using namespace ::com::sun::star::uno; 35 using namespace ::com::sun::star::xml::sax; 36 using ::rtl::OUString; 37 38 namespace oox { namespace drawingml { 39 40 41 // CT_DiagramDefinition 42 DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler& rParent, 43 const Reference< XFastAttributeList >& xAttributes, 44 const DiagramLayoutPtr &pLayout ) 45 : ContextHandler( rParent ) 46 , mpLayout( pLayout ) 47 { 48 OSL_TRACE( "OOX: DiagramDefinitionContext::DiagramDefinitionContext()" ); 49 mpLayout->setDefStyle( xAttributes->getOptionalValue( XML_defStyle ) ); 50 OUString sValue = xAttributes->getOptionalValue( XML_minVer ); 51 if( sValue.getLength() == 0 ) 52 { 53 sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ); 54 } 55 mpLayout->setMinVer( sValue ); 56 mpLayout->setUniqueId( xAttributes->getOptionalValue( XML_uniqueId ) ); 57 } 58 59 60 DiagramDefinitionContext::~DiagramDefinitionContext() 61 { 62 mpLayout->getNode()->dump(0); 63 } 64 65 void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 ) 66 throw (SAXException, RuntimeException) 67 { 68 69 } 70 71 72 Reference< XFastContextHandler > SAL_CALL 73 DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement, 74 const Reference< XFastAttributeList >& xAttribs ) 75 throw (SAXException, RuntimeException) 76 { 77 Reference< XFastContextHandler > xRet; 78 79 switch( aElement ) 80 { 81 case DGM_TOKEN( title ): 82 mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) ); 83 break; 84 case DGM_TOKEN( desc ): 85 mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) ); 86 break; 87 case DGM_TOKEN( layoutNode ): 88 mpLayout->getNode().reset( new LayoutNode() ); 89 xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) ); 90 break; 91 case DGM_TOKEN( clrData ): 92 // TODO, does not matter for the UI. skip. 93 return xRet; 94 case DGM_TOKEN( sampData ): 95 mpLayout->getSampData().reset( new DiagramData ); 96 xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) ); 97 break; 98 case DGM_TOKEN( styleData ): 99 mpLayout->getStyleData().reset( new DiagramData ); 100 xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) ); 101 break; 102 case DGM_TOKEN( cat ): 103 case DGM_TOKEN( catLst ): 104 // TODO, does not matter for the UI 105 default: 106 break; 107 } 108 if( !xRet.is() ) 109 xRet.set(this); 110 111 return xRet; 112 } 113 114 115 } } 116