diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-05-25 22:22:28 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-05-30 07:15:54 +0000 |
commit | ea01963baf5cc9f5a11f85e04fa61c56bc8a37f0 (patch) | |
tree | f315f50ce0f4ffc7e40f4ad507ea67bf3a935660 /sfx2 | |
parent | a7e2d4923b220900f41d0b70904377c771939e6f (diff) |
Context Menu for templates and other fixes in Start Center
Removed:
1: Save Mode Variable.
2. maSelTemplates and maSelFolders
3. OpenRegionHdl
4. cmpSelectionItems
Change-Id: I108da3a0ddfb4954a60fbb0df44eba0457326ca9
Reviewed-on: https://gerrit.libreoffice.org/25459
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/templatedefaultview.cxx | 36 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 93 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.hxx | 8 |
3 files changed, 87 insertions, 50 deletions
diff --git a/sfx2/source/control/templatedefaultview.cxx b/sfx2/source/control/templatedefaultview.cxx index 63c2e7148166..76e08eaecba9 100644 --- a/sfx2/source/control/templatedefaultview.cxx +++ b/sfx2/source/control/templatedefaultview.cxx @@ -9,9 +9,16 @@ #include <sfx2/templatedefaultview.hxx> #include <sfx2/thumbnailview.hxx> +#include <sfx2/templateviewitem.hxx> +#include <sfx2/sfxresid.hxx> #include <vcl/builderfactory.hxx> #include <sfx2/app.hxx> +#include "../doc/doc.hrc" + +#define MNI_OPEN 1 +#define MNI_EDIT 2 + #include <officecfg/Office/Common.hxx> VCL_BUILDER_FACTORY(TemplateDefaultView) @@ -39,6 +46,35 @@ void TemplateDefaultView::reload() TemplateLocalView::reload(); // Set preferred width set_width_request(mnTextHeight + mnItemMaxSize + 2*mnItemPadding); +} +void TemplateDefaultView::createContextMenu() +{ + std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu); + pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString()); + pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString()); + deselectItems(); + maSelectedItem->setSelection(true); + pItemMenu->SetSelectHdl(LINK(this, TemplateLocalView, ContextMenuSelectHdl)); + pItemMenu->Execute(this, Rectangle(maPosition,Size(1,1)), PopupMenuFlags::ExecuteDown); + Invalidate(); } + +IMPL_LINK_TYPED(TemplateDefaultView, ContextMenuSelectHdl, Menu*, pMenu, void) +{ + sal_uInt16 nMenuId = pMenu->GetCurItemId(); + + switch(nMenuId) + { + case MNI_OPEN: + maOpenTemplateHdl.Call(maSelectedItem); + break; + case MNI_EDIT: + maEditTemplateHdl.Call(maSelectedItem); + break; + default: + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 06955c234188..5c81eb842c53 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -66,29 +66,12 @@ const char SERVICENAME_CFGREADACCESS[] = "com.sun.star.configuration.Configurati // increase size of the text in the buttons on the left fMultiplier-times float fMultiplier = 1.4f; -/*** - * - * Order items in ascending order (useful for the selection sets and move/copy operations since the associated ids - * change when processed by the SfxDocumentTemplates class so we want to process to ones with higher id first) - * - ***/ - -static bool cmpSelectionItems (const ThumbnailViewItem *pItem1, const ThumbnailViewItem *pItem2) -{ - return pItem1->mnId > pItem2->mnId; -} - - BackingWindow::BackingWindow( vcl::Window* i_pParent ) : Window( i_pParent ), mbLocalViewInitialized(false), maButtonsTextColor(officecfg::Office::Common::Help::StartCenter::StartCenterTextColor::get()), - mbIsSaveMode( false ), mbInitControls( false ), - mnHideExternalLinks( 0 ), - maSelTemplates(cmpSelectionItems), - maSelFolders(cmpSelectionItems) - + mnHideExternalLinks( 0 ) { m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "sfx/ui/startcenter.ui", "StartCenter" ); @@ -279,8 +262,9 @@ void BackingWindow::initControls() mpTemplateButton->SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); //set handlers - mpLocalView->setOpenRegionHdl(LINK(this, BackingWindow, OpenRegionHdl)); - mpLocalView->setOpenTemplateHdl(LINK(this,BackingWindow,OpenTemplateHdl)); + mpLocalView->setRightClickHdl(LINK(this, BackingWindow, RightClickHdl)); + mpLocalView->setOpenTemplateHdl(LINK(this, BackingWindow, OpenTemplateHdl)); + mpLocalView->setEditTemplateHdl(LINK(this, BackingWindow, EditTemplateHdl)); setupButton( mpOpenButton ); setupButton( mpRemoteButton ); @@ -628,38 +612,59 @@ IMPL_LINK_TYPED( BackingWindow, MenuSelectHdl, MenuButton*, pButton, void ) mpLocalView->GrabFocus(); } - -IMPL_LINK_NOARG_TYPED( BackingWindow, OpenRegionHdl, void*, void) +IMPL_LINK_TYPED(BackingWindow, RightClickHdl, ThumbnailViewItem*, pItem, void) { - maSelFolders.clear(); - maSelTemplates.clear(); + const TemplateViewItem *pViewItem = dynamic_cast<TemplateViewItem*>(pItem); + + if (pViewItem) + mpLocalView->createContextMenu(); } IMPL_LINK_TYPED(BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem, void) { - if (!mbIsSaveMode) + uno::Sequence< PropertyValue > aArgs(4); + aArgs[0].Name = "AsTemplate"; + aArgs[0].Value <<= true; + aArgs[1].Name = "MacroExecutionMode"; + aArgs[1].Value <<= MacroExecMode::USE_CONFIG; + aArgs[2].Name = "UpdateDocMode"; + aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; + aArgs[3].Name = "InteractionHandler"; + aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ); + + TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem); + + Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY ); + + try + { + dispatchURL( pTemplateItem->getPath(), "_default", xFrame, aArgs ); + } + catch( const uno::Exception& ) { - uno::Sequence< PropertyValue > aArgs(4); - aArgs[0].Name = "AsTemplate"; - aArgs[0].Value <<= true; - aArgs[1].Name = "MacroExecutionMode"; - aArgs[1].Value <<= MacroExecMode::USE_CONFIG; - aArgs[2].Name = "UpdateDocMode"; - aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; - aArgs[3].Name = "InteractionHandler"; - aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ); - - TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem); + } +} - Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY ); +IMPL_LINK_TYPED(BackingWindow, EditTemplateHdl, ThumbnailViewItem*, pItem, void) +{ + uno::Sequence< PropertyValue > aArgs(3); + aArgs[0].Name = "AsTemplate"; + aArgs[0].Value <<= false; + aArgs[1].Name = "MacroExecutionMode"; + aArgs[1].Value <<= MacroExecMode::USE_CONFIG; + aArgs[2].Name = "UpdateDocMode"; + aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; - try - { - dispatchURL( pTemplateItem->getPath(), "_default", xFrame, aArgs ); - } - catch( const uno::Exception& ) - { - } + TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem); + + Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY ); + + try + { + dispatchURL( pViewItem->getPath(), "_default", xFrame, aArgs ); + } + catch( const uno::Exception& ) + { } } diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index 4d36dc3ec894..5b5194a106ef 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -51,7 +51,6 @@ class ToolBox; class BackingWindow : public vcl::Window, public VclBuilderContainer { - typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*, const ThumbnailViewItem*); css::uno::Reference<css::uno::XComponentContext> mxContext; css::uno::Reference<css::frame::XDispatchProvider> mxDesktopDispatchProvider; css::uno::Reference<css::frame::XFrame> mxFrame; @@ -89,7 +88,6 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer Color maButtonsTextColor; Rectangle maStartCentButtons; - bool mbIsSaveMode; bool mbInitControls; sal_Int32 mnHideExternalLinks; std::unique_ptr<svt::AcceleratorExecute> mpAccExec; @@ -102,14 +100,12 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer const css::uno::Reference<css::frame::XDispatchProvider >& i_xProv = css::uno::Reference<css::frame::XDispatchProvider>(), const css::uno::Sequence<css::beans::PropertyValue >& = css::uno::Sequence<css::beans::PropertyValue>()); - std::set<const ThumbnailViewItem*, selection_cmp_fn> maSelTemplates; - std::set<const ThumbnailViewItem*, selection_cmp_fn> maSelFolders; - DECL_LINK_TYPED(ClickHdl, Button*, void); DECL_LINK_TYPED(MenuSelectHdl, MenuButton*, void); DECL_LINK_TYPED(ExtLinkClickHdl, Button*, void); - DECL_LINK_TYPED(OpenRegionHdl, void*, void); + DECL_LINK_TYPED(RightClickHdl, ThumbnailViewItem*, void); DECL_LINK_TYPED(OpenTemplateHdl, ThumbnailViewItem*, void); + DECL_LINK_TYPED(EditTemplateHdl, ThumbnailViewItem*, void); void initControls(); |