LCOV - code coverage report
Current view: top level - extensions/source/abpilot - admininvokationimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "admininvokationimpl.hxx"
      30                 :            : #include <tools/debug.hxx>
      31                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      32                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      33                 :            : #include <com/sun/star/awt/XWindow.hpp>
      34                 :            : #include <vcl/stdtext.hxx>
      35                 :            : #include <toolkit/unohlp.hxx>
      36                 :            : #include "abpresid.hrc"
      37                 :            : #include "componentmodule.hxx"
      38                 :            : #include <vcl/waitobj.hxx>
      39                 :            : 
      40                 :            : 
      41                 :            : //.........................................................................
      42                 :            : namespace abp
      43                 :            : {
      44                 :            : //.........................................................................
      45                 :            : 
      46                 :            :     using namespace ::com::sun::star::uno;
      47                 :            :     using namespace ::com::sun::star::lang;
      48                 :            :     using namespace ::com::sun::star::beans;
      49                 :            :     using namespace ::com::sun::star::awt;
      50                 :            :     using namespace ::com::sun::star::ui::dialogs;
      51                 :            : 
      52                 :            :     //=====================================================================
      53                 :            :     //= OAdminDialogInvokation
      54                 :            :     //=====================================================================
      55                 :            :     //---------------------------------------------------------------------
      56                 :          0 :     OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XMultiServiceFactory >& _rxORB
      57                 :            :                     , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xDataSource
      58                 :            :                     , Window* _pMessageParent)
      59                 :            :         :m_xORB(_rxORB)
      60                 :            :         ,m_xDataSource(_xDataSource)
      61                 :          0 :         ,m_pMessageParent(_pMessageParent)
      62                 :            :     {
      63                 :            :         DBG_ASSERT(m_xORB.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!");
      64                 :            :         DBG_ASSERT(m_xDataSource.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid preferred name!");
      65                 :            :         DBG_ASSERT(m_pMessageParent, "OAdminDialogInvokation::OAdminDialogInvokation: invalid message parent!");
      66                 :          0 :     }
      67                 :            : 
      68                 :            :     //---------------------------------------------------------------------
      69                 :          0 :     sal_Bool OAdminDialogInvokation::invokeAdministration( sal_Bool _bFixedType )
      70                 :            :     {
      71                 :          0 :         if (!m_xORB.is())
      72                 :          0 :             return sal_False;
      73                 :            : 
      74                 :            :         try
      75                 :            :         {
      76                 :            :             // the service name of the administration dialog
      77                 :          0 :             const static ::rtl::OUString s_sAdministrationServiceName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatasourceAdministrationDialog"));
      78                 :          0 :             const static ::rtl::OUString s_sDataSourceTypeChangeDialog = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog"));
      79                 :            : 
      80                 :            :             // the parameters for the call
      81                 :          0 :             Sequence< Any > aArguments(3);
      82                 :          0 :             Any* pArguments = aArguments.getArray();
      83                 :            : 
      84                 :            :             // the parent window
      85                 :          0 :             Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface(m_pMessageParent);
      86                 :          0 :             *pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), -1, makeAny(xDialogParent), PropertyState_DIRECT_VALUE);
      87                 :            : 
      88                 :            :             // the title of the dialog
      89                 :          0 :             String sAdminDialogTitle(ModuleRes(RID_STR_ADMINDIALOGTITLE));
      90                 :          0 :             *pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), -1, makeAny(::rtl::OUString(sAdminDialogTitle)), PropertyState_DIRECT_VALUE);
      91                 :            : 
      92                 :            :             // the name of the new data source
      93                 :          0 :             *pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InitialSelection")), -1, makeAny(m_xDataSource), PropertyState_DIRECT_VALUE);
      94                 :            : 
      95                 :            :             // create the dialog
      96                 :          0 :             Reference< XExecutableDialog > xDialog;
      97                 :            :             {
      98                 :            :                 // creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded)
      99                 :            :                 // so we display a wait cursor
     100                 :          0 :                 WaitObject aWaitCursor(m_pMessageParent);
     101                 :          0 :                 xDialog = Reference< XExecutableDialog >( m_xORB->createInstanceWithArguments( _bFixedType ? s_sAdministrationServiceName : s_sDataSourceTypeChangeDialog, aArguments ), UNO_QUERY );
     102                 :            : 
     103                 :            :                 // just for a smoother UI: What the dialog does upon execution, is (amongst other things) creating
     104                 :            :                 // the DriverManager service
     105                 :            :                 // If this context has never been accessed before, this may be expensive (it includes loading of
     106                 :            :                 // at least one library).
     107                 :            :                 // As this wizard is intended to run on the first office start, it is very likely that the
     108                 :            :                 // context needs to be freshly created
     109                 :            :                 // Thus, we access the context here (within the WaitCursor), which means the user sees a waitcursor
     110                 :            :                 // while his/her office blocks a few seconds ....
     111                 :          0 :                 m_xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.DriverManager" )) );
     112                 :            :             }
     113                 :            : 
     114                 :          0 :             if (xDialog.is())
     115                 :            :             {   // execute it
     116                 :          0 :                 if (xDialog->execute())
     117                 :          0 :                     return sal_True;
     118                 :            :             }
     119                 :            :             else
     120                 :          0 :                 ShowServiceNotAvailableError(m_pMessageParent, s_sAdministrationServiceName, sal_True);
     121                 :            :         }
     122                 :          0 :         catch(const Exception&)
     123                 :            :         {
     124                 :            :             OSL_FAIL("OAdminDialogInvokation::invokeAdministration: caught an exception while executing the dialog!");
     125                 :            :         }
     126                 :          0 :         return sal_False;
     127                 :            :     }
     128                 :            : 
     129                 :            : //.........................................................................
     130                 :            : }   // namespace abp
     131                 :            : //.........................................................................
     132                 :            : 
     133                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10