1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_basctl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <ide_pch.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <basic/sbx.hxx> 35*cdf0e10cSrcweir #ifndef _SV_CMDEVT_HXX 36*cdf0e10cSrcweir #include <vcl/cmdevt.hxx> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir #include <vcl/taskpanelist.hxx> 39*cdf0e10cSrcweir #include <vcl/sound.hxx> 40*cdf0e10cSrcweir #include <objdlg.hrc> 41*cdf0e10cSrcweir #include <objdlg.hxx> 42*cdf0e10cSrcweir #include <bastypes.hxx> 43*cdf0e10cSrcweir #include <basidesh.hrc> 44*cdf0e10cSrcweir #include <basidesh.hxx> 45*cdf0e10cSrcweir #include <iderdll.hxx> 46*cdf0e10cSrcweir #include <iderdll2.hxx> 47*cdf0e10cSrcweir #include <sbxitem.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir //#ifndef _SFX_HELP_HXX //autogen 50*cdf0e10cSrcweir //#include <sfx2/sfxhelp.hxx> 51*cdf0e10cSrcweir //#endif 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir ObjectTreeListBox::ObjectTreeListBox( Window* pParent, const ResId& rRes ) 55*cdf0e10cSrcweir : BasicTreeListBox( pParent, rRes ) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir ObjectTreeListBox::~ObjectTreeListBox() 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir void ObjectTreeListBox::Command( const CommandEvent& ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir void ObjectTreeListBox::MouseButtonDown( const MouseEvent& rMEvt ) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir BasicTreeListBox::MouseButtonDown( rMEvt ); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) ) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir BasicEntryDescriptor aDesc( GetEntryDescriptor( GetCurEntry() ) ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir if ( aDesc.GetType() == OBJ_TYPE_METHOD ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 78*cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 79*cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 80*cdf0e10cSrcweir if( pDispatcher ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(), 83*cdf0e10cSrcweir aDesc.GetMethodName(), ConvertType( aDesc.GetType() ) ); 84*cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_SHOWSBX, 85*cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir ObjectCatalog::ObjectCatalog( Window * pParent ) 94*cdf0e10cSrcweir :FloatingWindow( pParent, IDEResId( RID_BASICIDE_OBJCAT ) ) 95*cdf0e10cSrcweir ,aMacroTreeList( this, IDEResId( RID_TLB_MACROS ) ) 96*cdf0e10cSrcweir ,aToolBox(this, IDEResId(RID_TB_TOOLBOX), IDEResId(RID_IMGLST_TB_HC)) 97*cdf0e10cSrcweir ,aMacroDescr( this, IDEResId( RID_FT_MACRODESCR ) ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir FreeResource(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir aToolBox.SetOutStyle( TOOLBOX_STYLE_FLAT ); 102*cdf0e10cSrcweir aToolBox.SetSizePixel( aToolBox.CalcWindowSizePixel() ); 103*cdf0e10cSrcweir aToolBox.SetSelectHdl( LINK( this, ObjectCatalog, ToolBoxHdl ) ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir aMacroTreeList.SetStyle( WB_BORDER | WB_TABSTOP | 106*cdf0e10cSrcweir WB_HASLINES | WB_HASLINESATROOT | 107*cdf0e10cSrcweir WB_HASBUTTONS | WB_HASBUTTONSATROOT | 108*cdf0e10cSrcweir WB_HSCROLL ); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir aMacroTreeList.SetSelectHdl( LINK( this, ObjectCatalog, TreeListHighlightHdl ) ); 111*cdf0e10cSrcweir aMacroTreeList.SetAccessibleName(String(IDEResId(RID_STR_TLB_MACROS))); 112*cdf0e10cSrcweir aMacroTreeList.ScanAllEntries(); 113*cdf0e10cSrcweir aMacroTreeList.GrabFocus(); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir CheckButtons(); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir Point aPos = IDE_DLL()->GetExtraData()->GetObjectCatalogPos(); 118*cdf0e10cSrcweir Size aSize = IDE_DLL()->GetExtraData()->GetObjectCatalogSize(); 119*cdf0e10cSrcweir if ( aPos.X() == INVPOSITION ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir // Zentriert nach AppWin: 122*cdf0e10cSrcweir Window* pWin = GetParent(); 123*cdf0e10cSrcweir aPos = pWin->OutputToScreenPixel( Point( 0, 0 ) ); 124*cdf0e10cSrcweir Size aAppWinSz = pWin->GetSizePixel(); 125*cdf0e10cSrcweir Size aDlgWinSz = GetSizePixel(); 126*cdf0e10cSrcweir aPos.X() += aAppWinSz.Width() / 2; 127*cdf0e10cSrcweir aPos.X() -= aDlgWinSz.Width() / 2; 128*cdf0e10cSrcweir aPos.Y() += aAppWinSz.Height() / 2; 129*cdf0e10cSrcweir aPos.Y() -= aDlgWinSz.Height() / 2; 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir SetPosPixel( aPos ); 132*cdf0e10cSrcweir if ( aSize.Width() ) 133*cdf0e10cSrcweir SetOutputSizePixel( aSize ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir Resize(); // damit der Resize-Handler die Controls anordnet 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // make object catalog keyboard accessible 138*cdf0e10cSrcweir pParent->GetSystemWindow()->GetTaskPaneList()->AddWindow( this ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir ObjectCatalog::~ObjectCatalog() 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir void __EXPORT ObjectCatalog::Move() 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir IDE_DLL()->GetExtraData()->SetObjectCatalogPos( GetPosPixel() ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir sal_Bool __EXPORT ObjectCatalog::Close() 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir aCancelHdl.Call( this ); 154*cdf0e10cSrcweir return sal_True; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void __EXPORT ObjectCatalog::Resize() 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir Size aOutSz = GetOutputSizePixel(); 160*cdf0e10cSrcweir IDE_DLL()->GetExtraData()->SetObjectCatalogSize( aOutSz ); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir Point aTreePos = aMacroTreeList.GetPosPixel(); 163*cdf0e10cSrcweir Size aDescrSz = aMacroDescr.GetSizePixel(); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir Size aTreeSz; 166*cdf0e10cSrcweir long nCtrlWidth = aOutSz.Width() - 2*aTreePos.X(); 167*cdf0e10cSrcweir aTreeSz.Width() = nCtrlWidth; 168*cdf0e10cSrcweir aTreeSz.Height() = aOutSz.Height() - aTreePos.Y() - 169*cdf0e10cSrcweir 2*aTreePos.X() - aDescrSz.Height(); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir if ( aTreeSz.Height() > 0 ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir aMacroTreeList.SetSizePixel( aTreeSz ); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir Point aDescrPos( aTreePos.X(), aTreePos.Y()+aTreeSz.Height()+aTreePos.X() ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir aMacroDescr.SetPosSizePixel( aDescrPos, Size( nCtrlWidth, aDescrSz.Height() ) ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir String aDesc = aMacroDescr.GetText(); 180*cdf0e10cSrcweir aMacroDescr.SetText(String()); 181*cdf0e10cSrcweir aMacroDescr.SetText(aDesc); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir // Die Buttons oben bleiben immer unveraendert stehen... 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir IMPL_LINK( ObjectCatalog, ToolBoxHdl, ToolBox*, pToolBox ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir sal_uInt16 nCurItem = pToolBox->GetCurItemId(); 190*cdf0e10cSrcweir switch ( nCurItem ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir case TBITEM_SHOW: 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir SfxAllItemSet aArgs( SFX_APP()->GetPool() ); 195*cdf0e10cSrcweir SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs ); 196*cdf0e10cSrcweir SFX_APP()->ExecuteSlot( aRequest ); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry(); 199*cdf0e10cSrcweir DBG_ASSERT( pCurEntry, "Entry?!" ); 200*cdf0e10cSrcweir BasicEntryDescriptor aDesc( aMacroTreeList.GetEntryDescriptor( pCurEntry ) ); 201*cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 202*cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 203*cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 204*cdf0e10cSrcweir if ( aDesc.GetType() == OBJ_TYPE_MODULE || 205*cdf0e10cSrcweir aDesc.GetType() == OBJ_TYPE_DIALOG || 206*cdf0e10cSrcweir aDesc.GetType() == OBJ_TYPE_METHOD ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir if( pDispatcher ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(), 211*cdf0e10cSrcweir aDesc.GetMethodName(), aMacroTreeList.ConvertType( aDesc.GetType() ) ); 212*cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_SHOWSBX, 213*cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir else 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir ErrorBox( this, WB_OK, String( IDEResId( RID_STR_OBJNOTFOUND ) ) ).Execute(); 219*cdf0e10cSrcweir aMacroTreeList.GetModel()->Remove( pCurEntry ); 220*cdf0e10cSrcweir CheckButtons(); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir break; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir return 0; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir void ObjectCatalog::CheckButtons() 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry(); 234*cdf0e10cSrcweir BasicEntryType eType = pCurEntry ? ((BasicEntry*)pCurEntry->GetUserData())->GetType() : OBJ_TYPE_UNKNOWN; 235*cdf0e10cSrcweir if ( eType == OBJ_TYPE_DIALOG || eType == OBJ_TYPE_MODULE || eType == OBJ_TYPE_METHOD ) 236*cdf0e10cSrcweir aToolBox.EnableItem( TBITEM_SHOW, sal_True ); 237*cdf0e10cSrcweir else 238*cdf0e10cSrcweir aToolBox.EnableItem( TBITEM_SHOW, sal_False ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir IMPL_LINK_INLINE_START( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir if ( pBox->IsSelected( pBox->GetHdlEntry() ) ) 246*cdf0e10cSrcweir UpdateFields(); 247*cdf0e10cSrcweir return 0; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir IMPL_LINK_INLINE_END( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox ) 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir void ObjectCatalog::UpdateFields() 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry(); 255*cdf0e10cSrcweir if ( pCurEntry ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir CheckButtons(); 258*cdf0e10cSrcweir aMacroDescr.SetText( String() ); 259*cdf0e10cSrcweir SbxVariable* pVar = aMacroTreeList.FindVariable( pCurEntry ); 260*cdf0e10cSrcweir if ( pVar ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir SbxInfoRef xInfo = pVar->GetInfo(); 263*cdf0e10cSrcweir if ( xInfo.Is() ) 264*cdf0e10cSrcweir aMacroDescr.SetText( xInfo->GetComment() ); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir void ObjectCatalog::UpdateEntries() 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir aMacroTreeList.UpdateEntries(); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir void ObjectCatalog::SetCurrentEntry( BasicEntryDescriptor& rDesc ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir aMacroTreeList.SetCurrentEntry( rDesc ); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir ObjectCatalogToolBox_Impl::ObjectCatalogToolBox_Impl( 281*cdf0e10cSrcweir Window * pParent, ResId const & rResId, 282*cdf0e10cSrcweir ResId const & rImagesHighContrastId): 283*cdf0e10cSrcweir ToolBox(pParent, rResId), 284*cdf0e10cSrcweir m_aImagesNormal(GetImageList()), 285*cdf0e10cSrcweir m_aImagesHighContrast(rImagesHighContrastId), 286*cdf0e10cSrcweir m_bHighContrast(false) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir setImages(); 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir // virtual 292*cdf0e10cSrcweir void ObjectCatalogToolBox_Impl::DataChanged(DataChangedEvent const & rDCEvt) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir ToolBox::DataChanged(rDCEvt); 295*cdf0e10cSrcweir if ((rDCEvt.GetType() == DATACHANGED_SETTINGS 296*cdf0e10cSrcweir || rDCEvt.GetType() == DATACHANGED_DISPLAY) 297*cdf0e10cSrcweir && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) 298*cdf0e10cSrcweir setImages(); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir void ObjectCatalogToolBox_Impl::setImages() 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 304*cdf0e10cSrcweir if (bHC != m_bHighContrast) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir SetImageList(bHC ? m_aImagesHighContrast : m_aImagesNormal); 307*cdf0e10cSrcweir m_bHighContrast = bHC; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310