From 404c51f3664ffd4f7e2c1c8bb8a12ac70954fec2 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 25 Apr 2022 14:53:33 +0200 Subject: officecfg,unotools,framework,sfx2: store ReadOnly for recent docs Add Office::Histories::HistoryItem::ReadOnly flag to configuration so that a document that was opened read-only isn't opened as editable from recent documents. Change-Id: I6985da287d3337a53a7e41e8e500421038eedb91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133385 Tested-by: Jenkins Reviewed-by: Michael Stahl --- unotools/source/config/historyoptions.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'unotools') diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx index de8186795cda..edbf5f5d6b7b 100644 --- a/unotools/source/config/historyoptions.cxx +++ b/unotools/source/config/historyoptions.cxx @@ -42,6 +42,7 @@ namespace { constexpr OUStringLiteral s_sTitle = u"Title"; constexpr OUStringLiteral s_sPassword = u"Password"; constexpr OUStringLiteral s_sThumbnail = u"Thumbnail"; + constexpr OUStringLiteral s_sReadOnly = u"ReadOnly"; } static uno::Reference GetConfig(); @@ -123,6 +124,7 @@ std::vector< HistoryItem > GetList( EHistoryType eHistory ) xSet->getPropertyValue(s_sTitle) >>= aItem.sTitle; xSet->getPropertyValue(s_sPassword) >>= aItem.sPassword; xSet->getPropertyValue(s_sThumbnail) >>= aItem.sThumbnail; + xSet->getPropertyValue(s_sReadOnly) >>= aItem.isReadOnly; aRet.push_back(aItem); } catch(const uno::Exception&) @@ -147,7 +149,8 @@ std::vector< HistoryItem > GetList( EHistoryType eHistory ) void AppendItem(EHistoryType eHistory, const OUString& sURL, const OUString& sFilter, const OUString& sTitle, - const std::optional& sThumbnail) + const std::optional& sThumbnail, + ::std::optional const oIsReadOnly) { try { @@ -171,12 +174,16 @@ void AppendItem(EHistoryType eHistory, if (xItemList->hasByName(sURL)) { uno::Reference xSet; + xItemList->getByName(sURL) >>= xSet; if (sThumbnail) { // update the thumbnail - xItemList->getByName(sURL) >>= xSet; xSet->setPropertyValue(s_sThumbnail, uno::makeAny(*sThumbnail)); } + if (oIsReadOnly) + { + xSet->setPropertyValue(s_sReadOnly, uno::makeAny(*oIsReadOnly)); + } for (sal_Int32 i=0; isetPropertyValue(s_sTitle, uno::makeAny(sTitle)); xSet->setPropertyValue(s_sPassword, uno::makeAny(OUString())); xSet->setPropertyValue(s_sThumbnail, uno::makeAny(sThumbnail.value_or(OUString()))); + if (oIsReadOnly) + { + xSet->setPropertyValue(s_sReadOnly, uno::makeAny(*oIsReadOnly)); + } ::comphelper::ConfigurationHelper::flush(xCfg); } -- cgit