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