LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/appl - openuriexternally.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 21 0.0 %
Date: 2012-12-27 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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com>
      17             :  *   (initial developer) ]
      18             :  *
      19             :  * All Rights Reserved.
      20             :  *
      21             :  * For minor contributions see the git repository.
      22             :  *
      23             :  * Alternatively, the contents of this file may be used under the terms of
      24             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      25             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      26             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      27             :  * instead of those above.
      28             :  */
      29             : 
      30             : #include "sal/config.h"
      31             : 
      32             : #include "com/sun/star/lang/IllegalArgumentException.hpp"
      33             : #include "com/sun/star/system/SystemShellExecute.hpp"
      34             : #include "com/sun/star/system/SystemShellExecuteException.hpp"
      35             : #include "com/sun/star/system/SystemShellExecuteFlags.hpp"
      36             : #include "com/sun/star/uno/Reference.hxx"
      37             : #include "com/sun/star/uno/RuntimeException.hpp"
      38             : #include "com/sun/star/uno/XInterface.hpp"
      39             : #include "comphelper/processfactory.hxx"
      40             : #include "rtl/ustring.h"
      41             : #include "rtl/ustring.hxx"
      42             : #include "sfx2/app.hxx"
      43             : #include "sfx2/sfxresid.hxx"
      44             : #include "tools/string.hxx"
      45             : #include "vcl/msgbox.hxx"
      46             : #include "vcl/svapp.hxx"
      47             : 
      48             : #include "openuriexternally.hxx"
      49             : 
      50             : #include "app.hrc"
      51             : 
      52           0 : bool sfx2::openUriExternally(
      53             :     rtl::OUString const & uri, bool handleSystemShellExecuteException)
      54             : {
      55             :     css::uno::Reference< css::system::XSystemShellExecute > exec(
      56           0 :         css::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
      57             :     try {
      58           0 :         exec->execute(
      59             :             uri, rtl::OUString(),
      60           0 :             css::system::SystemShellExecuteFlags::URIS_ONLY);
      61           0 :         return true;
      62           0 :     } catch (css::lang::IllegalArgumentException & e) {
      63           0 :         if (e.ArgumentPosition != 0) {
      64             :             throw css::uno::RuntimeException(
      65             :                 (rtl::OUString(
      66             :                     RTL_CONSTASCII_USTRINGPARAM(
      67             :                         "unexpected IllegalArgumentException: "))
      68           0 :                  + e.Message),
      69           0 :                 css::uno::Reference< css::uno::XInterface >());
      70             :         }
      71           0 :         SolarMutexGuard g;
      72             :         ErrorBox eb(
      73           0 :             SfxGetpApp()->GetTopWindow(), SfxResId(MSG_ERR_NO_ABS_URI_REF));
      74           0 :         String msg(eb.GetMessText());
      75           0 :         msg.SearchAndReplaceAscii("$(ARG1)", uri);
      76           0 :         eb.SetMessText(msg);
      77           0 :         eb.Execute();
      78           0 :     } catch (css::system::SystemShellExecuteException &) {
      79           0 :         if (!handleSystemShellExecuteException) {
      80           0 :             throw;
      81             :         }
      82           0 :         SolarMutexGuard g;
      83             :         ErrorBox(
      84             :             SfxGetpApp()->GetTopWindow(),
      85             :             SfxResId(MSG_ERR_NO_WEBBROWSER_FOUND)).
      86           0 :             Execute();
      87             :     }
      88           0 :     return false;
      89             : }
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10