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