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 $
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
40 using ::rtl::OUString
;
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() )
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)
85 // disableRefresh (bool)
86 // fillFormulas (bool)
87 // firstBackgroundRefresh (bool)
88 // growShrinkType (insertClear, insertDelete, overwriteClear)
90 // intermediate (bool)
92 // preserveFormatting(bool)
93 // refreshOnLoad (bool)
94 // removeDataOnSave (bool)
98 void WebQueryBuffer::importConnection( const AttributeList
& rAttribs
)
100 if ( !rAttribs
.hasAttribute( XML_id
) || !rAttribs
.hasAttribute( XML_name
) )
106 sal_uInt32 nId
= rAttribs
.getUnsigned( XML_id
, 0 );
107 if ( maConnections
.size() < (nId
+ 1) )
108 maConnections
.resize(nId
+ 1);
111 aConn
.maName
= rAttribs
.getString( XML_name
, OUString() );
112 aConn
.mnType
= rAttribs
.getInteger( XML_type
, 0 );
113 maConnections
[nId
] = aConn
;
116 // All documented attributes of connection.
118 // credentials (integrated, none, prompt, stored)
120 // description (string)
122 // interval (unsigned int)
124 // minRefreshableVersion (unsigned byte)
128 // onlyUseConnectionFile (bool)
129 // reconnectionMethod (unsigned int)
130 // refreshedVersion (unsigned byte)
131 // refreshOnLoad (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
)
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)
153 // htmlFormat (all, none, rtf)
165 void WebQueryBuffer::dump() const
167 #if DEBUG_OOX_WEBQUERY_BUFFER
168 fprintf(stdout
, "----------------------------------------\n");
171 vector
< Connection
>::const_iterator itr
= maConnections
.begin(), itrEnd
= maConnections
.end();
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",
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");
198 // ============================================================================