LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sfx2/source/appl - openuriexternally.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 22 4.5 %
Date: 2013-07-09 Functions: 2 3 66.7 %
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 "tools/string.hxx"
      25             : #include "vcl/msgbox.hxx"
      26             : #include "vcl/svapp.hxx"
      27             : 
      28             : #include "openuriexternally.hxx"
      29             : 
      30             : #include "app.hrc"
      31             : 
      32           0 : bool sfx2::openUriExternally(
      33             :     OUString const & uri, bool handleSystemShellExecuteException)
      34             : {
      35             :     css::uno::Reference< css::system::XSystemShellExecute > exec(
      36           0 :         css::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
      37             :     try {
      38           0 :         exec->execute(
      39             :             uri, OUString(),
      40           0 :             css::system::SystemShellExecuteFlags::URIS_ONLY);
      41           0 :         return true;
      42           0 :     } catch (css::lang::IllegalArgumentException & e) {
      43           0 :         if (e.ArgumentPosition != 0) {
      44             :             throw css::uno::RuntimeException(
      45             :                 (OUString(
      46             :                         "unexpected IllegalArgumentException: ")
      47           0 :                  + e.Message),
      48           0 :                 css::uno::Reference< css::uno::XInterface >());
      49             :         }
      50           0 :         SolarMutexGuard g;
      51             :         ErrorBox eb(
      52           0 :             SfxGetpApp()->GetTopWindow(), SfxResId(MSG_ERR_NO_ABS_URI_REF));
      53           0 :         String msg(eb.GetMessText());
      54           0 :         msg.SearchAndReplaceAscii("$(ARG1)", uri);
      55           0 :         eb.SetMessText(msg);
      56           0 :         eb.Execute();
      57           0 :     } catch (css::system::SystemShellExecuteException &) {
      58           0 :         if (!handleSystemShellExecuteException) {
      59           0 :             throw;
      60             :         }
      61           0 :         SolarMutexGuard g;
      62             :         ErrorBox(
      63             :             SfxGetpApp()->GetTopWindow(),
      64             :             SfxResId(MSG_ERR_NO_WEBBROWSER_FOUND)).
      65           0 :             Execute();
      66             :     }
      67           0 :     return false;
      68         408 : }
      69             : 
      70             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10