1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #include "DrawViewShell.hxx" 28 29 #include "ViewShellHint.hxx" 30 31 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 32 #include <toolkit/unohlp.hxx> 33 #endif 34 #include <sfx2/dispatch.hxx> 35 #ifndef _SVXIDS_HXX 36 #include <svx/svxids.hrc> 37 #endif 38 #include <vcl/msgbox.hxx> 39 #include <svx/svddef.hxx> 40 #include <sfx2/bindings.hxx> 41 #include <sfx2/request.hxx> 42 #include <sfx2/viewfrm.hxx> 43 #include <svx/svdograf.hxx> 44 #include <svx/svdpagv.hxx> 45 46 #include "app.hrc" 47 #include "strings.hrc" 48 49 #include "misc.hxx" 50 #include "fuzoom.hxx" 51 #include "fudspord.hxx" 52 #include "futransf.hxx" 53 #include "fuline.hxx" 54 #include "fuarea.hxx" 55 #include "fuchar.hxx" 56 #include "fuparagr.hxx" 57 #include "fubullet.hxx" 58 #include "futempl.hxx" 59 #include "fuinsert.hxx" 60 #include "fuprlout.hxx" 61 #include "fupage.hxx" 62 #ifndef SD_FU_OBJECT_ANIMATION_PARAMETERS_HXX 63 #include "fuoaprms.hxx" 64 #endif 65 #include "fucopy.hxx" 66 #ifndef SD_FU_LINE_END_HXX 67 #include "fulinend.hxx" 68 #endif 69 #include "fusnapln.hxx" 70 #include "fuolbull.hxx" 71 #include "fuinsfil.hxx" 72 #include "fulink.hxx" 73 #include "futhes.hxx" 74 #include "futxtatt.hxx" 75 #include "fumeasur.hxx" 76 #include "fuconnct.hxx" 77 #include "fumorph.hxx" 78 #include "fuvect.hxx" 79 #include "sdresid.hxx" 80 #include "Window.hxx" 81 #include "drawview.hxx" 82 #include "zoomlist.hxx" 83 #include <vos/mutex.hxx> 84 #include <vcl/salbtype.hxx> // FRound 85 #include <vcl/svapp.hxx> 86 87 namespace sd { 88 89 /************************************************************************* 90 |* 91 |* SfxRequests fuer temporaere Funktionen 92 |* 93 \************************************************************************/ 94 95 void DrawViewShell::FuTemp01(SfxRequest& rReq) 96 { 97 switch(rReq.GetSlot()) 98 { 99 case SID_ATTRIBUTES_LINE: // BASIC 100 { 101 SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 102 Cancel(); 103 } 104 break; 105 106 case SID_ATTRIBUTES_AREA: // BASIC 107 { 108 SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 109 Cancel(); 110 } 111 break; 112 113 case SID_ATTR_TRANSFORM: 114 { 115 SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 116 Invalidate(SID_RULER_OBJECT); 117 Cancel(); 118 } 119 break; 120 121 case SID_CHAR_DLG_EFFECT: 122 case SID_CHAR_DLG: // BASIC 123 { 124 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 125 Cancel(); 126 } 127 break; 128 129 case SID_PARA_DLG: 130 { 131 SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 132 Cancel(); 133 } 134 break; 135 case FN_NUM_BULLET_ON: 136 { 137 // The value (sal_uInt16)0xFFFF means set bullet on/off. 138 SfxUInt16Item aItem(FN_SVX_SET_BULLET, (sal_uInt16)0xFFFF); 139 GetViewFrame()->GetDispatcher()->Execute( FN_SVX_SET_BULLET, SFX_CALLMODE_RECORD, &aItem, 0L ); 140 } 141 break; 142 case FN_NUM_NUMBERING_ON: 143 { 144 // The value (sal_uInt16)0xFFFF means set bullet on/off. 145 SfxUInt16Item aItem(FN_SVX_SET_NUMBER, (sal_uInt16)0xFFFF); 146 GetViewFrame()->GetDispatcher()->Execute( FN_SVX_SET_NUMBER, SFX_CALLMODE_RECORD, &aItem, 0L ); 147 } 148 break; 149 150 case SID_OUTLINE_BULLET: 151 case FN_SVX_SET_BULLET: 152 case FN_SVX_SET_NUMBER: 153 { 154 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 155 Cancel(); 156 } 157 break; 158 159 case FN_INSERT_SOFT_HYPHEN: 160 case FN_INSERT_HARDHYPHEN: 161 case FN_INSERT_HARD_SPACE: 162 case SID_INSERT_RLM : 163 case SID_INSERT_LRM : 164 case SID_INSERT_ZWNBSP : 165 case SID_INSERT_ZWSP: 166 case SID_CHARMAP: 167 { 168 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 169 Cancel(); 170 } 171 break; 172 173 case SID_PRESENTATION_LAYOUT: 174 { 175 SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) ); 176 Cancel(); 177 } 178 break; 179 180 case SID_PASTE_SPECIAL: 181 { 182 SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 183 Cancel(); 184 rReq.Ignore (); 185 } 186 break; 187 188 case SID_INSERT_GRAPHIC: 189 { 190 SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 191 Cancel(); 192 rReq.Ignore (); 193 Invalidate(SID_DRAWTBX_INSERT); 194 } 195 break; 196 197 case SID_INSERT_AVMEDIA: 198 { 199 SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 200 201 Cancel(); 202 rReq.Ignore (); 203 204 Invalidate(SID_DRAWTBX_INSERT); 205 } 206 break; 207 208 case SID_INSERT_OBJECT: 209 case SID_INSERT_PLUGIN: 210 case SID_INSERT_SOUND: 211 case SID_INSERT_VIDEO: 212 case SID_INSERT_FLOATINGFRAME: 213 case SID_INSERT_MATH: 214 case SID_INSERT_DIAGRAM: 215 case SID_ATTR_TABLE: 216 { 217 SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 218 219 Cancel(); 220 rReq.Ignore (); 221 222 Invalidate(SID_DRAWTBX_INSERT); 223 } 224 break; 225 226 case SID_COPYOBJECTS: 227 { 228 if ( mpDrawView->IsPresObjSelected(sal_False, sal_True) ) 229 { 230 ::sd::Window* pWindow = GetActiveWindow(); 231 InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute(); 232 } 233 else 234 { 235 if ( mpDrawView->IsTextEdit() ) 236 { 237 mpDrawView->SdrEndTextEdit(); 238 } 239 240 SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 241 } 242 Cancel(); 243 rReq.Ignore (); 244 } 245 break; 246 247 case SID_INSERTFILE: // BASIC 248 { 249 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); 250 SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 251 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); 252 Cancel(); 253 rReq.Done (); 254 255 Invalidate(SID_DRAWTBX_INSERT); 256 } 257 break; 258 259 case SID_SELECT_BACKGROUND: 260 case SID_PAGESETUP: // BASIC ?? 261 { 262 SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 263 Cancel(); 264 rReq.Ignore (); // es werden eigenstaendige macros generiert !! 265 } 266 break; 267 268 case SID_ZOOM_OUT: 269 case SID_ZOOM_PANNING: 270 { 271 mbZoomOnPage = sal_False; 272 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) ); 273 // Beendet sich selbst, kein Cancel() notwendig! 274 Invalidate( SID_ZOOM_TOOLBOX ); 275 rReq.Ignore (); 276 } 277 break; 278 279 case SID_BEFORE_OBJ: 280 case SID_BEHIND_OBJ: 281 { 282 SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) ); 283 Invalidate( SID_POSITION ); 284 rReq.Ignore (); 285 // Beendet sich selbst, kein Cancel() notwendig! 286 } 287 break; 288 289 case SID_REVERSE_ORDER: // BASIC 290 { 291 mpDrawView->ReverseOrderOfMarked(); 292 Invalidate( SID_POSITION ); 293 Cancel(); 294 rReq.Done (); 295 } 296 break; 297 298 case SID_ANIMATION_EFFECTS: 299 { 300 SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) ); 301 Cancel(); 302 } 303 break; 304 305 case SID_LINEEND_POLYGON: 306 { 307 SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 308 Cancel(); 309 } 310 break; 311 312 case SID_CAPTUREPOINT: 313 // negative Werte um Aufruf aus Menue zu signalisieren 314 maMousePos = Point(-1,-1); 315 case SID_SET_SNAPITEM: 316 { 317 SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) ); 318 Cancel(); 319 } 320 break; 321 322 case SID_MANAGE_LINKS: 323 { 324 SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 325 Cancel(); 326 rReq.Ignore (); 327 } 328 break; 329 330 case SID_THESAURUS: 331 { 332 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 333 Cancel(); 334 rReq.Ignore (); 335 } 336 break; 337 338 case SID_TEXTATTR_DLG: 339 { 340 SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 341 Cancel(); 342 rReq.Ignore (); 343 } 344 break; 345 346 case SID_MEASURE_DLG: 347 { 348 SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 349 Cancel(); 350 rReq.Ignore (); 351 } 352 break; 353 354 case SID_CONNECTION_DLG: 355 { 356 SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 357 Cancel(); 358 rReq.Done(); 359 } 360 break; 361 362 case SID_CONNECTION_NEW_ROUTING: 363 { 364 SfxItemSet aDefAttr( GetPool(), SDRATTR_EDGELINE1DELTA, SDRATTR_EDGELINE3DELTA ); 365 GetView()->SetAttributes( aDefAttr, sal_True ); // (ReplaceAll) 366 367 Cancel(); 368 rReq.Done(); 369 } 370 break; 371 372 case SID_TWAIN_SELECT: 373 { 374 sal_Bool bDone = sal_False; 375 376 if( mxScannerManager.is() ) 377 { 378 try 379 { 380 const ::com::sun::star::uno::Sequence< ::com::sun::star::scanner::ScannerContext > 381 aContexts( mxScannerManager->getAvailableScanners() ); 382 383 if( aContexts.getLength() ) 384 { 385 ::com::sun::star::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] ); 386 bDone = mxScannerManager->configureScanner( aContext ); 387 } 388 } 389 catch(...) 390 { 391 } 392 } 393 394 Cancel(); 395 rReq.Done(); 396 } 397 break; 398 399 case SID_TWAIN_TRANSFER: 400 { 401 sal_Bool bDone = sal_False; 402 403 if( mxScannerManager.is() ) 404 { 405 try 406 { 407 const ::com::sun::star::uno::Sequence< ::com::sun::star::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() ); 408 409 if( aContexts.getLength() ) 410 { 411 mxScannerManager->startScan( aContexts.getConstArray()[ 0 ], mxScannerListener ); 412 bDone = sal_True; 413 } 414 } 415 catch( ... ) 416 { 417 } 418 } 419 420 if( !bDone ) 421 { 422 #ifndef UNX 423 const sal_uInt16 nId = STR_TWAIN_NO_SOURCE; 424 #else 425 const sal_uInt16 nId = STR_TWAIN_NO_SOURCE_UNX; 426 #endif 427 428 ::sd::Window* pWindow = GetActiveWindow(); 429 InfoBox(pWindow, String( SdResId( nId ) ) ).Execute(); 430 } 431 else 432 { 433 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 434 rBindings.Invalidate( SID_TWAIN_SELECT ); 435 rBindings.Invalidate( SID_TWAIN_TRANSFER ); 436 } 437 438 Cancel(); 439 rReq.Done(); 440 } 441 break; 442 443 case SID_POLYGON_MORPHING: 444 { 445 SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 446 Cancel(); 447 } 448 break; 449 450 case SID_VECTORIZE: 451 { 452 SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); 453 Cancel(); 454 } 455 break; 456 457 default: 458 { 459 // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die 460 // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8), 461 // FuTemp02 (drviewsb) gewandert. 462 FuTemp02(rReq); 463 } 464 break; 465 } 466 } 467 468 /************************************************************************* 469 |* 470 |* Scanner-Event 471 |* 472 \************************************************************************/ 473 474 void DrawViewShell::ScannerEvent( const ::com::sun::star::lang::EventObject& ) 475 { 476 if( mxScannerManager.is() ) 477 { 478 const ::com::sun::star::scanner::ScannerContext aContext( mxScannerManager->getAvailableScanners().getConstArray()[ 0 ] ); 479 const ::com::sun::star::scanner::ScanError eError = mxScannerManager->getError( aContext ); 480 481 if( ::com::sun::star::scanner::ScanError_ScanErrorNone == eError ) 482 { 483 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBitmap( mxScannerManager->getBitmap( aContext ) ); 484 485 if( xBitmap.is() ) 486 { 487 const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) ); 488 489 if( !!aScanBmp ) 490 { 491 const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 492 SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage(); 493 Size aBmpSize( aScanBmp.GetPrefSize() ), aPageSize( pPage->GetSize() ); 494 const MapMode aMap100( MAP_100TH_MM ); 495 496 if( !aBmpSize.Width() || !aBmpSize.Height() ) 497 aBmpSize = aScanBmp.GetSizePixel(); 498 499 if( aScanBmp.GetPrefMapMode().GetMapUnit() == MAP_PIXEL ) 500 aBmpSize = GetActiveWindow()->PixelToLogic( aBmpSize, aMap100 ); 501 else 502 aBmpSize = OutputDevice::LogicToLogic( aBmpSize, aScanBmp.GetPrefMapMode(), aMap100 ); 503 504 aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder(); 505 aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder(); 506 507 if( ( ( aBmpSize.Height() > aPageSize.Height() ) || ( aBmpSize.Width() > aPageSize.Width() ) ) && aBmpSize.Height() && aPageSize.Height() ) 508 { 509 double fGrfWH = (double) aBmpSize.Width() / aBmpSize.Height(); 510 double fWinWH = (double) aPageSize.Width() / aPageSize.Height(); 511 512 if( fGrfWH < fWinWH ) 513 { 514 aBmpSize.Width() = FRound( aPageSize.Height() * fGrfWH ); 515 aBmpSize.Height()= aPageSize.Height(); 516 } 517 else if( fGrfWH > 0.F ) 518 { 519 aBmpSize.Width() = aPageSize.Width(); 520 aBmpSize.Height()= FRound( aPageSize.Width() / fGrfWH ); 521 } 522 } 523 524 Point aPnt ( ( aPageSize.Width() - aBmpSize.Width() ) >> 1, ( aPageSize.Height() - aBmpSize.Height() ) >> 1 ); 525 aPnt += Point( pPage->GetLftBorder(), pPage->GetUppBorder() ); 526 Rectangle aRect( aPnt, aBmpSize ); 527 SdrGrafObj* pGrafObj = NULL; 528 sal_Bool bInsertNewObject = sal_True; 529 530 if( GetView()->AreObjectsMarked() ) 531 { 532 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 533 534 if( rMarkList.GetMarkCount() == 1 ) 535 { 536 SdrMark* pMark = rMarkList.GetMark(0); 537 SdrObject* pObj = pMark->GetMarkedSdrObj(); 538 539 if( pObj->ISA( SdrGrafObj ) ) 540 { 541 pGrafObj = static_cast< SdrGrafObj* >( pObj ); 542 543 if( pGrafObj->IsEmptyPresObj() ) 544 { 545 bInsertNewObject = sal_False; 546 pGrafObj->SetEmptyPresObj(sal_False); 547 pGrafObj->SetOutlinerParaObject(NULL); 548 pGrafObj->SetGraphic( Graphic( aScanBmp ) ); 549 } 550 } 551 } 552 } 553 554 if( bInsertNewObject ) 555 { 556 pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect ); 557 SdrPageView* pPV = GetView()->GetSdrPageView(); 558 GetView()->InsertObjectAtView( pGrafObj, *pPV, SDRINSERT_SETDEFLAYER ); 559 } 560 } 561 } 562 } 563 } 564 565 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 566 rBindings.Invalidate( SID_TWAIN_SELECT ); 567 rBindings.Invalidate( SID_TWAIN_TRANSFER ); 568 } 569 570 } // end of namespace sd 571