38#include <com/sun/star/script/XLibraryContainerPassword.hpp>
41#include <sfx2/sfxsids.hrc>
45#include <osl/diagnose.h>
68 pDispatcher->
Execute( SID_BASICIDE_STOREALLMODULESOURCES );
71 if ( pModule->
FindMethod( rMacroName, SbxClassType::Method ) )
74 OUString aMacroName( rMacroName );
75 if ( aMacroName.isEmpty() )
85 aMacroName =
"Macro" + OUString::number( nMacro );
87 bValid = pModule->
FindMethod( aMacroName, SbxClassType::Method ) ==
nullptr;
96 sal_Int32 nSourceLen = aOUSource.getLength();
100 if ( pStr[ nSourceLen - 1 ] !=
LINE_SEP )
101 aOUSource +=
"\n\n" ;
102 else if ( pStr[ nSourceLen - 2 ] !=
LINE_SEP )
104 else if ( pStr[ nSourceLen - 3 ] ==
LINE_SEP )
105 aOUSource = aOUSource.copy( 0, nSourceLen-1 );
108 aOUSource +=
"Sub " + aMacroName +
"\n\nEnd Sub";
113 SAL_WARN_IF(!pBasMgr,
"basctl.basicide",
"No BasicManager found!");
120 const OUString& aLibName = pBasic->
GetName();
121 const OUString& aModName = pModule->
GetName();
129 pDispatcher->
Execute( SID_BASICIDE_UPDATEALLMODULESOURCES );
141 OUString
const& rLibName,
142 OUString
const& rOldName,
143 OUString
const& rNewName
146 if ( !rDocument.
hasDialog( rLibName, rOldName ) )
148 OSL_FAIL(
"basctl::RenameDialog: old module name is invalid!" );
152 if ( rDocument.
hasDialog( rLibName, rNewName ) )
155 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
161 if ( rNewName.isEmpty() )
164 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_BADSBXNAME)));
173 xExistingDialog = pWin->GetEditor().GetDialog();
175 if ( xExistingDialog.is() )
178 if ( !rDocument.
renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) )
181 if (!pWin || !pShell)
185 pWin->SetName( rNewName );
188 pWin->UpdateBrowser();
220 while (pSbx && !
dynamic_cast<StarBASIC const*
>(pSbx))
228 for (
auto const& doc : aDocuments)
231 OSL_ENSURE( pBasicMgr,
"basctl::FindBasicManager: no basic manager for the document!" );
236 sal_Int32 nLibCount = aLibNames.getLength();
237 const OUString* pLibNames = aLibNames.getConstArray();
239 for ( sal_Int32
i = 0 ;
i < nLibCount ;
i++ )
270 pBindings->Invalidate( SID_SIGNATURE );
271 pBindings->Invalidate( SID_SAVEDOC );
272 pBindings->Update( SID_SAVEDOC );
280 pMethod->
Get( aRes );
289 for (
auto const& window : rWindows)
301 bool* pbAppWindowDisabled,
302 bool* pbDispatcherLocked,
303 sal_uInt16* pnWaitCount,
309 if ( pbAppWindowDisabled )
310 *pbAppWindowDisabled =
false;
311 if ( pbDispatcherLocked )
312 *pbDispatcherLocked =
false;
315 if ( ppSWActionCount )
316 *ppSWActionCount =
nullptr;
317 if ( ppSWLockViewCount )
318 *ppSWLockViewCount =
nullptr;
323 sal_uInt16 nWait = 0;
324 while ( pShell->GetViewFrame().GetWindow().IsWait() )
326 pShell->GetViewFrame().GetWindow().LeaveWait();
330 *pnWaitCount = nWait;
337 if ( pbAppWindowDisabled )
338 *pbAppWindowDisabled =
true;
350 pBindings->
Update( SID_BASICSTOP );
352 pBindings->
Update( SID_BASICRUN );
354 pBindings->
Update( SID_BASICCOMPILE );
356 pBindings->
Update( SID_BASICSTEPOVER );
358 pBindings->
Update( SID_BASICSTEPINTO );
360 pBindings->
Update( SID_BASICSTEPOUT );
361 pBindings->
Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
362 pBindings->
Update( SID_BASICIDE_TOGGLEBRKPNT );
363 pBindings->
Invalidate( SID_BASICIDE_STAT_POS );
364 pBindings->
Update( SID_BASICIDE_STAT_POS );
365 pBindings->
Invalidate( SID_BASICIDE_STAT_TITLE );
366 pBindings->
Update( SID_BASICIDE_STAT_TITLE );
381 Shell* pShell =
nullptr;
387 bool bProtected =
false;
389 OSL_ENSURE(
aDocument.
isValid(),
"basctl::HandleBasicError: no document for the given BasicManager!" );
392 const OUString& aOULibName( pBasic->
GetName() );
394 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
397 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
410 SfxRequest aRequest( SID_BASICIDE_APPEAR, SfxCallMode::SYNCHRON, aArgs );
433 pFrame = &pShell->GetViewFrame();
448 if ( pFrame !=
nullptr )
SfxApplication * SfxGetpApp()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static weld::Window * GetDefDialogParent()
StarBASIC * GetLib(sal_uInt16 nLib) const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
const SbxArrayRef & GetMethods() const
SbMethod * FindMethod(const OUString &, SbxClassType)
const OUString & GetSource32() const
bool Get(SbxValues &) const
const SbxObject * GetParent() const
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxDispatcher * GetDispatcher()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual SfxObjectShell * GetObjectShell() override
static ErrCode const & GetErrorCode()
virtual void SetPageText(sal_uInt16 nPageId, const OUString &rText)
void MakeVisible(sal_uInt16 nPageId)
sal_uInt16 GetCurPageId() const
virtual void BasicStopped()
static void removeResourceForDialog(const ScriptDocument &rDocument, const OUString &aLibName, std::u16string_view aDlgName, const css::uno::Reference< css::container::XNameContainer > &xDialogModel)
static void renameStringResourceIDs(const ScriptDocument &rDocument, const OUString &aLibName, std::u16string_view aDlgName, const css::uno::Reference< css::container::XNameContainer > &xDialogModel)
encapsulates a document which contains Basic scripts and dialogs
bool renameDialog(const OUString &_rLibName, const OUString &_rOldName, const OUString &_rNewName, const css::uno::Reference< css::container::XNameContainer > &_rxExistingDialogModel) const
renames a dialog
css::uno::Reference< css::script::XLibraryContainer > getLibraryContainer(LibraryContainerType _eType) const
returns the Basic or Dialog library container of the document
@ AllWithApplication
all ScriptDocuments, including the dedicated one which represents the application-wide scripts/dialog...
static ScriptDocuments getAllScriptDocuments(ScriptDocumentList _eListType)
returns the set of ScriptDocument instances, one for each open document which contains Basic/Dialog c...
bool removeDialog(const OUString &_rLibName, const OUString &_rDialogName) const
removes a given dialog from the document
bool updateModule(const OUString &_rLibName, const OUString &_rModName, const OUString &_rModuleCode) const
updates a given module with new code
static ScriptDocument getDocumentForBasicManager(const BasicManager *_pManager)
returns a (newly created) ScriptDocument instance for the document to which a given BasicManager belo...
bool isAlive() const
determines whether the document instance is alive
void setDocumentModified() const
marks the document as modified @precond the instance operates on a real document, not on the applicat...
bool hasDialog(const OUString &_rLibName, const OUString &_rDialogName) const
determines whether a dialog with the given name exists in the given library
bool isApplication() const
determines whether the ScriptDocument instance operates on the whole application, as opposed to a rea...
bool isValid() const
determines whether the document is actually able to contain Basic/Dialog libraries
bool CallBasicErrorHdl(StarBASIC const *pBasic)
void UpdateObjectCatalog()
sal_uInt16 GetWindowId(BaseWindow const *pWin) const
std::map< sal_uInt16, VclPtr< BaseWindow > > WindowTable
void SetAppBasicModified(bool bModified)
VclPtr< DialogWindow > FindDlgWin(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rName, bool bCreateIfNotExist=false, bool bFindSuspended=false)
#define DBG_ASSERT(sCon, aError)
#define SAL_WARN_IF(condition, area, stream)
void RunMethod(SbMethod const *pMethod)
SfxBindings * GetBindingsPtr()
tools::Long HandleBasicError(StarBASIC const *pBasic)
void BasicStopped(bool *pbAppWindowDisabled, bool *pbDispatcherLocked, sal_uInt16 *pnWaitCount, SfxUInt16Item **ppSWActionCount, SfxUInt16Item **ppSWLockViewCount)
ExtraData * GetExtraData()
SbMethod * CreateMacro(SbModule *pModule, const OUString &rMacroName)
bool RemoveDialog(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rDlgName)
SfxDispatcher * GetDispatcher()
void MarkDocumentModified(const ScriptDocument &rDocument)
BasicManager * FindBasicManager(StarBASIC const *pLib)
SAL_DLLPUBLIC_EXPORT tools::Long basicide_handle_basic_error(void const *pPtr)
StarBASIC * FindBasic(const SbxVariable *pVar)
void InvalidateDebuggerSlots()
bool RenameDialog(weld::Widget *pErrorParent, ScriptDocument const &rDocument, OUString const &rLibName, OUString const &rOldName, OUString const &rNewName)
renames a dialog
std::vector< ScriptDocument > ScriptDocuments
OUString IDEResId(TranslateId aId)