summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-05-24 22:44:30 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-05-25 11:45:47 +0200
commite36f83d81c462e1a5959b160886e481a8d449494 (patch)
tree32dcfbb76d86a0f044ae4f564b6eec097da61d60 /scripting
parentaaff3ae833f1180a17b9738a7825a780bea64a79 (diff)
Revert "fdo#46808, Convert awt::UnoControlDialogModel to new style"
This reverts commit 6c61b20a8d4a6dcac28801cde82a211fb7e30654. As discussed at <http://lists.freedesktop.org/archives/libreoffice/2013-May/052449.html> "Re: fdo#46808, Convert awt::UnoControlDialogModel to new style problem" why the odd change in 2e2a4827ce6708f0e8677dba9cc92e1479a44086 "scripting: get CreateUnoDialog() work again" appears to fix things again: The problem is that the implementation of the css.awt.UnoControlDialogModel involves UNO aggregation (IMPL_CREATE_INSTANCE_WITH_GEOMETRY(UnoControlDialogModel) in toolkit/soruce/helper/registerservices.cxx creating a OGeometryControlModel<UnoControlDialogModel> instance that aggregates a UnoControlDialogModel instance). That means that queryInterface can return a reference to something that is technically a different object, and that's what's happening here, and explains why calling setPropertyValue in two different ways on what logically appears to be a single object can end up calling two different implementations (of two different physical objects). (UNO aggregation is known to be broken and should not be used. Nevertheless, there's still code that does---code that is a horrible mess and hard to clean up.) That all this worked as intended in the past is just sheer luck, but any way of substantially touching it is asking for trouble. I'm going to revert 6c61b20a8d4a6dcac28801cde82a211fb7e30654 again. I wasn't able to revert without also reverting be50ad28f5bbdaeff527f646481ce263843c2401 "fdo#46808, Convert awt::XUnoControlDialog to new style," as the two were tightly dependant. Also reverts all the follow-up fixes cb4b6dde8fda2a5848e11063028bf44d72f85431 "-Werror,-Wuninitialized" (sans the const-ness fix in UpdateHandler::insertControlModel), 697a007c61b9cabceb9767fad87cd5822b300452 "Fix exception specifications," 2ce6828bbbf6ba181bb2276adeec279e74151ef6 "fix awt::UnoControlModelDialog crash," and 2e2a4827ce6708f0e8677dba9cc92e1479a44086 "scripting: get CreateUnoDialog() work again." Conflicts: basctl/source/dlged/dlged.cxx filter/source/t602/t602filter.cxx xmlscript/test/imexp.cxx Change-Id: I5d133468062f3ca36300db52fbd699be1ac72998
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/dlgprov/DialogModelProvider.cxx9
-rw-r--r--scripting/source/dlgprov/DialogModelProvider.hxx7
-rw-r--r--scripting/source/dlgprov/dlgprov.cxx102
-rw-r--r--scripting/source/dlgprov/dlgprov.hxx32
4 files changed, 85 insertions, 65 deletions
diff --git a/scripting/source/dlgprov/DialogModelProvider.cxx b/scripting/source/dlgprov/DialogModelProvider.cxx
index b7b5de3da34e..aee0a9a16ec5 100644
--- a/scripting/source/dlgprov/DialogModelProvider.cxx
+++ b/scripting/source/dlgprov/DialogModelProvider.cxx
@@ -76,9 +76,12 @@ void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any
if ( xInput.is() )
{
xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL);
+ Any aDialogSourceURLAny;
+ aDialogSourceURLAny <<= sURL;
Reference< frame::XModel > xModel;
- m_xDialogModel = dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, sURL );
+ m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW);
+ m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW);
}
}
catch( Exception& )
@@ -132,14 +135,14 @@ void SAL_CALL DialogModelProvider::removeByName(const OUString & aName) throw (c
}
uno::Reference< beans::XPropertySetInfo > SAL_CALL DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException)
{
- return m_xDialogModel->getPropertySetInfo();
+ return m_xDialogModelProp->getPropertySetInfo();
}
void SAL_CALL DialogModelProvider::setPropertyValue( const OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
{
}
uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
- return m_xDialogModel->getPropertyValue(PropertyName);
+ return m_xDialogModelProp->getPropertyValue(PropertyName);
}
void SAL_CALL DialogModelProvider::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
diff --git a/scripting/source/dlgprov/DialogModelProvider.hxx b/scripting/source/dlgprov/DialogModelProvider.hxx
index b104614948c5..4d9256a35f14 100644
--- a/scripting/source/dlgprov/DialogModelProvider.hxx
+++ b/scripting/source/dlgprov/DialogModelProvider.hxx
@@ -23,8 +23,6 @@
#include "com/sun/star/container/XNameContainer.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/awt/XUnoControlDialogModel.hpp"
-
/// anonymous implementation namespace
namespace dlgprov{
@@ -77,8 +75,9 @@ private:
// destructor is private and will be called indirectly by the release call virtual ~DialogModelProvider() {}
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
- css::uno::Reference< css::awt::XUnoControlDialogModel> m_xDialogModel;
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::container::XNameContainer> m_xDialogModel;
+ css::uno::Reference< css::beans::XPropertySet> m_xDialogModelProp;
};
} // closing anonymous implementation namespace
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index 2d96b9d2ff74..86c792774156 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -21,8 +21,6 @@
#include "DialogModelProvider.hxx"
#include "dlgprov.hxx"
#include "dlgevtatt.hxx"
-#include <com/sun/star/awt/UnoControlDialog.hpp>
-#include <com/sun/star/awt/UnoControlDialogModel.hpp>
#include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/awt/XControlContainer.hpp>
#include <com/sun/star/awt/XWindowPeer.hpp>
@@ -122,20 +120,23 @@ static OUString aResourceResolverPropName("ResourceResolver");
}
return xStringResourceManager;
}
- static Reference< XUnoControlDialogModel > lcl_createControlModel(const Reference< XComponentContext >& i_xContext)
+ Reference< container::XNameContainer > lcl_createControlModel(const Reference< XComponentContext >& i_xContext)
{
- Reference< XUnoControlDialogModel > xControlModel = UnoControlDialogModel::create( i_xContext );
+ Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_QUERY_THROW );
+ Reference< container::XNameContainer > xControlModel( xSMgr_->createInstanceWithContext( OUString( "com.sun.star.awt.UnoControlDialogModel" ), i_xContext ), UNO_QUERY_THROW );
return xControlModel;
}
- Reference< XUnoControlDialogModel > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext,
+ Reference< container::XNameContainer > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext,
const Reference< io::XInputStream >& xInput,
const Reference< frame::XModel >& xModel,
const Reference< resource::XStringResourceManager >& xStringResourceManager,
- const OUString& aDialogSourceURL) throw ( Exception )
+ const Any &aDialogSourceURL) throw ( Exception )
{
- Reference< XUnoControlDialogModel > xDialogModel( lcl_createControlModel(i_xContext) );
+ Reference< container::XNameContainer > xDialogModel( lcl_createControlModel(i_xContext) );
- xDialogModel->setDialogSourceURL( aDialogSourceURL );
+ OUString aDlgSrcUrlPropName( "DialogSourceURL" );
+ Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY );
+ xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL );
// #TODO we really need to detect the source of the Dialog, is it
// the dialog. E.g. if the dialog was created from basic ( then we just
@@ -254,15 +255,15 @@ static OUString aResourceResolverPropName("ResourceResolver");
return xStringResourceManager;
}
- Reference< XUnoControlDialogModel > DialogProviderImpl::createDialogModel(
+ Reference< container::XNameContainer > DialogProviderImpl::createDialogModel(
const Reference< io::XInputStream >& xInput,
const Reference< resource::XStringResourceManager >& xStringResourceManager,
- const OUString &aDialogSourceURL) throw ( Exception )
+ const Any &aDialogSourceURL) throw ( Exception )
{
return lcl_createDialogModel(m_xContext,xInput,m_xModel,xStringResourceManager,aDialogSourceURL);
}
- Reference< XUnoControlDialogModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception )
+ Reference< XControlModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception )
{
if ( !m_BasicInfo.get() )
// shouln't get here
@@ -270,10 +271,13 @@ static OUString aResourceResolverPropName("ResourceResolver");
Reference< resource::XStringResourceManager > xStringResourceManager = getStringResourceFromDialogLibrary( m_BasicInfo->mxDlgLib );
OUString aURL("" );
- return createDialogModel( m_BasicInfo->mxInput, xStringResourceManager, aURL );
+ Any aDialogSourceURL;
+ aDialogSourceURL <<= aURL;
+ Reference< XControlModel > xCtrlModel( createDialogModel( m_BasicInfo->mxInput, xStringResourceManager, aDialogSourceURL ), UNO_QUERY_THROW );
+ return xCtrlModel;
}
- Reference< XUnoControlDialogModel > DialogProviderImpl::createDialogModel( const OUString& sURL )
+ Reference< XControlModel > DialogProviderImpl::createDialogModel( const OUString& sURL )
{
OUString aURL( sURL );
@@ -443,7 +447,7 @@ static OUString aResourceResolverPropName("ResourceResolver");
}
// import dialog model
- Reference< XUnoControlDialogModel > xCtrlModel;
+ Reference< XControlModel > xCtrlModel;
if ( xInput.is() && m_xContext.is() )
{
Reference< resource::XStringResourceManager > xStringResourceManager;
@@ -456,51 +460,67 @@ static OUString aResourceResolverPropName("ResourceResolver");
xStringResourceManager = getStringResourceFromDialogLibrary( xDialogLib );
}
- xCtrlModel = createDialogModel( xInput , xStringResourceManager, aURL );
+ Any aDialogSourceURLAny;
+ aDialogSourceURLAny <<= aURL;
+
+ Reference< container::XNameContainer > xDialogModel( createDialogModel( xInput , xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW);
+
+ xCtrlModel = Reference< XControlModel >( xDialogModel, UNO_QUERY );
}
return xCtrlModel;
}
// -----------------------------------------------------------------------------
- Reference< XUnoControlDialog > DialogProviderImpl::createDialogControl
+ Reference< XControl > DialogProviderImpl::createDialogControl
( const Reference< XControlModel >& rxDialogModel, const Reference< XWindowPeer >& xParent )
{
OSL_ENSURE( rxDialogModel.is(), "DialogProviderImpl::getDialogControl: no dialog model" );
- Reference< XUnoControlDialog > xDialogControl;
+ Reference< XControl > xDialogControl;
if ( m_xContext.is() )
{
- xDialogControl = UnoControlDialog::create( m_xContext );
-
- // set the model
- if ( rxDialogModel.is() )
- xDialogControl->setModel( rxDialogModel );
+ Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
- // set visible
- xDialogControl->setVisible( sal_False );
-
- // get the parent of the dialog control
- Reference< XWindowPeer > xPeer;
- if( xParent.is() )
- {
- xPeer = xParent;
- }
- else if ( m_xModel.is() )
+ if ( xSMgr.is() )
{
- Reference< frame::XController > xController( m_xModel->getCurrentController(), UNO_QUERY );
- if ( xController.is() )
+ xDialogControl = Reference< XControl >( xSMgr->createInstanceWithContext(
+ OUString( "com.sun.star.awt.UnoControlDialog" ), m_xContext ), UNO_QUERY );
+
+ if ( xDialogControl.is() )
{
- Reference< frame::XFrame > xFrame( xController->getFrame(), UNO_QUERY );
- if ( xFrame.is() )
- xPeer = Reference< XWindowPeer>( xFrame->getContainerWindow(), UNO_QUERY );
+ // set the model
+ if ( rxDialogModel.is() )
+ xDialogControl->setModel( rxDialogModel );
+
+ // set visible
+ Reference< XWindow > xW( xDialogControl, UNO_QUERY );
+ if ( xW.is() )
+ xW->setVisible( sal_False );
+
+ // get the parent of the dialog control
+ Reference< XWindowPeer > xPeer;
+ if( xParent.is() )
+ {
+ xPeer = xParent;
+ }
+ else if ( m_xModel.is() )
+ {
+ Reference< frame::XController > xController( m_xModel->getCurrentController(), UNO_QUERY );
+ if ( xController.is() )
+ {
+ Reference< frame::XFrame > xFrame( xController->getFrame(), UNO_QUERY );
+ if ( xFrame.is() )
+ xPeer = Reference< XWindowPeer>( xFrame->getContainerWindow(), UNO_QUERY );
+ }
+ }
+
+ // create a peer
+ Reference< XToolkit> xToolkit( Toolkit::create( m_xContext ), UNO_QUERY_THROW );
+ xDialogControl->createPeer( xToolkit, xPeer );
}
}
-
- // create a peer
- Reference< XToolkit> xToolkit( Toolkit::create( m_xContext ), UNO_QUERY_THROW );
- xDialogControl->createPeer( xToolkit, xPeer );
}
return xDialogControl;
diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx
index 515f25a4d3bd..651edfa32cb0 100644
--- a/scripting/source/dlgprov/dlgprov.hxx
+++ b/scripting/source/dlgprov/dlgprov.hxx
@@ -21,20 +21,18 @@
#define SCRIPTING_DLGPROV_HXX
#include <com/sun/star/awt/XControl.hpp>
-#include <com/sun/star/awt/XContainerWindowProvider.hpp>
#include <com/sun/star/awt/XDialog.hpp>
#include <com/sun/star/awt/XDialogProvider2.hpp>
-#include <com/sun/star/awt/XUnoControlDialog.hpp>
-#include <com/sun/star/awt/XUnoControlDialogModel.hpp>
-#include <com/sun/star/beans/XIntrospectionAccess.hpp>
-#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/awt/XContainerWindowProvider.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/resource/XStringResourceManager.hpp>
#include <com/sun/star/script/XScriptEventsAttacher.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/resource/XStringResourceManager.hpp>
#include <cppuhelper/implbase4.hxx>
#include <osl/mutex.hxx>
@@ -55,14 +53,14 @@ namespace dlgprov
// =============================================================================
// class DialogProviderImpl
// =============================================================================
- ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const OUString& i_sURL);;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > lcl_createDialogModel(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext);
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const OUString& i_sURL);
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel,
const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager,
- const OUString& aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
+ const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
typedef ::cppu::WeakImplHelper4<
::com::sun::star::lang::XServiceInfo,
@@ -82,11 +80,11 @@ namespace dlgprov
std::auto_ptr< BasicRTLParams > m_BasicInfo;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
- OUString msDialogLibName;
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > createDialogModel( const OUString& sURL );
+ OUString msDialogLibName;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModel( const OUString& sURL );
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialog > createDialogControl(
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > createDialogControl(
const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxDialogModel,
const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent );
@@ -97,11 +95,11 @@ namespace dlgprov
::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > inspectHandler(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler );
// helper methods
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > createDialogModel(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createDialogModel(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager,
- const OUString &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception );
+ const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception );
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception );
// XDialogProvider / XDialogProvider2 impl method
virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XControl > SAL_CALL createDialogImpl(