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>
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
);
49 case XLS_TOKEN( webPr
):
50 if( nElement
== XLS_TOKEN( tables
) )
52 mrConnection
.importTables();
57 case XLS_TOKEN( tables
):
58 mrConnection
.importTable( rAttribs
, nElement
);
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
);
83 if( nRecId
== BIFF12_ID_WEBPRTABLES
)
85 mrConnection
.importWebPrTables( rStrm
);
90 case BIFF12_ID_WEBPRTABLES
:
91 mrConnection
.importWebPrTable( rStrm
, nRecId
);
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
) )
117 case XLS_TOKEN( connections
):
118 if( nElement
== XLS_TOKEN( connection
) )
119 return new ConnectionContext( *this, getConnections().createConnection() );
125 ContextHandlerRef
ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
127 switch( getCurrentElement() )
129 case XML_ROOT_CONTEXT
:
130 if( nRecId
== BIFF12_ID_CONNECTIONS
)
134 case BIFF12_ID_CONNECTIONS
:
135 if( nRecId
== BIFF12_ID_CONNECTION
)
136 return new ConnectionContext( *this, getConnections().createConnection() );
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 },
155 void ConnectionsFragment::finalizeImport()
157 getConnections().finalizeImport();
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */