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 #pragma once
21 
22 #include <memory>
23 #include <oox/helper/refvector.hxx>
24 #include "workbookhelper.hxx"
25 
26 namespace oox { class AttributeList; }
27 namespace oox { class SequenceInputStream; }
28 
29 namespace oox::xls {
30 
31 const sal_Int32 BIFF12_CONNECTION_UNKNOWN = 0;
32 const sal_Int32 BIFF12_CONNECTION_ODBC = 1;
33 const sal_Int32 BIFF12_CONNECTION_DAO = 2;
34 const sal_Int32 BIFF12_CONNECTION_FILE = 3;
35 const sal_Int32 BIFF12_CONNECTION_HTML = 4;
36 const sal_Int32 BIFF12_CONNECTION_OLEDB = 5;
37 const sal_Int32 BIFF12_CONNECTION_TEXT = 6;
38 const sal_Int32 BIFF12_CONNECTION_ADO = 7;
39 const sal_Int32 BIFF12_CONNECTION_DSP = 8;
40 
42 struct WebPrModel
43 {
44  typedef ::std::vector< css::uno::Any > TablesVector;
45 
46  TablesVector maTables;
47  OUString maUrl;
48  OUString maPostMethod;
49  OUString maEditPage;
50  sal_Int32 mnHtmlFormat;
51  bool mbXml;
52  bool mbSourceData;
53  bool mbParsePre;
55  bool mbFirstRow;
57  bool mbTextDates;
59  bool mbHtmlTables;
60 
61  explicit WebPrModel();
62 };
63 
66 {
67  typedef ::std::unique_ptr< WebPrModel > WebPrModelPtr;
68 
69  WebPrModelPtr mxWebPr;
70  OUString maName;
71  OUString maDescription;
72  OUString maSourceFile;
73  OUString maSourceConnFile;
74  OUString maSsoId;
75  sal_Int32 mnId;
76  sal_Int32 mnType;
77  sal_Int32 mnReconnectMethod;
78  sal_Int32 mnCredentials;
79  sal_Int32 mnInterval;
80  bool mbKeepAlive;
81  bool mbNew;
82  bool mbDeleted;
84  bool mbBackground;
86  bool mbSaveData;
88 
89  explicit ConnectionModel();
90 
92 };
93 
95 class Connection final : public WorkbookHelper
96 {
97 public:
98  explicit Connection( const WorkbookHelper& rHelper );
99 
101  void importConnection( const AttributeList& rAttribs );
103  void importWebPr( const AttributeList& rAttribs );
105  void importTables();
107  void importTable( const AttributeList& rAttribs, sal_Int32 nElement );
108 
112  void importWebPr( SequenceInputStream& rStrm );
114  void importWebPrTables( SequenceInputStream& rStrm );
116  void importWebPrTable( SequenceInputStream& rStrm, sal_Int32 nRecId );
117 
119  sal_Int32 getConnectionId() const { return maModel.mnId; }
121  sal_Int32 getConnectionType() const { return maModel.mnType; }
123  const ConnectionModel& getModel() const { return maModel; }
124 
125 private:
127 };
128 
129 typedef std::shared_ptr< Connection > ConnectionRef;
130 
131 class ConnectionsBuffer final : public WorkbookHelper
132 {
133 public:
134  explicit ConnectionsBuffer( const WorkbookHelper& rHelper );
135 
138 
140  void finalizeImport();
141 
143  ConnectionRef getConnection( sal_Int32 nConnId ) const;
144 
145 private:
147  void insertConnectionToMap( const ConnectionRef& rxConnection );
148 
149 private:
152 
153  ConnectionVector maConnections;
154  ConnectionMap maConnectionsById;
155  sal_Int32 mnUnusedId;
156 };
157 
158 } // namespace oox::xls
159 
160 /* 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