User: kz Date: 05/06/30 09:33:18 Modified: /dba/dbaccess/source/ui/dlg/ generalpage.cxx
Log: INTEGRATION: CWS wizopendb (1.41.86); FILE MERGED 2005/06/14 14:58:46 fs 1.41.86.2: #i42477# layout changes 2005/06/06 10:40:41 fs 1.41.86.1: #i42477# allow the 'New Database' wizard to load existing documents 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&r2=1.42 Delta lines: +154 -61 ---------------------- --- generalpage.cxx 21 Jan 2005 17:15:41 -0000 1.41 +++ generalpage.cxx 30 Jun 2005 16:33:15 -0000 1.42 @@ -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 //========================================================================= @@ -128,9 +143,13 @@ ,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) @@ -154,9 +173,18 @@ m_aDatasourceType.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_pLB_DocumentList.reset( NULL ); + } //------------------------------------------------------------------------- void OGeneralPage::initializeTypeList() @@ -242,26 +270,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(); } //------------------------------------------------------------------------- @@ -305,13 +331,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,26 +345,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_aDatasourceType.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_aDatasourceType ); + 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_aFTDataSourceAppendix.Enable(bValid); m_aDatasourceType.Enable(bValid); } // if the selection is invalid, disable evrything @@ -386,7 +428,7 @@ } } if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode) - sDisplayName = m_pCollection->getTypeDisplayName(DST_DBASE); + sDisplayName = m_pCollection->getTypeDisplayName(DST_JDBC); m_aDatasourceType.SelectEntry(sDisplayName); // notify our listener that our type selection has changed (if so) @@ -421,6 +463,7 @@ } + // ----------------------------------------------------------------------- void OGeneralPage::insertDatasourceTypeEntryData(DATASOURCE_TYPE _eType, String sDisplayName) { // insert a (temporary) entry @@ -428,7 +471,6 @@ m_aDatasourceType.SetEntryData(nPos, reinterpret_cast<void*>(_eType)); } - // ----------------------------------------------------------------------- void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) { @@ -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() ) + { + if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() ) + bChangedSomething = sal_True; + + // TODO + bCommitTypeSelection = false; + } + } + + if ( bCommitTypeSelection ) { USHORT nEntry = m_aDatasourceType.GetSelectEntryPos(); DATASOURCE_TYPE eSelectedType = static_cast<DATASOURCE_TYPE>(reinterpret_cast<sal_Int32>(m_aDatasourceType.GetEntryData(nEntry))); if (m_DBWizardMode) { - sal_Bool bCurCreationMode = IsDatabaseToBeCreated(); - if (( m_aDatasourceType.GetSavedValue() != nEntry) || (bCurCreationMode != m_bEntryCreationMode)) + if ( ( m_aDatasourceType.GetSavedValue() != nEntry ) + || ( GetDatabaseCreationMode() != m_eOriginalCreationMode ) + ) { _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType))); bChangedSomething = sal_True; @@ -523,27 +581,62 @@ 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); + DocumentDescriptor aDocument; + if ( m_aBrowsedDocument.sURL.Len() ) + aDocument = m_aBrowsedDocument; else - sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection); - USHORT n = m_aDatasourceType.GetEntryPos(sDisplayName); - if ((n < m_aDatasourceType.GetEntryCount()) && (n >= 0)) - m_aDatasourceType.SelectEntry(sDisplayName); - 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) + { + // TODO: nearly all of this could be outsourced to a IWindowOperator, and + // triggered via a DialogController, couldn't it? +// String sDisplayName; +// if (m_aRB_CreateDatabase.IsChecked()) +// 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); +// else +// m_aDatasourceType.SelectEntry(m_sMySQLEntry); 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]
