LibreOffice Module dbaccess (master) 1
DbAdminImpl.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
20#pragma once
21
22#include <sal/config.h>
23
24#include <map>
25
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/beans/PropertyValue.hpp>
28#include <com/sun/star/sdb/XDatabaseContext.hpp>
29#include <com/sun/star/sdbc/XConnection.hpp>
30#include <com/sun/star/sdbc/XDriver.hpp>
31#include <dsntypes.hxx>
32#include <svl/itemset.hxx>
33#include <com/sun/star/frame/XModel.hpp>
34#include <svl/poolitem.hxx>
35#include <vcl/weld.hxx>
36
37namespace dbaui
38{
39 namespace DataSourceInfoConverter
40 {
41 void convert(const css::uno::Reference< css::uno::XComponentContext> & xContext,
42 const ::dbaccess::ODsnTypeCollection* _pCollection,
43 std::u16string_view _sOldURLPrefix,
44 std::u16string_view _sNewURLPrefix,
45 const css::uno::Reference< css::beans::XPropertySet >& _xDatasource);
46 };
47 class IItemSetHelper;
48 // ODbDataSourceAdministrationHelper
50 {
51 public:
52 typedef std::map<sal_Int32, OUString> MapInt2String;
53
54 private:
55 css::uno::Reference< css::uno::XComponentContext >
57 css::uno::Reference< css::sdb::XDatabaseContext >
59 css::uno::Reference< css::beans::XPropertySet > m_xDatasource;
60 css::uno::Reference< css::frame::XModel > m_xModel;
61
62 css::uno::Any m_aDataSourceOrName;
63
68 public:
69
70 ODbDataSourceAdministrationHelper(const css::uno::Reference< css::uno::XComponentContext >& _xORB,
71 weld::Window* pParent, weld::Window* pTopParent,
72 IItemSetHelper* _pItemSetHelper);
73
77 bool getCurrentSettings(css::uno::Sequence< css::beans::PropertyValue >& _rDriverParams);
78
83
85 void clearPassword();
86
87 const css::uno::Reference< css::uno::XComponentContext >& getORB() const { return m_xContext; }
88
91 std::pair< css::uno::Reference< css::sdbc::XConnection >,bool> createConnection();
92
95 css::uno::Reference< css::sdbc::XDriver > getDriver();
96 css::uno::Reference< css::sdbc::XDriver > getDriver(const OUString& _sURL);
97
100 css::uno::Reference< css::beans::XPropertySet > const & getCurrentDataSource();
101 // returns the Url of a database document
102 static OUString getDocumentUrl(SfxItemSet const & _rDest);
103
104 void setDataSourceOrName( const css::uno::Any& _rDataSourceOrName );
105
109 static OUString getDatasourceType( const SfxItemSet& _rSet );
110
115 OUString getConnectionURL() const;
116
118 static void convertUrl(SfxItemSet& _rDest);
119
121
129 const css::uno::Reference< css::beans::XPropertySet >& _rxSource,
130 SfxItemSet& _rDest);
131
139 const SfxItemSet& _rSource,
140 const css::uno::Reference< css::beans::XPropertySet >& _rxDest);
141
142 bool saveChanges(const SfxItemSet& _rSource);
143 private:
146 void fillDatasourceInfo(const SfxItemSet& _rSource, css::uno::Sequence< css::beans::PropertyValue >& _rInfo);
147
149 void implTranslateProperty(SfxItemSet& _rSet, sal_Int32 _nId, const css::uno::Any& _rValue);
150
152 static css::uno::Any implTranslateProperty(const SfxPoolItem* _pItem);
153
155 static void implTranslateProperty(const css::uno::Reference< css::beans::XPropertySet >& _rxSet, const OUString& _rName, const SfxPoolItem* _pItem);
156
160 static bool hasAuthentication(const SfxItemSet& _rSet);
161
162 OString translatePropertyId( sal_Int32 _nId );
163 };
164
165} // namespace dbaui
166
167/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void implTranslateProperty(const css::uno::Reference< css::beans::XPropertySet > &_rxSet, const OUString &_rName, const SfxPoolItem *_pItem)
translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>,...
bool getCurrentSettings(css::uno::Sequence< css::beans::PropertyValue > &_rDriverParams)
translate the current dialog SfxItems into driver relevant PropertyValues
const MapInt2String & getIndirectProperties() const
std::pair< css::uno::Reference< css::sdbc::XConnection >, bool > createConnection()
creates a new connection.
OString translatePropertyId(sal_Int32 _nId)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: DbAdminImpl.hxx:56
css::uno::Reference< css::sdbc::XDriver > getDriver()
return the corresponding driver for the selected URL
const css::uno::Reference< css::uno::XComponentContext > & getORB() const
Definition: DbAdminImpl.hxx:87
std::map< sal_Int32, OUString > MapInt2String
Definition: DbAdminImpl.hxx:52
css::uno::Reference< css::beans::XPropertySet > m_xDatasource
database context we're working in
Definition: DbAdminImpl.hxx:59
void successfullyConnected()
to be called if the settings got from getCurrentSettings have been used for successfully connecting
void clearPassword()
clear the password in the current data source's item set
static OUString getDocumentUrl(SfxItemSet const &_rDest)
weld::Window * m_pParent
translating property id's into names (indirect properties of a data source)
Definition: DbAdminImpl.hxx:66
static void convertUrl(SfxItemSet &_rDest)
fill the necessary information from the url line
void setDataSourceOrName(const css::uno::Any &_rDataSourceOrName)
css::uno::Reference< css::beans::XPropertySet > const & getCurrentDataSource()
returns the data source the dialog is currently working with
static OUString getDatasourceType(const SfxItemSet &_rSet)
extracts the connection type from the given setThe connection type is determined by the value of the ...
void implTranslateProperty(SfxItemSet &_rSet, sal_Int32 _nId, const css::uno::Any &_rValue)
translate the given value into an SfxPoolItem, put this into the given set under the given id
ODbDataSourceAdministrationHelper(const css::uno::Reference< css::uno::XComponentContext > &_xORB, weld::Window *pParent, weld::Window *pTopParent, IItemSetHelper *_pItemSetHelper)
OUString getConnectionURL() const
returns the connection URL
void translateProperties(const SfxItemSet &_rSource, const css::uno::Reference< css::beans::XPropertySet > &_rxDest)
translate SfxItems into properties of a UNO data source
void translateProperties(const css::uno::Reference< css::beans::XPropertySet > &_rxSource, SfxItemSet &_rDest)
translates properties of a UNO data source into SfxItems
void fillDatasourceInfo(const SfxItemSet &_rSource, css::uno::Sequence< css::beans::PropertyValue > &_rInfo)
fill a data source info array with the settings from a given item set
css::uno::Reference< css::sdb::XDatabaseContext > m_xDatabaseContext
service factory
Definition: DbAdminImpl.hxx:58
static bool hasAuthentication(const SfxItemSet &_rSet)
check if the data source described by the given set needs authenticationThe return value depends on t...
bool saveChanges(const SfxItemSet &_rSource)
MapInt2String m_aIndirectPropTranslator
translating property id's into names (direct properties of a data source)
Definition: DbAdminImpl.hxx:65
css::uno::Reference< css::frame::XModel > m_xModel
Definition: DbAdminImpl.hxx:60
void convert(const css::uno::Reference< css::uno::XComponentContext > &xContext, const ::dbaccess::ODsnTypeCollection *_pCollection, std::u16string_view _sOldURLPrefix, std::u16string_view _sNewURLPrefix, const css::uno::Reference< css::beans::XPropertySet > &_xDatasource)