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

Generated by: LCOV version 1.10