summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-08 08:54:21 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-09 11:14:15 +0200
commit65404e2c72ea2d5d3f6c074121005b8b9369e7fb (patch)
tree15eeeb5b634c461611893dbe3b49d689ef71f5c4 /sfx2
parent40d83914d43f60a196dfabddea0b52e2046b333a (diff)
Move is*Locked methods to object shell
They depend on the model, not the view. Follow-up to 523922ee9d033fd304d2b50a72b76853ddcfbcdf Change-Id: I429bc25b8dd4f04ebf62eddd5ef455b5161e925d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91867 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objmisc.cxx36
-rw-r--r--sfx2/source/doc/objserv.cxx16
-rw-r--r--sfx2/source/view/viewsh.cxx44
3 files changed, 46 insertions, 50 deletions
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 7cc979a87e43..81f9f9ce4573 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1880,4 +1880,40 @@ bool SfxObjectShell::isEditDocLocked()
return aArgs.getOrDefault("LockEditDoc", false);
}
+bool SfxObjectShell::isContentExtractionLocked()
+{
+ Reference<XModel> xModel = GetModel();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockContentExtraction", false);
+}
+
+bool SfxObjectShell::isExportLocked()
+{
+ Reference<XModel> xModel = GetModel();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockExport", false);
+}
+
+bool SfxObjectShell::isPrintLocked()
+{
+ Reference<XModel> xModel = GetModel();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockPrint", false);
+}
+
+bool SfxObjectShell::isSaveLocked()
+{
+ Reference<XModel> xModel = GetModel();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockSave", false);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 96f932049c28..7e29c9b7ded9 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1098,8 +1098,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
{
case SID_DOCTEMPLATE :
{
- SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
- if ( pFrame && pFrame->GetViewShell()->isExportLocked())
+ if ( isExportLocked())
rSet.DisableItem( nWhich );
break;
}
@@ -1183,8 +1182,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
}
case SID_SAVEDOC:
{
- SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
- if ( IsReadOnly() || (pFrame && pFrame->GetViewShell()->isSaveLocked()))
+ if ( IsReadOnly() || isSaveLocked())
{
rSet.DisableItem(nWhich);
break;
@@ -1204,9 +1202,8 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_SAVEASDOC:
{
- SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT)
- || (pFrame && pFrame->GetViewShell()->isExportLocked()))
+ || isExportLocked())
{
rSet.DisableItem( nWhich );
break;
@@ -1220,9 +1217,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_SAVEACOPY:
{
- SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
- if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT)
- || (pFrame && pFrame->GetViewShell()->isExportLocked()))
+ if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT) || isExportLocked())
{
rSet.DisableItem( nWhich );
break;
@@ -1243,8 +1238,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_AUTOREDACTDOC:
case SID_SAVEASREMOTE:
{
- SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
- if (pFrame && pFrame->GetViewShell()->isExportLocked())
+ if (isExportLocked())
rSet.DisableItem( nWhich );
break;
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index d34b1d817a07..bc2ca6a447f6 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -658,6 +658,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
{
SfxWhichIter aIter( rSet );
+ SfxObjectShell *pSh = GetViewFrame()->GetObjectShell();
for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
{
switch ( nSID )
@@ -673,13 +674,13 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
#if HAVE_FEATURE_MACOSX_SANDBOX
rSet.DisableItem(nSID);
#endif
- if (isExportLocked() && nSID != SID_MAIL_SENDDOC)
+ if (pSh && pSh->isExportLocked() && nSID != SID_MAIL_SENDDOC)
rSet.DisableItem(nSID);
break;
}
case SID_WEBHTML:
{
- if (isExportLocked())
+ if (pSh && pSh->isExportLocked())
rSet.DisableItem(nSID);
break;
}
@@ -689,7 +690,8 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
case SID_SETUPPRINTER:
case SID_PRINTER_NAME:
{
- if (Application::GetSettings().GetMiscSettings().GetDisablePrinting() || isPrintLocked())
+ if (Application::GetSettings().GetMiscSettings().GetDisablePrinting()
+ || (pSh && pSh->isPrintLocked()))
{
rSet.DisableItem(nSID);
break;
@@ -1752,42 +1754,6 @@ void SfxViewShell::SetController( SfxBaseController* pController )
pImpl->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() );
}
-bool SfxViewShell::isContentExtractionLocked()
-{
- Reference<XModel> xModel = GetCurrentDocument();
- if (!xModel.is())
- return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
- return aArgs.getOrDefault("LockContentExtraction", false);
-}
-
-bool SfxViewShell::isExportLocked()
-{
- Reference<XModel> xModel = GetCurrentDocument();
- if (!xModel.is())
- return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
- return aArgs.getOrDefault("LockExport", false);
-}
-
-bool SfxViewShell::isPrintLocked()
-{
- Reference<XModel> xModel = GetCurrentDocument();
- if (!xModel.is())
- return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
- return aArgs.getOrDefault("LockPrint", false);
-}
-
-bool SfxViewShell::isSaveLocked()
-{
- Reference<XModel> xModel = GetCurrentDocument();
- if (!xModel.is())
- return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
- return aArgs.getOrDefault("LockSave", false);
-}
-
Reference < XController > SfxViewShell::GetController() const
{
return pImpl->m_pController.get();