Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef OOX_XLS_CONNECTIONSBUFFER_HXX
30 : : #define OOX_XLS_CONNECTIONSBUFFER_HXX
31 : :
32 : : #include "oox/helper/refvector.hxx"
33 : : #include "workbookhelper.hxx"
34 : :
35 : : namespace oox {
36 : : namespace xls {
37 : :
38 : : // ============================================================================
39 : :
40 : : const sal_Int32 BIFF12_CONNECTION_UNKNOWN = 0;
41 : : const sal_Int32 BIFF12_CONNECTION_ODBC = 1;
42 : : const sal_Int32 BIFF12_CONNECTION_DAO = 2;
43 : : const sal_Int32 BIFF12_CONNECTION_FILE = 3;
44 : : const sal_Int32 BIFF12_CONNECTION_HTML = 4;
45 : : const sal_Int32 BIFF12_CONNECTION_OLEDB = 5;
46 : : const sal_Int32 BIFF12_CONNECTION_TEXT = 6;
47 : : const sal_Int32 BIFF12_CONNECTION_ADO = 7;
48 : : const sal_Int32 BIFF12_CONNECTION_DSP = 8;
49 : :
50 : : // ============================================================================
51 : :
52 : : /** Special properties for data connections representing web queries. */
53 : 0 : struct WebPrModel
54 : : {
55 : : typedef ::std::vector< ::com::sun::star::uno::Any > TablesVector;
56 : :
57 : : TablesVector maTables; /// Names or indexes of the web query tables.
58 : : ::rtl::OUString maUrl; /// Source URL to refresh the data.
59 : : ::rtl::OUString maPostMethod; /// POST method to query data.
60 : : ::rtl::OUString maEditPage; /// Web page showing query data (for XML queries).
61 : : sal_Int32 mnHtmlFormat; /// Plain text, rich text, or HTML.
62 : : bool mbXml; /// True = XML query, false = HTML query.
63 : : bool mbSourceData; /// True = import XML source data referred by HTML table.
64 : : bool mbParsePre; /// True = parse preformatted sections (<pre> tag).
65 : : bool mbConsecutive; /// True = join consecutive delimiters.
66 : : bool mbFirstRow; /// True = use column withs of first row for entire <pre> tag.
67 : : bool mbXl97Created; /// True = web query created with Excel 97.
68 : : bool mbTextDates; /// True = read date values as text, false = parse dates.
69 : : bool mbXl2000Refreshed; /// True = refreshed with Excel 2000 or newer.
70 : : bool mbHtmlTables; /// True = HTML tables, false = entire document.
71 : :
72 : : explicit WebPrModel();
73 : : };
74 : :
75 : : // ----------------------------------------------------------------------------
76 : :
77 : : /** Common properties of an external data connection. */
78 : 0 : struct ConnectionModel
79 : : {
80 : : typedef ::std::auto_ptr< WebPrModel > WebPrModelPtr;
81 : :
82 : : WebPrModelPtr mxWebPr; /// Special settings for web queries.
83 : : ::rtl::OUString maName; /// Unique name of this connection.
84 : : ::rtl::OUString maDescription; /// User description of this connection.
85 : : ::rtl::OUString maSourceFile; /// URL of a source data file.
86 : : ::rtl::OUString maSourceConnFile; /// URL of a source connection file.
87 : : ::rtl::OUString maSsoId; /// Single sign-on identifier.
88 : : sal_Int32 mnId; /// Unique connection identifier.
89 : : sal_Int32 mnType; /// Data source type.
90 : : sal_Int32 mnReconnectMethod; /// Reconnection method.
91 : : sal_Int32 mnCredentials; /// Credentials method.
92 : : sal_Int32 mnInterval; /// Refresh interval in minutes.
93 : : bool mbKeepAlive; /// True = keep connection open after import.
94 : : bool mbNew; /// True = new connection, never updated.
95 : : bool mbDeleted; /// True = connection has been deleted.
96 : : bool mbOnlyUseConnFile; /// True = use maSourceConnFile, ignore mnReconnectMethod.
97 : : bool mbBackground; /// True = background refresh enabled.
98 : : bool mbRefreshOnLoad; /// True = refresh connection on import.
99 : : bool mbSaveData; /// True = save cached data with connection.
100 : : bool mbSavePassword; /// True = save password in connection string.
101 : :
102 : : explicit ConnectionModel();
103 : :
104 : : WebPrModel& createWebPr();
105 : : };
106 : :
107 : : // ----------------------------------------------------------------------------
108 : :
109 : : /** An external data connection (database, web query, etc.). */
110 [ # # ][ # # ]: 0 : class Connection : public WorkbookHelper
111 : : {
112 : : public:
113 : : explicit Connection( const WorkbookHelper& rHelper, sal_Int32 nConnId = -1 );
114 : :
115 : : /** Imports connection settings from the connection element. */
116 : : void importConnection( const AttributeList& rAttribs );
117 : : /** Imports web query settings from the webPr element. */
118 : : void importWebPr( const AttributeList& rAttribs );
119 : : /** Imports web query table settings from the tables element. */
120 : : void importTables( const AttributeList& rAttribs );
121 : : /** Imports a web query table identifier from the m, s, or x element. */
122 : : void importTable( const AttributeList& rAttribs, sal_Int32 nElement );
123 : :
124 : : /** Imports connection settings from the CONNECTION record. */
125 : : void importConnection( SequenceInputStream& rStrm );
126 : : /** Imports web query settings from the WEBPR record. */
127 : : void importWebPr( SequenceInputStream& rStrm );
128 : : /** Imports web query table settings from the WEBPRTABLES record. */
129 : : void importWebPrTables( SequenceInputStream& rStrm );
130 : : /** Imports a web query table identifier from the PCITEM_MISSING, PCITEM_STRING, or PCITEM_INDEX record. */
131 : : void importWebPrTable( SequenceInputStream& rStrm, sal_Int32 nRecId );
132 : :
133 : : /** Returns the unique connection identifier. */
134 : 0 : inline sal_Int32 getConnectionId() const { return maModel.mnId; }
135 : : /** Returns the source data type of the connection. */
136 : 0 : inline sal_Int32 getConnectionType() const { return maModel.mnType; }
137 : : /** Returns read-only access to the connection model data. */
138 : 0 : const ConnectionModel& getModel() const { return maModel; }
139 : :
140 : : private:
141 : : ConnectionModel maModel;
142 : : };
143 : :
144 : : typedef ::boost::shared_ptr< Connection > ConnectionRef;
145 : :
146 : : // ============================================================================
147 : :
148 [ - + ]: 48 : class ConnectionsBuffer : public WorkbookHelper
149 : : {
150 : : public:
151 : : explicit ConnectionsBuffer( const WorkbookHelper& rHelper );
152 : :
153 : : /** Creates a new empty connection. */
154 : : Connection& createConnection();
155 : :
156 : : /** Maps all connections by their identifier. */
157 : : void finalizeImport();
158 : :
159 : : /** Returns a data connection by its unique identifier. */
160 : : ConnectionRef getConnection( sal_Int32 nConnId ) const;
161 : :
162 : : private:
163 : : /** Inserts the passed connection into the map according to its identifier. */
164 : : void insertConnectionToMap( const ConnectionRef& rxConnection );
165 : :
166 : : private:
167 : : typedef RefVector< Connection > ConnectionVector;
168 : : typedef RefMap< sal_Int32, Connection > ConnectionMap;
169 : :
170 : : ConnectionVector maConnections;
171 : : ConnectionMap maConnectionsById;
172 : : sal_Int32 mnUnusedId;
173 : : };
174 : :
175 : : // ============================================================================
176 : :
177 : : } // namespace xls
178 : : } // namespace oox
179 : :
180 : : #endif
181 : :
182 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|