1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_basctl.hxx" 30 31 32 #include <ide_pch.hxx> 33 34 35 #define _BASIDE_POPUPWINDOWTBX 36 #include <tbxctl.hxx> 37 #include <svx/svxids.hrc> 38 #include <iderid.hxx> 39 #include <tbxctl.hrc> 40 #include <idetemp.hxx> 41 #include <sfx2/imagemgr.hxx> 42 #include <svl/aeitem.hxx> 43 #include <vcl/toolbox.hxx> 44 45 using namespace ::com::sun::star::uno; 46 47 48 static ::rtl::OUString aSubToolBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcontrolsbar" ) ); 49 50 SFX_IMPL_TOOLBOX_CONTROL( TbxControls, SfxAllEnumItem ) 51 52 /************************************************************************* 53 |* 54 |* WorkWindow Alignment 55 |* 56 \************************************************************************/ 57 /* 58 IMPL_LINK( PopupWindowTbx, SelectHdl, void*, EMPTYARG ) 59 { 60 if ( IsInPopupMode() ) 61 EndPopupMode(); 62 63 aSelectLink.Call( &aTbx.GetToolBox() ); 64 65 return 0; 66 } 67 68 PopupWindowTbx::PopupWindowTbx( sal_uInt16 nId, WindowAlign eAlign, 69 ResId aRIdWin, ResId aRIdTbx, 70 SfxBindings& rBind ) : 71 SfxPopupWindow ( nId, aRIdWin, rBind ), 72 aTbx ( this, GetBindings(), aRIdTbx ) 73 { 74 FreeResource(); 75 aTbx.Initialize(); 76 77 ToolBox& rBox = aTbx.GetToolBox(); 78 rBox.SetAlign( eAlign ); 79 if( eAlign == WINDOWALIGN_LEFT ) 80 SetText( String() ); 81 82 Size aSize = aTbx.CalcWindowSizePixel(); 83 rBox.SetSizePixel( aSize ); 84 SetOutputSizePixel( aSize ); 85 aSelectLink = rBox.GetSelectHdl(); 86 rBox.SetSelectHdl( LINK( this, PopupWindowTbx, SelectHdl ) ); 87 } 88 89 SfxPopupWindow* PopupWindowTbx::Clone() const 90 { 91 return new PopupWindowTbx( GetId(), aTbx.GetAlign(), 92 IDEResId( RID_TBXCONTROLS ), 93 IDEResId( RID_TOOLBOX ), 94 (SfxBindings&) GetBindings() ); 95 } 96 97 void PopupWindowTbx::PopupModeEnd() 98 { 99 aTbx.GetToolBox().EndSelection(); 100 SfxPopupWindow::PopupModeEnd(); 101 } 102 103 void PopupWindowTbx::Update() 104 { 105 ToolBox *pBox = &aTbx.GetToolBox(); 106 aTbx.Activate( pBox ); 107 aTbx.Deactivate( pBox ); 108 } 109 110 PopupWindowTbx::~PopupWindowTbx() 111 { 112 } 113 */ 114 /************************************************************************* 115 |* 116 |* Klasse fuer Toolbox 117 |* 118 \************************************************************************/ 119 120 TbxControls::TbxControls( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 121 SfxToolBoxControl( nSlotId, nId, rTbx ) 122 { 123 nLastSlot = USHRT_MAX; 124 125 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 126 rTbx.Invalidate(); 127 } 128 129 /************************************************************************* 130 |* 131 |* Wenn man ein PopupWindow erzeugen will 132 |* 133 \************************************************************************/ 134 SfxPopupWindowType TbxControls::GetPopupWindowType() const 135 { 136 if( nLastSlot == USHRT_MAX ) 137 return(SFX_POPUPWINDOW_ONCLICK); 138 return(SFX_POPUPWINDOW_ONTIMEOUT); 139 } 140 141 void TbxControls::StateChanged( sal_uInt16 nSID, SfxItemState eState, 142 const SfxPoolItem* pState ) 143 { 144 if( pState ) 145 { 146 SfxAllEnumItem* pItem = PTR_CAST(SfxAllEnumItem, pState); 147 if( pItem ) 148 { 149 sal_uInt16 nLastEnum = pItem->GetValue(); 150 sal_uInt16 nTemp = 0; 151 switch( nLastEnum ) 152 { 153 case SVX_SNAP_PUSHBUTTON: nTemp = SID_INSERT_PUSHBUTTON; break; 154 case SVX_SNAP_CHECKBOX: nTemp = SID_INSERT_CHECKBOX; break; 155 case SVX_SNAP_RADIOBUTTON: nTemp = SID_INSERT_RADIOBUTTON; break; 156 case SVX_SNAP_SPINBUTTON: nTemp = SID_INSERT_SPINBUTTON; break; 157 case SVX_SNAP_FIXEDTEXT: nTemp = SID_INSERT_FIXEDTEXT; break; 158 case SVX_SNAP_GROUPBOX: nTemp = SID_INSERT_GROUPBOX; break; 159 case SVX_SNAP_LISTBOX: nTemp = SID_INSERT_LISTBOX; break; 160 case SVX_SNAP_COMBOBOX: nTemp = SID_INSERT_COMBOBOX; break; 161 case SVX_SNAP_EDIT: nTemp = SID_INSERT_EDIT; break; 162 case SVX_SNAP_HSCROLLBAR: nTemp = SID_INSERT_HSCROLLBAR; break; 163 case SVX_SNAP_VSCROLLBAR: nTemp = SID_INSERT_VSCROLLBAR; break; 164 case SVX_SNAP_PREVIEW: nTemp = SID_INSERT_PREVIEW; break; 165 case SVX_SNAP_URLBUTTON: nTemp = SID_INSERT_URLBUTTON; break; 166 case SVX_SNAP_IMAGECONTROL: nTemp = SID_INSERT_IMAGECONTROL; break; 167 case SVX_SNAP_PROGRESSBAR: nTemp = SID_INSERT_PROGRESSBAR; break; 168 case SVX_SNAP_HFIXEDLINE: nTemp = SID_INSERT_HFIXEDLINE; break; 169 case SVX_SNAP_VFIXEDLINE: nTemp = SID_INSERT_VFIXEDLINE; break; 170 case SVX_SNAP_DATEFIELD: nTemp = SID_INSERT_DATEFIELD; break; 171 case SVX_SNAP_TIMEFIELD: nTemp = SID_INSERT_TIMEFIELD; break; 172 case SVX_SNAP_NUMERICFIELD: nTemp = SID_INSERT_NUMERICFIELD; break; 173 case SVX_SNAP_CURRENCYFIELD: nTemp = SID_INSERT_CURRENCYFIELD; break; 174 case SVX_SNAP_FORMATTEDFIELD: nTemp = SID_INSERT_FORMATTEDFIELD; break; 175 case SVX_SNAP_PATTERNFIELD: nTemp = SID_INSERT_PATTERNFIELD; break; 176 case SVX_SNAP_FILECONTROL: nTemp = SID_INSERT_FILECONTROL; break; 177 case SVX_SNAP_TREECONTROL: nTemp = SID_INSERT_TREECONTROL; break; 178 } 179 if( nTemp ) 180 { 181 rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 182 aSlotURL += rtl::OUString::valueOf( sal_Int32( nTemp )); 183 Image aImage = GetImage( m_xFrame, 184 aSlotURL, 185 hasBigImages(), 186 GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() ); 187 ToolBox& rBox = GetToolBox(); 188 rBox.SetItemImage(GetId(), aImage); 189 nLastSlot = nLastEnum; 190 } 191 } 192 } 193 SfxToolBoxControl::StateChanged( nSID, eState,pState ); 194 } 195 196 void TbxControls::Select( sal_uInt16 nModifier ) 197 { 198 (void)nModifier; 199 SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS, nLastSlot ); 200 SfxViewFrame* pCurFrame = SfxViewFrame::Current(); 201 DBG_ASSERT( pCurFrame != NULL, "No current view frame!" ); 202 SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL; 203 if( pDispatcher ) 204 { 205 pDispatcher->Execute( SID_CHOOSE_CONTROLS, SFX_CALLMODE_SYNCHRON, &aItem, 0L ); 206 } 207 } 208 209 /************************************************************************* 210 |* 211 |* Hier wird das Fenster erzeugt 212 |* Lage der Toolbox mit GetToolBox() abfragbar 213 |* rItemRect sind die Screen-Koordinaten 214 |* 215 \************************************************************************/ 216 SfxPopupWindow* TbxControls::CreatePopupWindow() 217 { 218 if ( GetSlotId() == SID_CHOOSE_CONTROLS ) 219 createAndPositionSubToolBar( aSubToolBarResName ); 220 221 /* 222 if (GetId() == SID_CHOOSE_CONTROLS) 223 { 224 PopupWindowTbx *pWin = 225 new PopupWindowTbx( GetId(), 226 GetToolBox().IsHorizontal() ? 227 WINDOWALIGN_LEFT : WINDOWALIGN_TOP, 228 IDEResId( RID_TBXCONTROLS ), 229 IDEResId( RID_TOOLBOX ), 230 GetBindings() ); 231 pWin->StartPopupMode(&GetToolBox(), sal_True); 232 pWin->Update(); 233 pWin->StartSelection(); 234 pWin->Show(); 235 return(pWin); 236 } 237 */ 238 return(0); 239 } 240 241 242