summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgt <gt@openoffice.org>2002-05-14 12:20:43 +0000
committergt <gt@openoffice.org>2002-05-14 12:20:43 +0000
commit38202ed091d68816e0d3f0e268cbcb02750a418b (patch)
tree7992aaf1bd793c434a5fa692d604c4fb2852d213
parent997f183824cc34b47d08bbe8a9f40ca781a8a544 (diff)
#94152# enabled context menu handling via SvTreeListBox
-rw-r--r--sfx2/source/dialog/templdlg.cxx54
-rw-r--r--sfx2/source/inc/templdgi.hxx15
2 files changed, 41 insertions, 28 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 6a0bd675199b..2f22e5272c4d 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templdlg.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: os $ $Date: 2002-02-26 12:39:46 $
+ * last change: $Author: gt $ $Date: 2002-05-14 13:20:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -401,6 +401,7 @@ SfxActionListBox::SfxActionListBox
: DropListBox_Impl(pParent->GetWindow(), nWinBits, pParent)
{
+ EnableContextMenuHandling();
}
//-------------------------------------------------------------------------
@@ -409,16 +410,14 @@ SfxActionListBox::SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent,
const ResId &rResId) :
DropListBox_Impl(pParent->GetWindow(), rResId, pParent)
{
+ EnableContextMenuHandling();
}
//-------------------------------------------------------------------------
-void SfxActionListBox::Command( const CommandEvent& rCEvt )
+PopupMenu* SfxActionListBox::CreateContextMenu( void )
{
- if ( COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
- pDialog->ExecuteContextMenu_Impl( rCEvt.GetMousePosPixel(), this );
- else
- DropListBox_Impl::Command( rCEvt );
+ return pDialog->CreateContextMenu();
}
//-------------------------------------------------------------------------
@@ -517,11 +516,7 @@ void StyleTreeListBox_Impl::Command( const CommandEvent& rCEvt )
*/
{
- if(COMMAND_CONTEXTMENU == rCEvt.GetCommand())
-// pCommon->ExecuteContextMenu_Impl(OutputToScreenPixel(rCEvt.GetMousePosPixel()));
- pCommon->ExecuteContextMenu_Impl( rCEvt.GetMousePosPixel(), this );
- else
- SvTreeListBox::Command(rCEvt);
+ SvTreeListBox::Command(rCEvt);
}
//-------------------------------------------------------------------------
@@ -2152,17 +2147,10 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu *, pMenu )
void SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl( const Point& rPos, Window* pWin )
{
- if ( bBindingUpdate )
- {
- pBindings->Invalidate( SID_STYLE_NEW, TRUE, FALSE );
- pBindings->Update( SID_STYLE_NEW );
- bBindingUpdate = FALSE;
- }
- PopupMenu* pMenu = new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) );
- pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) );
- pMenu->EnableItem( ID_EDIT, bCanEdit );
- pMenu->EnableItem( ID_DELETE, bCanDel );
- pMenu->EnableItem( ID_NEW, bCanNew );
+ // Bug# 94152: This part should never be called, because before this happens, the TreeListBox should captured this!
+ DBG_ASSERT( FALSE, "+SfxCommonTemplateDialog_Impl::ExecuteContextMenu_Impl(): How could this happen? Please infirm developer ASAP!" );
+
+ PopupMenu* pMenu = CreateContextMenu();
pMenu->Execute( pWin, rPos );
delete pMenu;
}
@@ -2193,6 +2181,25 @@ void SfxCommonTemplateDialog_Impl::PrepareDeleteAction()
{
}
+// -----------------------------------------------------------------------
+
+PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu( void )
+{
+ if ( bBindingUpdate )
+ {
+ pBindings->Invalidate( SID_STYLE_NEW, TRUE, FALSE );
+ pBindings->Update( SID_STYLE_NEW );
+ bBindingUpdate = FALSE;
+ }
+ PopupMenu* pMenu = new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) );
+ pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) );
+ pMenu->EnableItem( ID_EDIT, bCanEdit );
+ pMenu->EnableItem( ID_DELETE, bCanDel );
+ pMenu->EnableItem( ID_NEW, bCanNew );
+
+ return pMenu;
+}
+
// ------------------------------------------------------------------------
SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(
@@ -2382,7 +2389,6 @@ void SfxTemplateDialog_Impl::Command( const CommandEvent& rCEvt )
{
if(COMMAND_CONTEXTMENU == rCEvt.GetCommand())
ExecuteContextMenu_Impl( rCEvt.GetMousePosPixel(), pFloat );
-// ExecuteContextMenu_Impl(pFloat->OutputToScreenPixel(rCEvt.GetMousePosPixel()));
else
pFloat->Command(rCEvt);
}
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 85b267c4533d..aca3ad15a618 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templdgi.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: gt $ $Date: 2001-09-12 07:43:09 $
+ * last change: $Author: gt $ $Date: 2002-05-14 13:19:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -138,11 +138,11 @@ public:
class SfxActionListBox : public DropListBox_Impl
{
protected:
- virtual void Command( const CommandEvent& rMEvt );
-
public:
SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, const ResId &rResId );
+
+ virtual PopupMenu* CreateContextMenu( void );
};
// class SfxCommonTemplateDialog_Impl ------------------------------------
@@ -292,6 +292,13 @@ public:
SfxObjectShell* GetObjectShell() const { return pCurObjShell; }
virtual void PrepareDeleteAction(); // disable buttons, change button text, etc. when del is going to happen
+
+ inline BOOL CanEdit( void ) const { return bCanEdit; }
+ inline BOOL CanDel( void ) const { return bCanDel; }
+ inline BOOL CanNew( void ) const { return bCanNew; }
+
+ // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
+ virtual PopupMenu* CreateContextMenu( void );
};
// class SfxTemplateDialog_Impl ------------------------------------------