1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: generalpage.cxx,v $
10 * $Revision: 1.56.68.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include "dsnItem.hxx"
35 #include "generalpage.hxx"
36 #include <connectivity/dbexception.hxx>
37 #include "dbu_dlg.hrc"
38 #include "dbadmin.hrc"
39 #include "dsitems.hxx"
40 #include "dbustrings.hrc"
41 #include "dbadmin.hxx"
42 #include <sfx2/filedlghelper.hxx>
43 #include <sfx2/docfilt.hxx>
44 #include <vcl/stdtext.hxx>
45 #include "localresaccess.hxx"
46 #include <vcl/msgbox.hxx>
47 #include <svtools/stritem.hxx>
48 #include <vcl/waitobj.hxx>
49 #include <com/sun/star/sdbc/XDriverAccess.hpp>
50 #include <com/sun/star/beans/PropertyValue.hpp>
51 #include <com/sun/star/uno/Sequence.hxx>
52 #include <com/sun/star/container/XNameAccess.hpp>
53 #include "DriverSettings.hxx"
54 #include "UITools.hxx"
55 #include <comphelper/processfactory.hxx>
56 #include <unotools/confignode.hxx>
58 //.........................................................................
61 //.........................................................................
62 using namespace ::com::sun::star::uno
;
63 using namespace ::com::sun::star::sdbc
;
64 using namespace ::com::sun::star::beans
;
65 using namespace ::com::sun::star::container
;
67 //=========================================================================
69 //=========================================================================
70 //-------------------------------------------------------------------------
71 OGeneralPage::OGeneralPage(Window
* pParent
, const SfxItemSet
& _rItems
, sal_Bool _bDBWizardMode
)
72 :OGenericAdministrationPage(pParent
, ModuleRes(PAGE_GENERAL
), _rItems
)
73 ,m_aFTHeaderText (this, ModuleRes(FT_GENERALHEADERTEXT
))
74 ,m_aFTHelpText (this, ModuleRes(FT_GENERALHELPTEXT
))
75 ,m_aFT_DatasourceTypeHeader (this, ModuleRes(FT_DATASOURCEHEADER
))
76 ,m_aRB_CreateDatabase (this, ModuleRes(RB_CREATEDBDATABASE
))
77 ,m_aRB_OpenDocument (this, ModuleRes(RB_OPENEXISTINGDOC
))
78 ,m_aRB_GetExistingDatabase (this, ModuleRes(RB_GETEXISTINGDATABASE
))
79 ,m_aFT_DocListLabel (this, ModuleRes(FT_DOCLISTLABEL
))
80 ,m_pLB_DocumentList ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes( LB_DOCUMENTLIST
) ) )
81 ,m_aPB_OpenDocument (this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes(PB_OPENDOCUMENT
))
82 ,m_aTypePreLabel (this, ModuleRes(FT_DATASOURCETYPE_PRE
))
83 ,m_aDatasourceTypeLabel (this, ModuleRes(FT_DATATYPE
))
84 ,m_pDatasourceType ( new ListBox(this, ModuleRes(LB_DATATYPE
)))
85 ,m_aFTDataSourceAppendix (this, ModuleRes(FT_DATATYPEAPPENDIX
))
86 ,m_aTypePostLabel (this, ModuleRes(FT_DATASOURCETYPE_POST
))
87 ,m_aSpecialMessage (this, ModuleRes(FT_SPECIAL_MESSAGE
))
88 ,m_DBWizardMode (_bDBWizardMode
)
89 ,m_sMySQLEntry (ModuleRes(STR_MYSQLENTRY
))
90 ,m_eOriginalCreationMode (eCreateNew
)
92 ,m_eNotSupportedKnownType ( ::dbaccess::DST_UNKNOWN
)
93 ,m_eLastMessage (smNone
)
94 ,m_bDisplayingInvalid (sal_False
)
95 ,m_bUserGrabFocus (sal_True
)
96 ,m_bInitTypeList (true)
98 // fill the listbox with the UI descriptions for the possible types
99 // and remember the respective DSN prefixes
101 // extract the datasource type collection from the item set
102 DbuTypeCollectionItem
* pCollectionItem
= PTR_CAST(DbuTypeCollectionItem
, _rItems
.GetItem(DSID_TYPECOLLECTION
));
104 m_pCollection
= pCollectionItem
->getCollection();
105 DBG_ASSERT(m_pCollection
, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
107 // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
108 sal_Int32 nCreateNewDBIndex
= m_pCollection
->getIndexOf( m_pCollection
->getEmbeddedDatabase() );
109 if ( nCreateNewDBIndex
== -1 )
110 nCreateNewDBIndex
= m_pCollection
->getIndexOf( ::rtl::OUString::createFromAscii( "sdbc:dbase:" ) );
111 bool bHideCreateNew
= ( nCreateNewDBIndex
== -1 );
113 // also, if our application policies tell us to hide the option, do it
114 ::utl::OConfigurationTreeRoot
aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
115 ::comphelper::getProcessServiceFactory(),
116 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/Policies/Features/Base" ) )
118 sal_Bool
bAllowCreateLocalDatabase( sal_True
);
119 OSL_VERIFY( aConfig
.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase
);
120 if ( !bAllowCreateLocalDatabase
)
121 bHideCreateNew
= true;
123 if ( bHideCreateNew
)
125 m_aRB_CreateDatabase
.Hide();
126 Window
* pWindowsToMove
[] = {
127 &m_aRB_OpenDocument
, &m_aRB_GetExistingDatabase
, &m_aFT_DocListLabel
, m_pLB_DocumentList
.get(),
128 &m_aPB_OpenDocument
, &m_aDatasourceTypeLabel
, m_pDatasourceType
.get(), &m_aFTDataSourceAppendix
,
131 const long nOffset
= m_aRB_OpenDocument
.GetPosPixel().Y() - m_aRB_CreateDatabase
.GetPosPixel().Y();
132 for ( size_t i
=0; i
< sizeof( pWindowsToMove
) / sizeof( pWindowsToMove
[0] ); ++i
)
134 Point
aPos( pWindowsToMove
[i
]->GetPosPixel() );
136 pWindowsToMove
[i
]->SetPosPixel( aPos
);
140 if ( bHideCreateNew
)
141 m_aRB_GetExistingDatabase
.Check();
143 m_aRB_CreateDatabase
.Check();
146 m_pDatasourceType
->SetSelectHdl(LINK(this, OGeneralPage
, OnDatasourceTypeSelected
));
147 m_aRB_CreateDatabase
.SetClickHdl(LINK(this, OGeneralPage
, OnSetupModeSelected
));
148 m_aRB_GetExistingDatabase
.SetClickHdl(LINK(this, OGeneralPage
, OnSetupModeSelected
));
149 m_aRB_OpenDocument
.SetClickHdl(LINK(this, OGeneralPage
, OnSetupModeSelected
));
150 m_pLB_DocumentList
->SetSelectHdl( LINK( this, OGeneralPage
, OnDocumentSelected
) );
151 m_aPB_OpenDocument
.SetClickHdl( LINK( this, OGeneralPage
, OnOpenDocument
) );
154 //-------------------------------------------------------------------------
155 OGeneralPage::~OGeneralPage()
157 m_pDatasourceType
.reset( NULL
);
158 m_pLB_DocumentList
.reset( NULL
);
161 //-------------------------------------------------------------------------
166 ::rtl::OUString eType
;
169 DisplayedType( const ::rtl::OUString
& _eType
, const String
& _rDisplayName
) : eType( _eType
), sDisplayName( _rDisplayName
) { }
171 typedef ::std::vector
< DisplayedType
> DisplayedTypes
;
173 struct DisplayedTypeLess
: ::std::binary_function
< DisplayedType
, DisplayedType
, bool >
175 bool operator() ( const DisplayedType
& _rLHS
, const DisplayedType
& _rRHS
)
177 return _rLHS
.eType
< _rRHS
.eType
;
182 //-------------------------------------------------------------------------
183 void OGeneralPage::initializeTypeList()
185 if ( m_bInitTypeList
)
187 m_bInitTypeList
= false;
188 m_pDatasourceType
->Clear();
192 DisplayedTypes aDisplayedTypes
;
194 ::dbaccess::ODsnTypeCollection::TypeIterator aEnd
= m_pCollection
->end();
195 for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop
= m_pCollection
->begin();
200 const ::rtl::OUString sURLPrefix
= aTypeLoop
.getURLPrefix();
201 if ( sURLPrefix
.getLength() )
203 String sDisplayName
= aTypeLoop
.getDisplayName();
204 if ( m_pDatasourceType
->GetEntryPos( sDisplayName
) == LISTBOX_ENTRY_NOTFOUND
205 && approveDataSourceType( sURLPrefix
, sDisplayName
) )
207 aDisplayedTypes
.push_back( DisplayedTypes::value_type( sURLPrefix
, sDisplayName
) );
211 ::std::sort( aDisplayedTypes
.begin(), aDisplayedTypes
.end(), DisplayedTypeLess() );
212 DisplayedTypes::const_iterator aDisplayEnd
= aDisplayedTypes
.end();
213 for ( DisplayedTypes::const_iterator loop
= aDisplayedTypes
.begin();
217 insertDatasourceTypeEntryData( loop
->eType
, loop
->sDisplayName
);
218 } // if ( m_pCollection )
224 //-------------------------------------------------------------------------
225 void OGeneralPage::setParentTitle(const ::rtl::OUString
& _sURLPrefix
)
229 const String sName
= m_pCollection
->getTypeDisplayName(_sURLPrefix
);
230 if ( m_pAdminDialog
)
232 LocalResourceAccess
aStringResAccess( PAGE_GENERAL
, RSC_TABPAGE
);
233 String sMessage
= String(ModuleRes(STR_PARENTTITLE
));
234 sMessage
.SearchAndReplaceAscii("#",sName
);
235 m_pAdminDialog
->setTitle(sMessage
);
240 //-------------------------------------------------------------------------
241 OGeneralPage::CreationMode
OGeneralPage::GetDatabaseCreationMode() const
243 if ( m_aRB_CreateDatabase
.IsChecked() )
245 if ( m_aRB_GetExistingDatabase
.IsChecked() )
246 return eConnectExternal
;
247 return eOpenExisting
;
250 //-------------------------------------------------------------------------
251 void OGeneralPage::GetFocus()
253 OGenericAdministrationPage::GetFocus();
254 if ( m_pLB_DocumentList
.get() && m_pLB_DocumentList
->IsEnabled() )
255 m_pLB_DocumentList
->GrabFocus();
256 else if (m_pDatasourceType
.get() && m_pDatasourceType
->IsEnabled())
257 m_pDatasourceType
->GrabFocus();
260 //-------------------------------------------------------------------------
261 void OGeneralPage::switchMessage(const ::rtl::OUString
& _sURLPrefix
)
263 SPECIAL_MESSAGE eMessage
= smNone
;
264 if ( !_sURLPrefix
.getLength()/*_eType == m_eNotSupportedKnownType*/ )
266 eMessage
= smUnsupportedType
;
270 if ( eMessage
!= m_eLastMessage
)
272 sal_uInt16 nResId
= 0;
273 if ( smUnsupportedType
== eMessage
)
274 nResId
= STR_UNSUPPORTED_DATASOURCE_TYPE
;
278 LocalResourceAccess
aStringResAccess( PAGE_GENERAL
, RSC_TABPAGE
);
279 sMessage
= String(ModuleRes(nResId
));
281 m_aSpecialMessage
.SetText(sMessage
);
283 m_eLastMessage
= eMessage
;
287 //-------------------------------------------------------------------------
288 void OGeneralPage::onTypeSelected(const ::rtl::OUString
& _sURLPrefix
)
290 // the the new URL text as indicated by the selection history
291 implSetCurrentType( _sURLPrefix
);
293 switchMessage(_sURLPrefix
);
295 if ( m_aTypeSelectHandler
.IsSet() )
296 m_aTypeSelectHandler
.Call(this);
299 //-------------------------------------------------------------------------
300 void OGeneralPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
302 initializeTypeList();
304 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
305 sal_Bool bValid
, bReadonly
;
306 getFlags(_rSet
, bValid
, bReadonly
);
309 m_aTypePreLabel
.Hide();
310 m_aTypePostLabel
.Hide();
311 m_aSpecialMessage
.Hide();
312 SetControlFontWeight(&m_aFTHeaderText
);
315 LayoutHelper::positionBelow( m_aRB_GetExistingDatabase
, *m_pDatasourceType
, RelatedControls
, INDENT_BELOW_RADIO
);
317 if ( !bValid
|| bReadonly
)
319 m_aDatasourceTypeLabel
.Enable( false );
320 m_pDatasourceType
->Enable( false );
321 m_aFTDataSourceAppendix
.Enable( false );
322 m_aPB_OpenDocument
.Enable( false );
323 m_aFT_DocListLabel
.Enable( false );
324 m_pLB_DocumentList
->Enable( false );
328 m_aControlDependencies
.enableOnRadioCheck( m_aRB_GetExistingDatabase
, m_aDatasourceTypeLabel
, *m_pDatasourceType
, m_aFTDataSourceAppendix
);
329 m_aControlDependencies
.enableOnRadioCheck( m_aRB_OpenDocument
, m_aPB_OpenDocument
, m_aFT_DocListLabel
, *m_pLB_DocumentList
);
332 m_pLB_DocumentList
->SetDropDownLineCount( 20 );
333 if ( m_pLB_DocumentList
->GetEntryCount() )
334 m_pLB_DocumentList
->SelectEntryPos( 0 );
336 m_aDatasourceTypeLabel
.Hide();
337 m_aFTDataSourceAppendix
.Hide();
339 m_eOriginalCreationMode
= GetDatabaseCreationMode();
343 m_aFT_DatasourceTypeHeader
.Hide();
344 m_aRB_CreateDatabase
.Hide();
345 m_aRB_GetExistingDatabase
.Hide();
346 m_aRB_OpenDocument
.Hide();
347 m_aPB_OpenDocument
.Hide();
348 m_aFT_DocListLabel
.Hide();
349 m_pLB_DocumentList
->Hide();
350 m_aFTHeaderText
.Hide();
351 m_aFTHelpText
.Hide();
352 m_aTypePreLabel
.Enable(bValid
);
353 m_aTypePostLabel
.Enable(bValid
);
354 m_aDatasourceTypeLabel
.Enable(bValid
);
355 m_pDatasourceType
->Enable(bValid
);
357 // if the selection is invalid, disable evrything
358 String sName
,sConnectURL
;
359 m_bDisplayingInvalid
= !bValid
;
362 // collect some items and some values
363 SFX_ITEMSET_GET(_rSet
, pNameItem
, SfxStringItem
, DSID_NAME
, sal_True
);
364 SFX_ITEMSET_GET(_rSet
, pUrlItem
, SfxStringItem
, DSID_CONNECTURL
, sal_True
);
365 DBG_ASSERT(pUrlItem
, "OGeneralPage::implInitControls : missing the type attribute !");
366 DBG_ASSERT(pNameItem
, "OGeneralPage::implInitControls : missing the type attribute !");
367 sName
= pNameItem
->GetValue();
368 sConnectURL
= pUrlItem
->GetValue();
371 ::rtl::OUString eOldSelection
= m_eCurrentSelection
;
372 m_eNotSupportedKnownType
= ::dbaccess::DST_UNKNOWN
;
373 implSetCurrentType( ::rtl::OUString() );
375 // compare the DSN prefix with the registered ones
378 if (m_pCollection
&& bValid
)
380 implSetCurrentType( m_pCollection
->getPrefix(sConnectURL
) );
381 sDisplayName
= m_pCollection
->getTypeDisplayName(m_eCurrentSelection
);
384 // select the correct datasource type
385 if ( approveDataSourceType( m_eCurrentSelection
, sDisplayName
)
386 && ( LISTBOX_ENTRY_NOTFOUND
== m_pDatasourceType
->GetEntryPos( sDisplayName
) )
388 { // this indicates it's really a type which is known in general, but not supported on the current platform
389 // show a message saying so
390 // eSpecialMessage = smUnsupportedType;
391 insertDatasourceTypeEntryData(m_eCurrentSelection
, sDisplayName
);
392 // remember this type so we can show the special message again if the user selects this
393 // type again (without changing the data source)
394 m_eNotSupportedKnownType
= m_pCollection
->determineType(m_eCurrentSelection
);
397 if (m_aRB_CreateDatabase
.IsChecked() && m_DBWizardMode
)
398 sDisplayName
= m_pCollection
->getTypeDisplayName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:")));
399 m_pDatasourceType
->SelectEntry(sDisplayName
);
401 // notify our listener that our type selection has changed (if so)
402 if ( eOldSelection
!= m_eCurrentSelection
)
404 setParentTitle(m_eCurrentSelection
);
405 onTypeSelected(m_eCurrentSelection
);
408 // a special message for the current page state
409 switchMessage(m_eCurrentSelection
);
411 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
415 // For the databaseWizard we only have one entry for the MySQL Database,
416 // because we have a seperate tabpage to retrieve the respective datasource type
417 // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary
418 // representative for all MySQl databases)
419 // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
420 // databases to connect to.
421 bool OGeneralPage::approveDataSourceType( const ::rtl::OUString
& _sURLPrefix
, String
& _inout_rDisplayName
)
423 const ::dbaccess::DATASOURCE_TYPE eType
= m_pCollection
->determineType(_sURLPrefix
);
425 if ( m_DBWizardMode
)
429 case ::dbaccess::DST_MYSQL_JDBC
:
430 _inout_rDisplayName
= m_sMySQLEntry
;
432 case ::dbaccess::DST_MYSQL_ODBC
:
433 case ::dbaccess::DST_MYSQL_NATIVE
:
434 // don't display those, the decision whether the user connects via JDBC/ODBC/C-OOo is made on another
436 _inout_rDisplayName
= String();
438 case ::dbaccess::DST_MYSQL_NATIVE_DIRECT
:
439 // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if
440 // this driver is installed
441 if ( m_pCollection
->hasDriver( "sdbc:mysql:mysqlc:" ) )
442 _inout_rDisplayName
= String();
449 if ( eType
== ::dbaccess::DST_EMBEDDED_HSQLDB
)
450 _inout_rDisplayName
= String();
452 return _inout_rDisplayName
.Len() > 0;
456 // -----------------------------------------------------------------------
457 void OGeneralPage::insertDatasourceTypeEntryData(const ::rtl::OUString
& _sType
, String sDisplayName
)
459 // insert a (temporary) entry
460 sal_uInt16 nPos
= m_pDatasourceType
->InsertEntry(sDisplayName
);
461 if ( nPos
>= m_aURLPrefixes
.size() )
462 m_aURLPrefixes
.resize(nPos
+1);
463 m_aURLPrefixes
[nPos
] = _sType
;
466 // -----------------------------------------------------------------------
467 void OGeneralPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
469 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aTypePreLabel
));
470 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aDatasourceTypeLabel
));
471 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aTypePostLabel
));
472 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aSpecialMessage
));
473 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFTDataSourceAppendix
));
475 // -----------------------------------------------------------------------
476 void OGeneralPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
478 _rControlList
.push_back(new OSaveValueWrapper
<ListBox
>(m_pDatasourceType
.get()));
481 //-------------------------------------------------------------------------
482 SfxTabPage
* OGeneralPage::Create(Window
* _pParent
, const SfxItemSet
& _rAttrSet
, sal_Bool _bWizardMode
)
484 return ( new OGeneralPage( _pParent
, _rAttrSet
, _bWizardMode
) );
487 //-------------------------------------------------------------------------
488 void OGeneralPage::implSetCurrentType( const ::rtl::OUString
& _eType
)
490 if ( _eType
== m_eCurrentSelection
)
493 m_eCurrentSelection
= _eType
;
496 //-------------------------------------------------------------------------
497 void OGeneralPage::Reset(const SfxItemSet
& _rCoreAttrs
)
499 // reset all locale data
500 implSetCurrentType( ::rtl::OUString() );
501 // this ensures that our type selection link will be called, even if the new is is the same as the
503 OGenericAdministrationPage::Reset(_rCoreAttrs
);
506 //-------------------------------------------------------------------------
507 BOOL
OGeneralPage::FillItemSet(SfxItemSet
& _rCoreAttrs
)
509 sal_Bool bChangedSomething
= sal_False
;
511 bool bCommitTypeSelection
= true;
512 if ( m_DBWizardMode
)
514 if ( m_aRB_CreateDatabase
.IsChecked() )
516 _rCoreAttrs
.Put(SfxStringItem(DSID_CONNECTURL
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"))));
517 bChangedSomething
= sal_True
;
518 bCommitTypeSelection
= false;
520 else if ( m_aRB_OpenDocument
.IsChecked() )
522 if ( m_aRB_OpenDocument
.GetSavedValue() != m_aRB_OpenDocument
.IsChecked() )
523 bChangedSomething
= sal_True
;
526 bCommitTypeSelection
= false;
530 if ( bCommitTypeSelection
)
532 USHORT nEntry
= m_pDatasourceType
->GetSelectEntryPos();
533 ::rtl::OUString sURLPrefix
= m_aURLPrefixes
[nEntry
];
536 if ( ( m_pDatasourceType
->GetSavedValue() != nEntry
)
537 || ( GetDatabaseCreationMode() != m_eOriginalCreationMode
)
540 _rCoreAttrs
.Put(SfxStringItem(DSID_CONNECTURL
,sURLPrefix
));
541 bChangedSomething
= sal_True
;
544 implSetCurrentType(sURLPrefix
);
548 if ( m_pDatasourceType
->GetSavedValue() != nEntry
)
550 _rCoreAttrs
.Put(SfxStringItem(DSID_CONNECTURL
, sURLPrefix
));
551 bChangedSomething
= sal_True
;
555 return bChangedSomething
;
558 //-------------------------------------------------------------------------
559 IMPL_LINK(OGeneralPage
, OnDatasourceTypeSelected
, ListBox
*, _pBox
)
561 // get the type from the entry data
562 sal_Int16 nSelected
= _pBox
->GetSelectEntryPos();
563 const ::rtl::OUString sURLPrefix
= m_aURLPrefixes
[nSelected
];
565 setParentTitle(sURLPrefix
);
566 // let the impl method do all the stuff
567 onTypeSelected(sURLPrefix
);
568 // tell the listener we were modified
574 //-------------------------------------------------------------------------
575 OGeneralPage::DocumentDescriptor
OGeneralPage::GetSelectedDocument() const
577 DocumentDescriptor aDocument
;
578 if ( m_aBrowsedDocument
.sURL
.Len() )
579 aDocument
= m_aBrowsedDocument
;
582 aDocument
.sURL
= m_pLB_DocumentList
->GetSelectedDocumentURL();
583 aDocument
.sFilter
= m_pLB_DocumentList
->GetSelectedDocumentFilter();
588 //-------------------------------------------------------------------------
589 IMPL_LINK(OGeneralPage
, OnSetupModeSelected
, RadioButton
*, /*_pBox*/)
591 if ( m_aCreationModeHandler
.IsSet() )
592 m_aCreationModeHandler
.Call(this);
596 //-------------------------------------------------------------------------
597 IMPL_LINK(OGeneralPage
, OnDocumentSelected
, ListBox
*, /*_pBox*/)
599 m_aDocumentSelectionHandler
.Call( this );
603 //-------------------------------------------------------------------------
604 IMPL_LINK(OGeneralPage
, OnOpenDocument
, PushButton
*, /*_pBox*/)
606 ::sfx2::FileDialogHelper
aFileDlg( WB_OPEN
, ::String::CreateFromAscii("sdatabase") );
607 const SfxFilter
* pFilter
= getStandardDatabaseFilter();
610 // aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
611 aFileDlg
.SetCurrentFilter(pFilter
->GetUIName());
613 if ( aFileDlg
.Execute() == ERRCODE_NONE
)
615 String sPath
= aFileDlg
.GetPath();
616 if ( aFileDlg
.GetCurrentFilter() != pFilter
->GetUIName() || !pFilter
->GetWildcard().Matches(sPath
) )
618 String
sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO
));
619 InfoBox
aError(this, sMessage
);
621 m_aRB_GetExistingDatabase
.Check();
622 OnSetupModeSelected(&m_aRB_GetExistingDatabase
);
625 m_aBrowsedDocument
.sURL
= sPath
;
626 m_aBrowsedDocument
.sFilter
= String();
627 m_aChooseDocumentHandler
.Call( this );
634 //.........................................................................
636 //.........................................................................