LCOV - code coverage report
Current view: top level - forms/source/helper - urltransformer.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 17 21 81.0 %
Date: 2014-04-11 Functions: 4 5 80.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             :  * 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             : #include "urltransformer.hxx"
      21             : 
      22             : #include <com/sun/star/util/URLTransformer.hpp>
      23             : #include <tools/debug.hxx>
      24             : #include <comphelper/processfactory.hxx>
      25             : 
      26             : 
      27             : namespace frm
      28             : {
      29             : 
      30             : 
      31             :     using namespace ::com::sun::star::uno;
      32             :     using namespace ::com::sun::star::util;
      33             :     using namespace ::com::sun::star::lang;
      34             : 
      35             : 
      36             :     //= UrlTransformer
      37             : 
      38             : 
      39         383 :     UrlTransformer::UrlTransformer( const Reference< XComponentContext >& _rxORB )
      40             :         :m_xORB( _rxORB )
      41         383 :         ,m_bTriedToCreateTransformer( false )
      42             :     {
      43             :         DBG_ASSERT( _rxORB.is(), "UrlTransformer::UrlTransformer: invalid service factory!" );
      44         383 :     }
      45             : 
      46             : 
      47          19 :     bool UrlTransformer::implEnsureTransformer() const
      48             :     {
      49             :         // create the transformer, if not already attempted to do so
      50          19 :         if ( !m_xTransformer.is() && !m_bTriedToCreateTransformer )
      51             :         {
      52           1 :             if ( m_xORB.is() )
      53             :             {
      54           1 :                 m_xTransformer.set(URLTransformer::create(m_xORB));
      55             :             }
      56             : 
      57           1 :             m_bTriedToCreateTransformer = true;
      58             :         }
      59          19 :         return m_xTransformer.is();
      60             :     }
      61             : 
      62             : 
      63          19 :     URL UrlTransformer::getStrictURL( const OUString& _rURL ) const
      64             :     {
      65          19 :         URL aReturn;
      66          19 :         aReturn.Complete = _rURL;
      67          19 :         if ( implEnsureTransformer() )
      68          19 :             m_xTransformer->parseStrict( aReturn );
      69          19 :         return aReturn;
      70             :     }
      71             : 
      72             : 
      73          19 :     URL UrlTransformer::getStrictURLFromAscii( const sal_Char* _pAsciiURL ) const
      74             :     {
      75          19 :         return getStrictURL( OUString::createFromAscii( _pAsciiURL ) );
      76             :     }
      77             : 
      78             : 
      79           0 :     void UrlTransformer::parseSmartWithAsciiProtocol( ::com::sun::star::util::URL& _rURL, const sal_Char* _pAsciiURL ) const
      80             :     {
      81           0 :         if ( implEnsureTransformer() )
      82           0 :             m_xTransformer->parseSmart( _rURL, OUString::createFromAscii( _pAsciiURL ) );
      83           0 :     }
      84             : 
      85             : 
      86             : } // namespace frm
      87             : 
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10