summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx10
-rw-r--r--include/sfx2/lokhelper.hxx4
-rw-r--r--sfx2/source/view/lokhelper.cxx30
3 files changed, 38 insertions, 6 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 22a0abd3a6e3..a857dec6f3f5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7232,26 +7232,24 @@ static void doc_setViewTimezone(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*p
}
}
-static void doc_setViewReadOnly(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis, int nId, const bool readOnly)
+static void doc_setViewReadOnly(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId, const bool readOnly)
{
comphelper::ProfileZone aZone("doc_setViewReadOnly");
SolarMutexGuard aGuard;
SetLastExceptionMsg();
- doc_setView(pThis, nId);
- SfxViewShell::Current()->SetLokReadOnlyView(readOnly);
+ SfxLokHelper::setViewReadOnly(nId, readOnly);
}
-static void doc_setAllowChangeComments(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis, int nId, const bool allow)
+static void doc_setAllowChangeComments(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId, const bool allow)
{
comphelper::ProfileZone aZone("doc_setAllowChangeComments");
SolarMutexGuard aGuard;
SetLastExceptionMsg();
- doc_setView(pThis, nId);
- SfxViewShell::Current()->SetAllowChangeComments(allow);
+ SfxLokHelper::setAllowChangeComments(nId, allow);
}
static void doc_setAccessibilityState(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis, int nId, bool nEnabled)
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index c4e88035fd96..3820558d6500 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -119,6 +119,10 @@ public:
static void setDefaultLanguage(const OUString& rBcp47LanguageTag);
/// Enable/Disable AT support for the given view.
static void setAccessibilityState(int nId, bool nEnabled);
+ // Set the readonly state of the view.
+ static void setViewReadOnly(int nId, bool readOnly);
+ // In readonly view, can user add / modify comments or not.
+ static void setAllowChangeComments(int nId, bool allow);
/// Get the language used by the loading view (used for all save operations).
static const LanguageTag & getLoadLanguage();
/// Set the language used by the loading view (used for all save operations).
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index ff9f1a8175bf..145484fce9e7 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -342,6 +342,36 @@ void SfxLokHelper::setViewLanguage(int nId, const OUString& rBcp47LanguageTag)
}
}
+void SfxLokHelper::setViewReadOnly(int nId, bool readOnly)
+{
+ std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+
+ for (SfxViewShell* pViewShell : rViewArr)
+ {
+ if (pViewShell && pViewShell->GetViewShellId() == ViewShellId(nId))
+ {
+ LOK_INFO("lok.readonlyview", "SfxLokHelper::setViewReadOnly: view id: " << nId << ", readOnly: " << readOnly);
+ pViewShell->SetLokReadOnlyView(readOnly);
+ return;
+ }
+ }
+}
+
+void SfxLokHelper::setAllowChangeComments(int nId, bool allow)
+{
+ std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+
+ for (SfxViewShell* pViewShell : rViewArr)
+ {
+ if (pViewShell && pViewShell->GetViewShellId() == ViewShellId(nId))
+ {
+ LOK_INFO("lok.readonlyview", "SfxLokHelper::setAllowChangeComments: view id: " << nId << ", allow: " << allow);
+ pViewShell->SetAllowChangeComments(allow);
+ return;
+ }
+ }
+}
+
void SfxLokHelper::setAccessibilityState(int nId, bool nEnabled)
{
std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();