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 "condformatcontext.hxx"
21 : #include "extlstcontext.hxx"
22 :
23 : namespace oox {
24 : namespace xls {
25 :
26 : // ============================================================================
27 :
28 : using ::oox::core::ContextHandlerRef;
29 : using ::rtl::OUString;
30 :
31 : // ============================================================================
32 :
33 0 : ColorScaleContext::ColorScaleContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
34 : WorksheetContextBase( rFragment ),
35 0 : mxRule( xRule )
36 : {
37 0 : }
38 :
39 0 : ContextHandlerRef ColorScaleContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
40 : {
41 0 : switch( getCurrentElement() )
42 : {
43 : case XLS_TOKEN( cfRule ):
44 0 : return (nElement == XLS_TOKEN( colorScale )) ? this : 0;
45 : case XLS_TOKEN( colorScale ):
46 0 : if (nElement == XLS_TOKEN( cfvo ))
47 0 : return this;
48 0 : else if (nElement == XLS_TOKEN( color ))
49 0 : return this;
50 : else
51 0 : return 0;
52 : }
53 0 : return 0;
54 : }
55 :
56 0 : void ColorScaleContext::onStartElement( const AttributeList& rAttribs )
57 : {
58 0 : switch( getCurrentElement() )
59 : {
60 : case XLS_TOKEN( cfvo ):
61 0 : mxRule->getColorScale()->importCfvo( rAttribs );
62 0 : break;
63 : case XLS_TOKEN( color ):
64 0 : mxRule->getColorScale()->importColor( rAttribs );
65 0 : break;
66 : }
67 0 : }
68 :
69 : // ============================================================================
70 :
71 0 : DataBarContext::DataBarContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
72 : WorksheetContextBase( rFragment ),
73 0 : mxRule( xRule )
74 : {
75 0 : }
76 :
77 0 : ContextHandlerRef DataBarContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
78 : {
79 0 : switch( getCurrentElement() )
80 : {
81 : case XLS_TOKEN( cfRule ):
82 0 : return (nElement == XLS_TOKEN( dataBar )) ? this : 0;
83 : case XLS_TOKEN( dataBar ):
84 0 : if (nElement == XLS_TOKEN( cfvo ))
85 0 : return this;
86 0 : else if (nElement == XLS_TOKEN( color ))
87 0 : return this;
88 : else
89 0 : return 0;
90 : }
91 0 : return 0;
92 : }
93 :
94 0 : void DataBarContext::onStartElement( const AttributeList& rAttribs )
95 : {
96 0 : switch( getCurrentElement() )
97 : {
98 : case XLS_TOKEN( dataBar ):
99 0 : mxRule->getDataBar()->importAttribs( rAttribs );
100 0 : break;
101 : case XLS_TOKEN( cfvo ):
102 0 : mxRule->getDataBar()->importCfvo( rAttribs );
103 0 : break;
104 : case XLS_TOKEN( color ):
105 0 : mxRule->getDataBar()->importColor( rAttribs );
106 0 : break;
107 : }
108 0 : }
109 :
110 : // ============================================================================
111 :
112 0 : IconSetContext::IconSetContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
113 : WorksheetContextBase( rFragment ),
114 0 : mxRule( xRule )
115 : {
116 0 : }
117 :
118 0 : ContextHandlerRef IconSetContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
119 : {
120 0 : switch( getCurrentElement() )
121 : {
122 : case XLS_TOKEN( cfRule ):
123 0 : return (nElement == XLS_TOKEN( iconSet )) ? this : 0;
124 : case XLS_TOKEN( iconSet ):
125 0 : if (nElement == XLS_TOKEN( cfvo ))
126 0 : return this;
127 : else
128 0 : return 0;
129 : }
130 0 : return 0;
131 : }
132 :
133 0 : void IconSetContext::onStartElement( const AttributeList& rAttribs )
134 : {
135 0 : switch( getCurrentElement() )
136 : {
137 : case XLS_TOKEN( iconSet ):
138 0 : mxRule->getIconSet()->importAttribs( rAttribs );
139 0 : break;
140 : case XLS_TOKEN( cfvo ):
141 0 : mxRule->getIconSet()->importCfvo( rAttribs );
142 0 : break;
143 : }
144 0 : }
145 :
146 : // ============================================================================
147 :
148 56 : CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) :
149 56 : WorksheetContextBase( rFragment )
150 : {
151 56 : }
152 :
153 110 : ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
154 : {
155 110 : switch( getCurrentElement() )
156 : {
157 : case XLS_TOKEN( conditionalFormatting ):
158 72 : return (nElement == XLS_TOKEN( cfRule )) ? this : 0;
159 : case XLS_TOKEN( cfRule ):
160 38 : if (nElement == XLS_TOKEN( formula ))
161 38 : return this;
162 0 : else if (nElement == XLS_TOKEN( colorScale ) )
163 0 : return new ColorScaleContext( *this, mxRule );
164 0 : else if (nElement == XLS_TOKEN( dataBar ) )
165 0 : return new DataBarContext( *this, mxRule );
166 0 : else if (nElement == XLS_TOKEN( iconSet ) )
167 0 : return new IconSetContext( *this, mxRule );
168 0 : else if (nElement == XLS_TOKEN( extLst ) )
169 0 : return new ExtLstLocalContext( *this, mxRule->getDataBar()->getDataBarFormatData() );
170 : else
171 0 : return 0;
172 : }
173 0 : return 0;
174 : }
175 :
176 166 : void CondFormatContext::onEndElement()
177 : {
178 166 : switch( getCurrentElement() )
179 : {
180 : case XLS_TOKEN( conditionalFormatting ):
181 56 : if(mxCondFmt.get())
182 56 : mxCondFmt->finalizeImport();
183 56 : break;
184 : }
185 166 : }
186 :
187 166 : void CondFormatContext::onStartElement( const AttributeList& rAttribs )
188 : {
189 166 : switch( getCurrentElement() )
190 : {
191 : case XLS_TOKEN( conditionalFormatting ):
192 56 : mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs );
193 56 : break;
194 : case XLS_TOKEN( cfRule ):
195 72 : if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs );
196 72 : break;
197 : }
198 166 : }
199 :
200 38 : void CondFormatContext::onCharacters( const OUString& rChars )
201 : {
202 38 : if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() )
203 38 : mxRule->appendFormula( rChars );
204 38 : }
205 :
206 0 : ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
207 : {
208 0 : switch( getCurrentElement() )
209 : {
210 : case BIFF12_ID_CONDFORMATTING:
211 0 : return (nRecId == BIFF12_ID_CFRULE) ? this : 0;
212 : }
213 0 : return 0;
214 : }
215 :
216 0 : void CondFormatContext::onStartRecord( SequenceInputStream& rStrm )
217 : {
218 0 : switch( getCurrentElement() )
219 : {
220 : case BIFF12_ID_CONDFORMATTING:
221 0 : mxCondFmt = getCondFormats().importCondFormatting( rStrm );
222 0 : break;
223 : case BIFF12_ID_CFRULE:
224 0 : if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm );
225 0 : break;
226 : }
227 0 : }
228 :
229 0 : void CondFormatContext::onEndRecord()
230 : {
231 0 : switch( getCurrentElement() )
232 : {
233 : case BIFF12_ID_CONDFORMATTING:
234 0 : if( mxCondFmt.get() )
235 0 : mxCondFmt->finalizeImport();
236 0 : break;
237 : }
238 0 : }
239 :
240 : // ============================================================================
241 :
242 : } // namespace xls
243 24 : } // namespace oox
244 :
245 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|