LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/dlg - DBSetupConnectionPages.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 421 0.0 %
Date: 2012-12-27 Functions: 0 94 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             : #include "DBSetupConnectionPages.hxx"
      21             : #include "sqlmessage.hxx"
      22             : #include "dbu_resource.hrc"
      23             : #include "AutoControls.hrc"
      24             : #include "dbadminsetup.hrc"
      25             : #include <svl/itemset.hxx>
      26             : #include <svl/stritem.hxx>
      27             : #include <svl/eitem.hxx>
      28             : #include <svl/intitem.hxx>
      29             : #include "dsitems.hxx"
      30             : #include "dsnItem.hxx"
      31             : #include "dbaccess_helpid.hrc"
      32             : #include "localresaccess.hxx"
      33             : #include <vcl/msgbox.hxx>
      34             : #include <vcl/mnemonic.hxx>
      35             : #include <svl/cjkoptions.hxx>
      36             : #include <jvmaccess/virtualmachine.hxx>
      37             : #include <connectivity/CommonTools.hxx>
      38             : #include "DriverSettings.hxx"
      39             : #include "dbadmin.hxx"
      40             : #include <comphelper/types.hxx>
      41             : 
      42             : #include <com/sun/star/task/XInteractionHandler.hpp>
      43             : #include <com/sun/star/sdbc/XDriverAccess.hpp>
      44             : #include "dbustrings.hrc"
      45             : #include <svl/filenotation.hxx>
      46             : 
      47             : #include <unotools/localfilehelper.hxx>
      48             : #include <unotools/ucbhelper.hxx>
      49             : #include <ucbhelper/commandenvironment.hxx>
      50             : #include "finteraction.hxx"
      51             : #include <unotools/pathoptions.hxx>
      52             : #include <svtools/roadmapwizard.hxx>
      53             : #include "TextConnectionHelper.hxx"
      54             : #include <osl/diagnose.h>
      55             : 
      56             : 
      57             : //.........................................................................
      58             : namespace dbaui
      59             : {
      60             : //.........................................................................
      61             : using namespace ::com::sun::star;
      62             : 
      63           0 :     OGenericAdministrationPage* OTextConnectionPageSetup::CreateTextTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
      64             :     {
      65           0 :         return ( new OTextConnectionPageSetup( pParent, _rAttrSet ) );
      66             :     }
      67             : 
      68             : 
      69             :     //========================================================================
      70             :     //= OTextConnectionPageSetup
      71             :     //========================================================================
      72             : DBG_NAME(OTextConnectionPageSetup)
      73             : //------------------------------------------------------------------------
      74           0 :     OTextConnectionPageSetup::OTextConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
      75           0 :         :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_TEXT, _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE)
      76             :     {
      77             :         DBG_CTOR(OTextConnectionPageSetup,NULL);
      78             : 
      79           0 :         m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_SEPARATORS );
      80           0 :         m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) );
      81             : 
      82           0 :         FreeResource();
      83           0 :     }
      84             : 
      85             : 
      86             :     // -----------------------------------------------------------------------
      87           0 :     OTextConnectionPageSetup::~OTextConnectionPageSetup()
      88             :     {
      89           0 :         DELETEZ(m_pTextConnectionHelper);
      90             : 
      91             :         DBG_DTOR(OTextConnectionPageSetup,NULL);
      92           0 :     }
      93             : 
      94           0 :     IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/)
      95             :     {
      96           0 :         SetRoadmapStateValue((m_pTextConnectionHelper->GetExtension().Len() > 0) && OConnectionTabPageSetup::checkTestConnection());
      97           0 :         callModifiedHdl();
      98           0 :         return sal_True;
      99             :     }
     100             : 
     101             : 
     102           0 :     bool OTextConnectionPageSetup::checkTestConnection()
     103             :     {
     104           0 :         bool bDoEnable = OConnectionTabPageSetup::checkTestConnection();
     105           0 :         bDoEnable = (m_pTextConnectionHelper->GetExtension().Len() > 0) && bDoEnable;
     106           0 :         return bDoEnable;
     107             :     }
     108             : 
     109             :     // -----------------------------------------------------------------------
     110           0 :     void OTextConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     111             :     {
     112           0 :         OConnectionTabPageSetup::fillControls(_rControlList);
     113           0 :         m_pTextConnectionHelper->fillControls(_rControlList);
     114           0 :     }
     115             :     // -----------------------------------------------------------------------
     116           0 :     void OTextConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     117             :     {
     118           0 :         OConnectionTabPageSetup::fillWindows(_rControlList);
     119           0 :         m_pTextConnectionHelper->fillWindows(_rControlList);
     120           0 :     }
     121             :     // -----------------------------------------------------------------------
     122           0 :     void OTextConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     123             :     {
     124             :         // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     125             :         sal_Bool bValid, bReadonly;
     126           0 :         getFlags(_rSet, bValid, bReadonly);
     127           0 :         OConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue);
     128           0 :         m_pTextConnectionHelper->implInitControls(_rSet, bValid);
     129           0 :     }
     130             : 
     131             : 
     132             :     // -----------------------------------------------------------------------
     133           0 :     sal_Bool OTextConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
     134             :     {
     135           0 :         sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
     136           0 :         bChangedSomething = m_pTextConnectionHelper->FillItemSet(_rSet, bChangedSomething);
     137           0 :         return bChangedSomething;
     138             :     }
     139             : 
     140             : 
     141           0 :     sal_Bool OTextConnectionPageSetup::prepareLeave(){
     142           0 :         return m_pTextConnectionHelper->prepareLeave();
     143             :     }
     144             : 
     145             : 
     146           0 :     OGenericAdministrationPage* OLDAPConnectionPageSetup::CreateLDAPTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
     147             :     {
     148           0 :         return ( new OLDAPConnectionPageSetup( pParent, _rAttrSet ) );
     149             :     }
     150             : 
     151             : 
     152             :     //========================================================================
     153             :     //= OLDAPPageSetup
     154             :     //========================================================================
     155           0 :     OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
     156             :         :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_LDAP), _rCoreAttrs)
     157             :         ,m_aFTHeaderText        (this, ModuleRes(FT_LDAP_HEADERTEXT))
     158             :         ,m_aFTHelpText          (this, ModuleRes(FT_LDAP_HELPTEXT))
     159             :         ,m_aFTHostServer        (this, ModuleRes(FT_AUTOHOSTNAME))
     160             :         ,m_aETHostServer        (this, ModuleRes(ET_AUTOHOSTNAME))
     161             :         ,m_aFTBaseDN            (this, ModuleRes(FT_AUTOBASEDN))
     162             :         ,m_aETBaseDN            (this, ModuleRes(ET_AUTOBASEDN))
     163             :         ,m_aFTPortNumber        (this, ModuleRes(FT_AUTOPORTNUMBER))
     164             :         ,m_aNFPortNumber        (this, ModuleRes(NF_AUTOPORTNUMBER))
     165             :         ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT))
     166           0 :         ,m_aCBUseSSL            (this, ModuleRes(CB_WIZ_USESSL))
     167             :     {
     168           0 :         SetControlFontWeight(&m_aFTHeaderText);
     169           0 :         m_aFTDefaultPortNumber.SetText(String(ModuleRes(STR_LDAP_DEFAULT)));
     170           0 :         m_aETHostServer.SetModifyHdl(getControlModifiedLink());
     171           0 :         m_aETBaseDN.SetModifyHdl(getControlModifiedLink());
     172           0 :         m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
     173           0 :         m_aCBUseSSL.SetToggleHdl(getControlModifiedLink());
     174           0 :         SetRoadmapStateValue(sal_False);
     175           0 :         FreeResource();
     176           0 :     }
     177             : 
     178             :     // -----------------------------------------------------------------------
     179           0 :     sal_Bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
     180             :     {
     181           0 :            sal_Bool bChangedSomething = sal_False;
     182           0 :         fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN, bChangedSomething);
     183           0 :         fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
     184             : 
     185           0 :         if ( m_aETHostServer.GetText() != m_aETHostServer.GetSavedValue() )
     186             :         {
     187           0 :             DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
     188           0 :             ::dbaccess::ODsnTypeCollection* pCollection = NULL;
     189           0 :             if (pCollectionItem)
     190           0 :                 pCollection = pCollectionItem->getCollection();
     191             :             OSL_ENSURE(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
     192             : 
     193           0 :             String sUrl = pCollection->getPrefix( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:ldap:")));
     194           0 :             sUrl += m_aETHostServer.GetText();
     195           0 :             _rSet.Put(SfxStringItem(DSID_CONNECTURL, sUrl));
     196           0 :             bChangedSomething = sal_True;
     197             :         }
     198             : 
     199           0 :         fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
     200           0 :         return bChangedSomething;
     201             :     }
     202             :     // -----------------------------------------------------------------------
     203           0 :     void OLDAPConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     204             :     {
     205           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostServer));
     206           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN));
     207           0 :         _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
     208           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL));
     209           0 :     }
     210             :     // -----------------------------------------------------------------------
     211           0 :     void OLDAPConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     212             :     {
     213           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
     214           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostServer));
     215           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTBaseDN));
     216           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber));
     217           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber));
     218           0 :     }
     219             :     // -----------------------------------------------------------------------
     220           0 :     void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     221             :     {
     222             :         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     223             :         sal_Bool bValid, bReadonly;
     224           0 :         getFlags(_rSet, bValid, bReadonly);
     225             : 
     226             : 
     227           0 :         SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True);
     228           0 :         SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True);
     229             : 
     230           0 :         if ( bValid )
     231             :         {
     232           0 :             m_aETBaseDN.SetText(pBaseDN->GetValue());
     233           0 :             m_aNFPortNumber.SetValue(pPortNumber->GetValue());
     234             :         }
     235           0 :            OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
     236           0 :         callModifiedHdl();
     237           0 :     }
     238             : 
     239             :     // -----------------------------------------------------------------------
     240           0 :     IMPL_LINK(OLDAPConnectionPageSetup, OnEditModified, Edit*, /*_pEdit*/)
     241             :     {
     242           0 :         sal_Bool bRoadmapState = ((m_aETHostServer.GetText().Len() != 0 ) && ( m_aETBaseDN.GetText().Len() != 0 ) && (m_aFTPortNumber.GetText().Len() != 0 ));
     243           0 :         SetRoadmapStateValue(bRoadmapState);
     244           0 :         callModifiedHdl();
     245           0 :         return 0L;
     246             :     }
     247             : 
     248             : 
     249             :     // ----------------------------------------------------------------------- //OGenericAdministrationPage*
     250           0 :     OMySQLIntroPageSetup* OMySQLIntroPageSetup::CreateMySQLIntroTabPage( Window* _pParent, const SfxItemSet& _rAttrSet )
     251             :     {
     252           0 :         return ( new OMySQLIntroPageSetup( _pParent, _rAttrSet) );
     253             :     }
     254             : 
     255             : DBG_NAME(OMySQLIntroPageSetup)
     256             : 
     257           0 :     OMySQLIntroPageSetup::OMySQLIntroPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
     258             :             :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_MYSQL_INTRO), _rCoreAttrs)
     259             :             ,m_aRB_ODBCDatabase(this, ModuleRes(RB_CONNECTVIAODBC))
     260             :             ,m_aRB_JDBCDatabase(this, ModuleRes(RB_CONNECTVIAJDBC))
     261             :             ,m_aRB_NATIVEDatabase(this, ModuleRes(RB_CONNECTVIANATIVE))
     262             :             ,m_aFT_ConnectionMode(this, ModuleRes(FT_MYSQLCONNECTIONMODE))
     263             :             ,m_aFT_Helptext(this, ModuleRes(FT_MYSQL_HELPTEXT))
     264           0 :             ,m_aFT_Headertext(this, ModuleRes(FT_MYSQL_HEADERTEXT))
     265             :     {
     266             :         DBG_CTOR(OMySQLIntroPageSetup,NULL);
     267             : 
     268           0 :         SetControlFontWeight(&m_aFT_Headertext);
     269           0 :            m_aRB_ODBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
     270           0 :            m_aRB_JDBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
     271           0 :         m_aRB_NATIVEDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
     272           0 :         FreeResource();
     273           0 :     }
     274             : 
     275           0 :     IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/)
     276             :     {
     277           0 :         maClickHdl.Call( this );
     278           0 :         return true;
     279             :     }
     280             : 
     281             :     // -----------------------------------------------------------------------
     282           0 :     OMySQLIntroPageSetup::~OMySQLIntroPageSetup()
     283             :     {
     284             : 
     285             :         DBG_DTOR(OMySQLIntroPageSetup,NULL);
     286           0 :     }
     287             : 
     288             : 
     289             :     // -----------------------------------------------------------------------
     290           0 :     void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/)
     291             :     {
     292             :         // show the "Connect directly" option only if the driver is installed
     293           0 :         DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
     294           0 :         bool bHasMySQLNative = ( pCollectionItem != NULL ) && pCollectionItem->getCollection()->hasDriver( "sdbc:mysqlc:" );
     295           0 :         if ( bHasMySQLNative )
     296           0 :             m_aRB_NATIVEDatabase.Show();
     297             : 
     298             :         // if any of the options is checked, then there's nothing to do
     299           0 :         if ( m_aRB_ODBCDatabase.IsChecked() || m_aRB_JDBCDatabase.IsChecked() || m_aRB_NATIVEDatabase.IsChecked() )
     300           0 :             return;
     301             : 
     302             :         // prefer "native" or "JDBC"
     303           0 :         if ( bHasMySQLNative )
     304           0 :             m_aRB_NATIVEDatabase.Check();
     305             :         else
     306           0 :             m_aRB_JDBCDatabase.Check();
     307             :     }
     308             : 
     309             : 
     310             :     // -----------------------------------------------------------------------
     311           0 :     void OMySQLIntroPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
     312             :     {
     313           0 :     }
     314             : 
     315             :     // -----------------------------------------------------------------------
     316           0 :     void OMySQLIntroPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
     317             :     {
     318           0 :     }
     319             : 
     320             : 
     321             :     // -----------------------------------------------------------------------
     322           0 :     sal_Bool OMySQLIntroPageSetup::FillItemSet(SfxItemSet& /*_rSet*/)
     323             :     {
     324             :         OSL_FAIL("Who called me?! Please ask oj for more information.");
     325           0 :         return sal_True;
     326             :     }
     327             : 
     328             : 
     329           0 :     OMySQLIntroPageSetup::ConnectionType OMySQLIntroPageSetup::getMySQLMode()
     330             :     {
     331           0 :         if (m_aRB_JDBCDatabase.IsChecked())
     332           0 :             return VIA_JDBC;
     333           0 :         else if (m_aRB_NATIVEDatabase.IsChecked())
     334           0 :             return VIA_NATIVE;
     335             :         else
     336           0 :             return VIA_ODBC;
     337             :     }
     338             : 
     339             :     // =======================================================================
     340             :     // = MySQLNativeSetupPage
     341             :     // =======================================================================
     342             :     // -----------------------------------------------------------------------
     343           0 :     MySQLNativeSetupPage::MySQLNativeSetupPage( Window* _pParent, const SfxItemSet& _rCoreAttrs )
     344             :         :OGenericAdministrationPage( _pParent, ModuleRes( PAGE_DBWIZARD_MYSQL_NATIVE ), _rCoreAttrs )
     345             :         ,m_aHeader              ( this, ModuleRes( FT_SETUP_WIZARD_HEADER ) )
     346             :         ,m_aHelpText            ( this, ModuleRes( FT_SETUP_WIZARD_HELP ) )
     347           0 :         ,m_aMySQLSettings       ( *this, getControlModifiedLink() )
     348             :     {
     349           0 :         SetControlFontWeight( &m_aHeader );
     350             : 
     351           0 :         LayoutHelper::positionBelow( m_aHelpText, m_aMySQLSettings, UnrelatedControls, 0 );
     352           0 :         m_aMySQLSettings.Show();
     353             : 
     354           0 :         SetRoadmapStateValue(sal_False);
     355           0 :         FreeResource();
     356           0 :     }
     357             : 
     358             :     // -----------------------------------------------------------------------
     359           0 :     OGenericAdministrationPage* MySQLNativeSetupPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
     360             :     {
     361           0 :         return new MySQLNativeSetupPage( pParent, _rAttrSet );
     362             :     }
     363             : 
     364             :     // -----------------------------------------------------------------------
     365           0 :     void MySQLNativeSetupPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
     366             :     {
     367           0 :         m_aMySQLSettings.fillControls( _rControlList );
     368           0 :     }
     369             : 
     370             :     // -----------------------------------------------------------------------
     371           0 :     void MySQLNativeSetupPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
     372             :     {
     373           0 :         _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aHelpText ) );
     374           0 :         m_aMySQLSettings.fillWindows( _rControlList );
     375           0 :     }
     376             : 
     377             :     // -----------------------------------------------------------------------
     378           0 :     sal_Bool MySQLNativeSetupPage::FillItemSet( SfxItemSet& _rSet )
     379             :     {
     380           0 :         return m_aMySQLSettings.FillItemSet( _rSet );
     381             :     }
     382             : 
     383             :     // -----------------------------------------------------------------------
     384           0 :     void MySQLNativeSetupPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
     385             :     {
     386           0 :         m_aMySQLSettings.implInitControls( _rSet );
     387             : 
     388           0 :         OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
     389             : 
     390           0 :         OnModified( NULL );
     391           0 :     }
     392             : 
     393             :     // -----------------------------------------------------------------------
     394           0 :     Link MySQLNativeSetupPage::getControlModifiedLink()
     395             :     {
     396           0 :         return LINK( this, MySQLNativeSetupPage, OnModified );
     397             :     }
     398             : 
     399             :     // -----------------------------------------------------------------------
     400           0 :     IMPL_LINK( MySQLNativeSetupPage, OnModified, Edit*, _pEdit )
     401             :     {
     402           0 :         SetRoadmapStateValue( m_aMySQLSettings.canAdvance() );
     403             : 
     404           0 :         return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit );
     405             :     }
     406             : 
     407             :     //========================================================================
     408             :     //= OMySQLJDBCConnectionPageSetup
     409             :     //========================================================================
     410           0 :     OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( Window* pParent,sal_uInt16 _nResId, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, sal_uInt16 _nDefaultPortResId, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderTextResId, sal_uInt16 _nDriverClassId)
     411             :         :OGenericAdministrationPage(pParent, ModuleRes(_nResId), _rCoreAttrs)
     412             :         ,m_aFTHelpText          (this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
     413             :         ,m_aFTDatabasename      (this, ModuleRes(FT_AUTODATABASENAME))
     414             :         ,m_aETDatabasename      (this, ModuleRes(ET_AUTODATABASENAME))
     415             :         ,m_aFTHostname          (this, ModuleRes(FT_AUTOHOSTNAME))
     416             :         ,m_aETHostname          (this, ModuleRes(ET_AUTOHOSTNAME))
     417             :         ,m_aFTPortNumber        (this, ModuleRes(FT_AUTOPORTNUMBER))
     418             :         ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT))
     419             :         ,m_aNFPortNumber        (this, ModuleRes(NF_AUTOPORTNUMBER))
     420             :         ,m_aFTDriverClass       (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS))
     421             :         ,m_aETDriverClass       (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS))
     422             :         ,m_aPBTestJavaDriver    (this, ModuleRes(PB_AUTOTESTDRIVERCLASS))
     423           0 :         ,m_nPortId(_nPortId)
     424             :     {
     425           0 :         m_aFTDriverClass.SetText(String(ModuleRes(_nDriverClassId)));
     426             : 
     427           0 :         m_aFTDefaultPortNumber.SetText(String(ModuleRes(_nDefaultPortResId)));
     428           0 :         String sHelpText = String(ModuleRes(_nHelpTextResId));
     429           0 :         m_aFTHelpText.SetText(sHelpText);
     430             :         //TODO this code snippet is redundant
     431           0 :         SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderTextResId);
     432             : 
     433           0 :         m_aETDatabasename.SetModifyHdl(getControlModifiedLink());
     434           0 :         m_aETHostname.SetModifyHdl(getControlModifiedLink());
     435           0 :         m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
     436             : 
     437           0 :         m_aETDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified));
     438           0 :         m_aPBTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup,OnTestJavaClickHdl));
     439             : 
     440           0 :         SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
     441           0 :         SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
     442           0 :         ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
     443           0 :         if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() )
     444             :         {
     445           0 :             m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
     446             :         }
     447             : 
     448           0 :         SetRoadmapStateValue(sal_False);
     449           0 :         FreeResource();
     450           0 :     }
     451             : 
     452             : 
     453             :     // -----------------------------------------------------------------------
     454           0 :     OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
     455             :     {
     456             :         return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
     457             :                                                          PAGE_DBWIZARD_MYSQL_JDBC,
     458             :                                                          _rAttrSet,
     459             :                                                          DSID_MYSQL_PORTNUMBER ,
     460             :                                                          STR_MYSQL_DEFAULT,
     461             :                                                          STR_MYSQLJDBC_HELPTEXT,
     462             :                                                          STR_MYSQLJDBC_HEADERTEXT,
     463           0 :                                                          STR_MYSQL_DRIVERCLASSTEXT) );
     464             :     }
     465             : 
     466             :     // -----------------------------------------------------------------------
     467           0 :     OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
     468             :     {
     469             :         return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
     470             :                                                           PAGE_DBWIZARD_ORACLE,
     471             :                                                           _rAttrSet,
     472             :                                                           DSID_ORACLE_PORTNUMBER,
     473             :                                                           STR_ORACLE_DEFAULT,
     474             :                                                           STR_ORACLE_HELPTEXT,
     475             :                                                           STR_ORACLE_HEADERTEXT,
     476           0 :                                                           STR_ORACLE_DRIVERCLASSTEXT) );
     477             :     }
     478             : 
     479             :     // -----------------------------------------------------------------------
     480           0 :     void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     481             :     {
     482           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDatabasename));
     483           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass));
     484           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostname));
     485           0 :         _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
     486           0 :     }
     487             :     // -----------------------------------------------------------------------
     488           0 :     void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     489             :     {
     490           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
     491           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDatabasename));
     492           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
     493           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber));
     494           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber));
     495           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
     496           0 :     }
     497             : 
     498             :     // -----------------------------------------------------------------------
     499           0 :     sal_Bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
     500             :     {
     501           0 :         sal_Bool bChangedSomething = sal_False;
     502           0 :         fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
     503           0 :         fillString(_rSet,&m_aETHostname,DSID_CONN_HOSTNAME,bChangedSomething);
     504           0 :         fillString(_rSet,&m_aETDatabasename,DSID_DATABASENAME,bChangedSomething);
     505           0 :         fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething );
     506           0 :         return bChangedSomething;
     507             :     }
     508             : 
     509             :     // -----------------------------------------------------------------------
     510           0 :     void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     511             :     {
     512             :         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     513             :         sal_Bool bValid, bReadonly;
     514           0 :         getFlags(_rSet, bValid, bReadonly);
     515             : 
     516           0 :         SFX_ITEMSET_GET(_rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True);
     517           0 :         SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
     518           0 :         SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
     519           0 :         SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True);
     520             : 
     521           0 :         if ( bValid )
     522             :         {
     523           0 :             m_aETDatabasename.SetText(pDatabaseName->GetValue());
     524           0 :             m_aETDatabasename.ClearModifyFlag();
     525             : 
     526           0 :             m_aETDriverClass.SetText(pDrvItem->GetValue());
     527           0 :             m_aETDriverClass.ClearModifyFlag();
     528             : 
     529           0 :             m_aETHostname.SetText(pHostName->GetValue());
     530           0 :             m_aETHostname.ClearModifyFlag();
     531             : 
     532           0 :             m_aNFPortNumber.SetValue(pPortNumber->GetValue());
     533           0 :             m_aNFPortNumber.ClearModifyFlag();
     534             :         }
     535           0 :         OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
     536             : 
     537             :         // to get the correct value when saveValue was called by base class
     538           0 :         if ( !m_aETDriverClass.GetText().Len() )
     539             :         {
     540           0 :             m_aETDriverClass.SetText(m_sDefaultJdbcDriverName);
     541           0 :             m_aETDriverClass.SetModifyFlag();
     542             :         }
     543           0 :         callModifiedHdl();
     544             : 
     545           0 :         sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 ));
     546           0 :         SetRoadmapStateValue(bRoadmapState);
     547           0 :     }
     548             : 
     549             :     // -----------------------------------------------------------------------
     550           0 :     IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
     551             :     {
     552             :         OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
     553             : 
     554           0 :         sal_Bool bSuccess = sal_False;
     555             :         try
     556             :         {
     557           0 :             if ( m_aETDriverClass.GetText().Len() )
     558             :             {
     559             : // TODO chage jvmaccess
     560           0 :                 ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
     561           0 :                 bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText());
     562             :             }
     563             :         }
     564           0 :         catch(::com::sun::star::uno::Exception&)
     565             :         {
     566             :         }
     567             : 
     568           0 :         const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
     569           0 :         const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
     570           0 :         OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String(), WB_OK | WB_DEF_OK, mt );
     571           0 :         aMsg.Execute();
     572           0 :         return 0L;
     573             :     }
     574             : 
     575             :     // -----------------------------------------------------------------------
     576           0 :     IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
     577             :     {
     578           0 :         if ( _pEdit == &m_aETDriverClass )
     579           0 :             m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 );
     580           0 :         sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 ));
     581           0 :         SetRoadmapStateValue(bRoadmapState);
     582           0 :         callModifiedHdl();
     583           0 :         return 0L;
     584             :     }
     585             : 
     586             :     // -----------------------------------------------------------------------
     587           0 :     OGenericAdministrationPage* OJDBCConnectionPageSetup::CreateJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
     588             :     {
     589           0 :         return ( new OJDBCConnectionPageSetup( pParent, _rAttrSet));
     590             :     }
     591             : 
     592             : 
     593             :     //========================================================================
     594             :     //= OMySQLJDBCConnectionPageSetup
     595             :     //========================================================================
     596           0 :     OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs)
     597             :         :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_JDBC, _rCoreAttrs, STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL)
     598             :         ,m_aFTDriverClass       (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS))
     599             :         ,m_aETDriverClass       (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS))
     600           0 :         ,m_aPBTestJavaDriver    (this, ModuleRes(PB_AUTOTESTDRIVERCLASS))
     601             :     {
     602           0 :         m_aETDriverClass.SetModifyHdl(LINK(this, OJDBCConnectionPageSetup, OnEditModified));
     603           0 :         m_aPBTestJavaDriver.SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl));
     604           0 :         FreeResource();
     605           0 :     }
     606             : 
     607             :     // -----------------------------------------------------------------------
     608           0 :     void OJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     609             :     {
     610           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass));
     611           0 :     }
     612             : 
     613             :     // -----------------------------------------------------------------------
     614           0 :     void OJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     615             :     {
     616           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
     617           0 :     }
     618             : 
     619             :     // -----------------------------------------------------------------------
     620           0 :     sal_Bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
     621             :     {
     622           0 :         sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
     623           0 :         fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
     624           0 :         return bChangedSomething;
     625             :     }
     626             : 
     627             :     // -----------------------------------------------------------------------
     628           0 :     void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     629             :     {
     630             :         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     631             :         sal_Bool bValid, bReadonly;
     632           0 :         getFlags(_rSet, bValid, bReadonly);
     633             : 
     634           0 :         SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
     635             : 
     636           0 :         if ( bValid )
     637             :         {
     638           0 :             if ( !pDrvItem->GetValue().Len() )
     639             :             {
     640           0 :                 String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType);
     641           0 :                 if ( sDefaultJdbcDriverName.Len() )
     642             :                 {
     643           0 :                     m_aETDriverClass.SetText(sDefaultJdbcDriverName);
     644           0 :                     m_aETDriverClass.SetModifyFlag();
     645           0 :                 }
     646             :             }
     647             :             else
     648             :             {
     649           0 :                 m_aETDriverClass.SetText(pDrvItem->GetValue());
     650           0 :                 m_aETDriverClass.ClearModifyFlag();
     651             :             }
     652             :         }
     653           0 :         sal_Bool bEnable = pDrvItem->GetValue().Len() != 0;
     654           0 :         m_aPBTestJavaDriver.Enable(bEnable);
     655           0 :         OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
     656             : 
     657           0 :         SetRoadmapStateValue(checkTestConnection());
     658           0 :     }
     659             : 
     660             : 
     661           0 :     bool OJDBCConnectionPageSetup::checkTestConnection()
     662             :     {
     663             :         OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
     664           0 :         sal_Bool bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
     665           0 :         bEnableTestConnection = bEnableTestConnection && (m_aETDriverClass.GetText().Len() != 0);
     666           0 :         return bEnableTestConnection;
     667             :     }
     668             : 
     669             : 
     670             :     // -----------------------------------------------------------------------
     671           0 :     IMPL_LINK(OJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
     672             :     {
     673             :         OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
     674           0 :         sal_Bool bSuccess = sal_False;
     675             :         try
     676             :         {
     677           0 :             if ( m_aETDriverClass.GetText().Len() )
     678             :             {
     679             : // TODO chage jvmaccess
     680           0 :                 ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
     681           0 :                 bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText());
     682             :             }
     683             :         }
     684           0 :         catch(::com::sun::star::uno::Exception&)
     685             :         {
     686             :         }
     687             : 
     688           0 :         sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
     689           0 :         OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
     690           0 :         aMsg.Execute();
     691           0 :         return 0L;
     692             :     }
     693             : 
     694             :     // -----------------------------------------------------------------------
     695           0 :     IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
     696             :     {
     697           0 :         if ( _pEdit == &m_aETDriverClass )
     698           0 :             m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 );
     699           0 :         SetRoadmapStateValue(checkTestConnection());
     700             :         // tell the listener we were modified
     701           0 :         callModifiedHdl();
     702           0 :         return 0L;
     703             :     }
     704             : 
     705             : 
     706           0 :     OGenericAdministrationPage* OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
     707             :     {
     708           0 :         return ( new OSpreadSheetConnectionPageSetup( pParent, _rAttrSet ) );
     709             :     }
     710             : 
     711             : DBG_NAME(OSpreadSheetConnectionPageSetup)
     712             : 
     713           0 :     OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
     714             :         :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_SPREADSHEET, _rCoreAttrs, STR_SPREADSHEET_HELPTEXT, STR_SPREADSHEET_HEADERTEXT, STR_SPREADSHEETPATH)
     715           0 :             , m_aCBPasswordrequired(this, ModuleRes(CB_SPREADSHEETPASSWORDREQUIRED))
     716             :     {
     717             :         DBG_CTOR(OSpreadSheetConnectionPageSetup,NULL);
     718             : 
     719           0 :            m_aCBPasswordrequired.SetToggleHdl(getControlModifiedLink());
     720           0 :         FreeResource();
     721           0 :     }
     722             : 
     723             : 
     724             :     // -----------------------------------------------------------------------
     725           0 :     OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup()
     726             :     {
     727             : 
     728             :         DBG_DTOR(OSpreadSheetConnectionPageSetup,NULL);
     729           0 :     }
     730             : 
     731             : 
     732           0 :     void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
     733             :     {
     734           0 :     }
     735             : 
     736             :     // -----------------------------------------------------------------------
     737           0 :     void OSpreadSheetConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     738             :     {
     739           0 :         OConnectionTabPageSetup::fillControls(_rControlList);
     740           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordrequired));
     741             : 
     742           0 :     }
     743             : 
     744             :     // -----------------------------------------------------------------------
     745           0 :     void OSpreadSheetConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     746             :     {
     747           0 :         OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
     748           0 :     }
     749             : 
     750             :     // -----------------------------------------------------------------------
     751           0 :     sal_Bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
     752             :     {
     753           0 :         sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
     754           0 :         fillBool(_rSet,&m_aCBPasswordrequired,DSID_PASSWORDREQUIRED,bChangedSomething);
     755           0 :         return bChangedSomething;
     756             :     }
     757             : 
     758           0 :     OGenericAdministrationPage* OAuthentificationPageSetup::CreateAuthentificationTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
     759             :     {
     760           0 :         return ( new OAuthentificationPageSetup( pParent, _rAttrSet) );
     761             :     }
     762             : 
     763             : DBG_NAME(OAuthentificationPageSetup)
     764             : 
     765           0 :     OAuthentificationPageSetup::OAuthentificationPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
     766             :         :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_AUTHENTIFICATION), _rCoreAttrs )
     767             :         , m_aFTHelpText             (this, ModuleRes(FT_AUTHENTIFICATIONHELPTEXT))
     768             :         , m_aFTHeaderText           (this, ModuleRes(FT_AUTHENTIFICATIONHEADERTEXT))
     769             :         , m_aFTUserName             (this, ModuleRes(FT_GENERALUSERNAME))
     770             :         , m_aETUserName             (this, ModuleRes(ET_GENERALUSERNAME))
     771             :         , m_aCBPasswordRequired     (this, ModuleRes(CB_GENERALPASSWORDREQUIRED))
     772           0 :         , m_aPBTestConnection       (this, ModuleRes(PB_TESTCONNECTION))
     773             :     {
     774             :         DBG_CTOR(OAuthentificationPageSetup,NULL);
     775             : 
     776           0 :         SetControlFontWeight(&m_aFTHeaderText);
     777           0 :         m_aETUserName.SetModifyHdl(getControlModifiedLink());
     778           0 :         m_aCBPasswordRequired.SetClickHdl(getControlModifiedLink());
     779           0 :            m_aPBTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl));
     780           0 :         FreeResource();
     781             : 
     782           0 :         LayoutHelper::fitSizeRightAligned( m_aPBTestConnection );
     783           0 :     }
     784             : 
     785             : 
     786             :     // -----------------------------------------------------------------------
     787           0 :     OAuthentificationPageSetup::~OAuthentificationPageSetup()
     788             :     {
     789             : 
     790             :         DBG_DTOR(OAuthentificationPageSetup,NULL);
     791           0 :     }
     792             : 
     793             : 
     794           0 :     void OAuthentificationPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     795             :     {
     796           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
     797           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTUserName));
     798           0 :         _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPBTestConnection));
     799           0 :     }
     800             : 
     801             :     // -----------------------------------------------------------------------
     802           0 :     void OAuthentificationPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     803             :     {
     804           0 :         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETUserName));
     805           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordRequired));
     806           0 :     }
     807             : 
     808             :     // -----------------------------------------------------------------------
     809           0 :     void OAuthentificationPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/)
     810             :     {
     811             :         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
     812             :         sal_Bool bValid, bReadonly;
     813           0 :         getFlags(_rSet, bValid, bReadonly);
     814           0 :         SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
     815           0 :         SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
     816             : 
     817           0 :         m_aETUserName.SetText(pUidItem->GetValue());
     818           0 :         m_aCBPasswordRequired.Check(pAllowEmptyPwd->GetValue());
     819             : 
     820           0 :         m_aETUserName.ClearModifyFlag();
     821           0 :     }
     822             : 
     823             :     // -----------------------------------------------------------------------
     824           0 :     sal_Bool OAuthentificationPageSetup::FillItemSet( SfxItemSet& _rSet )
     825             :     {
     826           0 :         sal_Bool bChangedSomething = sal_False;
     827             : 
     828           0 :         if (m_aETUserName.GetText() != m_aETUserName.GetSavedValue())
     829             :         {
     830           0 :             _rSet.Put(SfxStringItem(DSID_USER, m_aETUserName.GetText()));
     831           0 :             _rSet.Put(SfxStringItem(DSID_PASSWORD, String()));
     832           0 :             bChangedSomething = sal_True;
     833             :         }
     834           0 :         fillBool(_rSet,&m_aCBPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
     835           0 :         return bChangedSomething;
     836             :     }
     837             : 
     838             : 
     839           0 :     OGenericAdministrationPage* OFinalDBPageSetup::CreateFinalDBTabPageSetup( Window* pParent, const SfxItemSet& _rAttrSet)
     840             :     {
     841           0 :         return ( new OFinalDBPageSetup( pParent, _rAttrSet) );
     842             :     }
     843             : 
     844             : DBG_NAME(OFinalDBPageSetup)
     845             : 
     846           0 :     OFinalDBPageSetup::OFinalDBPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
     847             :     :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_FINAL), _rCoreAttrs )
     848             :     , m_aFTFinalHeader              (this, ModuleRes(FT_FINALHEADER))
     849             :     , m_aFTFinalHelpText            (this, ModuleRes(FT_FINALHELPTEXT))
     850             :     , m_aRBRegisterDataSource       (this, ModuleRes(RB_REGISTERDATASOURCE))
     851             :     , m_aRBDontregisterDataSource   (this, ModuleRes(RB_DONTREGISTERDATASOURCE))
     852             :     , m_aFTAdditionalSettings       (this, ModuleRes(FT_ADDITIONALSETTINGS))
     853             :     , m_aCBOpenAfterwards           (this, ModuleRes(CB_OPENAFTERWARDS))
     854             :     , m_aCBStartTableWizard         (this, ModuleRes(CB_STARTTABLEWIZARD))
     855           0 :     , m_aFTFinalText                (this, ModuleRes(FT_FINALTEXT))
     856             :     {
     857             :         DBG_CTOR(OFinalDBPageSetup,NULL);
     858             : 
     859           0 :         String stext = m_aFTFinalHeader.GetText();
     860           0 :         SetControlFontWeight(&m_aFTFinalHeader);
     861           0 :         m_aCBOpenAfterwards.SetClickHdl(LINK(this, OFinalDBPageSetup, OnOpenSelected));
     862           0 :         m_aCBStartTableWizard.SetClickHdl(getControlModifiedLink());
     863           0 :         m_aRBRegisterDataSource.SetState(sal_True);
     864           0 :         FreeResource();
     865             : 
     866           0 :         sal_Int32 nUnrelatedHeight  = LogicToPixel( Size( 0, UNRELATED_CONTROLS ), MAP_APPFONT ).Height();
     867           0 :         sal_Int32 nRelatedHeight    = LogicToPixel( Size( 0, RELATED_CONTROLS ), MAP_APPFONT ).Height();
     868             : 
     869             :         ::std::pair<Window*,sal_Int32> pWindows[] = {
     870             :             ::std::pair<Window*,sal_Int32>(&m_aFTFinalHelpText,nRelatedHeight)
     871             :             ,::std::pair<Window*,sal_Int32>(&m_aRBRegisterDataSource,nRelatedHeight)
     872             :             ,::std::pair<Window*,sal_Int32>(&m_aRBDontregisterDataSource,nUnrelatedHeight)
     873             :             ,::std::pair<Window*,sal_Int32>(&m_aFTAdditionalSettings,nRelatedHeight)
     874             :             ,::std::pair<Window*,sal_Int32>(&m_aCBOpenAfterwards,nRelatedHeight)
     875             :             ,::std::pair<Window*,sal_Int32>(&m_aCBStartTableWizard,nUnrelatedHeight)
     876             :             ,::std::pair<Window*,sal_Int32>(&m_aFTFinalText,nUnrelatedHeight)
     877           0 :         };
     878             : 
     879           0 :         Point aPos(m_aFTFinalHeader.GetPosPixel());
     880           0 :         Size aStart(m_aFTFinalHeader.GetSizePixel());
     881           0 :         aPos.Y() += aStart.Height() + nUnrelatedHeight;
     882           0 :         sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
     883           0 :         for (sal_Int32 i=0; i < nCount; ++i)
     884             :         {
     885           0 :             aPos.X() = pWindows[i].first->GetPosPixel().X();
     886           0 :             Size aSize = pWindows[i].first->GetSizePixel();
     887           0 :             FixedText* pText = dynamic_cast<FixedText*>(pWindows[i].first);
     888           0 :             if ( pText )
     889           0 :                 aSize = pText->CalcMinimumSize(aSize.Width());
     890           0 :             pWindows[i].first->SetPosSizePixel(aPos,aSize);
     891           0 :             aPos.Y() += aSize.Height() + pWindows[i].second;
     892           0 :         }
     893           0 :     }
     894             : 
     895             : 
     896             :     // -----------------------------------------------------------------------
     897           0 :     OFinalDBPageSetup::~OFinalDBPageSetup()
     898             :     {
     899             : 
     900             :         DBG_DTOR(OFinalDBPageSetup,NULL);
     901           0 :     }
     902             : 
     903           0 :     sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered()
     904             :     {
     905           0 :         return m_aRBRegisterDataSource.IsChecked() && m_aRBRegisterDataSource.IsEnabled();
     906             :     }
     907             : 
     908           0 :     sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened()
     909             :     {
     910           0 :         return m_aCBOpenAfterwards.IsChecked() && m_aCBOpenAfterwards.IsEnabled();
     911             :     }
     912             : 
     913           0 :     sal_Bool OFinalDBPageSetup::IsTableWizardToBeStarted()
     914             :     {
     915           0 :         return m_aCBStartTableWizard.IsChecked() && m_aCBStartTableWizard.IsEnabled();
     916             :     }
     917             : 
     918             : 
     919           0 :     void OFinalDBPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     920             :     {
     921           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHeader));
     922           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHelpText));
     923           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTAdditionalSettings));
     924           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalText));
     925           0 :     }
     926             : 
     927             :     // -----------------------------------------------------------------------
     928           0 :     void OFinalDBPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     929             :     {
     930           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBOpenAfterwards));
     931           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBStartTableWizard));
     932           0 :         _rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBRegisterDataSource));
     933           0 :         _rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBDontregisterDataSource));
     934           0 :     }
     935             : 
     936             :     // -----------------------------------------------------------------------
     937           0 :     void OFinalDBPageSetup::implInitControls(const SfxItemSet& /*_rSet*/, sal_Bool /*_bSaveValue*/)
     938             :     {
     939           0 :         m_aCBOpenAfterwards.Check();
     940           0 :     }
     941             : 
     942           0 :     void OFinalDBPageSetup::enableTableWizardCheckBox( sal_Bool _bSupportsTableCreation)
     943             :     {
     944           0 :         m_aCBStartTableWizard.Enable(_bSupportsTableCreation);
     945           0 :     }
     946             : 
     947             :     // -----------------------------------------------------------------------
     948           0 :     sal_Bool OFinalDBPageSetup::FillItemSet( SfxItemSet& /*_rSet*/ )
     949             :     {
     950           0 :         return sal_True;
     951             :     }
     952             :     // -----------------------------------------------------------------------------
     953           0 :     IMPL_LINK(OFinalDBPageSetup, OnOpenSelected, CheckBox*, _pBox)
     954             :     {
     955           0 :         m_aCBStartTableWizard.Enable( _pBox->IsEnabled() && _pBox->IsChecked() );
     956           0 :         callModifiedHdl();
     957             :         // outta here
     958           0 :         return 0L;
     959             :     }
     960             : //.........................................................................
     961           0 : }
     962             : // namespace dbaui
     963             : //.........................................................................
     964             : 
     965             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10