summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-04-30 10:31:00 +0200
committerJan Holesovsky <kendy@suse.cz>2013-04-30 11:22:04 +0200
commitd27159060290da5cebb8c1daea32042394ce59f1 (patch)
tree1707e250ad93129308a76e21b972704ccec85c58
parentKill unused SfxHistoryToolBoxControl_Impl. (diff)
downloadcore-d27159060290da5cebb8c1daea32042394ce59f1.tar.gz
core-d27159060290da5cebb8c1daea32042394ce59f1.zip
bnc#816516: Implement easy access to the recent documents.
This adds a dropdown to the 'Open' toolbar tool. Change-Id: I5b4aa99476e721c1479152b46bbc79cc0b095318
-rw-r--r--sc/sdi/scalc.sdi3
-rw-r--r--sc/source/ui/app/scdll.cxx2
-rw-r--r--sfx2/inc/sfx2/tbxctrl.hxx19
-rw-r--r--sfx2/sdi/sfx.sdi3
-rw-r--r--sfx2/source/appl/appreg.cxx1
-rw-r--r--sfx2/source/toolbox/tbxitem.cxx58
-rw-r--r--sw/sdi/swriter.sdi3
-rw-r--r--sw/source/ui/app/swmodule.cxx2
8 files changed, 90 insertions, 1 deletions
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 050c64512366..fa0c55455b1e 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -8140,6 +8140,9 @@ SfxVoidItem OpenFromCalc SID_OPEN_CALC
RecordPerSet;
Synchron;
+ /* status: */
+ SlotType = SfxStringItem
+
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 3d84568cd777..23abb139b6a0 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -180,6 +180,8 @@ void ScDLL::Init()
ScMediaShell ::RegisterInterface(pMod);
ScPageBreakShell ::RegisterInterface(pMod);
+ SfxRecentFilesToolBoxControl::RegisterControl(SID_OPEN_CALC, pMod);
+
// eigene Controller
ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSERT, pMod);
ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSCELLS, pMod);
diff --git a/sfx2/inc/sfx2/tbxctrl.hxx b/sfx2/inc/sfx2/tbxctrl.hxx
index b8c1576937d7..5791654f7aa8 100644
--- a/sfx2/inc/sfx2/tbxctrl.hxx
+++ b/sfx2/inc/sfx2/tbxctrl.hxx
@@ -174,7 +174,7 @@ public:
#define SFX_DECL_TOOLBOX_CONTROL() \
static SfxToolBoxControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ); \
- static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
+ static void SFX2_DLLPUBLIC RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
/* For special ToolBox controls, such as a font selection box or toolbox
tear-off floating windows, an appropriate Item-Subclass of SfxTooBoxControl
@@ -366,6 +366,23 @@ private:
sal_Bool m_bShowMenuImages;
};
+/** Toolbox that implements recent files menu for the Open file toolbar button.
+
+To use that, the appropriate Sfx*Item (like Open, OpenFromCalc, or
+OpenFromWriter) has to have SlotType = SfxStringItem, and the appropriate
+module initialization has to call RegisterControl().
+*/
+class SfxRecentFilesToolBoxControl : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+ SfxRecentFilesToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox );
+ virtual ~SfxRecentFilesToolBoxControl();
+
+protected:
+ virtual SfxPopupWindow* CreatePopupWindow();
+};
+
class SfxReloadToolBoxControl_Impl : public SfxToolBoxControl
{
protected:
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 396fbb714528..6cefd9b4a986 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4255,6 +4255,9 @@ SfxObjectItem Open SID_OPENDOC
RecordPerSet;
Asynchron;
+ /* status: */
+ SlotType = SfxStringItem
+
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx
index 070bf9f92494..8d963d4ac0b3 100644
--- a/sfx2/source/appl/appreg.cxx
+++ b/sfx2/source/appl/appreg.cxx
@@ -71,6 +71,7 @@ void SfxApplication::Registrations_Impl()
SfxURLToolBoxControl_Impl::RegisterControl(SID_OPENURL);
SfxAppToolBoxControl_Impl::RegisterControl( SID_NEWDOCDIRECT );
SfxAppToolBoxControl_Impl::RegisterControl( SID_AUTOPILOTMENU );
+ SfxRecentFilesToolBoxControl::RegisterControl( SID_OPENDOC );
};
//--------------------------------------------------------------------
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index 3573f4b11c52..7ef50badb369 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -34,7 +34,9 @@
#include <string> // prevent conflict with STL includes
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/awt/XPopupMenu.hpp>
#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XController.hpp>
@@ -45,6 +47,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <com/sun/star/frame/status/ItemStatus.hpp>
#include <com/sun/star/frame/status/ItemState.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp>
@@ -99,6 +102,7 @@
#include "virtmenu.hxx"
#include "sfx2/imagemgr.hxx"
+using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::frame::status;
@@ -113,6 +117,7 @@ using namespace ::com::sun::star::ui;
SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, sal_True);
SFX_IMPL_TOOLBOX_CONTROL(SfxAppToolBoxControl_Impl, SfxStringItem);
+SFX_IMPL_TOOLBOX_CONTROL(SfxRecentFilesToolBoxControl, SfxStringItem);
static Window* GetTopMostParentSystemWindow( Window* pWindow )
{
@@ -1771,4 +1776,57 @@ void SfxAppToolBoxControl_Impl::Click( )
{
}
+//--------------------------------------------------------------------
+
+SfxRecentFilesToolBoxControl::SfxRecentFilesToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
+ : SfxToolBoxControl( nSlotId, nId, rBox )
+{
+ rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | TIB_DROPDOWN);
+}
+
+SfxRecentFilesToolBoxControl::~SfxRecentFilesToolBoxControl()
+{
+}
+
+SfxPopupWindow* SfxRecentFilesToolBoxControl::CreatePopupWindow()
+{
+ ToolBox& rBox = GetToolBox();
+ sal_uInt16 nItemId = GetId();
+ ::Rectangle aRect( rBox.GetItemRect( nItemId ) );
+
+ Sequence< Any > aArgs( 2 );
+ PropertyValue aPropValue;
+
+ aPropValue.Name = "CommandURL";
+ aPropValue.Value <<= rtl::OUString( ".uno:RecentFileList" );
+ aArgs[0] <<= aPropValue;
+
+ aPropValue.Name = "Frame";
+ aPropValue.Value <<= m_xFrame;
+ aArgs[1] <<= aPropValue;
+
+ uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
+
+ uno::Reference< frame::XPopupMenuController > xPopupController( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ "com.sun.star.comp.framework.RecentFilesMenuController", aArgs, xContext ), UNO_QUERY );
+
+ uno::Reference< awt::XPopupMenu > xPopupMenu( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.awt.PopupMenu", xContext ), uno::UNO_QUERY );
+
+ if ( xPopupController.is() && xPopupMenu.is() )
+ {
+ xPopupController->setPopupMenu( xPopupMenu );
+
+ rBox.SetItemDown( nItemId, sal_True );
+ Reference< awt::XWindowPeer > xPeer( getParent(), uno::UNO_QUERY );
+
+ if ( xPeer.is() )
+ xPopupMenu->execute( xPeer, VCLUnoHelper::ConvertToAWTRect( aRect ), 0 );
+
+ rBox.SetItemDown( nItemId, sal_False );
+ }
+
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 89e1530ca803..c12f66367492 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -10460,6 +10460,9 @@ SfxVoidItem OpenFromWriter FN_OPEN_FILE
RecordPerSet;
Synchron;
+ /* status: */
+ SlotType = SfxStringItem
+
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx
index a1fcd364b554..678bd7d144a8 100644
--- a/sw/source/ui/app/swmodule.cxx
+++ b/sw/source/ui/app/swmodule.cxx
@@ -319,6 +319,8 @@ void SwDLL::RegisterInterfaces()
void SwDLL::RegisterControls()
{
SwModule* pMod = SW_MOD();
+
+ SfxRecentFilesToolBoxControl::RegisterControl( FN_OPEN_FILE, pMod );
SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
SvxTbxCtlAlign::RegisterControl(SID_OBJECT_ALIGN, pMod );
SwTbxAnchor::RegisterControl(FN_TOOL_ANCHOR, pMod );