re-enabled user-defined numeric fields for dBase export
[LibreOffice.git] / sc / source / filter / inc / connectionsbuffer.hxx
blobfdcba12e0f3ab4545280e12f210f9811a18f81ec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef OOX_XLS_CONNECTIONSBUFFER_HXX
21 #define OOX_XLS_CONNECTIONSBUFFER_HXX
23 #include "oox/helper/refvector.hxx"
24 #include "workbookhelper.hxx"
26 namespace oox {
27 namespace xls {
29 // ============================================================================
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;
41 // ============================================================================
43 /** Special properties for data connections representing web queries. */
44 struct WebPrModel
46 typedef ::std::vector< ::com::sun::star::uno::Any > TablesVector;
48 TablesVector maTables; /// Names or indexes of the web query tables.
49 OUString maUrl; /// Source URL to refresh the data.
50 OUString maPostMethod; /// POST method to query data.
51 OUString maEditPage; /// Web page showing query data (for XML queries).
52 sal_Int32 mnHtmlFormat; /// Plain text, rich text, or HTML.
53 bool mbXml; /// True = XML query, false = HTML query.
54 bool mbSourceData; /// True = import XML source data referred by HTML table.
55 bool mbParsePre; /// True = parse preformatted sections (<pre> tag).
56 bool mbConsecutive; /// True = join consecutive delimiters.
57 bool mbFirstRow; /// True = use column withs of first row for entire <pre> tag.
58 bool mbXl97Created; /// True = web query created with Excel 97.
59 bool mbTextDates; /// True = read date values as text, false = parse dates.
60 bool mbXl2000Refreshed; /// True = refreshed with Excel 2000 or newer.
61 bool mbHtmlTables; /// True = HTML tables, false = entire document.
63 explicit WebPrModel();
66 // ----------------------------------------------------------------------------
68 /** Common properties of an external data connection. */
69 struct ConnectionModel
71 typedef ::std::auto_ptr< WebPrModel > WebPrModelPtr;
73 WebPrModelPtr mxWebPr; /// Special settings for web queries.
74 OUString maName; /// Unique name of this connection.
75 OUString maDescription; /// User description of this connection.
76 OUString maSourceFile; /// URL of a source data file.
77 OUString maSourceConnFile; /// URL of a source connection file.
78 OUString maSsoId; /// Single sign-on identifier.
79 sal_Int32 mnId; /// Unique connection identifier.
80 sal_Int32 mnType; /// Data source type.
81 sal_Int32 mnReconnectMethod; /// Reconnection method.
82 sal_Int32 mnCredentials; /// Credentials method.
83 sal_Int32 mnInterval; /// Refresh interval in minutes.
84 bool mbKeepAlive; /// True = keep connection open after import.
85 bool mbNew; /// True = new connection, never updated.
86 bool mbDeleted; /// True = connection has been deleted.
87 bool mbOnlyUseConnFile; /// True = use maSourceConnFile, ignore mnReconnectMethod.
88 bool mbBackground; /// True = background refresh enabled.
89 bool mbRefreshOnLoad; /// True = refresh connection on import.
90 bool mbSaveData; /// True = save cached data with connection.
91 bool mbSavePassword; /// True = save password in connection string.
93 explicit ConnectionModel();
95 WebPrModel& createWebPr();
98 // ----------------------------------------------------------------------------
100 /** An external data connection (database, web query, etc.). */
101 class Connection : public WorkbookHelper
103 public:
104 explicit Connection( const WorkbookHelper& rHelper, sal_Int32 nConnId = -1 );
106 /** Imports connection settings from the connection element. */
107 void importConnection( const AttributeList& rAttribs );
108 /** Imports web query settings from the webPr element. */
109 void importWebPr( const AttributeList& rAttribs );
110 /** Imports web query table settings from the tables element. */
111 void importTables( const AttributeList& rAttribs );
112 /** Imports a web query table identifier from the m, s, or x element. */
113 void importTable( const AttributeList& rAttribs, sal_Int32 nElement );
115 /** Imports connection settings from the CONNECTION record. */
116 void importConnection( SequenceInputStream& rStrm );
117 /** Imports web query settings from the WEBPR record. */
118 void importWebPr( SequenceInputStream& rStrm );
119 /** Imports web query table settings from the WEBPRTABLES record. */
120 void importWebPrTables( SequenceInputStream& rStrm );
121 /** Imports a web query table identifier from the PCITEM_MISSING, PCITEM_STRING, or PCITEM_INDEX record. */
122 void importWebPrTable( SequenceInputStream& rStrm, sal_Int32 nRecId );
124 /** Returns the unique connection identifier. */
125 inline sal_Int32 getConnectionId() const { return maModel.mnId; }
126 /** Returns the source data type of the connection. */
127 inline sal_Int32 getConnectionType() const { return maModel.mnType; }
128 /** Returns read-only access to the connection model data. */
129 const ConnectionModel& getModel() const { return maModel; }
131 private:
132 ConnectionModel maModel;
135 typedef ::boost::shared_ptr< Connection > ConnectionRef;
137 // ============================================================================
139 class ConnectionsBuffer : public WorkbookHelper
141 public:
142 explicit ConnectionsBuffer( const WorkbookHelper& rHelper );
144 /** Creates a new empty connection. */
145 Connection& createConnection();
147 /** Maps all connections by their identifier. */
148 void finalizeImport();
150 /** Returns a data connection by its unique identifier. */
151 ConnectionRef getConnection( sal_Int32 nConnId ) const;
153 private:
154 /** Inserts the passed connection into the map according to its identifier. */
155 void insertConnectionToMap( const ConnectionRef& rxConnection );
157 private:
158 typedef RefVector< Connection > ConnectionVector;
159 typedef RefMap< sal_Int32, Connection > ConnectionMap;
161 ConnectionVector maConnections;
162 ConnectionMap maConnectionsById;
163 sal_Int32 mnUnusedId;
166 // ============================================================================
168 } // namespace xls
169 } // namespace oox
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */