LCOV - code coverage report
Current view: top level - forms/source/helper - urltransformer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 21 81.0 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 28 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "urltransformer.hxx"
      30                 :            : 
      31                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      32                 :            : #include <tools/debug.hxx>
      33                 :            : #include <comphelper/componentcontext.hxx>
      34                 :            : 
      35                 :            : //........................................................................
      36                 :            : namespace frm
      37                 :            : {
      38                 :            : //........................................................................
      39                 :            : 
      40                 :            :     using namespace ::com::sun::star::uno;
      41                 :            :     using namespace ::com::sun::star::util;
      42                 :            :     using namespace ::com::sun::star::lang;
      43                 :            : 
      44                 :            :     //====================================================================
      45                 :            :     //= UrlTransformer
      46                 :            :     //====================================================================
      47                 :            :     //--------------------------------------------------------------------
      48                 :        266 :     UrlTransformer::UrlTransformer( const Reference< XMultiServiceFactory >& _rxORB )
      49                 :            :         :m_xORB( _rxORB )
      50                 :        266 :         ,m_bTriedToCreateTransformer( false )
      51                 :            :     {
      52                 :            :         DBG_ASSERT( _rxORB.is(), "UrlTransformer::UrlTransformer: invalid service factory!" );
      53                 :        266 :     }
      54                 :            : 
      55                 :            :     //--------------------------------------------------------------------
      56                 :         38 :     bool UrlTransformer::implEnsureTransformer() const
      57                 :            :     {
      58                 :            :         // create the transformer, if not already attempted to do so
      59 [ +  + ][ +  - ]:         38 :         if ( !m_xTransformer.is() && !m_bTriedToCreateTransformer )
                 [ +  + ]
      60                 :            :         {
      61         [ +  - ]:          2 :             if ( m_xORB.is() )
      62                 :            :             {
      63 [ +  - ][ +  - ]:          2 :                 m_xTransformer.set(URLTransformer::create(comphelper::ComponentContext(m_xORB).getUNOContext()));
                 [ +  - ]
      64                 :            :             }
      65                 :            : 
      66                 :          2 :             m_bTriedToCreateTransformer = true;
      67                 :            :         }
      68                 :         38 :         return m_xTransformer.is();
      69                 :            :     }
      70                 :            : 
      71                 :            :     //--------------------------------------------------------------------
      72                 :         38 :     URL UrlTransformer::getStrictURL( const ::rtl::OUString& _rURL ) const
      73                 :            :     {
      74                 :         38 :         URL aReturn;
      75                 :         38 :         aReturn.Complete = _rURL;
      76 [ +  - ][ +  - ]:         38 :         if ( implEnsureTransformer() )
      77 [ +  - ][ +  - ]:         38 :             m_xTransformer->parseStrict( aReturn );
      78                 :         38 :         return aReturn;
      79                 :            :     }
      80                 :            : 
      81                 :            :     //--------------------------------------------------------------------
      82                 :         38 :     URL UrlTransformer::getStrictURLFromAscii( const sal_Char* _pAsciiURL ) const
      83                 :            :     {
      84         [ +  - ]:         38 :         return getStrictURL( ::rtl::OUString::createFromAscii( _pAsciiURL ) );
      85                 :            :     }
      86                 :            : 
      87                 :            :     //--------------------------------------------------------------------
      88                 :          0 :     void UrlTransformer::parseSmartWithAsciiProtocol( ::com::sun::star::util::URL& _rURL, const sal_Char* _pAsciiURL ) const
      89                 :            :     {
      90         [ #  # ]:          0 :         if ( implEnsureTransformer() )
      91         [ #  # ]:          0 :             m_xTransformer->parseSmart( _rURL, ::rtl::OUString::createFromAscii( _pAsciiURL ) );
      92                 :          0 :     }
      93                 :            : 
      94                 :            : //........................................................................
      95                 :            : } // namespace frm
      96                 :            : //........................................................................
      97                 :            : 
      98                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10