xref: /aoo41x/main/oox/source/xls/tablefragment.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/xls/tablefragment.hxx"
29 
30 #include "oox/xls/autofilterbuffer.hxx"
31 #include "oox/xls/autofiltercontext.hxx"
32 #include "oox/xls/tablebuffer.hxx"
33 
34 namespace oox {
35 namespace xls {
36 
37 // ============================================================================
38 
39 using namespace ::oox::core;
40 
41 using ::rtl::OUString;
42 
43 // ============================================================================
44 
45 TableFragment::TableFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
46     WorksheetFragmentBase( rHelper, rFragmentPath ),
47     mrTable( getTables().createTable() )
48 {
49 }
50 
51 ContextHandlerRef TableFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
52 {
53     switch( getCurrentElement() )
54     {
55         case XML_ROOT_CONTEXT:
56             if( nElement == XLS_TOKEN( table ) )
57             {
58                 mrTable.importTable( rAttribs, getSheetIndex() );
59                 return this;
60             }
61         break;
62         case XLS_TOKEN( table ):
63             if( nElement == XLS_TOKEN( autoFilter ) )
64                 return new AutoFilterContext( *this, mrTable.createAutoFilter() );
65         break;
66     }
67     return 0;
68 }
69 
70 ContextHandlerRef TableFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
71 {
72     switch( getCurrentElement() )
73     {
74         case XML_ROOT_CONTEXT:
75             if( nRecId == BIFF12_ID_TABLE )
76             {
77                 mrTable.importTable( rStrm, getSheetIndex() );
78                 return this;
79             }
80         break;
81         case BIFF12_ID_TABLE:
82             if( nRecId == BIFF12_ID_AUTOFILTER )
83                 return new AutoFilterContext( *this, mrTable.createAutoFilter() );
84         break;
85     }
86     return 0;
87 }
88 
89 const RecordInfo* TableFragment::getRecordInfos() const
90 {
91     static const RecordInfo spRecInfos[] =
92     {
93         { BIFF12_ID_AUTOFILTER,         BIFF12_ID_AUTOFILTER + 1        },
94         { BIFF12_ID_CUSTOMFILTERS,      BIFF12_ID_CUSTOMFILTERS + 1     },
95         { BIFF12_ID_DISCRETEFILTERS,    BIFF12_ID_DISCRETEFILTERS + 1   },
96         { BIFF12_ID_FILTERCOLUMN,       BIFF12_ID_FILTERCOLUMN + 1      },
97         { BIFF12_ID_TABLE,              BIFF12_ID_TABLE + 1             },
98         { -1,                           -1                              }
99     };
100     return spRecInfos;
101 }
102 
103 // ============================================================================
104 
105 } // namespace xls
106 } // namespace oox
107