framework/inc/uielement/styletoolbarcontroller.hxx             |    4 
 framework/source/uielement/styletoolbarcontroller.cxx          |   47 
+++++++---
 officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu   |   42 ++++++++
 officecfg/registry/schema/org/openoffice/Office/Common.xcs     |    6 +
 officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs |    6 +
 sfx2/inc/sidebar/DeckDescriptor.hxx                            |    1 
 sfx2/source/dialog/backingwindow.cxx                           |   13 ++
 sfx2/source/doc/docfile.cxx                                    |    4 
 sfx2/source/doc/objmisc.cxx                                    |    3 
 sfx2/source/sidebar/DeckDescriptor.cxx                         |    1 
 sfx2/source/sidebar/ResourceManager.cxx                        |    5 +
 sfx2/source/view/frmload.cxx                                   |    5 +
 sfx2/source/view/viewfrm.cxx                                   |    6 +
 sw/sdi/swriter.sdi                                             |    6 -
 14 files changed, 133 insertions(+), 16 deletions(-)

New commits:
commit 531656832265eaad9ba7bf4a2bc9103bd9544be8
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Dec 6 16:15:30 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Dec 11 11:42:41 2024 +0100

    Mark some Writer slots as inactive in readonly mode
    
    Change-Id: Ic27b5558a835d1adaca5af52ae7ec5c81643a9e4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177962
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 77403112479e..dd123e29f6cf 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -4160,7 +4160,7 @@ SfxBoolItem HighlightCharDF FN_HIGHLIGHT_CHAR_DF
 [
     AutoUpdate = TRUE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = TRUE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5330,7 +5330,7 @@ SfxVoidItem Repaginate FN_REPAGINATE
 [
     AutoUpdate = FALSE,
     FastCall = TRUE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -6490,7 +6490,7 @@ SfxBoolItem TableNumberRecognition FN_SET_MODOPT_TBLNUMFMT
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
commit 08f1b209c4843ff3c7f4281641ec644569f63d17
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Dec 6 00:55:59 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Dec 11 11:42:36 2024 +0100

    tdf#62845: Hide some sidebar panels in Viewer app mode
    
    These are confusing and cluttering the UI in this mode.
    
    Change-Id: I909f17f71846f5a7e82e43f078f32ed7b5daf159
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177961
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
index 543d13edf274..48bf19ab3923 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
@@ -39,6 +39,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>100</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="InspectorDeck" oor:op="replace">
@@ -59,6 +62,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>600</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="WriterPageDeck" oor:op="replace">
@@ -79,6 +85,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>500</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="CommentsDeck" oor:op="replace">
@@ -122,6 +131,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>900</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="ShapesDeck" oor:op="replace">
@@ -142,6 +154,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>500</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
 
@@ -165,6 +180,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>300</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="SdMasterPagesDeck" oor:op="replace">
@@ -185,6 +203,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>700</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="SdCustomAnimationDeck" oor:op="replace">
@@ -205,6 +226,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>600</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="SdSlideTransitionDeck" oor:op="replace">
@@ -225,6 +249,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>500</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="NavigatorDeck" oor:op="replace">
@@ -269,6 +296,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>200</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="ScFunctionsDeck" oor:op="replace">
@@ -289,6 +319,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>500</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="SwManageChangesDeck" oor:op="replace">
@@ -313,6 +346,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>600</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="SwDesignDeck" oor:op="replace">
@@ -336,6 +372,9 @@
         <prop oor:name="IsExperimental" oor:type="xs:boolean">
           <value>true</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="ElementsDeck" oor:op="replace">
@@ -356,6 +395,9 @@
         <prop oor:name="OrderIndex" oor:type="xs:int">
           <value>300</value>
         </prop>
+        <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
       </node>
 
       <node oor:name="FindDeck" oor:op="replace">
diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs 
b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
index 28adbee51e30..e619c9028922 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
@@ -140,6 +140,12 @@
         </info>
         <value>false</value>
       </prop>
+      <prop oor:name="HiddenInViewer" oor:type="xs:boolean">
+        <info>
+          <desc>This flag controls whether the deck is hidden when viewer 
application mode is enabled.</desc>
+        </info>
+        <value>false</value>
+      </prop>
     </group>
     <group oor:name="Panel">
       <info>
diff --git a/sfx2/inc/sidebar/DeckDescriptor.hxx 
b/sfx2/inc/sidebar/DeckDescriptor.hxx
index 8fde0c0330f7..dc9174c79383 100644
--- a/sfx2/inc/sidebar/DeckDescriptor.hxx
+++ b/sfx2/inc/sidebar/DeckDescriptor.hxx
@@ -39,6 +39,7 @@ public:
     bool mbIsEnabled;
     sal_Int32 mnOrderIndex;
     bool mbExperimental;
+    bool mbHiddenInViewerMode = false;
 
     OUString msNodeName; // some impress deck nodes names are different from 
their Id
 
diff --git a/sfx2/source/sidebar/DeckDescriptor.cxx 
b/sfx2/source/sidebar/DeckDescriptor.cxx
index 29af33e33f22..97aa42cc0f3c 100644
--- a/sfx2/source/sidebar/DeckDescriptor.cxx
+++ b/sfx2/source/sidebar/DeckDescriptor.cxx
@@ -41,6 +41,7 @@ DeckDescriptor::DeckDescriptor (const DeckDescriptor& rOther)
       mbIsEnabled(rOther.mbIsEnabled),
       mnOrderIndex(rOther.mnOrderIndex),
       mbExperimental(rOther.mbExperimental),
+      mbHiddenInViewerMode(rOther.mbHiddenInViewerMode),
       mpDeck(rOther.mpDeck)
 {
 }
diff --git a/sfx2/source/sidebar/ResourceManager.cxx 
b/sfx2/source/sidebar/ResourceManager.cxx
index 93e55d5a0b10..cf333c1b0a8f 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -130,6 +130,8 @@ std::shared_ptr<DeckDescriptor> 
ResourceManager::ImplGetDeckDescriptor(std::u16s
 {
     for (auto const& deck : maDecks)
     {
+        if (deck->mbHiddenInViewerMode && 
officecfg::Office::Common::Misc::ViewerAppMode::get())
+            continue;
         if (deck->mbExperimental && 
!officecfg::Office::Common::Misc::ExperimentalMode::get())
             continue;
         if (deck->msId == rsDeckId)
@@ -169,6 +171,8 @@ const ResourceManager::DeckContextDescriptorContainer& 
ResourceManager::GetMatch
     std::multimap<sal_Int32,DeckContextDescriptor> aOrderedIds;
     for (auto const& deck : maDecks)
     {
+        if (deck->mbHiddenInViewerMode && 
officecfg::Office::Common::Misc::ViewerAppMode::get())
+            continue;
         if (deck->mbExperimental && 
!officecfg::Office::Common::Misc::ExperimentalMode::get())
             continue;
 
@@ -281,6 +285,7 @@ void ResourceManager::ReadDeckList()
         rDeckDescriptor.msHelpId = "SIDEBAR_" + 
rDeckDescriptor.msId.toAsciiUpperCase();
         rDeckDescriptor.mnOrderIndex = getInt32(aDeckNode, u"OrderIndex"_ustr);
         rDeckDescriptor.mbExperimental = getBool(aDeckNode, 
u"IsExperimental"_ustr);
+        rDeckDescriptor.mbHiddenInViewerMode = getBool(aDeckNode, 
u"HiddenInViewer"_ustr);
 
         rDeckDescriptor.msNodeName = aDeckName;
 
commit 05b2a255a0726b79c34785b5a8b85437bbfe8394
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Dec 6 17:51:10 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Dec 11 11:42:32 2024 +0100

    Let StyleDispatcher take the state of StyleApply slot into account
    
    Before, it only listened to ParaStyle, or CharStyle, etc. obtained
    in MapFamilyToCommand; and that meant, that its actual command was
    ".uno:StyleApply?...", but StyleApply state was ignored. This meant
    that all respective items under "Style" menu were enabled in read-
    only mode, where StyleApply itself was inactive.
    
    Listen to both. When StyleApply is disabled, that takes priority.
    
    Change-Id: Ic087ba6fc6fe6d45b8c8ecc35494734cd8765bd4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177971
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/framework/inc/uielement/styletoolbarcontroller.hxx 
b/framework/inc/uielement/styletoolbarcontroller.hxx
index 45b1ad7eccce..c155a7b2242b 100644
--- a/framework/inc/uielement/styletoolbarcontroller.hxx
+++ b/framework/inc/uielement/styletoolbarcontroller.hxx
@@ -52,8 +52,10 @@ private:
     OUString m_aStyleName, m_aCommand, m_aStatusCommand;
     css::uno::Reference< css::util::XURLTransformer > m_xUrlTransformer;
     css::uno::Reference< css::frame::XDispatchProvider > m_xFrame;
-    css::uno::Reference< css::frame::XDispatch > m_xStatusDispatch;
+    css::uno::Reference< css::frame::XDispatch > m_xStyleApplyStatusDispatch;
+    css::uno::Reference< css::frame::XDispatch > m_xStyleFamilyStatusDispatch;
     css::uno::Reference< css::frame::XStatusListener > m_xOwner;
+    bool m_bStyleApplyEnabled = true; // If this is disabled, style family 
state is irrelevant
 };
 
 class StyleToolbarController final : public svt::ToolboxController
diff --git a/framework/source/uielement/styletoolbarcontroller.cxx 
b/framework/source/uielement/styletoolbarcontroller.cxx
index 7e4a02c1423d..acad86db5e25 100644
--- a/framework/source/uielement/styletoolbarcontroller.cxx
+++ b/framework/source/uielement/styletoolbarcontroller.cxx
@@ -127,9 +127,12 @@ StyleDispatcher::StyleDispatcher( const 
css::uno::Reference< css::frame::XFrame
     if ( m_xFrame.is() )
     {
         css::util::URL aStatusURL;
+        aStatusURL.Complete = u".uno:StyleApply"_ustr;
+        m_xUrlTransformer->parseStrict( aStatusURL );
+        m_xStyleApplyStatusDispatch = m_xFrame->queryDispatch(aStatusURL, 
OUString(), 0);
         aStatusURL.Complete = m_aStatusCommand;
         m_xUrlTransformer->parseStrict( aStatusURL );
-        m_xStatusDispatch = m_xFrame->queryDispatch( aStatusURL, OUString(), 0 
);
+        m_xStyleFamilyStatusDispatch = m_xFrame->queryDispatch(aStatusURL, 
OUString(), 0);
     }
 }
 
@@ -147,32 +150,51 @@ void StyleDispatcher::dispatch( const css::util::URL& 
rURL,
 void StyleDispatcher::addStatusListener( const css::uno::Reference< 
css::frame::XStatusListener >& rListener,
                                          const css::util::URL& /*rURL*/ )
 {
-    if ( m_xStatusDispatch.is() )
+    if ( !m_xOwner.is() )
+        m_xOwner.set( rListener );
+    if (m_xStyleApplyStatusDispatch)
+    {
+        css::util::URL aStatusURL;
+        aStatusURL.Complete = u".uno:StyleApply"_ustr;
+        m_xUrlTransformer->parseStrict(aStatusURL);
+        m_xStyleApplyStatusDispatch->addStatusListener(this, aStatusURL);
+    }
+    if (m_xStyleFamilyStatusDispatch)
     {
-        if ( !m_xOwner.is() )
-            m_xOwner.set( rListener );
-
         css::util::URL aStatusURL;
         aStatusURL.Complete = m_aStatusCommand;
         m_xUrlTransformer->parseStrict( aStatusURL );
-        m_xStatusDispatch->addStatusListener( this, aStatusURL );
+        m_xStyleFamilyStatusDispatch->addStatusListener(this, aStatusURL);
     }
 }
 
 void StyleDispatcher::removeStatusListener( const css::uno::Reference< 
css::frame::XStatusListener >& /*rListener*/,
                                             const css::util::URL& /*rURL*/ )
 {
-    if ( m_xStatusDispatch.is() )
+    if (m_xStyleFamilyStatusDispatch)
     {
         css::util::URL aStatusURL;
         aStatusURL.Complete = m_aStatusCommand;
         m_xUrlTransformer->parseStrict( aStatusURL );
-        m_xStatusDispatch->removeStatusListener( this, aStatusURL );
+        m_xStyleFamilyStatusDispatch->removeStatusListener(this, aStatusURL);
+    }
+    if (m_xStyleApplyStatusDispatch)
+    {
+        css::util::URL aStatusURL;
+        aStatusURL.Complete = u".uno:StyleApply"_ustr;
+        m_xUrlTransformer->parseStrict(aStatusURL);
+        m_xStyleApplyStatusDispatch->removeStatusListener(this, aStatusURL);
     }
 }
 
 void StyleDispatcher::statusChanged( const css::frame::FeatureStateEvent& 
rEvent )
 {
+    if (rEvent.FeatureURL.Complete == ".uno:StyleApply")
+    {
+        m_bStyleApplyEnabled = rEvent.IsEnabled;
+        return;
+    }
+
     css::frame::status::Template aTemplate;
     rEvent.State >>= aTemplate;
 
@@ -180,15 +202,18 @@ void StyleDispatcher::statusChanged( const 
css::frame::FeatureStateEvent& rEvent
     aEvent.FeatureURL.Complete = m_aCommand;
     m_xUrlTransformer->parseStrict( aEvent.FeatureURL );
 
-    aEvent.IsEnabled = rEvent.IsEnabled;
+    aEvent.IsEnabled = m_bStyleApplyEnabled && rEvent.IsEnabled;
     aEvent.Requery = rEvent.Requery;
     aEvent.State <<= m_aStyleName == aTemplate.StyleName;
     m_xOwner->statusChanged( aEvent );
 }
 
-void StyleDispatcher::disposing( const css::lang::EventObject& /*rSource*/ )
+void StyleDispatcher::disposing( const css::lang::EventObject& rSource )
 {
-    m_xStatusDispatch.clear();
+    if (rSource.Source == m_xStyleFamilyStatusDispatch)
+        m_xStyleFamilyStatusDispatch.clear();
+    if (rSource.Source == m_xStyleApplyStatusDispatch)
+        m_xStyleApplyStatusDispatch.clear();
 }
 
 StyleToolbarController::StyleToolbarController( const css::uno::Reference< 
css::uno::XComponentContext >& rContext,
commit 21bba18b26cb13c98c2c16a83c974170e4bd2873
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Dec 6 00:55:59 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Dec 11 11:42:28 2024 +0100

    tdf#62845: Introduce an application-wide viewer mode
    
    Using the new 'ViewerAppMode' expert setting, the UI should disable
    all the edit controls; all options to create new content (including
    new documents); i.e., work as a view-only application.
    
    This change:
    
    1. Introduces the setting.
    2. Checks it in SfxMedium::IsReadOnly, making sure that all documents
       always have read-only medium.
    3. Checks it in SfxFrameLoader_Impl::load, to prevent creation of new
       documents.
    4. Checks it in SfxObjectShell::isEditDocLocked, to prevent entering
       edit mode.
    5. Checks it in BackingWindow::checkInstalledModules, to hide buttons
       that create new documents.
    6. Checks it in SfxViewFrame methods, to avoid showing "readonly" and
       "macros" infobars.
    
    Change-Id: Iaeeb8aab16db83ebdf500fd2bca8b8a9ac2180ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177903
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 67e62985321c..4fb3dec7983f 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5624,6 +5624,12 @@
         </info>
         <value>true</value>
       </prop>
+      <prop oor:name="ViewerAppMode" oor:type="xs:boolean" 
oor:nillable="false">
+        <info>
+          <desc>Open all files in read-only mode</desc>
+        </info>
+        <value>false</value>
+      </prop>
       <prop oor:name="OfferSafeMode" oor:type="xs:boolean" 
oor:nillable="false">
         <info>
           <desc>Offer Safe Mode to the user.</desc>
diff --git a/sfx2/source/dialog/backingwindow.cxx 
b/sfx2/source/dialog/backingwindow.cxx
index 41783bea9950..d351a79beec2 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -431,6 +431,19 @@ void BackingWindow::initializeLocalView()
 
 void BackingWindow::checkInstalledModules()
 {
+    if (officecfg::Office::Common::Misc::ViewerAppMode::get())
+    {
+        mxTemplateButton->set_visible(false);
+        mxCreateLabel->set_visible(false);
+        mxWriterAllButton->set_visible(false);
+        mxCalcAllButton->set_visible(false);
+        mxImpressAllButton->set_visible(false);
+        mxDrawAllButton->set_visible(false);
+        mxMathAllButton->set_visible(false);
+        mxDBAllButton->set_visible(false);
+        return;
+    }
+
     SvtModuleOptions aModuleOpt;
 
     mxWriterAllButton->set_sensitive(aModuleOpt.IsWriterInstalled());
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 4b637f2405cf..335b8c178c91 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3964,6 +3964,10 @@ void SfxMedium::SaveVersionList_Impl()
 
 bool SfxMedium::IsReadOnly() const
 {
+    // Application-wide read-only mode first
+    if (officecfg::Office::Common::Misc::ViewerAppMode::get())
+        return true;
+
     // a) ReadOnly filter can't produce read/write contents!
     bool bReadOnly = pImpl->m_pFilter && (pImpl->m_pFilter->GetFilterFlags() & 
SfxFilterFlags::OPENREADONLY);
 
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 123484e1706e..a8005cab97e0 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -2016,7 +2016,8 @@ bool SfxObjectShell::isEditDocLocked() const
     Reference<XModel3> xModel = GetModel();
     if (!xModel.is())
         return false;
-    if (!officecfg::Office::Common::Misc::AllowEditReadonlyDocs::get())
+    if (officecfg::Office::Common::Misc::ViewerAppMode::get()
+        || !officecfg::Office::Common::Misc::AllowEditReadonlyDocs::get())
         return true;
     return comphelper::NamedValueCollection::getOrDefault(xModel->getArgs2( { 
u"LockEditDoc"_ustr } ), u"LockEditDoc", false);
 }
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index 000c3854046f..7ef7c19d2f63 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -53,6 +53,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <framework/interaction.hxx>
+#include <officecfg/Office/Common.hxx>
 #include <rtl/ref.hxx>
 #include <sal/log.hxx>
 #include <svl/eitem.hxx>
@@ -626,6 +627,10 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const 
Sequence< PropertyValue >& rA
     // check for factory URLs to create a new doc, instead of loading one
     const OUString sURL = aDescriptor.getOrDefault( u"URL"_ustr, OUString() );
     const bool bIsFactoryURL = sURL.startsWith( "private:factory/" );
+
+    if (bIsFactoryURL && officecfg::Office::Common::Misc::ViewerAppMode::get())
+        return false;
+
     std::shared_ptr<const SfxFilter> pEmptyURLFilter;
     bool bInitNewModel = bIsFactoryURL;
     const bool bIsDefault = bIsFactoryURL && !bExternalModel;
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 8df6931536de..da03b23e6cf9 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1266,6 +1266,9 @@ const SvBorder& SfxViewFrame::GetBorderPixelImpl() const
 
 void SfxViewFrame::AppendReadOnlyInfobar()
 {
+    if (officecfg::Office::Common::Misc::ViewerAppMode::get())
+        return;
+
     bool bSignPDF = m_xObjSh->IsSignPDF();
     bool bSignWithCert = false;
     if (bSignPDF)
@@ -1344,6 +1347,9 @@ void SfxViewFrame::HandleSecurityInfobar(const OUString& 
sSecondaryMessage)
 
 void SfxViewFrame::AppendContainsMacrosInfobar()
 {
+    if (officecfg::Office::Common::Misc::ViewerAppMode::get())
+        return;
+
     SfxObjectShell_Impl* pObjImpl = m_xObjSh->Get_Impl();
 
     auto aResId = STR_CONTAINS_MACROS;

Reply via email to