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 <com/sun/star/drawing/XDrawPagesSupplier.hpp> 28 29 #include "DrawViewShell.hxx" 30 #include <vcl/msgbox.hxx> 31 #include <svl/urlbmk.hxx> 32 #include <svx/svdpagv.hxx> 33 #include <svx/svdundo.hxx> 34 #include <svx/fmglob.hxx> 35 #include <editeng/eeitem.hxx> 36 #ifndef _FLDITEM_HXX 37 #include <editeng/flditem.hxx> 38 #endif 39 #ifndef _SVXIDS_HRC 40 #include <svx/svxids.hrc> 41 #endif 42 #include <svx/ruler.hxx> 43 #ifndef _GLOBL3D_HXX 44 #include <svx/globl3d.hxx> 45 #endif 46 #include <editeng/outliner.hxx> 47 #ifndef _SFX_CLIENTSH_HXX 48 #include <sfx2/ipclient.hxx> 49 #endif 50 #include <sfx2/request.hxx> 51 #include <sfx2/dispatch.hxx> 52 #include <svx/svdopath.hxx> 53 #include <sfx2/viewfrm.hxx> 54 #include <editeng/editview.hxx> 55 #include <vcl/cursor.hxx> 56 57 58 #include "app.hrc" 59 #include "glob.hrc" 60 #include "strings.hrc" 61 #include "res_bmp.hrc" 62 #include "DrawDocShell.hxx" 63 #include "drawdoc.hxx" 64 #include "Window.hxx" 65 #include "fupoor.hxx" 66 #include "fusnapln.hxx" 67 #include "app.hxx" 68 #include "Ruler.hxx" 69 #include "sdresid.hxx" 70 #include "GraphicViewShell.hxx" 71 #include "sdpage.hxx" 72 #include "slideshow.hxx" 73 #include "anminfo.hxx" 74 #include "sdpopup.hxx" 75 #include "drawview.hxx" 76 #include <svx/bmpmask.hxx> 77 #include "LayerTabBar.hxx" 78 79 // #97016# IV 80 #include <svx/svditer.hxx> 81 82 namespace sd { 83 84 #define PIPETTE_RANGE 0 85 86 #ifdef _MSC_VER 87 #pragma optimize ( "", off ) 88 #endif 89 90 using namespace ::com::sun::star::uno; 91 using namespace ::com::sun::star::drawing; 92 93 /************************************************************************* 94 |* 95 |* aktuelle Seite loeschen 96 |* 97 \************************************************************************/ 98 99 void DrawViewShell::DeleteActualPage() 100 { 101 sal_uInt16 nPage = maTabControl.GetCurPageId() - 1; 102 103 mpDrawView->SdrEndTextEdit(); 104 105 try 106 { 107 Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW ); 108 Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 109 Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW ); 110 xPages->remove( xPage ); 111 } 112 catch( Exception& ) 113 { 114 DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!"); 115 } 116 } 117 118 /************************************************************************* 119 |* 120 |* aktuelle Ebene loeschen 121 |* 122 \************************************************************************/ 123 124 void DrawViewShell::DeleteActualLayer() 125 { 126 SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin(); 127 const String& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId()); 128 String aString(SdResId(STR_ASK_DELETE_LAYER)); 129 130 // Platzhalter ersetzen 131 sal_uInt16 nPos = aString.Search(sal_Unicode('$')); 132 aString.Erase(nPos, 1); 133 aString.Insert(rName, nPos); 134 135 if (QueryBox(GetActiveWindow(), WB_YES_NO, aString).Execute() == RET_YES) 136 { 137 const SdrLayer* pLayer = rAdmin.GetLayer(rName, sal_False); 138 mpDrawView->DeleteLayer( pLayer->GetName() ); 139 140 // damit TabBar und Window neu gezeichnet werden; 141 // sollte spaeter wie beim Aendern der Layerfolge durch einen 142 // Hint von Joe angestossen werden 143 // ( View::Notify() --> ViewShell::ResetActualLayer() ) 144 145 mbIsLayerModeActive = false; // damit ChangeEditMode() ueberhaupt was tut 146 ChangeEditMode(GetEditMode(), true); 147 } 148 } 149 150 151 /************************************************************************* 152 |* 153 |* Keyboard event 154 |* 155 \************************************************************************/ 156 157 sal_Bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin) 158 { 159 sal_Bool bRet = sal_False; 160 161 if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) ) 162 { 163 // #97016# IV 164 if(KEY_RETURN == rKEvt.GetKeyCode().GetCode() 165 && rKEvt.GetKeyCode().IsMod1() 166 && GetView()->IsTextEdit()) 167 { 168 // this should be used for cursor travelling. 169 SdPage* pActualPage = GetActualPage(); 170 const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList(); 171 SdrTextObj* pCandidate = 0L; 172 173 if(pActualPage && 1 == rMarkList.GetMarkCount()) 174 { 175 SdrMark* pMark = rMarkList.GetMark(0); 176 177 // remember which object was the text in edit mode 178 SdrObject* pOldObj = pMark->GetMarkedSdrObj(); 179 180 // end text edit now 181 GetView()->SdrEndTextEdit(); 182 183 // look for a new candidate, a successor of pOldObj 184 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS); 185 sal_Bool bDidVisitOldObject(sal_False); 186 187 while(aIter.IsMore() && !pCandidate) 188 { 189 SdrObject* pObj = aIter.Next(); 190 191 if(pObj && pObj->ISA(SdrTextObj)) 192 { 193 sal_uInt32 nInv(pObj->GetObjInventor()); 194 sal_uInt16 nKnd(pObj->GetObjIdentifier()); 195 196 if(SdrInventor == nInv && 197 (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd) 198 && bDidVisitOldObject) 199 { 200 pCandidate = (SdrTextObj*)pObj; 201 } 202 203 if(pObj == pOldObj) 204 { 205 bDidVisitOldObject = sal_True; 206 } 207 } 208 } 209 } 210 211 if(pCandidate) 212 { 213 // set the new candidate to text edit mode 214 GetView()->UnMarkAll(); 215 GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView()); 216 217 GetViewFrame()->GetDispatcher()->Execute( 218 SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON); 219 } 220 else 221 { 222 // insert a new page with the same page layout 223 GetViewFrame()->GetDispatcher()->Execute( 224 SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON); 225 } 226 } 227 else 228 { 229 bRet = ViewShell::KeyInput(rKEvt, pWin); 230 } 231 } 232 233 return bRet; 234 } 235 236 /************************************************************************* 237 |* 238 |* Vom Lineal ausgehenden Drag (Hilflinien, Ursprung) beginnen 239 |* 240 \************************************************************************/ 241 242 void DrawViewShell::StartRulerDrag ( 243 const Ruler& rRuler, 244 const MouseEvent& rMEvt) 245 { 246 GetActiveWindow()->CaptureMouse(); 247 248 Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel()); 249 250 if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) ) 251 { 252 mpDrawView->BegSetPageOrg(aWPos); 253 mbIsRulerDrag = sal_True; 254 } 255 else 256 { 257 // #i34536# if no guide-lines are visible yet, that show them 258 if( ! mpDrawView->IsHlplVisible()) 259 mpDrawView->SetHlplVisible( sal_True ); 260 261 SdrHelpLineKind eKind; 262 263 if ( rMEvt.IsMod1() ) 264 eKind = SDRHELPLINE_POINT; 265 else if ( rRuler.IsHorizontal() ) 266 eKind = SDRHELPLINE_HORIZONTAL; 267 else 268 eKind = SDRHELPLINE_VERTICAL; 269 270 mpDrawView->BegDragHelpLine(aWPos, eKind); 271 mbIsRulerDrag = sal_True; 272 } 273 } 274 275 /************************************************************************* 276 |* 277 |* MouseButtonDown event 278 |* 279 \************************************************************************/ 280 281 void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt, 282 ::sd::Window* pWin) 283 { 284 // We have to check if a context menu is shown and we have an UI 285 // active inplace client. In that case we have to ignore the mouse 286 // button down event. Otherwise we would crash (context menu has been 287 // opened by inplace client and we would deactivate the inplace client, 288 // the contex menu is closed by VCL asynchronously which in the end 289 // would work on deleted objects or the context menu has no parent anymore) 290 // See #126086# and #128122# 291 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient(); 292 sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() ); 293 294 if ( bIsOleActive && PopupMenu::IsInExecute() ) 295 return; 296 297 if ( !IsInputLocked() ) 298 { 299 ViewShell::MouseButtonDown(rMEvt, pWin); 300 301 if ( mbPipette ) 302 ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->PipetteClicked(); 303 } 304 } 305 306 /************************************************************************* 307 |* 308 |* MouseMove event 309 |* 310 \************************************************************************/ 311 312 313 void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) 314 { 315 if ( !IsInputLocked() ) 316 { 317 if ( mpDrawView->IsAction() ) 318 { 319 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel()); 320 321 if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) ) 322 { 323 sal_Bool bInsideOtherWindow = sal_False; 324 325 if (mpContentWindow.get() != NULL) 326 { 327 aOutputArea = Rectangle(Point(0,0), 328 mpContentWindow->GetOutputSizePixel()); 329 330 Point aPos = mpContentWindow->GetPointerPosPixel(); 331 if ( aOutputArea.IsInside(aPos) ) 332 bInsideOtherWindow = sal_True; 333 } 334 335 if (! GetActiveWindow()->HasFocus ()) 336 { 337 GetActiveWindow()->ReleaseMouse (); 338 mpDrawView->BrkAction (); 339 return; 340 } 341 else if ( bInsideOtherWindow ) 342 { 343 GetActiveWindow()->ReleaseMouse(); 344 pWin->CaptureMouse (); 345 } 346 } 347 else if ( pWin != GetActiveWindow() ) 348 pWin->CaptureMouse(); 349 } 350 351 // #109585# 352 // Since the next MouseMove may execute a IsSolidDraggingNow() in 353 // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor 354 // is needed it is necessary to set it here. 355 if(mpDrawView!=NULL && GetDoc()!=NULL) 356 { 357 svtools::ColorConfig aColorConfig; 358 Color aFillColor; 359 360 if(DOCUMENT_TYPE_IMPRESS == GetDoc()->GetDocumentType()) 361 { 362 aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor ); 363 } 364 else 365 { 366 aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor ); 367 } 368 369 mpDrawView->SetApplicationBackgroundColor(aFillColor); 370 } 371 372 ViewShell::MouseMove(rMEvt, pWin); 373 374 if( !mbMousePosFreezed ) 375 maMousePos = rMEvt.GetPosPixel(); 376 377 Rectangle aRect; 378 379 if ( mbIsRulerDrag ) 380 { 381 Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos); 382 mpDrawView->MovAction(aLogPos); 383 } 384 385 if ( mpDrawView->IsAction() ) 386 { 387 mpDrawView->TakeActionRect(aRect); 388 aRect = GetActiveWindow()->LogicToPixel(aRect); 389 } 390 else 391 { 392 aRect = Rectangle(maMousePos, maMousePos); 393 } 394 395 ShowMousePosInfo(aRect, pWin); 396 397 if ( mbPipette && GetViewFrame()->HasChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ) ) 398 { 399 const long nStartX = maMousePos.X() - PIPETTE_RANGE; 400 const long nEndX = maMousePos.X() + PIPETTE_RANGE; 401 const long nStartY = maMousePos.Y() - PIPETTE_RANGE; 402 const long nEndY = maMousePos.Y() + PIPETTE_RANGE; 403 long nRed = 0; 404 long nGreen = 0; 405 long nBlue = 0; 406 const double fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 ); 407 408 for ( long nY = nStartY; nY <= nEndY; nY++ ) 409 { 410 for( long nX = nStartX; nX <= nEndX; nX++ ) 411 { 412 const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) ); 413 414 nRed += aCol.GetRed(); 415 nGreen += aCol.GetGreen(); 416 nBlue += aCol.GetBlue(); 417 } 418 } 419 420 ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )-> 421 SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ), 422 (sal_uInt8) ( nGreen / fDiv + .5 ), 423 (sal_uInt8) ( nBlue / fDiv + .5 ) ) ); 424 } 425 } 426 } 427 428 429 /************************************************************************* 430 |* 431 |* MouseButtonUp event 432 |* 433 \************************************************************************/ 434 435 void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) 436 { 437 if ( !IsInputLocked() ) 438 { 439 FASTBOOL bIsSetPageOrg = mpDrawView->IsSetPageOrg(); 440 441 if (mbIsRulerDrag) 442 { 443 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel()); 444 445 if (aOutputArea.IsInside(rMEvt.GetPosPixel())) 446 { 447 mpDrawView->EndAction(); 448 449 if (bIsSetPageOrg) 450 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET); 451 } 452 else if (rMEvt.IsLeft() && bIsSetPageOrg) 453 { 454 mpDrawView->BrkAction(); 455 SdPage* pPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage(); 456 Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder()); 457 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg); 458 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET); 459 } 460 else 461 { 462 mpDrawView->BrkAction(); 463 } 464 465 GetActiveWindow()->ReleaseMouse(); 466 mbIsRulerDrag = sal_False; 467 } 468 else 469 ViewShell::MouseButtonUp(rMEvt, pWin); 470 } 471 } 472 473 /************************************************************************* 474 |* 475 |* Command event 476 |* 477 \************************************************************************/ 478 479 void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) 480 { 481 // The command event is send to the window after a possible context 482 // menu from an inplace client is closed. Now we have the chance to 483 // deactivate the inplace client without any problem regarding parent 484 // windows and code on the stack. 485 // For more information, see #126086# and #128122# 486 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient(); 487 sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() ); 488 if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )) 489 { 490 // Deactivate OLE object 491 mpDrawView->UnmarkAll(); 492 SelectionHasChanged(); 493 return; 494 } 495 496 if ( !IsInputLocked() ) 497 { 498 if( GetView() &&GetView()->getSmartTags().Command(rCEvt) ) 499 return; 500 501 const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase())); 502 503 if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow ) 504 { 505 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) ); 506 507 if( aDataHelper.GetTransferable().is() ) 508 { 509 Point aPos; 510 sal_Int8 nDnDAction = DND_ACTION_COPY; 511 512 if( GetActiveWindow() ) 513 aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() ); 514 515 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, sal_False ) ) 516 { 517 INetBookmark aINetBookmark( aEmptyStr, aEmptyStr ); 518 519 if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) && 520 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) || 521 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) && 522 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) || 523 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) && 524 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) 525 { 526 InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL ); 527 } 528 } 529 } 530 } 531 else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow && 532 pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() ) 533 { 534 sal_uInt16 nSdResId = 0; // ResourceID fuer Popup-Menue 535 sal_Bool bGraphicShell = this->ISA(GraphicViewShell); 536 537 // Ist ein Fangobjekt unter dem Mauszeiger? 538 SdrPageView* pPV; 539 Point aMPos = pWin->PixelToLogic( maMousePos ); 540 sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic( 541 Size(FuPoor::HITPIX, 0 ) ).Width(); 542 sal_uInt16 nHelpLine; 543 // fuer Klebepunkt 544 SdrObject* pObj = NULL; 545 sal_uInt16 nPickId = 0; 546 // fuer Feldbefehl 547 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView(); 548 const SvxFieldItem* pFldItem = NULL; 549 if( pOLV ) 550 pFldItem = pOLV->GetFieldAtSelection(); 551 //pFldItem = pOLV->GetFieldUnderMousePointer(); 552 553 // Hilfslinie 554 if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) ) 555 { 556 nSdResId = RID_DRAW_SNAPOBJECT_POPUP; 557 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel()); 558 return; 559 } 560 // Klebepunkt unter dem Mauszeiger markiert? 561 else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) && 562 mpDrawView->IsGluePointMarked( pObj, nPickId ) ) 563 { 564 nSdResId = RID_DRAW_GLUEPOINT_POPUP; 565 } 566 // Feldbefehl ? 567 else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) || 568 pFldItem->GetField()->ISA( SvxExtTimeField ) || 569 pFldItem->GetField()->ISA( SvxExtFileField ) || 570 pFldItem->GetField()->ISA( SvxAuthorField ) ) ) 571 { 572 LanguageType eLanguage( LANGUAGE_SYSTEM ); 573 574 // #101743# Format popup with outliner language, if possible 575 if( pOLV->GetOutliner() ) 576 { 577 ESelection aSelection( pOLV->GetSelection() ); 578 eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos ); 579 } 580 581 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage ); 582 583 if ( rCEvt.IsMouseEvent() ) 584 aMPos = rCEvt.GetMousePosPixel(); 585 else 586 aMPos = Point( 20, 20 ); 587 aFieldPopup.Execute( pWin, aMPos ); 588 589 SvxFieldData* pField = aFieldPopup.GetField(); 590 if( pField ) 591 { 592 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); 593 //pOLV->DeleteSelected(); <-- fehlt leider ! 594 // Feld selektieren, so dass es beim Insert geloescht wird 595 ESelection aSel = pOLV->GetSelection(); 596 sal_Bool bSel = sal_True; 597 if( aSel.nStartPos == aSel.nEndPos ) 598 { 599 bSel = sal_False; 600 aSel.nEndPos++; 601 } 602 pOLV->SetSelection( aSel ); 603 604 pOLV->InsertField( aFieldItem ); 605 606 // Selektion wird wieder in den Ursprungszustand gebracht 607 if( !bSel ) 608 aSel.nEndPos--; 609 pOLV->SetSelection( aSel ); 610 611 delete pField; 612 } 613 } 614 else 615 { 616 // ist etwas selektiert? 617 if (mpDrawView->AreObjectsMarked() && 618 mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 ) 619 { 620 pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); 621 if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) ) 622 { 623 nSdResId = RID_BEZIER_POPUP; 624 } 625 else 626 { 627 if( mpDrawView->GetTextEditObject() ) 628 { 629 OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView(); 630 Point aPos(rCEvt.GetMousePosPixel()); 631 632 if ( pOutlinerView ) 633 { 634 if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) || 635 ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) ) 636 { 637 // #91457# Popup for Online-Spelling now handled by DrawDocShell 638 // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback); 639 Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback); 640 641 if( !rCEvt.IsMouseEvent() ) 642 { 643 aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() ); 644 } 645 // While showing the spell context menu 646 // we lock the input so that another 647 // context menu can not be opened during 648 // that time (crash #i43235#). In order 649 // to not lock the UI completely we 650 // first release the mouse. 651 GetActiveWindow()->ReleaseMouse(); 652 LockInput(); 653 pOutlinerView->ExecuteSpellPopup(aPos, &aLink); 654 UnlockInput(); 655 } 656 else 657 { 658 if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) ) 659 { 660 nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP; 661 } 662 else 663 { 664 nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP; 665 } 666 } 667 } 668 } 669 else 670 { 671 sal_uInt32 nInv = pObj->GetObjInventor(); 672 sal_uInt16 nId = pObj->GetObjIdentifier(); 673 674 if (nInv == SdrInventor) 675 { 676 switch ( nId ) 677 { 678 case OBJ_CAPTION: 679 case OBJ_TITLETEXT: 680 case OBJ_OUTLINETEXT: 681 case OBJ_TEXT: 682 nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP : 683 RID_DRAW_TEXTOBJ_POPUP; 684 break; 685 686 case OBJ_PATHLINE: 687 case OBJ_PLIN: 688 nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP : 689 RID_DRAW_POLYLINEOBJ_POPUP; 690 break; 691 692 case OBJ_FREELINE: 693 case OBJ_EDGE: // Connector 694 nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP : 695 RID_DRAW_EDGEOBJ_POPUP; 696 break; 697 698 case OBJ_LINE: 699 nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP : 700 RID_DRAW_LINEOBJ_POPUP; 701 break; 702 703 case OBJ_MEASURE: 704 nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP : 705 RID_DRAW_MEASUREOBJ_POPUP; 706 break; 707 708 case OBJ_RECT: 709 case OBJ_CIRC: 710 case OBJ_FREEFILL: 711 case OBJ_PATHFILL: 712 case OBJ_POLY: 713 case OBJ_SECT: 714 case OBJ_CARC: 715 case OBJ_CCUT: 716 nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP : 717 RID_DRAW_GEOMOBJ_POPUP; 718 break; 719 720 case OBJ_CUSTOMSHAPE: 721 nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP : 722 RID_DRAW_CUSTOMSHAPE_POPUP; 723 break; 724 725 case OBJ_GRUP: 726 nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP : 727 RID_DRAW_GROUPOBJ_POPUP; 728 break; 729 730 case OBJ_GRAF: 731 nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP : 732 RID_DRAW_GRAPHIC_POPUP; 733 break; 734 735 case OBJ_OLE2: 736 nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP : 737 RID_DRAW_OLE2_POPUP; 738 break; 739 case OBJ_MEDIA: 740 nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP : 741 RID_DRAW_MEDIA_POPUP; 742 break; 743 case OBJ_TABLE: 744 nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP : 745 RID_DRAW_TABLE_POPUP; 746 break; 747 } 748 } 749 else if( nInv == E3dInventor /*&& nId == E3D_POLYSCENE_ID*/) 750 { 751 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID ) 752 { 753 if( !mpDrawView->IsGroupEntered() ) 754 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP : 755 RID_DRAW_3DSCENE_POPUP; 756 else 757 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP : 758 RID_DRAW_3DSCENE2_POPUP; 759 } 760 else 761 nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP : 762 RID_DRAW_3DOBJ_POPUP; 763 } 764 else if( nInv == FmFormInventor ) 765 { 766 nSdResId = RID_FORM_CONTROL_POPUP; 767 } 768 } 769 } 770 } 771 772 // Mehrfachselektion 773 else if (mpDrawView->AreObjectsMarked() && 774 mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 ) 775 { 776 nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP : 777 RID_DRAW_MULTISELECTION_POPUP; 778 } 779 780 // nichts selektiert 781 else 782 { 783 nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP : 784 RID_DRAW_NOSEL_POPUP; 785 } 786 } 787 // Popup-Menue anzeigen 788 if (nSdResId) 789 { 790 GetActiveWindow()->ReleaseMouse(); 791 792 if(rCEvt.IsMouseEvent()) 793 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId)); 794 else 795 { 796 //#106326# don't open contextmenu at mouse position if not opened via mouse 797 798 //middle of the window if nothing is marked 799 Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2 800 ,GetActiveWindow()->GetSizePixel().Height()/2); 801 802 //middle of the bounding rect if something is marked 803 if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 ) 804 { 805 Rectangle aMarkRect; 806 mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect); 807 aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() ); 808 809 //move the point into the visible window area 810 if( aMenuPos.X() < 0 ) 811 aMenuPos.X() = 0; 812 if( aMenuPos.Y() < 0 ) 813 aMenuPos.Y() = 0; 814 if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() ) 815 aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width(); 816 if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() ) 817 aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height(); 818 } 819 820 //open context menu at that point 821 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos); 822 } 823 mbMousePosFreezed = sal_False; 824 } 825 } 826 else 827 { 828 ViewShell::Command(rCEvt, pWin); 829 } 830 } 831 } 832 833 /************************************************************************* 834 |* 835 |* Linealmarkierungen anzeigen 836 |* 837 \************************************************************************/ 838 839 void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect, 840 ::sd::Window* pWin) 841 { 842 if (mbHasRulers && pWin ) 843 { 844 RulerLine pHLines[2]; 845 RulerLine pVLines[2]; 846 long nHOffs = 0L; 847 long nVOffs = 0L; 848 sal_uInt16 nCnt; 849 850 if (mpHorizontalRuler.get() != NULL) 851 mpHorizontalRuler->SetLines(); 852 853 if (mpVerticalRuler.get() != NULL) 854 mpVerticalRuler->SetLines(); 855 856 if (mpHorizontalRuler.get() != NULL) 857 { 858 nHOffs = mpHorizontalRuler->GetNullOffset() + 859 mpHorizontalRuler->GetPageOffset(); 860 } 861 862 if (mpVerticalRuler.get() != NULL) 863 { 864 nVOffs = mpVerticalRuler->GetNullOffset() + 865 mpVerticalRuler->GetPageOffset(); 866 } 867 868 nCnt = 1; 869 pHLines[0].nPos = rRect.Left() - nHOffs; 870 pVLines[0].nPos = rRect.Top() - nVOffs; 871 pHLines[0].nStyle = 0; 872 pVLines[0].nStyle = 0; 873 874 if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() ) 875 { 876 pHLines[1].nPos = rRect.Right() - nHOffs; 877 pVLines[1].nPos = rRect.Bottom() - nVOffs; 878 pHLines[1].nStyle = 0; 879 pVLines[1].nStyle = 0; 880 nCnt++; 881 } 882 883 if (mpHorizontalRuler.get() != NULL) 884 mpHorizontalRuler->SetLines(nCnt, pHLines); 885 if (mpVerticalRuler.get() != NULL) 886 mpVerticalRuler->SetLines(nCnt, pVLines); 887 } 888 889 // StatusBar Koordinatenanzeige 890 OSL_ASSERT (GetViewShell()!=NULL); 891 if ( !GetViewShell()->GetUIActiveClient() ) 892 { 893 SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT, 894 SID_ATTR_POSITION, SID_ATTR_POSITION, 895 SID_ATTR_SIZE, SID_ATTR_SIZE, 896 0L); 897 898 // GetStatusBarState(aSet); nicht performant bei gedrueckter Modifiertaste!! 899 900 aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) ); 901 902 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 903 rBindings.SetState(aSet); 904 rBindings.Invalidate(SID_CONTEXT); 905 rBindings.Invalidate(SID_ATTR_POSITION); 906 rBindings.Invalidate(SID_ATTR_SIZE); 907 } 908 } 909 910 /************************************************************************* 911 |* 912 |* 913 |* 914 \************************************************************************/ 915 916 void DrawViewShell::LockInput() 917 { 918 mnLockCount++; 919 } 920 921 /************************************************************************* 922 |* 923 |* 924 |* 925 \************************************************************************/ 926 927 void DrawViewShell::UnlockInput() 928 { 929 DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" ); 930 if ( mnLockCount ) 931 mnLockCount--; 932 } 933 934 935 936 937 void DrawViewShell::ShowSnapLineContextMenu ( 938 SdrPageView& rPageView, 939 const sal_uInt16 nSnapLineIndex, 940 const Point& rMouseLocation) 941 { 942 const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]); 943 ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ()); 944 945 if (rHelpLine.GetKind() == SDRHELPLINE_POINT) 946 { 947 pMenu->InsertItem( 948 SID_SET_SNAPITEM, 949 String(SdResId(STR_POPUP_EDIT_SNAPPOINT))); 950 pMenu->InsertSeparator(); 951 pMenu->InsertItem( 952 SID_DELETE_SNAPITEM, 953 String(SdResId(STR_POPUP_DELETE_SNAPPOINT))); 954 } 955 else 956 { 957 pMenu->InsertItem( 958 SID_SET_SNAPITEM, 959 String(SdResId(STR_POPUP_EDIT_SNAPLINE))); 960 pMenu->InsertSeparator(); 961 pMenu->InsertItem( 962 SID_DELETE_SNAPITEM, 963 String(SdResId(STR_POPUP_DELETE_SNAPLINE))); 964 } 965 966 pMenu->RemoveDisabledEntries(sal_False, sal_False); 967 968 const sal_uInt16 nResult = pMenu->Execute( 969 GetActiveWindow(), 970 Rectangle(rMouseLocation, Size(10,10)), 971 POPUPMENU_EXECUTE_DOWN); 972 switch (nResult) 973 { 974 case SID_SET_SNAPITEM: 975 { 976 SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex); 977 const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL}; 978 GetViewFrame()->GetDispatcher()->Execute( 979 SID_SET_SNAPITEM, 980 SFX_CALLMODE_SLOT, 981 aArguments); 982 } 983 break; 984 985 case SID_DELETE_SNAPITEM: 986 { 987 rPageView.DeleteHelpLine(nSnapLineIndex); 988 } 989 break; 990 991 default: 992 break; 993 } 994 } 995 996 997 998 999 #ifdef _MSC_VER 1000 #pragma optimize ( "", on ) 1001 #endif 1002 1003 } // end of namespace sd 1004