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 "autofiltercontext.hxx"
30 : :
31 : : #include "autofilterbuffer.hxx"
32 : : #include "biffinputstream.hxx"
33 : :
34 : : namespace oox {
35 : : namespace xls {
36 : :
37 : : using ::oox::core::ContextHandlerRef;
38 : : using ::rtl::OUString;
39 : :
40 : : // ============================================================================
41 : :
42 : 3 : FilterSettingsContext::FilterSettingsContext( WorksheetContextBase& rParent, FilterSettingsBase& rFilterSettings ) :
43 : : WorksheetContextBase( rParent ),
44 : 3 : mrFilterSettings( rFilterSettings )
45 : : {
46 : 3 : }
47 : :
48 : 3 : ContextHandlerRef FilterSettingsContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
49 : : {
50 [ - + - ]: 3 : switch( getCurrentElement() )
51 : : {
52 : : case XLS_TOKEN( filters ):
53 [ # # ]: 0 : if( nElement == XLS_TOKEN( filter ) ) return this;
54 : 0 : break;
55 : : case XLS_TOKEN( customFilters ):
56 [ + - ]: 3 : if( nElement == XLS_TOKEN( customFilter ) ) return this;
57 : 0 : break;
58 : : }
59 : 3 : return 0;
60 : : }
61 : :
62 : 6 : void FilterSettingsContext::onStartElement( const AttributeList& rAttribs )
63 : : {
64 : 6 : mrFilterSettings.importAttribs( getCurrentElement(), rAttribs );
65 : 6 : }
66 : :
67 : 0 : ContextHandlerRef FilterSettingsContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
68 : : {
69 [ # # # ]: 0 : switch( getCurrentElement() )
70 : : {
71 : : case BIFF12_ID_DISCRETEFILTERS:
72 [ # # ]: 0 : if( nRecId == BIFF12_ID_DISCRETEFILTER ) return this;
73 : 0 : break;
74 : : case BIFF12_ID_CUSTOMFILTERS:
75 [ # # ]: 0 : if( nRecId == BIFF12_ID_CUSTOMFILTER ) return this;
76 : 0 : break;
77 : : }
78 : 0 : return 0;
79 : : }
80 : :
81 : 0 : void FilterSettingsContext::onStartRecord( SequenceInputStream& rStrm )
82 : : {
83 : 0 : mrFilterSettings.importRecord( getCurrentElement(), rStrm );
84 : 0 : }
85 : :
86 : : // ============================================================================
87 : :
88 : 3 : FilterColumnContext::FilterColumnContext( WorksheetContextBase& rParent, FilterColumn& rFilterColumn ) :
89 : : WorksheetContextBase( rParent ),
90 : 3 : mrFilterColumn( rFilterColumn )
91 : : {
92 : 3 : }
93 : :
94 : 3 : ContextHandlerRef FilterColumnContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
95 : : {
96 [ + - ]: 3 : if( getCurrentElement() == XLS_TOKEN( filterColumn ) ) switch( nElement )
[ - - + - ]
97 : : {
98 : : case XLS_TOKEN( filters ):
99 [ # # ]: 0 : return new FilterSettingsContext( *this, mrFilterColumn.createFilterSettings< DiscreteFilter >() );
100 : : case XLS_TOKEN( top10 ):
101 [ # # ]: 0 : return new FilterSettingsContext( *this, mrFilterColumn.createFilterSettings< Top10Filter >() );
102 : : case XLS_TOKEN( customFilters ):
103 [ + - ]: 3 : return new FilterSettingsContext( *this, mrFilterColumn.createFilterSettings< CustomFilter >() );
104 : : }
105 : 3 : return 0;
106 : : }
107 : :
108 : 3 : void FilterColumnContext::onStartElement( const AttributeList& rAttribs )
109 : : {
110 : 3 : mrFilterColumn.importFilterColumn( rAttribs );
111 : 3 : }
112 : :
113 : 0 : ContextHandlerRef FilterColumnContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
114 : : {
115 [ # # ]: 0 : if( getCurrentElement() == BIFF12_ID_FILTERCOLUMN ) switch( nRecId )
[ # # # # ]
116 : : {
117 : : case BIFF12_ID_DISCRETEFILTERS:
118 [ # # ]: 0 : return new FilterSettingsContext( *this, mrFilterColumn.createFilterSettings< DiscreteFilter >() );
119 : : case BIFF12_ID_TOP10FILTER:
120 [ # # ]: 0 : return new FilterSettingsContext( *this, mrFilterColumn.createFilterSettings< Top10Filter >() );
121 : : case BIFF12_ID_CUSTOMFILTERS:
122 [ # # ]: 0 : return new FilterSettingsContext( *this, mrFilterColumn.createFilterSettings< CustomFilter >() );
123 : : }
124 : 0 : return 0;
125 : : }
126 : :
127 : 0 : void FilterColumnContext::onStartRecord( SequenceInputStream& rStrm )
128 : : {
129 : 0 : mrFilterColumn.importFilterColumn( rStrm );
130 : 0 : }
131 : :
132 : : // ============================================================================
133 : :
134 : 3 : AutoFilterContext::AutoFilterContext( WorksheetFragmentBase& rFragment, AutoFilter& rAutoFilter ) :
135 : : WorksheetContextBase( rFragment ),
136 : 3 : mrAutoFilter( rAutoFilter )
137 : : {
138 : 3 : }
139 : :
140 : 3 : ContextHandlerRef AutoFilterContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
141 : : {
142 [ + - ][ + - ]: 3 : if( (getCurrentElement() == XLS_TOKEN( autoFilter )) && (nElement == XLS_TOKEN( filterColumn )) )
[ + - ]
143 [ + - ]: 3 : return new FilterColumnContext( *this, mrAutoFilter.createFilterColumn() );
144 : 3 : return 0;
145 : : }
146 : :
147 : 3 : void AutoFilterContext::onStartElement( const AttributeList& rAttribs )
148 : : {
149 : 3 : mrAutoFilter.importAutoFilter( rAttribs, getSheetIndex() );
150 : 3 : }
151 : :
152 : 0 : ContextHandlerRef AutoFilterContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
153 : : {
154 [ # # ][ # # ]: 0 : if( (getCurrentElement() == BIFF12_ID_AUTOFILTER) && (nRecId == BIFF12_ID_FILTERCOLUMN) )
[ # # ]
155 [ # # ]: 0 : return new FilterColumnContext( *this, mrAutoFilter.createFilterColumn() );
156 : 0 : return 0;
157 : : }
158 : :
159 : 0 : void AutoFilterContext::onStartRecord( SequenceInputStream& rStrm )
160 : : {
161 : 0 : mrAutoFilter.importAutoFilter( rStrm, getSheetIndex() );
162 : 0 : }
163 : :
164 : : // ============================================================================
165 : :
166 : : } // namespace xls
167 [ + - ][ + - ]: 24 : } // namespace oox
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|