summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/objmisc.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/doc/objmisc.cxx')
-rwxr-xr-x[-rw-r--r--]sfx2/source/doc/objmisc.cxx204
1 files changed, 27 insertions, 177 deletions
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index d8d00bdc6cfa..e03d0a8813c3 100644..100755
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -107,6 +107,8 @@ using namespace ::com::sun::star::container;
#include <rtl/bootstrap.hxx>
#include <vcl/svapp.hxx>
#include <framework/interaction.hxx>
+#include <framework/documentundoguard.hxx>
+#include <comphelper/interaction.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/documentconstants.hxx>
@@ -115,7 +117,7 @@ using namespace ::com::sun::star::container;
#include "appdata.hxx"
#include <sfx2/request.hxx>
#include <sfx2/bindings.hxx>
-#include "sfxresid.hxx"
+#include "sfx2/sfxresid.hxx"
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/objsh.hxx>
@@ -129,7 +131,6 @@ using namespace ::com::sun::star::container;
#include <sfx2/ctrlitem.hxx>
#include "arrdecl.hxx"
#include <sfx2/module.hxx>
-#include <sfx2/macrconf.hxx>
#include <sfx2/docfac.hxx>
#include "helper.hxx"
#include "doc.hrc"
@@ -1103,9 +1104,9 @@ void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame* pFrame )
sal_uInt16 nId = pImp->nEventId;
pImp->nEventId = 0;
if ( nId == SFX_EVENT_OPENDOC )
- pSfxApp->NotifyEvent(SfxEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_OPENDOC), this ), sal_False);
+ pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_OPENDOC), this, pFrame->GetFrame().GetController() ), sal_False);
else if (nId == SFX_EVENT_CREATEDOC )
- pSfxApp->NotifyEvent(SfxEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_CREATEDOC), this ), sal_False);
+ pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_CREATEDOC), this, pFrame->GetFrame().GetController() ), sal_False);
}
}
}
@@ -1584,15 +1585,8 @@ SfxModule* SfxObjectShell::GetModule() const
return GetFactory().GetModule();
}
-sal_Bool SfxObjectShell::IsBasic(
- const String & rCode, SbxObject * pVCtrl )
-{
- if( !rCode.Len() ) return sal_False;
- return SfxMacroConfig::IsBasic( pVCtrl, rCode, GetBasicManager() );
-}
-
ErrCode SfxObjectShell::CallBasic( const String& rMacro,
- const String& rBasic, SbxObject* pVCtrl, SbxArray* pArgs,
+ const String& rBasic, SbxArray* pArgs,
SbxValue* pRet )
{
SfxApplication* pApp = SFX_APP();
@@ -1602,23 +1596,13 @@ ErrCode SfxObjectShell::CallBasic( const String& rMacro,
return ERRCODE_IO_ACCESSDENIED;
}
- pApp->EnterBasicCall();
BasicManager *pMgr = GetBasicManager();
if( pApp->GetName() == rBasic )
pMgr = pApp->GetBasicManager();
- ErrCode nRet = SfxMacroConfig::Call( pVCtrl, rMacro, pMgr, pArgs, pRet );
- pApp->LeaveBasicCall();
+ ErrCode nRet = SfxApplication::CallBasic( rMacro, pMgr, pArgs, pRet );
return nRet;
}
-ErrCode SfxObjectShell::Call( const String & rCode, sal_Bool bIsBasicReturn, SbxObject * pVCtrl )
-{
- ErrCode nErr = ERRCODE_NONE;
- if ( bIsBasicReturn )
- CallBasic( rCode, String(), pVCtrl );
- return nErr;
-}
-
namespace
{
static bool lcl_isScriptAccessAllowed_nothrow( const Reference< XInterface >& _rxScriptContext )
@@ -1672,6 +1656,9 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon
xScriptProvider.set( xScriptProviderFactory->createScriptProvider( makeAny( _rxScriptContext ) ), UNO_SET_THROW );
}
+ // ry to protect the invocation context's undo manager (if present), just in case the script tampers with it
+ ::framework::DocumentUndoGuard aUndoGuard( _rxScriptContext.get() );
+
// obtain the script, and execute it
Reference< provider::XScript > xScript( xScriptProvider->getScript( _rScriptURL ), UNO_QUERY_THROW );
if ( pCaller && pCaller->hasValue() )
@@ -1689,7 +1676,7 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon
catch ( const uno::Exception& )
{
aException = ::cppu::getCaughtException();
- bCaughtException = TRUE;
+ bCaughtException = sal_True;
nErr = ERRCODE_BASIC_INTERNAL_ERROR;
}
@@ -1723,118 +1710,6 @@ ErrCode SfxObjectShell::CallXScript( const String& rScriptURL,
}
//-------------------------------------------------------------------------
-namespace {
- using namespace ::com::sun::star::uno;
-
- //.....................................................................
- static SbxArrayRef lcl_translateUno2Basic( const void* _pAnySequence )
- {
- SbxArrayRef xReturn;
- if ( _pAnySequence )
- {
- // in real it's a sequence of Any (by convention)
- const Sequence< Any >* pArguments = static_cast< const Sequence< Any >* >( _pAnySequence );
-
- // do we have arguments ?
- if ( pArguments->getLength() )
- {
- // yep
- xReturn = new SbxArray;
- String sEmptyName;
-
- // loop through the sequence
- const Any* pArg = pArguments->getConstArray();
- const Any* pArgEnd = pArg + pArguments->getLength();
-
- for ( sal_uInt16 nArgPos=1; pArg != pArgEnd; ++pArg, ++nArgPos )
- // and create a Sb object for every Any
- xReturn->Put( GetSbUnoObject( sEmptyName, *pArg ), nArgPos );
- }
- }
- return xReturn;
- }
- //.....................................................................
- void lcl_translateBasic2Uno( const SbxVariableRef& _rBasicValue, void* _pAny )
- {
- if ( _pAny )
- *static_cast< Any* >( _pAny ) = sbxToUnoValue( _rBasicValue );
- }
-}
-//-------------------------------------------------------------------------
-ErrCode SfxObjectShell::CallStarBasicScript( const String& _rMacroName, const String& _rLocation,
- const void* _pArguments, void* _pReturn )
-{
- OSL_TRACE("in CallSBS");
- SolarMutexGuard aSolarGuard;
-
- // the arguments for the call
- SbxArrayRef xMacroArguments = lcl_translateUno2Basic( _pArguments );
-
- // the return value
- SbxVariableRef xReturn = _pReturn ? new SbxVariable : NULL;
-
- // the location (document or application)
- String sMacroLocation;
- if ( _rLocation.EqualsAscii( "application" ) )
- sMacroLocation = SFX_APP()->GetName();
-#ifdef DBG_UTIL
- else
- DBG_ASSERT( _rLocation.EqualsAscii( "document" ),
- "SfxObjectShell::CallStarBasicScript: invalid (unknown) location!" );
-#endif
-
- // call the script
- ErrCode eError = CallBasic( _rMacroName, sMacroLocation, NULL, xMacroArguments, xReturn );
-
- // translate the return value
- lcl_translateBasic2Uno( xReturn, _pReturn );
-
- // outta here
- return eError;
-}
-
-//-------------------------------------------------------------------------
-ErrCode SfxObjectShell::CallScript(
- const String & rScriptType,
- const String & rCode,
- const void *pArgs,
- void *pRet
-)
-{
- SolarMutexGuard aSolarGuard;
- ErrCode nErr = ERRCODE_NONE;
- if( rScriptType.EqualsAscii( "StarBasic" ) )
- {
- // the arguments for the call
- SbxArrayRef xMacroArguments = lcl_translateUno2Basic( pArgs );
-
- // the return value
- SbxVariableRef xReturn = pRet ? new SbxVariable : NULL;
-
- // call the script
- nErr = CallBasic( rCode, String(), NULL, xMacroArguments, xReturn );
-
- // translate the return value
- lcl_translateBasic2Uno( xReturn, pRet );
-
- // did this fail because the method was not found?
- if ( nErr == ERRCODE_BASIC_PROC_UNDEFINED )
- { // yep-> look in the application BASIC module
- nErr = CallBasic( rCode, SFX_APP()->GetName(), NULL, xMacroArguments, xReturn );
- }
- }
- else if( rScriptType.EqualsAscii( "JavaScript" ) )
- {
- OSL_FAIL( "JavaScript not allowed" );
- return 0;
- }
- else
- {
- OSL_FAIL( "StarScript not allowed" );
- }
- return nErr;
-}
-
SfxFrame* SfxObjectShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ )
{
return pSelf;
@@ -1852,25 +1727,6 @@ void SfxObjectShell::SetFlags( SfxObjectShellFlags eFlags )
pImp->eFlags = eFlags;
}
-String SfxObjectShell::QueryTitle( SfxTitleQuery eType ) const
-{
- String aRet;
-
- switch( eType )
- {
- case SFX_TITLE_QUERY_SAVE_NAME_PROPOSAL:
- {
- SfxMedium* pMed = GetMedium();
- const INetURLObject aObj( pMed->GetName() );
- aRet = aObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
- if ( !aRet.Len() )
- aRet = GetTitle( SFX_TITLE_CAPTION );
- break;
- }
- }
- return aRet;
-}
-
void SfxHeaderAttributes_Impl::SetAttributes()
{
bAlert = sal_True;
@@ -2019,7 +1875,7 @@ sal_Bool SfxObjectShell::IsSecure()
if ( GetMedium()->GetContent().is() )
{
Any aAny( ::utl::UCBContentHelper::GetProperty( aURL.GetMainURL( INetURLObject::NO_DECODE ), String( RTL_CONSTASCII_USTRINGPARAM("IsProtected")) ) );
- sal_Bool bIsProtected = FALSE;
+ sal_Bool bIsProtected = sal_False;
if ( ( aAny >>= bIsProtected ) && bIsProtected )
return sal_False;
else
@@ -2032,7 +1888,7 @@ sal_Bool SfxObjectShell::IsSecure()
return sal_False;
}
-void SfxObjectShell::SetWaitCursor( BOOL bSet ) const
+void SfxObjectShell::SetWaitCursor( sal_Bool bSet ) const
{
for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
{
@@ -2054,7 +1910,7 @@ String SfxObjectShell::GetAPIName() const
return aName;
}
-void SfxObjectShell::Invalidate( USHORT nId )
+void SfxObjectShell::Invalidate( sal_uInt16 nId )
{
for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
Invalidate_Impl( pFrame->GetBindings(), nId );
@@ -2077,7 +1933,7 @@ Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium )
{
Window* pWindow = 0;
SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet();
- SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE );
+ SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
if ( pUnoItem )
{
uno::Reference < frame::XFrame > xFrame( pUnoItem->GetFrame() );
@@ -2087,7 +1943,7 @@ Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium )
if ( !pWindow )
{
SfxFrame* pFrame = 0;
- SFX_ITEMSET_ARG( pSet, pFrameItem, SfxFrameItem, SID_DOCFRAME, FALSE );
+ SFX_ITEMSET_ARG( pSet, pFrameItem, SfxFrameItem, SID_DOCFRAME, sal_False );
if( pFrameItem && pFrameItem->GetFrame() )
// get target frame from ItemSet
pFrame = pFrameItem->GetFrame();
@@ -2121,7 +1977,7 @@ Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium )
return pWindow;
}
-String SfxObjectShell::UpdateTitle( SfxMedium* pMed, USHORT nDocViewNumber )
+String SfxObjectShell::UpdateTitle( SfxMedium* pMed, sal_uInt16 nDocViewNumber )
{
// Titel des Fensters
String aTitle;
@@ -2162,29 +2018,29 @@ void SfxObjectShell::SetCreateMode_Impl( SfxObjectCreateMode nMode )
eCreateMode = nMode;
}
-BOOL SfxObjectShell::IsInPlaceActive()
+sal_Bool SfxObjectShell::IsInPlaceActive()
{
if ( eCreateMode != SFX_CREATE_MODE_EMBEDDED )
- return FALSE;
+ return sal_False;
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
return pFrame && pFrame->GetFrame().IsInPlace();
}
-BOOL SfxObjectShell::IsUIActive()
+sal_Bool SfxObjectShell::IsUIActive()
{
if ( eCreateMode != SFX_CREATE_MODE_EMBEDDED )
- return FALSE;
+ return sal_False;
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
return pFrame && pFrame->GetFrame().IsInPlace() && pFrame->GetFrame().GetWorkWindow_Impl()->IsVisible_Impl();
}
-void SfxObjectShell::UIActivate( BOOL )
+void SfxObjectShell::UIActivate( sal_Bool )
{
}
-void SfxObjectShell::InPlaceActivate( BOOL )
+void SfxObjectShell::InPlaceActivate( sal_Bool )
{
}
@@ -2200,8 +2056,8 @@ sal_Bool SfxObjectShell::UseInteractionToHandleError(
{
uno::Any aInteraction;
uno::Sequence< uno::Reference< task::XInteractionContinuation > > lContinuations(2);
- ::framework::ContinuationAbort* pAbort = new ::framework::ContinuationAbort();
- ::framework::ContinuationApprove* pApprove = new ::framework::ContinuationApprove();
+ ::comphelper::OInteractionAbort* pAbort = new ::comphelper::OInteractionAbort();
+ ::comphelper::OInteractionApprove* pApprove = new ::comphelper::OInteractionApprove();
lContinuations[0] = uno::Reference< task::XInteractionContinuation >(
static_cast< task::XInteractionContinuation* >( pAbort ), uno::UNO_QUERY );
lContinuations[1] = uno::Reference< task::XInteractionContinuation >(
@@ -2210,14 +2066,8 @@ sal_Bool SfxObjectShell::UseInteractionToHandleError(
task::ErrorCodeRequest aErrorCode;
aErrorCode.ErrCode = nError;
aInteraction <<= aErrorCode;
-
- ::framework::InteractionRequest* pRequest = new ::framework::InteractionRequest(aInteraction,lContinuations);
- uno::Reference< task::XInteractionRequest > xRequest(
- static_cast< task::XInteractionRequest* >( pRequest ),
- uno::UNO_QUERY);
-
- xHandler->handle(xRequest);
- bResult = pAbort->isSelected();
+ xHandler->handle(::framework::InteractionRequest::CreateRequest (aInteraction,lContinuations));
+ bResult = pAbort->wasSelected();
}
catch( uno::Exception& )
{}