[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - include/sfx2 sfx2/source
Akshay Deep
akshaydeepiitr at gmail.com
Mon May 30 17:49:47 UTC 2016
include/sfx2/templatedefaultview.hxx | 5 +
sfx2/source/control/templatedefaultview.cxx | 36 ++++++++++
sfx2/source/dialog/backingwindow.cxx | 93 ++++++++++++++--------------
sfx2/source/dialog/backingwindow.hxx | 8 --
4 files changed, 91 insertions(+), 51 deletions(-)
New commits:
commit 130e4ceeca3aa8382984629c8a7bc639c118deaf
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date: Wed May 25 22:22:28 2016 +0530
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 at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
(cherry picked from commit ea01963baf5cc9f5a11f85e04fa61c56bc8a37f0)
Reviewed-on: https://gerrit.libreoffice.org/25681
Reviewed-by: Akshay Deep <akshaydeepiitr at gmail.com>
Tested-by: Akshay Deep <akshaydeepiitr at gmail.com>
diff --git a/include/sfx2/templatedefaultview.hxx b/include/sfx2/templatedefaultview.hxx
index e0f10d4..24157a1 100644
--- a/include/sfx2/templatedefaultview.hxx
+++ b/include/sfx2/templatedefaultview.hxx
@@ -11,7 +11,6 @@
#define INCLUDED_SFX2_TEMPLATEDEFAULTVIEW_HXX
#include <sfx2/templatelocalview.hxx>
-#include <sfx2/recentdocsviewitem.hxx>
class SFX2_DLLPUBLIC TemplateDefaultView : public TemplateLocalView
{
@@ -19,6 +18,10 @@ public:
TemplateDefaultView(Window *pParent);
virtual void reload() override;
+
+ void createContextMenu();
+
+ DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, void);
protected:
long mnItemMaxSize;
long mnTextHeight;
diff --git a/sfx2/source/control/templatedefaultview.cxx b/sfx2/source/control/templatedefaultview.cxx
index 63c2e71..76e08ea 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 06955c2..5c81eb8 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 4d36dc3..5b5194a 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();
More information about the Libreoffice-commits
mailing list