LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - UserAdminDlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 71 1.4 %
Date: 2015-06-13 12:38:46 Functions: 2 18 11.1 %
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 "adminpages.hxx"
      21             : #include "DbAdminImpl.hxx"
      22             : #include "dbu_dlg.hrc"
      23             : #include "DriverSettings.hxx"
      24             : #include "dsitems.hxx"
      25             : #include "propertysetitem.hxx"
      26             : #include "UITools.hxx"
      27             : #include "UserAdmin.hxx"
      28             : #include "UserAdminDlg.hxx"
      29             : 
      30             : #include <comphelper/processfactory.hxx>
      31             : #include <connectivity/dbmetadata.hxx>
      32             : #include <cppuhelper/exc_hlp.hxx>
      33             : #include <svl/eitem.hxx>
      34             : #include <svl/intitem.hxx>
      35             : #include <svl/stritem.hxx>
      36             : #include <tools/diagnose_ex.h>
      37             : #include <vcl/msgbox.hxx>
      38             : #include <vcl/stdtext.hxx>
      39             : 
      40             : namespace dbaui
      41             : {
      42             :     using namespace ::com::sun::star::uno;
      43             :     using namespace ::com::sun::star::beans;
      44             :     using namespace ::com::sun::star::lang;
      45             :     using namespace ::com::sun::star::sdbc;
      46             :     using namespace ::com::sun::star::sdbcx;
      47             : 
      48             :     // OUserAdminDlg
      49           0 :     OUserAdminDlg::OUserAdminDlg(vcl::Window* _pParent
      50             :                                             , SfxItemSet* _pItems
      51             :                                             ,const Reference< XComponentContext >& _rxORB
      52             :                                             ,const ::com::sun::star::uno::Any& _aDataSourceName
      53             :                                             ,const Reference< XConnection >& _xConnection)
      54             :         : SfxTabDialog(_pParent, "UserAdminDialog", "dbaccess/ui/useradmindialog.ui", _pItems)
      55             :         , m_pItemSet(_pItems)
      56             :         , m_xConnection(_xConnection)
      57           0 :         , m_bOwnConnection(!_xConnection.is())
      58             :     {
      59           0 :         m_pImpl.reset(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this));
      60           0 :         m_pImpl->setDataSourceOrName(_aDataSourceName);
      61           0 :         Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
      62           0 :         m_pImpl->translateProperties(xDatasource, *_pItems);
      63           0 :         SetInputSet(_pItems);
      64             :         // propagate this set as our new input set and reset the example set
      65           0 :         delete pExampleSet;
      66           0 :         pExampleSet = new SfxItemSet(*GetInputSetImpl());
      67             : 
      68           0 :         AddTabPage("settings", OUserAdmin::Create, 0);
      69             : 
      70             :         // remove the reset button - it's meaning is much too ambiguous in this dialog
      71           0 :         RemoveResetButton();
      72           0 :     }
      73             : 
      74           0 :     OUserAdminDlg::~OUserAdminDlg()
      75             :     {
      76           0 :         disposeOnce();
      77           0 :     }
      78             : 
      79           0 :     void OUserAdminDlg::dispose()
      80             :     {
      81           0 :         if ( m_bOwnConnection )
      82             :         {
      83             :             try
      84             :             {
      85           0 :                 ::comphelper::disposeComponent(m_xConnection);
      86             :             }
      87           0 :             catch(const Exception&)
      88             :             {
      89             :             }
      90             :         }
      91             : 
      92           0 :         SetInputSet(NULL);
      93           0 :         DELETEZ(pExampleSet);
      94           0 :         SfxTabDialog::dispose();
      95           0 :     }
      96             : 
      97           0 :     short OUserAdminDlg::Execute()
      98             :     {
      99             :         try
     100             :         {
     101           0 :             ::dbtools::DatabaseMetaData aMetaData( createConnection().first );
     102           0 :             if ( !aMetaData.supportsUserAdministration( getORB() ) )
     103             :             {
     104           0 :                 OUString sError(ModuleRes(STR_USERADMIN_NOT_AVAILABLE));
     105           0 :                 throw SQLException(sError,NULL,OUString("S1000") ,0,Any());
     106           0 :             }
     107             :         }
     108           0 :         catch(const SQLException&)
     109             :         {
     110           0 :             ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), GetParent(), getORB() );
     111           0 :             return RET_CANCEL;
     112             :         }
     113           0 :         catch(const Exception&)
     114             :         {
     115             :             DBG_UNHANDLED_EXCEPTION();
     116             :         }
     117           0 :         short nRet = SfxTabDialog::Execute();
     118           0 :         if ( nRet == RET_OK )
     119           0 :             m_pImpl->saveChanges(*GetOutputItemSet());
     120           0 :         return nRet;
     121             :     }
     122           0 :     void OUserAdminDlg::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
     123             :     {
     124             :         // register ourself as modified listener
     125           0 :         static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory( m_pImpl->getORB() );
     126           0 :         static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
     127             : 
     128           0 :         vcl::Window *pWin = GetViewWindow();
     129           0 :         if(pWin)
     130           0 :             pWin->Invalidate();
     131             : 
     132           0 :         SfxTabDialog::PageCreated(_nId, _rPage);
     133           0 :     }
     134           0 :     const SfxItemSet* OUserAdminDlg::getOutputSet() const
     135             :     {
     136           0 :         return m_pItemSet;
     137             :     }
     138           0 :     SfxItemSet* OUserAdminDlg::getWriteOutputSet()
     139             :     {
     140           0 :         return m_pItemSet;
     141             :     }
     142           0 :     ::std::pair< Reference<XConnection>,sal_Bool> OUserAdminDlg::createConnection()
     143             :     {
     144           0 :         if ( !m_xConnection.is() )
     145             :         {
     146           0 :             m_xConnection = m_pImpl->createConnection().first;
     147           0 :             m_bOwnConnection = m_xConnection.is();
     148             :         }
     149           0 :         return ::std::pair< Reference<XConnection>,sal_Bool> (m_xConnection,sal_False);
     150             :     }
     151           0 :     Reference< XComponentContext > OUserAdminDlg::getORB() const
     152             :     {
     153           0 :         return m_pImpl->getORB();
     154             :     }
     155           0 :     Reference< XDriver > OUserAdminDlg::getDriver()
     156             :     {
     157           0 :         return m_pImpl->getDriver();
     158             :     }
     159           0 :     OUString OUserAdminDlg::getDatasourceType(const SfxItemSet& _rSet) const
     160             :     {
     161           0 :         return dbaui::ODbDataSourceAdministrationHelper::getDatasourceType(_rSet);
     162             :     }
     163           0 :     void OUserAdminDlg::clearPassword()
     164             :     {
     165           0 :         m_pImpl->clearPassword();
     166           0 :     }
     167           0 :     void OUserAdminDlg::setTitle(const OUString& _sTitle)
     168             :     {
     169           0 :         SetText(_sTitle);
     170           0 :     }
     171           0 :     void OUserAdminDlg::enableConfirmSettings( bool _bEnable )
     172             :     {
     173             :         (void)_bEnable;
     174           0 :     }
     175           0 :     bool OUserAdminDlg::saveDatasource()
     176             :     {
     177           0 :         return PrepareLeaveCurrentPage();
     178             :     }
     179          36 : }   // namespace dbaui
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11