LibreOffice Module sd (master) 1
drviews4.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
21
22#include <DrawViewShell.hxx>
23#include <svl/intitem.hxx>
24#include <svl/stritem.hxx>
25#include <svl/urlbmk.hxx>
26#include <svx/svdpagv.hxx>
27#include <editeng/eeitem.hxx>
28#include <editeng/flditem.hxx>
29#include <svx/svxids.hrc>
30#include <svx/ruler.hxx>
31#include <svx/svdobjkind.hxx>
32#include <editeng/outliner.hxx>
33#include <sfx2/ipclient.hxx>
34#include <sfx2/dispatch.hxx>
35#include <svx/svdopath.hxx>
36#include <sfx2/viewfrm.hxx>
37#include <editeng/editview.hxx>
39#include <vcl/cursor.hxx>
40#include <vcl/commandevent.hxx>
41#include <vcl/dialoghelper.hxx>
42#include <vcl/svapp.hxx>
43#include <vcl/weldutils.hxx>
44
45#include <app.hrc>
46#include <strings.hrc>
47
48#include <DrawDocShell.hxx>
49#include <drawdoc.hxx>
50#include <Window.hxx>
51#include <fupoor.hxx>
52#include <sdmod.hxx>
53#include <Ruler.hxx>
54#include <sdresid.hxx>
55#include <sdpage.hxx>
56#include <slideshow.hxx>
57#include <sdpopup.hxx>
58#include <drawview.hxx>
59#include <svx/bmpmask.hxx>
60#include <LayerTabBar.hxx>
61#include <ViewShellBase.hxx>
62
64#include <svx/svditer.hxx>
65
66#include <navigatr.hxx>
67#include <memory>
68
69namespace {
70 void EndTextEditOnPage(sal_uInt16 nPageId)
71 {
73 while (pShell)
74 {
75 ::sd::ViewShellBase* pBase = dynamic_cast<::sd::ViewShellBase*>(pShell);
76 if (pBase)
77 {
78 ::sd::ViewShell* pViewSh = pBase->GetMainViewShell().get();
79 ::sd::DrawViewShell* pDrawSh = dynamic_cast<::sd::DrawViewShell*>(pViewSh);
80 if (pDrawSh && pDrawSh->GetDrawView() && pDrawSh->getCurrentPage()->getPageId() == nPageId)
81 pDrawSh->GetDrawView()->SdrEndTextEdit();
82 }
83
84 pShell = SfxViewShell::GetNext(*pShell);
85 }
86 }
87}
88
89namespace sd {
90
91#define PIPETTE_RANGE 0
92
93using namespace ::com::sun::star::uno;
94using namespace ::com::sun::star::drawing;
95
97{
98 mpDrawView->SdrEndTextEdit();
99
100 try
101 {
102 Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
103 Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_SET_THROW );
104 sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
105 SdPage* pPage = nullptr;
106 std::vector<Reference<XDrawPage>> pagesToDelete;
107
108 GetView()->BegUndo(SdResId(STR_UNDO_DELETEPAGES));
109
110 for (sal_uInt16 i = 0; i < nPageCount; i++)
111 {
112 pPage = GetDoc()->GetSdPage(i, mePageKind);
113 sal_uInt16 nPageIndex = maTabControl->GetPagePos(pPage->getPageId());
114
117 bool bUseSlideSorter = pVShell != nullptr;
118
119 if((bUseSlideSorter && IsSelected(nPageIndex)) || (!bUseSlideSorter && pPage->IsSelected()))
120 {
121 EndTextEditOnPage(pPage->getPageId());
122 Reference< XDrawPage > xPage( xPages->getByIndex( nPageIndex ), UNO_QUERY_THROW );
123 pagesToDelete.push_back(xPage);
124 }
125 }
126 for (const auto &xPage: pagesToDelete)
127 {
128 xPages->remove(xPage);
129 }
130
131 GetView()->EndUndo();
132 }
133 catch( Exception& )
134 {
135 TOOLS_WARN_EXCEPTION( "sd", "SelectionManager::DeleteSelectedMasterPages()");
136 }
137}
138
140{
141 if(!GetLayerTabControl()) // #i87182#
142 {
143 OSL_ENSURE(false, "No LayerTabBar (!)");
144 return;
145 }
146
147 SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
148 sal_uInt16 nId = GetLayerTabControl()->GetCurPageId();
149 const OUString& rName = GetLayerTabControl()->GetLayerName(nId);
151 {
152 assert(false && "Standard layer may not be deleted.");
153 return;
154 }
155 const OUString& rDisplayName(GetLayerTabControl()->GetPageText(nId));
156 OUString aString(SdResId(STR_ASK_DELETE_LAYER));
157
158 // replace placeholder
159 aString = aString.replaceFirst("$", rDisplayName);
160
161 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
162 VclMessageType::Question, VclButtonsType::YesNo,
163 aString));
164 if (xQueryBox->run() == RET_YES)
165 {
166 const SdrLayer* pLayer = rAdmin.GetLayer(rName);
167 mpDrawView->DeleteLayer( pLayer->GetName() );
168
169 /* in order to redraw TabBar and Window; should be initiated later on by
170 a hint from Joe (as by a change if the layer order). */
171 // ( View::Notify() --> ViewShell::ResetActualLayer() )
172
173 mbIsLayerModeActive = false; // so that ChangeEditMode() does something
175 }
176}
177
179{
180 bool bRet = false;
181
182 if (!IsInputLocked() || (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE))
183 {
184 if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
185 && rKEvt.GetKeyCode().IsMod1()
186 && GetView()->IsTextEdit())
187 {
188 // this should be used for cursor travelling.
189 SdPage* pActualPage = GetActualPage();
190 const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
191 SdrTextObj* pCandidate = nullptr;
192
193 if(pActualPage && 1 == rMarkList.GetMarkCount())
194 {
195 SdrMark* pMark = rMarkList.GetMark(0);
196
197 // remember which object was the text in edit mode
198 SdrObject* pOldObj = pMark->GetMarkedSdrObj();
199
200 // end text edit now
202
203 // look for a new candidate, a successor of pOldObj
204 SdrObjListIter aIter(pActualPage, SdrIterMode::DeepNoGroups);
205 bool bDidVisitOldObject(false);
206
207 while(aIter.IsMore() && !pCandidate)
208 {
209 SdrObject* pObj = aIter.Next();
210
211 if(auto pSdrTextObj = DynCastSdrTextObj( pObj ))
212 {
213 SdrInventor nInv(pObj->GetObjInventor());
214 SdrObjKind nKnd(pObj->GetObjIdentifier());
215
216 if(SdrInventor::Default == nInv &&
217 (SdrObjKind::TitleText == nKnd || SdrObjKind::OutlineText == nKnd || SdrObjKind::Text == nKnd)
218 && bDidVisitOldObject)
219 {
220 pCandidate = pSdrTextObj;
221 }
222
223 if(pObj == pOldObj)
224 {
225 bDidVisitOldObject = true;
226 }
227 }
228 }
229 }
230
231 if(pCandidate)
232 {
233 // set the new candidate to text edit mode
234 GetView()->UnMarkAll();
235 GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
236
238 SID_ATTR_CHAR, SfxCallMode::ASYNCHRON);
239 }
240 else
241 {
242 // insert a new page with the same page layout
244 SID_INSERTPAGE_QUICK, SfxCallMode::ASYNCHRON);
245 }
246 }
247 else
248 {
249 bRet = ViewShell::KeyInput(rKEvt, pWin);
250 //If object is marked , the corresponding entry is set true , else
251 //the corresponding entry is set false .
252 if(KEY_TAB == rKEvt.GetKeyCode().GetCode()
253 || KEY_ESCAPE == rKEvt.GetKeyCode().GetCode())
254
255 {
257 }
258 }
259 if (!bRet && !mbReadOnly) // tdf#139804
260 {
261 bRet = GetView()->KeyInput(rKEvt, pWin);
262 }
263 }
264
265 return bRet;
266}
267
272 const Ruler& rRuler,
273 const MouseEvent& rMEvt)
274{
276
277 Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
278
279 if ( rRuler.GetExtraRect().Contains(rMEvt.GetPosPixel()) )
280 {
281 mpDrawView->BegSetPageOrg(aWPos);
282 mbIsRulerDrag = true;
283 }
284 else
285 {
286 // #i34536# if no guide-lines are visible yet, that show them
287 if( ! mpDrawView->IsHlplVisible())
288 mpDrawView->SetHlplVisible();
289
290 SdrHelpLineKind eKind;
291
292 if ( rMEvt.IsMod1() )
293 eKind = SdrHelpLineKind::Point;
294 else if ( rRuler.IsHorizontal() )
295 eKind = SdrHelpLineKind::Horizontal;
296 else
297 eKind = SdrHelpLineKind::Vertical;
298
299 mpDrawView->BegDragHelpLine(aWPos, eKind);
300 mbIsRulerDrag = true;
301 }
302}
303
305{
306 SfxViewFrame *pViewFrame = GetViewFrame();
307 if (!pViewFrame)
308 return;
309 SfxChildWindow* pWindow = pViewFrame->GetChildWindow( SID_NAVIGATOR );
310 if( pWindow )
311 {
312 SdNavigatorFloat* pNavWin = static_cast<SdNavigatorFloat*>( pWindow->GetWindow() );
313 if( pNavWin )
314 pNavWin->FreshTree( GetDoc() );
315 }
316 // sidebar version
317 SfxBindings& rBindings = pViewFrame->GetBindings();
318 rBindings.Invalidate(SID_NAVIGATOR_STATE, true);
319}
320
322 ::sd::Window* pWin)
323{
324 mbMouseButtonDown = true;
325 mbMouseSelecting = false;
326
327 // We have to check if a context menu is shown and we have an UI
328 // active inplace client. In that case we have to ignore the mouse
329 // button down event. Otherwise we would crash (context menu has been
330 // opened by inplace client and we would deactivate the inplace client,
331 // the context menu is closed by VCL asynchronously which in the end
332 // would work on deleted objects or the context menu has no parent anymore)
333 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
334 bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
335
336 if (bIsOleActive && vcl::IsInPopupMenuExecute())
337 return;
338
339 if ( IsInputLocked() )
340 return;
341
342 ViewShell::MouseButtonDown(rMEvt, pWin);
343
344 //If object is marked , the corresponding entry is set true ,
345 //else the corresponding entry is set false .
347 if (mbPipette)
348 {
349 SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
350 SvxBmpMask* pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : nullptr;
351 if (pBmpMask)
352 pBmpMask->PipetteClicked();
353 }
354}
355
357{
358 if ( IsMouseButtonDown() )
359 mbMouseSelecting = true;
360
361 if ( IsInputLocked() )
362 return;
363
364 if ( mpDrawView->IsAction() )
365 {
366 ::tools::Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
367
368 if ( !aOutputArea.Contains(rMEvt.GetPosPixel()) )
369 {
370 bool bInsideOtherWindow = false;
371
372 if (mpContentWindow)
373 {
374 aOutputArea = ::tools::Rectangle(Point(0,0),
375 mpContentWindow->GetOutputSizePixel());
376
377 Point aPos = mpContentWindow->GetPointerPosPixel();
378 if ( aOutputArea.Contains(aPos) )
379 bInsideOtherWindow = true;
380 }
381
382 if (! GetActiveWindow()->HasFocus ())
383 {
385 mpDrawView->BrkAction ();
386 return;
387 }
388 else if ( bInsideOtherWindow )
389 {
391 pWin->CaptureMouse ();
392 }
393 }
394 else if ( pWin != GetActiveWindow() )
395 pWin->CaptureMouse();
396 }
397
398 // Since the next MouseMove may execute a IsSolidDraggingNow() in
399 // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
400 // is needed it is necessary to set it here.
401 if (GetDoc())
402 {
404 mpDrawView->SetApplicationBackgroundColor( GetViewOptions().mnAppBackgroundColor );
405 }
406
407 ViewShell::MouseMove(rMEvt, pWin);
408
409 maMousePos = rMEvt.GetPosPixel();
410
411 ::tools::Rectangle aRect;
412
413 if ( mbIsRulerDrag )
414 {
416 mpDrawView->MovAction(aLogPos);
417 }
418
419 if ( mpDrawView->IsAction() )
420 {
421 mpDrawView->TakeActionRect(aRect);
422 aRect = GetActiveWindow()->LogicToPixel(aRect);
423 }
424 else
425 {
427 }
428
429 ShowMousePosInfo(aRect, pWin);
430
431 SvxBmpMask* pBmpMask = nullptr;
432 if (mbPipette && GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
433 {
434 SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
435 pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : nullptr;
436 }
437
438 if (!pBmpMask)
439 return;
440
441 const ::tools::Long nStartX = maMousePos.X() - PIPETTE_RANGE;
442 const ::tools::Long nEndX = maMousePos.X() + PIPETTE_RANGE;
443 const ::tools::Long nStartY = maMousePos.Y() - PIPETTE_RANGE;
444 const ::tools::Long nEndY = maMousePos.Y() + PIPETTE_RANGE;
445 ::tools::Long nRed = 0;
446 ::tools::Long nGreen = 0;
447 ::tools::Long nBlue = 0;
448 const double fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
449
450 for ( ::tools::Long nY = nStartY; nY <= nEndY; nY++ )
451 {
452 for( ::tools::Long nX = nStartX; nX <= nEndX; nX++ )
453 {
454 const Color aCol( pWin->GetOutDev()->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
455
456 nRed += aCol.GetRed();
457 nGreen += aCol.GetGreen();
458 nBlue += aCol.GetBlue();
459 }
460 }
461
462 pBmpMask->SetColor( Color( static_cast<sal_uInt8>( nRed / fDiv + .5 ),
463 static_cast<sal_uInt8>( nGreen / fDiv + .5 ),
464 static_cast<sal_uInt8>( nBlue / fDiv + .5 ) ) );
465}
466
468{
469 mbMouseButtonDown = false;
470
471 if ( !IsInputLocked() )
472 {
473 bool bIsSetPageOrg = mpDrawView->IsSetPageOrg();
474
475 if (mbIsRulerDrag)
476 {
477 ::tools::Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
478
479 if (aOutputArea.Contains(rMEvt.GetPosPixel()))
480 {
481 mpDrawView->EndAction();
482
483 if (bIsSetPageOrg)
484 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
485 }
486 else if (rMEvt.IsLeft() && bIsSetPageOrg)
487 {
488 mpDrawView->BrkAction();
489 SdPage* pPage = static_cast<SdPage*>( mpDrawView->GetSdrPageView()->GetPage() );
490 Point aOrg(pPage->GetLeftBorder(), pPage->GetUpperBorder());
491 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
492 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
493 }
494 else
495 {
496 mpDrawView->BrkAction();
497 }
498
500 mbIsRulerDrag = false;
501 }
502 else
503 ViewShell::MouseButtonUp(rMEvt, pWin);
504 //If object is marked , the corresponding entry is set true ,
505 //else the corresponding entry is set false .
507 }
508 mbMouseSelecting = false;
509}
510
512{
513 // The command event is send to the window after a possible context
514 // menu from an inplace client is closed. Now we have the chance to
515 // deactivate the inplace client without any problem regarding parent
516 // windows and code on the stack.
517 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
518 bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
519 if ( bIsOleActive && ( rCEvt.GetCommand() == CommandEventId::ContextMenu ))
520 {
521 // Deactivate OLE object
522 mpDrawView->UnmarkAll();
524 return;
525 }
526
527 if ( IsInputLocked() )
528 return;
529
530 if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
531 return;
532
533 const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
534
535 if( rCEvt.GetCommand() == CommandEventId::PasteSelection && !bNativeShow )
536 {
538
539 if( aDataHelper.GetTransferable().is() )
540 {
541 Point aPos;
542 sal_Int8 nDnDAction = DND_ACTION_COPY;
543
544 if( GetActiveWindow() )
545 aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
546
547 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, false ) )
548 {
549 INetBookmark aINetBookmark( "", "" );
550
551 if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
552 aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
553 ( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) &&
554 aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
555 ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) &&
556 aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
557 {
558 InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), "" );
559 }
560 }
561 }
562 }
563 else if( rCEvt.GetCommand() == CommandEventId::ContextMenu && !bNativeShow &&
564 pWin != nullptr && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
565 {
566 OUString aPopupId; // Resource name for popup menu
567
568 // is there a snap object under the cursor?
569 SdrPageView* pPV;
570 Point aMPos = pWin->PixelToLogic( maMousePos );
571 sal_uInt16 nHitLog = static_cast<sal_uInt16>(GetActiveWindow()->PixelToLogic(
572 Size(FuPoor::HITPIX, 0 ) ).Width());
573 sal_uInt16 nHelpLine;
574 // for gluepoints
575 SdrObject* pObj = nullptr;
576 sal_uInt16 nPickId = 0;
577 // for field command
578 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
579 const SvxFieldItem* pFldItem = nullptr;
580 if( pOLV )
581 pFldItem = pOLV->GetFieldAtSelection();
582
583 // helper line
584 if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow()->GetOutDev(), nHelpLine, pPV) )
585 {
586 ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(10, 10));
587 weld::Window* pParent = weld::GetPopupParent(*pWin, aRect);
588 ShowSnapLineContextMenu(pParent, aRect, *pPV, nHelpLine);
589 return;
590 }
591 // is gluepoint under cursor marked?
592 else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
593 mpDrawView->IsGluePointMarked( pObj, nPickId ) )
594 {
595 aPopupId = "gluepoint";
596 }
597 // field command?
598 else if( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) ||
599 nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ||
600 nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) ||
601 nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) ) )
602 {
603 LanguageType eLanguage( LANGUAGE_SYSTEM );
604
605 // Format popup with outliner language, if possible
606 if( pOLV->GetOutliner() )
607 {
608 ESelection aSelection( pOLV->GetSelection() );
609 eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
610 }
611
612 //fdo#44998 if the outliner has captured the mouse events release the lock
613 //so the SdFieldPopup can get them
614 pOLV->ReleaseMouse();
615 SdFieldPopup aFieldPopup(pFldItem->GetField(), eLanguage);
616
617 if ( rCEvt.IsMouseEvent() )
618 aMPos = rCEvt.GetMousePosPixel();
619 else
620 aMPos = Point( 20, 20 );
621 ::tools::Rectangle aRect(aMPos, Size(1, 1));
622 weld::Window* pParent = weld::GetPopupParent(*pWin, aRect);
623
624 aFieldPopup.Execute(pParent, aRect);
625
626 std::unique_ptr<SvxFieldData> pField(aFieldPopup.GetField());
627 if (pField)
628 {
629 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
630 // select field, so that it will be deleted on insert
631 ESelection aSel = pOLV->GetSelection();
632 bool bSel = true;
633 if( aSel.nStartPos == aSel.nEndPos )
634 {
635 bSel = false;
636 aSel.nEndPos++;
637 }
638 pOLV->SetSelection( aSel );
639
640 pOLV->InsertField( aFieldItem );
641
642 // reset selection back to original state
643 if( !bSel )
644 aSel.nEndPos--;
645 pOLV->SetSelection( aSel );
646 }
647 }
648 else
649 {
650 // is something selected?
651 if (mpDrawView->AreObjectsMarked() &&
652 mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
653 {
654 pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
655 if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != nullptr ) )
656 {
657 aPopupId = "bezier";
658 }
659 else
660 {
661 if( mpDrawView->GetTextEditObject() )
662 {
663 OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
664 Point aPos(rCEvt.GetMousePosPixel());
665
666 if ( pOutlinerView )
667 {
668 if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
669 ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
670 {
671 // Popup for Online-Spelling now handled by DrawDocShell
672 Link<SpellCallbackInfo&,void> aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
673
674 if( !rCEvt.IsMouseEvent() )
675 {
676 aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
677 }
678 // While showing the spell context menu
679 // we lock the input so that another
680 // context menu can not be opened during
681 // that time (crash #i43235#). In order
682 // to not lock the UI completely we
683 // first release the mouse.
685 LockInput();
686 pOutlinerView->ExecuteSpellPopup(aPos, aLink);
687 pOutlinerView->GetEditView().Invalidate();
688 UnlockInput();
689 }
690 else
691 {
692 if( (pObj->GetObjInventor() == SdrInventor::Default) && (pObj->GetObjIdentifier() == SdrObjKind::Table) )
693 {
694 aPopupId = "table";
695 }
696 else
697 {
698 aPopupId = "drawtext";
699 }
700 }
701 }
702 }
703 else
704 {
705 SdrInventor nInv = pObj->GetObjInventor();
707
708 if (nInv == SdrInventor::Default)
709 {
710 switch ( nId )
711 {
712 case SdrObjKind::OutlineText:
713 case SdrObjKind::Caption:
714 case SdrObjKind::TitleText:
715 case SdrObjKind::Text:
716 aPopupId = "textbox";
717 break;
718
719 case SdrObjKind::PathLine:
720 case SdrObjKind::PolyLine:
721 aPopupId = "curve";
722 break;
723
724 case SdrObjKind::FreehandLine:
725 case SdrObjKind::Edge:
726 aPopupId = "connector";
727 break;
728
729 case SdrObjKind::Line:
730 aPopupId = "line";
731 break;
732
733 case SdrObjKind::Measure:
734 aPopupId = "measure";
735 break;
736
737 case SdrObjKind::Rectangle:
738 case SdrObjKind::CircleOrEllipse:
739 case SdrObjKind::FreehandFill:
740 case SdrObjKind::PathFill:
741 case SdrObjKind::Polygon:
742 case SdrObjKind::CircleSection:
743 case SdrObjKind::CircleArc:
744 case SdrObjKind::CircleCut:
745 case SdrObjKind::CustomShape:
746 aPopupId = "draw";
747 break;
748
749 case SdrObjKind::Group:
750 aPopupId = "group";
751 break;
752
753 case SdrObjKind::Graphic:
754 aPopupId = "graphic";
755 break;
756
757 case SdrObjKind::OLE2:
758 aPopupId = "oleobject";
759 break;
760 case SdrObjKind::Media:
761 aPopupId = "media";
762 break;
763 case SdrObjKind::Table:
764 aPopupId = "table";
765 break;
766 default: ;
767 }
768 }
769 else if( nInv == SdrInventor::E3d )
770 {
771 if( nId == SdrObjKind::E3D_Scene )
772 {
773 if( !mpDrawView->IsGroupEntered() )
774 aPopupId = "3dscene";
775 else
776 aPopupId = "3dscene2";
777 }
778 else
779 aPopupId = "3dobject";
780 }
781 else if( nInv == SdrInventor::FmForm )
782 {
783 aPopupId = "form";
784 }
785 }
786 }
787 }
788
789 // multiple selection
790 else if (mpDrawView->AreObjectsMarked() &&
791 mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
792 {
793 aPopupId = "multiselect";
794 }
795
796 // nothing selected
797 else
798 {
799 aPopupId = "page";
800 }
801 }
802 // show Popup-Menu
803 if (!aPopupId.isEmpty())
804 {
806
807 // tdf#137445 at this context menu popup time get what the
808 // DisableEditHyperlink would be for this position
809 bool bShouldDisableEditHyperlink = ShouldDisableEditHyperlink();
810
811 if(rCEvt.IsMouseEvent())
812 GetViewFrame()->GetDispatcher()->ExecutePopup( aPopupId );
813 else
814 {
815 //don't open contextmenu at mouse position if not opened via mouse
816
817 //middle of the window if nothing is marked
818 Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
819 ,GetActiveWindow()->GetSizePixel().Height()/2);
820
821 //middle of the bounding rect if something is marked
822 if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
823 {
824 ::tools::Rectangle aMarkRect;
825 mpDrawView->GetMarkedObjectList().TakeBoundRect(nullptr,aMarkRect);
826 aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
827
828 //move the point into the visible window area
829 if( aMenuPos.X() < 0 )
830 aMenuPos.setX( 0 );
831 if( aMenuPos.Y() < 0 )
832 aMenuPos.setY( 0 );
833 if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
834 aMenuPos.setX( GetActiveWindow()->GetSizePixel().Width() );
835 if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
836 aMenuPos.setY( GetActiveWindow()->GetSizePixel().Height() );
837 }
838
839 //open context menu at that point
840 GetViewFrame()->GetDispatcher()->ExecutePopup( aPopupId, GetActiveWindow(), &aMenuPos );
841 }
842
843 if (!bShouldDisableEditHyperlink)
844 {
845 SfxBindings& rBindings = GetViewFrame()->GetBindings();
846 // tdf#137445 set what the menu popup state for this was
848 // ensure moAtContextMenu_DisableEditHyperlink will be cleared
849 // in the case that EditHyperlink is not dispatched by the menu
850 rBindings.Invalidate(SID_EDIT_HYPERLINK);
851 }
852 }
853 }
854 else
855 {
856 ViewShell::Command(rCEvt, pWin);
857 }
858}
859
861{
863}
864
865void DrawViewShell::ShowMousePosInfo(const ::tools::Rectangle& rRect,
866 ::sd::Window const * pWin)
867{
868 if (mbHasRulers && pWin )
869 {
870 RulerLine pHLines[2];
871 RulerLine pVLines[2];
872 ::tools::Long nHOffs = 0;
873 ::tools::Long nVOffs = 0;
874 sal_uInt16 nCnt;
875
877 mpHorizontalRuler->SetLines();
878
879 if (mpVerticalRuler)
880 mpVerticalRuler->SetLines();
881
883 {
884 nHOffs = mpHorizontalRuler->GetNullOffset() +
885 mpHorizontalRuler->GetPageOffset();
886 }
887
888 if (mpVerticalRuler)
889 {
890 nVOffs = mpVerticalRuler->GetNullOffset() +
891 mpVerticalRuler->GetPageOffset();
892 }
893
894 nCnt = 1;
895 pHLines[0].nPos = rRect.Left() - nHOffs;
896 pVLines[0].nPos = rRect.Top() - nVOffs;
897
898 if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
899 {
900 pHLines[1].nPos = rRect.Right() - nHOffs;
901 pVLines[1].nPos = rRect.Bottom() - nVOffs;
902 nCnt++;
903 }
904
906 mpHorizontalRuler->SetLines(nCnt, pHLines);
907 if (mpVerticalRuler)
908 mpVerticalRuler->SetLines(nCnt, pVLines);
909 }
910
911 // display with coordinates in StatusBar
912 OSL_ASSERT (GetViewShell()!=nullptr);
913 if ( GetViewShell()->GetUIActiveClient() )
914 return;
915
917 SID_CONTEXT, SID_CONTEXT,
918 SID_ATTR_POSITION, SID_ATTR_SIZE> aSet(GetPool());
919
920 GetStatusBarState(aSet);
921
922 aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
923
924 SfxBindings& rBindings = GetViewFrame()->GetBindings();
925 rBindings.SetState(aSet);
926 rBindings.Invalidate(SID_CONTEXT);
927 rBindings.Invalidate(SID_ATTR_POSITION);
928 rBindings.Invalidate(SID_ATTR_SIZE);
929}
930
932{
933 mnLockCount++;
934}
935
937{
938 DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
939 if ( mnLockCount )
940 mnLockCount--;
941}
942
943void DrawViewShell::ShowSnapLineContextMenu(weld::Window* pParent, const ::tools::Rectangle& rRect,
944 SdrPageView& rPageView, const sal_uInt16 nSnapLineIndex)
945{
946 const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
947 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/simpress/ui/snapmenu.ui"));
948 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
949
950 if (rHelpLine.GetKind() == SdrHelpLineKind::Point)
951 {
952 xMenu->append(OUString::number(SID_SET_SNAPITEM), SdResId(STR_POPUP_EDIT_SNAPPOINT));
953 xMenu->append_separator("separator");
954 xMenu->append(OUString::number(SID_DELETE_SNAPITEM), SdResId(STR_POPUP_DELETE_SNAPPOINT));
955 }
956 else
957 {
958 xMenu->append(OUString::number(SID_SET_SNAPITEM), SdResId(STR_POPUP_EDIT_SNAPLINE));
959 xMenu->append_separator("separator");
960 xMenu->append(OUString::number(SID_DELETE_SNAPITEM), SdResId(STR_POPUP_DELETE_SNAPLINE));
961 }
962
963 const int nResult = xMenu->popup_at_rect(pParent, rRect).toInt32();
964 switch (nResult)
965 {
966 case SID_SET_SNAPITEM:
967 {
968 SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
969 const SfxPoolItem* aArguments[] = {&aHelpLineItem, nullptr};
971 SID_SET_SNAPITEM,
972 SfxCallMode::SLOT,
973 aArguments);
974 }
975 break;
976
977 case SID_DELETE_SNAPITEM:
978 {
979 rPageView.DeleteHelpLine(nSnapLineIndex);
980 }
981 break;
982
983 default:
984 break;
985 }
986}
987
988} // end of namespace sd
989
990/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nPageId
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
vcl::Cursor * GetCursor() const
void Invalidate()
bool KeyInput(const KeyEvent &rKEvt, vcl::Window *pWin) override
const OUString & GetDescription() const
const OUString & GetURL() const
const vcl::KeyCode & GetKeyCode() const
bool IsMod1() const
const Point & GetPosPixel() const
bool IsLeft() const
void ReleaseMouse()
void SetSelection(const ESelection &)
void InsertField(const SvxFieldItem &rFld)
bool IsWrongSpelledWordAtPos(const Point &rPosPixel)
const SvxFieldItem * GetFieldAtSelection() const
ESelection GetSelection() const
void ExecuteSpellPopup(const Point &rPosPixel, const Link< SpellCallbackInfo &, void > &rCallBack)
Outliner * GetOutliner() const
bool IsCursorAtWrongSpelledWord()
EditView & GetEditView() const
LanguageType GetLanguage(sal_Int32 nPara, sal_Int32 nPos) const
Color GetPixel(const Point &rPt) const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
PopupMenu for editing field-commands.
Definition: sdpopup.hxx:31
void Execute(weld::Window *pParent, const tools::Rectangle &rRect)
Definition: sdpopup.cxx:156
SvxFieldData * GetField()
Returns a new field, owned by caller.
Definition: sdpopup.cxx:180
bool IsSelected() const
Definition: sdpage.hxx:208
sal_uInt16 getPageId() const
Definition: sdpage.hxx:376
void BegUndo()
void EndUndo()
SdrHelpLineKind GetKind() const
SdrLayer * GetLayer(sal_uInt16 i)
const OUString & GetName() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
void UnMarkAll(SdrPageView const *pPV=nullptr)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
const SdrLayerAdmin & GetLayerAdmin() const
SdrObject * Next()
bool IsMore() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
const SdrHelpLineList & GetHelpLines() const
void DeleteHelpLine(sal_uInt16 nNum)
sal_Int32 GetUpperBorder() const
sal_Int32 GetLeftBorder() const
void SetState(const SfxItemSet &rSet)
void Invalidate(sal_uInt16 nId)
vcl::Window * GetWindow() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
bool IsObjectInPlaceActive() const
SfxItemPool & GetPool() const
SfxViewShell * GetViewShell() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxChildWindow * GetChildWindow(sal_uInt16)
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
SfxInPlaceClient * GetIPClient() const
void SetColor(const Color &rColor)
void PipetteClicked()
const SvxFieldData * GetField() const
sal_uInt16 GetCurPageId() const
static TransferableDataHelper CreateFromPrimarySelection()
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk) const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
virtual bool KeyInput(const KeyEvent &rKEvt, ::sd::Window *pWin) override
Definition: drviews4.cxx:178
void EnableEditHyperlink()
force "Edit Hyperlink" to true, with the expectation that SID_EDIT_HYPERLINK is later Invalidated to ...
Definition: drviews4.cxx:860
void GetStatusBarState(SfxItemSet &rSet)
Definition: drviewsa.cxx:533
void DeleteActualLayer()
Definition: drviews4.cxx:139
void ShowSnapLineContextMenu(weld::Window *pParent, const ::tools::Rectangle &rRect, SdrPageView &rPageView, const sal_uInt16 nSnapLineIndex)
Show the context menu for snap lines and points.
Definition: drviews4.cxx:943
bool IsSelected(sal_uInt16 nPage)
Definition: drviews1.cxx:814
virtual void MouseButtonDown(const MouseEvent &rMEvt, ::sd::Window *pWin) override
Definition: drviews4.cxx:321
virtual SdPage * getCurrentPage() const override
inherited from sd::ViewShell
Definition: drviews1.cxx:636
EditMode GetEditMode() const
std::unique_ptr< DrawView > mpDrawView
void FreshNavigatrTree()
Definition: drviews4.cxx:304
void DeleteActualPage()
Definition: drviews4.cxx:96
const SdViewOptions & GetViewOptions() const
VclPtr< TabControl > maTabControl
virtual void ChangeEditMode(EditMode eMode, bool bIsLayerModeActive)
Set status (enabled/disabled) of menu SfxSlots.
Definition: drviews1.cxx:333
void StartRulerDrag(const Ruler &rRuler, const MouseEvent &rMEvt)
Start with Drag from ruler (helper lines, origin)
Definition: drviews4.cxx:271
bool mbIsLayerModeActive
This flag controls whether the layer mode is active, i.e.
bool IsInputLocked() const
SD_DLLPUBLIC LayerTabBar * GetLayerTabControl()
Return a pointer to the tab control for layers.
Definition: drviews5.cxx:636
virtual SdPage * GetActualPage() override
virtual void MouseButtonUp(const MouseEvent &rMEvt, ::sd::Window *pWin) override
Definition: drviews4.cxx:467
DrawView * GetDrawView() const
void ShowMousePosInfo(const ::tools::Rectangle &rRect, ::sd::Window const *pWin)
Definition: drviews4.cxx:865
void InsertURLField(const OUString &rURL, const OUString &rText, const OUString &rTarget)
Definition: drviewse.cxx:1481
void ConfigureAppBackgroundColor(svtools::ColorConfig *pColorConfig=nullptr)
Definition: drviewsk.cxx:45
virtual void MouseMove(const MouseEvent &rMEvt, ::sd::Window *pWin) override
Definition: drviews4.cxx:356
static bool mbPipette
void SelectionHasChanged()
Called, if state of selection of view is changed.
Definition: drviews1.cxx:156
std::optional< bool > moAtContextMenu_DisableEditHyperlink
virtual void Command(const CommandEvent &rCEvt, ::sd::Window *pWin) override
Definition: drviews4.cxx:511
bool IsMouseButtonDown() const
bool ShouldDisableEditHyperlink() const
return true if "Edit Hyperlink" in context menu should be disabled
Definition: drviews7.cxx:284
static const int HITPIX
Definition: fupoor.hxx:50
OUString GetLayerName(sal_uInt16 nPageId) const
Definition: LayerTabBar.cxx:90
static bool IsRealNameOfStandardLayer(std::u16string_view rName)
bool IsHorizontal() const
Definition: Ruler.hxx:46
void FreshTree(const SdDrawDocument *pDoc)
static bool IsRunning(ViewShellBase const &rBase)
returns true if there is a running presentation for the given ViewShellBase
Definition: slideshow.cxx:208
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
virtual bool KeyInput(const KeyEvent &rKEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:391
VclPtr< SvxRuler > mpHorizontalRuler
Horizontal ruler is not shown by default.
Definition: ViewShell.hxx:441
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
virtual void MouseMove(const MouseEvent &rMEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:551
virtual void Command(const CommandEvent &rCEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:621
VclPtr< SvxRuler > mpVerticalRuler
Vertical ruler is not shown by default.
Definition: ViewShell.hxx:443
virtual void MouseButtonUp(const MouseEvent &rMEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:584
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
::sd::View * GetView() const
Definition: ViewShell.hxx:144
virtual void MouseButtonDown(const MouseEvent &rMEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:458
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
VclPtr< sd::Window > mpContentWindow
Window inside the rulers and scroll bars that shows a view of the document.
Definition: ViewShell.hxx:434
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
bool HasCurrentFunction() const
Definition: ViewShell.hxx:252
bool mbHasRulers
This flag controls whether the rulers are visible.
Definition: ViewShell.hxx:448
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
SD_DLLPUBLIC SlideSorter & GetSlideSorter() const
constexpr Point Center() const
bool Contains(const Point &rPOINT) const
const Point & GetPos() const
bool IsMod1() const
sal_uInt16 GetCode() const
Point LogicToPixel(const Point &rLogicPt) const
::OutputDevice const * GetOutDev() const
void ReleaseMouse()
Point PixelToLogic(const Point &rDevicePt) const
void CaptureMouse()
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define PIPETTE_RANGE
Definition: drviews4.cxx:91
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
Sequence< PropertyValue > aArguments
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_TAB
#define LANGUAGE_SYSTEM
@ Exception
int i
long Long
bool IsInPopupMenuExecute()
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
sal_Int16 nId
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
sal_Int32 nStartPara
sal_Int32 nEndPos
sal_Int32 nStartPos
tools::Long nPos
SdrHelpLineKind
SdrInventor
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SdrObjKind
#define DND_ACTION_COPY
unsigned char sal_uInt8
signed char sal_Int8
RET_YES