1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
28 using namespace ::oox::core
;
30 ConnectionContext::ConnectionContext( WorkbookFragmentBase
& rParent
, Connection
& rConnection
) :
31 WorkbookContextBase( rParent
),
32 mrConnection( rConnection
)
36 ContextHandlerRef
ConnectionContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
38 switch( getCurrentElement() )
40 case XLS_TOKEN( connection
):
41 if( nElement
== XLS_TOKEN( webPr
) )
43 mrConnection
.importWebPr( rAttribs
);
48 case XLS_TOKEN( webPr
):
49 if( nElement
== XLS_TOKEN( tables
) )
51 mrConnection
.importTables();
56 case XLS_TOKEN( tables
):
57 mrConnection
.importTable( rAttribs
, nElement
);
63 void ConnectionContext::onStartElement( const AttributeList
& rAttribs
)
65 if( getCurrentElement() == XLS_TOKEN( connection
) )
66 mrConnection
.importConnection( rAttribs
);
69 ContextHandlerRef
ConnectionContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& rStrm
)
71 switch( getCurrentElement() )
73 case BIFF12_ID_CONNECTION
:
74 if( nRecId
== BIFF12_ID_WEBPR
)
76 mrConnection
.importWebPr( rStrm
);
82 if( nRecId
== BIFF12_ID_WEBPRTABLES
)
84 mrConnection
.importWebPrTables( rStrm
);
89 case BIFF12_ID_WEBPRTABLES
:
90 mrConnection
.importWebPrTable( rStrm
, nRecId
);
96 void ConnectionContext::onStartRecord( SequenceInputStream
& rStrm
)
98 if( getCurrentElement() == BIFF12_ID_CONNECTION
)
99 mrConnection
.importConnection( rStrm
);
102 ConnectionsFragment::ConnectionsFragment( const WorkbookHelper
& rHelper
, const OUString
& rFragmentPath
) :
103 WorkbookFragmentBase( rHelper
, rFragmentPath
)
107 ContextHandlerRef
ConnectionsFragment::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
109 switch( getCurrentElement() )
111 case XML_ROOT_CONTEXT
:
112 if( nElement
== XLS_TOKEN( connections
) )
116 case XLS_TOKEN( connections
):
117 if( nElement
== XLS_TOKEN( connection
) )
118 return new ConnectionContext( *this, getConnections().createConnection() );
124 ContextHandlerRef
ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
126 switch( getCurrentElement() )
128 case XML_ROOT_CONTEXT
:
129 if( nRecId
== BIFF12_ID_CONNECTIONS
)
133 case BIFF12_ID_CONNECTIONS
:
134 if( nRecId
== BIFF12_ID_CONNECTION
)
135 return new ConnectionContext( *this, getConnections().createConnection() );
141 const RecordInfo
* ConnectionsFragment::getRecordInfos() const
143 static const RecordInfo spRecInfos
[] =
145 { BIFF12_ID_CONNECTIONS
, BIFF12_ID_CONNECTIONS
+ 1 },
146 { BIFF12_ID_CONNECTION
, BIFF12_ID_CONNECTION
+ 1 },
147 { BIFF12_ID_WEBPR
, BIFF12_ID_WEBPR
+ 1 },
148 { BIFF12_ID_WEBPRTABLES
, BIFF12_ID_WEBPRTABLES
+ 1 },
154 void ConnectionsFragment::finalizeImport()
156 getConnections().finalizeImport();
159 } // namespace oox::xls
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */