summaryrefslogtreecommitdiff
path: root/basic/source/classes/eventatt.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/classes/eventatt.cxx')
-rw-r--r--basic/source/classes/eventatt.cxx117
1 files changed, 84 insertions, 33 deletions
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index 5c57af5b6ce8..791e9fe5a8c1 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -55,13 +55,17 @@
#include <com/sun/star/awt/XDialogProvider.hpp>
#include <com/sun/star/frame/XModel.hpp>
-
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <basic/basicmanagerrepository.hxx>
+#include <basic/basmgr.hxx>
//==================================================================================================
#include <xmlscript/xmldlg_imexp.hxx>
#include <sbunoobj.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbmeth.hxx>
+#include <basic/sbuno.hxx>
#include <runtime.hxx>
#include <sbintern.hxx>
@@ -85,11 +89,6 @@ using namespace ::osl;
-//===================================================================
-void unoToSbxValue( SbxVariable* pVar, const Any& aValue );
-Any sbxToUnoValue( SbxVariable* pVar );
-
-
Reference< frame::XModel > getModelFromBasic( SbxObject* pBasic )
{
OSL_PRECOND( pBasic != NULL, "getModelFromBasic: illegal call!" );
@@ -450,6 +449,43 @@ Any implFindDialogLibForDialog( const Any& rDlgAny, SbxObject* pBasic )
return aRetDlgLibAny;
}
+Any implFindDialogLibForDialogBasic( const Any& aAnyISP, SbxObject* pBasic, StarBASIC*& pFoundBasic )
+{
+ Any aDlgLibAny;
+ // Find dialog library for dialog, direct access is not possible here
+ StarBASIC* pStartedBasic = (StarBASIC*)pBasic;
+ SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
+ SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
+
+ SbxObject* pSearchBasic1 = NULL;
+ SbxObject* pSearchBasic2 = NULL;
+ if( pParentParentBasic )
+ {
+ pSearchBasic1 = pParentBasic;
+ pSearchBasic2 = pParentParentBasic;
+ }
+ else
+ {
+ pSearchBasic1 = pStartedBasic;
+ pSearchBasic2 = pParentBasic;
+ }
+ if( pSearchBasic1 )
+ {
+ aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 );
+
+ if ( aDlgLibAny.hasValue() )
+ pFoundBasic = (StarBASIC*)pSearchBasic1;
+
+ else if( pSearchBasic2 )
+ {
+ aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 );
+ if ( aDlgLibAny.hasValue() )
+ pFoundBasic = (StarBASIC*)pSearchBasic2;
+ }
+ }
+ return aDlgLibAny;
+}
+
static ::rtl::OUString aDecorationPropName =
::rtl::OUString::createFromAscii( "Decoration" );
static ::rtl::OUString aTitlePropName =
@@ -529,39 +565,54 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
{}
}
- // Find dialog library for dialog, direct access is not possible here
- StarBASIC* pStartedBasic = pINST->GetBasic();
- SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
- SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
-
- SbxObject* pSearchBasic1 = NULL;
- SbxObject* pSearchBasic2 = NULL;
- if( pParentParentBasic )
+ Any aDlgLibAny;
+ bool bDocDialog = false;
+ StarBASIC* pFoundBasic = NULL;
+ OSL_TRACE("About to try get a hold of ThisComponent");
+ Reference< frame::XModel > xModel = getModelFromBasic( pINST->GetBasic() ) ;
+ aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pINST->GetBasic(), pFoundBasic );
+ // If we found the dialog then it belongs to the Search basic
+ if ( !pFoundBasic )
{
- pSearchBasic1 = pParentBasic;
- pSearchBasic2 = pParentParentBasic;
- }
- else
+ Reference< frame::XDesktop > xDesktop( xMSF->createInstance
+ ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
+ UNO_QUERY );
+ Reference< container::XEnumeration > xModels;
+ if ( xDesktop.is() )
{
- pSearchBasic1 = pStartedBasic;
- pSearchBasic2 = pParentBasic;
- }
-
- Any aDlgLibAny;
- if( pSearchBasic1 )
+ Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY );
+ if ( xComponents.is() )
+ xModels.set( xComponents->createEnumeration(), UNO_QUERY );
+ if ( xModels.is() )
+ {
+ while ( xModels->hasMoreElements() )
+ {
+ Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY );
+ if ( xNextModel.is() )
+ {
+ BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel );
+ if ( pMgr )
+ aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic );
+ if ( aDlgLibAny.hasValue() )
{
- aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 );
- if( pSearchBasic2 && aDlgLibAny.getValueType().getTypeClass() == TypeClass_VOID )
- aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 );
+ bDocDialog = true;
+ xModel = xNextModel;
+ break;
}
-
-
- OSL_TRACE("About to try get a hold of ThisComponent");
- Reference< frame::XModel > xModel = getModelFromBasic( pStartedBasic ) ;
- Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pStartedBasic, xModel );
+ }
+ }
+ }
+ }
+ }
+ if ( pFoundBasic )
+ bDocDialog = pFoundBasic->IsDocBasic();
+ Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel );
Sequence< Any > aArgs( 4 );
- aArgs[ 0 ] <<= xModel;
+ if( bDocDialog )
+ aArgs[ 0 ] <<= xModel;
+ else
+ aArgs[ 0 ] <<= uno::Reference< uno::XInterface >();
aArgs[ 1 ] <<= xInput;
aArgs[ 2 ] = aDlgLibAny;
aArgs[ 3 ] <<= xScriptListener;