Kaydet (Commit) 60714a81 authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#121606: displaying Mail Merge toolbar shouldn't activate connection

At least I think so. Thus now the code that queries the state of the
toolbar controls only queries dataset if connection is active.

Operating the navigation buttons (next/prev) will, naturally, activate
connection if not yet active. This should also enable the other controls
that may be initially disabled: create/save/print/email documents. Thus,
the navigation controls also check if they have activated the connection,
and invalidate said document creation controls state. Possibly there's a
better place for the invalidation of the controls, but I was unable to
find one.

Regression after commit 5c2c5ff0

Change-Id: I76f895c871718c9c761339ba03963baf6837b592
Reviewed-on: https://gerrit.libreoffice.org/64738
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst beae6c7a
...@@ -156,7 +156,8 @@ void SwModule::StateOther(SfxItemSet &rSet) ...@@ -156,7 +156,8 @@ void SwModule::StateOther(SfxItemSet &rSet)
xConfigItem = pView->GetMailMergeConfigItem(); xConfigItem = pView->GetMailMergeConfigItem();
if (!xConfigItem) if (!xConfigItem)
rSet.DisableItem(nWhich); rSet.DisableItem(nWhich);
else else if (xConfigItem->GetConnection().is()
&& !xConfigItem->GetConnection()->isClosed())
{ {
bool bFirst, bLast; bool bFirst, bLast;
bool bValid = xConfigItem->IsResultSetFirstLast(bFirst, bLast); bool bValid = xConfigItem->IsResultSetFirstLast(bFirst, bLast);
...@@ -209,6 +210,8 @@ void SwModule::StateOther(SfxItemSet &rSet) ...@@ -209,6 +210,8 @@ void SwModule::StateOther(SfxItemSet &rSet)
// #i51949# hide e-Mail option if e-Mail is not supported // #i51949# hide e-Mail option if e-Mail is not supported
// #i63267# printing might be disabled // #i63267# printing might be disabled
if (!xConfigItem || if (!xConfigItem ||
!xConfigItem->GetConnection().is() ||
xConfigItem->GetConnection()->isClosed() ||
!xConfigItem->GetResultSet().is() || !xConfigItem->GetResultSet().is() ||
xConfigItem->GetCurrentDBData().sDataSource.isEmpty() || xConfigItem->GetCurrentDBData().sDataSource.isEmpty() ||
xConfigItem->GetCurrentDBData().sCommand.isEmpty() || xConfigItem->GetCurrentDBData().sCommand.isEmpty() ||
...@@ -729,6 +732,9 @@ void SwModule::ExecOther(SfxRequest& rReq) ...@@ -729,6 +732,9 @@ void SwModule::ExecOther(SfxRequest& rReq)
if (!xConfigItem) if (!xConfigItem)
return; return;
const bool bHadConnection
= xConfigItem->GetConnection().is() && !xConfigItem->GetConnection()->isClosed();
sal_Int32 nPos = xConfigItem->GetResultSetPosition(); sal_Int32 nPos = xConfigItem->GetResultSetPosition();
switch (nWhich) switch (nWhich)
{ {
...@@ -766,6 +772,15 @@ void SwModule::ExecOther(SfxRequest& rReq) ...@@ -766,6 +772,15 @@ void SwModule::ExecOther(SfxRequest& rReq)
rBindings.Invalidate(FN_MAILMERGE_LAST_ENTRY); rBindings.Invalidate(FN_MAILMERGE_LAST_ENTRY);
rBindings.Invalidate(FN_MAILMERGE_CURRENT_ENTRY); rBindings.Invalidate(FN_MAILMERGE_CURRENT_ENTRY);
rBindings.Invalidate(FN_MAILMERGE_EXCLUDE_ENTRY); rBindings.Invalidate(FN_MAILMERGE_EXCLUDE_ENTRY);
if (!bHadConnection && xConfigItem->GetConnection().is()
&& !xConfigItem->GetConnection()->isClosed())
{
// The connection has been activated. Update controls that were disabled
rBindings.Invalidate(FN_MAILMERGE_CREATE_DOCUMENTS);
rBindings.Invalidate(FN_MAILMERGE_SAVE_DOCUMENTS);
rBindings.Invalidate(FN_MAILMERGE_PRINT_DOCUMENTS);
rBindings.Invalidate(FN_MAILMERGE_EMAIL_DOCUMENTS);
}
rBindings.Update(); rBindings.Update();
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment