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