LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/abpilot - admininvokationimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2012-12-27 Functions: 0 2 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             : #include "admininvokationimpl.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include <com/sun/star/beans/PropertyValue.hpp>
      23             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      24             : #include <com/sun/star/awt/XWindow.hpp>
      25             : #include <com/sun/star/sdbc/DriverManager.hpp>
      26             : #include <vcl/stdtext.hxx>
      27             : #include <toolkit/unohlp.hxx>
      28             : #include "abpresid.hrc"
      29             : #include "componentmodule.hxx"
      30             : #include <vcl/waitobj.hxx>
      31             : 
      32             : 
      33             : //.........................................................................
      34             : namespace abp
      35             : {
      36             : //.........................................................................
      37             : 
      38             :     using namespace ::com::sun::star::uno;
      39             :     using namespace ::com::sun::star::lang;
      40             :     using namespace ::com::sun::star::beans;
      41             :     using namespace ::com::sun::star::awt;
      42             :     using namespace ::com::sun::star::ui::dialogs;
      43             :     using namespace ::com::sun::star::sdbc;
      44             : 
      45             :     //=====================================================================
      46             :     //= OAdminDialogInvokation
      47             :     //=====================================================================
      48             :     //---------------------------------------------------------------------
      49           0 :     OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XComponentContext >& _rxContext
      50             :                     , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xDataSource
      51             :                     , Window* _pMessageParent)
      52             :         :m_xContext(_rxContext)
      53             :         ,m_xDataSource(_xDataSource)
      54           0 :         ,m_pMessageParent(_pMessageParent)
      55             :     {
      56             :         DBG_ASSERT(m_xContext.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!");
      57             :         DBG_ASSERT(m_xDataSource.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid preferred name!");
      58             :         DBG_ASSERT(m_pMessageParent, "OAdminDialogInvokation::OAdminDialogInvokation: invalid message parent!");
      59           0 :     }
      60             : 
      61             :     //---------------------------------------------------------------------
      62           0 :     sal_Bool OAdminDialogInvokation::invokeAdministration( sal_Bool _bFixedType )
      63             :     {
      64           0 :         if (!m_xContext.is())
      65           0 :             return sal_False;
      66             : 
      67             :         try
      68             :         {
      69             :             // the service name of the administration dialog
      70           0 :             const static ::rtl::OUString s_sAdministrationServiceName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatasourceAdministrationDialog"));
      71           0 :             const static ::rtl::OUString s_sDataSourceTypeChangeDialog = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog"));
      72             : 
      73             :             // the parameters for the call
      74           0 :             Sequence< Any > aArguments(3);
      75           0 :             Any* pArguments = aArguments.getArray();
      76             : 
      77             :             // the parent window
      78           0 :             Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface(m_pMessageParent);
      79           0 :             *pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), -1, makeAny(xDialogParent), PropertyState_DIRECT_VALUE);
      80             : 
      81             :             // the title of the dialog
      82           0 :             String sAdminDialogTitle(ModuleRes(RID_STR_ADMINDIALOGTITLE));
      83           0 :             *pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), -1, makeAny(::rtl::OUString(sAdminDialogTitle)), PropertyState_DIRECT_VALUE);
      84             : 
      85             :             // the name of the new data source
      86           0 :             *pArguments++ <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InitialSelection")), -1, makeAny(m_xDataSource), PropertyState_DIRECT_VALUE);
      87             : 
      88             :             // create the dialog
      89           0 :             Reference< XExecutableDialog > xDialog;
      90             :             {
      91             :                 // creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded)
      92             :                 // so we display a wait cursor
      93           0 :                 WaitObject aWaitCursor(m_pMessageParent);
      94           0 :                 xDialog = Reference< XExecutableDialog >( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(_bFixedType ? s_sAdministrationServiceName : s_sDataSourceTypeChangeDialog, aArguments, m_xContext), UNO_QUERY );
      95             : 
      96             :                 // just for a smoother UI: What the dialog does upon execution, is (amongst other things) creating
      97             :                 // the DriverManager service
      98             :                 // If this context has never been accessed before, this may be expensive (it includes loading of
      99             :                 // at least one library).
     100             :                 // As this wizard is intended to run on the first office start, it is very likely that the
     101             :                 // context needs to be freshly created
     102             :                 // Thus, we access the context here (within the WaitCursor), which means the user sees a waitcursor
     103             :                 // while his/her office blocks a few seconds ....
     104           0 :                 DriverManager::create( m_xContext );
     105             :             }
     106             : 
     107           0 :             if (xDialog.is())
     108             :             {   // execute it
     109           0 :                 if (xDialog->execute())
     110           0 :                     return sal_True;
     111             :             }
     112             :             else
     113           0 :                 ShowServiceNotAvailableError(m_pMessageParent, s_sAdministrationServiceName, sal_True);
     114             :         }
     115           0 :         catch(const Exception&)
     116             :         {
     117             :             OSL_FAIL("OAdminDialogInvokation::invokeAdministration: caught an exception while executing the dialog!");
     118             :         }
     119           0 :         return sal_False;
     120             :     }
     121             : 
     122             : //.........................................................................
     123             : }   // namespace abp
     124             : //.........................................................................
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10