xref: /trunk/main/oox/source/xls/tablefragment.cxx (revision ca5ec200)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/xls/tablefragment.hxx"
25 
26 #include "oox/xls/autofilterbuffer.hxx"
27 #include "oox/xls/autofiltercontext.hxx"
28 #include "oox/xls/tablebuffer.hxx"
29 
30 namespace oox {
31 namespace xls {
32 
33 // ============================================================================
34 
35 using namespace ::oox::core;
36 
37 using ::rtl::OUString;
38 
39 // ============================================================================
40 
TableFragment(const WorksheetHelper & rHelper,const OUString & rFragmentPath)41 TableFragment::TableFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
42     WorksheetFragmentBase( rHelper, rFragmentPath ),
43     mrTable( getTables().createTable() )
44 {
45 }
46 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)47 ContextHandlerRef TableFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
48 {
49     switch( getCurrentElement() )
50     {
51         case XML_ROOT_CONTEXT:
52             if( nElement == XLS_TOKEN( table ) )
53             {
54                 mrTable.importTable( rAttribs, getSheetIndex() );
55                 return this;
56             }
57         break;
58         case XLS_TOKEN( table ):
59             if( nElement == XLS_TOKEN( autoFilter ) )
60                 return new AutoFilterContext( *this, mrTable.createAutoFilter() );
61         break;
62     }
63     return 0;
64 }
65 
onCreateRecordContext(sal_Int32 nRecId,SequenceInputStream & rStrm)66 ContextHandlerRef TableFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
67 {
68     switch( getCurrentElement() )
69     {
70         case XML_ROOT_CONTEXT:
71             if( nRecId == BIFF12_ID_TABLE )
72             {
73                 mrTable.importTable( rStrm, getSheetIndex() );
74                 return this;
75             }
76         break;
77         case BIFF12_ID_TABLE:
78             if( nRecId == BIFF12_ID_AUTOFILTER )
79                 return new AutoFilterContext( *this, mrTable.createAutoFilter() );
80         break;
81     }
82     return 0;
83 }
84 
getRecordInfos() const85 const RecordInfo* TableFragment::getRecordInfos() const
86 {
87     static const RecordInfo spRecInfos[] =
88     {
89         { BIFF12_ID_AUTOFILTER,         BIFF12_ID_AUTOFILTER + 1        },
90         { BIFF12_ID_CUSTOMFILTERS,      BIFF12_ID_CUSTOMFILTERS + 1     },
91         { BIFF12_ID_DISCRETEFILTERS,    BIFF12_ID_DISCRETEFILTERS + 1   },
92         { BIFF12_ID_FILTERCOLUMN,       BIFF12_ID_FILTERCOLUMN + 1      },
93         { BIFF12_ID_TABLE,              BIFF12_ID_TABLE + 1             },
94         { -1,                           -1                              }
95     };
96     return spRecInfos;
97 }
98 
99 // ============================================================================
100 
101 } // namespace xls
102 } // namespace oox
103