Fix edit button still appearing in Calc
... even when editing readonly docs was disabled. Viewshell was not yet available at this point, so move the code where it belongs, into the object shell. Change-Id: I71cbaf9c912beeeb0b8177538999049f7f8b4e03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91832 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
@@ -585,6 +585,8 @@ public:
|
||||
const css::uno::Reference<css::embed::XStorage>& xTarget,
|
||||
const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>());
|
||||
|
||||
bool isEditDocLocked();
|
||||
|
||||
// The functions from SvPersist
|
||||
void EnableSetModified( bool bEnable = true );
|
||||
bool IsEnableSetModified() const;
|
||||
|
@@ -293,7 +293,6 @@ public:
|
||||
bool isExportLocked();
|
||||
bool isPrintLocked();
|
||||
bool isSaveLocked();
|
||||
bool isEditDocLocked();
|
||||
|
||||
SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const;
|
||||
SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const css::uno::Reference < css::ui::XContextMenuInterceptor >& xInterceptor );
|
||||
|
@@ -75,6 +75,8 @@
|
||||
#include <comphelper/interaction.hxx>
|
||||
#include <comphelper/storagehelper.hxx>
|
||||
#include <comphelper/documentconstants.hxx>
|
||||
#include <comphelper/namedvaluecollection.hxx>
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
|
||||
#include <sfx2/signaturestate.hxx>
|
||||
#include <sfx2/app.hxx>
|
||||
@@ -1867,4 +1869,15 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions(const OUString& aErrMess
|
||||
return mbContinueImportOnFilterExceptions == yes;
|
||||
}
|
||||
|
||||
bool SfxObjectShell::isEditDocLocked()
|
||||
{
|
||||
Reference<XModel> xModel = GetModel();
|
||||
if (!xModel.is())
|
||||
return false;
|
||||
if (!officecfg::Office::Common::Misc::AllowEditReadonlyDocs::get())
|
||||
return true;
|
||||
comphelper::NamedValueCollection aArgs(xModel->getArgs());
|
||||
return aArgs.getOrDefault("LockEditDoc", false);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -291,8 +291,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
|
||||
if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ))
|
||||
break;
|
||||
|
||||
SfxViewShell* pViewSh = GetViewShell();
|
||||
if (pViewSh && pViewSh->isEditDocLocked())
|
||||
if (pSh->isEditDocLocked())
|
||||
break;
|
||||
|
||||
// Only change read-only UI and remove info bar when we succeed
|
||||
@@ -911,7 +910,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
|
||||
const SfxShell *pFSh;
|
||||
if ( !pSh->HasName() ||
|
||||
!( pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) ||
|
||||
(GetViewShell() && GetViewShell()->isEditDocLocked()) ||
|
||||
(pSh->isEditDocLocked()) ||
|
||||
( pSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED &&
|
||||
( !(pVSh = pSh->GetViewShell()) ||
|
||||
!(pFSh = pVSh->GetFormShell()) ||
|
||||
@@ -1399,7 +1398,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
|
||||
}
|
||||
|
||||
bool showEditDocumentButton = true;
|
||||
if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked())
|
||||
if (m_xObjSh->isEditDocLocked())
|
||||
showEditDocumentButton = false;
|
||||
|
||||
if (showEditDocumentButton)
|
||||
|
@@ -1779,17 +1779,6 @@ bool SfxViewShell::isPrintLocked()
|
||||
return aArgs.getOrDefault("LockPrint", false);
|
||||
}
|
||||
|
||||
bool SfxViewShell::isEditDocLocked()
|
||||
{
|
||||
Reference<XModel> xModel = GetCurrentDocument();
|
||||
if (!xModel.is())
|
||||
return false;
|
||||
if (!officecfg::Office::Common::Misc::AllowEditReadonlyDocs::get())
|
||||
return true;
|
||||
comphelper::NamedValueCollection aArgs(xModel->getArgs());
|
||||
return aArgs.getOrDefault("LockEditDoc", false);
|
||||
}
|
||||
|
||||
bool SfxViewShell::isSaveLocked()
|
||||
{
|
||||
Reference<XModel> xModel = GetCurrentDocument();
|
||||
|
Reference in New Issue
Block a user