LCOV - code coverage report
Current view: top level - sfx2/source/appl - openuriexternally.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 21 0.0 %
Date: 2014-04-14 Functions: 0 1 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             : 
      10             : #include <sal/config.h>
      11             : 
      12             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      13             : #include <com/sun/star/system/SystemShellExecute.hpp>
      14             : #include <com/sun/star/system/SystemShellExecuteException.hpp>
      15             : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
      16             : #include <com/sun/star/uno/Reference.hxx>
      17             : #include <com/sun/star/uno/RuntimeException.hpp>
      18             : #include <com/sun/star/uno/XInterface.hpp>
      19             : #include <comphelper/processfactory.hxx>
      20             : #include <rtl/ustring.h>
      21             : #include <rtl/ustring.hxx>
      22             : #include <sfx2/app.hxx>
      23             : #include <sfx2/sfxresid.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : 
      27             : #include "openuriexternally.hxx"
      28             : 
      29             : #include "app.hrc"
      30             : 
      31           0 : bool sfx2::openUriExternally(
      32             :     OUString const & uri, bool handleSystemShellExecuteException)
      33             : {
      34             :     css::uno::Reference< css::system::XSystemShellExecute > exec(
      35           0 :         css::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
      36             :     try {
      37           0 :         exec->execute(
      38             :             uri, OUString(),
      39           0 :             css::system::SystemShellExecuteFlags::URIS_ONLY);
      40           0 :         return true;
      41           0 :     } catch (css::lang::IllegalArgumentException & e) {
      42           0 :         if (e.ArgumentPosition != 0) {
      43             :             throw css::uno::RuntimeException(
      44             :                 (OUString(
      45             :                         "unexpected IllegalArgumentException: ")
      46           0 :                  + e.Message),
      47           0 :                 css::uno::Reference< css::uno::XInterface >());
      48             :         }
      49           0 :         SolarMutexGuard g;
      50             :         ErrorBox eb(
      51           0 :             SfxGetpApp()->GetTopWindow(), SfxResId(MSG_ERR_NO_ABS_URI_REF));
      52           0 :         OUString msg(eb.GetMessText());
      53           0 :         msg = msg.replaceFirst("$(ARG1)", uri);
      54           0 :         eb.SetMessText(msg);
      55           0 :         eb.Execute();
      56           0 :     } catch (css::system::SystemShellExecuteException &) {
      57           0 :         if (!handleSystemShellExecuteException) {
      58           0 :             throw;
      59             :         }
      60           0 :         SolarMutexGuard g;
      61             :         ErrorBox(
      62             :             SfxGetpApp()->GetTopWindow(),
      63             :             SfxResId(MSG_ERR_NO_WEBBROWSER_FOUND)).
      64           0 :             Execute();
      65             :     }
      66           0 :     return false;
      67             : }
      68             : 
      69             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10