LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - ConnectionPageSetup.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 67 0.0 %
Date: 2014-04-14 Functions: 0 16 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 "ConnectionPageSetup.hxx"
      21             : #include "AutoControls.hrc"
      22             : #include "dbadminsetup.hrc"
      23             : #include "dbu_dlg.hrc"
      24             : #include <svl/itemset.hxx>
      25             : #include <unotools/pathoptions.hxx>
      26             : #include <svl/stritem.hxx>
      27             : #include <svl/eitem.hxx>
      28             : #include <svl/intitem.hxx>
      29             : #include "dsitems.hxx"
      30             : #include "dbaccess_helpid.hrc"
      31             : #include "localresaccess.hxx"
      32             : #include <osl/process.h>
      33             : #include <vcl/msgbox.hxx>
      34             : #include "dbadmin.hxx"
      35             : #include "dbadmin.hrc"
      36             : #include <comphelper/types.hxx>
      37             : #include <vcl/stdtext.hxx>
      38             : #include "sqlmessage.hxx"
      39             : #include "odbcconfig.hxx"
      40             : #include "dsselect.hxx"
      41             : #include <svl/filenotation.hxx>
      42             : #include "dbustrings.hrc"
      43             : #include <com/sun/star/sdbc/XRow.hpp>
      44             : #include <com/sun/star/awt/XWindow.hpp>
      45             : #include <com/sun/star/task/XInteractionHandler.hpp>
      46             : #include <com/sun/star/ucb/XProgressHandler.hpp>
      47             : #include <com/sun/star/sdbc/XConnection.hpp>
      48             : #include "UITools.hxx"
      49             : #include <unotools/localfilehelper.hxx>
      50             : #include <unotools/ucbhelper.hxx>
      51             : #include <ucbhelper/commandenvironment.hxx>
      52             : #include "finteraction.hxx"
      53             : #include <connectivity/CommonTools.hxx>
      54             : #include <sfx2/docfilt.hxx>
      55             : #include <vcl/mnemonic.hxx>
      56             : 
      57             : namespace dbaui
      58             : {
      59             :     using namespace ::com::sun::star::uno;
      60             :     using namespace ::com::sun::star::ucb;
      61             :     using namespace ::com::sun::star::ui::dialogs;
      62             :     using namespace ::com::sun::star::sdbc;
      63             :     using namespace ::com::sun::star::beans;
      64             :     using namespace ::com::sun::star::lang;
      65             :     using namespace ::com::sun::star::container;
      66             :     using namespace ::dbtools;
      67             :     using namespace ::svt;
      68             : 
      69           0 :     OGenericAdministrationPage* OConnectionTabPageSetup::CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
      70             :     {
      71           0 :         OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_DBASE,    _rAttrSet, STR_DBASE_HELPTEXT,    STR_DBASE_HEADERTEXT,    STR_DBASE_PATH_OR_FILE);
      72           0 :         oDBWizardPage->FreeResource();
      73           0 :         return oDBWizardPage;
      74             :     }
      75             : 
      76           0 :     OGenericAdministrationPage* OConnectionTabPageSetup::CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
      77             :     {
      78           0 :         OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_MSACCESS, _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE);
      79           0 :         oDBWizardPage->FreeResource();
      80           0 :         return oDBWizardPage;
      81             :     }
      82             : 
      83           0 :     OGenericAdministrationPage* OConnectionTabPageSetup::CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
      84             :     {
      85           0 :         OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADO, _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL);
      86           0 :         oDBWizardPage->FreeResource();
      87           0 :         return oDBWizardPage;
      88             :     }
      89             : 
      90           0 :     OGenericAdministrationPage* OConnectionTabPageSetup::CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
      91             :     {
      92           0 :         OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ODBC, _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE);
      93           0 :         oDBWizardPage->FreeResource();
      94           0 :         return oDBWizardPage;
      95             :     }
      96             : 
      97           0 :     OGenericAdministrationPage* OConnectionTabPageSetup::CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
      98             :     {
      99           0 :         OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_USERDEFINED, _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL);
     100           0 :         oDBWizardPage->FreeResource();
     101           0 :         return oDBWizardPage;
     102             :     }
     103             : 
     104             :     // OConnectionTabPageSetup
     105           0 :     OConnectionTabPageSetup::OConnectionTabPageSetup(Window* pParent, sal_uInt16 _rId, const SfxItemSet& _rCoreAttrs, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderResId, sal_uInt16 _nUrlResId)
     106             :         :OConnectionHelper(pParent, ModuleRes(_rId), _rCoreAttrs)
     107             :         ,m_bUserGrabFocus(sal_True)
     108           0 :         ,m_aFT_HelpText(this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
     109             :     {
     110             : 
     111           0 :         if ( USHRT_MAX != _nHelpTextResId )
     112             :         {
     113           0 :             OUString sHelpText = ModuleRes(_nHelpTextResId);
     114           0 :             m_aFT_HelpText.SetText(sHelpText);
     115             :         }
     116             :         else
     117           0 :             m_aFT_HelpText.Hide();
     118             : 
     119           0 :         if ( USHRT_MAX != _nHeaderResId )
     120           0 :             SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderResId);
     121             : 
     122           0 :         if ( USHRT_MAX != _nUrlResId )
     123             :         {
     124           0 :             OUString sLabelText = ModuleRes(_nUrlResId);
     125           0 :             m_aFT_Connection.SetText(sLabelText);
     126           0 :             if ( USHRT_MAX == _nHelpTextResId )
     127             :             {
     128           0 :                 Point aPos = m_aFT_HelpText.GetPosPixel();
     129           0 :                 Point aFTPos = m_aFT_Connection.GetPosPixel();
     130           0 :                 Point aEDPos = m_aConnectionURL.GetPosPixel();
     131           0 :                 Point aPBPos = m_aPB_Connection.GetPosPixel();
     132             : 
     133           0 :                 aEDPos.Y() = aPos.Y() + aEDPos.Y() - aFTPos.Y();
     134           0 :                 aPBPos.Y() = aPos.Y() + aPBPos.Y() - aFTPos.Y();
     135           0 :                 aFTPos.Y() = aPos.Y();
     136           0 :                 m_aFT_Connection.SetPosPixel(aFTPos);
     137           0 :                 m_aConnectionURL.SetPosPixel(aEDPos);
     138           0 :                 m_aPB_Connection.SetPosPixel(aPBPos);
     139           0 :             }
     140             :         }
     141             :         else
     142           0 :             m_aFT_Connection.Hide();
     143             : 
     144           0 :         m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified));
     145             : 
     146           0 :         SetRoadmapStateValue(sal_False);
     147           0 :     }
     148             : 
     149           0 :     OConnectionTabPageSetup::~OConnectionTabPageSetup()
     150             :     {
     151           0 :     }
     152             : 
     153           0 :     void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
     154             :     {
     155           0 :         m_eType = m_pAdminDialog->getDatasourceType(_rSet);
     156             :         // special handling for oracle, this can only happen
     157             :         // if the user enters the same url as used for Oracle and we are on the JDBC path
     158             :         //! TODO
     159             :         //if (  ::dbaccess::DST_ORACLE_JDBC == m_eType )
     160             :         //    m_eType =  ::dbaccess::DST_JDBC;
     161             : 
     162           0 :         OConnectionHelper::implInitControls(_rSet, _bSaveValue);
     163             : 
     164             :         //! TODO
     165             :         //if ( m_eType >=  ::dbaccess::DST_USERDEFINE1 )
     166             :         //{
     167             :         //  OUString sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
     168             :         //  FixedText* ppTextControls[] ={&m_aFT_Connection};
     169             :         //  for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i)
     170             :         //  {
     171             :         //      ppTextControls[i]->SetText(sDisplayName);
     172             :         //  }
     173             :         //}
     174             : 
     175           0 :         callModifiedHdl();
     176           0 :     }
     177             : 
     178           0 :     bool OConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ )
     179             :     {
     180           0 :         return commitURL();
     181             :     }
     182             : 
     183           0 :     bool OConnectionTabPageSetup::FillItemSet(SfxItemSet& _rSet)
     184             :     {
     185           0 :         sal_Bool bChangedSomething = sal_False;
     186           0 :         fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething);
     187           0 :         return bChangedSomething;
     188             :     }
     189           0 :     bool OConnectionTabPageSetup::checkTestConnection()
     190             :     {
     191           0 :         return !m_aConnectionURL.IsVisible() || !m_aConnectionURL.GetTextNoPrefix().isEmpty();
     192             :     }
     193             : 
     194           0 :     IMPL_LINK(OConnectionTabPageSetup, OnEditModified, Edit*, /*_pEdit*/)
     195             :     {
     196           0 :         SetRoadmapStateValue(checkTestConnection());
     197           0 :         callModifiedHdl();
     198           0 :         return 0L;
     199             :     }
     200           0 : }   // namespace dbaui
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10