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/helper/attributelist.hxx>
23 #include <oox/token/namespaces.hxx>
24 #include <oox/token/tokens.hxx>
25 #include "biffhelper.hxx"
26 #include "connectionsbuffer.hxx"
31 using namespace ::oox::core
;
33 ConnectionContext::ConnectionContext( WorkbookFragmentBase
& rParent
, Connection
& rConnection
) :
34 WorkbookContextBase( rParent
),
35 mrConnection( rConnection
)
39 ContextHandlerRef
ConnectionContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
41 switch( getCurrentElement() )
43 case XLS_TOKEN( connection
):
44 if( nElement
== XLS_TOKEN( webPr
) )
46 mrConnection
.importWebPr( rAttribs
);
51 case XLS_TOKEN( webPr
):
52 if( nElement
== XLS_TOKEN( tables
) )
54 mrConnection
.importTables( rAttribs
);
59 case XLS_TOKEN( tables
):
60 mrConnection
.importTable( rAttribs
, nElement
);
66 void ConnectionContext::onStartElement( const AttributeList
& rAttribs
)
68 if( getCurrentElement() == XLS_TOKEN( connection
) )
69 mrConnection
.importConnection( rAttribs
);
72 ContextHandlerRef
ConnectionContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& rStrm
)
74 switch( getCurrentElement() )
76 case BIFF12_ID_CONNECTION
:
77 if( nRecId
== BIFF12_ID_WEBPR
)
79 mrConnection
.importWebPr( rStrm
);
85 if( nRecId
== BIFF12_ID_WEBPRTABLES
)
87 mrConnection
.importWebPrTables( rStrm
);
92 case BIFF12_ID_WEBPRTABLES
:
93 mrConnection
.importWebPrTable( rStrm
, nRecId
);
99 void ConnectionContext::onStartRecord( SequenceInputStream
& rStrm
)
101 if( getCurrentElement() == BIFF12_ID_CONNECTION
)
102 mrConnection
.importConnection( rStrm
);
105 ConnectionsFragment::ConnectionsFragment( const WorkbookHelper
& rHelper
, const OUString
& rFragmentPath
) :
106 WorkbookFragmentBase( rHelper
, rFragmentPath
)
110 ContextHandlerRef
ConnectionsFragment::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
112 switch( getCurrentElement() )
114 case XML_ROOT_CONTEXT
:
115 if( nElement
== XLS_TOKEN( connections
) )
119 case XLS_TOKEN( connections
):
120 if( nElement
== XLS_TOKEN( connection
) )
121 return new ConnectionContext( *this, getConnections().createConnection() );
127 ContextHandlerRef
ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
129 switch( getCurrentElement() )
131 case XML_ROOT_CONTEXT
:
132 if( nRecId
== BIFF12_ID_CONNECTIONS
)
136 case BIFF12_ID_CONNECTIONS
:
137 if( nRecId
== BIFF12_ID_CONNECTION
)
138 return new ConnectionContext( *this, getConnections().createConnection() );
144 const RecordInfo
* ConnectionsFragment::getRecordInfos() const
146 static const RecordInfo spRecInfos
[] =
148 { BIFF12_ID_CONNECTIONS
, BIFF12_ID_CONNECTIONS
+ 1 },
149 { BIFF12_ID_CONNECTION
, BIFF12_ID_CONNECTION
+ 1 },
150 { BIFF12_ID_WEBPR
, BIFF12_ID_WEBPR
+ 1 },
151 { BIFF12_ID_WEBPRTABLES
, BIFF12_ID_WEBPRTABLES
+ 1 },
157 void ConnectionsFragment::finalizeImport()
159 getConnections().finalizeImport();
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */