Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / dlg / generalpage.cxx
blob1887206d359e84d0fea7058029940c15f644d1ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "dsnItem.hxx"
31 #include "generalpage.hxx"
32 #include <connectivity/dbexception.hxx>
33 #include "dbu_dlg.hrc"
34 #include "dbadmin.hrc"
35 #include "dsitems.hxx"
36 #include "dbustrings.hrc"
37 #include "dbadmin.hxx"
38 #include <sfx2/filedlghelper.hxx>
39 #include <sfx2/docfilt.hxx>
40 #include <vcl/stdtext.hxx>
41 #include "localresaccess.hxx"
42 #include <vcl/msgbox.hxx>
43 #include <svl/stritem.hxx>
44 #include <vcl/waitobj.hxx>
45 #include <com/sun/star/sdbc/XDriverAccess.hpp>
46 #include <com/sun/star/beans/PropertyValue.hpp>
47 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
48 #include <com/sun/star/uno/Sequence.hxx>
49 #include <com/sun/star/container/XNameAccess.hpp>
50 #include "DriverSettings.hxx"
51 #include "UITools.hxx"
52 #include <comphelper/processfactory.hxx>
53 #include <unotools/confignode.hxx>
54 #include <osl/diagnose.h>
56 //.........................................................................
57 namespace dbaui
59 //.........................................................................
60 using namespace ::com::sun::star;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::sdbc;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::container;
66 //=========================================================================
67 //= OGeneralPage
68 //=========================================================================
69 //-------------------------------------------------------------------------
70 OGeneralPage::OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode)
71 :OGenericAdministrationPage(pParent, ModuleRes(PAGE_GENERAL), _rItems)
72 ,m_aFTHeaderText (this, ModuleRes(FT_GENERALHEADERTEXT))
73 ,m_aFTHelpText (this, ModuleRes(FT_GENERALHELPTEXT))
74 ,m_aFT_DatasourceTypeHeader (this, ModuleRes(FT_DATASOURCEHEADER))
75 ,m_aRB_CreateDatabase (this, ModuleRes(RB_CREATEDBDATABASE))
76 ,m_aRB_OpenDocument (this, ModuleRes(RB_OPENEXISTINGDOC))
77 ,m_aRB_GetExistingDatabase (this, ModuleRes(RB_GETEXISTINGDATABASE))
78 ,m_aFT_DocListLabel (this, ModuleRes(FT_DOCLISTLABEL))
79 ,m_pLB_DocumentList ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes( LB_DOCUMENTLIST ) ) )
80 ,m_aPB_OpenDocument (this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes(PB_OPENDOCUMENT))
81 ,m_aTypePreLabel (this, ModuleRes(FT_DATASOURCETYPE_PRE))
82 ,m_aDatasourceTypeLabel (this, ModuleRes(FT_DATATYPE))
83 ,m_pDatasourceType ( new ListBox(this, ModuleRes(LB_DATATYPE)))
84 ,m_aFTDataSourceAppendix (this, ModuleRes(FT_DATATYPEAPPENDIX))
85 ,m_aTypePostLabel (this, ModuleRes(FT_DATASOURCETYPE_POST))
86 ,m_aSpecialMessage (this, ModuleRes(FT_SPECIAL_MESSAGE))
87 ,m_DBWizardMode (_bDBWizardMode)
88 ,m_sMySQLEntry (ModuleRes(STR_MYSQLENTRY))
89 ,m_eOriginalCreationMode (eCreateNew)
90 ,m_pCollection (NULL)
91 ,m_eNotSupportedKnownType ( ::dbaccess::DST_UNKNOWN)
92 ,m_eLastMessage (smNone)
93 ,m_bDisplayingInvalid (sal_False)
94 ,m_bUserGrabFocus (sal_True)
95 ,m_bInitTypeList (true)
97 // fill the listbox with the UI descriptions for the possible types
98 // and remember the respective DSN prefixes
99 FreeResource();
100 // extract the datasource type collection from the item set
101 DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION));
102 if (pCollectionItem)
103 m_pCollection = pCollectionItem->getCollection();
104 OSL_ENSURE(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
106 // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
107 sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() );
108 if ( nCreateNewDBIndex == -1 )
109 nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) );
110 bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
112 // also, if our application policies tell us to hide the option, do it
113 ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
114 ::comphelper::getProcessServiceFactory(),
115 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/Policies/Features/Base" ) )
116 ) );
117 sal_Bool bAllowCreateLocalDatabase( sal_True );
118 OSL_VERIFY( aConfig.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase );
119 if ( !bAllowCreateLocalDatabase )
120 bHideCreateNew = true;
122 if ( bHideCreateNew )
124 m_aRB_CreateDatabase.Hide();
125 Window* pWindowsToMove[] = {
126 &m_aRB_OpenDocument, &m_aRB_GetExistingDatabase, &m_aFT_DocListLabel, m_pLB_DocumentList.get(),
127 &m_aPB_OpenDocument, &m_aDatasourceTypeLabel, m_pDatasourceType.get(), &m_aFTDataSourceAppendix,
128 &m_aTypePostLabel
130 const long nOffset = m_aRB_OpenDocument.GetPosPixel().Y() - m_aRB_CreateDatabase.GetPosPixel().Y();
131 for ( size_t i=0; i < sizeof( pWindowsToMove ) / sizeof( pWindowsToMove[0] ); ++i )
133 Point aPos( pWindowsToMove[i]->GetPosPixel() );
134 aPos.Y() -= nOffset;
135 pWindowsToMove[i]->SetPosPixel( aPos );
139 if ( bHideCreateNew )
140 m_aRB_GetExistingDatabase.Check();
141 else
142 m_aRB_CreateDatabase.Check();
144 // do some knittings
145 m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
146 m_aRB_CreateDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
147 m_aRB_GetExistingDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
148 m_aRB_OpenDocument.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
149 m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPage, OnDocumentSelected ) );
150 m_aPB_OpenDocument.SetClickHdl( LINK( this, OGeneralPage, OnOpenDocument ) );
153 //-------------------------------------------------------------------------
154 OGeneralPage::~OGeneralPage()
156 m_pDatasourceType.reset( NULL );
157 m_pLB_DocumentList.reset( NULL );
160 //-------------------------------------------------------------------------
161 namespace
163 struct DisplayedType
165 ::rtl::OUString eType;
166 String sDisplayName;
168 DisplayedType( const ::rtl::OUString& _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { }
170 typedef ::std::vector< DisplayedType > DisplayedTypes;
172 struct DisplayedTypeLess : ::std::binary_function< DisplayedType, DisplayedType, bool >
174 bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS )
176 return _rLHS.eType < _rRHS.eType;
181 //-------------------------------------------------------------------------
182 void OGeneralPage::initializeTypeList()
184 if ( m_bInitTypeList )
186 m_bInitTypeList = false;
187 m_pDatasourceType->Clear();
189 if ( m_pCollection )
191 DisplayedTypes aDisplayedTypes;
193 ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end();
194 for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin();
195 aTypeLoop != aEnd;
196 ++aTypeLoop
199 const ::rtl::OUString sURLPrefix = aTypeLoop.getURLPrefix();
200 if ( !sURLPrefix.isEmpty() )
202 String sDisplayName = aTypeLoop.getDisplayName();
203 if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
204 && approveDataSourceType( sURLPrefix, sDisplayName ) )
206 aDisplayedTypes.push_back( DisplayedTypes::value_type( sURLPrefix, sDisplayName ) );
210 ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
211 DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end();
212 for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin();
213 loop != aDisplayEnd;
214 ++loop
216 insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName );
223 //-------------------------------------------------------------------------
224 void OGeneralPage::setParentTitle(const ::rtl::OUString& _sURLPrefix)
226 if (!m_DBWizardMode)
228 const String sName = m_pCollection->getTypeDisplayName(_sURLPrefix);
229 if ( m_pAdminDialog )
231 LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
232 String sMessage = String(ModuleRes(STR_PARENTTITLE));
233 sMessage.SearchAndReplaceAscii("#",sName);
234 m_pAdminDialog->setTitle(sMessage);
239 //-------------------------------------------------------------------------
240 OGeneralPage::CreationMode OGeneralPage::GetDatabaseCreationMode() const
242 if ( m_aRB_CreateDatabase.IsChecked() )
243 return eCreateNew;
244 if ( m_aRB_GetExistingDatabase.IsChecked() )
245 return eConnectExternal;
246 return eOpenExisting;
249 //-------------------------------------------------------------------------
250 void OGeneralPage::GetFocus()
252 OGenericAdministrationPage::GetFocus();
253 if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() )
254 m_pLB_DocumentList->GrabFocus();
255 else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled())
256 m_pDatasourceType->GrabFocus();
259 //-------------------------------------------------------------------------
260 void OGeneralPage::switchMessage(const ::rtl::OUString& _sURLPrefix)
262 SPECIAL_MESSAGE eMessage = smNone;
263 if ( _sURLPrefix.isEmpty()/*_eType == m_eNotSupportedKnownType*/ )
265 eMessage = smUnsupportedType;
269 if ( eMessage != m_eLastMessage )
271 sal_uInt16 nResId = 0;
272 if ( smUnsupportedType == eMessage )
273 nResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
274 String sMessage;
275 if ( nResId )
277 LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
278 sMessage = String(ModuleRes(nResId));
280 m_aSpecialMessage.SetText(sMessage);
282 m_eLastMessage = eMessage;
286 //-------------------------------------------------------------------------
287 void OGeneralPage::onTypeSelected(const ::rtl::OUString& _sURLPrefix)
289 // the the new URL text as indicated by the selection history
290 implSetCurrentType( _sURLPrefix );
292 switchMessage(_sURLPrefix);
294 if ( m_aTypeSelectHandler.IsSet() )
295 m_aTypeSelectHandler.Call(this);
298 //-------------------------------------------------------------------------
299 void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
301 initializeTypeList();
303 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
304 sal_Bool bValid, bReadonly;
305 getFlags(_rSet, bValid, bReadonly);
306 if (m_DBWizardMode)
308 m_aTypePreLabel.Hide();
309 m_aTypePostLabel.Hide();
310 m_aSpecialMessage.Hide();
311 SetControlFontWeight(&m_aFTHeaderText);
312 SetText(String());
314 LayoutHelper::positionBelow( m_aRB_GetExistingDatabase, *m_pDatasourceType, RelatedControls, INDENT_BELOW_RADIO );
316 if ( !bValid || bReadonly )
318 m_aDatasourceTypeLabel.Enable( false );
319 m_pDatasourceType->Enable( false );
320 m_aFTDataSourceAppendix.Enable( false );
321 m_aPB_OpenDocument.Enable( false );
322 m_aFT_DocListLabel.Enable( false );
323 m_pLB_DocumentList->Enable( false );
325 else
327 m_aControlDependencies.enableOnRadioCheck( m_aRB_GetExistingDatabase, m_aDatasourceTypeLabel, *m_pDatasourceType, m_aFTDataSourceAppendix );
328 m_aControlDependencies.enableOnRadioCheck( m_aRB_OpenDocument, m_aPB_OpenDocument, m_aFT_DocListLabel, *m_pLB_DocumentList );
331 m_pLB_DocumentList->SetDropDownLineCount( 20 );
332 if ( m_pLB_DocumentList->GetEntryCount() )
333 m_pLB_DocumentList->SelectEntryPos( 0 );
335 m_aDatasourceTypeLabel.Hide();
336 m_aFTDataSourceAppendix.Hide();
338 m_eOriginalCreationMode = GetDatabaseCreationMode();
340 else
342 m_aFT_DatasourceTypeHeader.Hide();
343 m_aRB_CreateDatabase.Hide();
344 m_aRB_GetExistingDatabase.Hide();
345 m_aRB_OpenDocument.Hide();
346 m_aPB_OpenDocument.Hide();
347 m_aFT_DocListLabel.Hide();
348 m_pLB_DocumentList->Hide();
349 m_aFTHeaderText.Hide();
350 m_aFTHelpText.Hide();
351 m_aTypePreLabel.Enable(bValid);
352 m_aTypePostLabel.Enable(bValid);
353 m_aDatasourceTypeLabel.Enable(bValid);
354 m_pDatasourceType->Enable(bValid);
356 // if the selection is invalid, disable evrything
357 String sName,sConnectURL;
358 m_bDisplayingInvalid = !bValid;
359 if ( bValid )
361 // collect some items and some values
362 SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
363 SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
364 OSL_ENSURE(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !");
365 OSL_ENSURE(pNameItem, "OGeneralPage::implInitControls : missing the type attribute !");
366 sName = pNameItem->GetValue();
367 sConnectURL = pUrlItem->GetValue();
370 ::rtl::OUString eOldSelection = m_eCurrentSelection;
371 m_eNotSupportedKnownType = ::dbaccess::DST_UNKNOWN;
372 implSetCurrentType( ::rtl::OUString() );
374 // compare the DSN prefix with the registered ones
375 String sDisplayName;
377 if (m_pCollection && bValid)
379 implSetCurrentType( m_pCollection->getPrefix(sConnectURL) );
380 sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection);
383 // select the correct datasource type
384 if ( approveDataSourceType( m_eCurrentSelection, sDisplayName )
385 && ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) )
387 { // this indicates it's really a type which is known in general, but not supported on the current platform
388 // show a message saying so
389 // eSpecialMessage = smUnsupportedType;
390 insertDatasourceTypeEntryData(m_eCurrentSelection, sDisplayName);
391 // remember this type so we can show the special message again if the user selects this
392 // type again (without changing the data source)
393 m_eNotSupportedKnownType = m_pCollection->determineType(m_eCurrentSelection);
396 if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode)
397 sDisplayName = m_pCollection->getTypeDisplayName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:")));
398 m_pDatasourceType->SelectEntry(sDisplayName);
400 // notify our listener that our type selection has changed (if so)
401 if ( eOldSelection != m_eCurrentSelection )
403 setParentTitle(m_eCurrentSelection);
404 onTypeSelected(m_eCurrentSelection);
407 // a special message for the current page state
408 switchMessage(m_eCurrentSelection);
410 OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
414 // For the databaseWizard we only have one entry for the MySQL Database,
415 // because we have a seperate tabpage to retrieve the respective datasource type
416 // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary
417 // representative for all MySQl databases)
418 // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
419 // databases to connect to.
420 bool OGeneralPage::approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName )
422 const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(_sURLPrefix);
424 if ( m_DBWizardMode )
426 switch ( eType )
428 case ::dbaccess::DST_MYSQL_JDBC:
429 _inout_rDisplayName = m_sMySQLEntry;
430 break;
431 case ::dbaccess::DST_MYSQL_ODBC:
432 case ::dbaccess::DST_MYSQL_NATIVE:
433 // don't display those, the decision whether the user connects via JDBC/ODBC/C-OOo is made on another
434 // page
435 _inout_rDisplayName = String();
436 break;
437 default:
438 break;
442 if ( eType == ::dbaccess::DST_MYSQL_NATIVE_DIRECT )
444 // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if
445 // this driver is installed
446 if ( m_pCollection->hasDriver( "sdbc:mysql:mysqlc:" ) )
447 _inout_rDisplayName = String();
450 if ( eType == ::dbaccess::DST_EMBEDDED_HSQLDB )
451 _inout_rDisplayName = String();
453 return _inout_rDisplayName.Len() > 0;
457 // -----------------------------------------------------------------------
458 void OGeneralPage::insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName)
460 // insert a (temporary) entry
461 sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName);
462 if ( nPos >= m_aURLPrefixes.size() )
463 m_aURLPrefixes.resize(nPos+1);
464 m_aURLPrefixes[nPos] = _sType;
467 // -----------------------------------------------------------------------
468 void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
470 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePreLabel));
471 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDatasourceTypeLabel));
472 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePostLabel));
473 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aSpecialMessage));
474 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDataSourceAppendix));
476 // -----------------------------------------------------------------------
477 void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
479 _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pDatasourceType.get()));
482 //-------------------------------------------------------------------------
483 SfxTabPage* OGeneralPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet, sal_Bool _bWizardMode)
485 return ( new OGeneralPage( _pParent, _rAttrSet, _bWizardMode ) );
488 //-------------------------------------------------------------------------
489 void OGeneralPage::implSetCurrentType( const ::rtl::OUString& _eType )
491 if ( _eType == m_eCurrentSelection )
492 return;
494 m_eCurrentSelection = _eType;
497 //-------------------------------------------------------------------------
498 void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs)
500 // reset all locale data
501 implSetCurrentType( ::rtl::OUString() );
502 // this ensures that our type selection link will be called, even if the new is is the same as the
503 // current one
504 OGenericAdministrationPage::Reset(_rCoreAttrs);
507 //-------------------------------------------------------------------------
508 sal_Bool OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs)
510 sal_Bool bChangedSomething = sal_False;
512 bool bCommitTypeSelection = true;
513 if ( m_DBWizardMode )
515 if ( m_aRB_CreateDatabase.IsChecked() )
517 _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"))));
518 bChangedSomething = sal_True;
519 bCommitTypeSelection = false;
521 else if ( m_aRB_OpenDocument.IsChecked() )
523 if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() )
524 bChangedSomething = sal_True;
526 // TODO
527 bCommitTypeSelection = false;
531 if ( bCommitTypeSelection )
533 sal_uInt16 nEntry = m_pDatasourceType->GetSelectEntryPos();
534 ::rtl::OUString sURLPrefix = m_aURLPrefixes[nEntry];
535 if (m_DBWizardMode)
537 if ( ( m_pDatasourceType->GetSavedValue() != nEntry )
538 || ( GetDatabaseCreationMode() != m_eOriginalCreationMode )
541 _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL,sURLPrefix ));
542 bChangedSomething = sal_True;
544 else
545 implSetCurrentType(sURLPrefix);
547 else
549 if ( m_pDatasourceType->GetSavedValue() != nEntry)
551 _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, sURLPrefix));
552 bChangedSomething = sal_True;
556 return bChangedSomething;
559 //-------------------------------------------------------------------------
560 IMPL_LINK(OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox)
562 // get the type from the entry data
563 sal_Int16 nSelected = _pBox->GetSelectEntryPos();
564 const ::rtl::OUString sURLPrefix = m_aURLPrefixes[nSelected];
566 setParentTitle(sURLPrefix);
567 // let the impl method do all the stuff
568 onTypeSelected(sURLPrefix);
569 // tell the listener we were modified
570 callModifiedHdl();
571 // outta here
572 return 0L;
575 //-------------------------------------------------------------------------
576 OGeneralPage::DocumentDescriptor OGeneralPage::GetSelectedDocument() const
578 DocumentDescriptor aDocument;
579 if ( m_aBrowsedDocument.sURL.Len() )
580 aDocument = m_aBrowsedDocument;
581 else
583 aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL();
584 aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter();
586 return aDocument;
589 //-------------------------------------------------------------------------
590 IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, /*_pBox*/)
592 if ( m_aCreationModeHandler.IsSet() )
593 m_aCreationModeHandler.Call(this);
594 return 1L;
597 //-------------------------------------------------------------------------
598 IMPL_LINK(OGeneralPage, OnDocumentSelected, ListBox*, /*_pBox*/)
600 m_aDocumentSelectionHandler.Call( this );
601 return 0L;
604 //-------------------------------------------------------------------------
605 IMPL_LINK(OGeneralPage, OnOpenDocument, PushButton*, /*_pBox*/)
607 ::sfx2::FileDialogHelper aFileDlg(
608 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
609 0, ::String::CreateFromAscii("sdatabase") );
610 const SfxFilter* pFilter = getStandardDatabaseFilter();
611 if ( pFilter )
613 aFileDlg.SetCurrentFilter(pFilter->GetUIName());
615 if ( aFileDlg.Execute() == ERRCODE_NONE )
617 String sPath = aFileDlg.GetPath();
618 if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) )
620 String sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO));
621 InfoBox aError(this, sMessage);
622 aError.Execute();
623 m_aRB_GetExistingDatabase.Check();
624 OnSetupModeSelected(&m_aRB_GetExistingDatabase);
625 return 0L;
627 m_aBrowsedDocument.sURL = sPath;
628 m_aBrowsedDocument.sFilter = String();
629 m_aChooseDocumentHandler.Call( this );
630 return 1L;
633 return 0L;
636 //.........................................................................
637 } // namespace dbaui
638 //.........................................................................
640 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */