1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "diagramdefinitioncontext.hxx" 25 #include "oox/helper/helper.hxx" 26 #include "layoutnodecontext.hxx" 27 #include "oox/drawingml/diagram/datamodelcontext.hxx" 28 29 using namespace ::oox::core; 30 using namespace ::com::sun::star::uno; 31 using namespace ::com::sun::star::xml::sax; 32 using ::rtl::OUString; 33 34 namespace oox { namespace drawingml { 35 36 37 // CT_DiagramDefinition 38 DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler& rParent, 39 const Reference< XFastAttributeList >& xAttributes, 40 const DiagramLayoutPtr &pLayout ) 41 : ContextHandler( rParent ) 42 , mpLayout( pLayout ) 43 { 44 OSL_TRACE( "OOX: DiagramDefinitionContext::DiagramDefinitionContext()" ); 45 mpLayout->setDefStyle( xAttributes->getOptionalValue( XML_defStyle ) ); 46 OUString sValue = xAttributes->getOptionalValue( XML_minVer ); 47 if( sValue.getLength() == 0 ) 48 { 49 sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ); 50 } 51 mpLayout->setMinVer( sValue ); 52 mpLayout->setUniqueId( xAttributes->getOptionalValue( XML_uniqueId ) ); 53 } 54 55 56 DiagramDefinitionContext::~DiagramDefinitionContext() 57 { 58 mpLayout->getNode()->dump(0); 59 } 60 61 void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 ) 62 throw (SAXException, RuntimeException) 63 { 64 65 } 66 67 68 Reference< XFastContextHandler > SAL_CALL 69 DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement, 70 const Reference< XFastAttributeList >& xAttribs ) 71 throw (SAXException, RuntimeException) 72 { 73 Reference< XFastContextHandler > xRet; 74 75 switch( aElement ) 76 { 77 case DGM_TOKEN( title ): 78 mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) ); 79 break; 80 case DGM_TOKEN( desc ): 81 mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) ); 82 break; 83 case DGM_TOKEN( layoutNode ): 84 mpLayout->getNode().reset( new LayoutNode() ); 85 xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) ); 86 break; 87 case DGM_TOKEN( clrData ): 88 // TODO, does not matter for the UI. skip. 89 return xRet; 90 case DGM_TOKEN( sampData ): 91 mpLayout->getSampData().reset( new DiagramData ); 92 xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) ); 93 break; 94 case DGM_TOKEN( styleData ): 95 mpLayout->getStyleData().reset( new DiagramData ); 96 xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) ); 97 break; 98 case DGM_TOKEN( cat ): 99 case DGM_TOKEN( catLst ): 100 // TODO, does not matter for the UI 101 default: 102 break; 103 } 104 if( !xRet.is() ) 105 xRet.set(this); 106 107 return xRet; 108 } 109 110 111 } } 112