merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / inc / dbadmin.hxx
blob3dcd68f5cae50e4cb744a72cf9ed60410469a468
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbadmin.hxx,v $
10 * $Revision: 1.36.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBAUI_DBADMIN_HXX_
32 #define _DBAUI_DBADMIN_HXX_
34 #ifndef _SFXTABDLG_HXX
35 #include <sfx2/tabdlg.hxx>
36 #endif
37 #ifndef _DBAUI_DSNTYPES_HXX_
38 #include "dsntypes.hxx"
39 #endif
40 #ifndef DBAUI_ITEMSETHELPER_HXX
41 #include "IItemSetHelper.hxx"
42 #endif
43 #ifndef _COMPHELPER_UNO3_HXX_
44 #include <comphelper/uno3.hxx>
45 #endif
46 #include <memory>
48 FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
49 FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
50 FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
52 //.........................................................................
53 namespace dbaui
55 //.........................................................................
57 //=========================================================================
58 //= ODbAdminDialog
59 //=========================================================================
60 class OGeneralPage;
61 class ODbDataSourceAdministrationHelper;
62 /** tab dialog for administrating the office wide registered data sources
64 class ODbAdminDialog : public SfxTabDialog , public IItemSetHelper, public IDatabaseSettingsDialog
66 private:
67 typedef ::std::stack< sal_Int32 > PageStack;
68 PageStack m_aCurrentDetailPages; // ids of all currently enabled (type-dependent) detail pages
70 ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
72 sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing
73 sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
74 USHORT m_nMainPageID;
76 public:
77 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
78 after the dialog has been destroyed
80 ODbAdminDialog(Window* pParent,
81 SfxItemSet* _pItems,
82 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
84 virtual ~ODbAdminDialog();
86 /** create and return an item set for use with the dialog.
87 @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case
88 the pool will not contain a typecollection default.
90 static SfxItemSet* createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection);
91 /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method>
93 static void destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults);
95 /** selects the DataSource
96 @param _rName
97 The name of the data source
99 void selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName);
101 virtual const SfxItemSet* getOutputSet() const;
102 virtual SfxItemSet* getWriteOutputSet();
104 // forwards to ODbDataSourceAdministrationHelper
105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
106 virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
107 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
108 virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
109 virtual void clearPassword();
110 virtual sal_Bool saveDatasource();
111 virtual void setTitle(const ::rtl::OUString& _sTitle);
112 virtual void enableConfirmSettings( bool _bEnable );
114 protected:
115 // adds a new detail page and remove all the old ones
116 void addDetailPage(USHORT _nPageId,USHORT _nTextId,CreateTabPage pCreateFunc);
117 // removes all detail pages
118 void removeDetailPages();
120 virtual void PageCreated(USHORT _nId, SfxTabPage& _rPage);
121 virtual short Ok();
123 protected:
124 inline sal_Bool isUIEnabled() const { return m_bUIEnabled; }
125 inline void disabledUI() { m_bUIEnabled = sal_False; }
127 private:
128 /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
129 void impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName);
130 /// reset the tag pages according to m_sCurrentDatasource and <arg>_rxDatasource</arg>
131 void impl_resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource);
133 enum ApplyResult
135 AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed
136 AR_LEAVE_UNCHANGED, // no changes were made
137 AR_KEEP // don't leave the page (e.g. because an error occured)
139 /** apply all changes made
141 ApplyResult implApplyChanges();
144 //.........................................................................
145 } // namespace dbaui
146 //.........................................................................
148 #endif // _DBAUI_DBADMIN_HXX_