Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "connectionsfragment.hxx"
21 :
22 : #include <oox/helper/attributelist.hxx>
23 : #include "biffhelper.hxx"
24 : #include "connectionsbuffer.hxx"
25 :
26 : namespace oox {
27 : namespace xls {
28 :
29 : using namespace ::oox::core;
30 :
31 0 : ConnectionContext::ConnectionContext( WorkbookFragmentBase& rParent, Connection& rConnection ) :
32 : WorkbookContextBase( rParent ),
33 0 : mrConnection( rConnection )
34 : {
35 0 : }
36 :
37 0 : ContextHandlerRef ConnectionContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
38 : {
39 0 : switch( getCurrentElement() )
40 : {
41 : case XLS_TOKEN( connection ):
42 0 : if( nElement == XLS_TOKEN( webPr ) )
43 : {
44 0 : mrConnection.importWebPr( rAttribs );
45 0 : return this;
46 : }
47 0 : break;
48 :
49 : case XLS_TOKEN( webPr ):
50 0 : if( nElement == XLS_TOKEN( tables ) )
51 : {
52 0 : mrConnection.importTables( rAttribs );
53 0 : return this;
54 : }
55 0 : break;
56 :
57 : case XLS_TOKEN( tables ):
58 0 : mrConnection.importTable( rAttribs, nElement );
59 0 : break;
60 : }
61 0 : return 0;
62 : }
63 :
64 0 : void ConnectionContext::onStartElement( const AttributeList& rAttribs )
65 : {
66 0 : if( getCurrentElement() == XLS_TOKEN( connection ) )
67 0 : mrConnection.importConnection( rAttribs );
68 0 : }
69 :
70 0 : ContextHandlerRef ConnectionContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
71 : {
72 0 : switch( getCurrentElement() )
73 : {
74 : case BIFF12_ID_CONNECTION:
75 0 : if( nRecId == BIFF12_ID_WEBPR )
76 : {
77 0 : mrConnection.importWebPr( rStrm );
78 0 : return this;
79 : }
80 0 : break;
81 :
82 : case BIFF12_ID_WEBPR:
83 0 : if( nRecId == BIFF12_ID_WEBPRTABLES )
84 : {
85 0 : mrConnection.importWebPrTables( rStrm );
86 0 : return this;
87 : }
88 0 : break;
89 :
90 : case BIFF12_ID_WEBPRTABLES:
91 0 : mrConnection.importWebPrTable( rStrm, nRecId );
92 0 : break;
93 : }
94 0 : return 0;
95 : }
96 :
97 0 : void ConnectionContext::onStartRecord( SequenceInputStream& rStrm )
98 : {
99 0 : if( getCurrentElement() == BIFF12_ID_CONNECTION )
100 0 : mrConnection.importConnection( rStrm );
101 0 : }
102 :
103 0 : ConnectionsFragment::ConnectionsFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
104 0 : WorkbookFragmentBase( rHelper, rFragmentPath )
105 : {
106 0 : }
107 :
108 0 : ContextHandlerRef ConnectionsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
109 : {
110 0 : switch( getCurrentElement() )
111 : {
112 : case XML_ROOT_CONTEXT:
113 0 : if( nElement == XLS_TOKEN( connections ) )
114 0 : return this;
115 0 : break;
116 :
117 : case XLS_TOKEN( connections ):
118 0 : if( nElement == XLS_TOKEN( connection ) )
119 0 : return new ConnectionContext( *this, getConnections().createConnection() );
120 0 : break;
121 : }
122 0 : return 0;
123 : }
124 :
125 0 : ContextHandlerRef ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
126 : {
127 0 : switch( getCurrentElement() )
128 : {
129 : case XML_ROOT_CONTEXT:
130 0 : if( nRecId == BIFF12_ID_CONNECTIONS )
131 0 : return this;
132 0 : break;
133 :
134 : case BIFF12_ID_CONNECTIONS:
135 0 : if( nRecId == BIFF12_ID_CONNECTION )
136 0 : return new ConnectionContext( *this, getConnections().createConnection() );
137 0 : break;
138 : }
139 0 : return 0;
140 : }
141 :
142 0 : const RecordInfo* ConnectionsFragment::getRecordInfos() const
143 : {
144 : static const RecordInfo spRecInfos[] =
145 : {
146 : { BIFF12_ID_CONNECTIONS, BIFF12_ID_CONNECTIONS + 1 },
147 : { BIFF12_ID_CONNECTION, BIFF12_ID_CONNECTION + 1 },
148 : { BIFF12_ID_WEBPR, BIFF12_ID_WEBPR + 1 },
149 : { BIFF12_ID_WEBPRTABLES, BIFF12_ID_WEBPRTABLES + 1 },
150 : { -1, -1 }
151 : };
152 0 : return spRecInfos;
153 : }
154 :
155 0 : void ConnectionsFragment::finalizeImport()
156 : {
157 0 : getConnections().finalizeImport();
158 0 : }
159 :
160 : } // namespace xls
161 48 : } // namespace oox
162 :
163 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|