2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-29 10:02:42 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:50:31 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:50:31 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:50:31 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:50:31 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:50:31 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:50:31 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 23:29:44 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_basctl.hxx"
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <ide_pch.hxx>
|
|
|
|
|
|
|
|
|
2005-04-13 08:52:38 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <vcl/cmdevt.hxx>
|
2002-04-25 08:34:09 +00:00
|
|
|
#include <vcl/taskpanelist.hxx>
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <vcl/sound.hxx>
|
|
|
|
#include <objdlg.hrc>
|
|
|
|
#include <objdlg.hxx>
|
|
|
|
#include <bastypes.hxx>
|
|
|
|
#include <basidesh.hrc>
|
2001-09-06 08:21:02 +00:00
|
|
|
#include <basidesh.hxx>
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <iderdll.hxx>
|
|
|
|
#include <iderdll2.hxx>
|
|
|
|
#include <sbxitem.hxx>
|
|
|
|
|
|
|
|
|
|
|
|
ObjectTreeListBox::ObjectTreeListBox( Window* pParent, const ResId& rRes )
|
|
|
|
: BasicTreeListBox( pParent, rRes )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectTreeListBox::~ObjectTreeListBox()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-16 15:33:22 +00:00
|
|
|
void ObjectTreeListBox::Command( const CommandEvent& )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
BasicTreeListBox::MouseButtonDown( rMEvt );
|
|
|
|
|
|
|
|
if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) )
|
|
|
|
{
|
2004-07-23 11:07:23 +00:00
|
|
|
BasicEntryDescriptor aDesc( GetEntryDescriptor( GetCurEntry() ) );
|
2001-06-15 07:45:19 +00:00
|
|
|
|
2004-07-23 11:07:23 +00:00
|
|
|
if ( aDesc.GetType() == OBJ_TYPE_METHOD )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-24 11:13:33 +01:00
|
|
|
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
|
2001-09-06 08:21:02 +00:00
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2000-09-29 10:02:42 +00:00
|
|
|
if( pDispatcher )
|
|
|
|
{
|
2007-03-15 14:58:57 +00:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
|
2004-07-23 11:07:23 +00:00
|
|
|
aDesc.GetMethodName(), ConvertType( aDesc.GetType() ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectCatalog::ObjectCatalog( Window * pParent )
|
2004-07-23 11:07:23 +00:00
|
|
|
:FloatingWindow( pParent, IDEResId( RID_BASICIDE_OBJCAT ) )
|
|
|
|
,aMacroTreeList( this, IDEResId( RID_TLB_MACROS ) )
|
2010-11-13 17:22:01 +00:00
|
|
|
,aToolBox(this, IDEResId(RID_TB_TOOLBOX))
|
2004-07-23 11:07:23 +00:00
|
|
|
,aMacroDescr( this, IDEResId( RID_FT_MACRODESCR ) )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
2001-09-26 11:33:39 +00:00
|
|
|
aToolBox.SetOutStyle( TOOLBOX_STYLE_FLAT );
|
2000-09-29 10:02:42 +00:00
|
|
|
aToolBox.SetSizePixel( aToolBox.CalcWindowSizePixel() );
|
|
|
|
aToolBox.SetSelectHdl( LINK( this, ObjectCatalog, ToolBoxHdl ) );
|
|
|
|
|
2010-09-03 17:53:47 +02:00
|
|
|
aMacroTreeList.SetStyle( WB_BORDER | WB_TABSTOP |
|
|
|
|
WB_HASLINES | WB_HASLINESATROOT |
|
|
|
|
WB_HASBUTTONS | WB_HASBUTTONSATROOT |
|
|
|
|
WB_HSCROLL );
|
2004-07-23 11:07:23 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
aMacroTreeList.SetSelectHdl( LINK( this, ObjectCatalog, TreeListHighlightHdl ) );
|
2011-01-19 18:42:37 +01:00
|
|
|
aMacroTreeList.SetAccessibleName(String(IDEResId(RID_STR_TLB_MACROS)));
|
2004-07-23 11:07:23 +00:00
|
|
|
aMacroTreeList.ScanAllEntries();
|
2011-01-19 18:42:37 +01:00
|
|
|
aMacroTreeList.GrabFocus();
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
CheckButtons();
|
|
|
|
|
2011-08-24 11:13:33 +01:00
|
|
|
Point aPos = BasicIDEGlobals::GetExtraData()->GetObjectCatalogPos();
|
|
|
|
Size aSize = BasicIDEGlobals::GetExtraData()->GetObjectCatalogSize();
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( aPos.X() == INVPOSITION )
|
|
|
|
{
|
2011-08-22 11:39:37 +02:00
|
|
|
// centered after AppWin:
|
2000-09-29 10:02:42 +00:00
|
|
|
Window* pWin = GetParent();
|
|
|
|
aPos = pWin->OutputToScreenPixel( Point( 0, 0 ) );
|
|
|
|
Size aAppWinSz = pWin->GetSizePixel();
|
|
|
|
Size aDlgWinSz = GetSizePixel();
|
|
|
|
aPos.X() += aAppWinSz.Width() / 2;
|
|
|
|
aPos.X() -= aDlgWinSz.Width() / 2;
|
|
|
|
aPos.Y() += aAppWinSz.Height() / 2;
|
|
|
|
aPos.Y() -= aDlgWinSz.Height() / 2;
|
|
|
|
}
|
|
|
|
SetPosPixel( aPos );
|
|
|
|
if ( aSize.Width() )
|
|
|
|
SetOutputSizePixel( aSize );
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
Resize(); // so that the resize-handler arranges the controls
|
2002-04-25 08:34:09 +00:00
|
|
|
|
|
|
|
// make object catalog keyboard accessible
|
|
|
|
pParent->GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2002-04-25 08:34:09 +00:00
|
|
|
ObjectCatalog::~ObjectCatalog()
|
|
|
|
{
|
|
|
|
GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ObjectCatalog::Move()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-08-24 11:13:33 +01:00
|
|
|
BasicIDEGlobals::GetExtraData()->SetObjectCatalogPos( GetPosPixel() );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_Bool ObjectCatalog::Close()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
aCancelHdl.Call( this );
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ObjectCatalog::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
Size aOutSz = GetOutputSizePixel();
|
2011-08-24 11:13:33 +01:00
|
|
|
BasicIDEGlobals::GetExtraData()->SetObjectCatalogSize( aOutSz );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
Point aTreePos = aMacroTreeList.GetPosPixel();
|
|
|
|
Size aDescrSz = aMacroDescr.GetSizePixel();
|
|
|
|
|
|
|
|
Size aTreeSz;
|
|
|
|
long nCtrlWidth = aOutSz.Width() - 2*aTreePos.X();
|
|
|
|
aTreeSz.Width() = nCtrlWidth;
|
|
|
|
aTreeSz.Height() = aOutSz.Height() - aTreePos.Y() -
|
|
|
|
2*aTreePos.X() - aDescrSz.Height();
|
|
|
|
|
|
|
|
if ( aTreeSz.Height() > 0 )
|
|
|
|
{
|
|
|
|
aMacroTreeList.SetSizePixel( aTreeSz );
|
|
|
|
|
|
|
|
Point aDescrPos( aTreePos.X(), aTreePos.Y()+aTreeSz.Height()+aTreePos.X() );
|
|
|
|
|
|
|
|
aMacroDescr.SetPosSizePixel( aDescrPos, Size( nCtrlWidth, aDescrSz.Height() ) );
|
|
|
|
|
|
|
|
String aDesc = aMacroDescr.GetText();
|
|
|
|
aMacroDescr.SetText(String());
|
|
|
|
aMacroDescr.SetText(aDesc);
|
|
|
|
}
|
|
|
|
|
2011-08-22 11:39:37 +02:00
|
|
|
// the buttons above always stay unmodified
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( ObjectCatalog, ToolBoxHdl, ToolBox*, pToolBox )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nCurItem = pToolBox->GetCurItemId();
|
2000-09-29 10:02:42 +00:00
|
|
|
switch ( nCurItem )
|
|
|
|
{
|
|
|
|
case TBITEM_SHOW:
|
|
|
|
{
|
2004-10-04 18:40:41 +00:00
|
|
|
SfxAllItemSet aArgs( SFX_APP()->GetPool() );
|
|
|
|
SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
|
|
|
|
SFX_APP()->ExecuteSlot( aRequest );
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
|
|
|
|
DBG_ASSERT( pCurEntry, "Entry?!" );
|
2004-07-23 11:07:23 +00:00
|
|
|
BasicEntryDescriptor aDesc( aMacroTreeList.GetEntryDescriptor( pCurEntry ) );
|
2011-08-24 11:13:33 +01:00
|
|
|
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
|
2007-10-09 14:24:41 +00:00
|
|
|
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
|
2004-10-04 18:40:41 +00:00
|
|
|
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
|
2004-07-23 11:07:23 +00:00
|
|
|
if ( aDesc.GetType() == OBJ_TYPE_MODULE ||
|
|
|
|
aDesc.GetType() == OBJ_TYPE_DIALOG ||
|
|
|
|
aDesc.GetType() == OBJ_TYPE_METHOD )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if( pDispatcher )
|
|
|
|
{
|
2007-03-15 14:58:57 +00:00
|
|
|
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
|
2004-07-23 11:07:23 +00:00
|
|
|
aDesc.GetMethodName(), aMacroTreeList.ConvertType( aDesc.GetType() ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
|
|
|
|
SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ErrorBox( this, WB_OK, String( IDEResId( RID_STR_OBJNOTFOUND ) ) ).Execute();
|
|
|
|
aMacroTreeList.GetModel()->Remove( pCurEntry );
|
|
|
|
CheckButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ObjectCatalog::CheckButtons()
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
|
2004-07-23 11:07:23 +00:00
|
|
|
BasicEntryType eType = pCurEntry ? ((BasicEntry*)pCurEntry->GetUserData())->GetType() : OBJ_TYPE_UNKNOWN;
|
|
|
|
if ( eType == OBJ_TYPE_DIALOG || eType == OBJ_TYPE_MODULE || eType == OBJ_TYPE_METHOD )
|
2011-01-14 11:16:25 +01:00
|
|
|
aToolBox.EnableItem( TBITEM_SHOW, sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
aToolBox.EnableItem( TBITEM_SHOW, sal_False );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK_INLINE_START( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox )
|
|
|
|
{
|
|
|
|
if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
|
|
|
|
UpdateFields();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox )
|
|
|
|
|
|
|
|
|
|
|
|
void ObjectCatalog::UpdateFields()
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
|
|
|
|
if ( pCurEntry )
|
|
|
|
{
|
|
|
|
CheckButtons();
|
|
|
|
aMacroDescr.SetText( String() );
|
|
|
|
SbxVariable* pVar = aMacroTreeList.FindVariable( pCurEntry );
|
|
|
|
if ( pVar )
|
|
|
|
{
|
|
|
|
SbxInfoRef xInfo = pVar->GetInfo();
|
|
|
|
if ( xInfo.Is() )
|
|
|
|
aMacroDescr.SetText( xInfo->GetComment() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ObjectCatalog::UpdateEntries()
|
|
|
|
{
|
|
|
|
aMacroTreeList.UpdateEntries();
|
|
|
|
}
|
|
|
|
|
2004-07-23 11:07:23 +00:00
|
|
|
void ObjectCatalog::SetCurrentEntry( BasicEntryDescriptor& rDesc )
|
|
|
|
{
|
|
|
|
aMacroTreeList.SetCurrentEntry( rDesc );
|
|
|
|
}
|
|
|
|
|
2002-07-03 14:53:24 +00:00
|
|
|
ObjectCatalogToolBox_Impl::ObjectCatalogToolBox_Impl(
|
2010-11-13 17:22:01 +00:00
|
|
|
Window * pParent, ResId const & rResId)
|
|
|
|
: ToolBox(pParent, rResId)
|
|
|
|
, m_aImagesNormal(GetImageList())
|
2002-07-03 14:53:24 +00:00
|
|
|
{
|
|
|
|
setImages();
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void ObjectCatalogToolBox_Impl::DataChanged(DataChangedEvent const & rDCEvt)
|
|
|
|
{
|
|
|
|
ToolBox::DataChanged(rDCEvt);
|
2002-07-04 12:33:07 +00:00
|
|
|
if ((rDCEvt.GetType() == DATACHANGED_SETTINGS
|
|
|
|
|| rDCEvt.GetType() == DATACHANGED_DISPLAY)
|
|
|
|
&& (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
|
2002-07-03 14:53:24 +00:00
|
|
|
setImages();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectCatalogToolBox_Impl::setImages()
|
|
|
|
{
|
2010-11-13 17:22:01 +00:00
|
|
|
SetImageList(m_aImagesNormal);
|
2002-07-03 14:53:24 +00:00
|
|
|
}
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|