LibreOffice Module sc (master) 1
connectionsfragment.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
22#include <oox/token/namespaces.hxx>
23#include <biffhelper.hxx>
24#include <connectionsbuffer.hxx>
25
26namespace oox::xls {
27
28using namespace ::oox::core;
29
31 WorkbookContextBase( rParent ),
32 mrConnection( rConnection )
33{
34}
35
37{
38 switch( getCurrentElement() )
39 {
40 case XLS_TOKEN( connection ):
41 if( nElement == XLS_TOKEN( webPr ) )
42 {
43 mrConnection.importWebPr( rAttribs );
44 return this;
45 }
46 break;
47
48 case XLS_TOKEN( webPr ):
49 if( nElement == XLS_TOKEN( tables ) )
50 {
52 return this;
53 }
54 break;
55
56 case XLS_TOKEN( tables ):
57 mrConnection.importTable( rAttribs, nElement );
58 break;
59 }
60 return nullptr;
61}
62
64{
65 if( getCurrentElement() == XLS_TOKEN( connection ) )
67}
68
70{
71 switch( getCurrentElement() )
72 {
74 if( nRecId == BIFF12_ID_WEBPR )
75 {
77 return this;
78 }
79 break;
80
81 case BIFF12_ID_WEBPR:
82 if( nRecId == BIFF12_ID_WEBPRTABLES )
83 {
85 return this;
86 }
87 break;
88
91 break;
92 }
93 return nullptr;
94}
95
97{
98 if( getCurrentElement() == BIFF12_ID_CONNECTION )
100}
101
102ConnectionsFragment::ConnectionsFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
103 WorkbookFragmentBase( rHelper, rFragmentPath )
104{
105}
106
108{
109 switch( getCurrentElement() )
110 {
111 case XML_ROOT_CONTEXT:
112 if( nElement == XLS_TOKEN( connections ) )
113 return this;
114 break;
115
116 case XLS_TOKEN( connections ):
117 if( nElement == XLS_TOKEN( connection ) )
118 return new ConnectionContext( *this, getConnections().createConnection() );
119 break;
120 }
121 return nullptr;
122}
123
125{
126 switch( getCurrentElement() )
127 {
128 case XML_ROOT_CONTEXT:
129 if( nRecId == BIFF12_ID_CONNECTIONS )
130 return this;
131 break;
132
134 if( nRecId == BIFF12_ID_CONNECTION )
135 return new ConnectionContext( *this, getConnections().createConnection() );
136 break;
137 }
138 return nullptr;
139}
140
141const RecordInfo* ConnectionsFragment::getRecordInfos() const
142{
143 static const RecordInfo spRecInfos[] =
144 {
149 { -1, -1 }
150 };
151 return spRecInfos;
152}
153
155{
157}
158
159} // namespace oox::xls
160
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onStartElement(const AttributeList &rAttribs) override
ConnectionContext(WorkbookFragmentBase &rParent, Connection &rConnection)
virtual void onStartRecord(SequenceInputStream &rStrm) override
An external data connection (database, web query, etc.).
void importTables()
Imports web query table settings from the tables element.
void importWebPr(const AttributeList &rAttribs)
Imports web query settings from the webPr element.
void importWebPrTable(SequenceInputStream &rStrm, sal_Int32 nRecId)
Imports a web query table identifier from the PCITEM_MISSING, PCITEM_STRING, or PCITEM_INDEX record.
void importTable(const AttributeList &rAttribs, sal_Int32 nElement)
Imports a web query table identifier from the m, s, or x element.
void importConnection(const AttributeList &rAttribs)
Imports connection settings from the connection element.
void importWebPrTables(SequenceInputStream &rStrm)
Imports web query table settings from the WEBPRTABLES record.
void finalizeImport()
Maps all connections by their identifier.
virtual void finalizeImport() override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
ConnectionsFragment(const WorkbookHelper &rHelper, const OUString &rFragmentPath)
Context handler derived from the WorkbookHelper helper class.
Fragment handler derived from the WorkbookHelper helper class.
Helper class to provide access to global workbook data.
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
svx::diagram::Connections & mrConnection
::dbtools::SQLExceptionInfo createConnection(const OUString &_rsDataSourceName, const css::uno::Reference< css::container::XNameAccess > &_xDatabaseContext, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, css::uno::Reference< css::lang::XEventListener > const &_rEvtLst, css::uno::Reference< css::sdbc::XConnection > &_rOUTConnection)
void SvStream & rStrm
const sal_Int32 XML_ROOT_CONTEXT
const sal_Int32 BIFF12_ID_CONNECTION
Definition: biffhelper.hxx:73
const sal_Int32 BIFF12_ID_CONNECTIONS
Definition: biffhelper.hxx:74
const sal_Int32 BIFF12_ID_WEBPRTABLES
Definition: biffhelper.hxx:237
const sal_Int32 BIFF12_ID_WEBPR
Definition: biffhelper.hxx:236