LCOV - code coverage report
Current view: top level - stoc/source/uriproc - VndSunStarPkgUrlReferenceFactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 30 6.7 %
Date: 2012-08-25 Functions: 1 10 10.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 42 0.0 %

           Branch data     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                 :            : 
      21                 :            : #include "stocservices.hxx"
      22                 :            : 
      23                 :            : #include "supportsService.hxx"
      24                 :            : 
      25                 :            : #include "com/sun/star/lang/XServiceInfo.hpp"
      26                 :            : #include "com/sun/star/uno/Exception.hpp"
      27                 :            : #include "com/sun/star/uno/Reference.hxx"
      28                 :            : #include "com/sun/star/uno/RuntimeException.hpp"
      29                 :            : #include "com/sun/star/uno/Sequence.hxx"
      30                 :            : #include "com/sun/star/uno/XComponentContext.hpp"
      31                 :            : #include "com/sun/star/uno/XInterface.hpp"
      32                 :            : #include "com/sun/star/uri/UriReferenceFactory.hpp"
      33                 :            : #include "com/sun/star/uri/XUriReference.hpp"
      34                 :            : #include "com/sun/star/uri/XUriReferenceFactory.hpp"
      35                 :            : #include "com/sun/star/uri/XVndSunStarPkgUrlReferenceFactory.hpp"
      36                 :            : #include "cppuhelper/implbase2.hxx"
      37                 :            : #include "cppuhelper/weak.hxx"
      38                 :            : #include "rtl/string.h"
      39                 :            : #include "rtl/textenc.h"
      40                 :            : #include "rtl/uri.h"
      41                 :            : #include "rtl/uri.hxx"
      42                 :            : #include "rtl/ustrbuf.hxx"
      43                 :            : #include "rtl/ustring.hxx"
      44                 :            : #include "sal/types.h"
      45                 :            : 
      46                 :            : #include <new>
      47                 :            : 
      48                 :            : namespace css = com::sun::star;
      49                 :            : 
      50                 :            : namespace {
      51                 :            : 
      52                 :            : class Factory: public cppu::WeakImplHelper2<
      53                 :            :     css::lang::XServiceInfo, css::uri::XVndSunStarPkgUrlReferenceFactory >
      54                 :            : {
      55                 :            : public:
      56                 :          0 :     explicit Factory(
      57                 :            :         css::uno::Reference< css::uno::XComponentContext > const & context):
      58                 :          0 :         m_context(context) {}
      59                 :            : 
      60                 :            :     virtual rtl::OUString SAL_CALL getImplementationName()
      61                 :            :         throw (css::uno::RuntimeException);
      62                 :            : 
      63                 :            :     virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName)
      64                 :            :         throw (css::uno::RuntimeException);
      65                 :            : 
      66                 :            :     virtual css::uno::Sequence< rtl::OUString > SAL_CALL
      67                 :            :     getSupportedServiceNames() throw (css::uno::RuntimeException);
      68                 :            : 
      69                 :            :     virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL
      70                 :            :     createVndSunStarPkgUrlReference(
      71                 :            :         css::uno::Reference< css::uri::XUriReference > const & authority)
      72                 :            :         throw (css::uno::RuntimeException);
      73                 :            : 
      74                 :            : private:
      75                 :            :     Factory(Factory &); // not implemented
      76                 :            :     void operator =(Factory); // not implemented
      77                 :            : 
      78         [ #  # ]:          0 :     virtual ~Factory() {}
      79                 :            : 
      80                 :            :     css::uno::Reference< css::uno::XComponentContext > m_context;
      81                 :            : };
      82                 :            : 
      83                 :          0 : rtl::OUString Factory::getImplementationName()
      84                 :            :     throw (css::uno::RuntimeException)
      85                 :            : {
      86                 :            :     return
      87                 :            :         stoc_services::VndSunStarPkgUrlReferenceFactory::
      88                 :          0 :         getImplementationName();
      89                 :            : }
      90                 :            : 
      91                 :          0 : sal_Bool Factory::supportsService(rtl::OUString const & serviceName)
      92                 :            :     throw (css::uno::RuntimeException)
      93                 :            : {
      94                 :            :     return stoc::uriproc::supportsService(
      95         [ #  # ]:          0 :         getSupportedServiceNames(), serviceName);
      96                 :            : }
      97                 :            : 
      98                 :          0 : css::uno::Sequence< rtl::OUString > Factory::getSupportedServiceNames()
      99                 :            :     throw (css::uno::RuntimeException)
     100                 :            : {
     101                 :            :     return stoc_services::VndSunStarPkgUrlReferenceFactory::
     102                 :          0 :         getSupportedServiceNames();
     103                 :            : }
     104                 :            : 
     105                 :            : css::uno::Reference< css::uri::XUriReference >
     106                 :          0 : Factory::createVndSunStarPkgUrlReference(
     107                 :            :     css::uno::Reference< css::uri::XUriReference > const & authority)
     108                 :            :     throw (css::uno::RuntimeException)
     109                 :            : {
     110                 :            :     OSL_ASSERT(authority.is());
     111 [ #  # ][ #  # ]:          0 :     if (authority->isAbsolute() && !authority->hasFragment()) {
                 [ #  # ]
     112                 :          0 :         rtl::OUStringBuffer buf;
     113         [ #  # ]:          0 :         buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pkg://"));
     114                 :            :         buf.append(
     115                 :            :             rtl::Uri::encode(
     116         [ #  # ]:          0 :                 authority->getUriReference(), rtl_UriCharClassRegName,
     117 [ #  # ][ #  # ]:          0 :                 rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8));
     118                 :            :         css::uno::Reference< css::uri::XUriReference > uriRef(
     119 [ #  # ][ #  # ]:          0 :             css::uri::UriReferenceFactory::create(m_context)->parse(
     120 [ #  # ][ #  # ]:          0 :                 buf.makeStringAndClear()));
     121                 :            :         OSL_ASSERT(uriRef.is());
     122                 :          0 :         return uriRef;
     123                 :            :     } else {
     124                 :          0 :         return css::uno::Reference< css::uri::XUriReference >();
     125                 :            :     }
     126                 :            : }
     127                 :            : 
     128                 :            : }
     129                 :            : 
     130                 :            : namespace stoc_services { namespace VndSunStarPkgUrlReferenceFactory
     131                 :            : {
     132                 :            : 
     133                 :          0 : css::uno::Reference< css::uno::XInterface > create(
     134                 :            :     css::uno::Reference< css::uno::XComponentContext > const & context)
     135                 :            :     SAL_THROW((css::uno::Exception))
     136                 :            : {
     137                 :            :     try {
     138 [ #  # ][ #  # ]:          0 :         return static_cast< cppu::OWeakObject * >(new Factory(context));
     139         [ #  # ]:          0 :     } catch (std::bad_alloc &) {
     140                 :            :         throw css::uno::RuntimeException(
     141   [ #  #  #  #  :          0 :             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("std::bad_alloc")), 0);
                   #  # ]
     142                 :            :     }
     143                 :            : }
     144                 :            : 
     145                 :        377 : rtl::OUString getImplementationName() {
     146                 :            :     return rtl::OUString(
     147                 :        377 :         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.uri.VndSunStarPkgUrlReferenceFactory"));
     148                 :            : }
     149                 :            : 
     150                 :          0 : css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
     151                 :          0 :     css::uno::Sequence< rtl::OUString > s(1);
     152         [ #  # ]:          0 :     s[0] = rtl::OUString(
     153         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.VndSunStarPkgUrlReferenceFactory"));
     154                 :          0 :     return s;
     155                 :            : }
     156                 :            : 
     157                 :            : } }
     158                 :            : 
     159                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10