diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index dd7d637a7de1..ae7d32e34d54 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -585,6 +585,8 @@ public: const css::uno::Reference& xTarget, const css::uno::Sequence& rExceptions = css::uno::Sequence()); + bool isEditDocLocked(); + // The functions from SvPersist void EnableSetModified( bool bEnable = true ); bool IsEnableSetModified() const; diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index e81d2db11b7b..47a50f23a3df 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -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 ); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 7bf2c77de4ef..7cc979a87e43 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -75,6 +75,8 @@ #include #include #include +#include +#include #include #include @@ -1867,4 +1869,15 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions(const OUString& aErrMess return mbContinueImportOnFilterExceptions == yes; } +bool SfxObjectShell::isEditDocLocked() +{ + Reference 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: */ diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 6267aee23ed1..3a0572058932 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -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) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 62c20909102c..d34b1d817a07 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1779,17 +1779,6 @@ bool SfxViewShell::isPrintLocked() return aArgs.getOrDefault("LockPrint", false); } -bool SfxViewShell::isEditDocLocked() -{ - Reference 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 = GetCurrentDocument();