libreoffice/VBA-macro-modification-warning.diff

145 lines
5.9 KiB
Diff

From cfc71b418d27bbfaec195238764078fd5881bab3 Mon Sep 17 00:00:00 2001
From: Jan Holesovsky <kendy@collabora.com>
Date: Thu, 22 May 2014 17:29:56 +0200
Subject: [PATCH] bnc#467278: Introduce a warning that changes to VBA macros
cannot be saved.
As an InfoBar, so hopefully not annoying...
Conflicts:
basctl/source/basicide/basidesh.cxx
Change-Id: I5d4e79273edc03829fdab2d6d5a291576c954e4b
---
basctl/inc/basidesh.hrc | 1 +
basctl/source/basicide/basidesh.cxx | 9 +++++++++
basctl/source/basicide/basidesh.src | 4 ++++
include/sfx2/viewfrm.hxx | 2 +-
4 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/basctl/inc/basidesh.hrc b/basctl/inc/basidesh.hrc
index 623cb0e..a40f788 100644
--- a/basctl/inc/basidesh.hrc
+++ b/basctl/inc/basidesh.hrc
@@ -68,6 +68,7 @@
#define RID_STR_OPEN ( RID_BASICIDE_START + 20 )
#define RID_STR_SAVE ( RID_BASICIDE_START + 21 )
#define RID_STR_RUNTIMEERROR ( RID_BASICIDE_START + 22 )
+#define RID_STR_CANNOTSAVEVBA ( RID_BASICIDE_START + 23 )
#define RID_STR_STDDIALOGNAME ( RID_BASICIDE_START + 24 )
#define RID_STR_STDMODULENAME ( RID_BASICIDE_START + 27 )
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 674775b..f95e6f4 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -35,6 +35,7 @@
#include <sfx2/app.hxx>
#include <sfx2/dinfdlg.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/infobar.hxx>
#include <sfx2/minfitem.hxx>
#include <sfx2/objface.hxx>
#include <svl/aeitem.hxx>
@@ -137,6 +138,7 @@ SFX_IMPL_INTERFACE( basctl_Shell, SfxViewShell, IDEResId( RID_STR_IDENAME ) )
{
SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_SHOW_PROPERTYBROWSER, BASICIDE_UI_FEATURE_SHOW_BROWSER);
+ SFX_CHILDWINDOW_REGISTRATION(SfxInfoBarContainerChild::GetChildWindowId());
SFX_POPUPMENU_REGISTRATION( IDEResId( RID_POPUP_DLGED ) );
}
@@ -250,7 +252,14 @@ Shell::~Shell()
void Shell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
{
if (pCurWin)
+ {
pCurWin->OnNewDocument();
+
+ // for VBA documents, show a warning that we can save them only in ODF
+ if (pCurWin->GetDocument().isInVBAMode())
+ GetViewFrame()->AppendInfoBar("vba_save", IDE_RESSTR(RID_STR_CANNOTSAVEVBA));
+ }
+
UpdateWindows();
}
diff --git a/basctl/source/basicide/basidesh.src b/basctl/source/basicide/basidesh.src
index 6876130..5e019fd 100644
--- a/basctl/source/basicide/basidesh.src
+++ b/basctl/source/basicide/basidesh.src
@@ -216,6 +216,10 @@ String RID_STR_CANNOTCLOSE
{
Text [ en-US ] = "The window cannot be closed while BASIC is running." ;
};
+String RID_STR_CANNOTSAVEVBA
+{
+ Text [ en-US ] = "You are editing a VBA macro. Changes can be saved only in OpenDocument Format." ;
+};
String RID_STR_REPLACESTDLIB
{
Text [ en-US ] = "The default library cannot be replaced." ;
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index cf316b7..8541397 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -190,7 +190,7 @@ public:
The buttons will be added from Right to Left at the right of the info bar. The parent, size
and position of each button will be changed: only the width will remain unchanged.
*/
- void AppendInfoBar( const OUString& sId, const OUString& sMessage, std::vector< PushButton* > aButtons );
+ void AppendInfoBar( const OUString& sId, const OUString& sMessage, std::vector< PushButton* > aButtons = std::vector< PushButton* >() );
void RemoveInfoBar( const OUString& sId );
SAL_DLLPRIVATE void SetDowning_Impl();
--
1.8.4.5
From 39a589e1cf9340e95d63602afd272faccbaac9a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@collabora.com>
Date: Fri, 23 May 2014 18:48:53 +0200
Subject: [PATCH] force posted events before timer timeouts in KDE4 event loop
(bnc#467278)
In this particular case, basctl::Shell::onDocumentCreated() and pretty much
everything in basctl/ it seems operate on the current window. The "OnNew"
event that triggers this comes from a timeout generated who knows where
for whatever reason. However, the code "knows" what the current window
is by having basctl::Shell::SetCurWindow() react on events about the current
window changing ... which come from posted events.
So, unless it's defined somewhere that an ordering here must exist, this
is inherently racy. At least generic and Gtk event loops appear to always
deliver the posted event first, so force the same ordering in the KDE
event loop handling.
Change-Id: Ia098f6b45e6b5a5133a12a9172eb09069e6362f9
---
vcl/unx/kde4/KDEXLib.cxx | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 2630c0c..9d2949e 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -349,6 +349,16 @@ void KDEXLib::StopTimer()
void KDEXLib::timeoutActivated()
{
+ // HACK? Always process posted events before timer timeouts.
+ // There are places that may watch both both (for example, there's a posted
+ // event about change of the current active window and there's a timeout
+ // event informing that a document has finished loading). This is of course
+ // racy, but both generic and gtk event loops manage to deliver posted events
+ // first, so it's at least consistent, and it probably kind of makes at least
+ // some sense (timeouts should be more ok to wait and be triggered somewhen).
+ while( SalKDEDisplay::self()->HasUserEvents() )
+ SalKDEDisplay::self()->DispatchInternalEvent();
+
X11SalData *pData = (X11SalData*)ImplGetSVData()->mpSalData;
pData->Timeout();
// QTimer is not single shot, so will be restarted immediatelly
--
1.8.4.5