1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ca5ec200SAndrew Rist  * distributed with this work for additional information
6*ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ca5ec200SAndrew Rist  *
11*ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ca5ec200SAndrew Rist  *
13*ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist  * under the License.
19*ca5ec200SAndrew Rist  *
20*ca5ec200SAndrew Rist  *************************************************************/
21*ca5ec200SAndrew Rist 
22*ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "oox/drawingml/chart/titlecontext.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "oox/drawingml/shapepropertiescontext.hxx"
27cdf0e10cSrcweir #include "oox/drawingml/textbodycontext.hxx"
28cdf0e10cSrcweir #include "oox/drawingml/chart/datasourcecontext.hxx"
29cdf0e10cSrcweir #include "oox/drawingml/chart/titlemodel.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace oox {
32cdf0e10cSrcweir namespace drawingml {
33cdf0e10cSrcweir namespace chart {
34cdf0e10cSrcweir 
35cdf0e10cSrcweir // ============================================================================
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using ::oox::core::ContextHandler2Helper;
38cdf0e10cSrcweir using ::oox::core::ContextHandlerRef;
39cdf0e10cSrcweir using ::rtl::OUString;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // ============================================================================
42cdf0e10cSrcweir 
TextContext(ContextHandler2Helper & rParent,TextModel & rModel)43cdf0e10cSrcweir TextContext::TextContext( ContextHandler2Helper& rParent, TextModel& rModel ) :
44cdf0e10cSrcweir     ContextBase< TextModel >( rParent, rModel )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
~TextContext()48cdf0e10cSrcweir TextContext::~TextContext()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir }
51cdf0e10cSrcweir 
onCreateContext(sal_Int32 nElement,const AttributeList &)52cdf0e10cSrcweir ContextHandlerRef TextContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir     // this context handler is used for <c:tx> and embedded <c:v> elements
55cdf0e10cSrcweir     if( isCurrentElement( C_TOKEN( tx ) ) ) switch( nElement )
56cdf0e10cSrcweir     {
57cdf0e10cSrcweir         case C_TOKEN( rich ):
58cdf0e10cSrcweir             return new TextBodyContext( *this, mrModel.mxTextBody.create() );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         case C_TOKEN( strRef ):
61cdf0e10cSrcweir             OSL_ENSURE( !mrModel.mxDataSeq, "TextContext::onCreateContext - multiple data sequences" );
62cdf0e10cSrcweir             return new StringSequenceContext( *this, mrModel.mxDataSeq.create() );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         case C_TOKEN( v ):
65cdf0e10cSrcweir             OSL_ENSURE( !mrModel.mxDataSeq, "TextContext::onCreateContext - multiple data sequences" );
66cdf0e10cSrcweir             return this;    // collect value in onCharacters()
67cdf0e10cSrcweir     }
68cdf0e10cSrcweir     return 0;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
onCharacters(const OUString & rChars)71cdf0e10cSrcweir void TextContext::onCharacters( const OUString& rChars )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     // store as single string sequence element
74cdf0e10cSrcweir     if( isCurrentElement( C_TOKEN( v ) ) )
75cdf0e10cSrcweir         mrModel.mxDataSeq.create().maData[ 0 ] <<= rChars;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // ============================================================================
79cdf0e10cSrcweir 
TitleContext(ContextHandler2Helper & rParent,TitleModel & rModel)80cdf0e10cSrcweir TitleContext::TitleContext( ContextHandler2Helper& rParent, TitleModel& rModel ) :
81cdf0e10cSrcweir     ContextBase< TitleModel >( rParent, rModel )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
~TitleContext()85cdf0e10cSrcweir TitleContext::~TitleContext()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)89cdf0e10cSrcweir ContextHandlerRef TitleContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     // this context handler is used for <c:title> only
92cdf0e10cSrcweir     switch( nElement )
93cdf0e10cSrcweir     {
94cdf0e10cSrcweir         case C_TOKEN( layout ):
95cdf0e10cSrcweir             return new LayoutContext( *this, mrModel.mxLayout.create() );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         case C_TOKEN( overlay ):
98cdf0e10cSrcweir             // default is 'false', not 'true' as specified
99cdf0e10cSrcweir             mrModel.mbOverlay = rAttribs.getBool( XML_val, false );
100cdf0e10cSrcweir             return 0;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         case C_TOKEN( spPr ):
103cdf0e10cSrcweir             return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         case C_TOKEN( tx ):
106cdf0e10cSrcweir             return new TextContext( *this, mrModel.mxText.create() );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         case C_TOKEN( txPr ):
109cdf0e10cSrcweir             return new TextBodyContext( *this, mrModel.mxTextProp.create() );
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir     return 0;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir // ============================================================================
115cdf0e10cSrcweir 
LegendContext(ContextHandler2Helper & rParent,LegendModel & rModel)116cdf0e10cSrcweir LegendContext::LegendContext( ContextHandler2Helper& rParent, LegendModel& rModel ) :
117cdf0e10cSrcweir     ContextBase< LegendModel >( rParent, rModel )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
~LegendContext()121cdf0e10cSrcweir LegendContext::~LegendContext()
122cdf0e10cSrcweir {
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)125cdf0e10cSrcweir ContextHandlerRef LegendContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     // this context handler is used for <c:legend> only
128cdf0e10cSrcweir     switch( nElement )
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         case C_TOKEN( layout ):
131cdf0e10cSrcweir             return new LayoutContext( *this, mrModel.mxLayout.create() );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         case C_TOKEN( legendPos ):
134cdf0e10cSrcweir             mrModel.mnPosition = rAttribs.getToken( XML_val, XML_r );
135cdf0e10cSrcweir             return 0;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         case C_TOKEN( overlay ):
138cdf0e10cSrcweir             // default is 'false', not 'true' as specified
139cdf0e10cSrcweir             mrModel.mbOverlay = rAttribs.getBool( XML_val, false );
140cdf0e10cSrcweir             return 0;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         case C_TOKEN( spPr ):
143cdf0e10cSrcweir             return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir         case C_TOKEN( txPr ):
146cdf0e10cSrcweir             return new TextBodyContext( *this, mrModel.mxTextProp.create() );
147cdf0e10cSrcweir     }
148cdf0e10cSrcweir     return 0;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir // ============================================================================
152cdf0e10cSrcweir 
153cdf0e10cSrcweir } // namespace chart
154cdf0e10cSrcweir } // namespace drawingml
155cdf0e10cSrcweir } // namespace oox
156