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 32*cdf0e10cSrcweir #include <ide_pch.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #define _BASIDE_POPUPWINDOWTBX 36*cdf0e10cSrcweir #include <tbxctl.hxx> 37*cdf0e10cSrcweir #include <svx/svxids.hrc> 38*cdf0e10cSrcweir #include <iderid.hxx> 39*cdf0e10cSrcweir #include <tbxctl.hrc> 40*cdf0e10cSrcweir #include <idetemp.hxx> 41*cdf0e10cSrcweir #include <sfx2/imagemgr.hxx> 42*cdf0e10cSrcweir #include <svl/aeitem.hxx> 43*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir static ::rtl::OUString aSubToolBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcontrolsbar" ) ); 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( TbxControls, SfxAllEnumItem ) 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir /************************************************************************* 53*cdf0e10cSrcweir |* 54*cdf0e10cSrcweir |* WorkWindow Alignment 55*cdf0e10cSrcweir |* 56*cdf0e10cSrcweir \************************************************************************/ 57*cdf0e10cSrcweir /* 58*cdf0e10cSrcweir IMPL_LINK( PopupWindowTbx, SelectHdl, void*, EMPTYARG ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir if ( IsInPopupMode() ) 61*cdf0e10cSrcweir EndPopupMode(); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir aSelectLink.Call( &aTbx.GetToolBox() ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir return 0; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir PopupWindowTbx::PopupWindowTbx( sal_uInt16 nId, WindowAlign eAlign, 69*cdf0e10cSrcweir ResId aRIdWin, ResId aRIdTbx, 70*cdf0e10cSrcweir SfxBindings& rBind ) : 71*cdf0e10cSrcweir SfxPopupWindow ( nId, aRIdWin, rBind ), 72*cdf0e10cSrcweir aTbx ( this, GetBindings(), aRIdTbx ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir FreeResource(); 75*cdf0e10cSrcweir aTbx.Initialize(); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir ToolBox& rBox = aTbx.GetToolBox(); 78*cdf0e10cSrcweir rBox.SetAlign( eAlign ); 79*cdf0e10cSrcweir if( eAlign == WINDOWALIGN_LEFT ) 80*cdf0e10cSrcweir SetText( String() ); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir Size aSize = aTbx.CalcWindowSizePixel(); 83*cdf0e10cSrcweir rBox.SetSizePixel( aSize ); 84*cdf0e10cSrcweir SetOutputSizePixel( aSize ); 85*cdf0e10cSrcweir aSelectLink = rBox.GetSelectHdl(); 86*cdf0e10cSrcweir rBox.SetSelectHdl( LINK( this, PopupWindowTbx, SelectHdl ) ); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir SfxPopupWindow* PopupWindowTbx::Clone() const 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir return new PopupWindowTbx( GetId(), aTbx.GetAlign(), 92*cdf0e10cSrcweir IDEResId( RID_TBXCONTROLS ), 93*cdf0e10cSrcweir IDEResId( RID_TOOLBOX ), 94*cdf0e10cSrcweir (SfxBindings&) GetBindings() ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir void PopupWindowTbx::PopupModeEnd() 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir aTbx.GetToolBox().EndSelection(); 100*cdf0e10cSrcweir SfxPopupWindow::PopupModeEnd(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir void PopupWindowTbx::Update() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir ToolBox *pBox = &aTbx.GetToolBox(); 106*cdf0e10cSrcweir aTbx.Activate( pBox ); 107*cdf0e10cSrcweir aTbx.Deactivate( pBox ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir PopupWindowTbx::~PopupWindowTbx() 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir */ 114*cdf0e10cSrcweir /************************************************************************* 115*cdf0e10cSrcweir |* 116*cdf0e10cSrcweir |* Klasse fuer Toolbox 117*cdf0e10cSrcweir |* 118*cdf0e10cSrcweir \************************************************************************/ 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir TbxControls::TbxControls( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 121*cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir nLastSlot = USHRT_MAX; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 126*cdf0e10cSrcweir rTbx.Invalidate(); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir /************************************************************************* 130*cdf0e10cSrcweir |* 131*cdf0e10cSrcweir |* Wenn man ein PopupWindow erzeugen will 132*cdf0e10cSrcweir |* 133*cdf0e10cSrcweir \************************************************************************/ 134*cdf0e10cSrcweir SfxPopupWindowType TbxControls::GetPopupWindowType() const 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir if( nLastSlot == USHRT_MAX ) 137*cdf0e10cSrcweir return(SFX_POPUPWINDOW_ONCLICK); 138*cdf0e10cSrcweir return(SFX_POPUPWINDOW_ONTIMEOUT); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir void TbxControls::StateChanged( sal_uInt16 nSID, SfxItemState eState, 142*cdf0e10cSrcweir const SfxPoolItem* pState ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if( pState ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir SfxAllEnumItem* pItem = PTR_CAST(SfxAllEnumItem, pState); 147*cdf0e10cSrcweir if( pItem ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir sal_uInt16 nLastEnum = pItem->GetValue(); 150*cdf0e10cSrcweir sal_uInt16 nTemp = 0; 151*cdf0e10cSrcweir switch( nLastEnum ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir case SVX_SNAP_PUSHBUTTON: nTemp = SID_INSERT_PUSHBUTTON; break; 154*cdf0e10cSrcweir case SVX_SNAP_CHECKBOX: nTemp = SID_INSERT_CHECKBOX; break; 155*cdf0e10cSrcweir case SVX_SNAP_RADIOBUTTON: nTemp = SID_INSERT_RADIOBUTTON; break; 156*cdf0e10cSrcweir case SVX_SNAP_SPINBUTTON: nTemp = SID_INSERT_SPINBUTTON; break; 157*cdf0e10cSrcweir case SVX_SNAP_FIXEDTEXT: nTemp = SID_INSERT_FIXEDTEXT; break; 158*cdf0e10cSrcweir case SVX_SNAP_GROUPBOX: nTemp = SID_INSERT_GROUPBOX; break; 159*cdf0e10cSrcweir case SVX_SNAP_LISTBOX: nTemp = SID_INSERT_LISTBOX; break; 160*cdf0e10cSrcweir case SVX_SNAP_COMBOBOX: nTemp = SID_INSERT_COMBOBOX; break; 161*cdf0e10cSrcweir case SVX_SNAP_EDIT: nTemp = SID_INSERT_EDIT; break; 162*cdf0e10cSrcweir case SVX_SNAP_HSCROLLBAR: nTemp = SID_INSERT_HSCROLLBAR; break; 163*cdf0e10cSrcweir case SVX_SNAP_VSCROLLBAR: nTemp = SID_INSERT_VSCROLLBAR; break; 164*cdf0e10cSrcweir case SVX_SNAP_PREVIEW: nTemp = SID_INSERT_PREVIEW; break; 165*cdf0e10cSrcweir case SVX_SNAP_URLBUTTON: nTemp = SID_INSERT_URLBUTTON; break; 166*cdf0e10cSrcweir case SVX_SNAP_IMAGECONTROL: nTemp = SID_INSERT_IMAGECONTROL; break; 167*cdf0e10cSrcweir case SVX_SNAP_PROGRESSBAR: nTemp = SID_INSERT_PROGRESSBAR; break; 168*cdf0e10cSrcweir case SVX_SNAP_HFIXEDLINE: nTemp = SID_INSERT_HFIXEDLINE; break; 169*cdf0e10cSrcweir case SVX_SNAP_VFIXEDLINE: nTemp = SID_INSERT_VFIXEDLINE; break; 170*cdf0e10cSrcweir case SVX_SNAP_DATEFIELD: nTemp = SID_INSERT_DATEFIELD; break; 171*cdf0e10cSrcweir case SVX_SNAP_TIMEFIELD: nTemp = SID_INSERT_TIMEFIELD; break; 172*cdf0e10cSrcweir case SVX_SNAP_NUMERICFIELD: nTemp = SID_INSERT_NUMERICFIELD; break; 173*cdf0e10cSrcweir case SVX_SNAP_CURRENCYFIELD: nTemp = SID_INSERT_CURRENCYFIELD; break; 174*cdf0e10cSrcweir case SVX_SNAP_FORMATTEDFIELD: nTemp = SID_INSERT_FORMATTEDFIELD; break; 175*cdf0e10cSrcweir case SVX_SNAP_PATTERNFIELD: nTemp = SID_INSERT_PATTERNFIELD; break; 176*cdf0e10cSrcweir case SVX_SNAP_FILECONTROL: nTemp = SID_INSERT_FILECONTROL; break; 177*cdf0e10cSrcweir case SVX_SNAP_TREECONTROL: nTemp = SID_INSERT_TREECONTROL; break; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir if( nTemp ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 182*cdf0e10cSrcweir aSlotURL += rtl::OUString::valueOf( sal_Int32( nTemp )); 183*cdf0e10cSrcweir Image aImage = GetImage( m_xFrame, 184*cdf0e10cSrcweir aSlotURL, 185*cdf0e10cSrcweir hasBigImages(), 186*cdf0e10cSrcweir GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() ); 187*cdf0e10cSrcweir ToolBox& rBox = GetToolBox(); 188*cdf0e10cSrcweir rBox.SetItemImage(GetId(), aImage); 189*cdf0e10cSrcweir nLastSlot = nLastEnum; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir SfxToolBoxControl::StateChanged( nSID, eState,pState ); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir void TbxControls::Select( sal_uInt16 nModifier ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir (void)nModifier; 199*cdf0e10cSrcweir SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS, nLastSlot ); 200*cdf0e10cSrcweir SfxViewFrame* pCurFrame = SfxViewFrame::Current(); 201*cdf0e10cSrcweir DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); 202*cdf0e10cSrcweir SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; 203*cdf0e10cSrcweir if( pDispatcher ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir pDispatcher->Execute( SID_CHOOSE_CONTROLS, SFX_CALLMODE_SYNCHRON, &aItem, 0L ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir /************************************************************************* 210*cdf0e10cSrcweir |* 211*cdf0e10cSrcweir |* Hier wird das Fenster erzeugt 212*cdf0e10cSrcweir |* Lage der Toolbox mit GetToolBox() abfragbar 213*cdf0e10cSrcweir |* rItemRect sind die Screen-Koordinaten 214*cdf0e10cSrcweir |* 215*cdf0e10cSrcweir \************************************************************************/ 216*cdf0e10cSrcweir SfxPopupWindow* TbxControls::CreatePopupWindow() 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir if ( GetSlotId() == SID_CHOOSE_CONTROLS ) 219*cdf0e10cSrcweir createAndPositionSubToolBar( aSubToolBarResName ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir /* 222*cdf0e10cSrcweir if (GetId() == SID_CHOOSE_CONTROLS) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir PopupWindowTbx *pWin = 225*cdf0e10cSrcweir new PopupWindowTbx( GetId(), 226*cdf0e10cSrcweir GetToolBox().IsHorizontal() ? 227*cdf0e10cSrcweir WINDOWALIGN_LEFT : WINDOWALIGN_TOP, 228*cdf0e10cSrcweir IDEResId( RID_TBXCONTROLS ), 229*cdf0e10cSrcweir IDEResId( RID_TOOLBOX ), 230*cdf0e10cSrcweir GetBindings() ); 231*cdf0e10cSrcweir pWin->StartPopupMode(&GetToolBox(), sal_True); 232*cdf0e10cSrcweir pWin->Update(); 233*cdf0e10cSrcweir pWin->StartSelection(); 234*cdf0e10cSrcweir pWin->Show(); 235*cdf0e10cSrcweir return(pWin); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir */ 238*cdf0e10cSrcweir return(0); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir 242