LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - ConnectionPageSetup.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-08-25 Functions: 0 14 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 80 0.0 %

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

Generated by: LCOV version 1.10