summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-04-25 14:53:33 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-04-26 10:39:31 +0200
commit404c51f3664ffd4f7e2c1c8bb8a12ac70954fec2 (patch)
treeb38e7a5088e4c3cbd1b7ea447b03fb595bd8f1ba /unotools
parentc51ef466f736c9e0e192d2c7feeda0a39bca2011 (diff)
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 <michael.stahl@allotropia.de>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/historyoptions.cxx15
1 files changed, 13 insertions, 2 deletions
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<container::XNameAccess> 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<OUString>& sThumbnail)
+ const std::optional<OUString>& sThumbnail,
+ ::std::optional<bool> const oIsReadOnly)
{
try
{
@@ -171,12 +174,16 @@ void AppendItem(EHistoryType eHistory,
if (xItemList->hasByName(sURL))
{
uno::Reference<beans::XPropertySet> 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; i<nLength; ++i)
{
@@ -265,6 +272,10 @@ void AppendItem(EHistoryType eHistory,
xSet->setPropertyValue(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);
}