12e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 52e2212a7SAndrew Rist * distributed with this work for additional information 62e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 72e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 82e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 92e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 102e2212a7SAndrew Rist * 112e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 122e2212a7SAndrew Rist * 132e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 142e2212a7SAndrew Rist * software distributed under the License is distributed on an 152e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 172e2212a7SAndrew Rist * specific language governing permissions and limitations 182e2212a7SAndrew Rist * under the License. 192e2212a7SAndrew Rist * 202e2212a7SAndrew Rist *************************************************************/ 212e2212a7SAndrew Rist 222e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DBAUI_DBADMIN_HXX_ 25cdf0e10cSrcweir #define _DBAUI_DBADMIN_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _SFXTABDLG_HXX 28cdf0e10cSrcweir #include <sfx2/tabdlg.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _DBAUI_DSNTYPES_HXX_ 31cdf0e10cSrcweir #include "dsntypes.hxx" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef DBAUI_ITEMSETHELPER_HXX 34cdf0e10cSrcweir #include "IItemSetHelper.hxx" 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _COMPHELPER_UNO3_HXX_ 37cdf0e10cSrcweir #include <comphelper/uno3.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <memory> 40cdf0e10cSrcweir 41cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(beans,XPropertySet) 42cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(sdbc,XConnection) 43cdf0e10cSrcweir FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory) 44cdf0e10cSrcweir 45cdf0e10cSrcweir //......................................................................... 46cdf0e10cSrcweir namespace dbaui 47cdf0e10cSrcweir { 48cdf0e10cSrcweir //......................................................................... 49cdf0e10cSrcweir 50cdf0e10cSrcweir //========================================================================= 51cdf0e10cSrcweir //= ODbAdminDialog 52cdf0e10cSrcweir //========================================================================= 53cdf0e10cSrcweir class OGeneralPage; 54cdf0e10cSrcweir class ODbDataSourceAdministrationHelper; 55cdf0e10cSrcweir /** tab dialog for administrating the office wide registered data sources 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir class ODbAdminDialog : public SfxTabDialog , public IItemSetHelper, public IDatabaseSettingsDialog 58cdf0e10cSrcweir { 59cdf0e10cSrcweir private: 60cdf0e10cSrcweir typedef ::std::stack< sal_Int32 > PageStack; 61cdf0e10cSrcweir PageStack m_aCurrentDetailPages; // ids of all currently enabled (type-dependent) detail pages 62cdf0e10cSrcweir 63cdf0e10cSrcweir ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl; 64cdf0e10cSrcweir 65cdf0e10cSrcweir sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing 66cdf0e10cSrcweir sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/> 67cdf0e10cSrcweir sal_uInt16 m_nMainPageID; 68cdf0e10cSrcweir 69cdf0e10cSrcweir public: 70cdf0e10cSrcweir /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed 71cdf0e10cSrcweir after the dialog has been destroyed 72cdf0e10cSrcweir */ 73cdf0e10cSrcweir ODbAdminDialog(Window* pParent, 74cdf0e10cSrcweir SfxItemSet* _pItems, 75cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB 76cdf0e10cSrcweir ); 77cdf0e10cSrcweir virtual ~ODbAdminDialog(); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** create and return an item set for use with the dialog. 80cdf0e10cSrcweir @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case 81cdf0e10cSrcweir the pool will not contain a typecollection default. 82cdf0e10cSrcweir */ 83cdf0e10cSrcweir static SfxItemSet* createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection); 84cdf0e10cSrcweir /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method> 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir static void destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** selects the DataSource 89cdf0e10cSrcweir @param _rName 90cdf0e10cSrcweir The name of the data source 91cdf0e10cSrcweir */ 92cdf0e10cSrcweir void selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName); 93cdf0e10cSrcweir 94cdf0e10cSrcweir virtual const SfxItemSet* getOutputSet() const; 95cdf0e10cSrcweir virtual SfxItemSet* getWriteOutputSet(); 96cdf0e10cSrcweir 97cdf0e10cSrcweir // forwards to ODbDataSourceAdministrationHelper 98cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; 99cdf0e10cSrcweir virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); 100cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); 101cdf0e10cSrcweir virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; 102cdf0e10cSrcweir virtual void clearPassword(); 103cdf0e10cSrcweir virtual sal_Bool saveDatasource(); 104cdf0e10cSrcweir virtual void setTitle(const ::rtl::OUString& _sTitle); 105cdf0e10cSrcweir virtual void enableConfirmSettings( bool _bEnable ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir protected: 108cdf0e10cSrcweir // adds a new detail page and remove all the old ones 109cdf0e10cSrcweir void addDetailPage(sal_uInt16 _nPageId,sal_uInt16 _nTextId,CreateTabPage pCreateFunc); 110cdf0e10cSrcweir 111cdf0e10cSrcweir virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage); 112cdf0e10cSrcweir virtual short Ok(); 113cdf0e10cSrcweir 114cdf0e10cSrcweir protected: isUIEnabled() const115cdf0e10cSrcweir inline sal_Bool isUIEnabled() const { return m_bUIEnabled; } disabledUI()116cdf0e10cSrcweir inline void disabledUI() { m_bUIEnabled = sal_False; } 117cdf0e10cSrcweir 118cdf0e10cSrcweir private: 119cdf0e10cSrcweir /// select a datasource with a given name, adjust the item set accordingly, and everything like that .. 120cdf0e10cSrcweir void impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName); 121cdf0e10cSrcweir /// reset the tag pages according to m_sCurrentDatasource and <arg>_rxDatasource</arg> 122cdf0e10cSrcweir void impl_resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource); 123cdf0e10cSrcweir 124cdf0e10cSrcweir enum ApplyResult 125cdf0e10cSrcweir { 126cdf0e10cSrcweir AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed 127cdf0e10cSrcweir AR_LEAVE_UNCHANGED, // no changes were made 128*07a3d7f1SPedro Giffuni AR_KEEP // don't leave the page (e.g. because an error occurred) 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir /** apply all changes made 131cdf0e10cSrcweir */ 132cdf0e10cSrcweir ApplyResult implApplyChanges(); 133cdf0e10cSrcweir }; 134cdf0e10cSrcweir 135cdf0e10cSrcweir //......................................................................... 136cdf0e10cSrcweir } // namespace dbaui 137cdf0e10cSrcweir //......................................................................... 138cdf0e10cSrcweir 139cdf0e10cSrcweir #endif // _DBAUI_DBADMIN_HXX_ 140cdf0e10cSrcweir 141