Kaydet (Commit) e2a5932d authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Caolán McNamara

tdf#41063: don't jump to cursor when saving

Reuse the fix from commits e1218439
and 36c84fa3.

Change-Id: I5b7cdc321c6e30e994732d2c0295e494a172a2e2
Reviewed-on: https://gerrit.libreoffice.org/58034
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 4c702afe
......@@ -51,6 +51,7 @@ class IDocumentDeviceAccess;
class IDocumentChartDataProviderAccess;
class SwDocShell;
class SwDrawModel;
class SwViewShell;
namespace svt
{
class EmbeddedObjectRef;
......@@ -318,6 +319,17 @@ public:
void RegisterAutomationDocumentEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
void CallAutomationDocumentEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
void RegisterAutomationDocumentObject(css::uno::Reference< ooo::vba::word::XDocument > const& xDocument);
class LockAllViewsGuard
{
std::vector<SwViewShell*> m_aViewWasUnLocked;
public:
explicit LockAllViewsGuard(SwViewShell* pViewShell);
~LockAllViewsGuard();
};
// Lock all unlocked views, and returns a guard object which unlocks those views when destructed
std::unique_ptr<LockAllViewsGuard> LockAllViews();
};
/** Find the right DocShell and create a new one:
......
......@@ -39,35 +39,6 @@
using namespace ::com::sun::star;
namespace
{
class LockAllViews
{
std::vector<SwViewShell*> m_aViewWasUnLocked;
SwViewShell* m_pViewShell;
public:
explicit LockAllViews(SwViewShell *pViewShell)
: m_pViewShell(pViewShell)
{
if (!m_pViewShell)
return;
for (SwViewShell& rShell : m_pViewShell->GetRingContainer())
{
if (!rShell.IsViewLocked())
{
m_aViewWasUnLocked.push_back(&rShell);
rShell.LockView(true);
}
}
}
~LockAllViews()
{
for(SwViewShell* pShell : m_aViewWasUnLocked)
pShell->LockView(false);
}
};
}
namespace sw
{
......@@ -218,7 +189,7 @@ bool DocumentStatisticsManager::IncrementalDocStatCalculate(long nChars, bool bF
const ModifyBlocker_Impl b(pObjShell);
// rhbz#1081176: don't jump to cursor pos because of (temporary)
// activation of modified flag triggering move to input position
LockAllViews aViewGuard(pObjShell->GetEditShell());
auto aViewGuard(pObjShell->LockAllViews());
xDocProps->setDocumentStatistics(aStat);
if (!bDocWasModified)
{
......
......@@ -130,6 +130,7 @@
#include <sal/log.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <o3tl/make_unique.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
......@@ -382,10 +383,37 @@ bool SwDocShell::Save()
return !nErr.IsError();
}
SwDocShell::LockAllViewsGuard::LockAllViewsGuard(SwViewShell* pViewShell)
{
if (!pViewShell)
return;
for (SwViewShell& rShell : pViewShell->GetRingContainer())
{
if (!rShell.IsViewLocked())
{
m_aViewWasUnLocked.push_back(&rShell);
rShell.LockView(true);
}
}
}
SwDocShell::LockAllViewsGuard::~LockAllViewsGuard()
{
for (SwViewShell* pShell : m_aViewWasUnLocked)
pShell->LockView(false);
}
std::unique_ptr<SwDocShell::LockAllViewsGuard> SwDocShell::LockAllViews()
{
return o3tl::make_unique<LockAllViewsGuard>(GetEditShell());
}
// Save using the Defaultformat
bool SwDocShell::SaveAs( SfxMedium& rMedium )
{
SwWait aWait( *this, true );
// tdf#41063: prevent jumping to cursor at any temporary modification
auto aViewGuard(LockAllViews());
//#i3370# remove quick help to prevent saving of autocorrection suggestions
if (m_pView)
m_pView->GetEditWin().StopQuickHelp();
......
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