summaryrefslogtreecommitdiff
path: root/basctl/source
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source')
-rw-r--r--basctl/source/basicide/basicbox.cxx4
-rw-r--r--basctl/source/basicide/baside2.cxx2
-rw-r--r--basctl/source/basicide/baside2.hxx3
-rw-r--r--basctl/source/basicide/baside3.cxx2
-rw-r--r--basctl/source/basicide/basidesh.cxx7
-rw-r--r--basctl/source/basicide/basobj2.cxx240
-rw-r--r--basctl/source/basicide/bastypes.cxx2
-rw-r--r--basctl/source/basicide/iderdll.cxx17
-rw-r--r--basctl/source/basicide/iderdll2.hxx2
-rw-r--r--basctl/source/inc/baside3.hxx3
-rw-r--r--basctl/source/inc/basidesh.hxx3
-rw-r--r--basctl/source/inc/bastypes.hxx9
12 files changed, 160 insertions, 134 deletions
diff --git a/basctl/source/basicide/basicbox.cxx b/basctl/source/basicide/basicbox.cxx
index 3d0ac3a544da..0ff56f208cad 100644
--- a/basctl/source/basicide/basicbox.cxx
+++ b/basctl/source/basicide/basicbox.cxx
@@ -144,9 +144,7 @@ void DocListenerBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/
void DocListenerBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ )
{
- if ( SFX_APP()->IsInBasicCall() )
- // Nicht wenn Office beendet
- FillBox();
+ FillBox();
}
void DocListenerBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 84a3c7b6b04c..5c13be2ff187 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -1332,7 +1332,7 @@ sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem,
return nFound;
}
-SfxUndoManager* __EXPORT ModulWindow::GetUndoManager()
+::svl::IUndoManager* __EXPORT ModulWindow::GetUndoManager()
{
if ( GetEditEngine() )
return &GetEditEngine()->GetUndoManager();
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 301ef3a6f69d..86e8527524f4 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -443,7 +443,8 @@ public:
virtual void BasicStarted();
virtual void BasicStopped();
- virtual SfxUndoManager* GetUndoManager();
+ virtual ::svl::IUndoManager*
+ GetUndoManager();
const ::rtl::OUString& GetModule() const { return m_aModule; }
void SetModule( const ::rtl::OUString& aModule ) { m_aModule = aModule; }
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index b6bba4918289..a0e217e55666 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -1281,7 +1281,7 @@ sal_Bool __EXPORT DialogWindow::IsModified()
return pEditor->IsModified();
}
-SfxUndoManager* __EXPORT DialogWindow::GetUndoManager()
+::svl::IUndoManager* __EXPORT DialogWindow::GetUndoManager()
{
return pUndoMgr;
}
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 56dcd66ad181..2786aa3311be 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -210,8 +210,6 @@ void BasicIDEShell::Init()
SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BasicIDE" ) ) );
SetHelpId( SVX_INTERFACE_BASIDE_VIEWSH );
- SFX_APP()->EnterBasicCall();
-
LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
@@ -289,7 +287,6 @@ __EXPORT BasicIDEShell::~BasicIDEShell()
// ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
// GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
- SFX_APP()->LeaveBasicCall();
IDE_DLL()->GetExtraData()->ShellInCriticalSection() = sal_False;
GnBasicIDEShellCount--;
@@ -554,9 +551,9 @@ void BasicIDEShell::ArrangeTabBar()
-SfxUndoManager* BasicIDEShell::GetUndoManager()
+::svl::IUndoManager* BasicIDEShell::GetUndoManager()
{
- SfxUndoManager* pMgr = NULL;
+ ::svl::IUndoManager* pMgr = NULL;
if( pCurWin )
pMgr = pCurWin->GetUndoManager();
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 206542ab173f..9123034b3c6a 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -30,23 +30,29 @@
#include <ide_pch.hxx>
-#include <vector>
-#include <algorithm>
-#include <basic/sbx.hxx>
-#include <unotools/moduleoptions.hxx>
+#include "basobj.hxx"
+#include "iderdll.hxx"
+#include "iderdll2.hxx"
+#include "iderid.hxx"
+#include "macrodlg.hxx"
+#include "moduldlg.hxx"
+#include "basidesh.hxx"
+#include "basidesh.hrc"
+#include "baside2.hxx"
+#include "basicmod.hxx"
+#include "basdoc.hxx"
+
#include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/document/XScriptInvocationContext.hpp>
-#include <basobj.hxx>
-#include <iderdll.hxx>
-#include <iderdll2.hxx>
-#include <iderid.hxx>
-#include <macrodlg.hxx>
-#include <moduldlg.hxx>
-#include <basidesh.hxx>
-#include <basidesh.hrc>
-#include <baside2.hxx>
-#include <basicmod.hxx>
-#include <basdoc.hxx>
+
+#include <basic/sbx.hxx>
+#include <framework/documentundoguard.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/moduleoptions.hxx>
+
+#include <vector>
+#include <algorithm>
+#include <memory>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -216,6 +222,51 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const
return true;
}
+
+//----------------------------------------------------------------------------
+
+namespace
+{
+ struct MacroExecutionData
+ {
+ ScriptDocument aDocument;
+ SbMethodRef xMethod;
+
+ MacroExecutionData()
+ :aDocument( ScriptDocument::NoDocument )
+ ,xMethod( NULL )
+ {
+ }
+ };
+
+ class MacroExecution
+ {
+ public:
+ DECL_STATIC_LINK( MacroExecution, ExecuteMacroEvent, MacroExecutionData* );
+ };
+
+
+ IMPL_STATIC_LINK( MacroExecution, ExecuteMacroEvent, MacroExecutionData*, i_pData )
+ {
+ (void)pThis;
+ ENSURE_OR_RETURN( i_pData, "wrong MacroExecutionData", 0L );
+ // take ownership of the data
+ ::std::auto_ptr< MacroExecutionData > pData( i_pData );
+
+ DBG_ASSERT( pData->xMethod->GetParent()->GetFlags() & SBX_EXTSEARCH, "Kein EXTSEARCH!" );
+
+ // in case this is a document-local macro, try to protect the document's Undo Manager from
+ // flawed scripts
+ ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
+ if ( pData->aDocument.isDocument() )
+ pUndoGuard.reset( new ::framework::DocumentUndoGuard( pData->aDocument.getDocument() ) );
+
+ BasicIDE::RunMethod( pData->xMethod );
+
+ return 1L;
+ }
+}
+
//----------------------------------------------------------------------------
::rtl::OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument, sal_Bool bChooseOnly, const ::rtl::OUString& rMacroDesc )
@@ -225,13 +276,12 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const
BasicIDEDLL::Init();
IDE_DLL()->GetExtraData()->ChoosingMacro() = sal_True;
- SFX_APP()->EnterBasicCall();
String aScriptURL;
sal_Bool bError = sal_False;
SbMethod* pMethod = NULL;
- MacroChooser* pChooser = new MacroChooser( NULL, sal_True );
+ ::std::auto_ptr< MacroChooser > pChooser( new MacroChooser( NULL, sal_True ) );
if ( bChooseOnly || !SvtModuleOptions().IsBasicIDE() )
pChooser->SetMode( MACROCHOOSER_CHOOSEONLY );
@@ -251,103 +301,95 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const
if ( !pMethod && pChooser->GetMode() == MACROCHOOSER_RECORDING )
pMethod = pChooser->CreateMacro();
- if ( pMethod )
+ if ( !pMethod )
+ break;
+
+ SbModule* pModule = pMethod->GetModule();
+ ENSURE_OR_BREAK( pModule, "BasicIDE::ChooseMacro: No Module found!" );
+
+ StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
+ ENSURE_OR_BREAK( pBasic, "BasicIDE::ChooseMacro: No Basic found!" );
+
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ ENSURE_OR_BREAK( pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!" );
+
+ // name
+ String aName;
+ aName += pBasic->GetName();
+ aName += '.';
+ aName += pModule->GetName();
+ aName += '.';
+ aName += pMethod->GetName();
+
+ // language
+ String aLanguage = String::CreateFromAscii("Basic");
+
+ // location
+ String aLocation;
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ if ( aDocument.isDocument() )
{
- SbModule* pModule = pMethod->GetModule();
- DBG_ASSERT(pModule, "BasicIDE::ChooseMacro: No Module found!");
- if ( pModule )
- {
- StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
- DBG_ASSERT(pBasic, "BasicIDE::ChooseMacro: No Basic found!");
- if ( pBasic )
- {
- BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
- DBG_ASSERT(pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!");
- if ( pBasMgr )
- {
- // name
- String aName;
- aName += pBasic->GetName();
- aName += '.';
- aName += pModule->GetName();
- aName += '.';
- aName += pMethod->GetName();
-
- // language
- String aLanguage = String::CreateFromAscii("Basic");
-
- // location
- String aLocation;
- ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
- if ( aDocument.isDocument() )
- {
- // document basic
- aLocation = String::CreateFromAscii("document");
-
- if ( rxLimitToDocument.is() )
- {
- uno::Reference< frame::XModel > xLimitToDocument( rxLimitToDocument );
-
- uno::Reference< document::XEmbeddedScripts > xScripts( rxLimitToDocument, UNO_QUERY );
- if ( !xScripts.is() )
- { // the document itself does not support embedding scripts
- uno::Reference< document::XScriptInvocationContext > xContext( rxLimitToDocument, UNO_QUERY );
- if ( xContext.is() )
- xScripts = xContext->getScriptContainer();
- if ( xScripts.is() )
- { // but it is able to refer to a document which actually does support this
- xLimitToDocument.set( xScripts, UNO_QUERY );
- if ( !xLimitToDocument.is() )
- {
- OSL_ENSURE( false, "BasicIDE::ChooseMacro: a script container which is no document!?" );
- xLimitToDocument = rxLimitToDocument;
- }
- }
- }
-
- if ( xLimitToDocument != aDocument.getDocument() )
- {
- // error
- bError = sal_True;
- ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
- }
- }
- }
- else
- {
- // application basic
- aLocation = String::CreateFromAscii("application");
- }
+ // document basic
+ aLocation = String::CreateFromAscii("document");
- // script URL
- if ( !bError )
+ if ( rxLimitToDocument.is() )
+ {
+ uno::Reference< frame::XModel > xLimitToDocument( rxLimitToDocument );
+
+ uno::Reference< document::XEmbeddedScripts > xScripts( rxLimitToDocument, UNO_QUERY );
+ if ( !xScripts.is() )
+ { // the document itself does not support embedding scripts
+ uno::Reference< document::XScriptInvocationContext > xContext( rxLimitToDocument, UNO_QUERY );
+ if ( xContext.is() )
+ xScripts = xContext->getScriptContainer();
+ if ( xScripts.is() )
+ { // but it is able to refer to a document which actually does support this
+ xLimitToDocument.set( xScripts, UNO_QUERY );
+ if ( !xLimitToDocument.is() )
{
- aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
- aScriptURL += aName;
- aScriptURL += String::CreateFromAscii("?language=");
- aScriptURL += aLanguage;
- aScriptURL += String::CreateFromAscii("&location=");
- aScriptURL += aLocation;
+ OSL_ENSURE( false, "BasicIDE::ChooseMacro: a script container which is no document!?" );
+ xLimitToDocument = rxLimitToDocument;
}
}
}
+
+ if ( xLimitToDocument != aDocument.getDocument() )
+ {
+ // error
+ bError = TRUE;
+ ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
+ }
}
}
+ else
+ {
+ // application basic
+ aLocation = String::CreateFromAscii("application");
+ }
+
+ // script URL
+ if ( !bError )
+ {
+ aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
+ aScriptURL += aName;
+ aScriptURL += String::CreateFromAscii("?language=");
+ aScriptURL += aLanguage;
+ aScriptURL += String::CreateFromAscii("&location=");
+ aScriptURL += aLocation;
+ }
- if ( pMethod && !rxLimitToDocument.is() )
+ if ( !rxLimitToDocument.is() )
{
- pMethod->AddRef(); // festhalten, bis Event abgearbeitet.
- Application::PostUserEvent( LINK( IDE_DLL()->GetExtraData(), BasicIDEData, ExecuteMacroEvent ), pMethod );
+ MacroExecutionData* pExecData = new MacroExecutionData;
+ pExecData->aDocument = aDocument;
+ pExecData->xMethod = pMethod; // keep alive until the event has been processed
+ Application::PostUserEvent( STATIC_LINK( NULL, MacroExecution, ExecuteMacroEvent ), pExecData );
}
}
break;
}
- delete pChooser;
-
- SFX_APP()->LeaveBasicCall();
-
- return ::rtl::OUString( aScriptURL );
+ return aScriptURL;
}
//----------------------------------------------------------------------------
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index 1d51d460d80f..9e8b1c452b9a 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -260,7 +260,7 @@ Window* __EXPORT IDEBaseWindow::GetLayoutWindow()
return this;
}
-SfxUndoManager* __EXPORT IDEBaseWindow::GetUndoManager()
+::svl::IUndoManager* __EXPORT IDEBaseWindow::GetUndoManager()
{
return NULL;
}
diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx
index d0589f5ca5d9..473b6219d16f 100644
--- a/basctl/source/basicide/iderdll.cxx
+++ b/basctl/source/basicide/iderdll.cxx
@@ -211,20 +211,3 @@ IMPL_LINK( BasicIDEData, GlobalBasicBreakHdl, StarBASIC *, pBasic )
return nRet;
}
-
-IMPL_LINK( BasicIDEData, ExecuteMacroEvent, void *, pData )
-{
- if ( pData )
- {
- SFX_APP()->EnterBasicCall();
- SbMethod* pMethod = (SbMethod*)pData;
-
- // Ist es eine StarScript-Methode? Am Parent erkennen
- DBG_ASSERT( pMethod->GetParent()->GetFlags() & SBX_EXTSEARCH, "Kein EXTSEARCH!" );
- BasicIDE::RunMethod( pMethod );
- pMethod->ReleaseRef(); // muss vorher inkrementiert worden sein!
- SFX_APP()->LeaveBasicCall();
- }
- return 0;
-}
-
diff --git a/basctl/source/basicide/iderdll2.hxx b/basctl/source/basicide/iderdll2.hxx
index 4897a2e232e7..bd812ee36f6f 100644
--- a/basctl/source/basicide/iderdll2.hxx
+++ b/basctl/source/basicide/iderdll2.hxx
@@ -100,8 +100,6 @@ public:
const String& GetAddLibFilter() const { return aAddLibFilter; }
void SetAddLibFilter( const String& rFilter ) { aAddLibFilter = rFilter; }
-
- DECL_LINK( ExecuteMacroEvent, void * );
};
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
index 880023ebb1d8..f59f921a0739 100644
--- a/basctl/source/inc/baside3.hxx
+++ b/basctl/source/inc/baside3.hxx
@@ -106,7 +106,8 @@ public:
virtual sal_Bool IsModified();
virtual sal_Bool IsPasteAllowed();
- virtual SfxUndoManager* GetUndoManager();
+ virtual ::svl::IUndoManager*
+ GetUndoManager();
// return number of pages to be printed
virtual sal_Int32 countPages( Printer* pPrinter );
// print page
diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx
index 34ee014aa7b2..de0cb539694c 100644
--- a/basctl/source/inc/basidesh.hxx
+++ b/basctl/source/inc/basidesh.hxx
@@ -197,7 +197,8 @@ public:
SdrView* GetCurDlgView() const;
- SfxUndoManager* GetUndoManager();
+ ::svl::IUndoManager*
+ GetUndoManager();
virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index 1a5838b2aa10..1a5283ae0691 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -164,9 +164,13 @@ public:
#define BASWIN_INRESCHEDULE 0x08
class Printer;
-class SfxUndoManager;
class BasicEntryDescriptor;
+namespace svl
+{
+ class IUndoManager;
+}
+
class IDEBaseWindow : public Window
{
private:
@@ -228,7 +232,8 @@ public:
virtual Window* GetLayoutWindow();
- virtual SfxUndoManager* GetUndoManager();
+ virtual ::svl::IUndoManager*
+ GetUndoManager();
virtual sal_uInt16 GetSearchOptions();