summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/sfxsids.hrc3
-rw-r--r--include/sfx2/viewsh.hxx1
-rw-r--r--offapi/com/sun/star/document/MediaDescriptor.idl6
-rw-r--r--offapi/com/sun/star/frame/XModel2.idl2
-rw-r--r--sfx2/source/appl/appuno.cxx18
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx5
-rwxr-xr-xsfx2/source/view/viewfrm.cxx22
-rw-r--r--sfx2/source/view/viewsh.cxx9
-rw-r--r--sw/qa/python/check_xmodel.py4
9 files changed, 62 insertions, 8 deletions
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 0384afd22c29..cf2ebfff4da0 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -266,8 +266,9 @@ class SvxSearchItem;
#define SID_DIALOG_PARENT (SID_SFX_START + 1735)
#define SID_LOCK_PRINT (SID_SFX_START + 1736)
#define SID_LOCK_SAVE (SID_SFX_START + 1737)
+#define SID_LOCK_EDITDOC (SID_SFX_START + 1738)
-// SID_SFX_free_START (SID_SFX_START + 1737)
+// SID_SFX_free_START (SID_SFX_START + 1738)
// SID_SFX_free_END (SID_SFX_START + 3999)
#define SID_OPEN_NEW_VIEW (SID_SFX_START + 520)
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 26bf52279a13..d36fcab1c301 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -292,6 +292,7 @@ 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/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl
index 72ee23fcd2ee..728ef4ab4a29 100644
--- a/offapi/com/sun/star/document/MediaDescriptor.idl
+++ b/offapi/com/sun/star/document/MediaDescriptor.idl
@@ -590,6 +590,12 @@ service MediaDescriptor
@since LibreOffice 6.4
*/
[optional,property] boolean LockSave;
+
+ /** Setting this option will disable switching to edit mode from read-only mode.
+ *
+ @since LibreOffice 6.4
+ */
+ [optional,property] boolean LockEditDoc;
};
diff --git a/offapi/com/sun/star/frame/XModel2.idl b/offapi/com/sun/star/frame/XModel2.idl
index 95372afd925c..0c896ad1cb73 100644
--- a/offapi/com/sun/star/frame/XModel2.idl
+++ b/offapi/com/sun/star/frame/XModel2.idl
@@ -146,7 +146,7 @@ interface XModel2 : com::sun::star::frame::XModel
<li>com::sun::star::document::MediaDescriptor::LockExport</li>
<li>com::sun::star::document::MediaDescriptor::LockPrint</li>
<li>com::sun::star::document::MediaDescriptor::LockSave</li>
-
+ <li>com::sun::star::document::MediaDescriptor::LockEditDoc</li>
</ul>
@throws com::sun::star::lang::IllegalArgumentException When trying to set an unsupported property
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index b076b5c59a19..8a5fa22cbb06 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -173,6 +173,7 @@ static char const sLockContentExtraction[] = "LockContentExtraction";
static char const sLockExport[] = "LockExport";
static char const sLockPrint[] = "LockPrint";
static char const sLockSave[] = "LockSave";
+static char const sLockEditDoc[] = "LockEditDoc";
static bool isMediaDescriptor( sal_uInt16 nSlotId )
{
@@ -888,6 +889,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
if (bOK)
rSet.Put( SfxBoolItem( SID_LOCK_SAVE, bVal ) );
}
+ else if (aName == sLockEditDoc)
+ {
+ bool bVal = false;
+ bool bOK = (rProp.Value >>= bVal);
+ DBG_ASSERT( bOK, "invalid type for LockEditDoc" );
+ if (bOK)
+ rSet.Put( SfxBoolItem( SID_LOCK_EDITDOC, bVal ) );
+ }
#ifdef DBG_UTIL
else
--nFoundArgs;
@@ -1117,6 +1126,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
nAdditional++;
if ( rSet.GetItemState( SID_LOCK_SAVE ) == SfxItemState::SET )
nAdditional++;
+ if ( rSet.GetItemState( SID_LOCK_EDITDOC ) == SfxItemState::SET )
+ nAdditional++;
// consider additional arguments
nProps += nAdditional;
@@ -1282,6 +1293,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
continue;
if ( nId == SID_LOCK_SAVE )
continue;
+ if ( nId == SID_LOCK_EDITDOC )
+ continue;
}
OStringBuffer aDbg("Unknown item detected: ");
@@ -1697,6 +1710,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
pValue[nActProp].Name = sLockSave;
pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
}
+ if ( rSet.GetItemState( SID_LOCK_EDITDOC, false, &pItem ) == SfxItemState::SET )
+ {
+ pValue[nActProp].Name = sLockEditDoc;
+ pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ }
}
rArgs = aSequ;
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 6410c3096d56..5010d462e419 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1094,6 +1094,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
rArg.Value >>= bValue;
pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_SAVE, bValue));
}
+ else if (rArg.Name == "LockEditDoc")
+ {
+ rArg.Value >>= bValue;
+ pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_EDITDOC, bValue));
+ }
else
{
throw lang::IllegalArgumentException("Setting property not supported: " + aArgs[i].Name,
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index cb900628df05..4fa88c354f99 100755
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -277,6 +277,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ))
break;
+ SfxViewShell* pViewSh = GetViewShell();
+ if (pViewSh && pViewSh->isEditDocLocked())
+ break;
+
// Only change read-only UI and remove info bar when we succeed
struct ReadOnlyUIGuard
{
@@ -864,6 +868,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
const SfxShell *pFSh;
if ( !pSh->HasName() ||
!( pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) ||
+ (GetViewShell() && GetViewShell()->isEditDocLocked()) ||
( pSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED &&
( !(pVSh = pSh->GetViewShell()) ||
!(pFSh = pVSh->GetFormShell()) ||
@@ -1347,11 +1352,18 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
pInfoBar->addButton(xSignButton);
}
- VclPtrInstance<PushButton> xBtn(&GetWindow());
- xBtn->SetText(SfxResId(STR_READONLY_EDIT));
- xBtn->SetSizePixel(xBtn->GetOptimalSize());
- xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
- pInfoBar->addButton(xBtn);
+ bool showEditDocumentButton = true;
+ if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked())
+ showEditDocumentButton = false;
+
+ if (showEditDocumentButton)
+ {
+ VclPtrInstance<PushButton> xBtn(&GetWindow());
+ xBtn->SetText(SfxResId(STR_READONLY_EDIT));
+ xBtn->SetSizePixel(xBtn->GetOptimalSize());
+ xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
+ pInfoBar->addButton(xBtn);
+ }
}
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 5ced6bdb9c37..6767bf0e98da 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1802,6 +1802,15 @@ bool SfxViewShell::isPrintLocked()
return aArgs.getOrDefault("LockPrint", false);
}
+bool SfxViewShell::isEditDocLocked()
+{
+ Reference<XModel> xModel = GetCurrentDocument();
+ if (!xModel.is())
+ return false;
+ comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ return aArgs.getOrDefault("LockEditDoc", false);
+}
+
bool SfxViewShell::isSaveLocked()
{
Reference<XModel> xModel = GetCurrentDocument();
diff --git a/sw/qa/python/check_xmodel.py b/sw/qa/python/check_xmodel.py
index c257ef33fb79..f6894dd21a3f 100644
--- a/sw/qa/python/check_xmodel.py
+++ b/sw/qa/python/check_xmodel.py
@@ -36,7 +36,8 @@ class TestXModel(unittest.TestCase):
p4 = PropertyValue(Name="LockExport", Value=True)
p5 = PropertyValue(Name="LockPrint", Value=True)
p6 = PropertyValue(Name="LockSave", Value=True)
- xDoc.setArgs([p1, p2, p3, p4, p5, p6])
+ p7 = PropertyValue(Name="LockEditDoc", Value=True)
+ xDoc.setArgs([p1, p2, p3, p4, p5, p6, p7])
# Make sure that all properties are returned with getArgs()
args = xDoc.getArgs()
@@ -46,6 +47,7 @@ class TestXModel(unittest.TestCase):
self.assertTrue(p4 in args)
self.assertTrue(p5 in args)
self.assertTrue(p6 in args)
+ self.assertTrue(p7 in args)
xDoc.close(True)