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

Generated by: LCOV version 1.10