Tag: cws_src680_dba20blocker User: fs Date: 05/07/04 01:25:52 Modified: /dba/dbaccess/source/ui/dlg/ generalpage.cxx
Log: RESYNC: (1.41-1.42); 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.102.1&r2=1.41.102.2 Delta lines: +146 -70 ---------------------- --- generalpage.cxx 23 Jun 2005 15:22:36 -0000 1.41.102.1 +++ generalpage.cxx 4 Jul 2005 08:25:49 -0000 1.41.102.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 //========================================================================= @@ -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,13 +173,18 @@ 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 = ::std::auto_ptr< ListBox >(); + m_pDatasourceType.reset( NULL ); + m_pLB_DocumentList.reset( NULL ); } //------------------------------------------------------------------------- @@ -247,25 +271,23 @@ } } - - 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_pDatasourceType.get() && m_pDatasourceType->IsEnabled()) + if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() ) + m_pLB_DocumentList->GrabFocus(); + else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled()) m_pDatasourceType->GrabFocus(); } @@ -310,13 +332,10 @@ m_aTypeSelectHandler.Call(this); } - //------------------------------------------------------------------------- void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) { initializeHistory(); -// if (m_pDatasourceType->GetEntryCount() > 0) -// return; initializeTypeList(); // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa) @@ -327,21 +346,39 @@ m_aTypePreLabel.Hide(); m_aTypePostLabel.Hide(); m_aSpecialMessage.Hide(); - m_aDatasourceTypeLabel.SetPosPixel( MovePoint( m_aRB_GetExistingDatabase.GetPosPixel(), 10, 14 ) ); - m_pDatasourceType->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_pDatasourceType->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); @@ -391,7 +428,7 @@ } } if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode) - sDisplayName = m_pCollection->getTypeDisplayName(DST_DBASE); + sDisplayName = m_pCollection->getTypeDisplayName(DST_JDBC); m_pDatasourceType->SelectEntry(sDisplayName); // notify our listener that our type selection has changed (if so) @@ -426,6 +463,7 @@ } + // ----------------------------------------------------------------------- void OGeneralPage::insertDatasourceTypeEntryData(DATASOURCE_TYPE _eType, String sDisplayName) { // insert a (temporary) entry @@ -433,7 +471,6 @@ m_pDatasourceType->SetEntryData(nPos, reinterpret_cast<void*>(_eType)); } - // ----------------------------------------------------------------------- void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) { @@ -480,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_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_pDatasourceType->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; @@ -528,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_pDatasourceType->Enable(bEnable); - m_aFTDataSourceAppendix.Enable(bEnable); - if (!bEnable) - sDisplayName = m_pCollection->getTypeDisplayName(DST_DBASE); - else - sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection); - USHORT n = m_pDatasourceType->GetEntryPos(sDisplayName); - if ((n < m_pDatasourceType->GetEntryCount()) && (n >= 0)) - m_pDatasourceType->SelectEntry(sDisplayName); + DocumentDescriptor aDocument; + if ( m_aBrowsedDocument.sURL.Len() ) + aDocument = m_aBrowsedDocument; else - m_pDatasourceType->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]
