LibreOffice Module dbaccess (master) 1
UITools.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
23#include "TypeInfo.hxx"
24#include <editeng/svxenum.hxx>
25#include <vcl/taskpanelist.hxx>
27#include <unotools/resmgr.hxx>
28
29#include <memory>
30#include <string_view>
31
32#define RET_ALL 100
33
34// we only need forward decl here
35namespace com::sun::star {
36
37 namespace beans { class XPropertySet;}
38 namespace container
39 {
40 class XNameAccess;
41 class XHierarchicalNameContainer;
42 }
43 namespace lang
44 {
45 class XEventListener;
46 }
47 namespace awt
48 {
49 struct FontDescriptor;
50 class XWindow;
51 }
52 namespace sdbc
53 {
54 class XDatabaseMetaData;
55 class XConnection;
56 }
57 namespace util
58 {
59 struct URL;
60 class XNumberFormatter;
61 }
62 namespace ucb { class XContent; }
63 namespace uno { class XComponentContext; }
64}
65
66namespace svt
67{
68 class EditBrowseBox;
69}
70
71namespace vcl { class Window; }
72namespace weld {
73 class Widget;
74 class Window;
75}
76class ToolBox;
77namespace vcl { class Font; }
79class SfxFilter;
80
81namespace dbaui
82{
83
93 const OUString& _rsDataSourceName,
94 const css::uno::Reference< css::container::XNameAccess >& _xDatabaseContext,
95 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
96 css::uno::Reference< css::lang::XEventListener> const & _rEvtLst,
97 css::uno::Reference< css::sdbc::XConnection>& _rOUTConnection );
106 const css::uno::Reference< css::beans::XPropertySet >& _xDataSource,
107 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
108 css::uno::Reference< css::lang::XEventListener> const & _rEvtLst,
109 css::uno::Reference< css::sdbc::XConnection>& _rOUTConnection );
110
117 void fillTypeInfo( const css::uno::Reference< css::sdbc::XConnection>& _rxConnection,
118 std::u16string_view _rsTypeNames,
119 OTypeInfoMap& _rTypeInfoMap,
120 std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters);
121
126 class OFieldDescription;
127 void setColumnProperties( const css::uno::Reference< css::beans::XPropertySet>& _rxColumn,
128 const OFieldDescription* _pFieldDesc);
129
130 OUString createDefaultName( const css::uno::Reference< css::sdbc::XDatabaseMetaData>& _xMetaData,
131 const css::uno::Reference< css::container::XNameAccess>& _xTables,
132 const OUString& _sName);
133
136 bool checkDataSourceAvailable( const OUString& _sDataSourceName,
137 const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
138
143 sal_Int32 mapTextAlign(const SvxCellHorJustify& _eAlignment);
144
161 css::uno::Reference< css::sdbc::XDataSource >
163 const OUString& _rDataSourceName,
164 weld::Window* _pErrorMessageParent,
165 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
166 ::dbtools::SQLExceptionInfo* _pErrorInfo
167 );
168
173 css::uno::Reference< css::uno::XInterface > getDataSourceOrModel(const css::uno::Reference< css::uno::XInterface >& _xObject);
174
179 SvxCellHorJustify mapTextJustify(sal_Int32 _nAlignment);
180
185 void callColumnFormatDialog(const css::uno::Reference< css::beans::XPropertySet>& _xAffectedCol,
186 const css::uno::Reference< css::beans::XPropertySet>& _xField,
187 SvNumberFormatter* _pFormatter,
188 weld::Widget* _pParent);
189
193 SvNumberFormatter* _pFormatter,
194 sal_Int32 _nDataType,
195 sal_Int32& _nFormatKey,
196 SvxCellHorJustify& _eJustify,
197 bool _bHasFormat);
205 bool appendToFilter(const css::uno::Reference< css::sdbc::XConnection>& xConnection,
206 const OUString& rName,
207 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
208 weld::Window* pParent);
209
221 void notifySystemWindow(vcl::Window const * _pWindow,
222 vcl::Window* _pToRegister,
223 const ::comphelper::mem_fun1_t<TaskPaneList,vcl::Window*>& _rMemFunc);
224
225 void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId );
226
233 bool isSQL92CheckEnabled(const css::uno::Reference< css::sdbc::XConnection>& _xConnection);
234
241 bool isAppendTableAliasEnabled(const css::uno::Reference< css::sdbc::XConnection>& _xConnection);
242
245 bool generateAsBeforeTableAlias( const css::uno::Reference< css::sdbc::XConnection>& _rxConnection );
246
255 void fillAutoIncrementValue(const css::uno::Reference< css::beans::XPropertySet>& _xDatasource
256 ,bool& _rAutoIncrementValueEnabled
257 ,OUString& _rsAutoIncrementValue);
258
267 void fillAutoIncrementValue(const css::uno::Reference< css::sdbc::XConnection>& _xConnection
268 ,bool& _rAutoIncrementValueEnabled
269 ,OUString& _rsAutoIncrementValue);
270
274 void setEvalDateFormatForFormatter(css::uno::Reference< css::util::XNumberFormatter > const & _rxFormatter);
275
283
292 TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo);
293
314 sal_Int32 askForUserAction(weld::Window* pParent, TranslateId pTitle, TranslateId pText, bool bAll, std::u16string_view rName);
315
326 css::uno::Reference< css::beans::XPropertySet> createView( const OUString& _sName
327 ,const css::uno::Reference< css::sdbc::XConnection >& _xConnection
328 ,const css::uno::Reference< css::beans::XPropertySet>& _xSourceObject);
329
332 css::uno::Reference< css::beans::XPropertySet> createView(
333 const OUString& _rName,
334 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
335 const OUString& _rCommand
336 );
337
346 OUString getStrippedDatabaseName(const css::uno::Reference< css::beans::XPropertySet>& _xDataSource
347 ,OUString& _rsDatabaseName);
348
353 std::shared_ptr<const SfxFilter> getStandardDatabaseFilter();
354
376 weld::Window* pParent,
377 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
378 const css::uno::Reference< css::container::XHierarchicalNameContainer>& _xNames,
379 const OUString& _sParentFolder,
380 bool _bForm,
381 bool _bCollection = true,
382 const css::uno::Reference< css::ucb::XContent>& _xContent = nullptr,
383 bool _bMove = false
384 );
385
392 css::uno::Reference< css::util::XNumberFormatter > getNumberFormatter(const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
393
394}
395
396/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
class SAL_NO_VTABLE XPropertySet
void fillTypeInfo(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, std::u16string_view _rsTypeNames, OTypeInfoMap &_rTypeInfoMap, std::vector< OTypeInfoMap::iterator > &_rTypeInfoIters)
fills a map and a vector with localized type names
css::uno::Reference< css::beans::XPropertySet > createView(const OUString &_sName, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::beans::XPropertySet > &_xSourceObject)
creates a new view from a query or table
void adjustBrowseBoxColumnWidth(::svt::EditBrowseBox *_pBox, sal_uInt16 _nColId)
Definition: UITools.cxx:928
void callColumnFormatDialog(const css::uno::Reference< css::beans::XPropertySet > &_xAffectedCol, const css::uno::Reference< css::beans::XPropertySet > &_xField, SvNumberFormatter *_pFormatter, weld::Widget *_pParent)
call the format dialog and set the selected format at the column
css::uno::Reference< css::sdbc::XDataSource > getDataSourceByName(const OUString &_rDataSourceName, weld::Window *_pErrorMessageParent, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, ::dbtools::SQLExceptionInfo *_pErrorInfo)
retrieves a data source given by name or URL, and displays an error if this fails
TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap &_rTypeInfo)
query for a type info which can be used to create a primary key column
Definition: UITools.cxx:1049
::dbtools::SQLExceptionInfo createConnection(const OUString &_rsDataSourceName, const css::uno::Reference< css::container::XNameAccess > &_xDatabaseContext, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, css::uno::Reference< css::lang::XEventListener > const &_rEvtLst, css::uno::Reference< css::sdbc::XConnection > &_rOUTConnection)
creates a new connection and appends the eventlistener
bool generateAsBeforeTableAlias(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection)
determines whether when generating SQL statements, AS should be placed before a table alias
css::uno::Reference< css::util::XNumberFormatter > getNumberFormatter(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
creates a number formatter
void fillAutoIncrementValue(const css::uno::Reference< css::beans::XPropertySet > &_xDatasource, bool &_rAutoIncrementValueEnabled, OUString &_rsAutoIncrementValue)
fills the bool and string value with information out of the datasource info property
bool isAppendTableAliasEnabled(const css::uno::Reference< css::sdbc::XConnection > &_xConnection)
check if the alias name of the table should be added at select statements
void notifySystemWindow(vcl::Window const *_pWindow, vcl::Window *_pToRegister, const ::comphelper::mem_fun1_t< TaskPaneList, vcl::Window * > &_rMemFunc)
notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search...
Definition: UITools.cxx:918
std::multimap< sal_Int32, TOTypeInfoSP > OTypeInfoMap
Definition: TypeInfo.hxx:100
TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType, const OTypeInfoMap &_rTypeInfo)
query for a specific type.
Definition: UITools.cxx:1077
void setColumnProperties(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn, const OFieldDescription *_pFieldDesc)
SvxCellHorJustify mapTextJustify(sal_Int32 _nAlignment)
maps css::awt::TextAlign to SvxCellHorJustify
Definition: UITools.cxx:704
void setEvalDateFormatForFormatter(css::uno::Reference< css::util::XNumberFormatter > const &_rxFormatter)
set the evaluation flag at the number formatter
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99
OUString createDefaultName(const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData, const css::uno::Reference< css::container::XNameAccess > &_xTables, const OUString &_sName)
css::uno::Reference< css::uno::XInterface > getDataSourceOrModel(const css::uno::Reference< css::uno::XInterface > &_xObject)
returns either the model when data source is given as parameter, or returns a data source when a mode...
sal_Int32 askForUserAction(weld::Window *pParent, TranslateId pTitle, TranslateId pText, bool bAll, std::u16string_view rName)
returns the configuration node name of user defined drivers.
Definition: UITools.cxx:1149
bool isSQL92CheckEnabled(const css::uno::Reference< css::sdbc::XConnection > &_xConnection)
check if SQL92 name checking is enabled
std::shared_ptr< const SfxFilter > getStandardDatabaseFilter()
returns the standard database filter
Definition: UITools.cxx:861
sal_Int32 mapTextAlign(const SvxCellHorJustify &_eAlignment)
maps SvxCellHorJustify to css::awt::TextAlign
Definition: UITools.cxx:689
bool checkDataSourceAvailable(const OUString &_sDataSourceName, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
checks if the given name exists in the database context
bool appendToFilter(const css::uno::Reference< css::sdbc::XConnection > &xConnection, const OUString &rName, const css::uno::Reference< css::uno::XComponentContext > &rxContext, weld::Window *pParent)
append a name to tablefilter of a datasource
OUString getStrippedDatabaseName(const css::uno::Reference< css::beans::XPropertySet > &_xDataSource, OUString &_rsDatabaseName)
returns the stripped database name.
bool insertHierarchyElement(weld::Window *pParent, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::container::XHierarchicalNameContainer > &_xNames, const OUString &_sParentFolder, bool _bForm, bool _bCollection=true, const css::uno::Reference< css::ucb::XContent > &_xContent=nullptr, bool _bMove=false)
opens a save dialog to store a form or report folder in the current hierarchy.
SvxCellHorJustify