Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / oox / connectionsfragment.cxx
blob3774f7315e8660fe8f152adbdd0ad5ff45c44e5b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <connectionsfragment.hxx>
22 #include <oox/token/namespaces.hxx>
23 #include <biffhelper.hxx>
24 #include <connectionsbuffer.hxx>
26 namespace oox {
27 namespace xls {
29 using namespace ::oox::core;
31 ConnectionContext::ConnectionContext( WorkbookFragmentBase& rParent, Connection& rConnection ) :
32 WorkbookContextBase( rParent ),
33 mrConnection( rConnection )
37 ContextHandlerRef ConnectionContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
39 switch( getCurrentElement() )
41 case XLS_TOKEN( connection ):
42 if( nElement == XLS_TOKEN( webPr ) )
44 mrConnection.importWebPr( rAttribs );
45 return this;
47 break;
49 case XLS_TOKEN( webPr ):
50 if( nElement == XLS_TOKEN( tables ) )
52 mrConnection.importTables();
53 return this;
55 break;
57 case XLS_TOKEN( tables ):
58 mrConnection.importTable( rAttribs, nElement );
59 break;
61 return nullptr;
64 void ConnectionContext::onStartElement( const AttributeList& rAttribs )
66 if( getCurrentElement() == XLS_TOKEN( connection ) )
67 mrConnection.importConnection( rAttribs );
70 ContextHandlerRef ConnectionContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
72 switch( getCurrentElement() )
74 case BIFF12_ID_CONNECTION:
75 if( nRecId == BIFF12_ID_WEBPR )
77 mrConnection.importWebPr( rStrm );
78 return this;
80 break;
82 case BIFF12_ID_WEBPR:
83 if( nRecId == BIFF12_ID_WEBPRTABLES )
85 mrConnection.importWebPrTables( rStrm );
86 return this;
88 break;
90 case BIFF12_ID_WEBPRTABLES:
91 mrConnection.importWebPrTable( rStrm, nRecId );
92 break;
94 return nullptr;
97 void ConnectionContext::onStartRecord( SequenceInputStream& rStrm )
99 if( getCurrentElement() == BIFF12_ID_CONNECTION )
100 mrConnection.importConnection( rStrm );
103 ConnectionsFragment::ConnectionsFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
104 WorkbookFragmentBase( rHelper, rFragmentPath )
108 ContextHandlerRef ConnectionsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
110 switch( getCurrentElement() )
112 case XML_ROOT_CONTEXT:
113 if( nElement == XLS_TOKEN( connections ) )
114 return this;
115 break;
117 case XLS_TOKEN( connections ):
118 if( nElement == XLS_TOKEN( connection ) )
119 return new ConnectionContext( *this, getConnections().createConnection() );
120 break;
122 return nullptr;
125 ContextHandlerRef ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
127 switch( getCurrentElement() )
129 case XML_ROOT_CONTEXT:
130 if( nRecId == BIFF12_ID_CONNECTIONS )
131 return this;
132 break;
134 case BIFF12_ID_CONNECTIONS:
135 if( nRecId == BIFF12_ID_CONNECTION )
136 return new ConnectionContext( *this, getConnections().createConnection() );
137 break;
139 return nullptr;
142 const RecordInfo* ConnectionsFragment::getRecordInfos() const
144 static const RecordInfo spRecInfos[] =
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 }
152 return spRecInfos;
155 void ConnectionsFragment::finalizeImport()
157 getConnections().finalizeImport();
160 } // namespace xls
161 } // namespace oox
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */