Tag: cws_src680_os63 User: os Date: 05/08/01 23:44:07 Modified: /dba/dbaccess/source/ui/dlg/ generalpage.cxx
Log: RESYNC: (1.41-1.43); FILE MERGED File Changes: Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [changed]: generalpage.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/dlg/generalpage.cxx?r1=1.41.90.1&r2=1.41.90.2 Delta lines: +160 -79 ---------------------- --- generalpage.cxx 6 Jul 2005 12:50:07 -0000 1.41.90.1 +++ generalpage.cxx 2 Aug 2005 06:44:04 -0000 1.41.90.2 @@ -104,9 +104,21 @@ #ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ #include <com/sun/star/sdbc/XDriverAccess.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif #ifndef DBAUI_DRIVERSETTINGS_HXX #include "DriverSettings.hxx" #endif +#ifndef DBACCESS_SOURCE_UI_INC_DIALOGCONTROLLING_HXX +#include "dialogcontrolling.hxx" +#endif //......................................................................... namespace dbaui @@ -114,6 +126,9 @@ //......................................................................... using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::container; + //========================================================================= //= OGeneralPage //========================================================================= @@ -124,13 +139,17 @@ ,m_aTypePostLabel (this, ResId(FT_DATASOURCETYPE_POST)) ,m_aSpecialMessage (this, ResId(FT_SPECIAL_MESSAGE)) ,m_aDatasourceTypeLabel (this, ResId(FT_DATATYPE)) - ,m_aDatasourceType (this, ResId(LB_DATATYPE)) + ,m_pDatasourceType ( new ListBox(this, ResId(LB_DATATYPE))) ,m_aFT_DatasourceTypeHeader (this, ResId(FT_DATASOURCEHEADER)) ,m_aRB_CreateDatabase (this, ResId(RB_CREATEDBDATABASE)) ,m_aRB_GetExistingDatabase (this, ResId(RB_GETEXISTINGDATABASE)) + ,m_aRB_OpenDocument (this, ResId(RB_OPENEXISTINGDOC)) ,m_aFTHeaderText (this, ResId(FT_GENERALHEADERTEXT)) ,m_aFTHelpText (this, ResId(FT_GENERALHELPTEXT)) ,m_aFTDataSourceAppendix (this, ResId(FT_DATATYPEAPPENDIX)) + ,m_pLB_DocumentList ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ResId( LB_DOCUMENTLIST ) ) ) + ,m_aFT_DocListLabel (this, ResId(FT_DOCLISTLABEL)) + ,m_aPB_OpenDocument (this, "com.sun.star.sdb.OfficeDatabaseDocument", ResId(PB_OPENDOCUMENT)) ,m_sMySQLEntry (ResId(STR_MYSQLENTRY)) ,m_pCollection (NULL) ,m_eCurrentSelection (DST_UNKNOWN) @@ -151,17 +170,27 @@ DBG_ASSERT(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !"); // do some knittings - m_aDatasourceType.SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected)); + m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected)); m_aRB_CreateDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected)); m_aRB_GetExistingDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected)); + m_aRB_OpenDocument.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected)); m_aRB_CreateDatabase.Check(); + + m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPage, OnDocumentSelected ) ); + m_aPB_OpenDocument.SetClickHdl( LINK( this, OGeneralPage, OnOpenDocument ) ); } + //------------------------------------------------------------------------- + OGeneralPage::~OGeneralPage() + { + m_pDatasourceType.reset( NULL ); + m_pLB_DocumentList.reset( NULL ); + } //------------------------------------------------------------------------- void OGeneralPage::initializeTypeList() { - m_aDatasourceType.Clear(); + m_pDatasourceType->Clear(); Reference< XDriverAccess > xDriverManager; @@ -199,7 +228,7 @@ continue; } String sDisplayName = aTypeLoop.getDisplayName(); - if ( m_aDatasourceType.GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND ) + if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND ) { sDisplayName = VerifyDisplayName(eType, sDisplayName); if (sDisplayName.Len() > 0) @@ -242,26 +271,24 @@ } } - - void OGeneralPage::SetToCreationMode(sal_Bool _bCreate){ - if (_bCreate) - m_aRB_CreateDatabase.Check(); - else - m_aRB_GetExistingDatabase.Check(); - } - - - sal_Bool OGeneralPage::IsDatabaseToBeCreated(){ - return m_aRB_CreateDatabase.IsChecked(); + //------------------------------------------------------------------------- + OGeneralPage::CreationMode OGeneralPage::GetDatabaseCreationMode() const + { + if ( m_aRB_CreateDatabase.IsChecked() ) + return eCreateNew; + if ( m_aRB_GetExistingDatabase.IsChecked() ) + return eConnectExternal; + return eOpenExisting; } - //------------------------------------------------------------------------- void OGeneralPage::GetFocus() { OGenericAdministrationPage::GetFocus(); - if (m_aDatasourceType.IsEnabled()) - m_aDatasourceType.GrabFocus(); + if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() ) + m_pLB_DocumentList->GrabFocus(); + else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled()) + m_pDatasourceType->GrabFocus(); } //------------------------------------------------------------------------- @@ -305,13 +332,10 @@ m_aTypeSelectHandler.Call(this); } - //------------------------------------------------------------------------- void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) { initializeHistory(); -// if (m_aDatasourceType.GetEntryCount() > 0) -// return; initializeTypeList(); // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) @@ -322,27 +346,45 @@ m_aTypePreLabel.Hide(); m_aTypePostLabel.Hide(); m_aSpecialMessage.Hide(); - m_aDatasourceTypeLabel.SetPosPixel( MovePoint( m_aRB_GetExistingDatabase.GetPosPixel(), 10, 14 ) ); - m_aDatasourceType.SetPosPixel( MovePoint( m_aRB_GetExistingDatabase.GetPosPixel(), 90, 12) ); - m_aFTDataSourceAppendix.SetPosPixel( MovePoint(m_aRB_GetExistingDatabase.GetPosPixel(), 162, 14) ); SetControlFontWeight(&m_aFTHeaderText); - SetText(::rtl::OUString::createFromAscii("")); - m_aDatasourceTypeLabel.Enable(bValid && m_aRB_GetExistingDatabase.IsChecked()); - m_aDatasourceType.Enable(bValid && m_aRB_GetExistingDatabase.IsChecked()); - m_aFTDataSourceAppendix.Enable(bValid && m_aRB_GetExistingDatabase.IsChecked()); - m_bEntryCreationMode = IsDatabaseToBeCreated(); + SetText(String()); + + m_pDatasourceType->SetPosPixel( MovePoint( m_aRB_GetExistingDatabase.GetPosPixel(), INDENT_BELOW_RADIO, 14 ) ); + + m_pSelectTypeController.reset( new RadioDependentEnabler( m_aRB_GetExistingDatabase, !bValid || bReadonly ) ); + m_pSelectTypeController->addDependentWindow( m_aDatasourceTypeLabel ); + m_pSelectTypeController->addDependentWindow( *m_pDatasourceType ); + m_pSelectTypeController->addDependentWindow( m_aFTDataSourceAppendix ); + + m_pOpenDocController.reset( new RadioDependentEnabler( m_aRB_OpenDocument, !bValid || bReadonly ) ); + m_pOpenDocController->addDependentWindow( m_aPB_OpenDocument ); + m_pOpenDocController->addDependentWindow( m_aFT_DocListLabel ); + m_pOpenDocController->addDependentWindow( *m_pLB_DocumentList ); + + m_pLB_DocumentList->SetDropDownLineCount( 20 ); + if ( m_pLB_DocumentList->GetEntryCount() ) + m_pLB_DocumentList->SelectEntryPos( 0 ); + + m_aDatasourceTypeLabel.Hide(); + m_aFTDataSourceAppendix.Hide(); + + m_eOriginalCreationMode = GetDatabaseCreationMode(); } else { m_aFT_DatasourceTypeHeader.Hide(); m_aRB_CreateDatabase.Hide(); m_aRB_GetExistingDatabase.Hide(); + m_aRB_OpenDocument.Hide(); + m_aPB_OpenDocument.Hide(); + m_aFT_DocListLabel.Hide(); + m_pLB_DocumentList->Hide(); m_aFTHeaderText.Hide(); m_aFTHelpText.Hide(); m_aTypePreLabel.Enable(bValid); m_aTypePostLabel.Enable(bValid); m_aDatasourceTypeLabel.Enable(bValid); - m_aDatasourceType.Enable(bValid); + m_pDatasourceType->Enable(bValid); } // if the selection is invalid, disable evrything String sName,sConnectURL; @@ -373,7 +415,7 @@ } sDisplayName = VerifyDisplayName(m_eCurrentSelection, sDisplayName); // select the correct datasource type - if (LISTBOX_ENTRY_NOTFOUND == m_aDatasourceType.GetEntryPos(sDisplayName)) + if (LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos(sDisplayName)) { // the type is not available on this platform (we omitted it in initializeTypeList) if (sDisplayName.Len()) { // this indicates it's really a type which is known in general, but not supported on the current platform @@ -386,8 +428,8 @@ } } if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode) - sDisplayName = m_pCollection->getTypeDisplayName(DST_DBASE); - m_aDatasourceType.SelectEntry(sDisplayName); + sDisplayName = m_pCollection->getTypeDisplayName(DST_JDBC); + m_pDatasourceType->SelectEntry(sDisplayName); // notify our listener that our type selection has changed (if so) if ( eOldSelection != m_eCurrentSelection ) @@ -421,14 +463,14 @@ } + // ----------------------------------------------------------------------- void OGeneralPage::insertDatasourceTypeEntryData(DATASOURCE_TYPE _eType, String sDisplayName) { // insert a (temporary) entry - sal_uInt16 nPos = m_aDatasourceType.InsertEntry(sDisplayName); - m_aDatasourceType.SetEntryData(nPos, reinterpret_cast<void*>(_eType)); + sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName); + m_pDatasourceType->SetEntryData(nPos, reinterpret_cast<void*>(_eType)); } - // ----------------------------------------------------------------------- void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) { @@ -441,7 +483,7 @@ // ----------------------------------------------------------------------- void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) { - _rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aDatasourceType)); + _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pDatasourceType.get())); } //------------------------------------------------------------------------- @@ -475,19 +517,35 @@ BOOL OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs) { sal_Bool bChangedSomething = sal_False; - if (m_aRB_CreateDatabase.IsChecked() && (m_DBWizardMode)) + + bool bCommitTypeSelection = true; + if ( m_DBWizardMode ) + { + if ( m_aRB_CreateDatabase.IsChecked() ) { _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(DST_DBASE))); bChangedSomething = sal_True; + bCommitTypeSelection = false; } - else + else if ( m_aRB_OpenDocument.IsChecked() ) { - USHORT nEntry = m_aDatasourceType.GetSelectEntryPos(); - DATASOURCE_TYPE eSelectedType = static_cast<DATASOURCE_TYPE>(reinterpret_cast<sal_Int32>(m_aDatasourceType.GetEntryData(nEntry))); + if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() ) + bChangedSomething = sal_True; + + // TODO + bCommitTypeSelection = false; + } + } + + if ( bCommitTypeSelection ) + { + USHORT nEntry = m_pDatasourceType->GetSelectEntryPos(); + DATASOURCE_TYPE eSelectedType = static_cast<DATASOURCE_TYPE>(reinterpret_cast<sal_Int32>(m_pDatasourceType->GetEntryData(nEntry))); if (m_DBWizardMode) { - sal_Bool bCurCreationMode = IsDatabaseToBeCreated(); - if (( m_aDatasourceType.GetSavedValue() != nEntry) || (bCurCreationMode != m_bEntryCreationMode)) + if ( ( m_pDatasourceType->GetSavedValue() != nEntry ) + || ( GetDatabaseCreationMode() != m_eOriginalCreationMode ) + ) { _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType))); bChangedSomething = sal_True; @@ -497,7 +555,7 @@ } else { - if ( m_aDatasourceType.GetSavedValue() != nEntry) + if ( m_pDatasourceType->GetSavedValue() != nEntry) { _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType))); bChangedSomething = sal_True; @@ -523,27 +581,50 @@ return 0L; } - IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, _pBox) + //------------------------------------------------------------------------- + OGeneralPage::DocumentDescriptor OGeneralPage::GetSelectedDocument() const { - String sDisplayName; - sal_Bool bEnable = m_aRB_GetExistingDatabase.IsChecked(); - m_aDatasourceTypeLabel.Enable(bEnable); - m_aDatasourceType.Enable(bEnable); - m_aFTDataSourceAppendix.Enable(bEnable); - if (!bEnable) - sDisplayName = m_pCollection->getTypeDisplayName(DST_DBASE); - else - sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection); - USHORT n = m_aDatasourceType.GetEntryPos(sDisplayName); - if ((n < m_aDatasourceType.GetEntryCount()) && (n >= 0)) - m_aDatasourceType.SelectEntry(sDisplayName); + DocumentDescriptor aDocument; + if ( m_aBrowsedDocument.sURL.Len() ) + aDocument = m_aBrowsedDocument; else - m_aDatasourceType.SelectEntry(m_sMySQLEntry); + { + aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL(); + aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter(); + } + return aDocument; + } + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, _pBox) + { if ( m_aCreationModeHandler.IsSet() ) m_aCreationModeHandler.Call(this); return 1L; } - // ----------------------------------------------------------------------- + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnDocumentSelected, ListBox*, _pBox) + { + m_aDocumentSelectionHandler.Call( this ); + return 0L; + } + + //------------------------------------------------------------------------- + IMPL_LINK(OGeneralPage, OnOpenDocument, PushButton*, _pBox) + { + ::sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("sdatabase") ); + if ( aFileDlg.Execute() == ERRCODE_NONE ) + { + m_aBrowsedDocument.sURL = aFileDlg.GetPath(); + m_aBrowsedDocument.sFilter = String(); + m_aChooseDocumentHandler.Call( this ); + return 1L; + } + + return 0L; + } + //......................................................................... } // namespace dbaui //......................................................................... --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
