framework/source/uielement/recentfilesmenucontroller.cxx |    7 +++++--
 sfx2/source/control/recentdocsviewitem.cxx               |    6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 34eea317c5929d640aa43477c737d26d6b700bdb
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri May 27 19:31:01 2022 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri May 27 20:26:52 2022 +0200

    tdf#149170 framework,sfx2: don't add ReadOnly=false
    
    There is a non-obvious difference in error handling when opening the
    file read/write for type-detection fails in
    utl::MediaDescriptor::impl_openStreamWithURL() - if ReadOnly=false is
    given, it will abort the file loading, whereas without any ReadOnly it
    will fall-back to a read-only opening of the file for type detection.
    
    At this point a StillReadWriteInteraction is used, so the user is never
    notified of the failure.
    
    (regression from commit 404c51f3664ffd4f7e2c1c8bb8a12ac70954fec2)
    
    Change-Id: I8c06fe23cc0bc0767df83f680a1a59e3700bbbbb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135045
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx 
b/framework/source/uielement/recentfilesmenucontroller.cxx
index 2fbad67becd9..dc4001a1f645 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -264,14 +264,17 @@ void RecentFilesMenuController::executeEntry( sal_Int32 
nIndex )
     Sequence< PropertyValue > aArgsList{
         comphelper::makePropertyValue("Referer", OUString( "private:user" )),
 
-        comphelper::makePropertyValue("ReadOnly", 
m_aRecentFilesItems[nIndex].second),
-
         // documents in the picklist will never be opened as templates
         comphelper::makePropertyValue("AsTemplate", false),
 
         // Type detection needs to know which app we are opening it from.
         comphelper::makePropertyValue("DocumentService", m_aModuleName)
     };
+    if (m_aRecentFilesItems[nIndex].second) // tdf#149170 only add if true
+    {
+        aArgsList.realloc(aArgsList.size()+1);
+        aArgsList.getArray()[aArgsList.size()-1] = 
comphelper::makePropertyValue("ReadOnly", true);
+    }
     dispatchCommand(m_aRecentFilesItems[nIndex].first, aArgsList, "_default");
 }
 
diff --git a/sfx2/source/control/recentdocsviewitem.cxx 
b/sfx2/source/control/recentdocsviewitem.cxx
index 0cdf74418d05..44f103dfbfa4 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -320,9 +320,13 @@ void RecentDocsViewItem::OpenDocument()
     xTrans->parseStrict(aTargetURL);
 
     aArgsList = { comphelper::makePropertyValue("Referer", 
OUString("private:user")),
-                  comphelper::makePropertyValue("ReadOnly", m_isReadOnly),
                   // documents will never be opened as templates
                   comphelper::makePropertyValue("AsTemplate", false) };
+    if (m_isReadOnly) // tdf#149170 only add if true
+    {
+        aArgsList.realloc(aArgsList.size()+1);
+        aArgsList.getArray()[aArgsList.size()-1] = 
comphelper::makePropertyValue("ReadOnly", true);
+    }
 
     xDispatch = xDesktop->queryDispatch(aTargetURL, "_default", 0);
 

Reply via email to