merge the formfield patch from ooo-build
[ooovba.git] / oox / source / xls / webquerybuffer.cxx
blobe2c2329889b217f9ad4195d04cc0fc78b1047731
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: webquerybuffer.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/xls/webquerybuffer.hxx"
32 #include "oox/helper/attributelist.hxx"
34 #define DEBUG_OOX_WEBQUERY_BUFFER 1
36 #if DEBUG_OOX_WEBQUERY_BUFFER
37 #include <stdio.h>
38 #endif
40 using ::rtl::OUString;
42 namespace oox {
43 namespace xls {
45 const sal_Int32 Connection::CONNECTION_ODBC_SOURCE = 1;
46 const sal_Int32 Connection::CONNECTION_DAO_SOURCE = 2;
47 const sal_Int32 Connection::CONNECTION_FILE_SOURCE = 3;
48 const sal_Int32 Connection::CONNECTION_WEBQUERY = 4;
49 const sal_Int32 Connection::CONNECTION_OLEDB_SOURCE = 5;
50 const sal_Int32 Connection::CONNECTION_TEXT_SOURCE = 6;
51 const sal_Int32 Connection::CONNECTION_ADO_RECORD_SET = 7;
52 const sal_Int32 Connection::CONNECTION_DSP = 8;
54 // ============================================================================
56 WebQueryBuffer::WebQueryBuffer( const WorkbookHelper& rHelper ) :
57 WorkbookHelper( rHelper )
59 maQueryTableMap.clear();
62 void WebQueryBuffer::importQueryTable( const AttributeList& rAttribs )
64 OUString aName = rAttribs.getString( XML_name, OUString() );
65 if ( !aName.getLength() )
66 return;
68 QueryTable aQTable;
69 aQTable.mnConnectionId = rAttribs.getInteger( XML_connectionId, 0 );
71 maQueryTableMap.insert( QueryTableHashMap::value_type( aName, aQTable ) );
73 // All documented attributes of queryTable:
74 // adjustColumnWidth (bool)
75 // applyAlignmentFormats (bool)
76 // applyBorderFormats (bool)
77 // applyFontFormats (bool)
78 // applyNumberFormats (bool)
79 // applyPatternFormats (bool)
80 // applyWidthHeightFormats (bool)
81 // autoFormatId (unsigned int)
82 // backgroundRefresh (bool)
83 // connectionId (unsigned int)
84 // disableEdit (bool)
85 // disableRefresh (bool)
86 // fillFormulas (bool)
87 // firstBackgroundRefresh (bool)
88 // growShrinkType (insertClear, insertDelete, overwriteClear)
89 // headers (bool)
90 // intermediate (bool)
91 // name (string)
92 // preserveFormatting(bool)
93 // refreshOnLoad (bool)
94 // removeDataOnSave (bool)
95 // rowNumbers (bool)
98 void WebQueryBuffer::importConnection( const AttributeList& rAttribs )
100 if ( !rAttribs.hasAttribute( XML_id ) || !rAttribs.hasAttribute( XML_name ) )
102 mnCurConnId = -1;
103 return;
106 sal_uInt32 nId = rAttribs.getUnsigned( XML_id, 0 );
107 if ( maConnections.size() < (nId + 1) )
108 maConnections.resize(nId + 1);
110 Connection aConn;
111 aConn.maName = rAttribs.getString( XML_name, OUString() );
112 aConn.mnType = rAttribs.getInteger( XML_type, 0 );
113 maConnections[nId] = aConn;
114 mnCurConnId = nId;
116 // All documented attributes of connection.
117 // background (bool)
118 // credentials (integrated, none, prompt, stored)
119 // deleted (bool)
120 // description (string)
121 // id (unsigned int)
122 // interval (unsigned int)
123 // keepAlive (bool)
124 // minRefreshableVersion (unsigned byte)
125 // name (string)
126 // new (bool)
127 // odcFile (string)
128 // onlyUseConnectionFile (bool)
129 // reconnectionMethod (unsigned int)
130 // refreshedVersion (unsigned byte)
131 // refreshOnLoad (bool)
132 // saveData (bool)
133 // savePassword (bool)
134 // singleSignOnId (string)
135 // sourceFile (string)
136 // type (unsigned int)
139 void WebQueryBuffer::importWebPr( const AttributeList& rAttribs )
141 if ( 0 > mnCurConnId )
142 return;
144 Connection& rConn = maConnections[mnCurConnId];
145 rConn.mpProperties.reset( new WebProperties );
146 WebProperties* pWebPr = static_cast< WebProperties* >( rConn.mpProperties.get() );
147 pWebPr->maURL = rAttribs.getString( XML_url, OUString() );
149 // All available attributes:
150 // consecutive (bool)
151 // editPage (string)
152 // firstRow (bool)
153 // htmlFormat (all, none, rtf)
154 // htmlTables (bool)
155 // parsePre (bool)
156 // post (string)
157 // sourceData (bool)
158 // textDates (bool)
159 // url (string)
160 // xl2000 (bool)
161 // xl97 (bool)
162 // xml (bool)
165 void WebQueryBuffer::dump() const
167 #if DEBUG_OOX_WEBQUERY_BUFFER
168 fprintf(stdout, "----------------------------------------\n");
170 using ::std::vector;
171 vector< Connection >::const_iterator itr = maConnections.begin(), itrEnd = maConnections.end();
172 sal_Int32 nId = 0;
173 for (; itr != itrEnd; ++itr, ++nId)
175 if ( itr->mnType == Connection::CONNECTION_WEBQUERY )
177 WebProperties* pWebPr = static_cast< WebProperties* >( itr->mpProperties.get() );
178 fprintf(stdout, "WebQueryBuffer::dump: id = %d url = %s\n",
179 (int)nId,
180 OUStringToOString(pWebPr->maURL, RTL_TEXTENCODING_UTF8).getStr());
185 QueryTableHashMap::const_iterator itr = maQueryTableMap.begin(), itrEnd = maQueryTableMap.end();
186 for (; itr != itrEnd; ++itr)
188 fprintf(stdout, "WebQueryBuffer::dump: name = %s connection ID = %d\n",
189 OUStringToOString(itr->first, RTL_TEXTENCODING_UTF8).getStr(),
190 (int)(itr->second.mnConnectionId));
193 fprintf(stdout, "----------------------------------------\n");
194 fflush(stdout);
195 #endif
198 // ============================================================================
200 } // namespace xls
201 } // namespace oox