summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-02-01 15:09:28 +0100
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2023-02-03 09:46:01 +0000
commit6836776fa295293c114c267bca38d18603993a54 (patch)
tree54142839a5dc58191587a015e7443225b36e0147 /framework
parent8855813f8147f430348a32703b89dfb7b0793fee (diff)
tdf#56696 - Sort recent document list according to current LibO module
Change-Id: I246dc9538e011b8981bea04963995559d2b43cc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146456 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/recentfilesmenucontroller.cxx53
1 files changed, 50 insertions, 3 deletions
diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index fe7de1c3d907..ef95d300058b 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -20,6 +20,8 @@
#include <strings.hrc>
#include <classes/fwkresid.hxx>
+#include <comphelper/mimeconfighelper.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
@@ -34,6 +36,8 @@
#include <vcl/svapp.hxx>
#include <o3tl/string_view.hxx>
+#include <officecfg/Office/Common.hxx>
+
using namespace css;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
@@ -42,6 +46,7 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::util;
#define MAX_MENU_ITEMS 99
+#define MAX_MENU_ITEMS_PER_MODULE 5
namespace {
@@ -154,12 +159,50 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
int nPickListMenuItems = std::min<sal_Int32>( aHistoryList.size(), MAX_MENU_ITEMS );
m_aRecentFilesItems.clear();
+ // tdf#56696 - retrieve expert configuration option if the recent document
+ // list should show only files that can be handled by the current module
+ const bool bShowCurrentModuleOnly
+ = officecfg::Office::Common::History::ShowCurrentModuleOnly::get();
+
+ size_t nItemPosModule = 0;
if (( nPickListMenuItems > 0 ) && !m_bDisabled )
{
- for ( int i = 0; i < nPickListMenuItems; i++ )
+ size_t nItemPos = 0;
+ if (m_aModuleName != "com.sun.star.frame.StartModule")
+ {
+ ::comphelper::MimeConfigurationHelper aConfigHelper(
+ comphelper::getProcessComponentContext());
+ // Show the first MAX_MENU_ITEMS_PER_MODULE items of the current module
+ // on top of the recent document list.
+ for (int i = 0; i < nPickListMenuItems; i++)
+ {
+ const SvtHistoryOptions::HistoryItem& rPickListEntry = aHistoryList[i];
+ const std::pair<OUString, bool> aPickListEntry(rPickListEntry.sURL,
+ rPickListEntry.isReadOnly);
+ if ((nItemPosModule < MAX_MENU_ITEMS_PER_MODULE || bShowCurrentModuleOnly)
+ && aConfigHelper.GetDocServiceNameFromFilter(rPickListEntry.sFilter)
+ == m_aModuleName)
+ {
+ m_aRecentFilesItems.insert(m_aRecentFilesItems.begin() + nItemPosModule,
+ aPickListEntry);
+ nItemPos++;
+ nItemPosModule++;
+ }
+ else if (!bShowCurrentModuleOnly)
+ {
+ m_aRecentFilesItems.insert(m_aRecentFilesItems.begin() + nItemPos,
+ aPickListEntry);
+ nItemPos++;
+ }
+ }
+ }
+ else
{
- const SvtHistoryOptions::HistoryItem& rPickListEntry = aHistoryList[i];
- m_aRecentFilesItems.emplace_back(rPickListEntry.sURL, rPickListEntry.isReadOnly);
+ for (int i = 0; i < nPickListMenuItems; i++)
+ {
+ const SvtHistoryOptions::HistoryItem& rPickListEntry = aHistoryList[i];
+ m_aRecentFilesItems.emplace_back(rPickListEntry.sURL, rPickListEntry.isReadOnly);
+ }
}
}
@@ -220,6 +263,10 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
rPopupMenu->setTipHelpText(sal_uInt16(i + 1), aTipHelpText);
rPopupMenu->setCommand(sal_uInt16(i + 1), aURLString);
+
+ // Show a separator after the MAX_MENU_ITEMS_PER_MODULE recent document items
+ if (nItemPosModule > 0 && i == nItemPosModule - 1)
+ rPopupMenu->insertSeparator(-1);
}
rPopupMenu->insertSeparator(-1);