bump product version to 4.1.6.2
[LibreOffice.git] / dbaccess / source / ui / dlg / generalpage.cxx
blob6a79acf0c510c195f8d0a7850c0f3a57a677714a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "dsnItem.hxx"
22 #include "generalpage.hxx"
23 #include <connectivity/dbexception.hxx>
24 #include "dbu_dlg.hrc"
25 #include "dbadmin.hrc"
26 #include "dsitems.hxx"
27 #include "dbustrings.hrc"
28 #include "dbadmin.hxx"
29 #include <sfx2/filedlghelper.hxx>
30 #include <sfx2/docfilt.hxx>
31 #include <vcl/stdtext.hxx>
32 #include "localresaccess.hxx"
33 #include <vcl/msgbox.hxx>
34 #include <svl/stritem.hxx>
35 #include <vcl/waitobj.hxx>
36 #include <com/sun/star/sdbc/XDriverAccess.hpp>
37 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
39 #include <com/sun/star/uno/Sequence.hxx>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include "DriverSettings.hxx"
42 #include "UITools.hxx"
43 #include <comphelper/processfactory.hxx>
44 #include <unotools/confignode.hxx>
45 #include <osl/diagnose.h>
47 //.........................................................................
48 namespace dbaui
50 //.........................................................................
51 using namespace ::com::sun::star;
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::sdbc;
54 using namespace ::com::sun::star::beans;
55 using namespace ::com::sun::star::container;
57 //=========================================================================
58 //= OGeneralPage
59 //=========================================================================
60 //-------------------------------------------------------------------------
61 OGeneralPage::OGeneralPage( Window* pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems )
62 :OGenericAdministrationPage( pParent, "PageGeneral", _rUIXMLDescription, _rItems )
63 ,m_pSpecialMessage ( NULL )
64 ,m_eNotSupportedKnownType ( ::dbaccess::DST_UNKNOWN )
65 ,m_eLastMessage ( smNone )
66 ,m_bDisplayingInvalid ( sal_False )
67 ,m_bInitTypeList ( true )
68 ,m_pDatasourceType ( NULL )
69 ,m_pCollection ( NULL )
71 get( m_pDatasourceType, "datasourceType" );
72 get( m_pSpecialMessage, "specialMessage" );
74 // extract the datasource type collection from the item set
75 DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION));
76 if (pCollectionItem)
77 m_pCollection = pCollectionItem->getCollection();
78 OSL_ENSURE(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
80 // do some knittings
81 m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
84 //-------------------------------------------------------------------------
85 OGeneralPage::~OGeneralPage()
89 //-------------------------------------------------------------------------
90 namespace
92 struct DisplayedType
94 OUString eType;
95 String sDisplayName;
97 DisplayedType( const OUString& _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { }
99 typedef ::std::vector< DisplayedType > DisplayedTypes;
101 struct DisplayedTypeLess : ::std::binary_function< DisplayedType, DisplayedType, bool >
103 bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS )
105 return _rLHS.eType < _rRHS.eType;
110 //-------------------------------------------------------------------------
111 void OGeneralPage::initializeTypeList()
113 if ( m_bInitTypeList )
115 m_bInitTypeList = false;
116 m_pDatasourceType->Clear();
118 if ( m_pCollection )
120 DisplayedTypes aDisplayedTypes;
122 ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end();
123 for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin();
124 aTypeLoop != aEnd;
125 ++aTypeLoop
128 const OUString sURLPrefix = aTypeLoop.getURLPrefix();
129 if ( !sURLPrefix.isEmpty() )
131 OUString sDisplayName = aTypeLoop.getDisplayName();
132 if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
133 && approveDatasourceType( sURLPrefix, sDisplayName ) )
135 aDisplayedTypes.push_back( DisplayedTypes::value_type( sURLPrefix, sDisplayName ) );
139 ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
140 DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end();
141 for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin();
142 loop != aDisplayEnd;
143 ++loop
145 insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName );
150 //-------------------------------------------------------------------------
151 void OGeneralPage::setParentTitle(const OUString&)
155 //-------------------------------------------------------------------------
156 void OGeneralPage::switchMessage(const OUString& _sURLPrefix)
158 SPECIAL_MESSAGE eMessage = smNone;
159 if ( _sURLPrefix.isEmpty()/*_eType == m_eNotSupportedKnownType*/ )
161 eMessage = smUnsupportedType;
165 if ( eMessage != m_eLastMessage )
167 sal_uInt16 nResId = 0;
168 if ( smUnsupportedType == eMessage )
169 nResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
170 String sMessage;
171 if ( nResId )
172 sMessage = String( ModuleRes( nResId ) );
174 m_pSpecialMessage->SetText( sMessage );
175 m_eLastMessage = eMessage;
179 //-------------------------------------------------------------------------
180 void OGeneralPage::onTypeSelected(const OUString& _sURLPrefix)
182 // the new URL text as indicated by the selection history
183 implSetCurrentType( _sURLPrefix );
185 switchMessage(_sURLPrefix);
187 if ( m_aTypeSelectHandler.IsSet() )
188 m_aTypeSelectHandler.Call(this);
191 //-------------------------------------------------------------------------
192 void OGeneralPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
194 initializeTypeList();
196 m_pDatasourceType->SelectEntry( getDatasourceName( _rSet ) );
198 // notify our listener that our type selection has changed (if so)
199 // FIXME: how to detect that it did not changed? (fdo#62937)
200 setParentTitle( m_eCurrentSelection );
201 onTypeSelected( m_eCurrentSelection );
203 // a special message for the current page state
204 switchMessage( m_eCurrentSelection );
206 OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
209 //-------------------------------------------------------------------------
210 OUString OGeneralPage::getDatasourceName( const SfxItemSet& _rSet )
212 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
213 sal_Bool bValid, bReadonly;
214 getFlags( _rSet, bValid, bReadonly );
216 // if the selection is invalid, disable everything
217 String sName,sConnectURL;
218 m_bDisplayingInvalid = !bValid;
219 if ( bValid )
221 // collect some items and some values
222 SFX_ITEMSET_GET( _rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True );
223 SFX_ITEMSET_GET( _rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True );
224 OSL_ENSURE( pUrlItem, "OGeneralPage::getDatasourceName: missing the type attribute !" );
225 OSL_ENSURE( pNameItem, "OGeneralPage::getDatasourceName: missing the type attribute !" );
226 sName = pNameItem->GetValue();
227 sConnectURL = pUrlItem->GetValue();
230 m_eNotSupportedKnownType = ::dbaccess::DST_UNKNOWN;
231 implSetCurrentType( OUString() );
233 // compare the DSN prefix with the registered ones
234 OUString sDisplayName;
236 if (m_pCollection && bValid)
238 implSetCurrentType( m_pCollection->getPrefix( sConnectURL ) );
239 sDisplayName = m_pCollection->getTypeDisplayName( m_eCurrentSelection );
242 // select the correct datasource type
243 if ( approveDatasourceType( m_eCurrentSelection, sDisplayName )
244 && ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) )
246 { // this indicates it's really a type which is known in general, but not supported on the current platform
247 // show a message saying so
248 // eSpecialMessage = smUnsupportedType;
249 insertDatasourceTypeEntryData( m_eCurrentSelection, sDisplayName );
250 // remember this type so we can show the special message again if the user selects this
251 // type again (without changing the data source)
252 m_eNotSupportedKnownType = m_pCollection->determineType( m_eCurrentSelection );
255 return sDisplayName;
258 // For the databaseWizard we only have one entry for the MySQL Database,
259 // because we have a separate tabpage to retrieve the respective datasource type
260 // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary
261 // representative for all MySQl databases)
262 // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
263 // databases to connect to.
264 bool OGeneralPage::approveDatasourceType( const OUString& _sURLPrefix, OUString& _inout_rDisplayName )
266 return approveDatasourceType( m_pCollection->determineType(_sURLPrefix), _inout_rDisplayName );
269 bool OGeneralPage::approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName )
271 if ( eType == ::dbaccess::DST_MYSQL_NATIVE_DIRECT )
273 // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if
274 // this driver is installed
275 if ( m_pCollection->hasDriver( "sdbc:mysql:mysqlc:" ) )
276 _inout_rDisplayName = String();
279 if ( eType == ::dbaccess::DST_EMBEDDED_HSQLDB )
280 _inout_rDisplayName = String();
282 return _inout_rDisplayName.getLength() > 0;
286 // -----------------------------------------------------------------------
287 void OGeneralPage::insertDatasourceTypeEntryData(const OUString& _sType, String sDisplayName)
289 // insert a (temporary) entry
290 sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName);
291 if ( nPos >= m_aURLPrefixes.size() )
292 m_aURLPrefixes.resize(nPos+1);
293 m_aURLPrefixes[nPos] = _sType;
296 // -----------------------------------------------------------------------
297 void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
299 _rControlList.push_back( new ODisableWrapper<FixedText>( m_pSpecialMessage ) );
302 // -----------------------------------------------------------------------
303 void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
305 _rControlList.push_back( new OSaveValueWrapper<ListBox>( m_pDatasourceType ) );
308 //-------------------------------------------------------------------------
309 void OGeneralPage::implSetCurrentType( const OUString& _eType )
311 if ( _eType == m_eCurrentSelection )
312 return;
314 m_eCurrentSelection = _eType;
317 //-------------------------------------------------------------------------
318 void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs)
320 // reset all locale data
321 implSetCurrentType( OUString() );
322 // this ensures that our type selection link will be called, even if the new is is the same as the
323 // current one
324 OGenericAdministrationPage::Reset(_rCoreAttrs);
327 //-------------------------------------------------------------------------
328 IMPL_LINK( OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox )
330 // get the type from the entry data
331 sal_uInt16 nSelected = _pBox->GetSelectEntryPos();
332 if (nSelected >= m_aURLPrefixes.size() )
334 SAL_WARN("dbaccess.ui.OGeneralPage", "Got out-of-range value '" << nSelected << "' from the DatasourceType selection ListBox's GetSelectEntryPos(): no corresponding URL prefix");
335 return 0L;
337 const OUString sURLPrefix = m_aURLPrefixes[ nSelected ];
339 setParentTitle( sURLPrefix );
340 // let the impl method do all the stuff
341 onTypeSelected( sURLPrefix );
342 // tell the listener we were modified
343 callModifiedHdl();
344 // outta here
345 return 0L;
348 //=========================================================================
349 //= OGeneralPageDialog
350 //=========================================================================
351 //-------------------------------------------------------------------------
352 OGeneralPageDialog::OGeneralPageDialog( Window* pParent, const SfxItemSet& _rItems )
353 :OGeneralPage( pParent, "dbaccess/ui/generalpagedialog.ui", _rItems )
357 //-------------------------------------------------------------------------
358 void OGeneralPageDialog::setParentTitle( const OUString& _sURLPrefix )
360 const OUString sName = m_pCollection->getTypeDisplayName( _sURLPrefix );
361 if ( m_pAdminDialog )
363 OUString sMessage = OUString( ModuleRes( STR_PARENTTITLE_GENERAL ) );
364 m_pAdminDialog->setTitle( sMessage.replaceAll( "#", sName ) );
368 //-------------------------------------------------------------------------
369 void OGeneralPageDialog::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
371 OGeneralPage::implInitControls( _rSet, _bSaveValue );
373 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
374 sal_Bool bValid, bReadonly;
375 getFlags(_rSet, bValid, bReadonly );
377 m_pDatasourceType->Enable( bValid );
380 //-------------------------------------------------------------------------
381 sal_Bool OGeneralPageDialog::FillItemSet( SfxItemSet& _rCoreAttrs )
383 sal_Bool bChangedSomething = sal_False;
385 sal_uInt16 nEntry = m_pDatasourceType->GetSelectEntryPos();
386 OUString sURLPrefix = m_aURLPrefixes[ nEntry ];
388 if ( m_pDatasourceType->GetSavedValue() != nEntry )
390 _rCoreAttrs.Put( SfxStringItem( DSID_CONNECTURL, sURLPrefix ) );
391 bChangedSomething = sal_True;
394 return bChangedSomething;
397 //=========================================================================
398 //= OGeneralPageWizard
399 //=========================================================================
400 //-------------------------------------------------------------------------
401 OGeneralPageWizard::OGeneralPageWizard( Window* pParent, const SfxItemSet& _rItems )
402 :OGeneralPage( pParent, "dbaccess/ui/generalpagewizard.ui", _rItems )
403 ,m_pFT_HeaderText ( NULL )
404 ,m_pFT_HelpText ( NULL )
405 ,m_pRB_CreateDatabase ( NULL )
406 ,m_pRB_OpenExistingDatabase ( NULL )
407 ,m_pRB_ConnectDatabase ( NULL )
408 ,m_pFT_DocListLabel ( NULL )
409 ,m_pLB_DocumentList ( NULL )
410 ,m_pPB_OpenDatabase ( NULL )
411 ,m_eOriginalCreationMode ( eCreateNew )
413 get( m_pFT_HeaderText, "headerText" );
414 get( m_pFT_HelpText, "helpText" );
415 get( m_pRB_CreateDatabase, "createDatabase" );
416 get( m_pRB_OpenExistingDatabase, "openExistingDatabase" );
417 get( m_pRB_ConnectDatabase, "connectDatabase" );
418 get( m_pFT_DocListLabel, "docListLabel" );
419 get( m_pLB_DocumentList, "documentList" );
420 get( m_pPB_OpenDatabase, "openDatabase" );
422 // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
423 sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() );
424 if ( nCreateNewDBIndex == -1 )
425 nCreateNewDBIndex = m_pCollection->getIndexOf( OUString( "sdbc:dbase:" ) );
426 bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
428 // also, if our application policies tell us to hide the option, do it
429 ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithComponentContext(
430 ::comphelper::getProcessComponentContext(),
431 OUString( "/org.openoffice.Office.DataAccess/Policies/Features/Base" )
432 ) );
433 sal_Bool bAllowCreateLocalDatabase( sal_True );
434 OSL_VERIFY( aConfig.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase );
435 if ( !bAllowCreateLocalDatabase )
436 bHideCreateNew = true;
438 if ( bHideCreateNew )
440 m_pRB_CreateDatabase->Hide();
441 m_pRB_ConnectDatabase->Check();
443 else
444 m_pRB_CreateDatabase->Check();
446 // do some knittings
447 m_pRB_CreateDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
448 m_pRB_ConnectDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
449 m_pRB_OpenExistingDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnSetupModeSelected ) );
450 m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPageWizard, OnDocumentSelected ) );
451 m_pPB_OpenDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnOpenDocument ) );
454 //-------------------------------------------------------------------------
455 OGeneralPageWizard::CreationMode OGeneralPageWizard::GetDatabaseCreationMode() const
457 if ( m_pRB_CreateDatabase->IsChecked() )
458 return eCreateNew;
459 if ( m_pRB_ConnectDatabase->IsChecked() )
460 return eConnectExternal;
461 return eOpenExisting;
464 //-------------------------------------------------------------------------
465 void OGeneralPageWizard::GetFocus()
467 OGeneralPage::GetFocus();
468 if ( m_pLB_DocumentList && m_pLB_DocumentList->IsEnabled() )
469 m_pLB_DocumentList->GrabFocus();
470 else if ( m_pDatasourceType && m_pDatasourceType->IsEnabled() )
471 m_pDatasourceType->GrabFocus();
474 //-------------------------------------------------------------------------
475 void OGeneralPageWizard::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
477 OGeneralPage::implInitControls( _rSet, _bSaveValue );
479 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
480 sal_Bool bValid, bReadonly;
481 getFlags( _rSet, bValid, bReadonly );
483 SetText( String() );
485 LayoutHelper::positionBelow( *m_pRB_ConnectDatabase, *m_pDatasourceType, RelatedControls, INDENT_BELOW_RADIO );
487 if ( !bValid || bReadonly )
489 m_pDatasourceType->Enable( false );
490 m_pPB_OpenDatabase->Enable( false );
491 m_pFT_DocListLabel->Enable( false );
492 m_pLB_DocumentList->Enable( false );
494 else
496 m_aControlDependencies.enableOnRadioCheck( *m_pRB_ConnectDatabase, *m_pDatasourceType );
497 m_aControlDependencies.enableOnRadioCheck( *m_pRB_OpenExistingDatabase, *m_pPB_OpenDatabase, *m_pFT_DocListLabel, *m_pLB_DocumentList );
500 m_pLB_DocumentList->SetDropDownLineCount( 20 );
501 if ( m_pLB_DocumentList->GetEntryCount() )
502 m_pLB_DocumentList->SelectEntryPos( 0 );
504 m_eOriginalCreationMode = GetDatabaseCreationMode();
507 //-------------------------------------------------------------------------
508 OUString OGeneralPageWizard::getDatasourceName(const SfxItemSet& _rSet)
510 if (m_pRB_CreateDatabase->IsChecked() )
511 return m_pCollection->getTypeDisplayName( OUString( "jdbc:" ) );
513 return OGeneralPage::getDatasourceName( _rSet );
516 //-------------------------------------------------------------------------
517 bool OGeneralPageWizard::approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName )
519 switch ( eType )
521 case ::dbaccess::DST_MYSQL_JDBC:
522 _inout_rDisplayName = "MySQL";
523 break;
524 case ::dbaccess::DST_MYSQL_ODBC:
525 case ::dbaccess::DST_MYSQL_NATIVE:
526 // don't display those, the decision whether the user connects via JDBC/ODBC/C-OOo is made on another
527 // page
528 _inout_rDisplayName = String();
529 break;
530 default:
531 break;
534 return OGeneralPage::approveDatasourceType( eType, _inout_rDisplayName );
537 //-------------------------------------------------------------------------
538 sal_Bool OGeneralPageWizard::FillItemSet(SfxItemSet& _rCoreAttrs)
540 sal_Bool bChangedSomething = sal_False;
542 bool bCommitTypeSelection = true;
544 if ( m_pRB_CreateDatabase->IsChecked() )
546 _rCoreAttrs.Put( SfxStringItem( DSID_CONNECTURL, OUString( "sdbc:dbase:" ) ) );
547 bChangedSomething = sal_True;
548 bCommitTypeSelection = false;
550 else if ( m_pRB_OpenExistingDatabase->IsChecked() )
552 if ( m_pRB_OpenExistingDatabase->GetSavedValue() != m_pRB_OpenExistingDatabase->IsChecked() )
553 bChangedSomething = sal_True;
555 // TODO
556 bCommitTypeSelection = false;
559 if ( bCommitTypeSelection )
561 sal_uInt16 nEntry = m_pDatasourceType->GetSelectEntryPos();
562 OUString sURLPrefix = m_aURLPrefixes[nEntry];
564 if ( ( m_pDatasourceType->GetSavedValue() != nEntry )
565 || ( GetDatabaseCreationMode() != m_eOriginalCreationMode )
568 _rCoreAttrs.Put( SfxStringItem( DSID_CONNECTURL,sURLPrefix ) );
569 bChangedSomething = sal_True;
571 else
572 implSetCurrentType( sURLPrefix );
574 return bChangedSomething;
577 //-------------------------------------------------------------------------
578 OGeneralPageWizard::DocumentDescriptor OGeneralPageWizard::GetSelectedDocument() const
580 DocumentDescriptor aDocument;
581 if ( m_aBrowsedDocument.sURL.Len() )
582 aDocument = m_aBrowsedDocument;
583 else
585 aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL();
586 aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter();
588 return aDocument;
591 //-------------------------------------------------------------------------
592 IMPL_LINK( OGeneralPageWizard, OnSetupModeSelected, RadioButton*, /*_pBox*/ )
594 if ( m_aCreationModeHandler.IsSet() )
595 m_aCreationModeHandler.Call( this );
596 OnDatasourceTypeSelected(m_pDatasourceType);
597 return 1L;
600 //-------------------------------------------------------------------------
601 IMPL_LINK( OGeneralPageWizard, OnDocumentSelected, ListBox*, /*_pBox*/ )
603 m_aDocumentSelectionHandler.Call( this );
604 return 0L;
607 //-------------------------------------------------------------------------
608 IMPL_LINK( OGeneralPageWizard, OnOpenDocument, PushButton*, /*_pBox*/ )
610 ::sfx2::FileDialogHelper aFileDlg(
611 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
612 0, OUString::createFromAscii("sdatabase") );
613 const SfxFilter* pFilter = getStandardDatabaseFilter();
614 if ( pFilter )
616 aFileDlg.SetCurrentFilter(pFilter->GetUIName());
618 if ( aFileDlg.Execute() == ERRCODE_NONE )
620 String sPath = aFileDlg.GetPath();
621 if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) )
623 String sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO));
624 InfoBox aError(this, sMessage);
625 aError.Execute();
626 m_pRB_ConnectDatabase->Check();
627 OnSetupModeSelected( m_pRB_ConnectDatabase );
628 return 0L;
630 m_aBrowsedDocument.sURL = sPath;
631 m_aBrowsedDocument.sFilter = String();
632 m_aChooseDocumentHandler.Call( this );
633 return 1L;
636 return 0L;
639 //.........................................................................
640 } // namespace dbaui
641 //.........................................................................
643 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */