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