1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_INC_DBADMIN_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_DBADMIN_HXX
23 #include <sfx2/tabdlg.hxx>
24 #include "dsntypes.hxx"
25 #include "IItemSetHelper.hxx"
26 #include <comphelper/uno3.hxx>
29 namespace com
{ namespace sun
{ namespace star
{
37 class XMultiServiceFactory
;
45 class ODbDataSourceAdministrationHelper
;
46 /** tab dialog for administrating the office wide registered data sources
48 class ODbAdminDialog
: public SfxTabDialog
, public IItemSetHelper
, public IDatabaseSettingsDialog
51 typedef ::std::stack
< sal_Int32
> PageStack
;
52 PageStack m_aCurrentDetailPages
; // ids of all currently enabled (type-dependent) detail pages
54 ::std::unique_ptr
<ODbDataSourceAdministrationHelper
> m_pImpl
;
56 bool m_bApplied
: 1; /// sal_True if any changes have been applied while the dialog was executing
57 bool m_bUIEnabled
: 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
58 sal_uInt16 m_nMainPageID
;
61 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
62 after the dialog has been destroyed
64 ODbAdminDialog(vcl::Window
* pParent
,
66 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxORB
68 virtual ~ODbAdminDialog();
69 virtual void dispose() SAL_OVERRIDE
;
71 /** create and return an item set for use with the dialog.
72 @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case
73 the pool will not contain a typecollection default.
75 static SfxItemSet
* createItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
, ::dbaccess::ODsnTypeCollection
* _pTypeCollection
);
76 /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method>
78 static void destroyItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
);
80 /** selects the DataSource
82 The name of the data source
84 void selectDataSource(const ::com::sun::star::uno::Any
& _aDataSourceName
);
86 virtual const SfxItemSet
* getOutputSet() const SAL_OVERRIDE
;
87 virtual SfxItemSet
* getWriteOutputSet() SAL_OVERRIDE
;
89 // forwards to ODbDataSourceAdministrationHelper
90 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> getORB() const SAL_OVERRIDE
;
91 virtual ::std::pair
< ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>,sal_Bool
> createConnection() SAL_OVERRIDE
;
92 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> getDriver() SAL_OVERRIDE
;
93 virtual OUString
getDatasourceType(const SfxItemSet
& _rSet
) const SAL_OVERRIDE
;
94 virtual void clearPassword() SAL_OVERRIDE
;
95 virtual bool saveDatasource() SAL_OVERRIDE
;
96 virtual void setTitle(const OUString
& _sTitle
) SAL_OVERRIDE
;
97 virtual void enableConfirmSettings( bool _bEnable
) SAL_OVERRIDE
;
100 // adds a new detail page and remove all the old ones
101 void addDetailPage(sal_uInt16 _nPageId
,sal_uInt16 _nTextId
,CreateTabPage pCreateFunc
);
103 virtual void PageCreated(sal_uInt16 _nId
, SfxTabPage
& _rPage
) SAL_OVERRIDE
;
104 virtual short Ok() SAL_OVERRIDE
;
107 inline bool isUIEnabled() const { return m_bUIEnabled
; }
108 inline void disabledUI() { m_bUIEnabled
= false; }
111 /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
112 void impl_selectDataSource(const ::com::sun::star::uno::Any
& _aDataSourceName
);
113 /// reset the tag pages according to m_sCurrentDatasource and <arg>_rxDatasource</arg>
114 void impl_resetPages(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxDatasource
);
118 AR_LEAVE_MODIFIED
, // something was modified and has successfully been committed
119 AR_LEAVE_UNCHANGED
, // no changes were made
120 AR_KEEP
// don't leave the page (e.g. because an error occurred)
122 /** apply all changes made
124 ApplyResult
implApplyChanges();
129 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DBADMIN_HXX
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */