update dev300-m58
[ooovba.git] / sd / source / ui / view / drviews4.cxx
blob137d17d19018abfadca976fc39c70f1fd67eb686
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 const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
507 if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow )
509 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
511 if( aDataHelper.GetTransferable().is() )
513 Point aPos;
514 sal_Int8 nDnDAction = DND_ACTION_COPY;
516 if( GetActiveWindow() )
517 aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
519 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, FALSE ) )
521 INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
523 if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
524 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
525 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
526 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
527 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
528 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
530 InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
535 else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow &&
536 pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
538 USHORT nSdResId = 0; // ResourceID fuer Popup-Menue
539 BOOL bGraphicShell = this->ISA(GraphicViewShell);
541 // Ist ein Fangobjekt unter dem Mauszeiger?
542 SdrPageView* pPV;
543 Point aMPos = pWin->PixelToLogic( maMousePos );
544 USHORT nHitLog = (USHORT) GetActiveWindow()->PixelToLogic(
545 Size(FuPoor::HITPIX, 0 ) ).Width();
546 USHORT nHelpLine;
547 // fuer Klebepunkt
548 SdrObject* pObj = NULL;
549 USHORT nPickId = 0;
550 // fuer Feldbefehl
551 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
552 const SvxFieldItem* pFldItem = NULL;
553 if( pOLV )
554 pFldItem = pOLV->GetFieldAtSelection();
555 //pFldItem = pOLV->GetFieldUnderMousePointer();
557 // Hilfslinie
558 if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
560 nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
561 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
562 return;
564 // Klebepunkt unter dem Mauszeiger markiert?
565 else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
566 mpDrawView->IsGluePointMarked( pObj, nPickId ) )
568 nSdResId = RID_DRAW_GLUEPOINT_POPUP;
570 // Feldbefehl ?
571 else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
572 pFldItem->GetField()->ISA( SvxExtTimeField ) ||
573 pFldItem->GetField()->ISA( SvxExtFileField ) ||
574 pFldItem->GetField()->ISA( SvxAuthorField ) ) )
576 LanguageType eLanguage( LANGUAGE_SYSTEM );
578 // #101743# Format popup with outliner language, if possible
579 if( pOLV->GetOutliner() )
581 ESelection aSelection( pOLV->GetSelection() );
582 eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
585 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
587 if ( rCEvt.IsMouseEvent() )
588 aMPos = rCEvt.GetMousePosPixel();
589 else
590 aMPos = Point( 20, 20 );
591 aFieldPopup.Execute( pWin, aMPos );
593 SvxFieldData* pField = aFieldPopup.GetField();
594 if( pField )
596 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
597 //pOLV->DeleteSelected(); <-- fehlt leider !
598 // Feld selektieren, so dass es beim Insert geloescht wird
599 ESelection aSel = pOLV->GetSelection();
600 BOOL bSel = TRUE;
601 if( aSel.nStartPos == aSel.nEndPos )
603 bSel = FALSE;
604 aSel.nEndPos++;
606 pOLV->SetSelection( aSel );
608 pOLV->InsertField( aFieldItem );
610 // Selektion wird wieder in den Ursprungszustand gebracht
611 if( !bSel )
612 aSel.nEndPos--;
613 pOLV->SetSelection( aSel );
615 delete pField;
618 else
620 // ist etwas selektiert?
621 if (mpDrawView->AreObjectsMarked() &&
622 mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
624 pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
625 if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
627 nSdResId = RID_BEZIER_POPUP;
629 else
631 if( mpDrawView->GetTextEditObject() )
633 OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
634 Point aPos(rCEvt.GetMousePosPixel());
636 if ( pOutlinerView )
638 if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
639 ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
641 // #91457# Popup for Online-Spelling now handled by DrawDocShell
642 // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
643 Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
645 if( !rCEvt.IsMouseEvent() )
647 aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
649 // While showing the spell context menu
650 // we lock the input so that another
651 // context menu can not be opened during
652 // that time (crash #i43235#). In order
653 // to not lock the UI completely we
654 // first release the mouse.
655 GetActiveWindow()->ReleaseMouse();
656 LockInput();
657 pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
658 UnlockInput();
660 else
662 if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
664 nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
666 else
668 nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
673 else
675 UINT32 nInv = pObj->GetObjInventor();
676 UINT16 nId = pObj->GetObjIdentifier();
678 if (nInv == SdrInventor)
680 switch ( nId )
682 case OBJ_OUTLINETEXT:
683 nSdResId = bGraphicShell ? RID_GRAPHIC_OUTLINETEXTOBJ_POPUP :
684 RID_DRAW_OUTLINETEXTOBJ_POPUP;
685 break;
687 case OBJ_CAPTION:
688 case OBJ_TITLETEXT:
689 case OBJ_TEXT:
690 nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
691 RID_DRAW_TEXTOBJ_POPUP;
692 break;
694 case OBJ_PATHLINE:
695 case OBJ_PLIN:
696 nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
697 RID_DRAW_POLYLINEOBJ_POPUP;
698 break;
700 case OBJ_FREELINE:
701 case OBJ_EDGE: // Connector
702 nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
703 RID_DRAW_EDGEOBJ_POPUP;
704 break;
706 case OBJ_LINE:
707 nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
708 RID_DRAW_LINEOBJ_POPUP;
709 break;
711 case OBJ_MEASURE:
712 nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
713 RID_DRAW_MEASUREOBJ_POPUP;
714 break;
716 case OBJ_RECT:
717 case OBJ_CIRC:
718 case OBJ_FREEFILL:
719 case OBJ_PATHFILL:
720 case OBJ_POLY:
721 case OBJ_SECT:
722 case OBJ_CARC:
723 case OBJ_CCUT:
724 nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
725 RID_DRAW_GEOMOBJ_POPUP;
726 break;
728 case OBJ_CUSTOMSHAPE:
729 nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
730 RID_DRAW_CUSTOMSHAPE_POPUP;
731 break;
733 case OBJ_GRUP:
734 nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
735 RID_DRAW_GROUPOBJ_POPUP;
736 break;
738 case OBJ_GRAF:
739 nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
740 RID_DRAW_GRAPHIC_POPUP;
741 break;
743 case OBJ_OLE2:
744 nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
745 RID_DRAW_OLE2_POPUP;
746 break;
747 case OBJ_MEDIA:
748 nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
749 RID_DRAW_MEDIA_POPUP;
750 break;
751 case OBJ_TABLE:
752 nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
753 RID_DRAW_TABLE_POPUP;
754 break;
757 else if( nInv == E3dInventor /*&& nId == E3D_POLYSCENE_ID*/)
759 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
761 if( !mpDrawView->IsGroupEntered() )
762 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
763 RID_DRAW_3DSCENE_POPUP;
764 else
765 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
766 RID_DRAW_3DSCENE2_POPUP;
768 else
769 nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
770 RID_DRAW_3DOBJ_POPUP;
772 else if( nInv == FmFormInventor )
774 nSdResId = RID_FORM_CONTROL_POPUP;
780 // Mehrfachselektion
781 else if (mpDrawView->AreObjectsMarked() &&
782 mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
784 nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
785 RID_DRAW_MULTISELECTION_POPUP;
788 // nichts selektiert
789 else
791 nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
792 RID_DRAW_NOSEL_POPUP;
795 // Popup-Menue anzeigen
796 if (nSdResId)
798 GetActiveWindow()->ReleaseMouse();
800 if(rCEvt.IsMouseEvent())
801 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
802 else
804 //#106326# don't open contextmenu at mouse position if not opened via mouse
806 //middle of the window if nothing is marked
807 Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
808 ,GetActiveWindow()->GetSizePixel().Height()/2);
810 //middle of the bounding rect if something is marked
811 if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
813 Rectangle aMarkRect;
814 mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
815 aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
817 //move the point into the visible window area
818 if( aMenuPos.X() < 0 )
819 aMenuPos.X() = 0;
820 if( aMenuPos.Y() < 0 )
821 aMenuPos.Y() = 0;
822 if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
823 aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
824 if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
825 aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
828 //open context menu at that point
829 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
831 mbMousePosFreezed = FALSE;
834 else
836 ViewShell::Command(rCEvt, pWin);
841 /*************************************************************************
843 |* Linealmarkierungen anzeigen
845 \************************************************************************/
847 void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
848 ::sd::Window* pWin)
850 if (mbHasRulers && pWin )
852 RulerLine pHLines[2];
853 RulerLine pVLines[2];
854 long nHOffs = 0L;
855 long nVOffs = 0L;
856 USHORT nCnt;
858 if (mpHorizontalRuler.get() != NULL)
859 mpHorizontalRuler->SetLines();
861 if (mpVerticalRuler.get() != NULL)
862 mpVerticalRuler->SetLines();
864 if (mpHorizontalRuler.get() != NULL)
866 nHOffs = mpHorizontalRuler->GetNullOffset() +
867 mpHorizontalRuler->GetPageOffset();
870 if (mpVerticalRuler.get() != NULL)
872 nVOffs = mpVerticalRuler->GetNullOffset() +
873 mpVerticalRuler->GetPageOffset();
876 nCnt = 1;
877 pHLines[0].nPos = rRect.Left() - nHOffs;
878 pVLines[0].nPos = rRect.Top() - nVOffs;
879 pHLines[0].nStyle = 0;
880 pVLines[0].nStyle = 0;
882 if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
884 pHLines[1].nPos = rRect.Right() - nHOffs;
885 pVLines[1].nPos = rRect.Bottom() - nVOffs;
886 pHLines[1].nStyle = 0;
887 pVLines[1].nStyle = 0;
888 nCnt++;
891 if (mpHorizontalRuler.get() != NULL)
892 mpHorizontalRuler->SetLines(nCnt, pHLines);
893 if (mpVerticalRuler.get() != NULL)
894 mpVerticalRuler->SetLines(nCnt, pVLines);
897 // StatusBar Koordinatenanzeige
898 OSL_ASSERT (GetViewShell()!=NULL);
899 if ( !GetViewShell()->GetUIActiveClient() )
901 SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
902 SID_ATTR_POSITION, SID_ATTR_POSITION,
903 SID_ATTR_SIZE, SID_ATTR_SIZE,
904 0L);
906 // GetStatusBarState(aSet); nicht performant bei gedrueckter Modifiertaste!!
908 aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
910 SfxBindings& rBindings = GetViewFrame()->GetBindings();
911 rBindings.SetState(aSet);
912 rBindings.Invalidate(SID_CONTEXT);
913 rBindings.Invalidate(SID_ATTR_POSITION);
914 rBindings.Invalidate(SID_ATTR_SIZE);
918 /*************************************************************************
922 \************************************************************************/
924 void DrawViewShell::LockInput()
926 mnLockCount++;
929 /*************************************************************************
933 \************************************************************************/
935 void DrawViewShell::UnlockInput()
937 DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
938 if ( mnLockCount )
939 mnLockCount--;
945 void DrawViewShell::ShowSnapLineContextMenu (
946 SdrPageView& rPageView,
947 const USHORT nSnapLineIndex,
948 const Point& rMouseLocation)
950 const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
951 ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
953 if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
955 pMenu->InsertItem(
956 SID_SET_SNAPITEM,
957 String(SdResId(STR_POPUP_EDIT_SNAPPOINT)));
958 pMenu->InsertSeparator();
959 pMenu->InsertItem(
960 SID_DELETE_SNAPITEM,
961 String(SdResId(STR_POPUP_DELETE_SNAPPOINT)));
963 else
965 pMenu->InsertItem(
966 SID_SET_SNAPITEM,
967 String(SdResId(STR_POPUP_EDIT_SNAPLINE)));
968 pMenu->InsertSeparator();
969 pMenu->InsertItem(
970 SID_DELETE_SNAPITEM,
971 String(SdResId(STR_POPUP_DELETE_SNAPLINE)));
974 pMenu->RemoveDisabledEntries(FALSE, FALSE);
976 const USHORT nResult = pMenu->Execute(
977 GetActiveWindow(),
978 Rectangle(rMouseLocation, Size(10,10)),
979 POPUPMENU_EXECUTE_DOWN);
980 switch (nResult)
982 case SID_SET_SNAPITEM:
984 SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
985 const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
986 GetViewFrame()->GetDispatcher()->Execute(
987 SID_SET_SNAPITEM,
988 SFX_CALLMODE_SLOT,
989 aArguments);
991 break;
993 case SID_DELETE_SNAPITEM:
995 rPageView.DeleteHelpLine(nSnapLineIndex);
997 break;
999 default:
1000 break;
1007 #ifdef _MSC_VER
1008 #pragma optimize ( "", on )
1009 #endif
1011 } // end of namespace sd