Kaydet (Commit) cc0d5df4 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

No need to have com.sun.star.comp.PPPOptimizer as a service

After de-extension-alization of Presentation Minimizer, it is important that its
UNO implementation names are different from the ones used by the extension (in
case the extension ever is installed as shared or per-user).  For
com.sun.star.comp.PPPOptimizer it appears to be easiest to not advertise this as
a service at all, but rather instantiate the object directly where used.  (For
com.sun.star.comp.PresentationMinimizerImp the necessary renaming had been done
in the previous commit already.)

Change-Id: I954b715f2d434cecf9abd2776b39c4ed3152c5ec
üst 2318ba0f
......@@ -10,9 +10,6 @@
<component xmlns="http://openoffice.org/2010/uno-components"
loader="com.sun.star.loader.SharedLibrary"
prefix="pptminimizer">
<implementation name="com.sun.star.comp.PPPOptimizerImp">
<service name="com.sun.star.comp.PPPOptimizer"/>
</implementation>
<implementation name="com.sun.star.comp.PresentationMinimizerImp">
<service name="com.sun.star.comp.PresentationMinimizer"/>
</implementation>
......
......@@ -19,6 +19,7 @@
#include "optimizerdialog.hxx"
#include "pppoptimizer.hxx"
#include "fileopendialog.hxx"
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
......@@ -589,11 +590,10 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
}
if ( bSuccessfullyExecuted )
{
Sequence< Any > aArgs( 1 );
aArgs[ 0 ] <<= mrOptimizerDialog.GetFrame();
Reference < XDispatch > xDispatch( mrOptimizerDialog.GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext(
OUString("com.sun.star.comp.PPPOptimizer"), aArgs, mrOptimizerDialog.GetComponentContext() ), UNO_QUERY );
Reference < XDispatch > xDispatch(
new PPPOptimizer(
mrOptimizerDialog.GetComponentContext(),
mrOptimizerDialog.GetFrame()));
URL aURL;
aURL.Protocol = OUString( "vnd.com.sun.star.comp.PPPOptimizer:" );
......@@ -607,8 +607,7 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
lArguments[ 2 ].Name = TKGet( TK_InformationDialog );
lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
if( xDispatch.is() )
xDispatch->dispatch( aURL, lArguments );
xDispatch->dispatch( aURL, lArguments );
mrOptimizerDialog.endExecute( bSuccessfullyExecuted );
}
......
......@@ -22,8 +22,6 @@
#include "impoptimizer.hxx"
#include <osl/file.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
using namespace ::rtl;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
......@@ -31,14 +29,15 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::beans;
#define SERVICE_NAME "com.sun.star.comp.PPPOptimizer"
// ----------------
// - PPPOptimizer -
// ----------------
PPPOptimizer::PPPOptimizer( const Reference< XComponentContext > &xContext ) :
mxContext( xContext )
PPPOptimizer::PPPOptimizer(
css::uno::Reference<css::uno::XComponentContext> const & xContext,
css::uno::Reference< css::frame::XFrame > const & xFrame):
mxContext( xContext ),
mxController( xFrame->getController() )
{
}
......@@ -48,44 +47,6 @@ PPPOptimizer::~PPPOptimizer()
{
}
// -----------------------------------------------------------------------------
// XInitialization
// -----------------------------------------------------------------------------
void SAL_CALL PPPOptimizer::initialize( const Sequence< Any >& aArguments )
throw ( Exception, RuntimeException )
{
if( aArguments.getLength() != 1 )
throw IllegalArgumentException();
Reference< XFrame > xFrame;
aArguments[ 0 ] >>= xFrame;
if ( xFrame.is() )
mxController = xFrame->getController();
}
// -----------------------------------------------------------------------------
// XServiceInfo
// -----------------------------------------------------------------------------
OUString SAL_CALL PPPOptimizer::getImplementationName()
throw ( RuntimeException )
{
return PPPOptimizer_getImplementationName();
}
sal_Bool SAL_CALL PPPOptimizer::supportsService( const OUString& rServiceName )
throw ( RuntimeException )
{
return rServiceName == SERVICE_NAME;
}
Sequence< OUString > SAL_CALL PPPOptimizer::getSupportedServiceNames()
throw ( RuntimeException )
{
return PPPOptimizer_getSupportedServiceNames();
}
// -----------------------------------------------------------------------------
// XDispatchProvider
// -----------------------------------------------------------------------------
......@@ -177,25 +138,4 @@ sal_Int64 PPPOptimizer::GetFileSize( const OUString& rURL )
return nFileSize;
}
// -----------------------------------------------------------------------------
OUString PPPOptimizer_getImplementationName()
{
return OUString( "com.sun.star.comp.PPPOptimizerImp" );
}
Sequence< OUString > PPPOptimizer_getSupportedServiceNames()
{
Sequence < OUString > aRet(1);
OUString* pArray = aRet.getArray();
pArray[0] = OUString ( SERVICE_NAME );
return aRet;
}
Reference< XInterface > PPPOptimizer_createInstance( const Reference< XComponentContext > & rSMgr )
throw( Exception )
{
return (cppu::OWeakObject*) new PPPOptimizer( rSMgr );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -20,22 +20,18 @@
#ifndef PPPOPTIMIZER_HXX
#define PPPOPTIMIZER_HXX
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase2.hxx>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/frame/XController.hpp>
// ----------------
// - PPPOptimizer -
// ----------------
class PPPOptimizer : public cppu::WeakImplHelper4<
com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo,
class PPPOptimizer : public cppu::WeakImplHelper2<
com::sun::star::frame::XDispatchProvider,
com::sun::star::frame::XDispatch >
{
......@@ -44,23 +40,11 @@ class PPPOptimizer : public cppu::WeakImplHelper4<
public:
PPPOptimizer( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext );
PPPOptimizer(
css::uno::Reference<css::uno::XComponentContext> const & xContext,
css::uno::Reference< css::frame::XFrame > const & xFrame);
virtual ~PPPOptimizer();
// XInitialization
void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
throw( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException );
// XServiceInfo
virtual OUString SAL_CALL getImplementationName()
throw( com::sun::star::uno::RuntimeException );
virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName )
throw( com::sun::star::uno::RuntimeException );
virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
throw( com::sun::star::uno::RuntimeException );
// XDispatchProvider
virtual com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(
const com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags )
......@@ -84,11 +68,6 @@ public:
static sal_Int64 GetFileSize( const OUString& rURL );
};
OUString PPPOptimizer_getImplementationName();
com::sun::star::uno::Sequence< OUString > PPPOptimizer_getSupportedServiceNames();
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > PPPOptimizer_createInstance( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rSMgr )
throw( com::sun::star::uno::Exception );
#endif // PPPOPTIMIZER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -22,7 +22,6 @@
#include <osl/mutex.hxx>
#include <osl/thread.h>
#include <cppuhelper/factory.hxx>
#include <pppoptimizer.hxx>
#include <pppoptimizerdialog.hxx>
using namespace ::rtl;
......@@ -43,15 +42,7 @@ extern "C"
if( pServiceManager )
{
Reference< XSingleComponentFactory > xFactory;
if( aImplName.equals( PPPOptimizer_getImplementationName() ) )
{
xFactory = createSingleComponentFactory(
PPPOptimizer_createInstance,
OUString::createFromAscii( pImplName ),
PPPOptimizer_getSupportedServiceNames() );
}
else if( aImplName.equals( PPPOptimizerDialog_getImplementationName() ) )
if( aImplName.equals( PPPOptimizerDialog_getImplementationName() ) )
{
xFactory = createSingleComponentFactory(
PPPOptimizerDialog_createInstance,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment