merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / inc / UITools.hxx
blobcf08bbd9be070ae95dcbaf486f4829ccc15cb88d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UITools.hxx,v $
10 * $Revision: 1.37.26.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_TOOLS_HXX
31 #define DBAUI_TOOLS_HXX
33 #ifndef _DBHELPER_DBEXCEPTION_HXX_
34 #include <connectivity/dbexception.hxx>
35 #endif
36 #ifndef _COMPHELPER_STLTYPES_HXX_
37 #include <comphelper/stl_types.hxx>
38 #endif
39 #ifndef DBAUI_TYPEINFO_HXX
40 #include "TypeInfo.hxx"
41 #endif
42 #ifndef _SVX_SVXENUM_HXX
43 #include <svx/svxenum.hxx>
44 #endif
45 #ifndef _SV_TASKPANELIST_HXX
46 #include <vcl/taskpanelist.hxx>
47 #endif
48 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
49 #include <connectivity/dbtools.hxx>
50 #endif
52 #define RET_ALL 10
54 // we only need forward decl here
55 namespace com { namespace sun { namespace star {
57 namespace beans { class XPropertySet;}
58 namespace container
60 class XNameAccess;
61 class XIndexAccess;
62 class XHierarchicalNameContainer;
63 class XNameContainer;
65 namespace lang
67 class XEventListener;
68 class XMultiServiceFactory;
70 namespace awt
72 struct FontDescriptor;
74 namespace sdbc
76 class XDatabaseMetaData;
77 class XConnection;
79 namespace util
81 struct URL;
82 class XNumberFormatter;
84 namespace frame
86 class XModel;
88 namespace ucb { class XContent; }
90 }}}
92 namespace svt
94 class EditBrowseBox;
97 class Window;
98 class ToolBox;
99 class Font;
100 class SvNumberFormatter;
101 class SfxFilter;
102 class SvLBoxEntry;
104 // .........................................................................
105 namespace dbaui
107 // .........................................................................
108 //class ODsnTypeCollection;
109 class DBTreeListBox;
111 /** creates a new connection and appends the eventlistener
112 @param _rsDataSourceName name of the datasource
113 @param _xDatabaseContext the database context
114 @param _rMF the multi service factory
115 @param _rEvtLst the eventlistener which will be added to the new created connection
116 @param _rOUTConnection this parameter will be filled with the new created connection
117 @return SQLExceptionInfo contains a SQLException, SQLContext or a SQLWarning when they araised else .isValid() will return false
119 ::dbtools::SQLExceptionInfo createConnection(
120 const ::rtl::OUString& _rsDataSourceName,
121 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext,
122 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
123 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
124 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection );
125 /** creates a new connection and appends the eventlistener
126 @param _xDataSource the datasource
127 @param _rMF the multi service factory
128 @param _rEvtLst the eventlistener which will be added to the new created connection
129 @param _rOUTConnection this parameter will be filled with the new created connection
130 @return SQLExceptionInfo contains a SQLException, SQLContext or a SQLWarning when they araised else .isValid() will return false
132 ::dbtools::SQLExceptionInfo createConnection(
133 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDataSource,
134 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
135 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
136 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection );
138 /** creates a error dialog which displays the SQLExceptionInfo. Also it supports a "more" button where detailed information are available
139 @param _rInfo the error which should be shown, if the info is not valid no error dialog will appear
140 @param _pParent the parent of the error dialog
141 @param _xFactory need to create the dialog
143 void showError( const ::dbtools::SQLExceptionInfo& _rInfo,
144 Window* _pParent,
145 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory);
147 /** return a vector which contains all key columns for the @see com::sun::star::sdbc::KeyType _nKeyType
148 @param _rxTable the table which must be a @see com::sun::star::sdbcx::XColumnsSupplier
149 @param _nKeyType @see com::sun::star::sdbc::KeyType
152 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> >
153 getKeyColumns( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxKeys,
154 sal_Int32 _nKeyType);
156 /** fills a map and a vector with localized type names
157 @param _rxConnection the connection to acces the metadata
158 @param _rsTypeNames a list of localized type names seperated with ';'
159 @param _rTypeInfoMap the filled map with the type names
160 @param _rTypeInfoIters the vector filled with map iterators
162 void fillTypeInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
163 const String& _rsTypeNames,
164 OTypeInfoMap& _rTypeInfoMap,
165 ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters);
167 /** fill a column with data of a field description
168 @param _rxColumn the column which should be filled
169 @param _pFieldDesc the source of the data
171 class OFieldDescription;
172 void setColumnProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
173 const OFieldDescription* _pFieldDesc);
175 ::rtl::OUString createDefaultName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
176 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTables,
177 const ::rtl::OUString& _sName);
179 /** checks if the given name exists in the database context
181 sal_Bool checkDataSourceAvailable( const ::rtl::OUString& _sDataSourceName,
182 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory_xORB);
184 /** maps SvxCellHorJustify to com::sun::star::awt::TextAlign
185 @param SvxCellHorJustify& _eAlignment
186 @return the corresponding com::sun::star::awt::TextAlign
188 sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment);
190 /** retrieves a data source given by name or URL, and displays an error if this fails
192 Any <type scope="com::sun::star::sdbc">SQLException</type>s which occur will be displayed.
193 Additionally, and Exceptions which indicate a data source name pointing to a non-existent database
194 URL will also be denoted. Yet more additionally, and other exceptions will be forwarded to
195 a <type scope="com::sun::star::sdb">InteractionHandler</type>.
197 @param _rDataSourceName
198 the URL of the database document, or the name of a registered data source
199 @param _pErrorMessageParent
200 the window to use as parent for error messages
201 @param _rxORB
202 a service factory to use for components to be created
203 @param _pErrorInfo
204 takes the error info in case of failure. If <NULL/>, the error is displayed to the user.
206 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >
207 getDataSourceByName(
208 const ::rtl::OUString& _rDataSourceName,
209 Window* _pErrorMessageParent,
210 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB,
211 ::dbtools::SQLExceptionInfo* _pErrorInfo
214 /** returns either the model when data source is given as parameter,
215 or returns a data source when a model is given.
216 @param _xObject Either a data source or a model.
218 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDataSourceOrModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xObject);
220 /** maps com::sun::star::awt::TextAlign to SvxCellHorJustify
221 @param com::sun::star::awt::TextAlign& _nAlignment
222 @return the corresponding SvxCellHorJustify
224 SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment);
226 /** convert Font to ::com::sun::star::awt::FontDescriptor
227 @param _rFont Font to be converted
228 @return the new FontDescriptor
230 ::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& _rFont );
232 /** call teh format dialog and set the selected format at the column
233 @param _xAffectedCol Font to be converted
234 @param _xField Font to be converted
236 void callColumnFormatDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xAffectedCol,
237 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xField,
238 SvNumberFormatter* _pFormatter,
239 Window* _pParent);
241 /** second variant of the function before
243 sal_Bool callColumnFormatDialog(Window* _pParent,
244 SvNumberFormatter* _pFormatter,
245 sal_Int32 _nDataType,
246 sal_Int32& _nFormatKey,
247 SvxCellHorJustify& _eJustify,
248 sal_uInt16& _nFlags,
249 sal_Bool _bHasFormat);
250 /** append a name to tablefilter of a datasource
251 @param _xConnection the connection is need to get the datasource
252 @param _sName the name which should be appended
253 @param _xFactory needed to check if datasource is available
254 @param _pParent needed when an error must be shown
255 @return false when datsource is not available otherwise true
257 sal_Bool appendToFilter(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
258 const ::rtl::OUString& _sName,
259 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory,
260 Window* _pParent);
262 /** notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search _pWindow.
263 @param _pWindow
264 The window which is used to search for the SystemWindow.
265 @param _pToRegister
266 The window which should be added or removed on the TaskPaneList.
267 @param _rMemFunc
268 The member function which should be called at the SystemWindow when found.
269 Possible values are:
270 ::comphelper::mem_fun(&TaskPaneList::AddWindow)
271 ::comphelper::mem_fun(&TaskPaneList::RemoveWindow)
273 void notifySystemWindow(Window* _pWindow,
274 Window* _pToRegister,
275 ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc);
277 /** adjustToolBoxSize checks if the size of the ToolBox is still valid. If not it will be resized.
278 @param _pToolBox
279 The Toolbox which should be resized.
281 void adjustToolBoxSize(ToolBox* _pToolBox);
283 /** isHiContrast check if we are in hi contrast mode.
284 @param _pWindow
285 The window we have to check on.
286 @return
287 <TRUE/> if so, otherwise <FALSE/>
289 sal_Bool isHiContrast(Window* _pWindow);
291 void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId );
293 /** check if SQL92 name checking is enabled
294 @param _xConnection
295 Used to get the datasource as parent from the connection.
296 @return
297 <TRUE/> if so otherwise <FALSE/>
299 sal_Bool isSQL92CheckEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
301 /** check if the alias name of the table should be added at select statements
302 @param _xConnection
303 Used to get the datasource as parent from the connection.
304 @return
305 <TRUE/> if so otherwise <FALSE/>
307 sal_Bool isAppendTableAliasEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
309 /** determines whether when generating SQL statements, AS should be placed before a table alias
311 sal_Bool generateAsBeforeTableAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection );
313 /** fills the bool and string value with information out of the datasource info property
314 @param _xDatasource
315 Asked for the properties.
316 @param _rAutoIncrementValueEnabled
317 <OUT/> Set to TRUE when the property was set in the datasource.
318 @param _rsAutoIncrementValue
319 <OUT/> Set to the value when the property was set in the datasource.
321 void fillAutoIncrementValue(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDatasource
322 ,sal_Bool& _rAutoIncrementValueEnabled
323 ,::rtl::OUString& _rsAutoIncrementValue);
325 /** fills the bool and string value with information out of the datasource info property
326 @param _xConnection
327 Used to get the datasource as parent from the connection.
328 @param _rAutoIncrementValueEnabled
329 <OUT/> Set to TRUE when the property was set in the datasource.
330 @param _rsAutoIncrementValue
331 <OUT/> Set to the value when the property was set in the datasource.
333 void fillAutoIncrementValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
334 ,sal_Bool& _rAutoIncrementValueEnabled
335 ,::rtl::OUString& _rsAutoIncrementValue);
337 /** creates the URL or the help agent
338 @param _sModuleName
339 @param _nHelpId
340 @return
341 The URL for the help agent to dispatch.
343 ::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName,const sal_Int32 _nHelpId);
345 /** set the evaluation flag at the number formatter
346 @param _rxFormatter
348 void setEvalDateFormatForFormatter(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter);
350 /** query for a type info which can be used to create a primary key column
351 @param _rTypeInfo
352 The map which contains all available types.
353 @return
354 The type info which can be used to create a primary key column.
356 TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo);
358 /** query for a specific type.
359 @param _nDataType
360 The type we are searching.
361 @param _rTypeInfo
362 The map which contains all available types.
363 @return
364 The type or <NULL/> if we can't find it.
366 TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo);
368 /** returns the configuration node name of user defined drivers.
369 @return
370 the configuration node name of user defined drivers.
373 /** returns the result of the user action when view the query dialog.
374 @param _pParent
375 The parent of the dialog
376 @param _nTitle
377 A string resource id for the text which will be displayed as title.
378 @param _nText
379 A string resource id for the text which will be displayed above the buttons.
380 When the string contains a #1. This will be replaced by the name.
381 @param _bAll
382 When set to <TRUE/>, the all button will be appended.
383 @param _sName
384 The name of the object to ask for.
385 @return
386 RET_YES, RET_NO, RET_ALL
388 sal_Int32 askForUserAction(Window* _pParent,USHORT _nTitle,USHORT _nText,sal_Bool _bAll,const ::rtl::OUString& _sName);
390 /** creates a new view from a query or table
391 @param _sName
392 The name of the view to be created.
393 @param _xConnection
394 The source connection.
395 @param _xSourceObject
396 The object for which a view should be created.
397 @return
398 The created view.
400 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createView( const ::rtl::OUString& _sName
401 ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
402 ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSourceObject);
404 /** creates a view with the given command
406 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createView(
407 const ::rtl::OUString& _rName,
408 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
409 const ::rtl::OUString& _rCommand
412 /** returns the stripped database name.
413 @param _xDataSource
414 The data source
415 @param _rsDatabaseName
416 Will be filled with the original data source if it is empty.
417 @return
418 The stripped database name either the registered naem or if it is a file url the last segment.
420 ::rtl::OUString getStrippedDatabaseName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource
421 ,::rtl::OUString& _rsDatabaseName);
423 /** returns the standard database filter
424 @retrun
425 the filter
427 const SfxFilter* getStandardDatabaseFilter();
429 /** opens a save dialog to store a form or report folder in the current hierachy.
430 @param _pParent
431 The parent of the dialog.
432 @param _rxORB
433 a multi service factory which can be used to instantiate usual global services
434 @param _xNames
435 Where to insert the new object.
436 @param _sParentFolder
437 The name of the parent folder.
438 @param _bForm
439 <TRUE/> if a form should be inserted
440 @param _bCollection
441 A folder should be inserted
442 @param _xContent
443 The content which should be copied.
444 @param _bMove
445 if <TRUE/> the name of the content must be inserted without any change, otherwise not.
446 @return
447 <TRUE/> if the insert opertions was successfull, otherwise <FALSE/>.
449 sal_Bool insertHierachyElement(
450 Window* _pParent,
451 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
452 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameContainer>& _xNames,
453 const String& _sParentFolder,
454 sal_Bool _bForm,
455 sal_Bool _bCollection = sal_True,
456 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent = NULL,
457 sal_Bool _bMove = sal_False
460 /** creates a number formatter
461 @param _rxConnection
462 The connection is needed to create the formatter
463 @param _rMF
464 The multi service factory
466 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > getNumberFormatter(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF );
468 // this completes a help url with the system parameters "Language" and "System"
469 // detect installed locale
470 void AppendConfigToken( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark );
472 // .........................................................................
474 // .........................................................................
475 #endif // DBAUI_TOOLS_HXX