LCOV - code coverage report
Current view: top level - sfx2/source/appl - openuriexternally.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 22 0.0 %
Date: 2012-08-25 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 73 0.0 %

           Branch data     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/XSystemShellExecute.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                 :            : namespace {
      53                 :            : 
      54                 :            : namespace css = com::sun::star;
      55                 :            : 
      56                 :            : }
      57                 :            : 
      58                 :          0 : bool sfx2::openUriExternally(
      59                 :            :     rtl::OUString const & uri, bool handleSystemShellExecuteException)
      60                 :            : {
      61                 :            :     css::uno::Reference< css::system::XSystemShellExecute > exec(
      62 [ #  # ][ #  # ]:          0 :         comphelper::getProcessServiceFactory()->createInstance(
      63                 :            :             rtl::OUString(
      64                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
      65                 :          0 :                     "com.sun.star.system.SystemShellExecute"))),
      66 [ #  # ][ #  # ]:          0 :         css::uno::UNO_QUERY_THROW);
                 [ #  # ]
      67                 :            :     try {
      68         [ #  # ]:          0 :         exec->execute(
      69                 :            :             uri, rtl::OUString(),
      70         [ #  # ]:          0 :             css::system::SystemShellExecuteFlags::URIS_ONLY);
      71                 :          0 :         return true;
      72         [ #  # ]:          0 :     } catch (css::lang::IllegalArgumentException & e) {
      73         [ #  # ]:          0 :         if (e.ArgumentPosition != 0) {
      74                 :            :             throw css::uno::RuntimeException(
      75                 :            :                 (rtl::OUString(
      76                 :            :                     RTL_CONSTASCII_USTRINGPARAM(
      77                 :            :                         "unexpected IllegalArgumentException: "))
      78                 :            :                  + e.Message),
      79   [ #  #  #  # ]:          0 :                 css::uno::Reference< css::uno::XInterface >());
      80                 :            :         }
      81         [ #  # ]:          0 :         SolarMutexGuard g;
      82                 :            :         ErrorBox eb(
      83   [ #  #  #  #  :          0 :             SfxGetpApp()->GetTopWindow(), SfxResId(MSG_ERR_NO_ABS_URI_REF));
             #  #  #  # ]
      84         [ #  # ]:          0 :         String msg(eb.GetMessText());
      85   [ #  #  #  #  :          0 :         msg.SearchAndReplaceAscii("$(ARG1)", uri);
                   #  # ]
      86         [ #  # ]:          0 :         eb.SetMessText(msg);
      87   [ #  #  #  #  :          0 :         eb.Execute();
             #  #  #  # ]
      88   [ #  #  #  #  :          0 :     } catch (css::system::SystemShellExecuteException &) {
                      # ]
      89         [ #  # ]:          0 :         if (!handleSystemShellExecuteException) {
      90                 :          0 :             throw;
      91                 :            :         }
      92         [ #  # ]:          0 :         SolarMutexGuard g;
      93                 :            :         ErrorBox(
      94                 :            :             SfxGetpApp()->GetTopWindow(),
      95                 :            :             SfxResId(MSG_ERR_NO_WEBBROWSER_FOUND)).
      96   [ #  #  #  #  :          0 :             Execute();
          #  #  #  #  #  
             #  #  #  #  
                      # ]
      97                 :            :     }
      98                 :          0 :     return false;
      99                 :            : }
     100                 :            : 
     101                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10