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/querytablefragment.hxx"
25
26 #include "oox/xls/biffinputstream.hxx"
27 #include "oox/xls/querytablebuffer.hxx"
28
29 namespace oox {
30 namespace xls {
31
32 // ============================================================================
33
34 using namespace ::oox::core;
35
36 using ::rtl::OUString;
37
38 // ============================================================================
39
QueryTableFragment(const WorksheetHelper & rHelper,const OUString & rFragmentPath)40 QueryTableFragment::QueryTableFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
41 WorksheetFragmentBase( rHelper, rFragmentPath ),
42 mrQueryTable( getQueryTables().createQueryTable() )
43 {
44 }
45
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)46 ContextHandlerRef QueryTableFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
47 {
48 switch( getCurrentElement() )
49 {
50 case XML_ROOT_CONTEXT:
51 if( nElement == XLS_TOKEN( queryTable ) )
52 mrQueryTable.importQueryTable( rAttribs );
53 break;
54 }
55 return 0;
56 }
57
onCreateRecordContext(sal_Int32 nRecId,SequenceInputStream & rStrm)58 ContextHandlerRef QueryTableFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
59 {
60 switch( getCurrentElement() )
61 {
62 case XML_ROOT_CONTEXT:
63 if( nRecId == BIFF12_ID_QUERYTABLE )
64 mrQueryTable.importQueryTable( rStrm );
65 break;
66 }
67 return 0;
68 }
69
getRecordInfos() const70 const RecordInfo* QueryTableFragment::getRecordInfos() const
71 {
72 static const RecordInfo spRecInfos[] =
73 {
74 { BIFF12_ID_QUERYTABLE, BIFF12_ID_QUERYTABLE + 1 },
75 { BIFF12_ID_QUERYTABLEREFRESH, BIFF12_ID_QUERYTABLEREFRESH + 1 },
76 { -1, -1 }
77 };
78 return spRecInfos;
79 }
80
81 // ============================================================================
82
BiffQueryTableContext(const WorksheetHelper & rHelper)83 BiffQueryTableContext::BiffQueryTableContext( const WorksheetHelper& rHelper ) :
84 BiffWorksheetContextBase( rHelper ),
85 mrQueryTable( getQueryTables().createQueryTable() )
86 {
87 }
88
importRecord(BiffInputStream & rStrm)89 void BiffQueryTableContext::importRecord( BiffInputStream& rStrm )
90 {
91 switch( rStrm.getRecId() )
92 {
93 case BIFF_ID_QUERYTABLE: mrQueryTable.importQueryTable( rStrm ); break;
94 case BIFF_ID_QUERYTABLEREFRESH: mrQueryTable.importQueryTableRefresh( rStrm ); break;
95 case BIFF_ID_QUERYTABLESETTINGS: mrQueryTable.importQueryTableSettings( rStrm ); break;
96 }
97 }
98
99 // ============================================================================
100
101 } // namespace xls
102 } // namespace oox
103