LCOV - code coverage report
Current view: top level - forms/source/helper - urltransformer.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 17 21 81.0 %
Date: 2014-11-03 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         706 :     UrlTransformer::UrlTransformer( const Reference< XComponentContext >& _rxORB )
      36             :         :m_xORB( _rxORB )
      37         706 :         ,m_bTriedToCreateTransformer( false )
      38             :     {
      39             :         DBG_ASSERT( _rxORB.is(), "UrlTransformer::UrlTransformer: invalid service factory!" );
      40         706 :     }
      41             : 
      42             : 
      43          38 :     bool UrlTransformer::implEnsureTransformer() const
      44             :     {
      45             :         // create the transformer, if not already attempted to do so
      46          38 :         if ( !m_xTransformer.is() && !m_bTriedToCreateTransformer )
      47             :         {
      48           2 :             if ( m_xORB.is() )
      49             :             {
      50           2 :                 m_xTransformer.set(URLTransformer::create(m_xORB));
      51             :             }
      52             : 
      53           2 :             m_bTriedToCreateTransformer = true;
      54             :         }
      55          38 :         return m_xTransformer.is();
      56             :     }
      57             : 
      58             : 
      59          38 :     URL UrlTransformer::getStrictURL( const OUString& _rURL ) const
      60             :     {
      61          38 :         URL aReturn;
      62          38 :         aReturn.Complete = _rURL;
      63          38 :         if ( implEnsureTransformer() )
      64          38 :             m_xTransformer->parseStrict( aReturn );
      65          38 :         return aReturn;
      66             :     }
      67             : 
      68             : 
      69          38 :     URL UrlTransformer::getStrictURLFromAscii( const sal_Char* _pAsciiURL ) const
      70             :     {
      71          38 :         return getStrictURL( OUString::createFromAscii( _pAsciiURL ) );
      72             :     }
      73             : 
      74             : 
      75           0 :     void UrlTransformer::parseSmartWithAsciiProtocol( ::com::sun::star::util::URL& _rURL, const sal_Char* _pAsciiURL ) const
      76             :     {
      77           0 :         if ( implEnsureTransformer() )
      78           0 :             m_xTransformer->parseSmart( _rURL, OUString::createFromAscii( _pAsciiURL ) );
      79           0 :     }
      80             : 
      81             : 
      82             : } // namespace frm
      83             : 
      84             : 
      85             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10