diff options
author | Ocke Janssen [oj] <Ocke.Janssen@oracle.com> | 2011-02-03 12:19:25 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@oracle.com> | 2011-02-03 12:19:25 +0100 |
commit | 7ce87234ca470fe1dc6668ff221300c703b535d8 (patch) | |
tree | 40c18479f7ca90514c779f6d1b2efa9a7ed87457 /svx/source/form | |
parent | Automated merge with ssh://hg@hg.services.openoffice.org/cws/dba34b (diff) | |
parent | #i10000# temporarily disable test (diff) | |
download | core-7ce87234ca470fe1dc6668ff221300c703b535d8.tar.gz core-7ce87234ca470fe1dc6668ff221300c703b535d8.zip |
merge from master
Diffstat (limited to 'svx/source/form')
-rw-r--r-- | svx/source/form/fmscriptingenv.cxx | 84 | ||||
-rw-r--r-- | svx/source/form/fmundo.cxx | 3 | ||||
-rw-r--r-- | svx/source/form/fmview.cxx | 1 | ||||
-rw-r--r-- | svx/source/form/formcontroller.cxx | 2 |
4 files changed, 26 insertions, 64 deletions
diff --git a/svx/source/form/fmscriptingenv.cxx b/svx/source/form/fmscriptingenv.cxx index 154999333296..3e8aa88a2612 100644 --- a/svx/source/form/fmscriptingenv.cxx +++ b/svx/source/form/fmscriptingenv.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" #include "fmscriptingenv.hxx" -#include <svx/fmmodel.hxx> +#include "svx/fmmodel.hxx" /** === begin UNO includes === **/ #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -37,6 +37,7 @@ #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> #include <com/sun/star/lang/DisposedException.hpp> /** === end UNO includes === **/ + #include <tools/diagnose_ex.h> #include <cppuhelper/implbase1.hxx> #include <comphelper/implementationreference.hxx> @@ -45,6 +46,8 @@ #include <vcl/svapp.hxx> #include <vos/mutex.hxx> #include <sfx2/objsh.hxx> +#include <sfx2/app.hxx> +#include <basic/basmgr.hxx> #include <boost/shared_ptr.hpp> @@ -416,60 +419,6 @@ namespace svxform m_rObjectShell.CallXScript( m_sScriptCode, _rArguments, _rSynchronousResult, aOutArgsIndex, aOutArgs ); } - - //................................................................ - //. QualifiedBasicScript - //................................................................ - class QualifiedBasicScript : public IScript - { - SfxObjectShell& m_rObjectShell; - const ::rtl::OUString m_sMacroLocation; - const ::rtl::OUString m_sScriptCode; - - public: - QualifiedBasicScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rLocation, const ::rtl::OUString& _rScriptCode ) - :m_rObjectShell( _rObjectShell ) - ,m_sMacroLocation( _rLocation ) - ,m_sScriptCode( _rScriptCode ) - { - } - - // IScript - virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ); - }; - - //................................................................ - void QualifiedBasicScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ) - { - m_rObjectShell.CallStarBasicScript( m_sScriptCode, m_sMacroLocation, - &_rArguments, &_rSynchronousResult ); - } - - //................................................................ - //. UnqualifiedBasicScript - //................................................................ - class UnqualifiedBasicScript : public IScript - { - SfxObjectShell& m_rObjectShell; - const ::rtl::OUString m_sScriptCode; - - public: - UnqualifiedBasicScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rScriptCode ) - :m_rObjectShell( _rObjectShell ) - ,m_sScriptCode( _rScriptCode ) - { - } - - // IScript - virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ); - }; - - //................................................................ - void UnqualifiedBasicScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ) - { - m_rObjectShell.CallScript( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ), m_sScriptCode, - &_rArguments, &_rSynchronousResult ); - } } //-------------------------------------------------------------------- @@ -481,6 +430,7 @@ namespace svxform if ( m_bDisposed ) return; + // SfxObjectShellRef is good here since the model controls the lifetime of the object SfxObjectShellRef xObjectShell = m_rFormModel.GetObjectShell(); if( !xObjectShell.Is() ) return; @@ -513,14 +463,24 @@ namespace svxform sScriptCode = sScriptCode.copy( nPrefixLen + 1 ); } - if ( sMacroLocation.getLength() ) - { // we have a StarBasic macro with fully-qualified macro location - pScript.reset( new QualifiedBasicScript( *xObjectShell, sMacroLocation, sScriptCode ) ); - } - else - { // we have a StarBasic macro without qualified location - let the object shell gues .... - pScript.reset( new UnqualifiedBasicScript( *xObjectShell, sScriptCode ) ); + if ( !sMacroLocation.getLength() ) + { + // legacy format: use the app-wide Basic, if it has a respective method, otherwise fall back to the doc's Basic + if ( SFX_APP()->GetBasicManager()->HasMacro( sScriptCode ) ) + sMacroLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application" ) ); + else + sMacroLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "document" ) ); } + + ::rtl::OUStringBuffer aScriptURI; + aScriptURI.appendAscii( "vnd.sun.star.script:" ); + aScriptURI.append( sScriptCode ); + aScriptURI.appendAscii( "?language=Basic" ); + aScriptURI.appendAscii( "&location=" ); + aScriptURI.append( sMacroLocation ); + + const ::rtl::OUString sScriptURI( aScriptURI.makeStringAndClear() ); + pScript.reset( new NewStyleUNOScript( *xObjectShell, sScriptURI ) ); } OSL_ENSURE( pScript.get(), "FormScriptingEnvironment::doFireScriptEvent: no script to execute!" ); diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index e63325f710e9..ed0d57b96f97 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -130,6 +130,8 @@ private: { Reference< XMultiComponentFactory > xMFac( xCtx->getServiceManager(), UNO_QUERY ); + + // SfxObjectShellRef is good here since the model controls the lifetime of the shell SfxObjectShellRef xObjSh = pModel->GetObjectShell(); Reference< XMultiServiceFactory > xDocFac; if ( xObjSh.Is() ) @@ -150,6 +152,7 @@ private: { try { + // SfxObjectShellRef is good here since the model controls the lifetime of the shell SfxObjectShellRef xObjSh = pModel->GetObjectShell(); if ( xObjSh.Is() && m_vbaListener.is() ) { diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index f9980284993d..1147e71b0731 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -46,7 +46,6 @@ #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <basic/sbuno.hxx> -#include <sfx2/macrconf.hxx> #include <basic/sbx.hxx> #include "fmitems.hxx" #include "fmobj.hxx" diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 7087e3d6793f..528661d2abe4 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -81,7 +81,7 @@ #include <comphelper/property.hxx> #include <comphelper/sequence.hxx> #include <comphelper/uno3.hxx> -#include <comphelper/scopeguard.hxx> +#include <comphelper/flagguard.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> #include <toolkit/controls/unocontrol.hxx> |