Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "condformatcontext.hxx"
30 : : #include "extlstcontext.hxx"
31 : :
32 : : namespace oox {
33 : : namespace xls {
34 : :
35 : : // ============================================================================
36 : :
37 : : using ::oox::core::ContextHandlerRef;
38 : : using ::rtl::OUString;
39 : :
40 : : // ============================================================================
41 : :
42 : 0 : ColorScaleContext::ColorScaleContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
43 : : WorksheetContextBase( rFragment ),
44 [ # # ]: 0 : mxRule( xRule )
45 : : {
46 : 0 : }
47 : :
48 : 0 : ContextHandlerRef ColorScaleContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
49 : : {
50 [ # # # ]: 0 : switch( getCurrentElement() )
51 : : {
52 : : case XLS_TOKEN( cfRule ):
53 [ # # ]: 0 : return (nElement == XLS_TOKEN( colorScale )) ? this : 0;
54 : : case XLS_TOKEN( colorScale ):
55 [ # # ]: 0 : if (nElement == XLS_TOKEN( cfvo ))
56 : 0 : return this;
57 [ # # ]: 0 : else if (nElement == XLS_TOKEN( color ))
58 : 0 : return this;
59 : : else
60 : 0 : return 0;
61 : : }
62 : 0 : return 0;
63 : : }
64 : :
65 : 0 : void ColorScaleContext::onStartElement( const AttributeList& rAttribs )
66 : : {
67 [ # # # ]: 0 : switch( getCurrentElement() )
68 : : {
69 : : case XLS_TOKEN( cfvo ):
70 : 0 : mxRule->getColorScale()->importCfvo( rAttribs );
71 : 0 : break;
72 : : case XLS_TOKEN( color ):
73 : 0 : mxRule->getColorScale()->importColor( rAttribs );
74 : 0 : break;
75 : : }
76 : 0 : }
77 : :
78 : : // ============================================================================
79 : :
80 : 0 : DataBarContext::DataBarContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
81 : : WorksheetContextBase( rFragment ),
82 [ # # ]: 0 : mxRule( xRule )
83 : : {
84 : 0 : }
85 : :
86 : 0 : ContextHandlerRef DataBarContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
87 : : {
88 [ # # # ]: 0 : switch( getCurrentElement() )
89 : : {
90 : : case XLS_TOKEN( cfRule ):
91 [ # # ]: 0 : return (nElement == XLS_TOKEN( colorScale )) ? this : 0;
92 : : case XLS_TOKEN( dataBar ):
93 [ # # ]: 0 : if (nElement == XLS_TOKEN( cfvo ))
94 : 0 : return this;
95 [ # # ]: 0 : else if (nElement == XLS_TOKEN( color ))
96 : 0 : return this;
97 : : else
98 : 0 : return 0;
99 : : }
100 : 0 : return 0;
101 : : }
102 : :
103 : 0 : void DataBarContext::onStartElement( const AttributeList& rAttribs )
104 : : {
105 [ # # # # ]: 0 : switch( getCurrentElement() )
106 : : {
107 : : case XLS_TOKEN( dataBar ):
108 : 0 : mxRule->getDataBar()->importAttribs( rAttribs );
109 : 0 : break;
110 : : case XLS_TOKEN( cfvo ):
111 : 0 : mxRule->getDataBar()->importCfvo( rAttribs );
112 : 0 : break;
113 : : case XLS_TOKEN( color ):
114 : 0 : mxRule->getDataBar()->importColor( rAttribs );
115 : 0 : break;
116 : : }
117 : 0 : }
118 : :
119 : : // ============================================================================
120 : :
121 : 0 : CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) :
122 [ # # ][ # # ]: 0 : WorksheetContextBase( rFragment )
123 : : {
124 : 0 : }
125 : :
126 : 0 : ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
127 : : {
128 [ # # # ]: 0 : switch( getCurrentElement() )
129 : : {
130 : : case XLS_TOKEN( conditionalFormatting ):
131 [ # # ]: 0 : return (nElement == XLS_TOKEN( cfRule )) ? this : 0;
132 : : case XLS_TOKEN( cfRule ):
133 [ # # ]: 0 : if (nElement == XLS_TOKEN( formula ))
134 : 0 : return this;
135 [ # # ]: 0 : else if (nElement == XLS_TOKEN( colorScale ) )
136 [ # # ]: 0 : return new ColorScaleContext( *this, mxRule );
137 [ # # ]: 0 : else if (nElement == XLS_TOKEN( dataBar ) )
138 [ # # ]: 0 : return new DataBarContext( *this, mxRule );
139 [ # # ]: 0 : else if (nElement == XLS_TOKEN( extLst ) )
140 [ # # ]: 0 : return new ExtLstLocalContext( *this, mxRule->getDataBar()->getDataBarFormatData() );
141 : : else
142 : 0 : return 0;
143 : : }
144 : 0 : return 0;
145 : : }
146 : :
147 : 0 : void CondFormatContext::onEndElement()
148 : : {
149 [ # # ]: 0 : switch( getCurrentElement() )
150 : : {
151 : : case XLS_TOKEN( conditionalFormatting ):
152 [ # # ]: 0 : if(mxCondFmt.get())
153 : 0 : mxCondFmt->finalizeImport();
154 : 0 : break;
155 : : }
156 : 0 : }
157 : :
158 : 0 : void CondFormatContext::onStartElement( const AttributeList& rAttribs )
159 : : {
160 [ # # # ]: 0 : switch( getCurrentElement() )
161 : : {
162 : : case XLS_TOKEN( conditionalFormatting ):
163 [ # # ]: 0 : mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs );
164 : 0 : break;
165 : : case XLS_TOKEN( cfRule ):
166 [ # # ][ # # ]: 0 : if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs );
167 : 0 : break;
168 : : }
169 : 0 : }
170 : :
171 : 0 : void CondFormatContext::onCharacters( const OUString& rChars )
172 : : {
173 [ # # ][ # # ]: 0 : if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() )
[ # # ][ # # ]
174 : 0 : mxRule->appendFormula( rChars );
175 : 0 : }
176 : :
177 : 0 : ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
178 : : {
179 [ # # ]: 0 : switch( getCurrentElement() )
180 : : {
181 : : case BIFF12_ID_CONDFORMATTING:
182 [ # # ]: 0 : return (nRecId == BIFF12_ID_CFRULE) ? this : 0;
183 : : }
184 : 0 : return 0;
185 : : }
186 : :
187 : 0 : void CondFormatContext::onStartRecord( SequenceInputStream& rStrm )
188 : : {
189 [ # # # ]: 0 : switch( getCurrentElement() )
190 : : {
191 : : case BIFF12_ID_CONDFORMATTING:
192 [ # # ]: 0 : mxCondFmt = getCondFormats().importCondFormatting( rStrm );
193 : 0 : break;
194 : : case BIFF12_ID_CFRULE:
195 [ # # ]: 0 : if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm );
196 : 0 : break;
197 : : }
198 : 0 : }
199 : :
200 : 0 : void CondFormatContext::onEndRecord()
201 : : {
202 [ # # ]: 0 : switch( getCurrentElement() )
203 : : {
204 : : case BIFF12_ID_CONDFORMATTING:
205 [ # # ]: 0 : if( mxCondFmt.get() )
206 : 0 : mxCondFmt->finalizeImport();
207 : 0 : break;
208 : : }
209 : 0 : }
210 : :
211 : : // ============================================================================
212 : :
213 : : } // namespace xls
214 [ + - ][ + - ]: 24 : } // namespace oox
215 : :
216 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|