Update ooo320-m1
[ooovba.git] / sd / source / ui / view / drviews4.cxx
blob5aeae876fda7b6aea70020401bbc8e30648cd196
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviews4.cxx,v $
10 * $Revision: 1.41 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
36 #include "DrawViewShell.hxx"
37 #include <vcl/msgbox.hxx>
38 #include <svtools/urlbmk.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdundo.hxx>
41 #include <svx/fmglob.hxx>
42 #include <svx/eeitem.hxx>
43 #ifndef _FLDITEM_HXX
44 #include <svx/flditem.hxx>
45 #endif
46 #ifndef _SVXIDS_HRC
47 #include <svx/svxids.hrc>
48 #endif
49 #include <svx/ruler.hxx>
50 #ifndef _GLOBL3D_HXX
51 #include <svx/globl3d.hxx>
52 #endif
53 #include <svx/outliner.hxx>
54 #ifndef _SFX_CLIENTSH_HXX
55 #include <sfx2/ipclient.hxx>
56 #endif
57 #include <sfx2/request.hxx>
58 #include <sfx2/dispatch.hxx>
59 #include <svx/svdopath.hxx>
60 #include <sfx2/viewfrm.hxx>
61 #include <svx/editview.hxx>
62 #include <vcl/cursor.hxx>
65 #include "app.hrc"
66 #include "glob.hrc"
67 #include "strings.hrc"
68 #include "res_bmp.hrc"
69 #include "DrawDocShell.hxx"
70 #include "drawdoc.hxx"
71 #include "Window.hxx"
72 #include "fupoor.hxx"
73 #include "fusnapln.hxx"
74 #include "app.hxx"
75 #include "Ruler.hxx"
76 #include "sdresid.hxx"
77 #include "GraphicViewShell.hxx"
78 #include "sdpage.hxx"
79 #include "slideshow.hxx"
80 #include "anminfo.hxx"
81 #include "sdpopup.hxx"
82 #include "drawview.hxx"
83 #include <svx/bmpmask.hxx>
84 #include "LayerTabBar.hxx"
86 // #97016# IV
87 #include <svx/svditer.hxx>
89 namespace sd {
91 #define PIPETTE_RANGE 0
93 #ifdef _MSC_VER
94 #pragma optimize ( "", off )
95 #endif
97 using namespace ::com::sun::star::uno;
98 using namespace ::com::sun::star::drawing;
100 /*************************************************************************
102 |* aktuelle Seite loeschen
104 \************************************************************************/
106 void DrawViewShell::DeleteActualPage()
108 USHORT nPage = maTabControl.GetCurPageId() - 1;
110 mpDrawView->SdrEndTextEdit();
114 Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
115 Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
116 Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
117 xPages->remove( xPage );
119 catch( Exception& )
121 DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
125 /*************************************************************************
127 |* aktuelle Ebene loeschen
129 \************************************************************************/
131 void DrawViewShell::DeleteActualLayer()
133 SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
134 const String& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
135 String aString(SdResId(STR_ASK_DELETE_LAYER));
137 // Platzhalter ersetzen
138 USHORT nPos = aString.Search(sal_Unicode('$'));
139 aString.Erase(nPos, 1);
140 aString.Insert(rName, nPos);
142 if (QueryBox(GetActiveWindow(), WB_YES_NO, aString).Execute() == RET_YES)
144 const SdrLayer* pLayer = rAdmin.GetLayer(rName, FALSE);
145 mpDrawView->DeleteLayer( pLayer->GetName() );
147 // damit TabBar und Window neu gezeichnet werden;
148 // sollte spaeter wie beim Aendern der Layerfolge durch einen
149 // Hint von Joe angestossen werden
150 // ( View::Notify() --> ViewShell::ResetActualLayer() )
152 mbIsLayerModeActive = false; // damit ChangeEditMode() ueberhaupt was tut
153 ChangeEditMode(GetEditMode(), true);
158 /*************************************************************************
160 |* Keyboard event
162 \************************************************************************/
164 BOOL DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
166 BOOL bRet = FALSE;
168 if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
170 // #97016# IV
171 if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
172 && rKEvt.GetKeyCode().IsMod1()
173 && GetView()->IsTextEdit())
175 // this should be used for cursor travelling.
176 SdPage* pActualPage = GetActualPage();
177 const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
178 SdrTextObj* pCandidate = 0L;
180 if(pActualPage && 1 == rMarkList.GetMarkCount())
182 SdrMark* pMark = rMarkList.GetMark(0);
184 // remember which object was the text in edit mode
185 SdrObject* pOldObj = pMark->GetMarkedSdrObj();
187 // end text edit now
188 GetView()->SdrEndTextEdit();
190 // look for a new candidate, a successor of pOldObj
191 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
192 BOOL bDidVisitOldObject(FALSE);
194 while(aIter.IsMore() && !pCandidate)
196 SdrObject* pObj = aIter.Next();
198 if(pObj && pObj->ISA(SdrTextObj))
200 sal_uInt32 nInv(pObj->GetObjInventor());
201 sal_uInt16 nKnd(pObj->GetObjIdentifier());
203 if(SdrInventor == nInv &&
204 (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd)
205 && bDidVisitOldObject)
207 pCandidate = (SdrTextObj*)pObj;
210 if(pObj == pOldObj)
212 bDidVisitOldObject = TRUE;
218 if(pCandidate)
220 // set the new candidate to text edit mode
221 GetView()->UnMarkAll();
222 GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
224 GetViewFrame()->GetDispatcher()->Execute(
225 SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON);
227 else
229 // insert a new page with the same page layout
230 GetViewFrame()->GetDispatcher()->Execute(
231 SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON);
234 else
236 bRet = ViewShell::KeyInput(rKEvt, pWin);
240 return bRet;
243 /*************************************************************************
245 |* Vom Lineal ausgehenden Drag (Hilflinien, Ursprung) beginnen
247 \************************************************************************/
249 void DrawViewShell::StartRulerDrag (
250 const Ruler& rRuler,
251 const MouseEvent& rMEvt)
253 GetActiveWindow()->CaptureMouse();
255 Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
257 if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) )
259 mpDrawView->BegSetPageOrg(aWPos);
260 mbIsRulerDrag = TRUE;
262 else
264 // #i34536# if no guide-lines are visible yet, that show them
265 if( ! mpDrawView->IsHlplVisible())
266 mpDrawView->SetHlplVisible( TRUE );
268 SdrHelpLineKind eKind;
270 if ( rMEvt.IsMod1() )
271 eKind = SDRHELPLINE_POINT;
272 else if ( rRuler.IsHorizontal() )
273 eKind = SDRHELPLINE_HORIZONTAL;
274 else
275 eKind = SDRHELPLINE_VERTICAL;
277 mpDrawView->BegDragHelpLine(aWPos, eKind);
278 mbIsRulerDrag = TRUE;
282 /*************************************************************************
284 |* MouseButtonDown event
286 \************************************************************************/
288 void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt,
289 ::sd::Window* pWin)
291 // We have to check if a context menu is shown and we have an UI
292 // active inplace client. In that case we have to ignore the mouse
293 // button down event. Otherwise we would crash (context menu has been
294 // opened by inplace client and we would deactivate the inplace client,
295 // the contex menu is closed by VCL asynchronously which in the end
296 // would work on deleted objects or the context menu has no parent anymore)
297 // See #126086# and #128122#
298 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
299 BOOL bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
301 if ( bIsOleActive && PopupMenu::IsInExecute() )
302 return;
304 if ( !IsInputLocked() )
306 ViewShell::MouseButtonDown(rMEvt, pWin);
308 if ( mbPipette )
309 ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->PipetteClicked();
313 /*************************************************************************
315 |* MouseMove event
317 \************************************************************************/
320 void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
322 if ( !IsInputLocked() )
324 if ( mpDrawView->IsAction() )
326 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
328 if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
330 BOOL bInsideOtherWindow = FALSE;
332 if (mpContentWindow.get() != NULL)
334 aOutputArea = Rectangle(Point(0,0),
335 mpContentWindow->GetOutputSizePixel());
337 Point aPos = mpContentWindow->GetPointerPosPixel();
338 if ( aOutputArea.IsInside(aPos) )
339 bInsideOtherWindow = TRUE;
342 if (! GetActiveWindow()->HasFocus ())
344 GetActiveWindow()->ReleaseMouse ();
345 mpDrawView->BrkAction ();
346 return;
348 else if ( bInsideOtherWindow )
350 GetActiveWindow()->ReleaseMouse();
351 pWin->CaptureMouse ();
354 else if ( pWin != GetActiveWindow() )
355 pWin->CaptureMouse();
358 // #109585#
359 // Since the next MouseMove may execute a IsSolidDraggingNow() in
360 // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
361 // is needed it is necessary to set it here.
362 if(mpDrawView!=NULL && GetDoc()!=NULL)
364 svtools::ColorConfig aColorConfig;
365 Color aFillColor;
367 if(DOCUMENT_TYPE_IMPRESS == GetDoc()->GetDocumentType())
369 aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
371 else
373 aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
376 mpDrawView->SetApplicationBackgroundColor(aFillColor);
379 ViewShell::MouseMove(rMEvt, pWin);
381 if( !mbMousePosFreezed )
382 maMousePos = rMEvt.GetPosPixel();
384 Rectangle aRect;
386 if ( mbIsRulerDrag )
388 Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
389 mpDrawView->MovAction(aLogPos);
392 if ( mpDrawView->IsAction() )
394 mpDrawView->TakeActionRect(aRect);
395 aRect = GetActiveWindow()->LogicToPixel(aRect);
397 else
399 aRect = Rectangle(maMousePos, maMousePos);
402 ShowMousePosInfo(aRect, pWin);
404 if ( mbPipette && GetViewFrame()->HasChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ) )
406 const long nStartX = maMousePos.X() - PIPETTE_RANGE;
407 const long nEndX = maMousePos.X() + PIPETTE_RANGE;
408 const long nStartY = maMousePos.Y() - PIPETTE_RANGE;
409 const long nEndY = maMousePos.Y() + PIPETTE_RANGE;
410 long nRed = 0;
411 long nGreen = 0;
412 long nBlue = 0;
413 const double fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
415 for ( long nY = nStartY; nY <= nEndY; nY++ )
417 for( long nX = nStartX; nX <= nEndX; nX++ )
419 const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
421 nRed += aCol.GetRed();
422 nGreen += aCol.GetGreen();
423 nBlue += aCol.GetBlue();
427 ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
428 SetColor( Color( (BYTE) ( nRed / fDiv + .5 ),
429 (BYTE) ( nGreen / fDiv + .5 ),
430 (BYTE) ( nBlue / fDiv + .5 ) ) );
436 /*************************************************************************
438 |* MouseButtonUp event
440 \************************************************************************/
442 void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
444 if ( !IsInputLocked() )
446 FASTBOOL bIsSetPageOrg = mpDrawView->IsSetPageOrg();
448 if (mbIsRulerDrag)
450 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
452 if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
454 mpDrawView->EndAction();
456 if (bIsSetPageOrg)
457 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
459 else if (rMEvt.IsLeft() && bIsSetPageOrg)
461 mpDrawView->BrkAction();
462 SdPage* pPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
463 Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
464 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
465 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
467 else
469 mpDrawView->BrkAction();
472 GetActiveWindow()->ReleaseMouse();
473 mbIsRulerDrag = FALSE;
475 else
476 ViewShell::MouseButtonUp(rMEvt, pWin);
480 /*************************************************************************
482 |* Command event
484 \************************************************************************/
486 void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
488 // The command event is send to the window after a possible context
489 // menu from an inplace client is closed. Now we have the chance to
490 // deactivate the inplace client without any problem regarding parent
491 // windows and code on the stack.
492 // For more information, see #126086# and #128122#
493 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
494 BOOL bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
495 if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
497 // Deactivate OLE object
498 mpDrawView->UnmarkAll();
499 SelectionHasChanged();
500 return;
503 if ( !IsInputLocked() )
505 if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
506 return;
508 const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
510 if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow )
512 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
514 if( aDataHelper.GetTransferable().is() )
516 Point aPos;
517 sal_Int8 nDnDAction = DND_ACTION_COPY;
519 if( GetActiveWindow() )
520 aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
522 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, FALSE ) )
524 INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
526 if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
527 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
528 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
529 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
530 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
531 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
533 InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
538 else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow &&
539 pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
541 USHORT nSdResId = 0; // ResourceID fuer Popup-Menue
542 BOOL bGraphicShell = this->ISA(GraphicViewShell);
544 // Ist ein Fangobjekt unter dem Mauszeiger?
545 SdrPageView* pPV;
546 Point aMPos = pWin->PixelToLogic( maMousePos );
547 USHORT nHitLog = (USHORT) GetActiveWindow()->PixelToLogic(
548 Size(FuPoor::HITPIX, 0 ) ).Width();
549 USHORT nHelpLine;
550 // fuer Klebepunkt
551 SdrObject* pObj = NULL;
552 USHORT nPickId = 0;
553 // fuer Feldbefehl
554 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
555 const SvxFieldItem* pFldItem = NULL;
556 if( pOLV )
557 pFldItem = pOLV->GetFieldAtSelection();
558 //pFldItem = pOLV->GetFieldUnderMousePointer();
560 // Hilfslinie
561 if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
563 nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
564 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
565 return;
567 // Klebepunkt unter dem Mauszeiger markiert?
568 else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
569 mpDrawView->IsGluePointMarked( pObj, nPickId ) )
571 nSdResId = RID_DRAW_GLUEPOINT_POPUP;
573 // Feldbefehl ?
574 else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
575 pFldItem->GetField()->ISA( SvxExtTimeField ) ||
576 pFldItem->GetField()->ISA( SvxExtFileField ) ||
577 pFldItem->GetField()->ISA( SvxAuthorField ) ) )
579 LanguageType eLanguage( LANGUAGE_SYSTEM );
581 // #101743# Format popup with outliner language, if possible
582 if( pOLV->GetOutliner() )
584 ESelection aSelection( pOLV->GetSelection() );
585 eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
588 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
590 if ( rCEvt.IsMouseEvent() )
591 aMPos = rCEvt.GetMousePosPixel();
592 else
593 aMPos = Point( 20, 20 );
594 aFieldPopup.Execute( pWin, aMPos );
596 SvxFieldData* pField = aFieldPopup.GetField();
597 if( pField )
599 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
600 //pOLV->DeleteSelected(); <-- fehlt leider !
601 // Feld selektieren, so dass es beim Insert geloescht wird
602 ESelection aSel = pOLV->GetSelection();
603 BOOL bSel = TRUE;
604 if( aSel.nStartPos == aSel.nEndPos )
606 bSel = FALSE;
607 aSel.nEndPos++;
609 pOLV->SetSelection( aSel );
611 pOLV->InsertField( aFieldItem );
613 // Selektion wird wieder in den Ursprungszustand gebracht
614 if( !bSel )
615 aSel.nEndPos--;
616 pOLV->SetSelection( aSel );
618 delete pField;
621 else
623 // ist etwas selektiert?
624 if (mpDrawView->AreObjectsMarked() &&
625 mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
627 pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
628 if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
630 nSdResId = RID_BEZIER_POPUP;
632 else
634 if( mpDrawView->GetTextEditObject() )
636 OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
637 Point aPos(rCEvt.GetMousePosPixel());
639 if ( pOutlinerView )
641 if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
642 ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
644 // #91457# Popup for Online-Spelling now handled by DrawDocShell
645 // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
646 Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
648 if( !rCEvt.IsMouseEvent() )
650 aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
652 // While showing the spell context menu
653 // we lock the input so that another
654 // context menu can not be opened during
655 // that time (crash #i43235#). In order
656 // to not lock the UI completely we
657 // first release the mouse.
658 GetActiveWindow()->ReleaseMouse();
659 LockInput();
660 pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
661 UnlockInput();
663 else
665 if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
667 nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
669 else
671 nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
676 else
678 UINT32 nInv = pObj->GetObjInventor();
679 UINT16 nId = pObj->GetObjIdentifier();
681 if (nInv == SdrInventor)
683 switch ( nId )
685 case OBJ_OUTLINETEXT:
686 nSdResId = bGraphicShell ? RID_GRAPHIC_OUTLINETEXTOBJ_POPUP :
687 RID_DRAW_OUTLINETEXTOBJ_POPUP;
688 break;
690 case OBJ_CAPTION:
691 case OBJ_TITLETEXT:
692 case OBJ_TEXT:
693 nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
694 RID_DRAW_TEXTOBJ_POPUP;
695 break;
697 case OBJ_PATHLINE:
698 case OBJ_PLIN:
699 nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
700 RID_DRAW_POLYLINEOBJ_POPUP;
701 break;
703 case OBJ_FREELINE:
704 case OBJ_EDGE: // Connector
705 nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
706 RID_DRAW_EDGEOBJ_POPUP;
707 break;
709 case OBJ_LINE:
710 nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
711 RID_DRAW_LINEOBJ_POPUP;
712 break;
714 case OBJ_MEASURE:
715 nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
716 RID_DRAW_MEASUREOBJ_POPUP;
717 break;
719 case OBJ_RECT:
720 case OBJ_CIRC:
721 case OBJ_FREEFILL:
722 case OBJ_PATHFILL:
723 case OBJ_POLY:
724 case OBJ_SECT:
725 case OBJ_CARC:
726 case OBJ_CCUT:
727 nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
728 RID_DRAW_GEOMOBJ_POPUP;
729 break;
731 case OBJ_CUSTOMSHAPE:
732 nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
733 RID_DRAW_CUSTOMSHAPE_POPUP;
734 break;
736 case OBJ_GRUP:
737 nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
738 RID_DRAW_GROUPOBJ_POPUP;
739 break;
741 case OBJ_GRAF:
742 nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
743 RID_DRAW_GRAPHIC_POPUP;
744 break;
746 case OBJ_OLE2:
747 nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
748 RID_DRAW_OLE2_POPUP;
749 break;
750 case OBJ_MEDIA:
751 nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
752 RID_DRAW_MEDIA_POPUP;
753 break;
754 case OBJ_TABLE:
755 nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
756 RID_DRAW_TABLE_POPUP;
757 break;
760 else if( nInv == E3dInventor /*&& nId == E3D_POLYSCENE_ID*/)
762 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
764 if( !mpDrawView->IsGroupEntered() )
765 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
766 RID_DRAW_3DSCENE_POPUP;
767 else
768 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
769 RID_DRAW_3DSCENE2_POPUP;
771 else
772 nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
773 RID_DRAW_3DOBJ_POPUP;
775 else if( nInv == FmFormInventor )
777 nSdResId = RID_FORM_CONTROL_POPUP;
783 // Mehrfachselektion
784 else if (mpDrawView->AreObjectsMarked() &&
785 mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
787 nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
788 RID_DRAW_MULTISELECTION_POPUP;
791 // nichts selektiert
792 else
794 nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
795 RID_DRAW_NOSEL_POPUP;
798 // Popup-Menue anzeigen
799 if (nSdResId)
801 GetActiveWindow()->ReleaseMouse();
803 if(rCEvt.IsMouseEvent())
804 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
805 else
807 //#106326# don't open contextmenu at mouse position if not opened via mouse
809 //middle of the window if nothing is marked
810 Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
811 ,GetActiveWindow()->GetSizePixel().Height()/2);
813 //middle of the bounding rect if something is marked
814 if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
816 Rectangle aMarkRect;
817 mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
818 aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
820 //move the point into the visible window area
821 if( aMenuPos.X() < 0 )
822 aMenuPos.X() = 0;
823 if( aMenuPos.Y() < 0 )
824 aMenuPos.Y() = 0;
825 if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
826 aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
827 if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
828 aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
831 //open context menu at that point
832 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
834 mbMousePosFreezed = FALSE;
837 else
839 ViewShell::Command(rCEvt, pWin);
844 /*************************************************************************
846 |* Linealmarkierungen anzeigen
848 \************************************************************************/
850 void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
851 ::sd::Window* pWin)
853 if (mbHasRulers && pWin )
855 RulerLine pHLines[2];
856 RulerLine pVLines[2];
857 long nHOffs = 0L;
858 long nVOffs = 0L;
859 USHORT nCnt;
861 if (mpHorizontalRuler.get() != NULL)
862 mpHorizontalRuler->SetLines();
864 if (mpVerticalRuler.get() != NULL)
865 mpVerticalRuler->SetLines();
867 if (mpHorizontalRuler.get() != NULL)
869 nHOffs = mpHorizontalRuler->GetNullOffset() +
870 mpHorizontalRuler->GetPageOffset();
873 if (mpVerticalRuler.get() != NULL)
875 nVOffs = mpVerticalRuler->GetNullOffset() +
876 mpVerticalRuler->GetPageOffset();
879 nCnt = 1;
880 pHLines[0].nPos = rRect.Left() - nHOffs;
881 pVLines[0].nPos = rRect.Top() - nVOffs;
882 pHLines[0].nStyle = 0;
883 pVLines[0].nStyle = 0;
885 if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
887 pHLines[1].nPos = rRect.Right() - nHOffs;
888 pVLines[1].nPos = rRect.Bottom() - nVOffs;
889 pHLines[1].nStyle = 0;
890 pVLines[1].nStyle = 0;
891 nCnt++;
894 if (mpHorizontalRuler.get() != NULL)
895 mpHorizontalRuler->SetLines(nCnt, pHLines);
896 if (mpVerticalRuler.get() != NULL)
897 mpVerticalRuler->SetLines(nCnt, pVLines);
900 // StatusBar Koordinatenanzeige
901 OSL_ASSERT (GetViewShell()!=NULL);
902 if ( !GetViewShell()->GetUIActiveClient() )
904 SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
905 SID_ATTR_POSITION, SID_ATTR_POSITION,
906 SID_ATTR_SIZE, SID_ATTR_SIZE,
907 0L);
909 // GetStatusBarState(aSet); nicht performant bei gedrueckter Modifiertaste!!
911 aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
913 SfxBindings& rBindings = GetViewFrame()->GetBindings();
914 rBindings.SetState(aSet);
915 rBindings.Invalidate(SID_CONTEXT);
916 rBindings.Invalidate(SID_ATTR_POSITION);
917 rBindings.Invalidate(SID_ATTR_SIZE);
921 /*************************************************************************
925 \************************************************************************/
927 void DrawViewShell::LockInput()
929 mnLockCount++;
932 /*************************************************************************
936 \************************************************************************/
938 void DrawViewShell::UnlockInput()
940 DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
941 if ( mnLockCount )
942 mnLockCount--;
948 void DrawViewShell::ShowSnapLineContextMenu (
949 SdrPageView& rPageView,
950 const USHORT nSnapLineIndex,
951 const Point& rMouseLocation)
953 const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
954 ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
956 if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
958 pMenu->InsertItem(
959 SID_SET_SNAPITEM,
960 String(SdResId(STR_POPUP_EDIT_SNAPPOINT)));
961 pMenu->InsertSeparator();
962 pMenu->InsertItem(
963 SID_DELETE_SNAPITEM,
964 String(SdResId(STR_POPUP_DELETE_SNAPPOINT)));
966 else
968 pMenu->InsertItem(
969 SID_SET_SNAPITEM,
970 String(SdResId(STR_POPUP_EDIT_SNAPLINE)));
971 pMenu->InsertSeparator();
972 pMenu->InsertItem(
973 SID_DELETE_SNAPITEM,
974 String(SdResId(STR_POPUP_DELETE_SNAPLINE)));
977 pMenu->RemoveDisabledEntries(FALSE, FALSE);
979 const USHORT nResult = pMenu->Execute(
980 GetActiveWindow(),
981 Rectangle(rMouseLocation, Size(10,10)),
982 POPUPMENU_EXECUTE_DOWN);
983 switch (nResult)
985 case SID_SET_SNAPITEM:
987 SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
988 const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
989 GetViewFrame()->GetDispatcher()->Execute(
990 SID_SET_SNAPITEM,
991 SFX_CALLMODE_SLOT,
992 aArguments);
994 break;
996 case SID_DELETE_SNAPITEM:
998 rPageView.DeleteHelpLine(nSnapLineIndex);
1000 break;
1002 default:
1003 break;
1010 #ifdef _MSC_VER
1011 #pragma optimize ( "", on )
1012 #endif
1014 } // end of namespace sd