LibreOffice Module sc (master)  1
connectionsbuffer.hxx
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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_CONNECTIONSBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_CONNECTIONSBUFFER_HXX
22 
23 #include <memory>
24 #include <oox/helper/refvector.hxx>
25 #include "workbookhelper.hxx"
26 
27 namespace oox { class AttributeList; }
28 namespace oox { class SequenceInputStream; }
29 
30 namespace oox::xls {
31 
32 const sal_Int32 BIFF12_CONNECTION_UNKNOWN = 0;
33 const sal_Int32 BIFF12_CONNECTION_ODBC = 1;
34 const sal_Int32 BIFF12_CONNECTION_DAO = 2;
35 const sal_Int32 BIFF12_CONNECTION_FILE = 3;
36 const sal_Int32 BIFF12_CONNECTION_HTML = 4;
37 const sal_Int32 BIFF12_CONNECTION_OLEDB = 5;
38 const sal_Int32 BIFF12_CONNECTION_TEXT = 6;
39 const sal_Int32 BIFF12_CONNECTION_ADO = 7;
40 const sal_Int32 BIFF12_CONNECTION_DSP = 8;
41 
43 struct WebPrModel
44 {
45  typedef ::std::vector< css::uno::Any > TablesVector;
46 
47  TablesVector maTables;
48  OUString maUrl;
49  OUString maPostMethod;
50  OUString maEditPage;
51  sal_Int32 mnHtmlFormat;
52  bool mbXml;
53  bool mbSourceData;
54  bool mbParsePre;
56  bool mbFirstRow;
58  bool mbTextDates;
60  bool mbHtmlTables;
61 
62  explicit WebPrModel();
63 };
64 
67 {
68  typedef ::std::unique_ptr< WebPrModel > WebPrModelPtr;
69 
70  WebPrModelPtr mxWebPr;
71  OUString maName;
72  OUString maDescription;
73  OUString maSourceFile;
74  OUString maSourceConnFile;
75  OUString maSsoId;
76  sal_Int32 mnId;
77  sal_Int32 mnType;
78  sal_Int32 mnReconnectMethod;
79  sal_Int32 mnCredentials;
80  sal_Int32 mnInterval;
81  bool mbKeepAlive;
82  bool mbNew;
83  bool mbDeleted;
85  bool mbBackground;
87  bool mbSaveData;
89 
90  explicit ConnectionModel();
91 
93 };
94 
96 class Connection : public WorkbookHelper
97 {
98 public:
99  explicit Connection( const WorkbookHelper& rHelper );
100 
102  void importConnection( const AttributeList& rAttribs );
104  void importWebPr( const AttributeList& rAttribs );
106  void importTables();
108  void importTable( const AttributeList& rAttribs, sal_Int32 nElement );
109 
113  void importWebPr( SequenceInputStream& rStrm );
115  void importWebPrTables( SequenceInputStream& rStrm );
117  void importWebPrTable( SequenceInputStream& rStrm, sal_Int32 nRecId );
118 
120  sal_Int32 getConnectionId() const { return maModel.mnId; }
122  sal_Int32 getConnectionType() const { return maModel.mnType; }
124  const ConnectionModel& getModel() const { return maModel; }
125 
126 private:
128 };
129 
130 typedef std::shared_ptr< Connection > ConnectionRef;
131 
133 {
134 public:
135  explicit ConnectionsBuffer( const WorkbookHelper& rHelper );
136 
139 
141  void finalizeImport();
142 
144  ConnectionRef getConnection( sal_Int32 nConnId ) const;
145 
146 private:
148  void insertConnectionToMap( const ConnectionRef& rxConnection );
149 
150 private:
153 
154  ConnectionVector maConnections;
155  ConnectionMap maConnectionsById;
156  sal_Int32 mnUnusedId;
157 };
158 
159 } // namespace oox::xls
160 
161 #endif
162 
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
bool mbSaveData
True = refresh connection on import.
bool mbSavePassword
True = save cached data with connection.
sal_Int32 mnCredentials
Reconnection method.
sal_Int32 getConnectionType() const
Returns the source data type of the connection.
sal_Int32 mnType
Unique connection identifier.
Connection(const WorkbookHelper &rHelper)
sal_Int32 getConnectionId() const
Returns the unique connection identifier.
bool mbDeleted
True = new connection, never updated.
bool mbTextDates
True = web query created with Excel 97.
::std::vector< css::uno::Any > TablesVector
bool mbSourceData
True = XML query, false = HTML query.
OUString maSourceConnFile
URL of a source data file.
void importWebPrTables(SequenceInputStream &rStrm)
Imports web query table settings from the WEBPRTABLES record.
OUString maSsoId
URL of a source connection file.
const sal_Int32 BIFF12_CONNECTION_FILE
bool mbNew
True = keep connection open after import.
OUString maEditPage
POST method to query data.
OUString maDescription
Unique name of this connection.
sal_Int32 mnReconnectMethod
Data source type.
::std::unique_ptr< WebPrModel > WebPrModelPtr
ConnectionModel()
True = save password in connection string.
bool mbHtmlTables
True = refreshed with Excel 2000 or newer.
Common properties of an external data connection.
bool mbXml
Plain text, rich text, or HTML.
WebPrModel()
True = HTML tables, false = entire document.
const sal_Int32 BIFF12_CONNECTION_OLEDB
Connection & createConnection()
Creates a new empty connection.
RefMap< sal_Int32, Connection > ConnectionMap
std::shared_ptr< Connection > ConnectionRef
An external data connection (database, web query, etc.).
bool mbXl97Created
True = use column widths of first row for entire.
void finalizeImport()
Maps all connections by their identifier.
void importWebPr(const AttributeList &rAttribs)
Imports web query settings from the webPr element.
OUString maSourceFile
User description of this connection.
OUString maPostMethod
Source URL to refresh the data.
void importConnection(const AttributeList &rAttribs)
Imports connection settings from the connection element.
const sal_Int32 BIFF12_CONNECTION_TEXT
bool mbFirstRow
True = join consecutive delimiters.
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.
const sal_Int32 BIFF12_CONNECTION_ADO
Special properties for data connections representing web queries.
sal_Int32 mnHtmlFormat
Web page showing query data (for XML queries).
ConnectionsBuffer(const WorkbookHelper &rHelper)
bool mbConsecutive
True = parse preformatted sections (.
bool mbOnlyUseConnFile
True = connection has been deleted.
bool mbXl2000Refreshed
True = read date values as text, false = parse dates.
OUString maUrl
Names or indexes of the web query tables.
bool mbRefreshOnLoad
True = background refresh enabled.
void importTable(const AttributeList &rAttribs, sal_Int32 nElement)
Imports a web query table identifier from the m, s, or x element.
const ConnectionModel & getModel() const
Returns read-only access to the connection model data.
RefVector< Connection > ConnectionVector
const sal_Int32 BIFF12_CONNECTION_ODBC
const sal_Int32 BIFF12_CONNECTION_UNKNOWN
void insertConnectionToMap(const ConnectionRef &rxConnection)
Inserts the passed connection into the map according to its identifier.
OUString maName
Special settings for web queries.
bool mbParsePre
True = import XML source data referred by HTML table.
bool mbKeepAlive
Refresh interval in minutes.
sal_Int32 mnInterval
Credentials method.
const sal_Int32 BIFF12_CONNECTION_DAO
bool mbBackground
True = use maSourceConnFile, ignore mnReconnectMethod.
ConnectionRef getConnection(sal_Int32 nConnId) const
Returns a data connection by its unique identifier.
void SvStream & rStrm
sal_Int32 mnId
Single sign-on identifier.
const sal_Int32 BIFF12_CONNECTION_DSP
const sal_Int32 BIFF12_CONNECTION_HTML