fwk: Use constructor feature for URLTransformer.

Change-Id: I6559cb4c97e7c20930fffba3ce3d565840c89033
This commit is contained in:
Matúš Kukan
2014-01-09 17:05:25 +01:00
parent d51b105904
commit 86b12c3448
4 changed files with 61 additions and 231 deletions

View File

@@ -1,192 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_URLTRANSFORMER_HXX
#define INCLUDED_FRAMEWORK_INC_SERVICES_URLTRANSFORMER_HXX
#include <threadhelp/threadhelpbase.hxx>
#include <macros/generic.hxx>
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx>
#include <general.h>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/util/URL.hpp>
#include <cppuhelper/implbase2.hxx>
namespace framework{
/*-************************************************************************************************************//**
@short
@descr -
@implements XInterface
XTypeProvider
XServiceInfo
XURLTransformer
@base ThreadHelpBase
OWeakObject
*//*-*************************************************************************************************************/
class URLTransformer : public ::cppu::WeakImplHelper2< ::com::sun::star::util::XURLTransformer, css::lang::XServiceInfo>
{
//-------------------------------------------------------------------------------------------------------------
// public methods
//-------------------------------------------------------------------------------------------------------------
public:
//---------------------------------------------------------------------------------------------------------
// constructor / destructor
//---------------------------------------------------------------------------------------------------------
/*-****************************************************************************************************//**
@short -
@descr -
@seealso -
@param -
@return -
@onerror -
*//*-*****************************************************************************************************/
URLTransformer( const css::uno::Reference< css::lang::XMultiServiceFactory >& sFactory );
/*-****************************************************************************************************//**
@short -
@descr -
@seealso -
@param -
@return -
@onerror -
*//*-*****************************************************************************************************/
virtual ~URLTransformer();
//---------------------------------------------------------------------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
//---------------------------------------------------------------------------------------------------------
DECLARE_XSERVICEINFO
//---------------------------------------------------------------------------------------------------------
// XURLTransformer
//---------------------------------------------------------------------------------------------------------
/*-****************************************************************************************************//**
@short -
@descr -
@seealso -
@param -
@return -
@onerror -
*//*-*****************************************************************************************************/
virtual sal_Bool SAL_CALL parseStrict( css::util::URL& aURL ) throw( css::uno::RuntimeException );
/*-****************************************************************************************************//**
@short -
@descr -
@seealso -
@param -
@return -
@onerror -
*//*-*****************************************************************************************************/
virtual sal_Bool SAL_CALL parseSmart( css::util::URL& aURL ,
const OUString& sSmartProtocol ) throw( css::uno::RuntimeException );
/*-****************************************************************************************************//**
@short -
@descr -
@seealso -
@param -
@return -
@onerror -
*//*-*****************************************************************************************************/
virtual sal_Bool SAL_CALL assemble( css::util::URL& aURL ) throw( css::uno::RuntimeException );
/*-****************************************************************************************************//**
@short -
@descr -
@seealso -
@param -
@return -
@onerror -
*//*-*****************************************************************************************************/
virtual OUString SAL_CALL getPresentation( const css::util::URL& aURL ,
sal_Bool bWithPassword ) throw( css::uno::RuntimeException );
//-------------------------------------------------------------------------------------------------------------
// protected methods
//-------------------------------------------------------------------------------------------------------------
protected:
//-------------------------------------------------------------------------------------------------------------
// private methods
//-------------------------------------------------------------------------------------------------------------
private:
//-------------------------------------------------------------------------------------------------------------
// debug methods
// (should be private everyway!)
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
// variables
// (should be private everyway!)
//-------------------------------------------------------------------------------------------------------------
private:
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// reference to factory, which has created this instance
}; // class URLTransformer
} // namespace framework
#endif // INCLUDED_FRAMEWORK_INC_SERVICES_URLTRANSFORMER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -33,7 +33,6 @@
IFFACTORIE( Service2 )
)
=================================================================================================================*/
#include <services/urltransformer.hxx>
#include <services/desktop.hxx>
#include <services/frame.hxx>
#include <services/modulemanager.hxx>
@@ -67,7 +66,6 @@
#include <services/ContextChangeEventMultiplexer.hxx>
COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::URLTransformer ) else
IFFACTORY( ::framework::Desktop ) else
IFFACTORY( ::framework::Frame ) else
IFFACTORY( ::framework::JobExecutor ) else

View File

@@ -17,53 +17,66 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <services/urltransformer.hxx>
#include <threadhelp/resetableguard.hxx>
#include <services.h>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <tools/urlobj.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/svapp.hxx>
namespace framework{
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
using namespace ::osl ;
using namespace ::cppu ;
using namespace ::com::sun::star::uno ;
using namespace ::com::sun::star::lang ;
using namespace ::com::sun::star::util ;
using namespace ::osl;
using namespace ::cppu;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::util;
//*****************************************************************************************************************
// constructor
//*****************************************************************************************************************
URLTransformer::URLTransformer( const Reference< XMultiServiceFactory >& /*xFactory*/ )
namespace {
class URLTransformer : public ::cppu::WeakImplHelper2< css::util::XURLTransformer, css::lang::XServiceInfo>
{
// Safe impossible cases.
// Method not defined for all incoming parameter.
//SAL_WARN_IF( !xFactory.is(), "fwk", "URLTransformer::URLTransformer(): Invalid parameter detected!" );
}
public:
URLTransformer() {}
//*****************************************************************************************************************
// destructor
//*****************************************************************************************************************
URLTransformer::~URLTransformer()
{
}
virtual ~URLTransformer() {}
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException)
{
return OUString("com.sun.star.comp.framework.URLTransformer");
}
DEFINE_XSERVICEINFO_MULTISERVICE ( URLTransformer ,
OWeakObject ,
"com.sun.star.util.URLTransformer" ,
IMPLEMENTATIONNAME_URLTRANSFORMER
)
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException)
{
return cppu::supportsService(this, ServiceName);
}
DEFINE_INIT_SERVICE ( URLTransformer,
{
}
)
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException)
{
css::uno::Sequence< OUString > aRet(1);
aRet[0] = "com.sun.star.util.URLTransformer";
return aRet;
}
virtual sal_Bool SAL_CALL parseStrict( css::util::URL& aURL )
throw( css::uno::RuntimeException );
virtual sal_Bool SAL_CALL parseSmart( css::util::URL& aURL, const OUString& sSmartProtocol )
throw( css::uno::RuntimeException );
virtual sal_Bool SAL_CALL assemble( css::util::URL& aURL )
throw( css::uno::RuntimeException );
virtual OUString SAL_CALL getPresentation( const css::util::URL& aURL, sal_Bool bWithPassword )
throw( css::uno::RuntimeException );
};
namespace
{
@@ -325,6 +338,16 @@ OUString SAL_CALL URLTransformer::getPresentation( const URL& aURL
return OUString();
}
} // namespace framework
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_framework_URLTransformer_get_implementation(
css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{
rtl::Reference<URLTransformer> x(new URLTransformer());
x->acquire();
return static_cast<cppu::OWeakObject *>(x.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -121,7 +121,8 @@
<implementation name="com.sun.star.comp.framework.UIElementFactoryManager">
<service name="com.sun.star.ui.UIElementFactoryManager"/>
</implementation>
<implementation name="com.sun.star.comp.framework.URLTransformer">
<implementation name="com.sun.star.comp.framework.URLTransformer"
constructor="com_sun_star_comp_framework_URLTransformer_get_implementation">
<service name="com.sun.star.util.URLTransformer"/>
</implementation>
<implementation name="com.sun.star.comp.framework.WindowContentFactoryManager">