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 
20 #include <connectionsfragment.hxx>
21 
22 #include <oox/token/namespaces.hxx>
23 #include <biffhelper.hxx>
24 #include <connectionsbuffer.hxx>
25 
26 namespace oox::xls {
27 
28 using 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 ) )
66  mrConnection.importConnection( rAttribs );
67 }
68 
70 {
71  switch( getCurrentElement() )
72  {
74  if( nRecId == BIFF12_ID_WEBPR )
75  {
76  mrConnection.importWebPr( rStrm );
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 
90  mrConnection.importWebPrTable( rStrm, nRecId );
91  break;
92  }
93  return nullptr;
94 }
95 
97 {
100 }
101 
102 ConnectionsFragment::ConnectionsFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
103  WorkbookFragmentBase( rHelper, rFragmentPath )
104 {
105 }
106 
107 ContextHandlerRef ConnectionsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
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 
141 const 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: */
Helper class to provide access to global workbook data.
const sal_Int32 BIFF12_ID_CONNECTION
Definition: biffhelper.hxx:74
SQLExceptionInfo createConnection(const OUString &_rsDataSourceName, const Reference< css::container::XNameAccess > &_xDatabaseContext, const Reference< css::uno::XComponentContext > &_rxContext, Reference< css::lang::XEventListener > const &_rEvtLst, Reference< css::sdbc::XConnection > &_rOUTConnection)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
void importWebPrTables(SequenceInputStream &rStrm)
Imports web query table settings from the WEBPRTABLES record.
virtual void onStartRecord(SequenceInputStream &rStrm) override
Fragment handler derived from the WorkbookHelper helper class.
const sal_Int32 BIFF12_ID_WEBPR
Definition: biffhelper.hxx:237
exports com.sun.star. connection
ConnectionsFragment(const WorkbookHelper &rHelper, const OUString &rFragmentPath)
An external data connection (database, web query, etc.).
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
sal_Int32 getCurrentElement() const
void finalizeImport()
Maps all connections by their identifier.
void importWebPr(const AttributeList &rAttribs)
Imports web query settings from the webPr element.
void importConnection(const AttributeList &rAttribs)
Imports connection settings from the connection element.
exports com.sun.star.comp. connections
void importWebPrTable(SequenceInputStream &rStrm, sal_Int32 nRecId)
Imports a web query table identifier from the PCITEM_MISSING, PCITEM_STRING, or PCITEM_INDEX record...
void importTables()
Imports web query table settings from the tables element.
Context handler derived from the WorkbookHelper helper class.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void finalizeImport() override
void importTable(const AttributeList &rAttribs, sal_Int32 nElement)
Imports a web query table identifier from the m, s, or x element.
const sal_Int32 BIFF12_ID_CONNECTIONS
Definition: biffhelper.hxx:75
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
const sal_Int32 XML_ROOT_CONTEXT
dgm::Connections & mrConnection
ConnectionContext(WorkbookFragmentBase &rParent, Connection &rConnection)
const sal_Int32 BIFF12_ID_WEBPRTABLES
Definition: biffhelper.hxx:238
virtual void onStartElement(const AttributeList &rAttribs) override