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_sd.hxx" 30 31 32 #include <sfx2/bindings.hxx> 33 #include <svx/svxids.hrc> 34 #include <svx/grafctrl.hxx> 35 #include <svl/cjkoptions.hxx> 36 #include <sfx2/viewsh.hxx> 37 #ifndef _SFX_IMAGEMGR_HXX 38 #include <sfx2/imagemgr.hxx> 39 #endif 40 #include <rtl/ustring.hxx> 41 #include <rtl/ustrbuf.hxx> 42 43 #include "sddll.hxx" 44 #include "GraphicDocShell.hxx" 45 46 #include <vcl/toolbox.hxx> 47 48 #include "app.hxx" 49 #include "app.hrc" 50 #include "res_bmp.hrc" 51 #include "sdresid.hxx" 52 #include "tbx_ww.hxx" 53 #include "tbx_ww.hrc" 54 55 SFX_IMPL_TOOLBOX_CONTROL( SdTbxControl, TbxImageItem ) 56 57 /************************************************************************* 58 |* 59 |* PopUp-Window 60 |* 61 \************************************************************************/ 62 /* 63 SdPopupWindowTbx::SdPopupWindowTbx( sal_uInt16 nId, WindowAlign eAlign, 64 SdResId aRIdWin, SdResId aRIdTbx, 65 SfxBindings& rBindings ) : 66 SfxPopupWindow ( nId, aRIdWin, rBindings ), 67 aTbx ( this, GetBindings(), aRIdTbx ), 68 aSdResIdWin ( aRIdWin ), 69 aSdResIdTbx ( aRIdTbx ), 70 eTbxAlign ( eAlign ) 71 { 72 aTbx.UseDefault(); 73 aSelectLink = aTbx.GetToolBox().GetSelectHdl(); 74 aTbx.GetToolBox().SetSelectHdl( LINK( this, SdPopupWindowTbx, TbxSelectHdl ) ); 75 76 FreeResource(); 77 78 if( ( eAlign == WINDOWALIGN_TOP ) || ( eAlign == WINDOWALIGN_BOTTOM ) ) 79 { 80 if ( aSdResIdWin.GetId() != RID_TEXT ) 81 aTbx.GetToolBox().SetAlign( WINDOWALIGN_LEFT ); 82 83 SetText( String() ); 84 } 85 86 AdaptToCTL(); 87 } 88 89 90 void SdPopupWindowTbx::AdaptToCTL (void) 91 { 92 Size aSize = aTbx.CalcWindowSizePixel(); 93 if (aSdResIdWin.GetId() == RID_TEXT) 94 { 95 SvtCJKOptions aCJKOptions; 96 if ( ! aCJKOptions.IsVerticalTextEnabled()) 97 { 98 ToolBox& aToolBox = aTbx.GetToolBox(); 99 100 // Iterate over all tool box items and remove those that are 101 // specific to complex text layout. 102 sal_uInt16 i=0; 103 while (i < aToolBox.GetItemCount()) 104 { 105 sal_uInt16 nIndex = aToolBox.GetItemId(i); 106 switch (nIndex) 107 { 108 case 0: // Line break. 109 case SID_ATTR_CHAR_VERTICAL: 110 case SID_TEXT_FITTOSIZE_VERTICAL: 111 case SID_DRAW_CAPTION_VERTICAL: 112 case SID_DRAW_FONTWORK_VERTICAL: 113 aToolBox.RemoveItem (i); 114 break; 115 116 default: 117 // Leave the item unmodified. Advance to the next one. 118 i+=1; 119 } 120 } 121 aToolBox.RecalcItems(); 122 // Why is this necessary? 123 aToolBox.SetLineCount(1); 124 sal_uInt16 nLineCount = aToolBox.GetLineCount(); 125 aSize = aToolBox.CalcWindowSizePixel(nLineCount); 126 } 127 } 128 aTbx.SetPosSizePixel( Point(), aSize ); 129 SetOutputSizePixel( aSize ); 130 } 131 */ 132 133 /*-------------------------------------------------------------------------*/ 134 /* 135 SdPopupWindowTbx::~SdPopupWindowTbx() 136 { 137 } 138 */ 139 /*-------------------------------------------------------------------------*/ 140 /* 141 SfxPopupWindow* SdPopupWindowTbx::Clone() const 142 { 143 SfxBindings& rBindings = (SfxBindings&)GetBindings(); 144 145 return( new SdPopupWindowTbx( GetId(), eTbxAlign, 146 aSdResIdWin, aSdResIdTbx, rBindings ) ); 147 148 //return( SfxPopupWindow::Clone() ); 149 } 150 */ 151 /*-------------------------------------------------------------------------*/ 152 /* 153 void SdPopupWindowTbx::Update() 154 { 155 AdaptToCTL(); 156 157 ToolBox *pBox = &aTbx.GetToolBox(); 158 aTbx.Activate( pBox ); 159 aTbx.Deactivate( pBox ); 160 } 161 */ 162 /*-------------------------------------------------------------------------*/ 163 /* 164 void SdPopupWindowTbx::PopupModeEnd() 165 { 166 aTbx.GetToolBox().EndSelection(); 167 168 SfxPopupWindow::PopupModeEnd(); 169 } 170 */ 171 /*-------------------------------------------------------------------------*/ 172 /* 173 IMPL_LINK( SdPopupWindowTbx, TbxSelectHdl, ToolBox*, pBox) 174 { 175 if( IsInPopupMode() ) 176 EndPopupMode(); 177 178 aSelectLink.Call( &aTbx.GetToolBox() ); 179 180 if ( pBox->GetModifier() & KEY_MOD1 ) 181 { 182 // #99013# if selected with control key, return focus to current view 183 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 184 if ( pShellWnd ) 185 pShellWnd->GrabFocus(); 186 } 187 188 return( 0L ); 189 } 190 */ 191 /************************************************************************* 192 |* 193 |* Klasse fuer Toolbox 194 |* 195 \************************************************************************/ 196 197 SdTbxControl::SdTbxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 198 SfxToolBoxControl( nSlotId, nId, rTbx ) 199 { 200 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 201 rTbx.Invalidate(); 202 } 203 204 /*-------------------------------------------------------------------------*/ 205 206 SfxPopupWindowType SdTbxControl::GetPopupWindowType() const 207 { 208 return( SFX_POPUPWINDOW_ONTIMEOUT ); 209 } 210 211 /************************************************************************* 212 |* 213 |* Hier wird das Fenster erzeugt 214 |* Lage der Toolbox mit GetToolBox() abfragbar 215 |* rItemRect sind die Screen-Koordinaten 216 |* 217 \************************************************************************/ 218 219 SfxPopupWindow* SdTbxControl::CreatePopupWindow() 220 { 221 SfxPopupWindow *pWin = NULL; 222 rtl::OUString aToolBarResStr; 223 rtl::OUStringBuffer aTbxResName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ))); 224 switch( GetSlotId() ) 225 { 226 case SID_OBJECT_ALIGN: 227 aTbxResName.appendAscii( "alignmentbar" ); 228 aToolBarResStr = aTbxResName.makeStringAndClear(); 229 break; 230 case SID_ZOOM_TOOLBOX: 231 aTbxResName.appendAscii( "zoombar" ); 232 aToolBarResStr = aTbxResName.makeStringAndClear(); 233 break; 234 case SID_OBJECT_CHOOSE_MODE: 235 aTbxResName.appendAscii( "choosemodebar" ); 236 aToolBarResStr = aTbxResName.makeStringAndClear(); 237 break; 238 case SID_POSITION: 239 aTbxResName.appendAscii( "positionbar" ); 240 aToolBarResStr = aTbxResName.makeStringAndClear(); 241 break; 242 case SID_DRAWTBX_TEXT: 243 aTbxResName.appendAscii( "textbar" ); 244 aToolBarResStr = aTbxResName.makeStringAndClear(); 245 break; 246 case SID_DRAWTBX_RECTANGLES: 247 aTbxResName.appendAscii( "rectanglesbar" ); 248 aToolBarResStr = aTbxResName.makeStringAndClear(); 249 break; 250 case SID_DRAWTBX_ELLIPSES: 251 aTbxResName.appendAscii( "ellipsesbar" ); 252 aToolBarResStr = aTbxResName.makeStringAndClear(); 253 break; 254 case SID_DRAWTBX_LINES: 255 aTbxResName.appendAscii( "linesbar" ); 256 aToolBarResStr = aTbxResName.makeStringAndClear(); 257 break; 258 case SID_DRAWTBX_ARROWS: 259 aTbxResName.appendAscii( "arrowsbar" ); 260 aToolBarResStr = aTbxResName.makeStringAndClear(); 261 break; 262 case SID_DRAWTBX_3D_OBJECTS: 263 aTbxResName.appendAscii( "3dobjectsbar" ); 264 aToolBarResStr = aTbxResName.makeStringAndClear(); 265 break; 266 case SID_DRAWTBX_CONNECTORS: 267 aTbxResName.appendAscii( "connectorsbar" ); 268 aToolBarResStr = aTbxResName.makeStringAndClear(); 269 break; 270 case SID_DRAWTBX_INSERT: 271 aTbxResName.appendAscii( "insertbar" ); 272 aToolBarResStr = aTbxResName.makeStringAndClear(); 273 break; 274 } 275 276 if ( aToolBarResStr.getLength() > 0 ) 277 createAndPositionSubToolBar( aToolBarResStr ); 278 279 return( pWin ); 280 } 281 282 /*-------------------------------------------------------------------------*/ 283 284 void SdTbxControl::StateChanged( sal_uInt16 nSId, 285 SfxItemState eState, const SfxPoolItem* pState ) 286 { 287 SfxToolBoxControl::StateChanged( nSId, eState, pState ); 288 289 if( eState == SFX_ITEM_AVAILABLE ) 290 { 291 TbxImageItem* pItem = PTR_CAST( TbxImageItem, pState ); 292 //DBG_ASSERT( pItem, "TbxImageItem erwartet!" ); 293 // Im StarDesktop kann jetzt auch ein anderes Item ankommen, 294 // das nicht ausgewertet werden darf (#33802# und #33838#) 295 if( pItem ) 296 { 297 ToolBox& rTbx = GetToolBox(); 298 sal_uInt16 nImage = pItem->GetValue(); 299 if( nImage == 0 ) 300 { 301 if( rTbx.IsItemChecked( nSId ) ) 302 rTbx.CheckItem( nSId, sal_False ); 303 } 304 else 305 { 306 rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 307 aSlotURL += rtl::OUString::valueOf( sal_Int32( nImage )); 308 Image aImage = GetImage( m_xFrame, 309 aSlotURL, 310 hasBigImages(), 311 GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() ); 312 313 // !-Operator prueft, ob Image nicht vorhanden ist 314 if( !!aImage ) 315 { 316 rTbx.SetItemImage( GetId(), aImage ); 317 rTbx.CheckItem( GetId(), IsCheckable( nImage ) ); 318 319 if( nSId != SID_ZOOM_TOOLBOX && 320 nSId != SID_DRAWTBX_INSERT && 321 nSId != SID_POSITION && 322 nSId != SID_OBJECT_ALIGN ) 323 { 324 if( nSId != SID_OBJECT_CHOOSE_MODE && 325 rTbx.IsItemChecked( SID_OBJECT_CHOOSE_MODE ) ) 326 rTbx.CheckItem( SID_OBJECT_CHOOSE_MODE, sal_False ); 327 if( nSId != SID_DRAWTBX_TEXT && 328 rTbx.IsItemChecked( SID_DRAWTBX_TEXT ) ) 329 rTbx.CheckItem( SID_DRAWTBX_TEXT, sal_False ); 330 if( nSId != SID_DRAWTBX_RECTANGLES && 331 rTbx.IsItemChecked( SID_DRAWTBX_RECTANGLES ) ) 332 rTbx.CheckItem( SID_DRAWTBX_RECTANGLES, sal_False ); 333 if( nSId != SID_DRAWTBX_ELLIPSES && 334 rTbx.IsItemChecked( SID_DRAWTBX_ELLIPSES ) ) 335 rTbx.CheckItem( SID_DRAWTBX_ELLIPSES, sal_False ); 336 if( nSId != SID_DRAWTBX_LINES && 337 rTbx.IsItemChecked( SID_DRAWTBX_LINES ) ) 338 rTbx.CheckItem( SID_DRAWTBX_LINES, sal_False ); 339 if( nSId != SID_DRAWTBX_ARROWS && 340 rTbx.IsItemChecked( SID_DRAWTBX_ARROWS ) ) 341 rTbx.CheckItem( SID_DRAWTBX_ARROWS, sal_False ); 342 if( nSId != SID_DRAWTBX_3D_OBJECTS && 343 rTbx.IsItemChecked( SID_DRAWTBX_3D_OBJECTS ) ) 344 rTbx.CheckItem( SID_DRAWTBX_3D_OBJECTS, sal_False ); 345 if( nSId != SID_DRAWTBX_CONNECTORS && 346 rTbx.IsItemChecked( SID_DRAWTBX_CONNECTORS ) ) 347 rTbx.CheckItem( SID_DRAWTBX_CONNECTORS, sal_False ); 348 } 349 } 350 } 351 } 352 } 353 } 354 355 /*-------------------------------------------------------------------------*/ 356 357 sal_Bool SdTbxControl::IsCheckable( sal_uInt16 nSId ) 358 { 359 switch( nSId ) 360 { 361 case SID_OBJECT_ROTATE: 362 case SID_OBJECT_MIRROR: 363 case SID_OBJECT_CROP: 364 case SID_OBJECT_TRANSPARENCE: 365 case SID_OBJECT_GRADIENT: 366 case SID_OBJECT_SHEAR: 367 case SID_OBJECT_CROOK_ROTATE: 368 case SID_OBJECT_CROOK_SLANT: 369 case SID_OBJECT_CROOK_STRETCH: 370 case SID_CONVERT_TO_3D_LATHE: 371 372 case SID_ATTR_CHAR: 373 case SID_ATTR_CHAR_VERTICAL: 374 case SID_TEXT_FITTOSIZE: 375 case SID_TEXT_FITTOSIZE_VERTICAL: 376 case SID_DRAW_CAPTION: 377 case SID_DRAW_CAPTION_VERTICAL: 378 case SID_DRAW_FONTWORK: 379 case SID_DRAW_FONTWORK_VERTICAL: 380 381 case SID_DRAW_RECT: 382 case SID_DRAW_SQUARE: 383 case SID_DRAW_RECT_ROUND: 384 case SID_DRAW_SQUARE_ROUND: 385 case SID_DRAW_RECT_NOFILL: 386 case SID_DRAW_SQUARE_NOFILL: 387 case SID_DRAW_RECT_ROUND_NOFILL: 388 case SID_DRAW_SQUARE_ROUND_NOFILL: 389 390 case SID_DRAW_ELLIPSE: 391 case SID_DRAW_CIRCLE: 392 case SID_DRAW_PIE: 393 case SID_DRAW_CIRCLEPIE: 394 case SID_DRAW_ELLIPSECUT: 395 case SID_DRAW_CIRCLECUT: 396 case SID_DRAW_ARC: 397 case SID_DRAW_CIRCLEARC: 398 case SID_DRAW_ELLIPSE_NOFILL: 399 case SID_DRAW_CIRCLE_NOFILL: 400 case SID_DRAW_PIE_NOFILL: 401 case SID_DRAW_CIRCLEPIE_NOFILL: 402 case SID_DRAW_ELLIPSECUT_NOFILL: 403 case SID_DRAW_CIRCLECUT_NOFILL: 404 405 case SID_DRAW_BEZIER_NOFILL: 406 case SID_DRAW_POLYGON_NOFILL: 407 case SID_DRAW_XPOLYGON_NOFILL: 408 case SID_DRAW_BEZIER_FILL: 409 case SID_DRAW_POLYGON: 410 case SID_DRAW_XPOLYGON: 411 case SID_DRAW_FREELINE: 412 case SID_DRAW_FREELINE_NOFILL: 413 414 case SID_DRAW_LINE: 415 case SID_DRAW_XLINE: 416 case SID_DRAW_MEASURELINE: 417 case SID_LINE_ARROW_START: 418 case SID_LINE_ARROW_END: 419 case SID_LINE_ARROWS: 420 case SID_LINE_ARROW_CIRCLE: 421 case SID_LINE_CIRCLE_ARROW: 422 case SID_LINE_ARROW_SQUARE: 423 case SID_LINE_SQUARE_ARROW: 424 425 case SID_3D_CUBE: 426 case SID_3D_SPHERE: 427 case SID_3D_CYLINDER: 428 case SID_3D_CONE: 429 case SID_3D_PYRAMID: 430 case SID_3D_TORUS: 431 case SID_3D_SHELL: 432 case SID_3D_HALF_SPHERE: 433 434 case SID_TOOL_CONNECTOR: 435 case SID_CONNECTOR_ARROW_START: 436 case SID_CONNECTOR_ARROW_END: 437 case SID_CONNECTOR_ARROWS: 438 case SID_CONNECTOR_CIRCLE_START: 439 case SID_CONNECTOR_CIRCLE_END: 440 case SID_CONNECTOR_CIRCLES: 441 case SID_CONNECTOR_LINE: 442 case SID_CONNECTOR_LINE_ARROW_START: 443 case SID_CONNECTOR_LINE_ARROW_END: 444 case SID_CONNECTOR_LINE_ARROWS: 445 case SID_CONNECTOR_LINE_CIRCLE_START: 446 case SID_CONNECTOR_LINE_CIRCLE_END: 447 case SID_CONNECTOR_LINE_CIRCLES: 448 case SID_CONNECTOR_CURVE: 449 case SID_CONNECTOR_CURVE_ARROW_START: 450 case SID_CONNECTOR_CURVE_ARROW_END: 451 case SID_CONNECTOR_CURVE_ARROWS: 452 case SID_CONNECTOR_CURVE_CIRCLE_START: 453 case SID_CONNECTOR_CURVE_CIRCLE_END: 454 case SID_CONNECTOR_CURVE_CIRCLES: 455 case SID_CONNECTOR_LINES: 456 case SID_CONNECTOR_LINES_ARROW_START: 457 case SID_CONNECTOR_LINES_ARROW_END: 458 case SID_CONNECTOR_LINES_ARROWS: 459 case SID_CONNECTOR_LINES_CIRCLE_START: 460 case SID_CONNECTOR_LINES_CIRCLE_END: 461 case SID_CONNECTOR_LINES_CIRCLES: 462 463 464 465 //case SID_ZOOM_OUT: 466 return( sal_True ); 467 } 468 return( sal_False ); 469 } 470 471 472 473