LCOV - code coverage report
Current view: top level - extensions/source/abpilot - admininvokationimpl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 24 0.0 %
Date: 2015-06-13 12:38:46 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/helper/vclunohelper.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           0 :     OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XComponentContext >& _rxContext,
      46             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDataSource
      47             :                     , vcl::Window* _pMessageParent)
      48             :         :m_xContext(_rxContext)
      49             :         ,m_xDataSource(_rxDataSource)
      50           0 :         ,m_pMessageParent(_pMessageParent)
      51             :     {
      52             :         DBG_ASSERT(m_xContext.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!");
      53             :         DBG_ASSERT(m_xDataSource.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid preferred name!");
      54             :         DBG_ASSERT(m_pMessageParent, "OAdminDialogInvokation::OAdminDialogInvokation: invalid message parent!");
      55           0 :     }
      56             : 
      57             : 
      58           0 :     bool OAdminDialogInvokation::invokeAdministration( bool _bFixedType )
      59             :     {
      60           0 :         if (!m_xContext.is())
      61           0 :             return false;
      62             : 
      63             :         try
      64             :         {
      65             :             // the service name of the administration dialog
      66             :             static const char s_sAdministrationServiceName[] = "com.sun.star.sdb.DatasourceAdministrationDialog";
      67             :             static const char s_sDataSourceTypeChangeDialog[] = "com.sun.star.sdb.DataSourceTypeChangeDialog";
      68             : 
      69             :             // the parameters for the call
      70           0 :             Sequence< Any > aArguments(3);
      71           0 :             Any* pArguments = aArguments.getArray();
      72             : 
      73             :             // the parent window
      74           0 :             Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface(m_pMessageParent);
      75           0 :             *pArguments++ <<= PropertyValue(OUString("ParentWindow"), -1, makeAny(xDialogParent), PropertyState_DIRECT_VALUE);
      76             : 
      77             :             // the title of the dialog
      78           0 :             OUString sAdminDialogTitle(ModuleRes(RID_STR_ADMINDIALOGTITLE).toString());
      79           0 :             *pArguments++ <<= PropertyValue(OUString("Title"), -1, makeAny(sAdminDialogTitle), PropertyState_DIRECT_VALUE);
      80             : 
      81             :             // the name of the new data source
      82           0 :             *pArguments++ <<= PropertyValue(OUString("InitialSelection"), -1, makeAny(m_xDataSource), PropertyState_DIRECT_VALUE);
      83             : 
      84             :             // create the dialog
      85           0 :             Reference< XExecutableDialog > xDialog;
      86             :             {
      87             :                 // creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded)
      88             :                 // so we display a wait cursor
      89           0 :                 WaitObject aWaitCursor(m_pMessageParent);
      90           0 :                 Reference<XInterface> x = m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(_bFixedType ? OUString(s_sAdministrationServiceName) : OUString(s_sDataSourceTypeChangeDialog), aArguments, m_xContext);
      91           0 :                 xDialog = Reference< XExecutableDialog >( x, UNO_QUERY );
      92             : 
      93             :                 // just for a smoother UI: What the dialog does upon execution, is (amongst other things) creating
      94             :                 // the DriverManager service
      95             :                 // If this context has never been accessed before, this may be expensive (it includes loading of
      96             :                 // at least one library).
      97             :                 // As this wizard is intended to run on the first office start, it is very likely that the
      98             :                 // context needs to be freshly created
      99             :                 // Thus, we access the context here (within the WaitCursor), which means the user sees a waitcursor
     100             :                 // while his/her office blocks a few seconds ....
     101           0 :                 DriverManager::create( m_xContext );
     102             :             }
     103             : 
     104           0 :             if (xDialog.is())
     105             :             {   // execute it
     106           0 :                 if (xDialog->execute())
     107           0 :                     return true;
     108             :             }
     109             :             else
     110           0 :                 ShowServiceNotAvailableError(m_pMessageParent, s_sAdministrationServiceName, true);
     111             :         }
     112           0 :         catch(const Exception&)
     113             :         {
     114             :             OSL_FAIL("OAdminDialogInvokation::invokeAdministration: caught an exception while executing the dialog!");
     115             :         }
     116           0 :         return false;
     117             :     }
     118             : 
     119             : 
     120             : }   // namespace abp
     121             : 
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11