svt: Use constructor feature for Wizard.

Change-Id: I25e31c57c58e26e4de9d0ccc63ae1f6f0c86505b
This commit is contained in:
Matúš Kukan
2014-01-08 17:30:34 +01:00
parent 22c91244d4
commit d5524ff99c
4 changed files with 82 additions and 163 deletions

View File

@@ -27,7 +27,6 @@
#include <osl/diagnose.h>
#include <uno/mapping.hxx>
#include "hatchwindow.hxx"
#include "unowizard.hxx"
#include "comphelper/servicedecl.hxx"
@@ -51,20 +50,6 @@ extern sdecl::ServiceDecl const serviceDecl;
Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& ); \
}
namespace
{
static const struct ::cppu::ImplementationEntry s_aServiceEntries[] =
{
{
::svt::uno::Wizard::Create,
::svt::uno::Wizard::getImplementationName_static,
::svt::uno::Wizard::getSupportedServiceNames_static,
::cppu::createSingleComponentFactory, NULL, 0
},
{ 0, 0, 0, 0, 0, 0 }
};
}
DECLARE_CREATEINSTANCE_NAMESPACE( svt, OAddressBookSourceDialogUno )
extern "C"
@@ -98,11 +83,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory (
static_cast<css::lang::XMultiServiceFactory *>(_pServiceManager),
static_cast<css::registry::XRegistryKey *>(pRegistryKey),
unographic::serviceDecl );
if ( !pResult )
pResult = cppu::component_getFactoryHelper(pImplementationName,
_pServiceManager,
pRegistryKey,
s_aServiceEntries);
}
if ( xFactory.is() )

View File

@@ -1,108 +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_SVTOOLS_SOURCE_UNO_UNOWIZARD_HXX
#define INCLUDED_SVTOOLS_SOURCE_UNO_UNOWIZARD_HXX
#include "svtools/genericunodialog.hxx"
#include <com/sun/star/ui/dialogs/XWizard.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ui/dialogs/XWizardController.hpp>
#include <cppuhelper/implbase1.hxx>
//......................................................................................................................
namespace svt { namespace uno
{
//......................................................................................................................
//==================================================================================================================
//= Wizard - declaration
//==================================================================================================================
typedef ::cppu::ImplInheritanceHelper1 < ::svt::OGenericUnoDialog
, ::com::sun::star::ui::dialogs::XWizard
> Wizard_Base;
class Wizard;
typedef ::comphelper::OPropertyArrayUsageHelper< Wizard > Wizard_PBase;
class Wizard : public Wizard_Base
, public Wizard_PBase
{
public:
Wizard( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext );
// ::com::sun::star::lang::XServiceInfo - static version
static OUString SAL_CALL getImplementationName_static() throw(::com::sun::star::uno::RuntimeException);
static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static() throw(::com::sun::star::uno::RuntimeException);
static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext );
protected:
// ::com::sun::star::lang::XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
// ::com::sun::star::beans::XPropertySet
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
// OPropertyArrayUsageHelper
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
// ::com::sun::star::ui::dialogs::XWizard
virtual OUString SAL_CALL getHelpURL() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHelpURL( const OUString& _helpurl ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getDialogWindow() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardPage > SAL_CALL getCurrentPage( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL enableButton( ::sal_Int16 WizardButton, ::sal_Bool Enable ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setDefaultButton( ::sal_Int16 WizardButton ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL travelNext( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL travelPrevious( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL enablePage( ::sal_Int16 PageID, ::sal_Bool Enable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL updateTravelUI( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL advanceTo( ::sal_Int16 PageId ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL goBackTo( ::sal_Int16 PageId ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL activatePath( ::sal_Int16 PathIndex, ::sal_Bool Final ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException);
// ::com::sun::star::ui::dialogs::XExecutableDialog
virtual void SAL_CALL setTitle( const OUString& aTitle ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException);
// ::com::sun::star::lang::XInitialization
virtual 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);
protected:
~Wizard();
protected:
virtual Dialog* createDialog( Window* _pParent );
virtual void destroyDialog();
private:
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int16 > > m_aWizardSteps;
::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XWizardController > m_xController;
OUString m_sHelpURL;
};
//......................................................................................................................
} } // namespace svt::uno
//......................................................................................................................
#endif // INCLUDED_SVTOOLS_SOURCE_UNO_UNOWIZARD_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -18,26 +18,29 @@
*/
#include "../unowizard.hxx"
#include "wizardshell.hxx"
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
#include <com/sun/star/ui/dialogs/XWizard.hpp>
#include <com/sun/star/ui/dialogs/XWizardController.hpp>
#include <com/sun/star/ui/dialogs/WizardButton.hpp>
#include <cppuhelper/implbase1.hxx>
#include <svtools/genericunodialog.hxx>
#include <tools/diagnose_ex.h>
#include <rtl/ref.hxx>
#include <rtl/strbuf.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include <tools/urlobj.hxx>
//......................................................................................................................
namespace svt { namespace uno
{
//......................................................................................................................
using namespace ::com::sun::star;
using namespace ::svt::uno;
namespace {
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::XInterface;
@@ -85,10 +88,63 @@ namespace svt { namespace uno
}
}
//==================================================================================================================
//= Wizard - implementation
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
typedef ::cppu::ImplInheritanceHelper1 < ::svt::OGenericUnoDialog
, ui::dialogs::XWizard
> Wizard_Base;
class Wizard;
typedef ::comphelper::OPropertyArrayUsageHelper< Wizard > Wizard_PBase;
class Wizard : public Wizard_Base
, public Wizard_PBase
{
public:
Wizard( const uno::Reference< uno::XComponentContext >& i_rContext );
// lang::XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw(uno::RuntimeException);
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(uno::RuntimeException);
// beans::XPropertySet
virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(uno::RuntimeException);
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
// OPropertyArrayUsageHelper
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
// ui::dialogs::XWizard
virtual OUString SAL_CALL getHelpURL() throw (uno::RuntimeException);
virtual void SAL_CALL setHelpURL( const OUString& _helpurl ) throw (uno::RuntimeException);
virtual uno::Reference< awt::XWindow > SAL_CALL getDialogWindow() throw (uno::RuntimeException);
virtual uno::Reference< ui::dialogs::XWizardPage > SAL_CALL getCurrentPage( ) throw (uno::RuntimeException);
virtual void SAL_CALL enableButton( ::sal_Int16 WizardButton, ::sal_Bool Enable ) throw (uno::RuntimeException);
virtual void SAL_CALL setDefaultButton( ::sal_Int16 WizardButton ) throw (uno::RuntimeException);
virtual ::sal_Bool SAL_CALL travelNext( ) throw (uno::RuntimeException);
virtual ::sal_Bool SAL_CALL travelPrevious( ) throw (uno::RuntimeException);
virtual void SAL_CALL enablePage( ::sal_Int16 PageID, ::sal_Bool Enable ) throw (container::NoSuchElementException, util::InvalidStateException, uno::RuntimeException);
virtual void SAL_CALL updateTravelUI( ) throw (uno::RuntimeException);
virtual ::sal_Bool SAL_CALL advanceTo( ::sal_Int16 PageId ) throw (uno::RuntimeException);
virtual ::sal_Bool SAL_CALL goBackTo( ::sal_Int16 PageId ) throw (uno::RuntimeException);
virtual void SAL_CALL activatePath( ::sal_Int16 PathIndex, ::sal_Bool Final ) throw (container::NoSuchElementException, util::InvalidStateException, uno::RuntimeException);
// ui::dialogs::XExecutableDialog
virtual void SAL_CALL setTitle( const OUString& aTitle ) throw (uno::RuntimeException);
virtual ::sal_Int16 SAL_CALL execute( ) throw (uno::RuntimeException);
// lang::XInitialization
virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException);
protected:
~Wizard();
protected:
virtual Dialog* createDialog( Window* _pParent );
virtual void destroyDialog();
private:
uno::Sequence< uno::Sequence< sal_Int16 > > m_aWizardSteps;
uno::Reference< ui::dialogs::XWizardController > m_xController;
OUString m_sHelpURL;
};
Wizard::Wizard( const Reference< XComponentContext >& _rxContext )
:Wizard_Base( _rxContext )
{
@@ -107,12 +163,6 @@ namespace svt { namespace uno
}
}
//--------------------------------------------------------------------
Reference< XInterface > SAL_CALL Wizard::Create( const Reference< XComponentContext >& _rxContext )
{
return *(new Wizard( _rxContext ) );
}
//--------------------------------------------------------------------
namespace
{
@@ -235,30 +285,18 @@ namespace svt { namespace uno
Wizard_Base::destroyDialog();
}
//--------------------------------------------------------------------
OUString SAL_CALL Wizard::getImplementationName_static() throw(RuntimeException)
{
return OUString( "com.sun.star.comp.svtools.uno.Wizard" );
}
//--------------------------------------------------------------------
Sequence< OUString > SAL_CALL Wizard::getSupportedServiceNames_static() throw(RuntimeException)
{
Sequence< OUString > aServices(1);
aServices[0] = "com.sun.star.ui.dialogs.Wizard";
return aServices;
}
//--------------------------------------------------------------------
OUString SAL_CALL Wizard::getImplementationName() throw(RuntimeException)
{
return getImplementationName_static();
return OUString("com.sun.star.comp.svtools.uno.Wizard");
}
//--------------------------------------------------------------------
Sequence< OUString > SAL_CALL Wizard::getSupportedServiceNames() throw(RuntimeException)
{
return getSupportedServiceNames_static();
Sequence< OUString > aServices(1);
aServices[0] = "com.sun.star.ui.dialogs.Wizard";
return aServices;
}
//--------------------------------------------------------------------
@@ -457,8 +495,16 @@ namespace svt { namespace uno
return Wizard_Base::OGenericUnoDialog::execute();
}
//......................................................................................................................
} } // namespace svt::uno
//......................................................................................................................
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_svtools_uno_Wizard_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
rtl::Reference<Wizard> x(new Wizard(context));
x->acquire();
return static_cast<cppu::OWeakObject *>(x.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -30,7 +30,8 @@
<implementation name="com.sun.star.comp.svtools.OAddressBookSourceDialogUno">
<service name="com.sun.star.ui.AddressBookSourceDialog"/>
</implementation>
<implementation name="com.sun.star.comp.svtools.uno.Wizard">
<implementation name="com.sun.star.comp.svtools.uno.Wizard"
constructor="com_sun_star_comp_svtools_uno_Wizard_get_implementation">
<service name="com.sun.star.ui.dialogs.Wizard"/>
</implementation>
<implementation name="com.sun.star.graphic.GraphicObject">