summaryrefslogtreecommitdiff
path: root/sfx2/source/appl/appserv.cxx
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-03-06 18:50:24 +0000
committerKurt Zenker <kz@openoffice.org>2008-03-06 18:50:24 +0000
commit802c3b6ae6c50a0d96c90528fe698ef09bbac497 (patch)
tree431b86117c18492bdaff406e900e496f033c1f9a /sfx2/source/appl/appserv.cxx
parent69cfcd75e21c91aaf6e099eae1619e15ce45b190 (diff)
INTEGRATION: CWS odbmacros2 (1.71.38); FILE MERGED
2008/03/04 12:11:38 fs 1.71.38.8: RESYNC: (1.72-1.73); FILE MERGED 2008/02/04 13:15:30 fs 1.71.38.7: RESYNC: (1.71-1.72); FILE MERGED 2008/01/24 11:19:51 fs 1.71.38.6: during #i49133#: give the script selector dialog a proper parent 2008/01/06 21:50:59 fs 1.71.38.5: #i49133# RUNMACRO: use the frame's model or controller (if there is no model) as script context when executing the selected macro 2007/12/11 23:22:44 fs 1.71.38.4: #i10000# 2007/12/11 22:44:26 fs 1.71.38.3: #i49133# SID_RUNMACRO: use the new SfxObjectShell::CallXScript, together with the ScriptSelector's GetContextDocument 2007/12/10 10:54:33 fs 1.71.38.2: #i49133# OfaExec_Impl( SID_RUNMACRO ): the code for executing macros in non-SFX documents was simply broken. Fixed it, and unified the code, so no there isn't a distinction SFX-doc <-> non-SFX-doc anymore 2007/12/10 08:54:34 fs 1.71.38.1: #i49133# CreateScriptSelectorDialog taking a frame now
Diffstat (limited to 'sfx2/source/appl/appserv.cxx')
-rw-r--r--sfx2/source/appl/appserv.cxx163
1 files changed, 73 insertions, 90 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 923fb5834f1c..9de29488a3f8 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: appserv.cxx,v $
*
- * $Revision: 1.73 $
+ * $Revision: 1.74 $
*
- * last change: $Author: obo $ $Date: 2008-02-26 15:03:48 $
+ * last change: $Author: kz $ $Date: 2008-03-06 19:50:24 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -75,6 +75,9 @@
#ifndef _COM_SUN_STAR_FRAME_XLAYOUTMANAGER_HPP_
#include <com/sun/star/frame/XLayoutManager.hpp>
#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XEMBEDDEDSCRIPTS_HPP_
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#endif
#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
#include <com/sun/star/embed/XStorage.hpp>
@@ -116,6 +119,9 @@
#ifndef _CONFIG_HXX
#include <tools/config.hxx>
#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
@@ -160,13 +166,14 @@
#include <svtools/moduleoptions.hxx>
#include <svtools/regoptions.hxx>
#include <svtools/helpopt.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <tools/shl.hxx>
#include <unotools/bootstrap.hxx>
#include <vos/process.hxx>
#include <rtl/bootstrap.hxx>
+#include <cppuhelper/exc_hlp.hxx>
#include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
-#include <com/sun/star/script/provider/ScriptFrameworkErrorException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include "about.hxx"
@@ -220,8 +227,7 @@ using namespace ::com::sun::star::util;
using namespace ::com::sun::star::script;
using namespace ::com::sun::star::system;
using namespace ::com::sun::star::lang;
-
-#define SFX_KEY_MULTIQUICKSEARCH "ExplorerMultiQuickSearch"
+using namespace ::com::sun::star::document;
//-------------------------------------------------------------------------
long QuitAgain_Impl( void* pObj, void* pArg )
@@ -827,6 +833,30 @@ ResMgr* SfxApplication::GetOffResManager_Impl()
return pAppData_Impl->pOfaResMgr;
}
+namespace
+{
+ Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, Window* _pFallback )
+ {
+ if ( !_rxFrame.is() )
+ return _pFallback;
+
+ try
+ {
+ Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
+ Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
+ OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
+
+ if ( pWindow )
+ return pWindow->GetSystemWindow();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return _pFallback;
+ }
+}
+
void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
{
DBG_MEMTEST();
@@ -963,99 +993,52 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
{
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
- AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog( GetTopWindow() );
- if( pDlg )
+
+ Reference< XFrame > xFrame;
+ const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
+ SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, FALSE );
+ if ( pFrameItem )
+ pFrameItem->GetValue() >>= xFrame;
+
+ if ( !xFrame.is() )
{
- pDlg->SetRunLabel();
- short ret = pDlg->Execute();
- if ( ret )
- {
- const String scriptURL = pDlg->GetScriptURL();
- SfxViewFrame* pView = SfxViewFrame::Current();
- SfxObjectShell* pObjShell = NULL;
- Sequence< Any > args(0);
- Any aRet;
- Sequence< sal_Int16 > outIndex;
- Sequence< Any > outArgs( 0 );
- if ( pView )
- {
- pObjShell = pView->GetObjectShell();
- }
- if ( pObjShell )
- {
- pObjShell->CallXScript(scriptURL, args, aRet, outIndex, outArgs);
- }
- else
- {
- bool bCaughtException = FALSE;
- Any aException;
+ const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+ const SfxFrame* pFrame = pViewFrame ? pViewFrame->GetFrame() : NULL;
+ if ( pFrame )
+ xFrame = pFrame->GetFrameInterface();
+ }
- try
- {
- Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
- Reference< XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW );
+ do // artificial loop for flow control
+ {
+ AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog(
+ lcl_getDialogParent( xFrame, GetTopWindow() ), FALSE, xFrame );
+ OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
+ if ( !pDlg )
+ break;
+ pDlg->SetRunLabel();
- Reference< provider::XScriptProviderFactory > xFac(
- xCtx->getValueByName(
- ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory") ), UNO_QUERY_THROW );
+ short nDialogResult = pDlg->Execute();
+ if ( !nDialogResult )
+ break;
- Any aContext;
+ Sequence< Any > args;
+ Sequence< sal_Int16 > outIndex;
+ Sequence< Any > outArgs;
+ Any ret;
- Reference< provider::XScriptProvider > xScriptProvider( xFac->createScriptProvider( aContext ),
- UNO_QUERY_THROW );
- Reference< provider::XScript > xScript(
- xScriptProvider->getScript( scriptURL ), UNO_QUERY_THROW );
+ Reference< XInterface > xScriptContext;
- xScript->invoke( args, outIndex, outArgs );
- }
- catch ( provider::ScriptFrameworkErrorException& se )
- {
- aException = makeAny( se );
- bCaughtException = TRUE;
- }
- catch ( ::com::sun::star::reflection::InvocationTargetException& ite )
- {
- aException = makeAny( ite );
- bCaughtException = TRUE;
- }
- catch ( ::com::sun::star::lang::IllegalArgumentException& iae )
- {
- aException = makeAny( iae );
- bCaughtException = TRUE;
- }
- catch ( ::com::sun::star::uno::RuntimeException& rte )
- {
- aException = makeAny( rte );
- bCaughtException = TRUE;
- }
- catch ( ::com::sun::star::uno::Exception& e )
- {
- aException = makeAny( e );
- bCaughtException = TRUE;
- }
+ Reference< XController > xController;
+ if ( xFrame.is() )
+ xController = xFrame->getController();
+ if ( xController.is() )
+ xScriptContext = xController->getModel();
+ if ( !xScriptContext.is() )
+ xScriptContext = xController;
- if ( bCaughtException )
- {
- if ( pFact != NULL )
- {
- VclAbstractDialog* pScriptErrDlg =
- pFact->CreateScriptErrorDialog(
- NULL, aException );
-
- if ( pScriptErrDlg != NULL )
- {
- pScriptErrDlg->Execute();
- delete pScriptErrDlg;
- }
- }
- }
- }
- }
- }
- else
- {
- OSL_TRACE("no dialog!!!");
+ SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs );
}
+ while ( false );
rReq.Done();
}
break;