LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/dlg - generalpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 283 0.0 %
Date: 2012-12-27 Functions: 0 34 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      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>
      46             : 
      47             : //.........................................................................
      48             : namespace dbaui
      49             : {
      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;
      56             : 
      57             :     //=========================================================================
      58             :     //= OGeneralPage
      59             :     //=========================================================================
      60             :     //-------------------------------------------------------------------------
      61           0 :     OGeneralPage::OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode)
      62             :         :OGenericAdministrationPage(pParent, ModuleRes(PAGE_GENERAL), _rItems)
      63             :         ,m_aFTHeaderText                (this, ModuleRes(FT_GENERALHEADERTEXT))
      64             :         ,m_aFTHelpText                  (this, ModuleRes(FT_GENERALHELPTEXT))
      65             :         ,m_aFT_DatasourceTypeHeader     (this, ModuleRes(FT_DATASOURCEHEADER))
      66             :         ,m_aRB_CreateDatabase           (this, ModuleRes(RB_CREATEDBDATABASE))
      67             :         ,m_aRB_OpenDocument             (this, ModuleRes(RB_OPENEXISTINGDOC))
      68             :         ,m_aRB_GetExistingDatabase      (this, ModuleRes(RB_GETEXISTINGDATABASE))
      69             :         ,m_aFT_DocListLabel             (this, ModuleRes(FT_DOCLISTLABEL))
      70           0 :         ,m_pLB_DocumentList             ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes( LB_DOCUMENTLIST ) ) )
      71             :         ,m_aPB_OpenDocument             (this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes(PB_OPENDOCUMENT))
      72             :         ,m_aTypePreLabel                (this, ModuleRes(FT_DATASOURCETYPE_PRE))
      73             :         ,m_aDatasourceTypeLabel         (this, ModuleRes(FT_DATATYPE))
      74           0 :         ,m_pDatasourceType              ( new ListBox(this, ModuleRes(LB_DATATYPE)))
      75             :         ,m_aFTDataSourceAppendix        (this, ModuleRes(FT_DATATYPEAPPENDIX))
      76             :         ,m_aTypePostLabel               (this, ModuleRes(FT_DATASOURCETYPE_POST))
      77             :         ,m_aSpecialMessage              (this, ModuleRes(FT_SPECIAL_MESSAGE))
      78             :         ,m_DBWizardMode                 (_bDBWizardMode)
      79             :         ,m_sMySQLEntry                  (ModuleRes(STR_MYSQLENTRY))
      80             :         ,m_eOriginalCreationMode        (eCreateNew)
      81             :         ,m_pCollection                  (NULL)
      82             :         ,m_eNotSupportedKnownType       ( ::dbaccess::DST_UNKNOWN)
      83             :         ,m_eLastMessage                 (smNone)
      84             :         ,m_bDisplayingInvalid           (sal_False)
      85           0 :         ,m_bInitTypeList                (true)
      86             :     {
      87             :         // fill the listbox with the UI descriptions for the possible types
      88             :         // and remember the respective DSN prefixes
      89           0 :         FreeResource();
      90             :         // extract the datasource type collection from the item set
      91           0 :         DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION));
      92           0 :         if (pCollectionItem)
      93           0 :             m_pCollection = pCollectionItem->getCollection();
      94             :         OSL_ENSURE(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
      95             : 
      96             :         // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
      97           0 :         sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() );
      98           0 :         if ( nCreateNewDBIndex == -1 )
      99           0 :             nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) );
     100           0 :         bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
     101             : 
     102             :         // also, if our application policies tell us to hide the option, do it
     103             :         ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
     104             :             ::comphelper::getProcessServiceFactory(),
     105             :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/Policies/Features/Base" ) )
     106           0 :         ) );
     107           0 :         sal_Bool bAllowCreateLocalDatabase( sal_True );
     108           0 :         OSL_VERIFY( aConfig.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase );
     109           0 :         if ( !bAllowCreateLocalDatabase )
     110           0 :             bHideCreateNew = true;
     111             : 
     112           0 :         if ( bHideCreateNew )
     113             :         {
     114           0 :             m_aRB_CreateDatabase.Hide();
     115             :             Window* pWindowsToMove[] = {
     116           0 :                 &m_aRB_OpenDocument, &m_aRB_GetExistingDatabase, &m_aFT_DocListLabel, m_pLB_DocumentList.get(),
     117           0 :                 &m_aPB_OpenDocument, &m_aDatasourceTypeLabel, m_pDatasourceType.get(), &m_aFTDataSourceAppendix,
     118             :                 &m_aTypePostLabel
     119           0 :             };
     120           0 :             const long nOffset = m_aRB_OpenDocument.GetPosPixel().Y() - m_aRB_CreateDatabase.GetPosPixel().Y();
     121           0 :             for ( size_t i=0; i < sizeof( pWindowsToMove ) / sizeof( pWindowsToMove[0] ); ++i )
     122             :             {
     123           0 :                 Point aPos( pWindowsToMove[i]->GetPosPixel() );
     124           0 :                 aPos.Y() -= nOffset;
     125           0 :                 pWindowsToMove[i]->SetPosPixel( aPos );
     126             :             }
     127             :         }
     128             : 
     129           0 :         if ( bHideCreateNew )
     130           0 :             m_aRB_GetExistingDatabase.Check();
     131             :         else
     132           0 :             m_aRB_CreateDatabase.Check();
     133             : 
     134             :         // do some knittings
     135           0 :         m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
     136           0 :            m_aRB_CreateDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
     137           0 :            m_aRB_GetExistingDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
     138           0 :            m_aRB_OpenDocument.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
     139           0 :         m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPage, OnDocumentSelected ) );
     140           0 :         m_aPB_OpenDocument.SetClickHdl( LINK( this, OGeneralPage, OnOpenDocument ) );
     141           0 :     }
     142             : 
     143             :     //-------------------------------------------------------------------------
     144           0 :     OGeneralPage::~OGeneralPage()
     145             :     {
     146           0 :         m_pDatasourceType.reset( NULL );
     147           0 :         m_pLB_DocumentList.reset( NULL );
     148           0 :     }
     149             : 
     150             :     //-------------------------------------------------------------------------
     151             :     namespace
     152             :     {
     153           0 :         struct DisplayedType
     154             :         {
     155             :             ::rtl::OUString eType;
     156             :             String          sDisplayName;
     157             : 
     158           0 :             DisplayedType( const ::rtl::OUString& _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { }
     159             :         };
     160             :         typedef ::std::vector< DisplayedType > DisplayedTypes;
     161             : 
     162             :         struct DisplayedTypeLess : ::std::binary_function< DisplayedType, DisplayedType, bool >
     163             :         {
     164           0 :             bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS )
     165             :             {
     166           0 :                 return _rLHS.eType < _rRHS.eType;
     167             :             }
     168             :         };
     169             :     }
     170             : 
     171             :     //-------------------------------------------------------------------------
     172           0 :     void OGeneralPage::initializeTypeList()
     173             :     {
     174           0 :         if ( m_bInitTypeList )
     175             :         {
     176           0 :             m_bInitTypeList = false;
     177           0 :             m_pDatasourceType->Clear();
     178             : 
     179           0 :             if ( m_pCollection )
     180             :             {
     181           0 :                 DisplayedTypes aDisplayedTypes;
     182             : 
     183           0 :                 ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end();
     184           0 :                 for (   ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop =  m_pCollection->begin();
     185             :                         aTypeLoop != aEnd;
     186             :                         ++aTypeLoop
     187             :                     )
     188             :                 {
     189           0 :                     const ::rtl::OUString sURLPrefix = aTypeLoop.getURLPrefix();
     190           0 :                     if ( !sURLPrefix.isEmpty() )
     191             :                     {
     192           0 :                         String sDisplayName = aTypeLoop.getDisplayName();
     193           0 :                         if (   m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
     194           0 :                             && approveDataSourceType( sURLPrefix, sDisplayName ) )
     195             :                         {
     196           0 :                             aDisplayedTypes.push_back( DisplayedTypes::value_type( sURLPrefix, sDisplayName ) );
     197           0 :                         }
     198             :                     }
     199           0 :                 }
     200           0 :                 ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
     201           0 :                 DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end();
     202           0 :                 for (   DisplayedTypes::const_iterator loop = aDisplayedTypes.begin();
     203             :                         loop != aDisplayEnd;
     204             :                         ++loop
     205             :                     )
     206           0 :                     insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName );
     207             :             }
     208             :         }
     209           0 :     }
     210             : 
     211             : 
     212             : 
     213             :     //-------------------------------------------------------------------------
     214           0 :     void OGeneralPage::setParentTitle(const ::rtl::OUString& _sURLPrefix)
     215             :     {
     216           0 :         if (!m_DBWizardMode)
     217             :         {
     218           0 :             const String sName = m_pCollection->getTypeDisplayName(_sURLPrefix);
     219           0 :             if ( m_pAdminDialog )
     220             :             {
     221           0 :                 LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
     222           0 :                 String sMessage = String(ModuleRes(STR_PARENTTITLE));
     223           0 :                 sMessage.SearchAndReplaceAscii("#",sName);
     224           0 :                 m_pAdminDialog->setTitle(sMessage);
     225           0 :             }
     226             :         }
     227           0 :     }
     228             : 
     229             :     //-------------------------------------------------------------------------
     230           0 :     OGeneralPage::CreationMode OGeneralPage::GetDatabaseCreationMode() const
     231             :     {
     232           0 :         if ( m_aRB_CreateDatabase.IsChecked() )
     233           0 :             return eCreateNew;
     234           0 :         if ( m_aRB_GetExistingDatabase.IsChecked() )
     235           0 :             return eConnectExternal;
     236           0 :         return eOpenExisting;
     237             :     }
     238             : 
     239             :     //-------------------------------------------------------------------------
     240           0 :     void OGeneralPage::GetFocus()
     241             :     {
     242           0 :         OGenericAdministrationPage::GetFocus();
     243           0 :         if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() )
     244           0 :             m_pLB_DocumentList->GrabFocus();
     245           0 :         else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled())
     246           0 :             m_pDatasourceType->GrabFocus();
     247           0 :     }
     248             : 
     249             :     //-------------------------------------------------------------------------
     250           0 :     void OGeneralPage::switchMessage(const ::rtl::OUString& _sURLPrefix)
     251             :     {
     252           0 :         SPECIAL_MESSAGE eMessage = smNone;
     253           0 :         if ( _sURLPrefix.isEmpty()/*_eType == m_eNotSupportedKnownType*/ )
     254             :         {
     255           0 :             eMessage = smUnsupportedType;
     256             :         }
     257             : 
     258             : 
     259           0 :         if ( eMessage != m_eLastMessage )
     260             :         {
     261           0 :             sal_uInt16 nResId = 0;
     262           0 :             if ( smUnsupportedType == eMessage )
     263           0 :                 nResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
     264           0 :             String sMessage;
     265           0 :             if ( nResId )
     266             :             {
     267           0 :                 LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
     268           0 :                 sMessage = String(ModuleRes(nResId));
     269             :             }
     270           0 :             m_aSpecialMessage.SetText(sMessage);
     271             : 
     272           0 :             m_eLastMessage = eMessage;
     273             :         }
     274           0 :     }
     275             : 
     276             :     //-------------------------------------------------------------------------
     277           0 :     void OGeneralPage::onTypeSelected(const ::rtl::OUString& _sURLPrefix)
     278             :     {
     279             :         // the the new URL text as indicated by the selection history
     280           0 :         implSetCurrentType( _sURLPrefix );
     281             : 
     282           0 :         switchMessage(_sURLPrefix);
     283             : 
     284           0 :         if ( m_aTypeSelectHandler.IsSet() )
     285           0 :             m_aTypeSelectHandler.Call(this);
     286           0 :     }
     287             : 
     288             :     //-------------------------------------------------------------------------
     289           0 :     void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     290             :     {
     291           0 :         initializeTypeList();
     292             : 
     293             :         // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     294             :         sal_Bool bValid, bReadonly;
     295           0 :         getFlags(_rSet, bValid, bReadonly);
     296           0 :         if (m_DBWizardMode)
     297             :         {
     298           0 :             m_aTypePreLabel.Hide();
     299           0 :             m_aTypePostLabel.Hide();
     300           0 :             m_aSpecialMessage.Hide();
     301           0 :             SetControlFontWeight(&m_aFTHeaderText);
     302           0 :             SetText(String());
     303             : 
     304           0 :             LayoutHelper::positionBelow( m_aRB_GetExistingDatabase, *m_pDatasourceType, RelatedControls, INDENT_BELOW_RADIO );
     305             : 
     306           0 :             if ( !bValid || bReadonly )
     307             :             {
     308           0 :                 m_aDatasourceTypeLabel.Enable( false );
     309           0 :                 m_pDatasourceType->Enable( false );
     310           0 :                 m_aFTDataSourceAppendix.Enable( false );
     311           0 :                 m_aPB_OpenDocument.Enable( false );
     312           0 :                 m_aFT_DocListLabel.Enable( false );
     313           0 :                 m_pLB_DocumentList->Enable( false );
     314             :             }
     315             :             else
     316             :             {
     317           0 :                 m_aControlDependencies.enableOnRadioCheck( m_aRB_GetExistingDatabase, m_aDatasourceTypeLabel, *m_pDatasourceType, m_aFTDataSourceAppendix );
     318           0 :                 m_aControlDependencies.enableOnRadioCheck( m_aRB_OpenDocument, m_aPB_OpenDocument, m_aFT_DocListLabel, *m_pLB_DocumentList );
     319             :             }
     320             : 
     321           0 :             m_pLB_DocumentList->SetDropDownLineCount( 20 );
     322           0 :             if ( m_pLB_DocumentList->GetEntryCount() )
     323           0 :                 m_pLB_DocumentList->SelectEntryPos( 0 );
     324             : 
     325           0 :             m_aDatasourceTypeLabel.Hide();
     326           0 :             m_aFTDataSourceAppendix.Hide();
     327             : 
     328           0 :             m_eOriginalCreationMode = GetDatabaseCreationMode();
     329             :         }
     330             :         else
     331             :         {
     332           0 :             m_aFT_DatasourceTypeHeader.Hide();
     333           0 :             m_aRB_CreateDatabase.Hide();
     334           0 :             m_aRB_GetExistingDatabase.Hide();
     335           0 :             m_aRB_OpenDocument.Hide();
     336           0 :             m_aPB_OpenDocument.Hide();
     337           0 :             m_aFT_DocListLabel.Hide();
     338           0 :             m_pLB_DocumentList->Hide();
     339           0 :             m_aFTHeaderText.Hide();
     340           0 :             m_aFTHelpText.Hide();
     341           0 :             m_aTypePreLabel.Enable(bValid);
     342           0 :             m_aTypePostLabel.Enable(bValid);
     343           0 :             m_aDatasourceTypeLabel.Enable(bValid);
     344           0 :             m_pDatasourceType->Enable(bValid);
     345             :         }
     346             :         // if the selection is invalid, disable evrything
     347           0 :         String sName,sConnectURL;
     348           0 :         m_bDisplayingInvalid = !bValid;
     349           0 :         if ( bValid )
     350             :         {
     351             :             // collect some items and some values
     352           0 :             SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
     353           0 :             SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
     354             :             OSL_ENSURE(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !");
     355             :             OSL_ENSURE(pNameItem, "OGeneralPage::implInitControls : missing the type attribute !");
     356           0 :             sName = pNameItem->GetValue();
     357           0 :             sConnectURL = pUrlItem->GetValue();
     358             :         }
     359             : 
     360           0 :         ::rtl::OUString eOldSelection = m_eCurrentSelection;
     361           0 :         m_eNotSupportedKnownType =  ::dbaccess::DST_UNKNOWN;
     362           0 :         implSetCurrentType(  ::rtl::OUString() );
     363             : 
     364             :         // compare the DSN prefix with the registered ones
     365           0 :         String sDisplayName;
     366             : 
     367           0 :         if (m_pCollection && bValid)
     368             :         {
     369           0 :             implSetCurrentType( m_pCollection->getPrefix(sConnectURL) );
     370           0 :             sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection);
     371             :         }
     372             : 
     373             :         // select the correct datasource type
     374           0 :         if  (   approveDataSourceType( m_eCurrentSelection, sDisplayName )
     375           0 :             &&  ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) )
     376             :             )
     377             :         {   // this indicates it's really a type which is known in general, but not supported on the current platform
     378             :             // show a message saying so
     379             :             //  eSpecialMessage = smUnsupportedType;
     380           0 :             insertDatasourceTypeEntryData(m_eCurrentSelection, sDisplayName);
     381             :             // remember this type so we can show the special message again if the user selects this
     382             :             // type again (without changing the data source)
     383           0 :             m_eNotSupportedKnownType = m_pCollection->determineType(m_eCurrentSelection);
     384             :         }
     385             : 
     386           0 :         if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode)
     387           0 :             sDisplayName = m_pCollection->getTypeDisplayName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:")));
     388           0 :         m_pDatasourceType->SelectEntry(sDisplayName);
     389             : 
     390             :         // notify our listener that our type selection has changed (if so)
     391           0 :         if ( eOldSelection != m_eCurrentSelection )
     392             :         {
     393           0 :             setParentTitle(m_eCurrentSelection);
     394           0 :             onTypeSelected(m_eCurrentSelection);
     395             :         }
     396             : 
     397             :         // a special message for the current page state
     398           0 :         switchMessage(m_eCurrentSelection);
     399             : 
     400           0 :         OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
     401           0 :     }
     402             : 
     403             : 
     404             :     // For the databaseWizard we only have one entry for the MySQL Database,
     405             :     // because we have a seperate tabpage to retrieve the respective datasource type
     406             :     // ( ::dbaccess::DST_MYSQL_ODBC ||  ::dbaccess::DST_MYSQL_JDBC). Therefore we use  ::dbaccess::DST_MYSQL_JDBC as a temporary
     407             :     // representative for all MySQl databases)
     408             :     // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
     409             :     // databases to connect to.
     410           0 :     bool OGeneralPage::approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName )
     411             :     {
     412           0 :         const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(_sURLPrefix);
     413             : 
     414           0 :         if ( m_DBWizardMode )
     415             :         {
     416           0 :             switch ( eType )
     417             :             {
     418             :             case ::dbaccess::DST_MYSQL_JDBC:
     419           0 :                 _inout_rDisplayName = m_sMySQLEntry;
     420           0 :                 break;
     421             :             case ::dbaccess::DST_MYSQL_ODBC:
     422             :             case ::dbaccess::DST_MYSQL_NATIVE:
     423             :                 // don't display those, the decision whether the user connects via JDBC/ODBC/C-OOo is made on another
     424             :                 // page
     425           0 :                 _inout_rDisplayName = String();
     426           0 :                 break;
     427             :             default:
     428           0 :                 break;
     429             :             }
     430             :         }
     431             : 
     432           0 :         if ( eType == ::dbaccess::DST_MYSQL_NATIVE_DIRECT )
     433             :         {
     434             :             // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if
     435             :             // this driver is installed
     436           0 :             if ( m_pCollection->hasDriver( "sdbc:mysql:mysqlc:" ) )
     437           0 :                 _inout_rDisplayName = String();
     438             :         }
     439             : 
     440           0 :         if ( eType ==  ::dbaccess::DST_EMBEDDED_HSQLDB )
     441           0 :             _inout_rDisplayName = String();
     442             : 
     443           0 :         return _inout_rDisplayName.Len() > 0;
     444             :     }
     445             : 
     446             : 
     447             :     // -----------------------------------------------------------------------
     448           0 :     void OGeneralPage::insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName)
     449             :     {
     450             :         // insert a (temporary) entry
     451           0 :         sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName);
     452           0 :         if ( nPos >= m_aURLPrefixes.size() )
     453           0 :             m_aURLPrefixes.resize(nPos+1);
     454           0 :         m_aURLPrefixes[nPos] = _sType;
     455           0 :     }
     456             : 
     457             :     // -----------------------------------------------------------------------
     458           0 :     void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     459             :     {
     460           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePreLabel));
     461           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDatasourceTypeLabel));
     462           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePostLabel));
     463           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aSpecialMessage));
     464           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDataSourceAppendix));
     465           0 :     }
     466             :     // -----------------------------------------------------------------------
     467           0 :     void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     468             :     {
     469           0 :         _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pDatasourceType.get()));
     470           0 :     }
     471             : 
     472             :     //-------------------------------------------------------------------------
     473           0 :     SfxTabPage* OGeneralPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet, sal_Bool _bWizardMode)
     474             :     {
     475           0 :            return ( new OGeneralPage( _pParent, _rAttrSet, _bWizardMode ) );
     476             :     }
     477             : 
     478             :     //-------------------------------------------------------------------------
     479           0 :     void OGeneralPage::implSetCurrentType( const ::rtl::OUString& _eType )
     480             :     {
     481           0 :         if ( _eType == m_eCurrentSelection )
     482           0 :             return;
     483             : 
     484           0 :         m_eCurrentSelection = _eType;
     485             :     }
     486             : 
     487             :     //-------------------------------------------------------------------------
     488           0 :     void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs)
     489             :     {
     490             :         // reset all locale data
     491           0 :         implSetCurrentType(  ::rtl::OUString() );
     492             :             // this ensures that our type selection link will be called, even if the new is is the same as the
     493             :             // current one
     494           0 :         OGenericAdministrationPage::Reset(_rCoreAttrs);
     495           0 :     }
     496             : 
     497             :     //-------------------------------------------------------------------------
     498           0 :     sal_Bool OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs)
     499             :     {
     500           0 :         sal_Bool bChangedSomething = sal_False;
     501             : 
     502           0 :         bool bCommitTypeSelection = true;
     503           0 :         if ( m_DBWizardMode )
     504             :         {
     505           0 :             if ( m_aRB_CreateDatabase.IsChecked() )
     506             :             {
     507           0 :                 _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"))));
     508           0 :                 bChangedSomething = sal_True;
     509           0 :                 bCommitTypeSelection = false;
     510             :             }
     511           0 :             else if ( m_aRB_OpenDocument.IsChecked() )
     512             :             {
     513           0 :                 if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() )
     514           0 :                     bChangedSomething = sal_True;
     515             : 
     516             :                 // TODO
     517           0 :                 bCommitTypeSelection = false;
     518             :             }
     519             :         }
     520             : 
     521           0 :         if ( bCommitTypeSelection )
     522             :         {
     523           0 :             sal_uInt16 nEntry = m_pDatasourceType->GetSelectEntryPos();
     524           0 :             ::rtl::OUString sURLPrefix = m_aURLPrefixes[nEntry];
     525           0 :             if (m_DBWizardMode)
     526             :             {
     527           0 :                 if  (  ( m_pDatasourceType->GetSavedValue() != nEntry )
     528           0 :                     || ( GetDatabaseCreationMode() != m_eOriginalCreationMode )
     529             :                     )
     530             :                 {
     531           0 :                     _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL,sURLPrefix ));
     532           0 :                     bChangedSomething = sal_True;
     533             :                 }
     534             :                 else
     535           0 :                     implSetCurrentType(sURLPrefix);
     536             :             }
     537             :             else
     538             :             {
     539           0 :                 if ( m_pDatasourceType->GetSavedValue() != nEntry)
     540             :                 {
     541           0 :                     _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, sURLPrefix));
     542           0 :                     bChangedSomething = sal_True;
     543             :                 }
     544           0 :             }
     545             :         }
     546           0 :         return bChangedSomething;
     547             :     }
     548             : 
     549             :     //-------------------------------------------------------------------------
     550           0 :     IMPL_LINK(OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox)
     551             :     {
     552             :         // get the type from the entry data
     553           0 :         sal_Int16 nSelected = _pBox->GetSelectEntryPos();
     554           0 :         const ::rtl::OUString sURLPrefix = m_aURLPrefixes[nSelected];
     555             : 
     556           0 :         setParentTitle(sURLPrefix);
     557             :         // let the impl method do all the stuff
     558           0 :         onTypeSelected(sURLPrefix);
     559             :         // tell the listener we were modified
     560           0 :         callModifiedHdl();
     561             :         // outta here
     562           0 :         return 0L;
     563             :     }
     564             : 
     565             :     //-------------------------------------------------------------------------
     566           0 :     OGeneralPage::DocumentDescriptor OGeneralPage::GetSelectedDocument() const
     567             :     {
     568           0 :         DocumentDescriptor aDocument;
     569           0 :         if ( m_aBrowsedDocument.sURL.Len() )
     570           0 :             aDocument = m_aBrowsedDocument;
     571             :         else
     572             :         {
     573           0 :             aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL();
     574           0 :             aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter();
     575             :         }
     576           0 :         return aDocument;
     577             :     }
     578             : 
     579             :     //-------------------------------------------------------------------------
     580           0 :     IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, /*_pBox*/)
     581             :     {
     582           0 :         if ( m_aCreationModeHandler.IsSet() )
     583           0 :             m_aCreationModeHandler.Call(this);
     584           0 :         return 1L;
     585             :     }
     586             : 
     587             :     //-------------------------------------------------------------------------
     588           0 :     IMPL_LINK(OGeneralPage, OnDocumentSelected, ListBox*, /*_pBox*/)
     589             :     {
     590           0 :         m_aDocumentSelectionHandler.Call( this );
     591           0 :         return 0L;
     592             :     }
     593             : 
     594             :     //-------------------------------------------------------------------------
     595           0 :     IMPL_LINK(OGeneralPage, OnOpenDocument, PushButton*, /*_pBox*/)
     596             :     {
     597             :         ::sfx2::FileDialogHelper aFileDlg(
     598             :                 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
     599           0 :                 0, rtl::OUString::createFromAscii("sdatabase") );
     600           0 :         const SfxFilter* pFilter = getStandardDatabaseFilter();
     601           0 :         if ( pFilter )
     602             :         {
     603           0 :             aFileDlg.SetCurrentFilter(pFilter->GetUIName());
     604             :         }
     605           0 :         if ( aFileDlg.Execute() == ERRCODE_NONE )
     606             :         {
     607           0 :             String sPath = aFileDlg.GetPath();
     608           0 :             if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) )
     609             :             {
     610           0 :                 String sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO));
     611           0 :                 InfoBox aError(this, sMessage);
     612           0 :                 aError.Execute();
     613           0 :                 m_aRB_GetExistingDatabase.Check();
     614           0 :                 OnSetupModeSelected(&m_aRB_GetExistingDatabase);
     615           0 :                 return 0L;
     616             :             }
     617           0 :             m_aBrowsedDocument.sURL = sPath;
     618           0 :             m_aBrowsedDocument.sFilter = String();
     619           0 :             m_aChooseDocumentHandler.Call( this );
     620           0 :             return 1L;
     621             :         }
     622             : 
     623           0 :         return 0L;
     624             :     }
     625             : 
     626             : //.........................................................................
     627           0 : }   // namespace dbaui
     628             : //.........................................................................
     629             : 
     630             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10