summaryrefslogtreecommitdiff
path: root/sfx2
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 /sfx2
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 'sfx2')
-rw-r--r--sfx2/inc/recentdocsview.hxx2
-rw-r--r--sfx2/source/appl/newhelp.cxx4
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx4
-rw-r--r--sfx2/source/control/recentdocsview.cxx6
-rw-r--r--sfx2/source/control/recentdocsviewitem.cxx6
-rw-r--r--sfx2/source/control/recentdocsviewitem.hxx4
6 files changed, 18 insertions, 8 deletions
diff --git a/sfx2/inc/recentdocsview.hxx b/sfx2/inc/recentdocsview.hxx
index 28b1f77e7c27..3ee34eabc41a 100644
--- a/sfx2/inc/recentdocsview.hxx
+++ b/sfx2/inc/recentdocsview.hxx
@@ -63,7 +63,7 @@ public:
RecentDocsView(std::unique_ptr<weld::ScrolledWindow> xWindow, std::unique_ptr<weld::Menu> xMenu);
virtual ~RecentDocsView() override;
- void insertItem(const OUString &rURL, const OUString &rTitle, const OUString& rThumbnail, sal_uInt16 nId);
+ void insertItem(const OUString &rURL, const OUString &rTitle, const OUString& rThumbnail, bool isReadOnly, sal_uInt16 nId);
static bool typeMatchesExtension(ApplicationType type, std::u16string_view rExt);
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index a120a99f41bb..289a848b4b36 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1186,7 +1186,9 @@ BookmarksTabPage_Impl::~BookmarksTabPage_Impl()
SvtHistoryOptions::Clear( EHistoryType::HelpBookmarks );
const sal_Int32 nCount = m_xBookmarksBox->n_children();
for (sal_Int32 i = 0; i < nCount; ++i)
- SvtHistoryOptions::AppendItem(EHistoryType::HelpBookmarks, m_xBookmarksBox->get_id(i), "", m_xBookmarksBox->get_text(i), std::nullopt);
+ {
+ SvtHistoryOptions::AppendItem(EHistoryType::HelpBookmarks, m_xBookmarksBox->get_id(i), "", m_xBookmarksBox->get_text(i), std::nullopt, std::nullopt);
+ }
m_xBookmarksBox.reset();
m_xBookmarksPB.reset();
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 83834597aff0..8d929d1ad68b 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -123,13 +123,15 @@ void SfxPickListImpl::AddDocumentToPickList( const SfxObjectShell* pDocSh )
}
}
}
+ ::std::optional<bool> const oIsReadOnly(pDocSh->IsReadOnly());
// add to svtool history options
SvtHistoryOptions::AppendItem( EHistoryType::PickList,
aURL.GetURLNoPass( INetURLObject::DecodeMechanism::NONE ),
aFilter,
aTitle,
- aThumbnail);
+ aThumbnail,
+ oIsReadOnly);
if ( aURL.GetProtocol() == INetProtocol::File )
Application::AddToRecentDocumentList( aURL.GetURLNoPass( INetURLObject::DecodeMechanism::NONE ),
diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx
index 3c6110c1e8a1..b7a6ba4adcea 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -143,9 +143,9 @@ bool RecentDocsView::isAcceptedFile(const INetURLObject& rURL) const
(mnFileTypes & ApplicationType::TYPE_OTHER && typeMatchesExtension(ApplicationType::TYPE_OTHER, aExt));
}
-void RecentDocsView::insertItem(const OUString &rURL, const OUString &rTitle, const OUString& rThumbnail, sal_uInt16 nId)
+void RecentDocsView::insertItem(const OUString &rURL, const OUString &rTitle, const OUString& rThumbnail, bool isReadOnly, sal_uInt16 nId)
{
- AppendItem( std::make_unique<RecentDocsViewItem>(*this, rURL, rTitle, rThumbnail, nId, mnItemMaxSize) );
+ AppendItem( std::make_unique<RecentDocsViewItem>(*this, rURL, rTitle, rThumbnail, nId, mnItemMaxSize, isReadOnly) );
}
void RecentDocsView::Reload()
@@ -166,7 +166,7 @@ void RecentDocsView::Reload()
//Remove extension from url's last segment and use it as title
const OUString aTitle = aURLObj.GetBase(); //DecodeMechanism::WithCharset
- insertItem(aURL, aTitle, rRecentEntry.sThumbnail, i+1);
+ insertItem(aURL, aTitle, rRecentEntry.sThumbnail, rRecentEntry.isReadOnly, i+1);
}
CalculateItemPositions();
diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx
index d58f1a49d562..e9c53faeffcf 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -121,10 +121,13 @@ BitmapEx getModuleOverlay(const OUString& rURL)
};
RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUString &rURL,
- const OUString &rTitle, std::u16string_view sThumbnailBase64, sal_uInt16 nId, tools::Long nThumbnailSize)
+ const OUString &rTitle, std::u16string_view const sThumbnailBase64,
+ sal_uInt16 const nId, tools::Long const nThumbnailSize,
+ bool const isReadOnly)
: ThumbnailViewItem(rView, nId),
mrParentView(rView),
maURL(rURL),
+ m_isReadOnly(isReadOnly),
m_bRemoveIconHighlighted(false),
m_aRemoveRecentBitmap(BMP_RECENTDOC_REMOVE),
m_aRemoveRecentBitmapHighlighted(BMP_RECENTDOC_REMOVE_HIGHLIGHTED)
@@ -317,6 +320,7 @@ 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) };
diff --git a/sfx2/source/control/recentdocsviewitem.hxx b/sfx2/source/control/recentdocsviewitem.hxx
index 41225e68c21b..3f5f6d3faab2 100644
--- a/sfx2/source/control/recentdocsviewitem.hxx
+++ b/sfx2/source/control/recentdocsviewitem.hxx
@@ -21,7 +21,7 @@ class RecentDocsViewItem final : public ThumbnailViewItem
{
public:
RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUString &rURL,
- const OUString &rTitle, std::u16string_view sThumbnailBase64, sal_uInt16 nId, tools::Long nThumbnailSize);
+ const OUString &rTitle, std::u16string_view sThumbnailBase64, sal_uInt16 nId, tools::Long nThumbnailSize, bool isReadOnly);
/** Updates own highlight status based on the aPoint position.
@@ -50,6 +50,8 @@ private:
OUString maURL;
+ bool m_isReadOnly = false;
+
OUString m_sHelpText;
/// Is the icon that the user can click to remove the document from the recent documents highlighted?