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