diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-07-07 16:44:59 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-07-16 09:53:32 +0200 |
commit | ce722af0cce170a2aac3a5e01cd66e6c24fba63c (patch) | |
tree | 4915fbc22ac6ddfd09c2858c3d8653a72f0e6bae /sfx2/source/toolbox | |
parent | 1ceb7bc53b347deb93e7cca415b90e71057cfac5 (diff) |
'Save As' popup menu in the Writer's toolbar
Change-Id: I1b1cb7fcd2ae0e0f50e4d8e3900bc416435e60bf
Diffstat (limited to 'sfx2/source/toolbox')
-rw-r--r-- | sfx2/source/toolbox/tbxitem.cxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 99c466c35a1b..aae7ef38422a 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -106,6 +106,7 @@ 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 ) { @@ -1403,4 +1404,53 @@ VclPtr<SfxPopupWindow> SfxRecentFilesToolBoxControl::CreatePopupWindow() return 0; } +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 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |