diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-21 10:33:23 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-21 15:48:12 +0100 |
commit | 12efe34abb984ac37abae59ccac83a4f86a27e77 (patch) | |
tree | d0b72087fe2911e9ce73a31b955582186f2ca7d8 /svtools | |
parent | 718c82d1de44d2d7c16e4299b61171b72186f50b (diff) |
support both vcl and weld in genericunodialog for interim
Change-Id: Ife85dd7a4bd27260514b390ca3928152db0d688f
Reviewed-on: https://gerrit.libreoffice.org/51699
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/uno/addrtempuno.cxx | 12 | ||||
-rw-r--r-- | svtools/source/uno/genericunodialog.cxx | 50 | ||||
-rw-r--r-- | svtools/source/uno/wizard/unowizard.cxx | 44 |
3 files changed, 55 insertions, 51 deletions
diff --git a/svtools/source/uno/addrtempuno.cxx b/svtools/source/uno/addrtempuno.cxx index e9817e217fac..ef1af102dbd6 100644 --- a/svtools/source/uno/addrtempuno.cxx +++ b/svtools/source/uno/addrtempuno.cxx @@ -71,7 +71,7 @@ namespace { protected: // OGenericUnoDialog overridables - virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) override; + virtual svt::OGenericUnoDialog::Dialog createDialog(vcl::Window* _pParent) override; virtual void implInitialize(const css::uno::Any& _rValue) override; @@ -132,8 +132,8 @@ namespace { OGenericUnoDialog::executedDialog(_nExecutionResult); if ( _nExecutionResult ) - if ( m_pDialog ) - static_cast< AddressBookSourceDialog* >( m_pDialog.get() )->getFieldMapping( m_aAliases ); + if ( m_aDialog ) + static_cast< AddressBookSourceDialog* >( m_aDialog.m_xVclDialog.get() )->getFieldMapping( m_aAliases ); } void SAL_CALL OAddressBookSourceDialogUno::initialize(const Sequence< Any >& rArguments) @@ -199,12 +199,12 @@ namespace { } - VclPtr<Dialog> OAddressBookSourceDialogUno::createDialog(vcl::Window* _pParent) + svt::OGenericUnoDialog::Dialog OAddressBookSourceDialogUno::createDialog(vcl::Window* _pParent) { if ( m_xDataSource.is() && !m_sTable.isEmpty() ) - return VclPtr<AddressBookSourceDialog>::Create(_pParent, m_aContext, m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases ); + return svt::OGenericUnoDialog::Dialog(VclPtr<AddressBookSourceDialog>::Create(_pParent, m_aContext, m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases)); else - return VclPtr<AddressBookSourceDialog>::Create( _pParent, m_aContext ); + return svt::OGenericUnoDialog::Dialog(VclPtr<AddressBookSourceDialog>::Create(_pParent, m_aContext)); } } diff --git a/svtools/source/uno/genericunodialog.cxx b/svtools/source/uno/genericunodialog.cxx index f6446e76ec62..c28af0833a45 100644 --- a/svtools/source/uno/genericunodialog.cxx +++ b/svtools/source/uno/genericunodialog.cxx @@ -47,7 +47,6 @@ namespace svt OGenericUnoDialog::OGenericUnoDialog(const Reference< XComponentContext >& _rxContext) :OPropertyContainer(GetBroadcastHelper()) - ,m_pDialog(nullptr) ,m_bExecuting(false) ,m_bTitleAmbiguous(true) ,m_bInitialized( false ) @@ -63,11 +62,11 @@ OGenericUnoDialog::OGenericUnoDialog(const Reference< XComponentContext >& _rxCo OGenericUnoDialog::~OGenericUnoDialog() { - if ( m_pDialog ) + if (m_aDialog) { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - if ( m_pDialog ) + if (m_aDialog) destroyDialog(); } } @@ -113,8 +112,8 @@ void OGenericUnoDialog::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, con // from now on m_sTitle is valid m_bTitleAmbiguous = false; - if (m_pDialog) - m_pDialog->SetText(m_sTitle); + if (m_aDialog) + m_aDialog.set_title(m_sTitle); } } @@ -162,7 +161,7 @@ void SAL_CALL OGenericUnoDialog::setTitle( const OUString& _rTitle ) bool OGenericUnoDialog::impl_ensureDialog_lck() { - if ( m_pDialog ) + if (m_aDialog) return true; // get the parameters for the dialog from the current settings @@ -176,30 +175,32 @@ bool OGenericUnoDialog::impl_ensureDialog_lck() // the title OUString sTitle = m_sTitle; - VclPtr<Dialog> pDialog = createDialog( pParent ); - OSL_ENSURE( pDialog, "OGenericUnoDialog::impl_ensureDialog_lck: createDialog returned nonsense!" ); - if ( !pDialog ) + OGenericUnoDialog::Dialog aDialog(createDialog(pParent)); + OSL_ENSURE(aDialog, "OGenericUnoDialog::impl_ensureDialog_lck: createDialog returned nonsense!"); + if (!aDialog) return false; // do some initialisations - if ( !m_bTitleAmbiguous ) - pDialog->SetText( sTitle ); + if (!m_bTitleAmbiguous) + aDialog.set_title(sTitle); - // be notified when the dialog is killed by somebody else #i65958# - pDialog->AddEventListener( LINK( this, OGenericUnoDialog, OnDialogDying ) ); + if (aDialog.m_xVclDialog) + { + // be notified when the dialog is killed by somebody else #i65958# + aDialog.m_xVclDialog->AddEventListener(LINK(this, OGenericUnoDialog, OnDialogDying)); + } - m_pDialog = pDialog; + m_aDialog = std::move(aDialog); return true; } - -sal_Int16 SAL_CALL OGenericUnoDialog::execute( ) +sal_Int16 SAL_CALL OGenericUnoDialog::execute() { // both creation and execution of the dialog must be guarded with the SolarMutex, so be generous here SolarMutexGuard aSolarGuard; - Dialog* pDialogToExecute = nullptr; + ::Dialog* pVclDialogToExecute = nullptr; // create the dialog, if necessary { UnoDialogEntryGuard aGuard( *this ); @@ -215,13 +216,15 @@ sal_Int16 SAL_CALL OGenericUnoDialog::execute( ) if ( !impl_ensureDialog_lck() ) return 0; - pDialogToExecute = m_pDialog; + pVclDialogToExecute = m_aDialog.m_xVclDialog; } // start execution sal_Int16 nReturn(0); - if ( pDialogToExecute ) - nReturn = pDialogToExecute->Execute(); + if (pVclDialogToExecute) + nReturn = pVclDialogToExecute->Execute(); + else if (m_aDialog.m_xWeldDialog) + nReturn = m_aDialog.m_xWeldDialog->run(); { ::osl::MutexGuard aGuard(m_aMutex); @@ -275,15 +278,16 @@ void SAL_CALL OGenericUnoDialog::initialize( const Sequence< Any >& aArguments ) void OGenericUnoDialog::destroyDialog() { SolarMutexGuard aSolarGuard; - m_pDialog.disposeAndClear(); + m_aDialog.m_xVclDialog.disposeAndClear(); + m_aDialog.m_xWeldDialog.reset(); } IMPL_LINK( OGenericUnoDialog, OnDialogDying, VclWindowEvent&, _rEvent, void ) { - OSL_ENSURE( _rEvent.GetWindow() == m_pDialog, "OGenericUnoDialog::OnDialogDying: where does this come from?" ); + OSL_ENSURE( _rEvent.GetWindow() == m_aDialog.m_xVclDialog, "OGenericUnoDialog::OnDialogDying: where does this come from?" ); if ( _rEvent.GetId() == VclEventId::ObjectDying ) - m_pDialog = nullptr; + m_aDialog.m_xVclDialog = nullptr; } diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx index 9906d34e5ffe..103b39c9aff1 100644 --- a/svtools/source/uno/wizard/unowizard.cxx +++ b/svtools/source/uno/wizard/unowizard.cxx @@ -130,7 +130,7 @@ namespace { virtual ~Wizard() override; protected: - virtual VclPtr<Dialog> createDialog( vcl::Window* _pParent ) override; + virtual OGenericUnoDialog::Dialog createDialog(vcl::Window* _pParent) override; private: css::uno::Sequence< css::uno::Sequence< sal_Int16 > > m_aWizardSteps; @@ -157,12 +157,12 @@ namespace { Wizard::~Wizard() { - if ( m_pDialog ) + if (m_aDialog) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( m_pDialog ) + if (m_aDialog) { - m_sHelpURL = lcl_getHelpURL( m_pDialog->GetHelpId() ); + m_sHelpURL = lcl_getHelpURL(m_aDialog.get_help_id()); destroyDialog(); } } @@ -251,12 +251,12 @@ namespace { return OUStringToOString( _rHelpURL, RTL_TEXTENCODING_UTF8 ); } - VclPtr<Dialog> Wizard::createDialog( vcl::Window* i_pParent ) + svt::OGenericUnoDialog::Dialog Wizard::createDialog( vcl::Window* i_pParent ) { VclPtrInstance<WizardShell> pDialog( i_pParent, m_xController, m_aWizardSteps ); pDialog->SetHelpId( lcl_getHelpId( m_sHelpURL ) ); pDialog->setTitleBase( m_sTitle ); - return pDialog.get(); + return OGenericUnoDialog::Dialog(pDialog); } OUString SAL_CALL Wizard::getImplementationName() @@ -297,10 +297,10 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - if ( !m_pDialog ) + if (!m_aDialog) return m_sHelpURL; - return lcl_getHelpURL( m_pDialog->GetHelpId() ); + return lcl_getHelpURL(m_aDialog.get_help_id()); } @@ -309,10 +309,10 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - if ( !m_pDialog ) + if (!m_aDialog) m_sHelpURL = i_HelpURL; else - m_pDialog->SetHelpId( lcl_getHelpId( i_HelpURL ) ); + m_aDialog.set_help_id(lcl_getHelpId(i_HelpURL)); } @@ -321,8 +321,8 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - ENSURE_OR_RETURN( m_pDialog, "Wizard::getDialogWindow: illegal call (execution did not start, yet)!", nullptr ); - return Reference< XWindow >( m_pDialog->GetComponentInterface(), UNO_QUERY ); + ENSURE_OR_RETURN( m_aDialog.m_xVclDialog, "Wizard::getDialogWindow: illegal call (execution did not start, yet)!", nullptr ); + return Reference< XWindow >( m_aDialog.m_xVclDialog->GetComponentInterface(), UNO_QUERY ); } @@ -331,7 +331,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::enableButtons: invalid dialog implementation!" ); pWizardImpl->enableButtons( lcl_convertWizardButtonToWZB( i_WizardButton ), i_Enable ); @@ -343,7 +343,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::setDefaultButton: invalid dialog implementation!" ); pWizardImpl->defaultButton( lcl_convertWizardButtonToWZB( i_WizardButton ) ); @@ -355,7 +355,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::travelNext: invalid dialog implementation!" ); return pWizardImpl->travelNext(); @@ -367,7 +367,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::travelPrevious: invalid dialog implementation!" ); return pWizardImpl->travelPrevious(); @@ -379,7 +379,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::enablePage: invalid dialog implementation!" ); if ( !pWizardImpl->knowsPage( i_PageID ) ) @@ -397,7 +397,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::updateTravelUI: invalid dialog implementation!" ); pWizardImpl->updateTravelUI(); @@ -409,7 +409,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::advanceTo: invalid dialog implementation!" ); return pWizardImpl->advanceTo( i_PageId ); @@ -421,7 +421,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::goBackTo: invalid dialog implementation!" ); return pWizardImpl->goBackTo( i_PageId ); @@ -433,7 +433,7 @@ namespace { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN( pWizardImpl, "Wizard::getCurrentPage: invalid dialog implementation!", Reference< XWizardPage >() ); return pWizardImpl->getCurrentWizardPage(); @@ -448,7 +448,7 @@ namespace { if ( ( i_PathIndex < 0 ) || ( i_PathIndex >= m_aWizardSteps.getLength() ) ) throw NoSuchElementException( OUString(), *this ); - WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog.get() ); + WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_aDialog.m_xVclDialog.get() ); ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::activatePath: invalid dialog implementation!" ); pWizardImpl->activatePath( i_PathIndex, i_Final ); |