diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-05-24 22:44:30 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-05-25 11:47:50 +0200 |
commit | 1b6678993c905df231147d55e4fc9a9b15406812 (patch) | |
tree | 200dd3911abf9dc99713ac0ec52e50a6a3a22252 /filter | |
parent | f6d39d7e2c64a6aec8c83943caf827a57f067335 (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
(cherry picked from commit e36f83d81c462e1a5959b160886e481a8d449494)
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/t602/t602filter.cxx | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx index 0d3c948e0996..4ef5b6deeecf 100644 --- a/filter/source/t602/t602filter.cxx +++ b/filter/source/t602/t602filter.cxx @@ -26,13 +26,11 @@ #include <cppuhelper/factory.hxx> #include <cppuhelper/bootstrap.hxx> #include <com/sun/star/awt/Toolkit.hpp> -#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/bridge/XUnoUrlResolver.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/awt/UnoControlDialog.hpp> #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XDialog.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> @@ -940,19 +938,27 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _prop->setPropertyValue(OUString::createFromAscii(_nam), any); #define _propGet(_prop,_nam) \ _prop->getPropertyValue(OUString::createFromAscii(_nam)); +#define _InstCtx(_path,_ctx)\ + rServiceManager->createInstanceWithContext(\ + OUString::createFromAscii(_path),_ctx); +#define _Inst(_path)\ + xMultiServiceFactory->createInstance(OUString::createFromAscii(_path) ); #define _Insert(_cont,_nam,_obj) \ any <<= _obj;\ _cont->insertByName( OUString::createFromAscii(_nam), any ); Reference < XComponentContext > rComponentContext = defaultBootstrap_InitialComponentContext(); Reference < XMultiComponentFactory > rServiceManager = rComponentContext->getServiceManager(); - Reference < XUnoControlDialogModel > rInstance = UnoControlDialogModel::create(rComponentContext ); + Reference < XInterface > rInstance = _InstCtx("com.sun.star.awt.UnoControlDialogModel", rComponentContext ); - rInstance->setPositionX(100); - rInstance->setPositionY(100); - rInstance->setWidth(130); - rInstance->setHeight(90); - rInstance->setTitle(getResStr(T602FILTER_STR_IMPORT_DIALOG_TITLE)); + Reference <XMultiServiceFactory> xMultiServiceFactory (rInstance,UNO_QUERY); + + Reference < XPropertySet > xPSetDialog( rInstance, UNO_QUERY ); + _propInt(xPSetDialog,"PositionX",100); + _propInt(xPSetDialog,"PositionY",100); + _propInt(xPSetDialog,"Width",130); + _propInt(xPSetDialog,"Height",90); + _propStringFromResId(xPSetDialog,"Title", T602FILTER_STR_IMPORT_DIALOG_TITLE); #define T602DLG_OK_BUTTON "ok_button" #define T602DLG_CANCEL_BUTTON "cancel_button" @@ -962,7 +968,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() #define T602DLG_REFORMAT_CB "reformat_cb" #define T602DLG_CODE_TXT "code_txt" - Reference < XInterface > TextModel = rInstance->createInstance("com.sun.star.awt.UnoControlFixedTextModel"); + Reference < XInterface > TextModel = _Inst("com.sun.star.awt.UnoControlFixedTextModel"); Reference < XPropertySet > xPSetText( TextModel, UNO_QUERY ); _propInt(xPSetText,"PositionX",10); _propInt(xPSetText,"PositionY",8); @@ -971,7 +977,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _propString(xPSetText,"Name",T602DLG_CODE_TXT); _propStringFromResId(xPSetText,"Label",T602FILTER_STR_ENCODING_LABEL); - Reference < XInterface > ListBoxModel = rInstance->createInstance("com.sun.star.awt.UnoControlListBoxModel"); + Reference < XInterface > ListBoxModel = _Inst("com.sun.star.awt.UnoControlListBoxModel"); Reference < XPropertySet > xPSetCodeLB( ListBoxModel, UNO_QUERY ); _propInt(xPSetCodeLB,"PositionX",40); _propInt(xPSetCodeLB,"PositionY",5); @@ -995,7 +1001,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() any <<= shr; xPSetCodeLB->setPropertyValue(OUString( "SelectedItems" ), any); - Reference < XInterface > AzbCheckBoxModel = rInstance->createInstance("com.sun.star.awt.UnoControlCheckBoxModel"); + Reference < XInterface > AzbCheckBoxModel = _Inst("com.sun.star.awt.UnoControlCheckBoxModel"); Reference < XPropertySet > xPSetAzbukaCB( AzbCheckBoxModel, UNO_QUERY ); _propInt(xPSetAzbukaCB,"PositionX",10); _propInt(xPSetAzbukaCB,"PositionY",25); @@ -1006,7 +1012,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _propStringFromResId(xPSetAzbukaCB,"Label",T602FILTER_STR_CYRILLIC_MODE); _propShort(xPSetAzbukaCB,"State",ini.ruscode); - Reference < XInterface > RefCheckBoxModel = rInstance->createInstance("com.sun.star.awt.UnoControlCheckBoxModel"); + Reference < XInterface > RefCheckBoxModel = _Inst("com.sun.star.awt.UnoControlCheckBoxModel"); Reference < XPropertySet > xPSetRefCB( RefCheckBoxModel, UNO_QUERY ); _propInt(xPSetRefCB,"PositionX",10); _propInt(xPSetRefCB,"PositionY",40); @@ -1017,7 +1023,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _propStringFromResId(xPSetRefCB,"Label",T602FILTER_STR_REFORMAT_TEXT); _propShort(xPSetRefCB,"State",ini.reformatpars); - Reference < XInterface > CommCheckBoxModel = rInstance->createInstance("com.sun.star.awt.UnoControlCheckBoxModel"); + Reference < XInterface > CommCheckBoxModel = _Inst("com.sun.star.awt.UnoControlCheckBoxModel"); Reference < XPropertySet > xPSetCommCB( CommCheckBoxModel, UNO_QUERY ); _propInt(xPSetCommCB,"PositionX",10); _propInt(xPSetCommCB,"PositionY",55); @@ -1028,7 +1034,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _propStringFromResId(xPSetCommCB,"Label",T602FILTER_STR_DOT_COMMANDS); _propShort(xPSetCommCB,"State",ini.showcomm); - Reference < XInterface > CancelButtonModel = rInstance->createInstance("com.sun.star.awt.UnoControlButtonModel"); + Reference < XInterface > CancelButtonModel = _Inst("com.sun.star.awt.UnoControlButtonModel"); Reference < XPropertySet > xPSetCancelButton( CancelButtonModel, UNO_QUERY ); _propInt(xPSetCancelButton,"PositionX",10); _propInt(xPSetCancelButton,"PositionY",70); @@ -1039,7 +1045,7 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _propShort(xPSetCancelButton,"PushButtonType",2); _propStringFromResId(xPSetCancelButton,"Label",T602FILTER_STR_CANCEL_BUTTON); - Reference < XInterface > OkButtonModel = rInstance->createInstance("com.sun.star.awt.UnoControlButtonModel"); + Reference < XInterface > OkButtonModel = _Inst("com.sun.star.awt.UnoControlButtonModel"); Reference < XPropertySet > xPSetOkButton( OkButtonModel, UNO_QUERY ); _propInt(xPSetOkButton,"PositionX",70); _propInt(xPSetOkButton,"PositionY",70); @@ -1061,18 +1067,31 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() _Insert(xNameCont, T602DLG_CODE_LB, ListBoxModel); _Insert(xNameCont, T602DLG_CODE_TXT, TextModel); - Reference< XUnoControlDialog > dialog = UnoControlDialog::create(rComponentContext); + Reference< XInterface > dialog = _InstCtx("com.sun.star.awt.UnoControlDialog",rComponentContext); + Reference < XControl > xControl (dialog,UNO_QUERY); Reference < XControlModel > xControlModel (rInstance,UNO_QUERY); - dialog->setModel( xControlModel ); + if(!xControl.is()) + return sal_False; + + xControl->setModel( xControlModel ); Reference < XToolkit > xToolkit = Toolkit::create( rComponentContext ); + Reference < XWindow > xWindow (xControl,UNO_QUERY); + + if(!xWindow.is()) + return sal_False; - dialog->setVisible( false ); - dialog->createPeer( xToolkit, NULL ); + xWindow->setVisible( false ); + xControl->createPeer( xToolkit, NULL ); - ret = ( dialog->execute() != 0 ); + Reference < XDialog > xDialog (dialog,UNO_QUERY); + + if(!xDialog.is()) + return sal_False; + + ret = ( xDialog->execute() != 0 ); if ( ret ) { sal_Int16 tt = 0; @@ -1091,7 +1110,9 @@ sal_Bool T602ImportFilterDialog::OptionsDlg() } } - Reference<XControl>(dialog)->dispose(); + Reference < XComponent > xComponent (dialog,UNO_QUERY); + + xComponent->dispose(); return ret; } |