196de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
396de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
496de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
596de5490SAndrew Rist * distributed with this work for additional information
696de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
796de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
896de5490SAndrew Rist * "License"); you may not use this file except in compliance
996de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
1196de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
1396de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
1496de5490SAndrew Rist * software distributed under the License is distributed on an
1596de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1696de5490SAndrew Rist * KIND, either express or implied. See the License for the
1796de5490SAndrew Rist * specific language governing permissions and limitations
1896de5490SAndrew Rist * under the License.
19cdf0e10cSrcweir *
2096de5490SAndrew Rist *************************************************************/
2196de5490SAndrew Rist
2296de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX
28cdf0e10cSrcweir #include "UITools.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _SFX_DOCFILT_HACK_HXX
31cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _DBACCESS_UI_CALLBACKS_HXX_
34cdf0e10cSrcweir #include "callbacks.hxx"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
37cdf0e10cSrcweir #include "dbustrings.hrc"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _DBU_RESOURCE_HRC_
40cdf0e10cSrcweir #include "dbu_resource.hrc"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef DBAUI_DLGSAVE_HXX
43cdf0e10cSrcweir #include "dlgsave.hxx"
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef DBAUI_DBTREELISTBOX_HXX
46cdf0e10cSrcweir #include "dbtreelistbox.hxx"
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
49cdf0e10cSrcweir #include "defaultobjectnamecheck.hxx"
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_
52cdf0e10cSrcweir #include <comphelper/extract.hxx>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_
55cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
58cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
61cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
64cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
67cdf0e10cSrcweir #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
70cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
73cdf0e10cSrcweir #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
76cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
79cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
80cdf0e10cSrcweir #endif
81cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
82cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAppend.hpp>
83cdf0e10cSrcweir #endif
84cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
85cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
86cdf0e10cSrcweir #endif
87cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
88cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
91cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
92cdf0e10cSrcweir #endif
93cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp>
94cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
95cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
98cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp>
99cdf0e10cSrcweir #endif
100cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
101cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
102cdf0e10cSrcweir #endif
103cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
104cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
105cdf0e10cSrcweir #endif
106cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
107cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
108cdf0e10cSrcweir #endif
109cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
110cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
111cdf0e10cSrcweir #endif
112cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_
113cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp>
114cdf0e10cSrcweir #endif
115cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
116cdf0e10cSrcweir #include <com/sun/star/sdb/XDocumentDataSource.hpp>
117cdf0e10cSrcweir #endif
118cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_
119cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp>
120cdf0e10cSrcweir #endif
121cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
122cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir #ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
125cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
126cdf0e10cSrcweir #endif
127cdf0e10cSrcweir #ifndef _VCL_STDTEXT_HXX
128cdf0e10cSrcweir #include <vcl/stdtext.hxx>
129cdf0e10cSrcweir #endif
130cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
131cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
132cdf0e10cSrcweir #endif
133cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
134cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
135cdf0e10cSrcweir #endif
136cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
137cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
138cdf0e10cSrcweir #endif
139cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
140cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
141cdf0e10cSrcweir #endif
142cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
143cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
144cdf0e10cSrcweir #endif
145cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
146cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
147cdf0e10cSrcweir #endif
148cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
149cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>
150cdf0e10cSrcweir #endif
151cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
152cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
153cdf0e10cSrcweir #endif
154cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
155cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
156cdf0e10cSrcweir #endif
157cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_
158cdf0e10cSrcweir #include <com/sun/star/awt/FontRelief.hpp>
159cdf0e10cSrcweir #endif
160cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_
161cdf0e10cSrcweir #include <com/sun/star/awt/FontWidth.hpp>
162cdf0e10cSrcweir #endif
163cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
164cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
165cdf0e10cSrcweir #endif
166cdf0e10cSrcweir #ifndef DBAUI_SBATTRDLG_HRC
167cdf0e10cSrcweir #include "dlgattr.hrc"
168cdf0e10cSrcweir #endif
169cdf0e10cSrcweir #ifndef DBAUI_TYPEINFO_HXX
170cdf0e10cSrcweir #include "TypeInfo.hxx"
171cdf0e10cSrcweir #endif
172cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX
173cdf0e10cSrcweir #include "FieldDescriptions.hxx"
174cdf0e10cSrcweir #endif
175cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_
176cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
177cdf0e10cSrcweir #endif
178cdf0e10cSrcweir #ifndef COMPHELPER_COMPONENTCONTEXT_HXX
179cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
180cdf0e10cSrcweir #endif
181cdf0e10cSrcweir
182cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
183cdf0e10cSrcweir #include <svx/svxids.hrc>
184cdf0e10cSrcweir #endif
185cdf0e10cSrcweir
186cdf0e10cSrcweir #define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
187cdf0e10cSrcweir #define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
188cdf0e10cSrcweir //#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION
189cdf0e10cSrcweir #define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
190cdf0e10cSrcweir #define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
191cdf0e10cSrcweir #define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO
192cdf0e10cSrcweir
193cdf0e10cSrcweir #ifndef _SFXITEMPOOL_HXX
194cdf0e10cSrcweir #include <svl/itempool.hxx>
195cdf0e10cSrcweir #endif
196cdf0e10cSrcweir #ifndef _STRING_HXX
197cdf0e10cSrcweir #include <tools/string.hxx>
198cdf0e10cSrcweir #endif
199cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_
200cdf0e10cSrcweir #include "dbaccess_helpid.hrc"
201cdf0e10cSrcweir #endif
202cdf0e10cSrcweir #ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet
203cdf0e10cSrcweir #include <svl/itemset.hxx>
204cdf0e10cSrcweir #endif
205cdf0e10cSrcweir #ifndef DBACCESS_SBA_GRID_HRC
206cdf0e10cSrcweir #include "sbagrid.hrc"
207cdf0e10cSrcweir #endif
208cdf0e10cSrcweir #ifndef _SFXRNGITEM_HXX
209cdf0e10cSrcweir #include <svl/rngitem.hxx>
210cdf0e10cSrcweir #endif
211cdf0e10cSrcweir #ifndef _SFXINTITEM_HXX
212cdf0e10cSrcweir #include <svl/intitem.hxx>
213cdf0e10cSrcweir #endif
214cdf0e10cSrcweir #ifndef _SVX_ALGITEM_HXX
215cdf0e10cSrcweir #include <svx/algitem.hxx>
216cdf0e10cSrcweir #endif
217cdf0e10cSrcweir #ifndef _SVX_NUMINF_HXX
218cdf0e10cSrcweir #include <svx/numinf.hxx>
219cdf0e10cSrcweir #endif
220cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE
221cdf0e10cSrcweir #ifndef _SVX_NUMINF_HXX
222cdf0e10cSrcweir #include <svx/numinf.hxx>
223cdf0e10cSrcweir #endif
224cdf0e10cSrcweir #ifndef _ZFORLIST_HXX
225cdf0e10cSrcweir #include <svl/zforlist.hxx>
226cdf0e10cSrcweir #endif
227cdf0e10cSrcweir #ifndef DBAUI_SBATTRDLG_HXX
228cdf0e10cSrcweir #include "dlgattr.hxx"
229cdf0e10cSrcweir #endif
230cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX
231cdf0e10cSrcweir #include <vcl/msgbox.hxx>
232cdf0e10cSrcweir #endif
233cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
234cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
235cdf0e10cSrcweir #endif
236cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
237cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
238cdf0e10cSrcweir #endif
239cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
240cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp>
241cdf0e10cSrcweir #endif
242cdf0e10cSrcweir #ifndef _DBU_MISC_HRC_
243cdf0e10cSrcweir #include "dbu_misc.hrc"
244cdf0e10cSrcweir #endif
245cdf0e10cSrcweir #ifndef _DBAUI_SQLMESSAGE_HXX_
246cdf0e10cSrcweir #include "sqlmessage.hxx"
247cdf0e10cSrcweir #endif
248cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
249cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp>
250cdf0e10cSrcweir #endif
251cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_URL_HPP_
252cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
253cdf0e10cSrcweir #endif
254cdf0e10cSrcweir #ifndef _SV_TOOLBOX_HXX
255cdf0e10cSrcweir #include <vcl/toolbox.hxx>
256cdf0e10cSrcweir #endif
257cdf0e10cSrcweir #ifndef _DBAUI_DLGSIZE_HXX
258cdf0e10cSrcweir #include "dlgsize.hxx"
259cdf0e10cSrcweir #endif
260cdf0e10cSrcweir #ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
261cdf0e10cSrcweir #include <svtools/editbrowsebox.hxx>
262cdf0e10cSrcweir #endif
263cdf0e10cSrcweir #ifndef _UTL_CONFIGMGR_HXX_
264cdf0e10cSrcweir #include <unotools/configmgr.hxx>
265cdf0e10cSrcweir #endif
266cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_HELPOPT_HXX
267cdf0e10cSrcweir #include <svtools/helpopt.hxx>
268cdf0e10cSrcweir #endif
269cdf0e10cSrcweir #ifndef _UCBHELPER_CONTENT_HXX
270cdf0e10cSrcweir #include <ucbhelper/content.hxx>
271cdf0e10cSrcweir #endif
272cdf0e10cSrcweir #ifndef _URLOBJ_HXX
273cdf0e10cSrcweir #include <tools/urlobj.hxx>
274cdf0e10cSrcweir #endif
275cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
276cdf0e10cSrcweir #include <tools/diagnose_ex.h>
277cdf0e10cSrcweir #endif
278cdf0e10cSrcweir #ifndef _NUMUNO_HXX
279cdf0e10cSrcweir #include <svl/numuno.hxx>
280cdf0e10cSrcweir #endif
281cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
282cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
283cdf0e10cSrcweir #endif
284cdf0e10cSrcweir #ifndef SVTOOLS_FILENOTATION_HXX_
285cdf0e10cSrcweir #include <svl/filenotation.hxx>
286cdf0e10cSrcweir #endif
287cdf0e10cSrcweir #ifndef _SVT_FILEVIEW_HXX
288cdf0e10cSrcweir #include <svtools/fileview.hxx>
289cdf0e10cSrcweir #endif
290cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_VALUE_HXX_
291cdf0e10cSrcweir #include <connectivity/FValue.hxx>
292cdf0e10cSrcweir #endif
293cdf0e10cSrcweir
294cdf0e10cSrcweir // .........................................................................
295cdf0e10cSrcweir namespace dbaui
296cdf0e10cSrcweir {
297cdf0e10cSrcweir // .........................................................................
298cdf0e10cSrcweir using namespace ::dbtools;
299cdf0e10cSrcweir using namespace ::comphelper;
300cdf0e10cSrcweir using namespace ::com::sun::star::uno;
301cdf0e10cSrcweir using namespace ::com::sun::star::task;
302cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
303cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
304cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
305cdf0e10cSrcweir using namespace ::com::sun::star::util;
306cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
307cdf0e10cSrcweir using namespace ::com::sun::star::beans;
308cdf0e10cSrcweir using namespace ::com::sun::star::container;
309cdf0e10cSrcweir using namespace ::com::sun::star::lang;
310cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
311cdf0e10cSrcweir using namespace ::svt;
312cdf0e10cSrcweir using ::com::sun::star::ucb::InteractiveIOException;
313cdf0e10cSrcweir using ::com::sun::star::ucb::IOErrorCode_NO_FILE;
314cdf0e10cSrcweir using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING;
315cdf0e10cSrcweir using ::com::sun::star::frame::XModel;
316cdf0e10cSrcweir
317cdf0e10cSrcweir // -----------------------------------------------------------------------------
createConnection(const::rtl::OUString & _rsDataSourceName,const Reference<::com::sun::star::container::XNameAccess> & _xDatabaseContext,const Reference<::com::sun::star::lang::XMultiServiceFactory> & _rMF,Reference<::com::sun::star::lang::XEventListener> & _rEvtLst,Reference<::com::sun::star::sdbc::XConnection> & _rOUTConnection)318cdf0e10cSrcweir SQLExceptionInfo createConnection( const ::rtl::OUString& _rsDataSourceName,
319cdf0e10cSrcweir const Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext,
320cdf0e10cSrcweir const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
321cdf0e10cSrcweir Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
322cdf0e10cSrcweir Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir Reference<XPropertySet> xProp;
325cdf0e10cSrcweir try
326cdf0e10cSrcweir {
327cdf0e10cSrcweir xProp.set(_xDatabaseContext->getByName(_rsDataSourceName),UNO_QUERY);
328cdf0e10cSrcweir }
329cdf0e10cSrcweir catch(Exception&)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir }
332cdf0e10cSrcweir SQLExceptionInfo aInfo;
333cdf0e10cSrcweir
334cdf0e10cSrcweir return createConnection(xProp,_rMF,_rEvtLst,_rOUTConnection);
335cdf0e10cSrcweir }
336cdf0e10cSrcweir // -----------------------------------------------------------------------------
createConnection(const Reference<::com::sun::star::beans::XPropertySet> & _xDataSource,const Reference<::com::sun::star::lang::XMultiServiceFactory> & _rMF,Reference<::com::sun::star::lang::XEventListener> & _rEvtLst,Reference<::com::sun::star::sdbc::XConnection> & _rOUTConnection)337cdf0e10cSrcweir SQLExceptionInfo createConnection( const Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource,
338cdf0e10cSrcweir const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
339cdf0e10cSrcweir Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
340cdf0e10cSrcweir Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir SQLExceptionInfo aInfo;
343cdf0e10cSrcweir if ( !_xDataSource.is() )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir OSL_ENSURE(0,"createConnection: coult not retrieve the data source!");
346cdf0e10cSrcweir return aInfo;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
349cdf0e10cSrcweir ::rtl::OUString sPwd, sUser;
350cdf0e10cSrcweir sal_Bool bPwdReq = sal_False;
351cdf0e10cSrcweir try
352cdf0e10cSrcweir {
353cdf0e10cSrcweir _xDataSource->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
354cdf0e10cSrcweir bPwdReq = ::cppu::any2bool(_xDataSource->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED));
355cdf0e10cSrcweir _xDataSource->getPropertyValue(PROPERTY_USER) >>= sUser;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir catch(Exception&)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir OSL_ENSURE(0,"createConnection: error while retrieving data source properties!");
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir
363cdf0e10cSrcweir try
364cdf0e10cSrcweir {
365cdf0e10cSrcweir if(bPwdReq && !sPwd.getLength())
366cdf0e10cSrcweir { // password required, but empty -> connect using an interaction handler
367cdf0e10cSrcweir Reference<XCompletedConnection> xConnectionCompletion(_xDataSource, UNO_QUERY);
368cdf0e10cSrcweir if (!xConnectionCompletion.is())
369cdf0e10cSrcweir {
370cdf0e10cSrcweir OSL_ENSURE(0,"createConnection: missing an interface ... need an error message here!");
371cdf0e10cSrcweir }
372cdf0e10cSrcweir else
373cdf0e10cSrcweir { // instantiate the default SDB interaction handler
374cdf0e10cSrcweir Reference< XInteractionHandler > xHandler(_rMF->createInstance(SERVICE_TASK_INTERACTION_HANDLER), UNO_QUERY);
375cdf0e10cSrcweir if (!xHandler.is())
376cdf0e10cSrcweir {
377cdf0e10cSrcweir OSL_ENSURE(sal_False, "createConnection: could not instantiate an interaction handler!");
378cdf0e10cSrcweir // ShowServiceNotAvailableError(NULL, String(SERVICE_TASK_INTERACTION_HANDLER), sal_True);
379cdf0e10cSrcweir // TODO: a real parent!
380cdf0e10cSrcweir }
381cdf0e10cSrcweir else
382cdf0e10cSrcweir _rOUTConnection = xConnectionCompletion->connectWithCompletion(xHandler);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir }
385cdf0e10cSrcweir else
386cdf0e10cSrcweir {
387cdf0e10cSrcweir Reference<XDataSource> xDataSource(_xDataSource,UNO_QUERY);
388cdf0e10cSrcweir _rOUTConnection = xDataSource->getConnection(sUser, sPwd);
389cdf0e10cSrcweir }
390cdf0e10cSrcweir // be notified when connection is in disposing
391cdf0e10cSrcweir Reference< XComponent > xComponent(_rOUTConnection, UNO_QUERY);
392cdf0e10cSrcweir if (xComponent.is() && _rEvtLst.is())
393cdf0e10cSrcweir xComponent->addEventListener(_rEvtLst);
394cdf0e10cSrcweir }
395cdf0e10cSrcweir catch(SQLContext& e) { aInfo = SQLExceptionInfo(e); }
396cdf0e10cSrcweir catch(SQLWarning& e) { aInfo = SQLExceptionInfo(e); }
397cdf0e10cSrcweir catch(SQLException& e) { aInfo = SQLExceptionInfo(e); }
398cdf0e10cSrcweir catch(Exception&) { OSL_ENSURE(0,"SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); }
399cdf0e10cSrcweir
400cdf0e10cSrcweir // showError(aInfo);
401cdf0e10cSrcweir
402cdf0e10cSrcweir return aInfo;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDataSourceByName(const::rtl::OUString & _rDataSourceName,Window * _pErrorMessageParent,Reference<XMultiServiceFactory> _rxORB,::dbtools::SQLExceptionInfo * _pErrorInfo)405cdf0e10cSrcweir Reference< XDataSource > getDataSourceByName( const ::rtl::OUString& _rDataSourceName,
406cdf0e10cSrcweir Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, ::dbtools::SQLExceptionInfo* _pErrorInfo )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir ::comphelper::ComponentContext aContext( _rxORB );
409cdf0e10cSrcweir Reference< XNameAccess > xDatabaseContext( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
410cdf0e10cSrcweir
411cdf0e10cSrcweir Reference< XDataSource > xDatasource;
412cdf0e10cSrcweir Any aError;
413cdf0e10cSrcweir SQLExceptionInfo aSQLError;
414cdf0e10cSrcweir try
415cdf0e10cSrcweir {
416cdf0e10cSrcweir xDatabaseContext->getByName( _rDataSourceName ) >>= xDatasource;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir catch(const WrappedTargetException& e)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir InteractiveIOException aIOException;
421cdf0e10cSrcweir if ( ( e.TargetException >>= aIOException )
422cdf0e10cSrcweir && ( ( aIOException.Code == IOErrorCode_NO_FILE )
423cdf0e10cSrcweir || ( aIOException.Code == IOErrorCode_NOT_EXISTING )
424cdf0e10cSrcweir )
425cdf0e10cSrcweir )
426cdf0e10cSrcweir {
427cdf0e10cSrcweir String sErrorMessage = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) );
428cdf0e10cSrcweir OFileNotation aTransformer( e.Message );
429cdf0e10cSrcweir sErrorMessage.SearchAndReplaceAscii( "$file$", aTransformer.get( OFileNotation::N_SYSTEM ) );
430cdf0e10cSrcweir aSQLError = SQLExceptionInfo( sErrorMessage ).get();
431cdf0e10cSrcweir }
432cdf0e10cSrcweir else
433cdf0e10cSrcweir {
434cdf0e10cSrcweir aSQLError = SQLExceptionInfo( e.TargetException );
435cdf0e10cSrcweir if ( !aSQLError.isValid() )
436cdf0e10cSrcweir aError = e.TargetException;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir }
439cdf0e10cSrcweir catch( const Exception& )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir if ( xDatasource.is() )
445cdf0e10cSrcweir return xDatasource;
446cdf0e10cSrcweir
447cdf0e10cSrcweir if ( aSQLError.isValid() )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir if ( _pErrorInfo )
450cdf0e10cSrcweir {
451cdf0e10cSrcweir *_pErrorInfo = aSQLError;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir else
454cdf0e10cSrcweir {
455cdf0e10cSrcweir showError( aSQLError, _pErrorMessageParent, _rxORB );
456cdf0e10cSrcweir }
457cdf0e10cSrcweir }
458cdf0e10cSrcweir
459cdf0e10cSrcweir return Reference<XDataSource>();
460cdf0e10cSrcweir }
461cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDataSourceOrModel(const Reference<XInterface> & _xObject)462cdf0e10cSrcweir Reference< XInterface > getDataSourceOrModel(const Reference< XInterface >& _xObject)
463cdf0e10cSrcweir {
464cdf0e10cSrcweir Reference< XInterface > xRet;
465cdf0e10cSrcweir Reference<XDocumentDataSource> xDocumentDataSource(_xObject,UNO_QUERY);
466cdf0e10cSrcweir if ( xDocumentDataSource.is() )
467cdf0e10cSrcweir xRet = xDocumentDataSource->getDatabaseDocument();
468cdf0e10cSrcweir
469cdf0e10cSrcweir if ( !xRet.is() )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir Reference<XOfficeDatabaseDocument> xOfficeDoc(_xObject,UNO_QUERY);
472cdf0e10cSrcweir if ( xOfficeDoc.is() )
473cdf0e10cSrcweir xRet = xOfficeDoc->getDataSource();
474cdf0e10cSrcweir }
475cdf0e10cSrcweir
476cdf0e10cSrcweir return xRet;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir // -----------------------------------------------------------------------------
showError(const SQLExceptionInfo & _rInfo,Window * _pParent,const Reference<XMultiServiceFactory> & _xFactory)479cdf0e10cSrcweir void showError(const SQLExceptionInfo& _rInfo,Window* _pParent,const Reference< XMultiServiceFactory >& _xFactory)
480cdf0e10cSrcweir {
481cdf0e10cSrcweir OSL_ENSURE(_pParent,"showError: Parent window must be NOT NULL!");
482cdf0e10cSrcweir ::dbtools::showError(_rInfo,VCLUnoHelper::GetInterface(_pParent),_xFactory);
483cdf0e10cSrcweir }
484cdf0e10cSrcweir
485cdf0e10cSrcweir // -----------------------------------------------------------------------------
getKeyColumns(const Reference<XIndexAccess> & _rxKeys,sal_Int32 _nKeyType)486cdf0e10cSrcweir ::std::vector< Reference<XNameAccess> > getKeyColumns(const Reference<XIndexAccess >& _rxKeys,
487cdf0e10cSrcweir sal_Int32 _nKeyType)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir // use keys and indexes for excat postioning
490cdf0e10cSrcweir // first the keys
491cdf0e10cSrcweir ::std::vector< Reference<XNameAccess> > vRet;
492cdf0e10cSrcweir if(_rxKeys.is())
493cdf0e10cSrcweir {
494cdf0e10cSrcweir Reference<XPropertySet> xProp;
495cdf0e10cSrcweir for(sal_Int32 i=0;i< _rxKeys->getCount();++i)
496cdf0e10cSrcweir {
497cdf0e10cSrcweir _rxKeys->getByIndex(i) >>= xProp;
498cdf0e10cSrcweir sal_Int32 nKeyType = 0;
499cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
500cdf0e10cSrcweir if(_nKeyType == nKeyType)
501cdf0e10cSrcweir {
502cdf0e10cSrcweir Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY);
503cdf0e10cSrcweir OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
504cdf0e10cSrcweir vRet.push_back(xKeyColsSup->getColumns());
505cdf0e10cSrcweir }
506cdf0e10cSrcweir }
507cdf0e10cSrcweir }
508cdf0e10cSrcweir
509cdf0e10cSrcweir return vRet;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir // -----------------------------------------------------------------------------
512cdf0e10cSrcweir
getTypeInfoFromType(const OTypeInfoMap & _rTypeInfo,sal_Int32 _nType,const::rtl::OUString & _sTypeName,const::rtl::OUString & _sCreateParams,sal_Int32 _nPrecision,sal_Int32 _nScale,sal_Bool _bAutoIncrement,sal_Bool & _brForceToType)513cdf0e10cSrcweir TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
514cdf0e10cSrcweir sal_Int32 _nType,
515cdf0e10cSrcweir const ::rtl::OUString& _sTypeName,
516cdf0e10cSrcweir const ::rtl::OUString& _sCreateParams,
517cdf0e10cSrcweir sal_Int32 _nPrecision,
518cdf0e10cSrcweir sal_Int32 _nScale,
519cdf0e10cSrcweir sal_Bool _bAutoIncrement,
520cdf0e10cSrcweir sal_Bool& _brForceToType)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir TOTypeInfoSP pTypeInfo;
523cdf0e10cSrcweir _brForceToType = sal_False;
524cdf0e10cSrcweir // search for type
525cdf0e10cSrcweir ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
526cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = aPair.first;
527cdf0e10cSrcweir if(aIter != _rTypeInfo.end()) // compare with end is correct here
528cdf0e10cSrcweir {
529cdf0e10cSrcweir for(;aIter != aPair.second;++aIter)
530cdf0e10cSrcweir {
531cdf0e10cSrcweir // search the best matching type
532cdf0e10cSrcweir #ifdef DBG_UTIL
533cdf0e10cSrcweir ::rtl::OUString sDBTypeName = aIter->second->aTypeName; (void)sDBTypeName;
534cdf0e10cSrcweir sal_Int32 nDBTypePrecision = aIter->second->nPrecision; (void)nDBTypePrecision;
535cdf0e10cSrcweir sal_Int32 nDBTypeScale = aIter->second->nMaximumScale; (void)nDBTypeScale;
536cdf0e10cSrcweir sal_Bool bDBAutoIncrement = aIter->second->bAutoIncrement; (void)bDBAutoIncrement;
537cdf0e10cSrcweir #endif
538cdf0e10cSrcweir if ( (
539cdf0e10cSrcweir !_sTypeName.getLength()
540cdf0e10cSrcweir || (aIter->second->aTypeName.equalsIgnoreAsciiCase(_sTypeName))
541cdf0e10cSrcweir )
542cdf0e10cSrcweir && (
543cdf0e10cSrcweir (
544cdf0e10cSrcweir !aIter->second->aCreateParams.getLength()
545cdf0e10cSrcweir && !_sCreateParams.getLength()
546cdf0e10cSrcweir )
547cdf0e10cSrcweir || (
548cdf0e10cSrcweir (aIter->second->nPrecision >= _nPrecision)
549cdf0e10cSrcweir && (aIter->second->nMaximumScale >= _nScale)
550cdf0e10cSrcweir && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
551cdf0e10cSrcweir )
552cdf0e10cSrcweir )
553cdf0e10cSrcweir )
554cdf0e10cSrcweir break;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir
557cdf0e10cSrcweir if (aIter == aPair.second)
558cdf0e10cSrcweir {
559cdf0e10cSrcweir for(aIter = aPair.first; aIter != aPair.second; ++aIter)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir sal_Int32 nPrec = aIter->second->nPrecision;
562cdf0e10cSrcweir sal_Int32 nScale = aIter->second->nMaximumScale;
563cdf0e10cSrcweir // search the best matching type (now comparing the local names)
564cdf0e10cSrcweir if ( (aIter->second->aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
565cdf0e10cSrcweir && (nPrec >= _nPrecision)
566cdf0e10cSrcweir && (nScale >= _nScale)
567cdf0e10cSrcweir && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
568cdf0e10cSrcweir )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir OSL_ENSURE(sal_False,
571cdf0e10cSrcweir ( ::rtl::OString("getTypeInfoFromType: assuming column type ")
572cdf0e10cSrcweir += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
573cdf0e10cSrcweir += ::rtl::OString("\" (expected type name ")
574cdf0e10cSrcweir += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
575cdf0e10cSrcweir += ::rtl::OString(" matches the type's local name).")).getStr());
576cdf0e10cSrcweir break;
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
581cdf0e10cSrcweir if (aIter == aPair.second)
582cdf0e10cSrcweir { // no match for the names, no match for the local names
583cdf0e10cSrcweir // -> drop the precision and the scale restriction, accept any type with the property
584cdf0e10cSrcweir // type id (nType)
585cdf0e10cSrcweir
586cdf0e10cSrcweir //OSL_ENSURE(sal_False,
587cdf0e10cSrcweir // ( ::rtl::OString("getTypeInfoFromType: did not find a matching type")
588cdf0e10cSrcweir // += ::rtl::OString(" (expected type name: ")
589cdf0e10cSrcweir // += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
590cdf0e10cSrcweir // += ::rtl::OString(")! Defaulting to the first matching type.")).getStr());
591cdf0e10cSrcweir for(aIter = aPair.first; aIter != aPair.second; ++aIter)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir // search the best matching type (now comparing the local names)
594cdf0e10cSrcweir #ifdef DBG_UTIL
595cdf0e10cSrcweir ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
596cdf0e10cSrcweir #endif
597cdf0e10cSrcweir sal_Int32 nPrec = aIter->second->nPrecision;
598cdf0e10cSrcweir sal_Int32 nScale = aIter->second->nMaximumScale;
599cdf0e10cSrcweir if ( (nPrec >= _nPrecision)
600cdf0e10cSrcweir && (nScale >= _nScale)
601cdf0e10cSrcweir && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
602cdf0e10cSrcweir )
603cdf0e10cSrcweir break;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir }
606cdf0e10cSrcweir if (aIter == aPair.second)
607cdf0e10cSrcweir {
608cdf0e10cSrcweir if ( _bAutoIncrement )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir for(aIter = aPair.first; aIter != aPair.second; ++aIter)
611cdf0e10cSrcweir {
612cdf0e10cSrcweir // search the best matching type (now comparing the local names)
613cdf0e10cSrcweir #ifdef DBG_UTIL
614cdf0e10cSrcweir ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
615cdf0e10cSrcweir #endif
616cdf0e10cSrcweir sal_Int32 nScale = aIter->second->nMaximumScale;
617cdf0e10cSrcweir if ( (nScale >= _nScale)
618cdf0e10cSrcweir && (aIter->second->bAutoIncrement == _bAutoIncrement)
619cdf0e10cSrcweir )
620cdf0e10cSrcweir break;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir if ( aIter == aPair.second )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir // try it without the auto increment flag
625cdf0e10cSrcweir pTypeInfo = getTypeInfoFromType(_rTypeInfo,
626cdf0e10cSrcweir _nType,
627cdf0e10cSrcweir _sTypeName,
628cdf0e10cSrcweir _sCreateParams,
629cdf0e10cSrcweir _nPrecision,
630cdf0e10cSrcweir _nScale,
631cdf0e10cSrcweir sal_False,
632cdf0e10cSrcweir _brForceToType);
633cdf0e10cSrcweir }
634cdf0e10cSrcweir else
635cdf0e10cSrcweir pTypeInfo = aIter->second;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir else
638cdf0e10cSrcweir {
639cdf0e10cSrcweir pTypeInfo = aPair.first->second;
640cdf0e10cSrcweir _brForceToType = sal_True;
641cdf0e10cSrcweir }
642cdf0e10cSrcweir }
643cdf0e10cSrcweir else
644cdf0e10cSrcweir pTypeInfo = aIter->second;
645cdf0e10cSrcweir }
646cdf0e10cSrcweir else
647cdf0e10cSrcweir {
648cdf0e10cSrcweir ::comphelper::TStringMixEqualFunctor aCase(sal_False);
649cdf0e10cSrcweir // search for typeinfo where the typename is equal _sTypeName
650cdf0e10cSrcweir OTypeInfoMap::const_iterator typeInfoLoop = _rTypeInfo.begin();
651cdf0e10cSrcweir OTypeInfoMap::const_iterator typeInfoEnd = _rTypeInfo.end();
652cdf0e10cSrcweir for (; typeInfoLoop != typeInfoEnd; ++typeInfoLoop)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir if ( aCase( typeInfoLoop->second->getDBName() , _sTypeName ) )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir pTypeInfo = typeInfoLoop->second;
657cdf0e10cSrcweir break;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir }
660cdf0e10cSrcweir }
661cdf0e10cSrcweir
662cdf0e10cSrcweir OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
663cdf0e10cSrcweir return pTypeInfo;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillTypeInfo(const Reference<::com::sun::star::sdbc::XConnection> & _rxConnection,const String & _rsTypeNames,OTypeInfoMap & _rTypeInfoMap,::std::vector<OTypeInfoMap::iterator> & _rTypeInfoIters)666cdf0e10cSrcweir void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
667cdf0e10cSrcweir const String& _rsTypeNames,
668cdf0e10cSrcweir OTypeInfoMap& _rTypeInfoMap,
669cdf0e10cSrcweir ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters)
670cdf0e10cSrcweir {
671cdf0e10cSrcweir if(!_rxConnection.is())
672cdf0e10cSrcweir return;
673cdf0e10cSrcweir Reference< XResultSet> xRs = _rxConnection->getMetaData ()->getTypeInfo ();
674cdf0e10cSrcweir Reference< XRow> xRow(xRs,UNO_QUERY);
675cdf0e10cSrcweir // Information for a single SQL type
676cdf0e10cSrcweir if(xRs.is())
677cdf0e10cSrcweir {
678cdf0e10cSrcweir static const ::rtl::OUString aB1 = ::rtl::OUString::createFromAscii(" [ ");
679cdf0e10cSrcweir static const ::rtl::OUString aB2 = ::rtl::OUString::createFromAscii(" ]");
680cdf0e10cSrcweir Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData();
681cdf0e10cSrcweir ::connectivity::ORowSetValue aValue;
682cdf0e10cSrcweir ::std::vector<sal_Int32> aTypes;
683cdf0e10cSrcweir ::std::vector<sal_Bool> aNullable;
684cdf0e10cSrcweir // Loop on the result set until we reach end of file
685cdf0e10cSrcweir while (xRs->next())
686cdf0e10cSrcweir {
687cdf0e10cSrcweir TOTypeInfoSP pInfo(new OTypeInfo());
688cdf0e10cSrcweir sal_Int32 nPos = 1;
689cdf0e10cSrcweir if ( aTypes.empty() )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir sal_Int32 nCount = xResultSetMetaData->getColumnCount();
692cdf0e10cSrcweir if ( nCount < 1 )
693cdf0e10cSrcweir nCount = 18;
694cdf0e10cSrcweir aTypes.reserve(nCount+1);
695cdf0e10cSrcweir aTypes.push_back(-1);
696cdf0e10cSrcweir aNullable.push_back(sal_False);
697cdf0e10cSrcweir for (sal_Int32 j = 1; j <= nCount ; ++j)
698cdf0e10cSrcweir {
699cdf0e10cSrcweir aTypes.push_back(xResultSetMetaData->getColumnType(j));
700cdf0e10cSrcweir aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS);
701cdf0e10cSrcweir }
702cdf0e10cSrcweir }
703cdf0e10cSrcweir
704cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
705cdf0e10cSrcweir pInfo->aTypeName = aValue;
706cdf0e10cSrcweir ++nPos;
707cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
708cdf0e10cSrcweir pInfo->nType = aValue;
709cdf0e10cSrcweir ++nPos;
710cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
711cdf0e10cSrcweir pInfo->nPrecision = aValue;
712cdf0e10cSrcweir ++nPos;
713cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
714cdf0e10cSrcweir pInfo->aLiteralPrefix = aValue;
715cdf0e10cSrcweir ++nPos;
716cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
717cdf0e10cSrcweir pInfo->aLiteralSuffix = aValue;
718cdf0e10cSrcweir ++nPos;
719cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
720cdf0e10cSrcweir pInfo->aCreateParams = aValue;
721cdf0e10cSrcweir ++nPos;
722cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
723cdf0e10cSrcweir pInfo->bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE;
724cdf0e10cSrcweir ++nPos;
725cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
726cdf0e10cSrcweir pInfo->bCaseSensitive = (sal_Bool)aValue;
727cdf0e10cSrcweir ++nPos;
728cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
729cdf0e10cSrcweir pInfo->nSearchType = aValue;
730cdf0e10cSrcweir ++nPos;
731cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
732cdf0e10cSrcweir pInfo->bUnsigned = (sal_Bool)aValue;
733cdf0e10cSrcweir ++nPos;
734cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
735cdf0e10cSrcweir pInfo->bCurrency = (sal_Bool)aValue;
736cdf0e10cSrcweir ++nPos;
737cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
738cdf0e10cSrcweir pInfo->bAutoIncrement = (sal_Bool)aValue;
739cdf0e10cSrcweir ++nPos;
740cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
741cdf0e10cSrcweir pInfo->aLocalTypeName = aValue;
742cdf0e10cSrcweir ++nPos;
743cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
744cdf0e10cSrcweir pInfo->nMinimumScale = aValue;
745cdf0e10cSrcweir ++nPos;
746cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
747cdf0e10cSrcweir pInfo->nMaximumScale = aValue;
748cdf0e10cSrcweir nPos = 18;
749cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
750cdf0e10cSrcweir
751cdf0e10cSrcweir // check if values are less than zero like it happens in a oracle jdbc driver
752cdf0e10cSrcweir if( pInfo->nPrecision < 0)
753cdf0e10cSrcweir pInfo->nPrecision = 0;
754cdf0e10cSrcweir if( pInfo->nMinimumScale < 0)
755cdf0e10cSrcweir pInfo->nMinimumScale = 0;
756cdf0e10cSrcweir if( pInfo->nMaximumScale < 0)
757cdf0e10cSrcweir pInfo->nMaximumScale = 0;
758cdf0e10cSrcweir
759cdf0e10cSrcweir String aName;
760cdf0e10cSrcweir switch(pInfo->nType)
761cdf0e10cSrcweir {
762cdf0e10cSrcweir case DataType::CHAR:
763cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_CHAR);
764cdf0e10cSrcweir break;
765cdf0e10cSrcweir case DataType::VARCHAR:
766cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_TEXT);
767cdf0e10cSrcweir break;
768cdf0e10cSrcweir case DataType::DECIMAL:
769cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DECIMAL);
770cdf0e10cSrcweir break;
771cdf0e10cSrcweir case DataType::NUMERIC:
772cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_NUMERIC);
773cdf0e10cSrcweir break;
774cdf0e10cSrcweir case DataType::BIGINT:
775cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BIGINT);
776cdf0e10cSrcweir break;
777cdf0e10cSrcweir case DataType::FLOAT:
778cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_FLOAT);
779cdf0e10cSrcweir break;
780cdf0e10cSrcweir case DataType::DOUBLE:
781cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DOUBLE);
782cdf0e10cSrcweir break;
783cdf0e10cSrcweir case DataType::LONGVARCHAR:
784cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_MEMO);
785cdf0e10cSrcweir break;
786cdf0e10cSrcweir case DataType::LONGVARBINARY:
787cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_IMAGE);
788cdf0e10cSrcweir break;
789cdf0e10cSrcweir case DataType::DATE:
790cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DATE);
791cdf0e10cSrcweir break;
792cdf0e10cSrcweir case DataType::TIME:
793cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_TIME);
794cdf0e10cSrcweir break;
795cdf0e10cSrcweir case DataType::TIMESTAMP:
796cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DATETIME);
797cdf0e10cSrcweir break;
798cdf0e10cSrcweir case DataType::BIT:
799cdf0e10cSrcweir if ( pInfo->aCreateParams.getLength() )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BIT);
802cdf0e10cSrcweir break;
803cdf0e10cSrcweir }
804cdf0e10cSrcweir // run through
805cdf0e10cSrcweir case DataType::BOOLEAN:
806cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BOOL);
807cdf0e10cSrcweir break;
808cdf0e10cSrcweir case DataType::TINYINT:
809cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_TINYINT);
810cdf0e10cSrcweir break;
811cdf0e10cSrcweir case DataType::SMALLINT:
812cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_SMALLINT);
813cdf0e10cSrcweir break;
814cdf0e10cSrcweir case DataType::INTEGER:
815cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_INTEGER);
816cdf0e10cSrcweir break;
817cdf0e10cSrcweir case DataType::REAL:
818cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_REAL);
819cdf0e10cSrcweir break;
820cdf0e10cSrcweir case DataType::BINARY:
821cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BINARY);
822cdf0e10cSrcweir break;
823cdf0e10cSrcweir case DataType::VARBINARY:
824cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_VARBINARY);
825cdf0e10cSrcweir break;
826cdf0e10cSrcweir case DataType::SQLNULL:
827cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_SQLNULL);
828cdf0e10cSrcweir break;
829cdf0e10cSrcweir case DataType::OBJECT:
830cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_OBJECT);
831cdf0e10cSrcweir break;
832cdf0e10cSrcweir case DataType::DISTINCT:
833cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DISTINCT);
834cdf0e10cSrcweir break;
835cdf0e10cSrcweir case DataType::STRUCT:
836cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_STRUCT);
837cdf0e10cSrcweir break;
838cdf0e10cSrcweir case DataType::ARRAY:
839cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_ARRAY);
840cdf0e10cSrcweir break;
841cdf0e10cSrcweir case DataType::BLOB:
842cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BLOB);
843cdf0e10cSrcweir break;
844cdf0e10cSrcweir case DataType::CLOB:
845cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_CLOB);
846cdf0e10cSrcweir break;
847cdf0e10cSrcweir case DataType::REF:
848cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_REF);
849cdf0e10cSrcweir break;
850cdf0e10cSrcweir case DataType::OTHER:
851cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_OTHER);
852cdf0e10cSrcweir break;
853cdf0e10cSrcweir }
854cdf0e10cSrcweir if ( aName.Len() )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir pInfo->aUIName = aName.GetBuffer();
857cdf0e10cSrcweir pInfo->aUIName += aB1;
858cdf0e10cSrcweir }
859cdf0e10cSrcweir pInfo->aUIName += pInfo->aTypeName;
860cdf0e10cSrcweir if ( aName.Len() )
861cdf0e10cSrcweir pInfo->aUIName += aB2;
862cdf0e10cSrcweir // Now that we have the type info, save it in the multimap
863cdf0e10cSrcweir _rTypeInfoMap.insert(OTypeInfoMap::value_type(pInfo->nType,pInfo));
864cdf0e10cSrcweir }
865cdf0e10cSrcweir // for a faster index access
866cdf0e10cSrcweir _rTypeInfoIters.reserve(_rTypeInfoMap.size());
867cdf0e10cSrcweir
868cdf0e10cSrcweir OTypeInfoMap::iterator aIter = _rTypeInfoMap.begin();
869cdf0e10cSrcweir OTypeInfoMap::iterator aEnd = _rTypeInfoMap.end();
870cdf0e10cSrcweir for(;aIter != aEnd;++aIter)
871cdf0e10cSrcweir _rTypeInfoIters.push_back(aIter);
872cdf0e10cSrcweir
873cdf0e10cSrcweir // Close the result set/statement.
874cdf0e10cSrcweir
875cdf0e10cSrcweir ::comphelper::disposeComponent(xRs);
876cdf0e10cSrcweir }
877cdf0e10cSrcweir }
878cdf0e10cSrcweir // -----------------------------------------------------------------------------
setColumnProperties(const Reference<XPropertySet> & _rxColumn,const OFieldDescription * _pFieldDesc)879cdf0e10cSrcweir void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDescription* _pFieldDesc)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_NAME,makeAny(_pFieldDesc->GetName()));
882cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_TYPENAME,makeAny(_pFieldDesc->getTypeInfo()->aTypeName));
883cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_TYPE,makeAny(_pFieldDesc->GetType()));
884cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_PRECISION,makeAny(_pFieldDesc->GetPrecision()));
885cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_SCALE,makeAny(_pFieldDesc->GetScale()));
886cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(_pFieldDesc->GetIsNullable()));
887cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT,::cppu::bool2any(_pFieldDesc->IsAutoIncrement()));
888cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_pFieldDesc->GetDescription()));
889cdf0e10cSrcweir if ( _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISCURRENCY) && _pFieldDesc->IsCurrency() )
890cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(_pFieldDesc->IsCurrency()));
891cdf0e10cSrcweir // set autoincrement value when available
892cdf0e10cSrcweir // and only set when the entry is not empty, that lets the value in the column untouched
893cdf0e10cSrcweir if ( _pFieldDesc->IsAutoIncrement() && _pFieldDesc->GetAutoIncrementValue().getLength() && _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
894cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_pFieldDesc->GetAutoIncrementValue()));
895cdf0e10cSrcweir }
896cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDefaultName(const Reference<XDatabaseMetaData> & _xMetaData,const Reference<XNameAccess> & _xTables,const::rtl::OUString & _sName)897cdf0e10cSrcweir ::rtl::OUString createDefaultName(const Reference< XDatabaseMetaData>& _xMetaData,const Reference<XNameAccess>& _xTables,const ::rtl::OUString& _sName)
898cdf0e10cSrcweir {
899cdf0e10cSrcweir OSL_ENSURE(_xMetaData.is(),"No MetaData!");
900cdf0e10cSrcweir ::rtl::OUString sDefaultName = _sName;
901cdf0e10cSrcweir try
902cdf0e10cSrcweir {
903cdf0e10cSrcweir ::rtl::OUString sCatalog,sSchema,sCompsedName;
904cdf0e10cSrcweir if(_xMetaData->supportsCatalogsInTableDefinitions())
905cdf0e10cSrcweir {
906cdf0e10cSrcweir try
907cdf0e10cSrcweir {
908cdf0e10cSrcweir Reference< XConnection> xCon = _xMetaData->getConnection();
909cdf0e10cSrcweir if ( xCon.is() )
910cdf0e10cSrcweir sCatalog = xCon->getCatalog();
911cdf0e10cSrcweir if ( !sCatalog.getLength() )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir Reference<XResultSet> xRes = _xMetaData->getCatalogs();
914cdf0e10cSrcweir Reference<XRow> xRow(xRes,UNO_QUERY);
915cdf0e10cSrcweir while(xRes.is() && xRes->next())
916cdf0e10cSrcweir {
917cdf0e10cSrcweir sCatalog = xRow->getString(1);
918cdf0e10cSrcweir if(!xRow->wasNull())
919cdf0e10cSrcweir break;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir }
922cdf0e10cSrcweir }
923cdf0e10cSrcweir catch(const SQLException&)
924cdf0e10cSrcweir {
925cdf0e10cSrcweir }
926cdf0e10cSrcweir }
927cdf0e10cSrcweir if(_xMetaData->supportsSchemasInTableDefinitions())
928cdf0e10cSrcweir {
929cdf0e10cSrcweir sSchema = _xMetaData->getUserName();
930cdf0e10cSrcweir }
931cdf0e10cSrcweir sCompsedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, _sName, sal_False, ::dbtools::eInDataManipulation );
932cdf0e10cSrcweir sDefaultName = ::dbtools::createUniqueName(_xTables,sCompsedName);
933cdf0e10cSrcweir }
934cdf0e10cSrcweir catch(const SQLException&)
935cdf0e10cSrcweir {
936cdf0e10cSrcweir }
937cdf0e10cSrcweir return sDefaultName;
938cdf0e10cSrcweir }
939cdf0e10cSrcweir // -----------------------------------------------------------------------------
checkDataSourceAvailable(const::rtl::OUString & _sDataSourceName,const Reference<::com::sun::star::lang::XMultiServiceFactory> & _xORB)940cdf0e10cSrcweir sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB)
941cdf0e10cSrcweir {
942cdf0e10cSrcweir sal_Bool bRet = sal_False;
943cdf0e10cSrcweir Reference< XNameAccess > xDataBaseContext(_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
944cdf0e10cSrcweir if ( xDataBaseContext.is() )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir bRet = xDataBaseContext->hasByName(_sDataSourceName);
947cdf0e10cSrcweir if ( !bRet )
948cdf0e10cSrcweir { // try if this one is a URL
949cdf0e10cSrcweir try
950cdf0e10cSrcweir {
951cdf0e10cSrcweir bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue();
952cdf0e10cSrcweir }
953cdf0e10cSrcweir catch(Exception)
954cdf0e10cSrcweir {
955cdf0e10cSrcweir }
956cdf0e10cSrcweir }
957cdf0e10cSrcweir }
958cdf0e10cSrcweir return bRet;
959cdf0e10cSrcweir }
960cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapTextAllign(const SvxCellHorJustify & _eAlignment)961cdf0e10cSrcweir sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment)
962cdf0e10cSrcweir {
963cdf0e10cSrcweir sal_Int32 nAlignment = com::sun::star::awt::TextAlign::LEFT;
964cdf0e10cSrcweir switch (_eAlignment)
965cdf0e10cSrcweir {
966cdf0e10cSrcweir case SVX_HOR_JUSTIFY_STANDARD:
967cdf0e10cSrcweir case SVX_HOR_JUSTIFY_LEFT: nAlignment = ::com::sun::star::awt::TextAlign::LEFT; break;
968cdf0e10cSrcweir case SVX_HOR_JUSTIFY_CENTER: nAlignment = ::com::sun::star::awt::TextAlign::CENTER; break;
969cdf0e10cSrcweir case SVX_HOR_JUSTIFY_RIGHT: nAlignment = ::com::sun::star::awt::TextAlign::RIGHT; break;
970cdf0e10cSrcweir default:
971cdf0e10cSrcweir OSL_ENSURE(0,"Invalid TextAlign!");
972cdf0e10cSrcweir }
973cdf0e10cSrcweir return nAlignment;
974cdf0e10cSrcweir }
975cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapTextJustify(const sal_Int32 & _nAlignment)976cdf0e10cSrcweir SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment)
977cdf0e10cSrcweir {
978cdf0e10cSrcweir SvxCellHorJustify eJustify = SVX_HOR_JUSTIFY_LEFT;
979cdf0e10cSrcweir switch (_nAlignment)
980cdf0e10cSrcweir {
981cdf0e10cSrcweir case ::com::sun::star::awt::TextAlign::LEFT : eJustify = SVX_HOR_JUSTIFY_LEFT; break;
982cdf0e10cSrcweir case ::com::sun::star::awt::TextAlign::CENTER : eJustify = SVX_HOR_JUSTIFY_CENTER; break;
983cdf0e10cSrcweir case ::com::sun::star::awt::TextAlign::RIGHT : eJustify = SVX_HOR_JUSTIFY_RIGHT; break;
984cdf0e10cSrcweir default:
985cdf0e10cSrcweir OSL_ENSURE(0,"Invalid TextAlign!");
986cdf0e10cSrcweir }
987cdf0e10cSrcweir return eJustify;
988cdf0e10cSrcweir }
989cdf0e10cSrcweir // -----------------------------------------------------------------------------
ConvertFontWeight(::FontWeight eWeight)990cdf0e10cSrcweir float ConvertFontWeight( ::FontWeight eWeight )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir if( eWeight == WEIGHT_DONTKNOW )
993cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::DONTKNOW;
994cdf0e10cSrcweir else if( eWeight == WEIGHT_THIN )
995cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::THIN;
996cdf0e10cSrcweir else if( eWeight == WEIGHT_ULTRALIGHT )
997cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::ULTRALIGHT;
998cdf0e10cSrcweir else if( eWeight == WEIGHT_LIGHT )
999cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::LIGHT;
1000cdf0e10cSrcweir else if( eWeight == WEIGHT_SEMILIGHT )
1001cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::SEMILIGHT;
1002cdf0e10cSrcweir else if( ( eWeight == WEIGHT_NORMAL ) || ( eWeight == WEIGHT_MEDIUM ) )
1003cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::NORMAL;
1004cdf0e10cSrcweir else if( eWeight == WEIGHT_SEMIBOLD )
1005cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::SEMIBOLD;
1006cdf0e10cSrcweir else if( eWeight == WEIGHT_BOLD )
1007cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::BOLD;
1008cdf0e10cSrcweir else if( eWeight == WEIGHT_ULTRABOLD )
1009cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::ULTRABOLD;
1010cdf0e10cSrcweir else if( eWeight == WEIGHT_BLACK )
1011cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::BLACK;
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir OSL_ENSURE(0, "Unknown FontWeigth" );
1014cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::DONTKNOW;
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir // -----------------------------------------------------------------------------
ConvertFontWidth(::FontWidth eWidth)1017cdf0e10cSrcweir float ConvertFontWidth( ::FontWidth eWidth )
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir if( eWidth == WIDTH_DONTKNOW )
1020cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::DONTKNOW;
1021cdf0e10cSrcweir else if( eWidth == WIDTH_ULTRA_CONDENSED )
1022cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::ULTRACONDENSED;
1023cdf0e10cSrcweir else if( eWidth == WIDTH_EXTRA_CONDENSED )
1024cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::EXTRACONDENSED;
1025cdf0e10cSrcweir else if( eWidth == WIDTH_CONDENSED )
1026cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::CONDENSED;
1027cdf0e10cSrcweir else if( eWidth == WIDTH_SEMI_CONDENSED )
1028cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::SEMICONDENSED;
1029cdf0e10cSrcweir else if( eWidth == WIDTH_NORMAL )
1030cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::NORMAL;
1031cdf0e10cSrcweir else if( eWidth == WIDTH_SEMI_EXPANDED )
1032cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::SEMIEXPANDED;
1033cdf0e10cSrcweir else if( eWidth == WIDTH_EXPANDED )
1034cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::EXPANDED;
1035cdf0e10cSrcweir else if( eWidth == WIDTH_EXTRA_EXPANDED )
1036cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::EXTRAEXPANDED;
1037cdf0e10cSrcweir else if( eWidth == WIDTH_ULTRA_EXPANDED )
1038cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::ULTRAEXPANDED;
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir OSL_ENSURE(0, "Unknown FontWidth" );
1041cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::DONTKNOW;
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir // -----------------------------------------------------------------------------
CreateFontDescriptor(const Font & rFont)1044cdf0e10cSrcweir ::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& rFont )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir ::com::sun::star::awt::FontDescriptor aFD;
1047cdf0e10cSrcweir aFD.Name = rFont.GetName();
1048cdf0e10cSrcweir aFD.StyleName = rFont.GetStyleName();
1049cdf0e10cSrcweir aFD.Height = (sal_Int16)rFont.GetSize().Height();
1050cdf0e10cSrcweir aFD.Width = (sal_Int16)rFont.GetSize().Width();
1051cdf0e10cSrcweir aFD.Family = sal::static_int_cast< sal_Int16 >(rFont.GetFamily());
1052cdf0e10cSrcweir aFD.CharSet = rFont.GetCharSet();
1053cdf0e10cSrcweir aFD.Pitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
1054cdf0e10cSrcweir aFD.CharacterWidth = ConvertFontWidth( rFont.GetWidthType() );
1055cdf0e10cSrcweir aFD.Weight = ConvertFontWeight( rFont.GetWeight() );
1056cdf0e10cSrcweir aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic();
1057cdf0e10cSrcweir aFD.Underline = sal::static_int_cast< sal_Int16 >(
1058cdf0e10cSrcweir rFont.GetUnderline());
1059cdf0e10cSrcweir aFD.Strikeout = sal::static_int_cast< sal_Int16 >(
1060cdf0e10cSrcweir rFont.GetStrikeout());
1061cdf0e10cSrcweir aFD.Orientation = rFont.GetOrientation();
1062cdf0e10cSrcweir aFD.Kerning = rFont.IsKerning();
1063cdf0e10cSrcweir aFD.WordLineMode = rFont.IsWordLineMode();
1064cdf0e10cSrcweir aFD.Type = 0; // ??? => Nur an Metric...
1065cdf0e10cSrcweir return aFD;
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir // -----------------------------------------------------------------------------
callColumnFormatDialog(const Reference<XPropertySet> & xAffectedCol,const Reference<XPropertySet> & xField,SvNumberFormatter * _pFormatter,Window * _pParent)1068cdf0e10cSrcweir void callColumnFormatDialog(const Reference<XPropertySet>& xAffectedCol,
1069cdf0e10cSrcweir const Reference<XPropertySet>& xField,
1070cdf0e10cSrcweir SvNumberFormatter* _pFormatter,
1071cdf0e10cSrcweir Window* _pParent)
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir if (xAffectedCol.is() && xField.is())
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir try
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo();
1078cdf0e10cSrcweir sal_Bool bHasFormat = xInfo->hasPropertyByName(PROPERTY_FORMATKEY);
1079cdf0e10cSrcweir sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE));
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir SvxCellHorJustify eJustify(SVX_HOR_JUSTIFY_STANDARD);
1082cdf0e10cSrcweir Any aAlignment = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
1083cdf0e10cSrcweir if (aAlignment.hasValue())
1084cdf0e10cSrcweir eJustify = dbaui::mapTextJustify(::comphelper::getINT16(aAlignment));
1085cdf0e10cSrcweir sal_Int32 nFormatKey = 0;
1086cdf0e10cSrcweir if ( bHasFormat )
1087cdf0e10cSrcweir nFormatKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY));
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir sal_uInt16 nFlags = 0;
1090cdf0e10cSrcweir if(callColumnFormatDialog(_pParent,_pFormatter,nDataType,nFormatKey,eJustify,nFlags,bHasFormat))
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir xAffectedCol->setPropertyValue(PROPERTY_ALIGN, makeAny((sal_Int16)dbaui::mapTextAllign(eJustify)));
1093cdf0e10cSrcweir if (nFlags & TP_ATTR_NUMBER)
1094cdf0e10cSrcweir xAffectedCol->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey));
1095cdf0e10cSrcweir
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir catch( const Exception& )
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir }
1104cdf0e10cSrcweir // -----------------------------------------------------------------------------
callColumnFormatDialog(Window * _pParent,SvNumberFormatter * _pFormatter,sal_Int32 _nDataType,sal_Int32 & _nFormatKey,SvxCellHorJustify & _eJustify,sal_uInt16 & _nFlags,sal_Bool _bHasFormat)1105cdf0e10cSrcweir sal_Bool callColumnFormatDialog(Window* _pParent,
1106cdf0e10cSrcweir SvNumberFormatter* _pFormatter,
1107cdf0e10cSrcweir sal_Int32 _nDataType,
1108cdf0e10cSrcweir sal_Int32& _nFormatKey,
1109cdf0e10cSrcweir SvxCellHorJustify& _eJustify,
1110cdf0e10cSrcweir sal_uInt16& _nFlags,
1111cdf0e10cSrcweir sal_Bool _bHasFormat)
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir sal_Bool bRet = sal_False;
1114cdf0e10cSrcweir // the allowed format changes depend of the type of the field ...
1115cdf0e10cSrcweir _nFlags = TP_ATTR_ALIGN;
1116cdf0e10cSrcweir
1117cdf0e10cSrcweir if (_bHasFormat)
1118cdf0e10cSrcweir _nFlags |= TP_ATTR_NUMBER;
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir // ------------
1121cdf0e10cSrcweir // UNO->ItemSet
1122cdf0e10cSrcweir static SfxItemInfo aItemInfos[] =
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir { 0, 0 },
1125cdf0e10cSrcweir { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE },
1126cdf0e10cSrcweir { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE },
1127cdf0e10cSrcweir { SID_ATTR_NUMBERFORMAT_ONE_AREA, SFX_ITEM_POOLABLE },
1128cdf0e10cSrcweir { SID_ATTR_NUMBERFORMAT_INFO, SFX_ITEM_POOLABLE }
1129cdf0e10cSrcweir };
1130cdf0e10cSrcweir static sal_uInt16 aAttrMap[] =
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY,
1133cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
1134cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
1135cdf0e10cSrcweir 0
1136cdf0e10cSrcweir };
1137cdf0e10cSrcweir
1138cdf0e10cSrcweir SfxPoolItem* pDefaults[] =
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY),
1141cdf0e10cSrcweir new SfxUInt32Item(SBA_DEF_FMTVALUE),
1142cdf0e10cSrcweir new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, SBA_ATTR_ALIGN_HOR_JUSTIFY),
1143cdf0e10cSrcweir new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_False),
1144cdf0e10cSrcweir new SvxNumberInfoItem(SID_ATTR_NUMBERFORMAT_INFO)
1145cdf0e10cSrcweir };
1146cdf0e10cSrcweir
1147cdf0e10cSrcweir SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, pDefaults);
1148cdf0e10cSrcweir pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); // ripped, don't understand why
1149cdf0e10cSrcweir pPool->FreezeIdRanges(); // the same
1150cdf0e10cSrcweir
1151cdf0e10cSrcweir SfxItemSet* pFormatDescriptor = new SfxItemSet(*pPool, aAttrMap);
1152cdf0e10cSrcweir // fill it
1153cdf0e10cSrcweir pFormatDescriptor->Put(SvxHorJustifyItem(_eJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY));
1154cdf0e10cSrcweir sal_Bool bText = sal_False;
1155cdf0e10cSrcweir if (_bHasFormat)
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir // if the col is bound to a text field we have to disallow all non-text formats
1158cdf0e10cSrcweir if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType))
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir bText = sal_True;
1161cdf0e10cSrcweir pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True));
1162cdf0e10cSrcweir if (!_pFormatter->IsTextFormat(_nFormatKey))
1163cdf0e10cSrcweir // text fields can only have text formats
1164cdf0e10cSrcweir _nFormatKey = _pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT,_pParent->GetSettings().GetLanguage());
1165cdf0e10cSrcweir }
1166cdf0e10cSrcweir
1167cdf0e10cSrcweir pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, _nFormatKey));
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir if (!bText)
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir double dPreviewVal = 1234.56789;
1173cdf0e10cSrcweir SvxNumberInfoItem aFormatter(_pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO);
1174cdf0e10cSrcweir pFormatDescriptor->Put(aFormatter);
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir { // want the dialog to be destroyed before our set
1178cdf0e10cSrcweir SbaSbAttrDlg aDlg(_pParent, pFormatDescriptor, _pFormatter, _nFlags);
1179cdf0e10cSrcweir if (RET_OK == aDlg.Execute())
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir // ------------
1182cdf0e10cSrcweir // ItemSet->UNO
1183cdf0e10cSrcweir // UNO-properties
1184cdf0e10cSrcweir const SfxItemSet* pSet = aDlg.GetExampleSet();
1185cdf0e10cSrcweir // (of course we could put the modified items directly into the column, but then the UNO-model
1186cdf0e10cSrcweir // won't reflect these changes, and why do we have a model, then ?)
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir // horizontal justify
1189cdf0e10cSrcweir SFX_ITEMSET_GET(*pSet, pHorJustify, SvxHorJustifyItem, SBA_ATTR_ALIGN_HOR_JUSTIFY, sal_True);
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir _eJustify = (SvxCellHorJustify)pHorJustify->GetValue();
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir // format key
1194cdf0e10cSrcweir if (_nFlags & TP_ATTR_NUMBER)
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir SFX_ITEMSET_GET(*pSet, pFormat, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True);
1197cdf0e10cSrcweir _nFormatKey = (sal_Int32)pFormat->GetValue();
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir bRet = sal_True;
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir // deleted formats
1202cdf0e10cSrcweir const SfxItemSet* pResult = aDlg.GetOutputItemSet();
1203cdf0e10cSrcweir if (pResult)
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
1206cdf0e10cSrcweir const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem);
1207cdf0e10cSrcweir if (pInfoItem && pInfoItem->GetDelCount())
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
1212cdf0e10cSrcweir _pFormatter->DeleteEntry(*pDeletedKeys);
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir delete pFormatDescriptor;
1218cdf0e10cSrcweir SfxItemPool::Free(pPool);
1219cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
1220cdf0e10cSrcweir delete pDefaults[i];
1221cdf0e10cSrcweir
1222cdf0e10cSrcweir return bRet;
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir //------------------------------------------------------------------------------
getStandardDatabaseFilter()1226cdf0e10cSrcweir const SfxFilter* getStandardDatabaseFilter()
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
1229cdf0e10cSrcweir const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
1230cdf0e10cSrcweir OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
1231cdf0e10cSrcweir return pFilter;
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir // -----------------------------------------------------------------------------
appendToFilter(const Reference<XConnection> & _xConnection,const::rtl::OUString & _sName,const Reference<XMultiServiceFactory> & _xFactory,Window * _pParent)1236cdf0e10cSrcweir sal_Bool appendToFilter(const Reference<XConnection>& _xConnection,
1237cdf0e10cSrcweir const ::rtl::OUString& _sName,
1238cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _xFactory,
1239cdf0e10cSrcweir Window* _pParent)
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir sal_Bool bRet = sal_False;
1242cdf0e10cSrcweir Reference< XChild> xChild(_xConnection,UNO_QUERY);
1243cdf0e10cSrcweir if(xChild.is())
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
1246cdf0e10cSrcweir if(xProp.is())
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir Sequence< ::rtl::OUString > aFilter;
1249cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter;
1250cdf0e10cSrcweir // first check if we have something like SCHEMA.%
1251cdf0e10cSrcweir sal_Bool bHasToInsert = sal_True;
1252cdf0e10cSrcweir static ::rtl::OUString sPattern = ::rtl::OUString::createFromAscii("%");
1253cdf0e10cSrcweir const ::rtl::OUString* pBegin = aFilter.getConstArray();
1254cdf0e10cSrcweir const ::rtl::OUString* pEnd = pBegin + aFilter.getLength();
1255cdf0e10cSrcweir for (;pBegin != pEnd; ++pBegin)
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir if(pBegin->indexOf('%') != -1)
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir sal_Int32 nLen;
1260cdf0e10cSrcweir if((nLen = pBegin->lastIndexOf('.')) != -1 && !pBegin->compareTo(_sName,nLen))
1261cdf0e10cSrcweir bHasToInsert = sal_False;
1262cdf0e10cSrcweir else if(pBegin->getLength() == 1)
1263cdf0e10cSrcweir bHasToInsert = sal_False;
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir }
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir bRet = sal_True;
1268cdf0e10cSrcweir if(bHasToInsert)
1269cdf0e10cSrcweir {
1270cdf0e10cSrcweir if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_xFactory))
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir String aMessage(ModuleRes(STR_TABLEDESIGN_DATASOURCE_DELETED));
1273cdf0e10cSrcweir OSQLWarningBox( _pParent, aMessage ).Execute();
1274cdf0e10cSrcweir bRet = sal_False;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir else
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir aFilter.realloc(aFilter.getLength()+1);
1279cdf0e10cSrcweir aFilter.getArray()[aFilter.getLength()-1] = _sName;
1280cdf0e10cSrcweir xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter));
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir }
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir }
1285cdf0e10cSrcweir return bRet;
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifySystemWindow(Window * _pWindow,Window * _pToRegister,::comphelper::mem_fun1_t<TaskPaneList,Window * > _rMemFunc)1288cdf0e10cSrcweir void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc)
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir OSL_ENSURE(_pWindow,"Window can not be null!");
1291cdf0e10cSrcweir SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : NULL;
1292cdf0e10cSrcweir if ( pSystemWindow )
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir _rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir // -----------------------------------------------------------------------------
adjustToolBoxSize(ToolBox * _pToolBox)1298cdf0e10cSrcweir void adjustToolBoxSize(ToolBox* _pToolBox)
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir // adjust the toolbox size, otherwise large bitmaps don't fit into
1301cdf0e10cSrcweir Size aOldSize = _pToolBox->GetSizePixel();
1302cdf0e10cSrcweir Size aSize = _pToolBox->CalcWindowSizePixel();
1303cdf0e10cSrcweir if ( !aSize.Width() )
1304cdf0e10cSrcweir aSize.Width() = aOldSize.Width();
1305cdf0e10cSrcweir else if ( !aSize.Height() )
1306cdf0e10cSrcweir aSize.Height() = aOldSize.Height();
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir Size aTbSize = _pToolBox->GetSizePixel();
1309cdf0e10cSrcweir if ( (aSize.Width() && aSize.Width() != aTbSize.Width()) ||
1310cdf0e10cSrcweir (aSize.Height() && aSize.Height() != aTbSize.Height()) )
1311cdf0e10cSrcweir {
1312cdf0e10cSrcweir _pToolBox->SetPosSizePixel( _pToolBox->GetPosPixel(), aSize );
1313cdf0e10cSrcweir _pToolBox->Invalidate();
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir // -----------------------------------------------------------------------------
isHiContrast(Window * _pWindow)1317cdf0e10cSrcweir sal_Bool isHiContrast(Window* _pWindow)
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir OSL_ENSURE(_pWindow,"Window must be not null!");
1320cdf0e10cSrcweir Window* pIter = _pWindow;
1321cdf0e10cSrcweir // while( pIter && pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT )
1322cdf0e10cSrcweir while( pIter )
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir if ( pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT )
1325cdf0e10cSrcweir pIter = pIter->GetParent();
1326cdf0e10cSrcweir else
1327cdf0e10cSrcweir break;
1328cdf0e10cSrcweir }
1329cdf0e10cSrcweir return pIter && pIter->GetSettings().GetStyleSettings().GetHighContrastMode();
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir // -----------------------------------------------------------------------------
adjustBrowseBoxColumnWidth(::svt::EditBrowseBox * _pBox,sal_uInt16 _nColId)1333cdf0e10cSrcweir void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId )
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir sal_Int32 nColSize = -1;
1336cdf0e10cSrcweir sal_uInt32 nDefaultWidth = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
1337cdf0e10cSrcweir if ( nDefaultWidth != _pBox->GetColumnWidth( _nColId ) )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir Size aSizeMM = _pBox->PixelToLogic( Size( _pBox->GetColumnWidth( _nColId ), 0 ), MapMode( MAP_MM ) );
1340cdf0e10cSrcweir nColSize = aSizeMM.Width() * 10;
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir
1343cdf0e10cSrcweir Size aDefaultMM = _pBox->PixelToLogic( Size( nDefaultWidth, 0 ), MapMode( MAP_MM ) );
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir DlgSize aColumnSizeDlg( _pBox, nColSize, sal_False, aDefaultMM.Width() * 10 );
1346cdf0e10cSrcweir if ( aColumnSizeDlg.Execute() )
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir sal_Int32 nValue = aColumnSizeDlg.GetValue();
1349cdf0e10cSrcweir if ( -1 == nValue )
1350cdf0e10cSrcweir { // default width
1351cdf0e10cSrcweir nValue = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir else
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir Size aSizeMM( nValue / 10, 0 );
1356cdf0e10cSrcweir nValue = _pBox->LogicToPixel( aSizeMM, MapMode( MAP_MM ) ).Width();
1357cdf0e10cSrcweir }
1358cdf0e10cSrcweir _pBox->SetColumnWidth( _nColId, nValue );
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir // -----------------------------------------------------------------------------
1362cdf0e10cSrcweir // check if SQL92 name checking is enabled
isSQL92CheckEnabled(const Reference<XConnection> & _xConnection)1363cdf0e10cSrcweir sal_Bool isSQL92CheckEnabled(const Reference<XConnection>& _xConnection)
1364cdf0e10cSrcweir {
1365cdf0e10cSrcweir return ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_ENABLESQL92CHECK );
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir // -----------------------------------------------------------------------------
isAppendTableAliasEnabled(const Reference<XConnection> & _xConnection)1368cdf0e10cSrcweir sal_Bool isAppendTableAliasEnabled(const Reference<XConnection>& _xConnection)
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_APPEND_TABLE_ALIAS );
1371cdf0e10cSrcweir }
1372cdf0e10cSrcweir
1373cdf0e10cSrcweir // -----------------------------------------------------------------------------
generateAsBeforeTableAlias(const Reference<XConnection> & _xConnection)1374cdf0e10cSrcweir sal_Bool generateAsBeforeTableAlias(const Reference<XConnection>& _xConnection)
1375cdf0e10cSrcweir {
1376cdf0e10cSrcweir return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_AS_BEFORE_CORRELATION_NAME );
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillAutoIncrementValue(const Reference<XPropertySet> & _xDatasource,sal_Bool & _rAutoIncrementValueEnabled,::rtl::OUString & _rsAutoIncrementValue)1380cdf0e10cSrcweir void fillAutoIncrementValue(const Reference<XPropertySet>& _xDatasource,
1381cdf0e10cSrcweir sal_Bool& _rAutoIncrementValueEnabled,
1382cdf0e10cSrcweir ::rtl::OUString& _rsAutoIncrementValue)
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir if ( _xDatasource.is() )
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir OSL_ENSURE(_xDatasource->getPropertySetInfo()->hasPropertyByName(PROPERTY_INFO),"NO datasource supplied!");
1387cdf0e10cSrcweir Sequence<PropertyValue> aInfo;
1388cdf0e10cSrcweir _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo;
1389cdf0e10cSrcweir
1390cdf0e10cSrcweir // search the right propertyvalue
1391cdf0e10cSrcweir const PropertyValue* pValue =::std::find_if(aInfo.getConstArray(),
1392cdf0e10cSrcweir aInfo.getConstArray() + aInfo.getLength(),
1393cdf0e10cSrcweir ::std::bind2nd(TPropertyValueEqualFunctor(),PROPERTY_AUTOINCREMENTCREATION));
1394cdf0e10cSrcweir if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
1395cdf0e10cSrcweir pValue->Value >>= _rsAutoIncrementValue;
1396cdf0e10cSrcweir pValue =::std::find_if(aInfo.getConstArray(),
1397cdf0e10cSrcweir aInfo.getConstArray() + aInfo.getLength(),
1398cdf0e10cSrcweir ::std::bind2nd(TPropertyValueEqualFunctor(),::rtl::OUString::createFromAscii("IsAutoRetrievingEnabled") ));
1399cdf0e10cSrcweir if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
1400cdf0e10cSrcweir pValue->Value >>= _rAutoIncrementValueEnabled;
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillAutoIncrementValue(const Reference<XConnection> & _xConnection,sal_Bool & _rAutoIncrementValueEnabled,::rtl::OUString & _rsAutoIncrementValue)1404cdf0e10cSrcweir void fillAutoIncrementValue(const Reference<XConnection>& _xConnection,
1405cdf0e10cSrcweir sal_Bool& _rAutoIncrementValueEnabled,
1406cdf0e10cSrcweir ::rtl::OUString& _rsAutoIncrementValue)
1407cdf0e10cSrcweir {
1408cdf0e10cSrcweir Reference< XChild> xChild(_xConnection,UNO_QUERY);
1409cdf0e10cSrcweir if(xChild.is())
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
1412cdf0e10cSrcweir fillAutoIncrementValue(xProp,_rAutoIncrementValueEnabled,_rsAutoIncrementValue);
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir // -----------------------------------------------------------------------------
getStrippedDatabaseName(const Reference<XPropertySet> & _xDataSource,::rtl::OUString & _rsDatabaseName)1416cdf0e10cSrcweir ::rtl::OUString getStrippedDatabaseName(const Reference<XPropertySet>& _xDataSource,::rtl::OUString& _rsDatabaseName)
1417cdf0e10cSrcweir {
1418cdf0e10cSrcweir if ( !_rsDatabaseName.getLength() && _xDataSource.is() )
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir try
1421cdf0e10cSrcweir {
1422cdf0e10cSrcweir _xDataSource->getPropertyValue(PROPERTY_NAME) >>= _rsDatabaseName;
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir catch(const Exception& )
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir ::rtl::OUString sName = _rsDatabaseName;
1430cdf0e10cSrcweir INetURLObject aURL(sName);
1431cdf0e10cSrcweir if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
1432cdf0e10cSrcweir sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
1433cdf0e10cSrcweir return sName;
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir // -----------------------------------------------------------------------------
AppendConfigToken(::rtl::OUString & _rURL,sal_Bool _bQuestionMark)1436cdf0e10cSrcweir void AppendConfigToken( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark )
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir Any aLocale =
1439cdf0e10cSrcweir ::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty( ::utl::ConfigManager::LOCALE );
1440cdf0e10cSrcweir ::rtl::OUString sLocaleStr;
1441cdf0e10cSrcweir if ( !( aLocale >>= sLocaleStr ) )
1442cdf0e10cSrcweir // fallback is english
1443cdf0e10cSrcweir sLocaleStr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir // query part exists?
1446cdf0e10cSrcweir if ( _bQuestionMark )
1447cdf0e10cSrcweir // no, so start with '?'
1448cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?"));
1449cdf0e10cSrcweir else
1450cdf0e10cSrcweir // yes, so only append with '&'
1451cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&"));
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir // set parameters
1454cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Language="));
1455cdf0e10cSrcweir _rURL += sLocaleStr;
1456cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&System="));
1457cdf0e10cSrcweir _rURL += SvtHelpOptions().GetSystem();
1458cdf0e10cSrcweir }
1459cdf0e10cSrcweir
1460cdf0e10cSrcweir namespace
1461cdf0e10cSrcweir {
1462cdf0e10cSrcweir // -----------------------------------------------------------------------
1463cdf0e10cSrcweir
GetHelpAnchor_Impl(const::rtl::OUString & _rURL,::rtl::OUString & _rAnchor)1464cdf0e10cSrcweir sal_Bool GetHelpAnchor_Impl( const ::rtl::OUString& _rURL, ::rtl::OUString& _rAnchor )
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir sal_Bool bRet = sal_False;
1467cdf0e10cSrcweir ::rtl::OUString sAnchor;
1468cdf0e10cSrcweir
1469cdf0e10cSrcweir try
1470cdf0e10cSrcweir {
1471cdf0e10cSrcweir ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::NO_DECODE ),
1472cdf0e10cSrcweir Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
1473cdf0e10cSrcweir if ( ( aCnt.getPropertyValue( ::rtl::OUString::createFromAscii( "AnchorName" ) ) >>= sAnchor ) )
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir
1476cdf0e10cSrcweir if ( sAnchor.getLength() > 0 )
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir _rAnchor = sAnchor;
1479cdf0e10cSrcweir bRet = sal_True;
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir else
1483cdf0e10cSrcweir {
1484cdf0e10cSrcweir DBG_ERRORFILE( "Property 'AnchorName' is missing" );
1485cdf0e10cSrcweir }
1486cdf0e10cSrcweir }
1487cdf0e10cSrcweir catch( Exception& )
1488cdf0e10cSrcweir {
1489cdf0e10cSrcweir }
1490cdf0e10cSrcweir
1491cdf0e10cSrcweir return bRet;
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir // .........................................................................
1494cdf0e10cSrcweir } // annonymous
1495cdf0e10cSrcweir // .........................................................................
1496cdf0e10cSrcweir // -----------------------------------------------------------------------------
createHelpAgentURL(const::rtl::OUString & _sModuleName,const rtl::OString & sHelpId)1497cdf0e10cSrcweir ::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName, const rtl::OString& sHelpId)
1498cdf0e10cSrcweir {
1499cdf0e10cSrcweir ::com::sun::star::util::URL aURL;
1500cdf0e10cSrcweir aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.help://" ) );
1501cdf0e10cSrcweir aURL.Complete += _sModuleName;
1502cdf0e10cSrcweir aURL.Complete += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
150324c56ab9SHerbert Dürr aURL.Complete += ::rtl::OStringToOUString( sHelpId, RTL_TEXTENCODING_UTF8);
1504cdf0e10cSrcweir
1505cdf0e10cSrcweir ::rtl::OUString sAnchor;
1506cdf0e10cSrcweir ::rtl::OUString sTempURL = aURL.Complete;
1507cdf0e10cSrcweir AppendConfigToken( sTempURL, sal_True );
1508cdf0e10cSrcweir sal_Bool bHasAnchor = GetHelpAnchor_Impl( sTempURL, sAnchor );
1509cdf0e10cSrcweir AppendConfigToken(aURL.Complete,sal_True);
1510cdf0e10cSrcweir if ( bHasAnchor )
1511cdf0e10cSrcweir {
1512cdf0e10cSrcweir aURL.Complete += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("#"));
1513cdf0e10cSrcweir aURL.Complete += sAnchor;
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir return aURL;
1516cdf0e10cSrcweir }
1517cdf0e10cSrcweir // -----------------------------------------------------------------------------
setEvalDateFormatForFormatter(Reference<::com::sun::star::util::XNumberFormatter> & _rxFormatter)1518cdf0e10cSrcweir void setEvalDateFormatForFormatter(Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir OSL_ENSURE( _rxFormatter.is(),"setEvalDateFormatForFormatter: Formatter is NULL!");
1521cdf0e10cSrcweir if ( _rxFormatter.is() )
1522cdf0e10cSrcweir {
1523cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = _rxFormatter->getNumberFormatsSupplier();
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
1526cdf0e10cSrcweir SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1527cdf0e10cSrcweir OSL_ENSURE(pSupplierImpl,"No Supplier!");
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir if ( pSupplierImpl )
1530cdf0e10cSrcweir {
1531cdf0e10cSrcweir SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
1532cdf0e10cSrcweir pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT);
1533cdf0e10cSrcweir }
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir // -----------------------------------------------------------------------------
queryPrimaryKeyType(const OTypeInfoMap & _rTypeInfo)1537cdf0e10cSrcweir TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo)
1538cdf0e10cSrcweir {
1539cdf0e10cSrcweir TOTypeInfoSP pTypeInfo;
1540cdf0e10cSrcweir // first we search for a type which supports autoIncrement
1541cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = _rTypeInfo.begin();
1542cdf0e10cSrcweir OTypeInfoMap::const_iterator aEnd = _rTypeInfo.end();
1543cdf0e10cSrcweir for(;aIter != aEnd;++aIter)
1544cdf0e10cSrcweir {
1545cdf0e10cSrcweir // OJ: we don't want to set an autoincrement column to be key
1546cdf0e10cSrcweir // because we don't have the possiblity to know how to create
1547cdf0e10cSrcweir // such auto increment column later on
1548cdf0e10cSrcweir // so until we know how to do it, we create a column without autoincrement
1549cdf0e10cSrcweir // if ( !aIter->second->bAutoIncrement )
1550cdf0e10cSrcweir { // therefor we have searched
1551cdf0e10cSrcweir if ( aIter->second->nType == DataType::INTEGER )
1552cdf0e10cSrcweir {
1553cdf0e10cSrcweir pTypeInfo = aIter->second; // alternative
1554cdf0e10cSrcweir break;
1555cdf0e10cSrcweir }
1556cdf0e10cSrcweir else if ( !pTypeInfo.get() && aIter->second->nType == DataType::DOUBLE )
1557cdf0e10cSrcweir pTypeInfo = aIter->second; // alternative
1558cdf0e10cSrcweir else if ( !pTypeInfo.get() && aIter->second->nType == DataType::REAL )
1559cdf0e10cSrcweir pTypeInfo = aIter->second; // alternative
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir }
1562cdf0e10cSrcweir if ( !pTypeInfo.get() ) // just a fallback
1563cdf0e10cSrcweir pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo);
1564cdf0e10cSrcweir
1565cdf0e10cSrcweir OSL_ENSURE(pTypeInfo.get(),"checkColumns: cann't find a type which is useable as a key!");
1566cdf0e10cSrcweir return pTypeInfo;
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir // -----------------------------------------------------------------------------
queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap & _rTypeInfo)1569cdf0e10cSrcweir TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo)
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = _rTypeInfo.find(_nDataType);
1572cdf0e10cSrcweir if(aIter != _rTypeInfo.end())
1573cdf0e10cSrcweir return aIter->second;
1574cdf0e10cSrcweir // fall back if the type is unknown
1575cdf0e10cSrcweir TOTypeInfoSP pTypeInfo;
1576cdf0e10cSrcweir switch(_nDataType)
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir case DataType::TINYINT:
157977faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::SMALLINT,_rTypeInfo);
1580*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1581cdf0e10cSrcweir break;
1582cdf0e10cSrcweir // run through
1583cdf0e10cSrcweir case DataType::SMALLINT:
158477faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::INTEGER,_rTypeInfo);
1585*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1586cdf0e10cSrcweir break;
1587cdf0e10cSrcweir // run through
1588cdf0e10cSrcweir case DataType::INTEGER:
158977faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::FLOAT,_rTypeInfo);
1590*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1591cdf0e10cSrcweir break;
1592cdf0e10cSrcweir // run through
1593cdf0e10cSrcweir case DataType::FLOAT:
159477faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::REAL,_rTypeInfo);
1595*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1596cdf0e10cSrcweir break;
1597cdf0e10cSrcweir // run through
1598cdf0e10cSrcweir case DataType::DATE:
1599cdf0e10cSrcweir case DataType::TIME:
1600cdf0e10cSrcweir if( DataType::DATE == _nDataType || DataType::TIME == _nDataType )
1601cdf0e10cSrcweir {
160277faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::TIMESTAMP,_rTypeInfo);
1603*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1604cdf0e10cSrcweir break;
1605cdf0e10cSrcweir }
1606cdf0e10cSrcweir // run through
1607cdf0e10cSrcweir case DataType::TIMESTAMP:
1608cdf0e10cSrcweir case DataType::REAL:
1609cdf0e10cSrcweir case DataType::BIGINT:
161077faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo);
1611*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1612cdf0e10cSrcweir break;
1613cdf0e10cSrcweir // run through
1614cdf0e10cSrcweir case DataType::DOUBLE:
161577faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo);
1616*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1617cdf0e10cSrcweir break;
1618cdf0e10cSrcweir // run through
1619cdf0e10cSrcweir case DataType::NUMERIC:
1620cdf0e10cSrcweir pTypeInfo = queryTypeInfoByType(DataType::DECIMAL,_rTypeInfo);
1621cdf0e10cSrcweir break;
1622cdf0e10cSrcweir case DataType::DECIMAL:
162377faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo);
1624*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1625cdf0e10cSrcweir break;
162677faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo);
1627*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1628cdf0e10cSrcweir break;
1629cdf0e10cSrcweir break;
1630cdf0e10cSrcweir case DataType::VARCHAR:
163177faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo);
1632*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1633cdf0e10cSrcweir break;
1634cdf0e10cSrcweir break;
1635cdf0e10cSrcweir case DataType::LONGVARCHAR:
163677faa9f2SHerbert Dürr pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo);
1637*b862c97cSHerbert Dürr if( bool(pTypeInfo))
1638cdf0e10cSrcweir break;
1639cdf0e10cSrcweir break;
1640cdf0e10cSrcweir default:
1641cdf0e10cSrcweir ;
1642cdf0e10cSrcweir } // switch(_nDataType)
1643cdf0e10cSrcweir if ( !pTypeInfo )
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x")),sTypeName;
1646cdf0e10cSrcweir sal_Bool bForce = sal_True;
1647cdf0e10cSrcweir pTypeInfo = ::dbaui::getTypeInfoFromType(_rTypeInfo,DataType::VARCHAR,sTypeName,sCreate,50,0,sal_False,bForce);
1648cdf0e10cSrcweir } // if ( !pTypeInfo )
1649cdf0e10cSrcweir OSL_ENSURE(pTypeInfo,"Wrong DataType supplied!");
1650cdf0e10cSrcweir return pTypeInfo;
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir // -----------------------------------------------------------------------------
askForUserAction(Window * _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,sal_Bool _bAll,const::rtl::OUString & _sName)1653cdf0e10cSrcweir sal_Int32 askForUserAction(Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,sal_Bool _bAll,const ::rtl::OUString& _sName)
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() );
1656cdf0e10cSrcweir String aMsg = String(ModuleRes(_nText));
1657cdf0e10cSrcweir aMsg.SearchAndReplace(String::CreateFromAscii("%1"),String(_sName));
1658cdf0e10cSrcweir OSQLMessageBox aAsk(_pParent,String(ModuleRes(_nTitle )),aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query);
1659cdf0e10cSrcweir if ( _bAll )
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir aAsk.AddButton(String(ModuleRes(STR_BUTTON_TEXT_ALL)), RET_ALL, 0);
1662cdf0e10cSrcweir aAsk.GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL);
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir return aAsk.Execute();
1665cdf0e10cSrcweir }
1666cdf0e10cSrcweir
1667cdf0e10cSrcweir // -----------------------------------------------------------------------------
1668cdf0e10cSrcweir namespace
1669cdf0e10cSrcweir {
lcl_createSDBCLevelStatement(const::rtl::OUString & _rStatement,const Reference<XConnection> & _rxConnection)1670cdf0e10cSrcweir static ::rtl::OUString lcl_createSDBCLevelStatement( const ::rtl::OUString& _rStatement, const Reference< XConnection >& _rxConnection )
1671cdf0e10cSrcweir {
1672cdf0e10cSrcweir ::rtl::OUString sSDBCLevelStatement( _rStatement );
1673cdf0e10cSrcweir try
1674cdf0e10cSrcweir {
1675cdf0e10cSrcweir Reference< XMultiServiceFactory > xAnalyzerFactory( _rxConnection, UNO_QUERY_THROW );
1676cdf0e10cSrcweir Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xAnalyzerFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
1677cdf0e10cSrcweir xAnalyzer->setQuery( _rStatement );
1678cdf0e10cSrcweir sSDBCLevelStatement = xAnalyzer->getQueryWithSubstitution();
1679cdf0e10cSrcweir }
1680cdf0e10cSrcweir catch( const Exception& )
1681cdf0e10cSrcweir {
1682cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
1683cdf0e10cSrcweir }
1684cdf0e10cSrcweir return sSDBCLevelStatement;
1685cdf0e10cSrcweir }
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir // -----------------------------------------------------------------------------
createView(const::rtl::OUString & _rName,const Reference<XConnection> & _rxConnection,const::rtl::OUString & _rCommand)1689cdf0e10cSrcweir Reference< XPropertySet > createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection,
1690cdf0e10cSrcweir const ::rtl::OUString& _rCommand )
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir Reference<XViewsSupplier> xSup(_rxConnection,UNO_QUERY);
1693cdf0e10cSrcweir Reference< XNameAccess > xViews;
1694cdf0e10cSrcweir if(xSup.is())
1695cdf0e10cSrcweir xViews = xSup->getViews();
1696cdf0e10cSrcweir Reference<XDataDescriptorFactory> xFact(xViews,UNO_QUERY);
1697cdf0e10cSrcweir OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
1698cdf0e10cSrcweir if(!xFact.is())
1699cdf0e10cSrcweir return NULL;
1700cdf0e10cSrcweir
1701cdf0e10cSrcweir Reference<XPropertySet> xView = xFact->createDataDescriptor();
1702cdf0e10cSrcweir if ( !xView.is() )
1703cdf0e10cSrcweir return NULL;
1704cdf0e10cSrcweir
1705cdf0e10cSrcweir ::rtl::OUString sCatalog,sSchema,sTable;
1706cdf0e10cSrcweir ::dbtools::qualifiedNameComponents(_rxConnection->getMetaData(),
1707cdf0e10cSrcweir _rName,
1708cdf0e10cSrcweir sCatalog,
1709cdf0e10cSrcweir sSchema,
1710cdf0e10cSrcweir sTable,
1711cdf0e10cSrcweir ::dbtools::eInDataManipulation);
1712cdf0e10cSrcweir
1713cdf0e10cSrcweir xView->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
1714cdf0e10cSrcweir xView->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
1715cdf0e10cSrcweir xView->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
1716cdf0e10cSrcweir
1717cdf0e10cSrcweir xView->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
1718cdf0e10cSrcweir
1719cdf0e10cSrcweir Reference<XAppend> xAppend(xViews,UNO_QUERY);
1720cdf0e10cSrcweir if(xAppend.is())
1721cdf0e10cSrcweir xAppend->appendByDescriptor(xView);
1722cdf0e10cSrcweir
1723cdf0e10cSrcweir xView = NULL;
1724cdf0e10cSrcweir // we need to reget the view because after appending it it is no longer valid
1725cdf0e10cSrcweir // but this time it isn't a view object it is a table object with type "VIEW"
1726cdf0e10cSrcweir Reference<XTablesSupplier> xTabSup(_rxConnection,UNO_QUERY);
1727cdf0e10cSrcweir Reference< XNameAccess > xTables;
1728cdf0e10cSrcweir if ( xTabSup.is() )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir xTables = xTabSup->getTables();
1731cdf0e10cSrcweir if ( xTables.is() && xTables->hasByName( _rName ) )
1732cdf0e10cSrcweir xTables->getByName( _rName ) >>= xView;
1733cdf0e10cSrcweir }
1734cdf0e10cSrcweir
1735cdf0e10cSrcweir return xView;
1736cdf0e10cSrcweir }
1737cdf0e10cSrcweir
1738cdf0e10cSrcweir // -----------------------------------------------------------------------------
createView(const::rtl::OUString & _rName,const Reference<XConnection> & _rxConnection,const Reference<XPropertySet> & _rxSourceObject)1739cdf0e10cSrcweir Reference<XPropertySet> createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection
1740cdf0e10cSrcweir ,const Reference<XPropertySet>& _rxSourceObject)
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir ::rtl::OUString sCommand;
1743cdf0e10cSrcweir Reference< XPropertySetInfo > xPSI( _rxSourceObject->getPropertySetInfo(), UNO_SET_THROW );
1744cdf0e10cSrcweir if ( xPSI->hasPropertyByName( PROPERTY_COMMAND ) )
1745cdf0e10cSrcweir {
1746cdf0e10cSrcweir _rxSourceObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
1747cdf0e10cSrcweir
1748cdf0e10cSrcweir sal_Bool bEscapeProcessing( sal_False );
1749cdf0e10cSrcweir OSL_VERIFY( _rxSourceObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
1750cdf0e10cSrcweir if ( bEscapeProcessing )
1751cdf0e10cSrcweir sCommand = lcl_createSDBCLevelStatement( sCommand, _rxConnection );
1752cdf0e10cSrcweir }
1753cdf0e10cSrcweir else
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir sCommand = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SELECT * FROM " ) );
1756cdf0e10cSrcweir sCommand += composeTableNameForSelect( _rxConnection, _rxSourceObject );
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir return createView( _rName, _rxConnection, sCommand );
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir
1761cdf0e10cSrcweir // -----------------------------------------------------------------------------
insertHierachyElement(Window * _pParent,const Reference<XMultiServiceFactory> & _rxORB,const Reference<XHierarchicalNameContainer> & _xNames,const String & _sParentFolder,sal_Bool _bForm,sal_Bool _bCollection,const Reference<XContent> & _xContent,sal_Bool _bMove)1762cdf0e10cSrcweir sal_Bool insertHierachyElement( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB,
1763cdf0e10cSrcweir const Reference<XHierarchicalNameContainer>& _xNames,
1764cdf0e10cSrcweir const String& _sParentFolder,
1765cdf0e10cSrcweir sal_Bool _bForm,
1766cdf0e10cSrcweir sal_Bool _bCollection,
1767cdf0e10cSrcweir const Reference<XContent>& _xContent,
1768cdf0e10cSrcweir sal_Bool _bMove)
1769cdf0e10cSrcweir {
1770cdf0e10cSrcweir OSL_ENSURE( _xNames.is(), "insertHierachyElement: illegal name container!" );
1771cdf0e10cSrcweir if ( !_xNames.is() )
1772cdf0e10cSrcweir return sal_False;
1773cdf0e10cSrcweir
1774cdf0e10cSrcweir Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY );
1775cdf0e10cSrcweir ::rtl::OUString sName = _sParentFolder;
1776cdf0e10cSrcweir if ( _xNames->hasByHierarchicalName(sName) )
1777cdf0e10cSrcweir {
1778cdf0e10cSrcweir Reference<XChild> xChild(_xNames->getByHierarchicalName(sName),UNO_QUERY);
1779cdf0e10cSrcweir xNameAccess.set(xChild,UNO_QUERY);
1780cdf0e10cSrcweir if ( !xNameAccess.is() && xChild.is() )
1781cdf0e10cSrcweir xNameAccess.set(xChild->getParent(),UNO_QUERY);
1782cdf0e10cSrcweir }
1783cdf0e10cSrcweir
1784cdf0e10cSrcweir OSL_ENSURE( xNameAccess.is(), "insertHierachyElement: could not find the proper name container!" );
1785cdf0e10cSrcweir if ( !xNameAccess.is() )
1786cdf0e10cSrcweir return sal_False;
1787cdf0e10cSrcweir
1788cdf0e10cSrcweir ::rtl::OUString sNewName;
1789cdf0e10cSrcweir Reference<XPropertySet> xProp(_xContent,UNO_QUERY);
1790cdf0e10cSrcweir if ( xProp.is() )
1791cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_NAME) >>= sNewName;
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir if ( !_bMove || !sNewName.getLength() )
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir String sTargetName,sLabel;
1796cdf0e10cSrcweir if ( !sNewName.getLength() || xNameAccess->hasByName(sNewName) )
1797cdf0e10cSrcweir {
1798cdf0e10cSrcweir if ( sNewName.getLength() )
1799cdf0e10cSrcweir sTargetName = sNewName;
1800cdf0e10cSrcweir else
1801cdf0e10cSrcweir sTargetName = String(ModuleRes( _bCollection ? STR_NEW_FOLDER : ((_bForm) ? RID_STR_FORM : RID_STR_REPORT)));
1802cdf0e10cSrcweir sLabel = String(ModuleRes( _bCollection ? STR_FOLDER_LABEL : ((_bForm) ? STR_FRM_LABEL : STR_RPT_LABEL)));
1803cdf0e10cSrcweir sTargetName = ::dbtools::createUniqueName(xNameAccess,sTargetName);
1804cdf0e10cSrcweir
1805cdf0e10cSrcweir
1806cdf0e10cSrcweir // here we have everything needed to create a new query object ...
1807cdf0e10cSrcweir HierarchicalNameCheck aNameChecker( _xNames.get(), sName );
1808cdf0e10cSrcweir // ... ehm, except a new name
1809cdf0e10cSrcweir OSaveAsDlg aAskForName( _pParent,
1810cdf0e10cSrcweir _rxORB,
1811cdf0e10cSrcweir sTargetName,
1812cdf0e10cSrcweir sLabel,
1813cdf0e10cSrcweir aNameChecker,
1814cdf0e10cSrcweir SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS);
1815cdf0e10cSrcweir if ( RET_OK != aAskForName.Execute() )
1816cdf0e10cSrcweir // cancelled by the user
1817cdf0e10cSrcweir return sal_False;
1818cdf0e10cSrcweir
1819cdf0e10cSrcweir sNewName = aAskForName.getName();
1820cdf0e10cSrcweir }
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir else if ( xNameAccess->hasByName(sNewName) )
1823cdf0e10cSrcweir {
1824cdf0e10cSrcweir String sError(ModuleRes(STR_NAME_ALREADY_EXISTS));
1825cdf0e10cSrcweir sError.SearchAndReplaceAscii("#",sNewName);
1826cdf0e10cSrcweir throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir
1829cdf0e10cSrcweir try
1830cdf0e10cSrcweir {
1831cdf0e10cSrcweir Reference<XMultiServiceFactory> xORB( xNameAccess, UNO_QUERY_THROW );
1832cdf0e10cSrcweir Sequence< Any > aArguments(3);
1833cdf0e10cSrcweir PropertyValue aValue;
1834cdf0e10cSrcweir // set as folder
1835cdf0e10cSrcweir aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
1836cdf0e10cSrcweir aValue.Value <<= sNewName;
1837cdf0e10cSrcweir aArguments[0] <<= aValue;
1838cdf0e10cSrcweir //parent
1839cdf0e10cSrcweir aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
1840cdf0e10cSrcweir aValue.Value <<= xNameAccess;
1841cdf0e10cSrcweir aArguments[1] <<= aValue;
1842cdf0e10cSrcweir
1843cdf0e10cSrcweir aValue.Name = PROPERTY_EMBEDDEDOBJECT;
1844cdf0e10cSrcweir aValue.Value <<= _xContent;
1845cdf0e10cSrcweir aArguments[2] <<= aValue;
1846cdf0e10cSrcweir
1847cdf0e10cSrcweir ::rtl::OUString sServiceName(_bCollection ? ((_bForm) ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION) : SERVICE_SDB_DOCUMENTDEFINITION);
1848cdf0e10cSrcweir
1849cdf0e10cSrcweir Reference<XContent > xNew( xORB->createInstanceWithArguments( sServiceName, aArguments ), UNO_QUERY_THROW );
1850cdf0e10cSrcweir Reference< XNameContainer > xNameContainer( xNameAccess, UNO_QUERY_THROW );
1851cdf0e10cSrcweir xNameContainer->insertByName( sNewName, makeAny( xNew ) );
1852cdf0e10cSrcweir }
1853cdf0e10cSrcweir catch( const IllegalArgumentException& e )
1854cdf0e10cSrcweir {
1855cdf0e10cSrcweir ::dbtools::throwGenericSQLException( e.Message, e.Context );
1856cdf0e10cSrcweir }
1857cdf0e10cSrcweir catch( const Exception& )
1858cdf0e10cSrcweir {
1859cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
1860cdf0e10cSrcweir return sal_False;
1861cdf0e10cSrcweir }
1862cdf0e10cSrcweir
1863cdf0e10cSrcweir return sal_True;
1864cdf0e10cSrcweir }
1865cdf0e10cSrcweir // -----------------------------------------------------------------------------
getNumberFormatter(const Reference<XConnection> & _rxConnection,const Reference<::com::sun::star::lang::XMultiServiceFactory> & _rMF)1866cdf0e10cSrcweir Reference< XNumberFormatter > getNumberFormatter(const Reference< XConnection >& _rxConnection,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF )
1867cdf0e10cSrcweir {
1868cdf0e10cSrcweir // ---------------------------------------------------------------
1869cdf0e10cSrcweir // create a formatter working with the connections format supplier
1870cdf0e10cSrcweir Reference< XNumberFormatter > xFormatter;
1871cdf0e10cSrcweir
1872cdf0e10cSrcweir try
1873cdf0e10cSrcweir {
1874cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(_rxConnection, sal_True,_rMF));
1875cdf0e10cSrcweir
1876cdf0e10cSrcweir if ( xSupplier.is() )
1877cdf0e10cSrcweir {
1878cdf0e10cSrcweir // create a new formatter
1879cdf0e10cSrcweir xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > (
1880cdf0e10cSrcweir _rMF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
1881cdf0e10cSrcweir if ( xFormatter.is() )
1882cdf0e10cSrcweir xFormatter->attachNumberFormatsSupplier(xSupplier);
1883cdf0e10cSrcweir }
1884cdf0e10cSrcweir }
1885cdf0e10cSrcweir catch(const Exception&)
1886cdf0e10cSrcweir {
1887cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir return xFormatter;
1890cdf0e10cSrcweir }
1891cdf0e10cSrcweir
1892cdf0e10cSrcweir
1893cdf0e10cSrcweir // .........................................................................
1894cdf0e10cSrcweir } // dbaui
1895cdf0e10cSrcweir // .........................................................................
1896