fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / inc / UITools.hxx
blob81808470d6fbcc0c30c292bad1315af1b4880048
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_UITOOLS_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_UITOOLS_HXX
22 #include <connectivity/dbexception.hxx>
23 #include <comphelper/stl_types.hxx>
24 #include "TypeInfo.hxx"
25 #include <editeng/svxenum.hxx>
26 #include <vcl/taskpanelist.hxx>
27 #include <connectivity/dbtools.hxx>
29 #define RET_ALL 10
31 // we only need forward decl here
32 namespace com { namespace sun { namespace star {
34 namespace beans { class XPropertySet;}
35 namespace container
37 class XNameAccess;
38 class XHierarchicalNameContainer;
40 namespace lang
42 class XEventListener;
44 namespace awt
46 struct FontDescriptor;
48 namespace sdbc
50 class XDatabaseMetaData;
51 class XConnection;
53 namespace util
55 struct URL;
56 class XNumberFormatter;
58 namespace ucb { class XContent; }
59 namespace uno { class XComponentContext; }
61 }}}
63 namespace svt
65 class EditBrowseBox;
68 namespace vcl { class Window; }
69 class ToolBox;
70 namespace vcl { class Font; }
71 class SvNumberFormatter;
72 class SfxFilter;
74 namespace dbaui
77 /** creates a new connection and appends the eventlistener
78 @param _rsDataSourceName name of the datasource
79 @param _xDatabaseContext the database context
80 @param _rxContext the UNO component context
81 @param _rEvtLst the eventlistener which will be added to the new created connection
82 @param _rOUTConnection this parameter will be filled with the new created connection
83 @return SQLExceptionInfo contains a SQLException, SQLContext or a SQLWarning when they araised else .isValid() will return false
85 ::dbtools::SQLExceptionInfo createConnection(
86 const OUString& _rsDataSourceName,
87 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext,
88 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
89 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
90 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection );
91 /** creates a new connection and appends the eventlistener
92 @param _xDataSource the datasource
93 @param _rxContext the UNO component context
94 @param _rEvtLst the eventlistener which will be added to the new created connection
95 @param _rOUTConnection this parameter will be filled with the new created connection
96 @return SQLExceptionInfo contains a SQLException, SQLContext or a SQLWarning when they araised else .isValid() will return false
98 ::dbtools::SQLExceptionInfo createConnection(
99 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDataSource,
100 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
101 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
102 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection );
104 /** creates a error dialog which displays the SQLExceptionInfo. Also it supports a "more" button where detailed information are available
105 @param _rInfo the error which should be shown, if the info is not valid no error dialog will appear
106 @param _pParent the parent of the error dialog
107 @param _rxContext need to create the dialog
109 void showError( const ::dbtools::SQLExceptionInfo& _rInfo,
110 vcl::Window* _pParent,
111 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
113 /** fills a map and a vector with localized type names
114 @param _rxConnection the connection to access the metadata
115 @param _rsTypeNames a list of localized type names separated with ';'
116 @param _rTypeInfoMap the filled map with the type names
117 @param _rTypeInfoIters the vector filled with map iterators
119 void fillTypeInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
120 const OUString& _rsTypeNames,
121 OTypeInfoMap& _rTypeInfoMap,
122 ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters);
124 /** fill a column with data of a field description
125 @param _rxColumn the column which should be filled
126 @param _pFieldDesc the source of the data
128 class OFieldDescription;
129 void setColumnProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
130 const OFieldDescription* _pFieldDesc);
132 OUString createDefaultName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
133 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTables,
134 const OUString& _sName);
136 /** checks if the given name exists in the database context
138 bool checkDataSourceAvailable( const OUString& _sDataSourceName,
139 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
141 /** maps SvxCellHorJustify to com::sun::star::awt::TextAlign
142 @param SvxCellHorJustify& _eAlignment
143 @return the corresponding com::sun::star::awt::TextAlign
145 sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment);
147 /** retrieves a data source given by name or URL, and displays an error if this fails
149 Any <type scope="com::sun::star::sdbc">SQLException</type>s which occur will be displayed.
150 Additionally, and Exceptions which indicate a data source name pointing to a non-existent database
151 URL will also be denoted. Yet more additionally, and other exceptions will be forwarded to
152 a <type scope="com::sun::star::sdb">InteractionHandler</type>.
154 @param _rDataSourceName
155 the URL of the database document, or the name of a registered data source
156 @param _pErrorMessageParent
157 the window to use as parent for error messages
158 @param _rxContext
159 a service factory to use for components to be created
160 @param _pErrorInfo
161 takes the error info in case of failure. If <NULL/>, the error is displayed to the user.
163 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >
164 getDataSourceByName(
165 const OUString& _rDataSourceName,
166 vcl::Window* _pErrorMessageParent,
167 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > _rxContext,
168 ::dbtools::SQLExceptionInfo* _pErrorInfo
171 /** returns either the model when data source is given as parameter,
172 or returns a data source when a model is given.
173 @param _xObject Either a data source or a model.
175 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDataSourceOrModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xObject);
177 /** maps com::sun::star::awt::TextAlign to SvxCellHorJustify
178 @param com::sun::star::awt::TextAlign& _nAlignment
179 @return the corresponding SvxCellHorJustify
181 SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment);
183 /** call the format dialog and set the selected format at the column
184 @param _xAffectedCol Font to be converted
185 @param _xField Font to be converted
187 void callColumnFormatDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xAffectedCol,
188 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xField,
189 SvNumberFormatter* _pFormatter,
190 vcl::Window* _pParent);
192 /** second variant of the function before
194 bool callColumnFormatDialog(vcl::Window* _pParent,
195 SvNumberFormatter* _pFormatter,
196 sal_Int32 _nDataType,
197 sal_Int32& _nFormatKey,
198 SvxCellHorJustify& _eJustify,
199 bool _bHasFormat);
200 /** append a name to tablefilter of a datasource
201 @param _xConnection the connection is need to get the datasource
202 @param _sName the name which should be appended
203 @param _rxContext needed to check if datasource is available
204 @param _pParent needed when an error must be shown
205 @return false when datsource is not available otherwise true
207 bool appendToFilter(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
208 const OUString& _sName,
209 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
210 vcl::Window* _pParent);
212 /** notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search _pWindow.
213 @param _pWindow
214 The window which is used to search for the SystemWindow.
215 @param _pToRegister
216 The window which should be added or removed on the TaskPaneList.
217 @param _rMemFunc
218 The member function which should be called at the SystemWindow when found.
219 Possible values are:
220 ::comphelper::mem_fun(&TaskPaneList::AddWindow)
221 ::comphelper::mem_fun(&TaskPaneList::RemoveWindow)
223 void notifySystemWindow(vcl::Window* _pWindow,
224 vcl::Window* _pToRegister,
225 const ::comphelper::mem_fun1_t<TaskPaneList,vcl::Window*>& _rMemFunc);
227 /** adjustToolBoxSize checks if the size of the ToolBox is still valid. If not it will be resized.
228 @param _pToolBox
229 The Toolbox which should be resized.
231 void adjustToolBoxSize(ToolBox* _pToolBox);
233 void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId );
235 /** check if SQL92 name checking is enabled
236 @param _xConnection
237 Used to get the datasource as parent from the connection.
238 @return
239 <TRUE/> if so otherwise <FALSE/>
241 bool isSQL92CheckEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
243 /** check if the alias name of the table should be added at select statements
244 @param _xConnection
245 Used to get the datasource as parent from the connection.
246 @return
247 <TRUE/> if so otherwise <FALSE/>
249 bool isAppendTableAliasEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
251 /** determines whether when generating SQL statements, AS should be placed before a table alias
253 bool generateAsBeforeTableAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection );
255 /** fills the bool and string value with information out of the datasource info property
256 @param _xDatasource
257 Asked for the properties.
258 @param _rAutoIncrementValueEnabled
259 <OUT/> Set to sal_True when the property was set in the datasource.
260 @param _rsAutoIncrementValue
261 <OUT/> Set to the value when the property was set in the datasource.
263 void fillAutoIncrementValue(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDatasource
264 ,bool& _rAutoIncrementValueEnabled
265 ,OUString& _rsAutoIncrementValue);
267 /** fills the bool and string value with information out of the datasource info property
268 @param _xConnection
269 Used to get the datasource as parent from the connection.
270 @param _rAutoIncrementValueEnabled
271 <OUT/> Set to sal_True when the property was set in the datasource.
272 @param _rsAutoIncrementValue
273 <OUT/> Set to the value when the property was set in the datasource.
275 void fillAutoIncrementValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
276 ,bool& _rAutoIncrementValueEnabled
277 ,OUString& _rsAutoIncrementValue);
279 /** creates the URL or the help agent
280 @param _sModuleName
281 @param _nHelpId
282 @return
283 The URL for the help agent to dispatch.
285 ::com::sun::star::util::URL createHelpAgentURL(const OUString& _sModuleName,const OString& _rHelpId);
287 /** set the evaluation flag at the number formatter
288 @param _rxFormatter
290 void setEvalDateFormatForFormatter(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter);
292 /** query for a type info which can be used to create a primary key column
293 @param _rTypeInfo
294 The map which contains all available types.
295 @return
296 The type info which can be used to create a primary key column.
298 TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo);
300 /** query for a specific type.
301 @param _nDataType
302 The type we are searching.
303 @param _rTypeInfo
304 The map which contains all available types.
305 @return
306 The type or <NULL/> if we can't find it.
308 TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo);
310 /** returns the configuration node name of user defined drivers.
311 @return
312 the configuration node name of user defined drivers.
315 /** returns the result of the user action when view the query dialog.
316 @param _pParent
317 The parent of the dialog
318 @param _nTitle
319 A string resource id for the text which will be displayed as title.
320 @param _nText
321 A string resource id for the text which will be displayed above the buttons.
322 When the string contains a #1. This will be replaced by the name.
323 @param _bAll
324 When set to <TRUE/>, the all button will be appended.
325 @param _sName
326 The name of the object to ask for.
327 @return
328 RET_YES, RET_NO, RET_ALL
330 sal_Int32 askForUserAction(vcl::Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,bool _bAll,const OUString& _sName);
332 /** creates a new view from a query or table
333 @param _sName
334 The name of the view to be created.
335 @param _xConnection
336 The source connection.
337 @param _xSourceObject
338 The object for which a view should be created.
339 @return
340 The created view.
342 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createView( const OUString& _sName
343 ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
344 ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSourceObject);
346 /** creates a view with the given command
348 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createView(
349 const OUString& _rName,
350 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
351 const OUString& _rCommand
354 /** returns the stripped database name.
355 @param _xDataSource
356 The data source
357 @param _rsDatabaseName
358 Will be filled with the original data source if it is empty.
359 @return
360 The stripped database name either the registered naem or if it is a file url the last segment.
362 OUString getStrippedDatabaseName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource
363 ,OUString& _rsDatabaseName);
365 /** returns the standard database filter
366 @retrun
367 the filter
369 const SfxFilter* getStandardDatabaseFilter();
371 /** opens a save dialog to store a form or report folder in the current hierarchy.
372 @param _pParent
373 The parent of the dialog.
374 @param _rxContext
375 a multi service factory which can be used to instantiate usual global services
376 @param _xNames
377 Where to insert the new object.
378 @param _sParentFolder
379 The name of the parent folder.
380 @param _bForm
381 <TRUE/> if a form should be inserted
382 @param _bCollection
383 A folder should be inserted
384 @param _xContent
385 The content which should be copied.
386 @param _bMove
387 if <TRUE/> the name of the content must be inserted without any change, otherwise not.
388 @return
389 <TRUE/> if the insert opertions was successful, otherwise <FALSE/>.
391 bool insertHierachyElement(
392 vcl::Window* _pParent,
393 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
394 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameContainer>& _xNames,
395 const OUString& _sParentFolder,
396 bool _bForm,
397 bool _bCollection = true,
398 const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent = NULL,
399 bool _bMove = false
402 /** creates a number formatter
403 @param _rxConnection
404 The connection is needed to create the formatter
405 @param _rxContext
406 The multi service factory
408 ::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::uno::XComponentContext >& _rxContext );
410 // this completes a help url with the system parameters "Language" and "System"
411 // detect installed locale
412 void AppendConfigToken( OUString& _rURL, bool _bQuestionMark );
415 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_UITOOLS_HXX
417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */