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