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
DiagramDefinitionContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttributes,const DiagramLayoutPtr & pLayout)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
~DiagramDefinitionContext()56 DiagramDefinitionContext::~DiagramDefinitionContext()
57 {
58 mpLayout->getNode()->dump(0);
59 }
60
endFastElement(::sal_Int32)61 void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 )
62 {
63
64 }
65
66
67 Reference< XFastContextHandler > SAL_CALL
createFastChildContext(::sal_Int32 aElement,const Reference<XFastAttributeList> & xAttribs)68 DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement,
69 const Reference< XFastAttributeList >& xAttribs )
70 {
71 Reference< XFastContextHandler > xRet;
72
73 switch( aElement )
74 {
75 case DGM_TOKEN( title ):
76 mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) );
77 break;
78 case DGM_TOKEN( desc ):
79 mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) );
80 break;
81 case DGM_TOKEN( layoutNode ):
82 mpLayout->getNode().reset( new LayoutNode() );
83 xRet.set( new LayoutNodeContext( *this, xAttribs, mpLayout->getNode() ) );
84 break;
85 case DGM_TOKEN( clrData ):
86 // TODO, does not matter for the UI. skip.
87 return xRet;
88 case DGM_TOKEN( sampData ):
89 mpLayout->getSampData().reset( new DiagramData );
90 xRet.set( new DataModelContext( *this, mpLayout->getSampData() ) );
91 break;
92 case DGM_TOKEN( styleData ):
93 mpLayout->getStyleData().reset( new DiagramData );
94 xRet.set( new DataModelContext( *this, mpLayout->getStyleData() ) );
95 break;
96 case DGM_TOKEN( cat ):
97 case DGM_TOKEN( catLst ):
98 // TODO, does not matter for the UI
99 default:
100 break;
101 }
102 if( !xRet.is() )
103 xRet.set(this);
104
105 return xRet;
106 }
107
108
109 } }
110