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 "connectionsfragment.hxx"
30 : :
31 : : #include "oox/helper/attributelist.hxx"
32 : : #include "biffhelper.hxx"
33 : : #include "connectionsbuffer.hxx"
34 : :
35 : : namespace oox {
36 : : namespace xls {
37 : :
38 : : // ============================================================================
39 : :
40 : : using namespace ::oox::core;
41 : :
42 : : using ::rtl::OUString;
43 : :
44 : : // ============================================================================
45 : :
46 : 0 : ConnectionContext::ConnectionContext( WorkbookFragmentBase& rParent, Connection& rConnection ) :
47 : : WorkbookContextBase( rParent ),
48 : 0 : mrConnection( rConnection )
49 : : {
50 : 0 : }
51 : :
52 : 0 : ContextHandlerRef ConnectionContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
53 : : {
54 [ # # # # ]: 0 : switch( getCurrentElement() )
55 : : {
56 : : case XLS_TOKEN( connection ):
57 [ # # ]: 0 : if( nElement == XLS_TOKEN( webPr ) )
58 : : {
59 : 0 : mrConnection.importWebPr( rAttribs );
60 : 0 : return this;
61 : : }
62 : 0 : break;
63 : :
64 : : case XLS_TOKEN( webPr ):
65 [ # # ]: 0 : if( nElement == XLS_TOKEN( tables ) )
66 : : {
67 : 0 : mrConnection.importTables( rAttribs );
68 : 0 : return this;
69 : : }
70 : 0 : break;
71 : :
72 : : case XLS_TOKEN( tables ):
73 : 0 : mrConnection.importTable( rAttribs, nElement );
74 : 0 : break;
75 : : }
76 : 0 : return 0;
77 : : }
78 : :
79 : 0 : void ConnectionContext::onStartElement( const AttributeList& rAttribs )
80 : : {
81 [ # # ]: 0 : if( getCurrentElement() == XLS_TOKEN( connection ) )
82 : 0 : mrConnection.importConnection( rAttribs );
83 : 0 : }
84 : :
85 : 0 : ContextHandlerRef ConnectionContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
86 : : {
87 [ # # # # ]: 0 : switch( getCurrentElement() )
88 : : {
89 : : case BIFF12_ID_CONNECTION:
90 [ # # ]: 0 : if( nRecId == BIFF12_ID_WEBPR )
91 : : {
92 : 0 : mrConnection.importWebPr( rStrm );
93 : 0 : return this;
94 : : }
95 : 0 : break;
96 : :
97 : : case BIFF12_ID_WEBPR:
98 [ # # ]: 0 : if( nRecId == BIFF12_ID_WEBPRTABLES )
99 : : {
100 : 0 : mrConnection.importWebPrTables( rStrm );
101 : 0 : return this;
102 : : }
103 : 0 : break;
104 : :
105 : : case BIFF12_ID_WEBPRTABLES:
106 : 0 : mrConnection.importWebPrTable( rStrm, nRecId );
107 : 0 : break;
108 : : }
109 : 0 : return 0;
110 : : }
111 : :
112 : 0 : void ConnectionContext::onStartRecord( SequenceInputStream& rStrm )
113 : : {
114 [ # # ]: 0 : if( getCurrentElement() == BIFF12_ID_CONNECTION )
115 : 0 : mrConnection.importConnection( rStrm );
116 : 0 : }
117 : :
118 : : // ============================================================================
119 : :
120 : 0 : ConnectionsFragment::ConnectionsFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
121 : 0 : WorkbookFragmentBase( rHelper, rFragmentPath )
122 : : {
123 : 0 : }
124 : :
125 : 0 : ContextHandlerRef ConnectionsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
126 : : {
127 [ # # # ]: 0 : switch( getCurrentElement() )
128 : : {
129 : : case XML_ROOT_CONTEXT:
130 [ # # ]: 0 : if( nElement == XLS_TOKEN( connections ) )
131 : 0 : return this;
132 : 0 : break;
133 : :
134 : : case XLS_TOKEN( connections ):
135 [ # # ]: 0 : if( nElement == XLS_TOKEN( connection ) )
136 [ # # ]: 0 : return new ConnectionContext( *this, getConnections().createConnection() );
137 : 0 : break;
138 : : }
139 : 0 : return 0;
140 : : }
141 : :
142 : 0 : ContextHandlerRef ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
143 : : {
144 [ # # # ]: 0 : switch( getCurrentElement() )
145 : : {
146 : : case XML_ROOT_CONTEXT:
147 [ # # ]: 0 : if( nRecId == BIFF12_ID_CONNECTIONS )
148 : 0 : return this;
149 : 0 : break;
150 : :
151 : : case BIFF12_ID_CONNECTIONS:
152 [ # # ]: 0 : if( nRecId == BIFF12_ID_CONNECTION )
153 [ # # ]: 0 : return new ConnectionContext( *this, getConnections().createConnection() );
154 : 0 : break;
155 : : }
156 : 0 : return 0;
157 : : }
158 : :
159 : 0 : const RecordInfo* ConnectionsFragment::getRecordInfos() const
160 : : {
161 : : static const RecordInfo spRecInfos[] =
162 : : {
163 : : { BIFF12_ID_CONNECTIONS, BIFF12_ID_CONNECTIONS + 1 },
164 : : { BIFF12_ID_CONNECTION, BIFF12_ID_CONNECTION + 1 },
165 : : { BIFF12_ID_WEBPR, BIFF12_ID_WEBPR + 1 },
166 : : { BIFF12_ID_WEBPRTABLES, BIFF12_ID_WEBPRTABLES + 1 },
167 : : { -1, -1 }
168 : : };
169 : 0 : return spRecInfos;
170 : : }
171 : :
172 : 0 : void ConnectionsFragment::finalizeImport()
173 : : {
174 : 0 : getConnections().finalizeImport();
175 : 0 : }
176 : :
177 : : // ============================================================================
178 : :
179 : : } // namespace xls
180 [ + - ][ + - ]: 24 : } // namespace oox
181 : :
182 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|