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 0 : UrlTransformer::UrlTransformer( const Reference< XComponentContext >& _rxORB )
40 : :m_xORB( _rxORB )
41 0 : ,m_bTriedToCreateTransformer( false )
42 : {
43 : DBG_ASSERT( _rxORB.is(), "UrlTransformer::UrlTransformer: invalid service factory!" );
44 0 : }
45 :
46 :
47 0 : bool UrlTransformer::implEnsureTransformer() const
48 : {
49 : // create the transformer, if not already attempted to do so
50 0 : if ( !m_xTransformer.is() && !m_bTriedToCreateTransformer )
51 : {
52 0 : if ( m_xORB.is() )
53 : {
54 0 : m_xTransformer.set(URLTransformer::create(m_xORB));
55 : }
56 :
57 0 : m_bTriedToCreateTransformer = true;
58 : }
59 0 : return m_xTransformer.is();
60 : }
61 :
62 :
63 0 : URL UrlTransformer::getStrictURL( const OUString& _rURL ) const
64 : {
65 0 : URL aReturn;
66 0 : aReturn.Complete = _rURL;
67 0 : if ( implEnsureTransformer() )
68 0 : m_xTransformer->parseStrict( aReturn );
69 0 : return aReturn;
70 : }
71 :
72 :
73 0 : URL UrlTransformer::getStrictURLFromAscii( const sal_Char* _pAsciiURL ) const
74 : {
75 0 : 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: */
|