bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / view / drviews4.cxx
blob548dbf4e314fb421f19a82fe56162b40e16dcb74
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
22 #include "DrawViewShell.hxx"
23 #include <vcl/msgbox.hxx>
24 #include <svl/urlbmk.hxx>
25 #include <svx/svdpagv.hxx>
26 #include <svx/svdundo.hxx>
27 #include <svx/fmglob.hxx>
28 #include <editeng/eeitem.hxx>
29 #include <editeng/flditem.hxx>
30 #include <svx/svxids.hrc>
31 #include <svx/ruler.hxx>
32 #include <svx/globl3d.hxx>
33 #include <editeng/outliner.hxx>
34 #include <sfx2/ipclient.hxx>
35 #include <sfx2/request.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <svx/svdopath.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <editeng/editview.hxx>
40 #include <vcl/cursor.hxx>
42 #include "app.hrc"
43 #include "glob.hrc"
44 #include "strings.hrc"
45 #include "res_bmp.hrc"
46 #include "DrawDocShell.hxx"
47 #include "drawdoc.hxx"
48 #include "Window.hxx"
49 #include "fupoor.hxx"
50 #include "fusnapln.hxx"
51 #include "sdmod.hxx"
52 #include "Ruler.hxx"
53 #include "sdresid.hxx"
54 #include "GraphicViewShell.hxx"
55 #include "sdpage.hxx"
56 #include "slideshow.hxx"
57 #include "anminfo.hxx"
58 #include "sdpopup.hxx"
59 #include "drawview.hxx"
60 #include <svx/bmpmask.hxx>
61 #include "LayerTabBar.hxx"
63 #include <svx/svditer.hxx>
65 #include <navigatr.hxx>
66 #include <boost/scoped_ptr.hpp>
68 namespace sd {
70 #define PIPETTE_RANGE 0
72 using namespace ::com::sun::star::uno;
73 using namespace ::com::sun::star::drawing;
75 void DrawViewShell::DeleteActualPage()
77 sal_uInt16 nPage = maTabControl->GetCurPageId() - 1;
79 mpDrawView->SdrEndTextEdit();
81 try
83 Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
84 Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
85 Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
86 xPages->remove( xPage );
88 catch( Exception& )
90 OSL_FAIL("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
94 void DrawViewShell::DeleteActualLayer()
96 if(!GetLayerTabControl()) // #i87182#
98 OSL_ENSURE(false, "No LayerTabBar (!)");
99 return;
102 SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
103 const OUString& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
104 OUString aString(SD_RESSTR(STR_ASK_DELETE_LAYER));
106 // replace placeholder
107 aString = aString.replaceFirst("$", rName);
109 if (ScopedVclPtr<QueryBox>::Create(GetActiveWindow(), WB_YES_NO, aString)->Execute() == RET_YES)
111 const SdrLayer* pLayer = rAdmin.GetLayer(rName, false);
112 mpDrawView->DeleteLayer( pLayer->GetName() );
114 /* in order to redraw TabBar and Window; should be initiated later on by
115 a hint from Joe (as by a change if the layer order). */
116 // ( View::Notify() --> ViewShell::ResetActualLayer() )
118 mbIsLayerModeActive = false; // so that ChangeEditMode() does something
119 ChangeEditMode(GetEditMode(), true);
123 bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
125 bool bRet = false;
127 if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
129 if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
130 && rKEvt.GetKeyCode().IsMod1()
131 && GetView()->IsTextEdit())
133 // this should be used for cursor travelling.
134 SdPage* pActualPage = GetActualPage();
135 const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
136 SdrTextObj* pCandidate = 0L;
138 if(pActualPage && 1 == rMarkList.GetMarkCount())
140 SdrMark* pMark = rMarkList.GetMark(0);
142 // remember which object was the text in edit mode
143 SdrObject* pOldObj = pMark->GetMarkedSdrObj();
145 // end text edit now
146 GetView()->SdrEndTextEdit();
148 // look for a new candidate, a successor of pOldObj
149 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
150 bool bDidVisitOldObject(false);
152 while(aIter.IsMore() && !pCandidate)
154 SdrObject* pObj = aIter.Next();
156 if(pObj && pObj->ISA(SdrTextObj))
158 sal_uInt32 nInv(pObj->GetObjInventor());
159 sal_uInt16 nKnd(pObj->GetObjIdentifier());
161 if(SdrInventor == nInv &&
162 (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd)
163 && bDidVisitOldObject)
165 pCandidate = static_cast<SdrTextObj*>(pObj);
168 if(pObj == pOldObj)
170 bDidVisitOldObject = true;
176 if(pCandidate)
178 // set the new candidate to text edit mode
179 GetView()->UnMarkAll();
180 GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
182 GetViewFrame()->GetDispatcher()->Execute(
183 SID_ATTR_CHAR, SfxCallMode::ASYNCHRON);
185 else
187 // insert a new page with the same page layout
188 GetViewFrame()->GetDispatcher()->Execute(
189 SID_INSERTPAGE_QUICK, SfxCallMode::ASYNCHRON);
192 else
194 bRet = ViewShell::KeyInput(rKEvt, pWin);
195 //If object is marked , the corresponding entry is set true , else
196 //the corresponding entry is set false .
197 if(KEY_TAB == rKEvt.GetKeyCode().GetCode())
199 FreshNavigatrTree();
204 return bRet;
208 * Start with Drag from ruler (helper lines, origin)
210 void DrawViewShell::StartRulerDrag (
211 const Ruler& rRuler,
212 const MouseEvent& rMEvt)
214 GetActiveWindow()->CaptureMouse();
216 Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
218 if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) )
220 mpDrawView->BegSetPageOrg(aWPos);
221 mbIsRulerDrag = true;
223 else
225 // #i34536# if no guide-lines are visible yet, that show them
226 if( ! mpDrawView->IsHlplVisible())
227 mpDrawView->SetHlplVisible( true );
229 SdrHelpLineKind eKind;
231 if ( rMEvt.IsMod1() )
232 eKind = SDRHELPLINE_POINT;
233 else if ( rRuler.IsHorizontal() )
234 eKind = SDRHELPLINE_HORIZONTAL;
235 else
236 eKind = SDRHELPLINE_VERTICAL;
238 mpDrawView->BegDragHelpLine(aWPos, eKind);
239 mbIsRulerDrag = true;
243 //If object is marked , the corresponding entry is set true ,
244 //else the corresponding entry is set false .
245 void DrawViewShell::FreshNavigatrEntry()
247 sal_uInt16 nId = SID_NAVIGATOR;
248 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
249 if( pWindow )
251 SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
252 if( pNavWin )
253 pNavWin->FreshEntry();
257 void DrawViewShell::FreshNavigatrTree()
259 sal_uInt16 nId = SID_NAVIGATOR;
260 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
261 if( pWindow )
263 SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
264 if( pNavWin )
265 pNavWin->FreshTree( GetDoc() );
269 void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt,
270 ::sd::Window* pWin)
272 // We have to check if a context menu is shown and we have an UI
273 // active inplace client. In that case we have to ignore the mouse
274 // button down event. Otherwise we would crash (context menu has been
275 // opened by inplace client and we would deactivate the inplace client,
276 // the contex menu is closed by VCL asynchronously which in the end
277 // would work on deleted objects or the context menu has no parent anymore)
278 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
279 bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
281 if ( bIsOleActive && PopupMenu::IsInExecute() )
282 return;
284 if ( !IsInputLocked() )
286 ViewShell::MouseButtonDown(rMEvt, pWin);
288 //If object is marked , the corresponding entry is set true ,
289 //else the corresponding entry is set false .
290 FreshNavigatrTree();
291 if (mbPipette)
293 SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
294 SvxBmpMask* pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : NULL;
295 if (pBmpMask)
296 pBmpMask->PipetteClicked();
301 void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
303 if ( !IsInputLocked() )
305 if ( mpDrawView->IsAction() )
307 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
309 if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
311 bool bInsideOtherWindow = false;
313 if (mpContentWindow.get() != NULL)
315 aOutputArea = Rectangle(Point(0,0),
316 mpContentWindow->GetOutputSizePixel());
318 Point aPos = mpContentWindow->GetPointerPosPixel();
319 if ( aOutputArea.IsInside(aPos) )
320 bInsideOtherWindow = true;
323 if (! GetActiveWindow()->HasFocus ())
325 GetActiveWindow()->ReleaseMouse ();
326 mpDrawView->BrkAction ();
327 return;
329 else if ( bInsideOtherWindow )
331 GetActiveWindow()->ReleaseMouse();
332 pWin->CaptureMouse ();
335 else if ( pWin != GetActiveWindow() )
336 pWin->CaptureMouse();
339 // Since the next MouseMove may execute a IsSolidDraggingNow() in
340 // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
341 // is needed it is necessary to set it here.
342 if (GetDoc())
344 svtools::ColorConfig aColorConfig;
345 Color aFillColor;
347 aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
349 mpDrawView->SetApplicationBackgroundColor(aFillColor);
352 ViewShell::MouseMove(rMEvt, pWin);
354 if( !mbMousePosFreezed )
355 maMousePos = rMEvt.GetPosPixel();
357 Rectangle aRect;
359 if ( mbIsRulerDrag )
361 Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
362 mpDrawView->MovAction(aLogPos);
365 if ( mpDrawView->IsAction() )
367 mpDrawView->TakeActionRect(aRect);
368 aRect = GetActiveWindow()->LogicToPixel(aRect);
370 else
372 aRect = Rectangle(maMousePos, maMousePos);
375 ShowMousePosInfo(aRect, pWin);
377 SvxBmpMask* pBmpMask = NULL;
378 if (mbPipette && GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
380 SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
381 pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : NULL;
384 if (pBmpMask)
386 const long nStartX = maMousePos.X() - PIPETTE_RANGE;
387 const long nEndX = maMousePos.X() + PIPETTE_RANGE;
388 const long nStartY = maMousePos.Y() - PIPETTE_RANGE;
389 const long nEndY = maMousePos.Y() + PIPETTE_RANGE;
390 long nRed = 0;
391 long nGreen = 0;
392 long nBlue = 0;
393 const double fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
395 for ( long nY = nStartY; nY <= nEndY; nY++ )
397 for( long nX = nStartX; nX <= nEndX; nX++ )
399 const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
401 nRed += aCol.GetRed();
402 nGreen += aCol.GetGreen();
403 nBlue += aCol.GetBlue();
407 pBmpMask->SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ),
408 (sal_uInt8) ( nGreen / fDiv + .5 ),
409 (sal_uInt8) ( nBlue / fDiv + .5 ) ) );
414 void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
416 if ( !IsInputLocked() )
418 bool bIsSetPageOrg = mpDrawView->IsSetPageOrg();
420 if (mbIsRulerDrag)
422 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
424 if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
426 mpDrawView->EndAction();
428 if (bIsSetPageOrg)
429 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
431 else if (rMEvt.IsLeft() && bIsSetPageOrg)
433 mpDrawView->BrkAction();
434 SdPage* pPage = static_cast<SdPage*>( mpDrawView->GetSdrPageView()->GetPage() );
435 Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
436 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
437 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
439 else
441 mpDrawView->BrkAction();
444 GetActiveWindow()->ReleaseMouse();
445 mbIsRulerDrag = false;
447 else
448 ViewShell::MouseButtonUp(rMEvt, pWin);
449 //If object is marked , the corresponding entry is set true ,
450 //else the corresponding entry is set false .
451 FreshNavigatrTree();
455 void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
457 // The command event is send to the window after a possible context
458 // menu from an inplace client is closed. Now we have the chance to
459 // deactivate the inplace client without any problem regarding parent
460 // windows and code on the stack.
461 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
462 bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
463 if ( bIsOleActive && ( rCEvt.GetCommand() == CommandEventId::ContextMenu ))
465 // Deactivate OLE object
466 mpDrawView->UnmarkAll();
467 SelectionHasChanged();
468 return;
471 if ( !IsInputLocked() )
473 if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
474 return;
476 const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
478 if( rCEvt.GetCommand() == CommandEventId::PasteSelection && !bNativeShow )
480 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
482 if( aDataHelper.GetTransferable().is() )
484 Point aPos;
485 sal_Int8 nDnDAction = DND_ACTION_COPY;
487 if( GetActiveWindow() )
488 aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
490 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, false ) )
492 INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
494 if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
495 aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
496 ( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) &&
497 aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
498 ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) &&
499 aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
501 InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
506 else if( rCEvt.GetCommand() == CommandEventId::ContextMenu && !bNativeShow &&
507 pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
509 sal_uInt16 nSdResId = 0; // ResourceID for popup menu
510 bool bGraphicShell = this->ISA(GraphicViewShell);
512 // is there a snap object under the cursor?
513 SdrPageView* pPV;
514 Point aMPos = pWin->PixelToLogic( maMousePos );
515 sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
516 Size(FuPoor::HITPIX, 0 ) ).Width();
517 sal_uInt16 nHelpLine;
518 // for glue points
519 SdrObject* pObj = NULL;
520 sal_uInt16 nPickId = 0;
521 // for field command
522 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
523 const SvxFieldItem* pFldItem = NULL;
524 if( pOLV )
525 pFldItem = pOLV->GetFieldAtSelection();
527 // helper line
528 if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
530 nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
531 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
532 return;
534 // is glue point under cursor marked?
535 else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
536 mpDrawView->IsGluePointMarked( pObj, nPickId ) )
538 nSdResId = RID_DRAW_GLUEPOINT_POPUP;
540 // field command?
541 else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
542 pFldItem->GetField()->ISA( SvxExtTimeField ) ||
543 pFldItem->GetField()->ISA( SvxExtFileField ) ||
544 pFldItem->GetField()->ISA( SvxAuthorField ) ) )
546 LanguageType eLanguage( LANGUAGE_SYSTEM );
548 // Format popup with outliner language, if possible
549 if( pOLV->GetOutliner() )
551 ESelection aSelection( pOLV->GetSelection() );
552 eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
555 //fdo#44998 if the outliner has captured the mouse events release the lock
556 //so the SdFieldPopup can get them
557 pOLV->ReleaseMouse();
558 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
560 if ( rCEvt.IsMouseEvent() )
561 aMPos = rCEvt.GetMousePosPixel();
562 else
563 aMPos = Point( 20, 20 );
564 aFieldPopup.Execute( pWin, aMPos );
566 boost::scoped_ptr<SvxFieldData> pField(aFieldPopup.GetField());
567 if( pField )
569 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
570 // select field, so that it will be deleted on insert
571 ESelection aSel = pOLV->GetSelection();
572 bool bSel = true;
573 if( aSel.nStartPos == aSel.nEndPos )
575 bSel = false;
576 aSel.nEndPos++;
578 pOLV->SetSelection( aSel );
580 pOLV->InsertField( aFieldItem );
582 // reset selection back to original state
583 if( !bSel )
584 aSel.nEndPos--;
585 pOLV->SetSelection( aSel );
588 else
590 // is something selected?
591 if (mpDrawView->AreObjectsMarked() &&
592 mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
594 pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
595 if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
597 nSdResId = RID_BEZIER_POPUP;
599 else
601 if( mpDrawView->GetTextEditObject() )
603 OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
604 Point aPos(rCEvt.GetMousePosPixel());
606 if ( pOutlinerView )
608 if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
609 ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
611 // Popup for Online-Spelling now handled by DrawDocShell
612 Link<> aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
614 if( !rCEvt.IsMouseEvent() )
616 aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
618 // While showing the spell context menu
619 // we lock the input so that another
620 // context menu can not be opened during
621 // that time (crash #i43235#). In order
622 // to not lock the UI completely we
623 // first release the mouse.
624 GetActiveWindow()->ReleaseMouse();
625 LockInput();
626 pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
627 UnlockInput();
629 else
631 if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
633 nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
635 else
637 nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
642 else
644 sal_uInt32 nInv = pObj->GetObjInventor();
645 sal_uInt16 nId = pObj->GetObjIdentifier();
647 if (nInv == SdrInventor)
649 switch ( nId )
651 case OBJ_OUTLINETEXT:
652 nSdResId = bGraphicShell ? RID_GRAPHIC_OUTLINETEXTOBJ_POPUP :
653 RID_DRAW_OUTLINETEXTOBJ_POPUP;
654 break;
656 case OBJ_CAPTION:
657 case OBJ_TITLETEXT:
658 case OBJ_TEXT:
659 nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
660 RID_DRAW_TEXTOBJ_POPUP;
661 break;
663 case OBJ_PATHLINE:
664 case OBJ_PLIN:
665 nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
666 RID_DRAW_POLYLINEOBJ_POPUP;
667 break;
669 case OBJ_FREELINE:
670 case OBJ_EDGE: // Connector
671 nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
672 RID_DRAW_EDGEOBJ_POPUP;
673 break;
675 case OBJ_LINE:
676 nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
677 RID_DRAW_LINEOBJ_POPUP;
678 break;
680 case OBJ_MEASURE:
681 nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
682 RID_DRAW_MEASUREOBJ_POPUP;
683 break;
685 case OBJ_RECT:
686 case OBJ_CIRC:
687 case OBJ_FREEFILL:
688 case OBJ_PATHFILL:
689 case OBJ_POLY:
690 case OBJ_SECT:
691 case OBJ_CARC:
692 case OBJ_CCUT:
693 nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
694 RID_DRAW_GEOMOBJ_POPUP;
695 break;
697 case OBJ_CUSTOMSHAPE:
698 nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
699 RID_DRAW_CUSTOMSHAPE_POPUP;
700 break;
702 case OBJ_GRUP:
703 nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
704 RID_DRAW_GROUPOBJ_POPUP;
705 break;
707 case OBJ_GRAF:
708 nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
709 RID_DRAW_GRAPHIC_POPUP;
710 break;
712 case OBJ_OLE2:
713 nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
714 RID_DRAW_OLE2_POPUP;
715 break;
716 case OBJ_MEDIA:
717 nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
718 RID_DRAW_MEDIA_POPUP;
719 break;
720 case OBJ_TABLE:
721 nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
722 RID_DRAW_TABLE_POPUP;
723 break;
726 else if( nInv == E3dInventor )
728 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
730 if( !mpDrawView->IsGroupEntered() )
731 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
732 RID_DRAW_3DSCENE_POPUP;
733 else
734 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
735 RID_DRAW_3DSCENE2_POPUP;
737 else
738 nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
739 RID_DRAW_3DOBJ_POPUP;
741 else if( nInv == FmFormInventor )
743 nSdResId = RID_FORM_CONTROL_POPUP;
749 // multiple selection
750 else if (mpDrawView->AreObjectsMarked() &&
751 mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
753 nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
754 RID_DRAW_MULTISELECTION_POPUP;
757 // nothing selected
758 else
760 nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
761 RID_DRAW_NOSEL_POPUP;
764 // show Popup-Menu
765 if (nSdResId)
767 GetActiveWindow()->ReleaseMouse();
769 if(rCEvt.IsMouseEvent())
770 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
771 else
773 //don't open contextmenu at mouse position if not opened via mouse
775 //middle of the window if nothing is marked
776 Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
777 ,GetActiveWindow()->GetSizePixel().Height()/2);
779 //middle of the bounding rect if something is marked
780 if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
782 Rectangle aMarkRect;
783 mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
784 aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
786 //move the point into the visible window area
787 if( aMenuPos.X() < 0 )
788 aMenuPos.X() = 0;
789 if( aMenuPos.Y() < 0 )
790 aMenuPos.Y() = 0;
791 if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
792 aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
793 if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
794 aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
797 //open context menu at that point
798 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
800 mbMousePosFreezed = false;
803 else
805 ViewShell::Command(rCEvt, pWin);
810 void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
811 ::sd::Window* pWin)
813 if (mbHasRulers && pWin )
815 RulerLine pHLines[2];
816 RulerLine pVLines[2];
817 long nHOffs = 0L;
818 long nVOffs = 0L;
819 sal_uInt16 nCnt;
821 if (mpHorizontalRuler.get() != NULL)
822 mpHorizontalRuler->SetLines();
824 if (mpVerticalRuler.get() != NULL)
825 mpVerticalRuler->SetLines();
827 if (mpHorizontalRuler.get() != NULL)
829 nHOffs = mpHorizontalRuler->GetNullOffset() +
830 mpHorizontalRuler->GetPageOffset();
833 if (mpVerticalRuler.get() != NULL)
835 nVOffs = mpVerticalRuler->GetNullOffset() +
836 mpVerticalRuler->GetPageOffset();
839 nCnt = 1;
840 pHLines[0].nPos = rRect.Left() - nHOffs;
841 pVLines[0].nPos = rRect.Top() - nVOffs;
842 pHLines[0].nStyle = 0;
843 pVLines[0].nStyle = 0;
845 if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
847 pHLines[1].nPos = rRect.Right() - nHOffs;
848 pVLines[1].nPos = rRect.Bottom() - nVOffs;
849 pHLines[1].nStyle = 0;
850 pVLines[1].nStyle = 0;
851 nCnt++;
854 if (mpHorizontalRuler.get() != NULL)
855 mpHorizontalRuler->SetLines(nCnt, pHLines);
856 if (mpVerticalRuler.get() != NULL)
857 mpVerticalRuler->SetLines(nCnt, pVLines);
860 // display with coordinates in StatusBar
861 OSL_ASSERT (GetViewShell()!=NULL);
862 if ( !GetViewShell()->GetUIActiveClient() )
864 SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
865 SID_ATTR_POSITION, SID_ATTR_POSITION,
866 SID_ATTR_SIZE, SID_ATTR_SIZE,
867 0L);
869 GetStatusBarState(aSet);
871 aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
873 SfxBindings& rBindings = GetViewFrame()->GetBindings();
874 rBindings.SetState(aSet);
875 rBindings.Invalidate(SID_CONTEXT);
876 rBindings.Invalidate(SID_ATTR_POSITION);
877 rBindings.Invalidate(SID_ATTR_SIZE);
881 void DrawViewShell::LockInput()
883 mnLockCount++;
886 void DrawViewShell::UnlockInput()
888 DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
889 if ( mnLockCount )
890 mnLockCount--;
893 void DrawViewShell::ShowSnapLineContextMenu (
894 SdrPageView& rPageView,
895 const sal_uInt16 nSnapLineIndex,
896 const Point& rMouseLocation)
898 const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
899 ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
901 if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
903 pMenu->InsertItem(
904 SID_SET_SNAPITEM,
905 SD_RESSTR(STR_POPUP_EDIT_SNAPPOINT));
906 pMenu->InsertSeparator();
907 pMenu->InsertItem(
908 SID_DELETE_SNAPITEM,
909 SD_RESSTR(STR_POPUP_DELETE_SNAPPOINT));
911 else
913 pMenu->InsertItem(
914 SID_SET_SNAPITEM,
915 SD_RESSTR(STR_POPUP_EDIT_SNAPLINE));
916 pMenu->InsertSeparator();
917 pMenu->InsertItem(
918 SID_DELETE_SNAPITEM,
919 SD_RESSTR(STR_POPUP_DELETE_SNAPLINE));
922 pMenu->RemoveDisabledEntries(false, false);
924 const sal_uInt16 nResult = pMenu->Execute(
925 GetActiveWindow(),
926 Rectangle(rMouseLocation, Size(10,10)),
927 PopupMenuFlags::ExecuteDown);
928 switch (nResult)
930 case SID_SET_SNAPITEM:
932 SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
933 const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
934 GetViewFrame()->GetDispatcher()->Execute(
935 SID_SET_SNAPITEM,
936 SfxCallMode::SLOT,
937 aArguments);
939 break;
941 case SID_DELETE_SNAPITEM:
943 rPageView.DeleteHelpLine(nSnapLineIndex);
945 break;
947 default:
948 break;
952 } // end of namespace sd
954 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */