summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-11-18 16:36:12 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2015-11-18 15:16:58 +0000
commit5da50768716fbcb0ffc093ecd588527723109fed (patch)
treeb6343cad3ec9ee80c556bf76d5136fd5aa61cae6 /sfx2
parent99648095012187ef284d0a9399a8e12878b2a370 (diff)
Unify menu-based toolbar controllers
The new GenericPopupToolbarController takes by default the popup menu controller that registered for the same .uno:Something command, and sets ToolBoxItemBits to ToolBoxItemBits::DROPDOWNONLY. If a different command specified using the "Value" property - takes the popup menu controller that registered for this command, and sets bits to ToolBoxItemBits::DROPDOWN. Change-Id: I75c5300bd27fcc9f618f2ee0df2aa6aefd088239 Reviewed-on: https://gerrit.libreoffice.org/20040 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appreg.cxx3
-rw-r--r--sfx2/source/toolbox/tbxitem.cxx106
2 files changed, 1 insertions, 108 deletions
diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx
index fc648ff36c8f..fb04a9dcfa8e 100644
--- a/sfx2/source/appl/appreg.cxx
+++ b/sfx2/source/appl/appreg.cxx
@@ -61,8 +61,7 @@ void SfxApplication::Registrations_Impl()
// Controller
SfxToolBoxControl::RegisterControl(SID_REPEAT);
SfxURLToolBoxControl_Impl::RegisterControl(SID_OPENURL);
- SfxRecentFilesToolBoxControl::RegisterControl( SID_OPENDOC );
-};
+}
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index a23c55f02dc2..3a8062786190 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -105,8 +105,6 @@ using namespace ::com::sun::star::ui;
SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, true);
-SFX_IMPL_TOOLBOX_CONTROL(SfxRecentFilesToolBoxControl, SfxStringItem);
-SFX_IMPL_TOOLBOX_CONTROL(SfxSaveAsToolBoxControl, SfxStringItem);
static vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow )
{
@@ -1132,108 +1130,4 @@ void SfxPopupWindow::Delete()
disposeOnce();
}
-
-
-SfxRecentFilesToolBoxControl::SfxRecentFilesToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
- : SfxToolBoxControl( nSlotId, nId, rBox )
-{
- rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | ToolBoxItemBits::DROPDOWN);
-}
-
-SfxRecentFilesToolBoxControl::~SfxRecentFilesToolBoxControl()
-{
-}
-
-VclPtr<SfxPopupWindow> SfxRecentFilesToolBoxControl::CreatePopupWindow()
-{
- ToolBox& rBox = GetToolBox();
- sal_uInt16 nItemId = GetId();
- ::Rectangle aRect( rBox.GetItemRect( nItemId ) );
-
- Sequence< Any > aArgs( 3 );
- PropertyValue aPropValue;
-
- aPropValue.Name = "CommandURL";
- aPropValue.Value <<= OUString( ".uno:RecentFileList" );
- aArgs[0] <<= aPropValue;
-
- aPropValue.Name = "Frame";
- aPropValue.Value <<= m_xFrame;
- aArgs[1] <<= aPropValue;
-
- aPropValue.Name = "ShowRemote";
- aPropValue.Value <<= true;
- aArgs[2] <<= aPropValue;
-
- uno::Reference< frame::XPopupMenuController > xPopupController( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
- "com.sun.star.comp.framework.RecentFilesMenuController", aArgs, m_xContext ), UNO_QUERY );
-
- uno::Reference< awt::XPopupMenu > xPopupMenu( m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.awt.PopupMenu", m_xContext ), uno::UNO_QUERY );
-
- if ( xPopupController.is() && xPopupMenu.is() )
- {
- xPopupController->setPopupMenu( xPopupMenu );
-
- rBox.SetItemDown( nItemId, true );
- Reference< awt::XWindowPeer > xPeer( getParent(), uno::UNO_QUERY );
-
- if ( xPeer.is() )
- xPopupMenu->execute( xPeer, VCLUnoHelper::ConvertToAWTRect( aRect ), 0 );
-
- rBox.SetItemDown( nItemId, false );
- }
-
- return nullptr;
-}
-
-SfxSaveAsToolBoxControl::SfxSaveAsToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
- : SfxToolBoxControl( nSlotId, nId, rBox )
-{
- rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | ToolBoxItemBits::DROPDOWN);
-}
-
-SfxSaveAsToolBoxControl::~SfxSaveAsToolBoxControl()
-{
-}
-
-VclPtr<SfxPopupWindow> SfxSaveAsToolBoxControl::CreatePopupWindow()
-{
- ToolBox& rBox = GetToolBox();
- sal_uInt16 nItemId = GetId();
- ::Rectangle aRect( rBox.GetItemRect( nItemId ) );
-
- Sequence< Any > aArgs( 2 );
- PropertyValue aPropValue;
-
- aPropValue.Name = "CommandURL";
- aPropValue.Value <<= OUString( ".uno:SaveAsMenu" );
- aArgs[0] <<= aPropValue;
-
- aPropValue.Name = "Frame";
- aPropValue.Value <<= m_xFrame;
- aArgs[1] <<= aPropValue;
-
- uno::Reference< frame::XPopupMenuController > xPopupController( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
- "com.sun.star.comp.framework.SaveAsMenuController", aArgs, m_xContext ), UNO_QUERY );
-
- uno::Reference< awt::XPopupMenu > xPopupMenu( m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.awt.PopupMenu", m_xContext ), uno::UNO_QUERY );
-
- if ( xPopupController.is() && xPopupMenu.is() )
- {
- xPopupController->setPopupMenu( xPopupMenu );
-
- rBox.SetItemDown( nItemId, true );
- Reference< awt::XWindowPeer > xPeer( getParent(), uno::UNO_QUERY );
-
- if ( xPeer.is() )
- xPopupMenu->execute( xPeer, VCLUnoHelper::ConvertToAWTRect( aRect ), 0 );
-
- rBox.SetItemDown( nItemId, false );
- }
-
- return nullptr;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */