fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / dlg / DbAdminImpl.hxx
blob0e7803d9e9bcd31dd57717394e26c3f6f2abdff0
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_DLG_DBADMINIMPL_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_DLG_DBADMINIMPL_HXX
23 #include <sal/config.h>
25 #include <map>
26 #include <set>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <com/sun/star/sdb/XDatabaseContext.hpp>
32 #include <com/sun/star/sdbc/XConnection.hpp>
33 #include <com/sun/star/sdbc/XDriver.hpp>
34 #include "dsntypes.hxx"
35 #include <svl/itemset.hxx>
36 #include <com/sun/star/frame/XModel.hpp>
37 #include <svl/poolitem.hxx>
38 #include <vcl/vclptr.hxx>
40 namespace vcl { class Window; }
41 namespace dbaui
43 namespace DataSourceInfoConverter
45 void convert(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> & xContext,
46 const ::dbaccess::ODsnTypeCollection* _pCollection,
47 const OUString& _sOldURLPrefix,
48 const OUString& _sNewURLPrefix,
49 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource);
51 class IItemSetHelper;
52 // ODbDataSourceAdministrationHelper
53 class ODbDataSourceAdministrationHelper
55 public:
56 typedef std::map<sal_Int32, OUString> MapInt2String;
58 private:
59 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
60 m_xContext; /// service factory
61 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseContext >
62 m_xDatabaseContext; /// database context we're working in
63 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDatasource;
64 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
66 ::com::sun::star::uno::Any m_aDataSourceOrName;
67 typedef ::std::set< OUString > StringSet;
68 typedef StringSet::const_iterator ConstStringSetIterator;
70 MapInt2String m_aDirectPropTranslator; /// translating property id's into names (direct properties of a data source)
71 MapInt2String m_aIndirectPropTranslator; /// translating property id's into names (indirect properties of a data source)
72 VclPtr<vcl::Window> m_pParent;
73 IItemSetHelper* m_pItemSetHelper;
74 public:
76 ODbDataSourceAdministrationHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xORB
77 ,vcl::Window* _pParent
78 ,IItemSetHelper* _pItemSetHelper);
80 /** translate the current dialog SfxItems into driver relevant PropertyValues
81 @see successfullyConnected
83 bool getCurrentSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverParams);
85 /** to be called if the settings got from getCurrentSettings have been used for successfully connecting
86 @see getCurrentSettings
88 void successfullyConnected();
90 /// clear the password in the current data source's item set
91 void clearPassword();
93 inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getORB() const { return m_xContext; }
95 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseContext > getDatabaseContext() const { return m_xDatabaseContext; }
97 /** creates a new connection. The caller is responsible to dispose it !!!!
99 ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
101 /** return the corresponding driver for the selected URL
103 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
104 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(const OUString& _sURL);
106 /** returns the data source the dialog is currently working with
108 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getCurrentDataSource();
109 // returns the Url of a database document
110 static OUString getDocumentUrl(SfxItemSet& _rDest);
112 void setDataSourceOrName( const ::com::sun::star::uno::Any& _rDataSourceOrName );
114 /** extracts the connection type from the given set<p/>
115 The connection type is determined by the value of the DSN item, analyzed by the TypeCollection item.
117 static OUString getDatasourceType( const SfxItemSet& _rSet );
119 /** returns the connection URL
120 @return
121 The connection URL
123 OUString getConnectionURL() const;
125 /// fill the necessary information from the url line
126 static void convertUrl(SfxItemSet& _rDest);
128 const MapInt2String& getIndirectProperties() const { return m_aIndirectPropTranslator; }
130 /** translates properties of an UNO data source into SfxItems
131 @param _rxSource
132 The data source
133 @param _rDest
134 The item set to fill.
136 void translateProperties(
137 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSource,
138 SfxItemSet& _rDest);
140 /** translate SfxItems into properties of an UNO data source
141 @param _rSource
142 The item set to read from.
143 @param _rxDest
144 The data source to fill.
146 void translateProperties(
147 const SfxItemSet& _rSource,
148 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDest);
150 bool saveChanges(const SfxItemSet& _rSource);
151 protected:
152 /** fill a data source info array with the settings from a given item set
154 void fillDatasourceInfo(const SfxItemSet& _rSource, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
156 /// translate the given value into an SfxPoolItem, put this into the given set under the given id
157 void implTranslateProperty(SfxItemSet& _rSet, sal_Int32 _nId, const ::com::sun::star::uno::Any& _rValue);
159 /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>
160 static ::com::sun::star::uno::Any implTranslateProperty(const SfxPoolItem* _pItem);
162 /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>, set it (under the given name) on the given property set
163 static void implTranslateProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSet, const OUString& _rName, const SfxPoolItem* _pItem);
165 /** check if the data source described by the given set needs authentication<p/>
166 The return value depends on the data source type only.
168 static bool hasAuthentication(const SfxItemSet& _rSet);
170 #if OSL_DEBUG_LEVEL > 0
171 OString translatePropertyId( sal_Int32 _nId );
172 #endif
175 } // namespace dbaui
177 #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_DBADMINIMPL_HXX
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */