summaryrefslogtreecommitdiff
path: root/sfx2/source/control/macrconf.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/control/macrconf.cxx')
-rw-r--r--sfx2/source/control/macrconf.cxx163
1 files changed, 42 insertions, 121 deletions
diff --git a/sfx2/source/control/macrconf.cxx b/sfx2/source/control/macrconf.cxx
index 3b55e9362a..ed854c3532 100644
--- a/sfx2/source/control/macrconf.cxx
+++ b/sfx2/source/control/macrconf.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,27 +30,19 @@
#include "precompiled_sfx2.hxx"
#include <basic/sbstar.hxx>
#include <basic/basmgr.hxx>
-#ifndef _SBX_HXX //autogen
#include <basic/sbx.hxx>
#endif
#include <svl/intitem.hxx>
#include <basic/sbmeth.hxx>
#include <basic/sbmod.hxx>
-#ifndef _BASIC_SBUNO_HXX
#include <basic/sbuno.hxx>
-#endif
#include <osl/mutex.hxx>
#include <com/sun/star/script/XEngine.hpp>
#include <com/sun/star/document/MacroExecMode.hpp>
-#ifndef GCC
-#endif
-
-#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
#include <comphelper/processfactory.hxx>
-#endif
#include <unotools/intlwrapper.hxx>
#include <sfx2/msgpool.hxx>
@@ -94,8 +87,8 @@ void SfxMacroConfig::Release_Impl()
struct SfxMacroConfig_Impl
{
SfxMacroInfoArr_Impl aArr;
- sal_uInt32 nEventId;
- sal_Bool bWaitingForCallback;
+ sal_uInt32 nEventId;
+ sal_Bool bWaitingForCallback;
SfxMacroConfig_Impl()
: nEventId( 0 )
@@ -187,7 +180,7 @@ SfxMacroInfo::SfxMacroInfo( const String& rURL ) :
if ( aTmp.GetTokenCount('/') > 3 )
{
// 'macro:///lib.mod.proc(args)' => Macro via App-BASIC-Mgr
- // 'macro://[docname|.]/lib.mod.proc(args)' => Macro via zugehoerigen Doc-BASIC-Mgr
+ // 'macro://[docname|.]/lib.mod.proc(args)' => Macro via included Doc-BASIC-Mgr
if ( aTmp.CompareToAscii("///", 3 ) != COMPARE_EQUAL )
bAppBasic = FALSE;
aTmp = rURL.GetToken( 3, '/' );
@@ -234,7 +227,7 @@ SfxMacroInfo::SfxMacroInfo(bool _bAppBasic, const String& rLibName,
//==========================================================================
SfxMacroInfo::SfxMacroInfo(bool _bAppBasic, const String& rQualifiedName )
-: pHelpText(0),
+: pHelpText(0),
nRefCnt(0),
bAppBasic(_bAppBasic),
nSlotId(0),
@@ -274,7 +267,7 @@ SfxMacroInfo::~SfxMacroInfo()
sal_Bool SfxMacroInfo::operator==(const SfxMacroInfo& rOther) const
{
if ( GetQualifiedName() == rOther.GetQualifiedName() &&
- bAppBasic == rOther.bAppBasic )
+ bAppBasic == rOther.bAppBasic )
return sal_True;
else
return sal_False;
@@ -307,14 +300,16 @@ String SfxMacroInfo::GetQualifiedName() const
aMacroName += '.';
}
- // Wg. ::com::sun::star::script::JavaScript kein Zerlegen des Strings mehr
+ // due to ::com::sun::star::script::JavaScript
+ // no more disassembly of the string
aMacroName += aMethodName;
return aMacroName;
}
String SfxMacroInfo::GetFullQualifiedName() const
{
- // Liefert nur Unsinn, wenn f"ur ein ::com::sun::star::script::JavaScript aufgerufen !
+ // Returns only nonsense, when called for a
+ // ::com::sun::star::script::JavaScript !
String aRet;
if ( bAppBasic )
aRet = SFX_APP()->GetName();
@@ -329,7 +324,7 @@ String SfxMacroInfo::GetURL() const
return aMethodName;
// 'macro:///lib.mod.proc(args)' => Macro via App-BASIC-Mgr
- // 'macro://[docname|.]/lib.mod.proc(args)' => Macro via zugehoerigen Doc-BASIC-Mgr
+ // 'macro://[docname|.]/lib.mod.proc(args)' => Macro via included Doc-BASIC-Mgr
// 'macro://obj.method(args)' => Object via App-BASIC-Mgr
String aURL( String::CreateFromAscii("macro://") );
if ( !bAppBasic )
@@ -411,83 +406,6 @@ void SfxMacroInfo::SetHelpText( const String& rName )
*pHelpText = rName;
}
-//==========================================================================
-
-SvStream& operator >> (SvStream& rStream, SfxMacroInfo& rInfo)
-{
- sal_uInt16 nAppBasic, nFileVersion;
- String aDocName;
-
- rStream >> nFileVersion;
- if ( nVersion < nCompatVersion )
- {
- // In der 1.Version ohne Versionskennung
- nAppBasic = nVersion;
- nFileVersion = 1;
- rStream.ReadByteString(aDocName,RTL_TEXTENCODING_UTF8);
- rStream.ReadByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8);
- rStream.ReadByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8);
- rStream.ReadByteString(rInfo.aMethodName,RTL_TEXTENCODING_UTF8);
- }
- else
- {
- String aInput;
- rStream >> nAppBasic;
- rStream.ReadByteString(aDocName,RTL_TEXTENCODING_UTF8); // Vorsicht: kann bei AppName Unsinn sein!
- rStream.ReadByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8);
- rStream.ReadByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8);
- rStream.ReadByteString(aInput,RTL_TEXTENCODING_UTF8);
-
- if ( nFileVersion == nCompatVersion )
- rInfo.aMethodName = aInput;
- else
- {
- sal_uInt16 nCount = aInput.GetTokenCount('.');
- rInfo.aMethodName = aInput.GetToken( nCount-1, '.' );
- if ( nCount > 1 )
- rInfo.aModuleName = aInput.GetToken( nCount-2, '.' );
- if ( nCount > 2 )
- rInfo.aLibName = aInput.GetToken( 0, '.' );
- }
- }
-
- rInfo.bAppBasic = (sal_Bool) nAppBasic;
- return rStream;
-}
-
-int SfxMacroInfo::Load( SvStream& rStream )
-{
- rStream >> (*this);
- nSlotId = SFX_APP()->GetMacroConfig()->GetSlotId(this);
- return 0;
-}
-
-//==========================================================================
-
-SvStream& operator << (SvStream& rStream, const SfxMacroInfo& rInfo)
-{
- if ( rInfo.bAppBasic )
- {
- rStream << nVersion
- << (sal_uInt16) rInfo.bAppBasic;
- rStream.WriteByteString(rInfo.GetBasicName(),RTL_TEXTENCODING_UTF8);
- rStream.WriteByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8);
- rStream.WriteByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8);
- rStream.WriteByteString(rInfo.aMethodName,RTL_TEXTENCODING_UTF8);
- }
- else
- {
- rStream << nVersion
- << (sal_uInt16) rInfo.bAppBasic;
- rStream.WriteByteString(SFX_APP()->GetName(),RTL_TEXTENCODING_UTF8);
- rStream.WriteByteString(rInfo.aLibName,RTL_TEXTENCODING_UTF8);
- rStream.WriteByteString(rInfo.aModuleName,RTL_TEXTENCODING_UTF8);
- rStream.WriteByteString(rInfo.aMethodName,RTL_TEXTENCODING_UTF8);
- }
-
- return rStream;
-}
-
sal_Bool SfxMacroInfo::Compare( const SvxMacro& rMacro ) const
{
String aName = rMacro.GetLibName();
@@ -521,17 +439,18 @@ SFX_EXEC_STUB( SfxApplication, MacroExec_Impl )
sal_uInt16 SfxMacroConfig::GetSlotId(SfxMacroInfoPtr pInfo)
{
- sal_uInt16 nCount = pImp->aArr.Count(); // Macro suchen
+ sal_uInt16 nCount = pImp->aArr.Count(); // Search for Macro
sal_uInt16 i;
for (i=0; i<nCount; i++)
if ((*(pImp->aArr)[i]) == (*pInfo))
break;
if (i == nCount)
- { // Macro noch unbekannt
+ {
+ // Macro still unknown
nCount = aIdArray.Count();
sal_uInt16 n;
- for (n=0; n<nCount; n++) // freie SlotId suchen
+ for (n=0; n<nCount; n++) // Seearch for free SlotId
if (aIdArray[n] > SID_MACRO_START + n)
break;
@@ -564,7 +483,7 @@ sal_uInt16 SfxMacroConfig::GetSlotId(SfxMacroInfoPtr pInfo)
else
pNewSlot->pNextSlot = pNewSlot;
- // Macro uebernehmen
+ // Take over Macro
SfxMacroInfoPtr pNewInfo = new SfxMacroInfo(*pInfo);
pNewInfo->nSlotId = SID_MACRO_START + n;
pImp->aArr.Insert(pNewInfo,n);
@@ -585,7 +504,7 @@ sal_uInt16 SfxMacroConfig::GetSlotId(SfxMacroInfoPtr pInfo)
void SfxMacroConfig::ReleaseSlotId(sal_uInt16 nId)
{
- DBG_ASSERT( IsMacroSlot( nId ), "SlotId ist kein Macro!");
+ DBG_ASSERT( IsMacroSlot( nId ), "SlotId is no Macro!");
sal_uInt16 nCount = pImp->aArr.Count();
for (sal_uInt16 i=0; i<nCount; i++)
@@ -596,23 +515,23 @@ void SfxMacroConfig::ReleaseSlotId(sal_uInt16 nId)
pInfo->nRefCnt--;
if (pInfo->nRefCnt == 0)
{
- // Slot wird nicht mehr referenziert, also holen
+ // Slot is no longer referenced, so get
SfxSlot *pSlot = pInfo->pSlot;
- // Slot aus der Verkettung rausnehmen
+ // Take out Slot from the concatenation
while (pSlot->pNextSlot != pInfo->pSlot)
pSlot = (SfxSlot*) pSlot->pNextSlot;
pSlot->pNextSlot = pInfo->pSlot->pNextSlot;
- // Slot selbst kurz schlie\sen
+ // Slot close itself briefly
pSlot = pInfo->pSlot;
pSlot->pNextSlot = pSlot;
- // MacroInfo aus Array entfernen, damit sie kein Unheil
- // anrichten kann
+ // Remove Macro info from array so that it can not cause
+ // any harm
pImp->aArr.Remove(i);
- // SlotId wieder freigeben
+ // Release SlotId again
sal_uInt16 nIdCount = aIdArray.Count();
for (sal_uInt16 n=0; n<nIdCount; n++)
{
@@ -623,9 +542,9 @@ void SfxMacroConfig::ReleaseSlotId(sal_uInt16 nId)
}
}
- // Sofern nicht die Applikation heruntergefahren wird, mu\s
- // der Slot asynchron gel"oscht werden, falls er in seinem
- // eigenen Execute abgeschossen wird!
+ // Unless the application is not shut down, then
+ // the Slot has to be deleted asynchronously if cancelled in
+ // its own Execute!
if ( !SFX_APP()->Get_Impl()->bInQuit )
pImp->nEventId = Application::PostUserEvent( LINK(this, SfxMacroConfig, EventHdl_Impl), pInfo );
else
@@ -635,14 +554,14 @@ void SfxMacroConfig::ReleaseSlotId(sal_uInt16 nId)
}
}
- DBG_ERROR("Macro-SlotId nicht gefunden!");
+ DBG_ERROR("Macro-SlotId is not found!");
}
//==========================================================================
void SfxMacroConfig::RegisterSlotId(sal_uInt16 nId)
{
- DBG_ASSERT( IsMacroSlot( nId ), "SlotId ist kein Macro!");
+ DBG_ASSERT( IsMacroSlot( nId ), "SlotId is no Macro!");
sal_uInt16 nCount = pImp->aArr.Count();
for (sal_uInt16 i=0; i<nCount; i++)
@@ -654,7 +573,7 @@ void SfxMacroConfig::RegisterSlotId(sal_uInt16 nId)
}
}
- DBG_ERROR("Macro-SlotId nicht gefunden!");
+ DBG_ERROR("Macro-SlotId is not found!");
}
//==========================================================================
@@ -693,7 +612,7 @@ sal_Bool SfxMacroConfig::ExecuteMacro( sal_uInt16 nId, const String& rArgs ) con
SvxMacro aMacro( pInfo->GetQualifiedName(), pInfo->GetBasicName(), STARBASIC );
sal_Bool bRet = ExecuteMacro( pSh, &aMacro, rArgs );
- // Release, da im Dispatcher-Execute ein Register gemacht wurde
+ // Release, because a register was created in the dispatcher Execute
((SfxMacroConfig*)this)->ReleaseSlotId( nId );
return bRet;
}
@@ -702,11 +621,11 @@ sal_Bool SfxMacroConfig::ExecuteMacro( SfxObjectShell *pSh, const SvxMacro* pMac
{
SfxApplication *pApp = SFX_APP();
- // Name des Macros oder Scripts bzw. ScriptCode
+ // Name of the Macros or Scripts (ScriptCode)
String aCode( pMacro->GetMacName() );
ErrCode nErr = ERRCODE_NONE;
- // Ist es ein Basic-Macro ?
+ // Is it a Basic-Macro ?
ScriptType eSType = pMacro->GetScriptType();
sal_Bool bIsBasic = eSType == STARBASIC;
sal_Bool bIsStarScript = ( eSType == EXTENDED_STYPE && pMacro->GetLibName().SearchAscii( "StarScript" ) != STRING_NOTFOUND );
@@ -718,10 +637,10 @@ sal_Bool SfxMacroConfig::ExecuteMacro( SfxObjectShell *pSh, const SvxMacro* pMac
BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
if( bIsBasic )
{
- // BasicManager von Document?
+ // BasicManager of the Document?
BasicManager *pMgr = pSh ? pSh->GetBasicManager() : NULL;
- // Da leider der Name zwischendurch h"aufig gewechselt hat ...
+ // As the name has unfortunately been changed often ...
if( SFX_APP()->GetName() == pMacro->GetLibName() ||
pMacro->GetLibName().EqualsAscii("StarDesktop") )
pMgr = pAppMgr;
@@ -761,16 +680,16 @@ sal_Bool SfxMacroConfig::CheckMacro( SfxObjectShell *pSh, const SvxMacro* pMacro
{
SfxApplication *pApp = SFX_APP();
- // Name des Macros oder Scripts bzw. ScriptCode
+ // Name of Macros or Scripts (ScriptCode)
String aCode( pMacro->GetMacName() );
ErrCode nErr = ERRCODE_NONE;
- // BasicManager von Document oder Application
+ // BasicManager of Document or Application
pApp->EnterBasicCall();
BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
BasicManager *pMgr = pSh ? pSh->GetBasicManager() : NULL;
- // Da leider der Name zwischendurch h"aufig gewechselt hat ...
+ // As the name has unfortunately been changed often ...
if( SFX_APP()->GetName() == pMacro->GetLibName() ||
pMacro->GetLibName().EqualsAscii("StarDesktop") )
pMgr = pAppMgr;
@@ -791,14 +710,15 @@ sal_Bool SfxMacroConfig::CheckMacro( sal_uInt16 nId ) const
if ( !pInfo )
return sal_False;
- // Basic nur initialisieren, wenn default nicht ::com::sun::star::script::JavaScript; dann mu\s
- // in IsBasic() sowieso das Basic angelegt werden
+ // only initialize Basic, when default is not
+ // ::com::sun::star::script::JavaScript; then the Basic has to be created
+ // anyway in IsBasic()
SfxObjectShell* pSh = SfxObjectShell::Current();
SfxApplication *pApp = SFX_APP();
pApp->EnterBasicCall();
- // BasicManager von Document oder Application
+ // BasicManager of Document or Application
BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
BasicManager *pMgr = pSh ? pSh->GetBasicManager() : NULL;
@@ -872,3 +792,4 @@ sal_Bool SfxMacroConfig::IsMacroSlot( sal_uInt16 nId )
}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */