tdf#106731 Warn user that a module/dialog is read-only in Basic IDE
As discussed in the ticket the Basic IDE does not make it clear that the currently opened module is read-only, which can cause confusion to the user, since they may be pressing keys and seeing no result. With this patch the IDE clarifies that the module/dialog is read-only in two ways: 1) In the status bar the string "(Read-only)" is added after the module/dialog name 2) When a module/dialog is opened an infobar is shown warning that it is read-only. 3) In a module, if the user closed the infobar and tries to edit the code, the infobar is shown again. Change-Id: I15197c4316bb2ed19e54be0c33f4fb61b5bbd862 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145307 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
@@ -110,6 +110,9 @@
|
||||
#define RID_STR_EXPORTPACKAGE NC_("RID_STR_EXPORTPACKAGE", "Export library as extension")
|
||||
#define RID_STR_EXPORTBASIC NC_("RID_STR_EXPORTBASIC", "Export as BASIC library")
|
||||
#define RID_STR_PACKAGE_BUNDLE NC_("RID_STR_PACKAGE_BUNDLE", "Extension")
|
||||
#define RID_STR_READONLY NC_("RID_STR_READONLY", "Read-only")
|
||||
#define RID_STR_MODULE_READONLY NC_("RID_STR_READONLY_WARNING", "This module is read-only and cannot be edited.")
|
||||
#define RID_STR_DIALOG_READONLY NC_("RID_STR_READONLY_WARNING", "This dialog is read-only and cannot be edited.")
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1130,6 +1130,9 @@ void ModulWindow::GetState( SfxItemSet &rSet )
|
||||
if (!sProcName.isEmpty())
|
||||
aTitle += "." + sProcName;
|
||||
|
||||
if (IsReadOnly())
|
||||
aTitle += " (" + IDEResId(RID_STR_READONLY) + ")";
|
||||
|
||||
SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle );
|
||||
rSet.Put( aTitleItem );
|
||||
}
|
||||
|
||||
@@ -627,6 +627,13 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
||||
pBindings->Update( SID_BASICIDE_STAT_POS );
|
||||
pBindings->Update( SID_BASICIDE_STAT_TITLE );
|
||||
}
|
||||
if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_ALPHA ||
|
||||
rKEvt.GetKeyCode().GetGroup() == KEYGROUP_NUM )
|
||||
{
|
||||
// If the module is read-only, warn that it cannont be edited
|
||||
if ( rModulWindow.IsReadOnly() )
|
||||
rModulWindow.ShowReadOnlyInfoBar();
|
||||
}
|
||||
if ( !bWasModified && pEditEngine->IsModified() )
|
||||
{
|
||||
pBindings->Invalidate( SID_SAVEDOC );
|
||||
|
||||
@@ -1019,6 +1019,8 @@ void Shell::GetState(SfxItemSet &rSet)
|
||||
if ( pCurWin )
|
||||
{
|
||||
OUString aTitle = pCurWin->CreateQualifiedName();
|
||||
if (pCurWin->IsReadOnly())
|
||||
aTitle += " (" + IDEResId(RID_STR_READONLY) + ")";
|
||||
SfxStringItem aItem( SID_BASICIDE_STAT_TITLE, aTitle );
|
||||
rSet.Put( aItem );
|
||||
}
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
|
||||
#include <sal/log.hxx>
|
||||
#include <sfx2/dispatch.hxx>
|
||||
#include <sfx2/infobar.hxx>
|
||||
#include <sfx2/passwd.hxx>
|
||||
#include <sfx2/sfxsids.hrc>
|
||||
#include <sfx2/viewfrm.hxx>
|
||||
#include <svl/intitem.hxx>
|
||||
#include <svl/stritem.hxx>
|
||||
#include <svl/srchdefs.hxx>
|
||||
@@ -51,6 +53,9 @@
|
||||
namespace basctl
|
||||
{
|
||||
|
||||
// ID used for the read-only infobar
|
||||
constexpr OUStringLiteral BASIC_IDE_READONLY_INFOBAR = u"readonly";
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
@@ -87,6 +92,12 @@ void BaseWindow::Init()
|
||||
pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, VertScrollHdl ) );
|
||||
if ( pShellHScrollBar )
|
||||
pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, HorzScrollHdl ) );
|
||||
|
||||
// Show the read-only infobar if the module/dialog is read-only
|
||||
GetShell()->GetViewFrame()->RemoveInfoBar(BASIC_IDE_READONLY_INFOBAR);
|
||||
if (IsReadOnly())
|
||||
ShowReadOnlyInfoBar();
|
||||
|
||||
DoInit(); // virtual...
|
||||
}
|
||||
|
||||
@@ -220,6 +231,19 @@ bool BaseWindow::IsReadOnly ()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show the read-only warning messages for module and dialog windows
|
||||
void BaseWindow::ShowReadOnlyInfoBar()
|
||||
{
|
||||
OUString aMsg;
|
||||
if (dynamic_cast<ModulWindow*>(this))
|
||||
aMsg = IDEResId(RID_STR_MODULE_READONLY);
|
||||
else
|
||||
aMsg = IDEResId(RID_STR_DIALOG_READONLY);
|
||||
|
||||
GetShell()->GetViewFrame()->AppendInfoBar(BASIC_IDE_READONLY_INFOBAR, OUString(),
|
||||
aMsg, InfobarType::INFO, true);
|
||||
}
|
||||
|
||||
void BaseWindow::BasicStarted()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ public:
|
||||
|
||||
virtual void SetReadOnly (bool bReadOnly);
|
||||
virtual bool IsReadOnly();
|
||||
void ShowReadOnlyInfoBar();
|
||||
|
||||
int GetStatus() const { return nStatus; }
|
||||
void SetStatus(int n) { nStatus = n; }
|
||||
|
||||
Reference in New Issue
Block a user