/src/libreoffice/sd/source/ui/view/viewshel.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 <framework/FrameworkHelper.hxx> |
21 | | #include <framework/ViewShellWrapper.hxx> |
22 | | #include <framework/ConfigurationController.hxx> |
23 | | #include <memory> |
24 | | #include <ViewShell.hxx> |
25 | | #include <ViewShellImplementation.hxx> |
26 | | #include <createtableobjectbar.hxx> |
27 | | |
28 | | #include <ViewShellBase.hxx> |
29 | | #include <ShellFactory.hxx> |
30 | | #include <DrawController.hxx> |
31 | | #include <LayerTabBar.hxx> |
32 | | #include <Outliner.hxx> |
33 | | #include <ResourceId.hxx> |
34 | | |
35 | | #include <sal/log.hxx> |
36 | | #include <sfx2/viewfrm.hxx> |
37 | | #include <sfx2/bindings.hxx> |
38 | | #include <sfx2/dispatch.hxx> |
39 | | #include <vcl/commandevent.hxx> |
40 | | #include <vcl/svapp.hxx> |
41 | | #include <svl/eitem.hxx> |
42 | | #include <svx/ruler.hxx> |
43 | | #include <svx/svxids.hrc> |
44 | | #include <svx/fmshell.hxx> |
45 | | #include <WindowUpdater.hxx> |
46 | | #include <sdxfer.hxx> |
47 | | |
48 | | #include <app.hrc> |
49 | | |
50 | | #include <OutlineView.hxx> |
51 | | #include <DrawViewShell.hxx> |
52 | | #include <DrawDocShell.hxx> |
53 | | #include <slideshow.hxx> |
54 | | #include <drawdoc.hxx> |
55 | | #include <sdpage.hxx> |
56 | | #include <zoomlist.hxx> |
57 | | #include <FrameView.hxx> |
58 | | #include <BezierObjectBar.hxx> |
59 | | #include <TextObjectBar.hxx> |
60 | | #include <GraphicObjectBar.hxx> |
61 | | #include <MediaObjectBar.hxx> |
62 | | #include <SlideSorter.hxx> |
63 | | #include <SlideSorterViewShell.hxx> |
64 | | #include <ViewShellManager.hxx> |
65 | | #include <FormShellManager.hxx> |
66 | | #include <EventMultiplexer.hxx> |
67 | | #include <svx/extrusionbar.hxx> |
68 | | #include <svx/fontworkbar.hxx> |
69 | | #include <svx/svdoutl.hxx> |
70 | | #include <tools/svborder.hxx> |
71 | | #include <comphelper/lok.hxx> |
72 | | |
73 | | #include <svl/slstitm.hxx> |
74 | | #include <sfx2/request.hxx> |
75 | | #include <SpellDialogChildWindow.hxx> |
76 | | #include <controller/SlideSorterController.hxx> |
77 | | #include <controller/SlsPageSelector.hxx> |
78 | | #include <controller/SlsSelectionObserver.hxx> |
79 | | #include <view/SlideSorterView.hxx> |
80 | | |
81 | | #include <basegfx/utils/zoomtools.hxx> |
82 | | |
83 | | #include <officecfg/Office/Draw.hxx> |
84 | | |
85 | | #include <Window.hxx> |
86 | | #include <fupoor.hxx> |
87 | | #include <futext.hxx> |
88 | | |
89 | | #include <editeng/numitem.hxx> |
90 | | #include <editeng/eeitem.hxx> |
91 | | #include <editeng/editview.hxx> |
92 | | #include <editeng/editeng.hxx> |
93 | | #include <editeng/editund2.hxx> |
94 | | #include <svl/itempool.hxx> |
95 | | #include <svl/intitem.hxx> |
96 | | #include <svl/poolitem.hxx> |
97 | | #include <strings.hxx> |
98 | | #include <sdmod.hxx> |
99 | | #include <AccessibleDocumentViewBase.hxx> |
100 | | |
101 | | #include <framework/Configuration.hxx> |
102 | | #include <framework/AbstractView.hxx> |
103 | | #include <com/sun/star/frame/XFrame.hpp> |
104 | | |
105 | | using namespace ::com::sun::star; |
106 | | using namespace ::com::sun::star::uno; |
107 | | using namespace ::com::sun::star::presentation; |
108 | | |
109 | | namespace { |
110 | | |
111 | | class ViewShellObjectBarFactory |
112 | | : public ::sd::ShellFactory<SfxShell> |
113 | | { |
114 | | public: |
115 | | explicit ViewShellObjectBarFactory (::sd::ViewShell& rViewShell); |
116 | | virtual SfxShell* CreateShell( ::sd::ShellId nId ) override; |
117 | | virtual void ReleaseShell (SfxShell* pShell) override; |
118 | | private: |
119 | | ::sd::ViewShell& mrViewShell; |
120 | | }; |
121 | | |
122 | | } // end of anonymous namespace |
123 | | |
124 | | namespace sd { |
125 | | |
126 | | /// When true, scrolling to bottom of a page switches to the next page. |
127 | | bool ViewShell::CanPanAcrossPages() const |
128 | 0 | { |
129 | 0 | return dynamic_cast<const DrawViewShell*>(this) && mpContentWindow && |
130 | 0 | mpContentWindow->GetVisibleHeight() < 1.0; |
131 | 0 | } |
132 | | |
133 | | bool ViewShell::IsPageFlipMode() const |
134 | 0 | { |
135 | 0 | return dynamic_cast< const DrawViewShell *>( this ) != nullptr && mpContentWindow && |
136 | 0 | mpContentWindow->GetVisibleHeight() >= 1.0; |
137 | 0 | } |
138 | | |
139 | | SfxViewFrame* ViewShell::GetViewFrame() const |
140 | 0 | { |
141 | 0 | const SfxViewShell* pViewShell = GetViewShell(); |
142 | 0 | if (pViewShell != nullptr) |
143 | 0 | { |
144 | 0 | return &pViewShell->GetViewFrame(); |
145 | 0 | } |
146 | 0 | else |
147 | 0 | { |
148 | 0 | OSL_ASSERT (GetViewShell()!=nullptr); |
149 | 0 | return nullptr; |
150 | 0 | } |
151 | 0 | } |
152 | | |
153 | | /// declare SFX-Slotmap and standard interface |
154 | | |
155 | | ViewShell::ViewShell( vcl::Window* pParentWindow, ViewShellBase& rViewShellBase) |
156 | 0 | : SfxShell(&rViewShellBase) |
157 | 0 | , mbHasRulers(false) |
158 | 0 | , mpActiveWindow(nullptr) |
159 | 0 | , mpView(nullptr) |
160 | 0 | , mpFrameView(nullptr) |
161 | 0 | , mpZoomList(new ZoomList( *this )) |
162 | 0 | , mfLastZoomScale(0) |
163 | 0 | , mbStartShowWithDialog(false) |
164 | 0 | , mnPrintedHandoutPageNum(1) |
165 | 0 | , mnPrintedHandoutPageCount(0) |
166 | 0 | , meShellType(ST_NONE) |
167 | 0 | , mpImpl(new Implementation(*this)) |
168 | 0 | , mpParentWindow(pParentWindow) |
169 | 0 | , mpWindowUpdater(new ::sd::WindowUpdater()) |
170 | 0 | { |
171 | 0 | OSL_ASSERT (GetViewShell()!=nullptr); |
172 | |
|
173 | 0 | if (IsMainViewShell()) |
174 | 0 | GetDocSh()->Connect (this); |
175 | |
|
176 | 0 | mpContentWindow.reset(VclPtr< ::sd::Window >::Create(GetParentWindow())); |
177 | 0 | SetActiveWindow (mpContentWindow.get()); |
178 | |
|
179 | 0 | GetParentWindow()->SetBackground(Application::GetSettings().GetStyleSettings().GetFaceColor()); |
180 | 0 | mpContentWindow->SetBackground (Wallpaper()); |
181 | 0 | mpContentWindow->SetCenterAllowed(true); |
182 | 0 | mpContentWindow->SetViewShell(this); |
183 | 0 | mpContentWindow->SetPosSizePixel( |
184 | 0 | GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel()); |
185 | |
|
186 | 0 | if ( ! GetDocSh()->IsPreview()) |
187 | 0 | { |
188 | | // Create scroll bars and the filler between the scroll bars. |
189 | 0 | mpHorizontalScrollBar.reset (VclPtr<ScrollAdaptor>::Create(GetParentWindow(), true)); |
190 | 0 | mpHorizontalScrollBar->EnableRTL (false); |
191 | 0 | mpHorizontalScrollBar->SetRange(Range(0, 32000)); |
192 | 0 | mpHorizontalScrollBar->SetScrollHdl(LINK(this, ViewShell, HScrollHdl)); |
193 | |
|
194 | 0 | mpVerticalScrollBar.reset (VclPtr<ScrollAdaptor>::Create(GetParentWindow(), false)); |
195 | 0 | mpVerticalScrollBar->SetRange(Range(0, 32000)); |
196 | 0 | mpVerticalScrollBar->SetScrollHdl(LINK(this, ViewShell, VScrollHdl)); |
197 | 0 | } |
198 | |
|
199 | 0 | SetName (u"ViewShell"_ustr); |
200 | |
|
201 | 0 | GetDoc()->StartOnlineSpelling(false); |
202 | |
|
203 | 0 | mpWindowUpdater->SetDocument (GetDoc()); |
204 | | |
205 | | // Re-initialize the spell dialog. |
206 | 0 | ::sd::SpellDialogChildWindow* pSpellDialog = |
207 | 0 | static_cast< ::sd::SpellDialogChildWindow*> ( |
208 | 0 | GetViewFrame()->GetChildWindow ( |
209 | 0 | ::sd::SpellDialogChildWindow::GetChildWindowId())); |
210 | 0 | if (pSpellDialog != nullptr) |
211 | 0 | pSpellDialog->InvalidateSpellDialog(); |
212 | | |
213 | | // Register the sub shell factory. |
214 | 0 | mpImpl->mpSubShellFactory = std::make_shared<ViewShellObjectBarFactory>(*this); |
215 | 0 | GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory); |
216 | | |
217 | | // Compare size of all pages to set SdDrawDocument's mbResizeAllPages after document load |
218 | | // instead of setting it true unconditionally. |
219 | 0 | sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(PageKind::Standard); |
220 | 0 | if (nPageCnt > 0) |
221 | 0 | { |
222 | 0 | Size aSize1 = GetDoc()->GetSdPage(0, PageKind::Standard)->GetSize(); |
223 | |
|
224 | 0 | for (sal_uInt16 i = 1; i < nPageCnt; i++) |
225 | 0 | { |
226 | 0 | Size aSize2 = GetDoc()->GetSdPage(i, PageKind::Standard)->GetSize(); |
227 | 0 | if (aSize1 != aSize2) |
228 | 0 | GetDoc()->SetResizeAllPages(false); |
229 | 0 | } |
230 | 0 | } |
231 | 0 | } |
232 | | |
233 | | ViewShell::~ViewShell() |
234 | 0 | { |
235 | | // Keep the content window from accessing in its destructor the |
236 | | // WindowUpdater. |
237 | 0 | if (mpContentWindow) |
238 | 0 | suppress_fun_call_w_exception(mpContentWindow->SetViewShell(nullptr)); |
239 | |
|
240 | 0 | mpZoomList.reset(); |
241 | |
|
242 | 0 | mpLayerTabBar.disposeAndClear(); |
243 | |
|
244 | 0 | if (mpImpl->mpSubShellFactory) |
245 | 0 | GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory( |
246 | 0 | this,mpImpl->mpSubShellFactory); |
247 | |
|
248 | 0 | if (mpContentWindow) |
249 | 0 | { |
250 | 0 | SAL_INFO( |
251 | 0 | "sd.view", |
252 | 0 | "destroying mpContentWindow at " << mpContentWindow.get() |
253 | 0 | << " with parent " << mpContentWindow->GetParent()); |
254 | 0 | mpContentWindow.disposeAndClear(); |
255 | 0 | } |
256 | | |
257 | 0 | mpVerticalRuler.disposeAndClear(); |
258 | 0 | mpHorizontalRuler.disposeAndClear(); |
259 | 0 | mpVerticalScrollBar.disposeAndClear(); |
260 | 0 | mpHorizontalScrollBar.disposeAndClear(); |
261 | 0 | } |
262 | | |
263 | | void ViewShell::doShow() |
264 | 0 | { |
265 | 0 | mpContentWindow->Show(); |
266 | 0 | static_cast< vcl::Window*>(mpContentWindow.get())->Resize(); |
267 | 0 | SAL_INFO( |
268 | 0 | "sd.view", |
269 | 0 | "content window has size " << mpContentWindow->GetSizePixel().Width() |
270 | 0 | << " " << mpContentWindow->GetSizePixel().Height()); |
271 | | |
272 | 0 | if ( ! GetDocSh()->IsPreview()) |
273 | 0 | { |
274 | | // Show scroll bars |
275 | 0 | mpHorizontalScrollBar->Show(); |
276 | |
|
277 | 0 | mpVerticalScrollBar->Show(); |
278 | 0 | maScrBarWH = Size( |
279 | 0 | mpVerticalScrollBar->GetSizePixel().Width(), |
280 | 0 | mpHorizontalScrollBar->GetSizePixel().Height()); |
281 | 0 | } |
282 | |
|
283 | 0 | GetParentWindow()->Show(); |
284 | 0 | } |
285 | | |
286 | | void ViewShell::Init (bool bIsMainViewShell) |
287 | 0 | { |
288 | 0 | mpImpl->mbIsInitialized = true; |
289 | 0 | SetIsMainViewShell(bIsMainViewShell); |
290 | 0 | if (bIsMainViewShell) |
291 | 0 | SetActiveWindow (mpContentWindow.get()); |
292 | 0 | } |
293 | | |
294 | | void ViewShell::Exit() |
295 | 0 | { |
296 | 0 | sd::View* pView = GetView(); |
297 | 0 | if (pView!=nullptr && pView->IsTextEdit()) |
298 | 0 | { |
299 | 0 | pView->SdrEndTextEdit(); |
300 | 0 | pView->UnmarkAll(); |
301 | 0 | } |
302 | |
|
303 | 0 | Deactivate (true); |
304 | |
|
305 | 0 | if (IsMainViewShell()) |
306 | 0 | GetDocSh()->Disconnect(this); |
307 | |
|
308 | 0 | SetIsMainViewShell(false); |
309 | 0 | } |
310 | | |
311 | | /** |
312 | | * set focus to working window |
313 | | */ |
314 | | void ViewShell::Activate(bool bIsMDIActivate) |
315 | 0 | { |
316 | | // Do not forward to SfxShell::Activate() |
317 | | |
318 | | /* According to MI, nobody is allowed to call GrabFocus, who does not |
319 | | exactly know from which window the focus is grabbed. Since Activate() |
320 | | is sent sometimes asynchronous, it can happen, that the wrong window |
321 | | gets the focus. */ |
322 | |
|
323 | 0 | if (mpHorizontalRuler) |
324 | 0 | mpHorizontalRuler->SetActive(); |
325 | 0 | if (mpVerticalRuler) |
326 | 0 | mpVerticalRuler->SetActive(); |
327 | |
|
328 | 0 | if (bIsMDIActivate) |
329 | 0 | { |
330 | | // thus, the Navigator will also get a current status |
331 | 0 | SfxBoolItem aItem( SID_NAVIGATOR_INIT, true ); |
332 | 0 | if (GetDispatcher() != nullptr) |
333 | 0 | { |
334 | 0 | SfxCallMode nCall = SfxCallMode::RECORD; |
335 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
336 | 0 | { |
337 | | // Make sure the LOK case doesn't dispatch async events while switching views, that |
338 | | // would lead to a loop, see SfxHintPoster::DoEvent_Impl(). |
339 | 0 | nCall |= SfxCallMode::SYNCHRON; |
340 | 0 | } |
341 | 0 | else |
342 | 0 | { |
343 | 0 | nCall |= SfxCallMode::ASYNCHRON; |
344 | 0 | } |
345 | 0 | GetDispatcher()->ExecuteList( |
346 | 0 | SID_NAVIGATOR_INIT, |
347 | 0 | nCall, |
348 | 0 | { &aItem }); |
349 | 0 | } |
350 | |
|
351 | 0 | SfxViewShell* pViewShell = GetViewShell(); |
352 | 0 | assert(pViewShell!=nullptr); |
353 | 0 | SfxBindings& rBindings = pViewShell->GetViewFrame().GetBindings(); |
354 | 0 | rBindings.Invalidate( SID_3D_STATE, true ); |
355 | |
|
356 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
357 | 0 | if (xSlideShow.is() && xSlideShow->isRunning()) //IASS |
358 | 0 | { |
359 | 0 | bool bSuccess = xSlideShow->activate(GetViewShellBase()); |
360 | 0 | assert(bSuccess && "can only return false with a PresentationViewShell"); (void)bSuccess; |
361 | 0 | } |
362 | |
|
363 | 0 | if(HasCurrentFunction()) |
364 | 0 | GetCurrentFunction()->Activate(); |
365 | |
|
366 | 0 | if(!GetDocSh()->IsUIActive()) |
367 | 0 | UpdatePreview( GetActualPage() ); |
368 | 0 | } |
369 | |
|
370 | 0 | ReadFrameViewData( mpFrameView ); |
371 | |
|
372 | 0 | if (IsMainViewShell()) |
373 | 0 | GetDocSh()->Connect(this); |
374 | 0 | } |
375 | | |
376 | | void ViewShell::UIActivating( SfxInPlaceClient* ) |
377 | 0 | { |
378 | 0 | OSL_ASSERT (GetViewShell()!=nullptr); |
379 | 0 | GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed(); |
380 | 0 | } |
381 | | |
382 | | void ViewShell::UIDeactivated( SfxInPlaceClient* ) |
383 | 0 | { |
384 | 0 | OSL_ASSERT (GetViewShell()!=nullptr); |
385 | 0 | GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed(); |
386 | 0 | if ( GetDrawView() ) |
387 | 0 | GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this, *GetDrawView()); |
388 | 0 | } |
389 | | |
390 | | void ViewShell::Deactivate(bool bIsMDIActivate) |
391 | 0 | { |
392 | | // remove view from a still active drag'n'drop session |
393 | 0 | SdTransferable* pDragTransferable = SdModule::get()->pTransferDrag; |
394 | |
|
395 | 0 | if (IsMainViewShell()) |
396 | 0 | GetDocSh()->Disconnect(this); |
397 | |
|
398 | 0 | if( pDragTransferable ) |
399 | 0 | pDragTransferable->SetView( nullptr ); |
400 | |
|
401 | 0 | OSL_ASSERT (GetViewShell()!=nullptr); |
402 | | |
403 | | // remember view attributes of FrameView |
404 | 0 | WriteFrameViewData(); |
405 | |
|
406 | 0 | if (bIsMDIActivate) |
407 | 0 | { |
408 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
409 | 0 | if(xSlideShow.is() && xSlideShow->isRunning() ) //IASS |
410 | 0 | xSlideShow->deactivate(); |
411 | |
|
412 | 0 | if(HasCurrentFunction()) |
413 | 0 | GetCurrentFunction()->Deactivate(); |
414 | 0 | } |
415 | |
|
416 | 0 | if (mpHorizontalRuler) |
417 | 0 | mpHorizontalRuler->SetActive(false); |
418 | 0 | if (mpVerticalRuler) |
419 | 0 | mpVerticalRuler->SetActive(false); |
420 | |
|
421 | 0 | SfxShell::Deactivate(bIsMDIActivate); |
422 | 0 | } |
423 | | |
424 | | void ViewShell::BroadcastContextForActivation(const bool bIsActivated) |
425 | 0 | { |
426 | 0 | auto getFrameworkResourceIdForShell |
427 | 0 | = [&]() -> rtl::Reference<framework::ResourceId> const |
428 | 0 | { |
429 | 0 | DrawController* pDrawController = GetViewShellBase().GetDrawController(); |
430 | 0 | if (!pDrawController) |
431 | 0 | return {}; |
432 | | |
433 | 0 | rtl::Reference<sd::framework::ConfigurationController> xConfigurationController |
434 | 0 | = pDrawController->getConfigurationController(); |
435 | 0 | if (!xConfigurationController.is()) |
436 | 0 | return {}; |
437 | | |
438 | 0 | rtl::Reference<framework::Configuration> xConfiguration |
439 | 0 | = xConfigurationController->getCurrentConfiguration(); |
440 | 0 | if (!xConfiguration.is()) |
441 | 0 | return {}; |
442 | | |
443 | 0 | auto aResIdsIndirect |
444 | 0 | = xConfiguration->getResources({}, u"", drawing::framework::AnchorBindingMode_INDIRECT); |
445 | |
|
446 | 0 | for (const rtl::Reference<framework::ResourceId>& rResId : aResIdsIndirect) |
447 | 0 | { |
448 | 0 | auto pFrameworkHelper = framework::FrameworkHelper::Instance(GetViewShellBase()); |
449 | |
|
450 | 0 | rtl::Reference<sd::framework::AbstractView> xView; |
451 | 0 | if (rResId->getResourceURL().match(framework::FrameworkHelper::msViewURLPrefix)) |
452 | 0 | { |
453 | 0 | xView = dynamic_cast<sd::framework::AbstractView*>(xConfigurationController->getResource(rResId).get()); |
454 | |
|
455 | 0 | if (xView.is()) |
456 | 0 | { |
457 | 0 | if (auto pViewShellWrapper = dynamic_cast<framework::ViewShellWrapper*>(xView.get())) |
458 | 0 | { |
459 | 0 | if (pViewShellWrapper->GetViewShell().get() == this) |
460 | 0 | { |
461 | 0 | return rResId; |
462 | 0 | } |
463 | 0 | } |
464 | 0 | } |
465 | 0 | } |
466 | 0 | } |
467 | 0 | return {}; |
468 | 0 | }; |
469 | |
|
470 | 0 | if (bIsActivated) |
471 | 0 | { |
472 | 0 | GetViewShellBase().GetEventMultiplexer()->MultiplexEvent( |
473 | 0 | EventMultiplexerEventId::FocusShifted, nullptr, getFrameworkResourceIdForShell()); |
474 | 0 | } |
475 | |
|
476 | 0 | if (GetDispatcher()) |
477 | 0 | SfxShell::BroadcastContextForActivation(bIsActivated); |
478 | 0 | } |
479 | | |
480 | | void ViewShell::Shutdown() |
481 | 0 | { |
482 | 0 | Exit (); |
483 | 0 | } |
484 | | |
485 | | // IASS: Check if commands should be used for SlideShow |
486 | | // This is the case when IASS is on, SlideShow is active |
487 | | // and the SlideShow Window has the focus |
488 | | bool ViewShell::useInputForSlideShow() const |
489 | 0 | { |
490 | 0 | rtl::Reference< SlideShow > xSlideShow(SlideShow::GetSlideShow(GetViewShellBase())); |
491 | |
|
492 | 0 | if (!xSlideShow.is()) |
493 | | // no SlideShow, do not use |
494 | 0 | return false; |
495 | | |
496 | 0 | if (!xSlideShow->isRunning()) |
497 | | // SlideShow not running, do not use |
498 | 0 | return false; |
499 | | |
500 | 0 | if(!xSlideShow->IsInteractiveSlideshow()) |
501 | | // if IASS is deactivated, do what was done before when |
502 | | // SlideSHow is running: use for SlideShow |
503 | 0 | return true; |
504 | | |
505 | | // else, check if SlideShow Window has the focus |
506 | 0 | OutputDevice* pShOut(xSlideShow->getShowWindow()); |
507 | 0 | vcl::Window* pShWin(pShOut ? pShOut->GetOwnerWindow() : nullptr); |
508 | | |
509 | | // return true if we got the SlideShow Window and it has the focus |
510 | 0 | return nullptr != pShWin && pShWin->HasFocus(); |
511 | 0 | } |
512 | | |
513 | | bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) |
514 | 0 | { |
515 | 0 | bool bReturn(false); |
516 | |
|
517 | 0 | if(pWin) |
518 | 0 | SetActiveWindow(pWin); |
519 | | |
520 | | // give key input first to SfxViewShell to give CTRL+Key |
521 | | // (e.g. CTRL+SHIFT+'+', to front) priority. |
522 | 0 | OSL_ASSERT(GetViewShell() != nullptr); |
523 | 0 | bReturn = GetViewShell()->KeyInput(rKEvt); |
524 | |
|
525 | 0 | if (sd::View* pView = GetView()) |
526 | 0 | { |
527 | 0 | const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); |
528 | 0 | const size_t OriCount = rMarkList.GetMarkCount(); |
529 | 0 | if(!bReturn) |
530 | 0 | { |
531 | 0 | if(useInputForSlideShow()) //IASS |
532 | 0 | { |
533 | | // use for SlideShow |
534 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
535 | 0 | bReturn = xSlideShow->keyInput(rKEvt); |
536 | 0 | } |
537 | 0 | else |
538 | 0 | { |
539 | 0 | bool bConsumed = false; |
540 | 0 | bConsumed = pView->getSmartTags().KeyInput(rKEvt); |
541 | |
|
542 | 0 | if( !bConsumed ) |
543 | 0 | { |
544 | 0 | rtl::Reference< sdr::SelectionController > xSelectionController( pView->getSelectionController() ); |
545 | 0 | if( !xSelectionController.is() || !xSelectionController->onKeyInput( rKEvt, pWin ) ) |
546 | 0 | { |
547 | 0 | if(HasCurrentFunction()) |
548 | 0 | bReturn = GetCurrentFunction()->KeyInput(rKEvt); |
549 | 0 | } |
550 | 0 | else |
551 | 0 | { |
552 | 0 | bReturn = true; |
553 | 0 | if (HasCurrentFunction()) |
554 | 0 | { |
555 | 0 | FuText* pTextFunction = dynamic_cast<FuText*>(GetCurrentFunction().get()); |
556 | 0 | if(pTextFunction != nullptr) |
557 | 0 | pTextFunction->InvalidateBindings(); |
558 | 0 | } |
559 | 0 | } |
560 | 0 | } |
561 | 0 | } |
562 | 0 | } |
563 | 0 | const size_t EndCount = rMarkList.GetMarkCount(); |
564 | | // Here, oriCount or endCount must have one value=0, another value > 0, then to switch focus between Document and shape objects |
565 | 0 | if(bReturn && (OriCount + EndCount > 0) && (OriCount * EndCount == 0)) |
566 | 0 | SwitchActiveViewFireFocus(); |
567 | 0 | } |
568 | |
|
569 | 0 | if(!bReturn && GetActiveWindow()) |
570 | 0 | { |
571 | 0 | vcl::KeyCode aKeyCode = rKEvt.GetKeyCode(); |
572 | |
|
573 | 0 | if (aKeyCode.IsMod1() && aKeyCode.IsShift() |
574 | 0 | && aKeyCode.GetCode() == KEY_R) |
575 | 0 | { |
576 | 0 | InvalidateWindows(); |
577 | 0 | bReturn = true; |
578 | 0 | } |
579 | 0 | } |
580 | |
|
581 | 0 | return bReturn; |
582 | 0 | } |
583 | | |
584 | | void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) |
585 | 0 | { |
586 | | // We have to lock tool bar updates while the mouse button is pressed in |
587 | | // order to prevent the shape under the mouse to be moved (this happens |
588 | | // when the number of docked tool bars changes as result of a changed |
589 | | // selection; this changes the window size and thus the mouse position |
590 | | // in model coordinates: with respect to model coordinates the mouse |
591 | | // moves.) |
592 | 0 | OSL_ASSERT(mpImpl->mpUpdateLockForMouse.expired()); |
593 | 0 | mpImpl->mpUpdateLockForMouse = ViewShell::Implementation::ToolBarManagerLock::Create( |
594 | 0 | GetViewShellBase().GetToolBarManager()); |
595 | |
|
596 | 0 | if ( pWin && !pWin->HasFocus() ) |
597 | 0 | { |
598 | 0 | pWin->GrabFocus(); |
599 | 0 | SetActiveWindow(pWin); |
600 | 0 | } |
601 | |
|
602 | 0 | ::sd::View* pView = GetView(); |
603 | 0 | if (!pView) |
604 | 0 | return; |
605 | | |
606 | | // insert MouseEvent into E3dView |
607 | 0 | pView->SetMouseEvent(rMEvt); |
608 | |
|
609 | 0 | bool bConsumed = false; |
610 | 0 | bConsumed = pView->getSmartTags().MouseButtonDown( rMEvt ); |
611 | |
|
612 | 0 | if( bConsumed ) |
613 | 0 | return; |
614 | | |
615 | 0 | rtl::Reference< sdr::SelectionController > xSelectionController( pView->getSelectionController() ); |
616 | 0 | if( !xSelectionController.is() || !xSelectionController->onMouseButtonDown( rMEvt, pWin ) ) |
617 | 0 | { |
618 | 0 | if(HasCurrentFunction()) |
619 | 0 | GetCurrentFunction()->MouseButtonDown(rMEvt); |
620 | 0 | } |
621 | 0 | else |
622 | 0 | { |
623 | 0 | if (HasCurrentFunction()) |
624 | 0 | { |
625 | 0 | FuText* pTextFunction = dynamic_cast<FuText*>(GetCurrentFunction().get()); |
626 | 0 | if (pTextFunction != nullptr) |
627 | 0 | pTextFunction->InvalidateBindings(); |
628 | 0 | } |
629 | 0 | } |
630 | 0 | } |
631 | | |
632 | | void ViewShell::SetCursorMm100Position(const Point& rPosition, bool bPoint, bool bClearMark) |
633 | 0 | { |
634 | 0 | if (SdrView* pSdrView = GetView()) |
635 | 0 | { |
636 | 0 | rtl::Reference<sdr::SelectionController> xSelectionController(GetView()->getSelectionController()); |
637 | 0 | if (!xSelectionController.is() || !xSelectionController->setCursorLogicPosition(rPosition, bPoint)) |
638 | 0 | { |
639 | 0 | if (pSdrView->GetTextEditObject()) |
640 | 0 | { |
641 | 0 | EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView(); |
642 | 0 | rEditView.SetCursorLogicPosition(rPosition, bPoint, bClearMark); |
643 | 0 | } |
644 | 0 | } |
645 | 0 | } |
646 | 0 | } |
647 | | |
648 | | uno::Reference<datatransfer::XTransferable> ViewShell::GetSelectionTransferable() const |
649 | 0 | { |
650 | 0 | SdrView* pSdrView = GetView(); |
651 | 0 | if (!pSdrView) |
652 | 0 | return uno::Reference<datatransfer::XTransferable>(); |
653 | | |
654 | 0 | if (!pSdrView->GetTextEditObject()) |
655 | 0 | return uno::Reference<datatransfer::XTransferable>(); |
656 | | |
657 | 0 | EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView(); |
658 | 0 | return rEditView.getEditEngine().CreateTransferable(rEditView.GetSelection()); |
659 | 0 | } |
660 | | |
661 | | void ViewShell::SetGraphicMm100Position(bool bStart, const Point& rPosition) |
662 | 0 | { |
663 | 0 | if (bStart) |
664 | 0 | { |
665 | 0 | MouseEvent aClickEvent(rPosition, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT); |
666 | 0 | MouseButtonDown(aClickEvent, mpActiveWindow); |
667 | 0 | MouseEvent aMoveEvent(Point(rPosition.getX(), rPosition.getY()), 0, MouseEventModifiers::SIMPLEMOVE, MOUSE_LEFT); |
668 | 0 | MouseMove(aMoveEvent, mpActiveWindow); |
669 | 0 | } |
670 | 0 | else |
671 | 0 | { |
672 | 0 | MouseEvent aMoveEvent(Point(rPosition.getX(), rPosition.getY()), 0, MouseEventModifiers::SIMPLEMOVE, MOUSE_LEFT); |
673 | 0 | MouseMove(aMoveEvent, mpActiveWindow); |
674 | 0 | MouseEvent aClickEvent(rPosition, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT); |
675 | 0 | MouseButtonUp(aClickEvent, mpActiveWindow); |
676 | 0 | } |
677 | 0 | } |
678 | | |
679 | | void ViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) |
680 | 0 | { |
681 | 0 | if (rMEvt.IsLeaveWindow()) |
682 | 0 | { |
683 | 0 | if ( ! mpImpl->mpUpdateLockForMouse.expired()) |
684 | 0 | { |
685 | 0 | std::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock( |
686 | 0 | mpImpl->mpUpdateLockForMouse); |
687 | 0 | if (pLock != nullptr) |
688 | 0 | pLock->Release(); |
689 | 0 | } |
690 | 0 | } |
691 | |
|
692 | 0 | if ( pWin ) |
693 | 0 | { |
694 | 0 | SetActiveWindow(pWin); |
695 | 0 | } |
696 | | |
697 | | // insert MouseEvent into E3dView |
698 | 0 | if (GetView() != nullptr) |
699 | 0 | GetView()->SetMouseEvent(rMEvt); |
700 | |
|
701 | 0 | if(HasCurrentFunction()) |
702 | 0 | { |
703 | 0 | rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() ); |
704 | 0 | if( !xSelectionController.is() || !xSelectionController->onMouseMove( rMEvt, pWin ) ) |
705 | 0 | { |
706 | 0 | if(HasCurrentFunction()) |
707 | 0 | GetCurrentFunction()->MouseMove(rMEvt); |
708 | 0 | } |
709 | 0 | } |
710 | 0 | } |
711 | | |
712 | | void ViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) |
713 | 0 | { |
714 | 0 | if ( pWin ) |
715 | 0 | SetActiveWindow(pWin); |
716 | | |
717 | | // insert MouseEvent into E3dView |
718 | 0 | if (GetView() != nullptr) |
719 | 0 | GetView()->SetMouseEvent(rMEvt); |
720 | |
|
721 | 0 | if( HasCurrentFunction()) |
722 | 0 | { |
723 | 0 | rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() ); |
724 | 0 | if( !xSelectionController.is() || !xSelectionController->onMouseButtonUp( rMEvt, pWin ) ) |
725 | 0 | { |
726 | 0 | if(HasCurrentFunction()) |
727 | 0 | GetCurrentFunction()->MouseButtonUp(rMEvt); |
728 | 0 | } |
729 | 0 | else |
730 | 0 | { |
731 | 0 | if (HasCurrentFunction()) |
732 | 0 | { |
733 | 0 | FuText* pTextFunction = dynamic_cast<FuText*>(GetCurrentFunction().get()); |
734 | 0 | if (pTextFunction != nullptr) |
735 | 0 | pTextFunction->InvalidateBindings(); |
736 | 0 | } |
737 | 0 | } |
738 | 0 | } |
739 | |
|
740 | 0 | if ( ! mpImpl->mpUpdateLockForMouse.expired()) |
741 | 0 | { |
742 | 0 | std::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock( |
743 | 0 | mpImpl->mpUpdateLockForMouse); |
744 | 0 | if (pLock != nullptr) |
745 | 0 | pLock->Release(); |
746 | 0 | } |
747 | 0 | } |
748 | | |
749 | | void ViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) |
750 | 0 | { |
751 | 0 | bool bDone = HandleScrollCommand (rCEvt, pWin); |
752 | |
|
753 | 0 | if( bDone ) |
754 | 0 | return; |
755 | | |
756 | 0 | if( rCEvt.GetCommand() == CommandEventId::InputLanguageChange ) |
757 | 0 | { |
758 | | //#i42732# update state of fontname if input language changes |
759 | 0 | GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT ); |
760 | 0 | GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); |
761 | 0 | } |
762 | 0 | else |
763 | 0 | { |
764 | 0 | bool bConsumed = false; |
765 | 0 | if( GetView() ) |
766 | 0 | bConsumed = GetView()->getSmartTags().Command(rCEvt); |
767 | |
|
768 | 0 | if( !bConsumed && HasCurrentFunction()) |
769 | 0 | GetCurrentFunction()->Command(rCEvt); |
770 | 0 | } |
771 | 0 | } |
772 | | |
773 | | bool ViewShell::Notify(NotifyEvent const & rNEvt, ::sd::Window* pWin) |
774 | 0 | { |
775 | | // handle scroll commands when they arrived at child windows |
776 | 0 | bool bRet = false; |
777 | 0 | if( rNEvt.GetType() == NotifyEventType::COMMAND ) |
778 | 0 | { |
779 | | // note: dynamic_cast is not possible as GetData() returns a void* |
780 | 0 | CommandEvent* pCmdEvent = static_cast< CommandEvent* >(rNEvt.GetData()); |
781 | 0 | bRet = HandleScrollCommand(*pCmdEvent, pWin); |
782 | 0 | } |
783 | 0 | return bRet; |
784 | 0 | } |
785 | | |
786 | | bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWin) |
787 | 0 | { |
788 | 0 | bool bDone = false; |
789 | |
|
790 | 0 | switch( rCEvt.GetCommand() ) |
791 | 0 | { |
792 | 0 | case CommandEventId::GestureSwipe: |
793 | 0 | { |
794 | 0 | if(useInputForSlideShow()) //IASS |
795 | 0 | { |
796 | | // use for SlideShow |
797 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
798 | 0 | const CommandGestureSwipeData* pSwipeData = rCEvt.GetGestureSwipeData(); |
799 | 0 | bDone = xSlideShow->swipe(*pSwipeData); |
800 | 0 | } |
801 | 0 | } |
802 | 0 | break; |
803 | 0 | case CommandEventId::GestureLongPress: |
804 | 0 | { |
805 | 0 | if(useInputForSlideShow()) //IASS |
806 | 0 | { |
807 | | // use for SlideShow |
808 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
809 | 0 | const CommandGestureLongPressData* pLongPressData = rCEvt.GetLongPressData(); |
810 | 0 | bDone = xSlideShow->longpress(*pLongPressData); |
811 | 0 | } |
812 | 0 | } |
813 | 0 | break; |
814 | | |
815 | 0 | case CommandEventId::Wheel: |
816 | 0 | { |
817 | 0 | Reference< XSlideShowController > xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) ); |
818 | 0 | if( xSlideShowController.is() ) |
819 | 0 | { |
820 | 0 | if(useInputForSlideShow()) //IASS |
821 | 0 | { |
822 | | // use for SlideShow |
823 | | // We ignore zooming with control+mouse wheel. |
824 | 0 | const CommandWheelData* pData = rCEvt.GetWheelData(); |
825 | 0 | if( pData && !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) && !pData->IsHorz() ) |
826 | 0 | { |
827 | 0 | ::tools::Long nDelta = pData->GetDelta(); |
828 | 0 | if( nDelta > 0 ) |
829 | 0 | xSlideShowController->gotoPreviousSlide(); |
830 | 0 | else if( nDelta < 0 ) |
831 | 0 | xSlideShowController->gotoNextEffect(); |
832 | 0 | } |
833 | 0 | break; |
834 | 0 | } |
835 | 0 | } |
836 | 0 | } |
837 | 0 | [[fallthrough]]; |
838 | 0 | case CommandEventId::StartAutoScroll: |
839 | 0 | case CommandEventId::AutoScroll: |
840 | 0 | { |
841 | 0 | const CommandWheelData* pData = rCEvt.GetWheelData(); |
842 | |
|
843 | 0 | if (pData != nullptr) |
844 | 0 | { |
845 | 0 | const bool bZoomWithWheel = GetDoc() != nullptr |
846 | 0 | && GetDoc()->GetDocumentType() == DocumentType::Draw |
847 | 0 | && officecfg::Office::Draw::Layout::Display::ZoomWithMouseWheel::get(); |
848 | 0 | const bool bShouldZoom = pData->IsMod1() != bZoomWithWheel; |
849 | |
|
850 | 0 | if (bShouldZoom) |
851 | 0 | { |
852 | 0 | if( !GetDocSh()->IsUIActive() ) |
853 | 0 | { |
854 | 0 | const sal_uInt16 nOldZoom = GetActiveWindow()->GetZoom(); |
855 | 0 | sal_uInt16 nNewZoom; |
856 | 0 | Point aOldMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); |
857 | |
|
858 | 0 | if( pData->GetDelta() < 0 ) |
859 | 0 | nNewZoom = std::max<sal_uInt16>( pWin->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom )); |
860 | 0 | else |
861 | 0 | nNewZoom = std::min<sal_uInt16>( pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom )); |
862 | |
|
863 | 0 | SetZoom( nNewZoom ); |
864 | | // Keep mouse at same doc point before zoom |
865 | 0 | Point aNewMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); |
866 | 0 | SetWinViewPos(GetWinViewPos() - (aNewMousePos - aOldMousePos)); |
867 | |
|
868 | 0 | Invalidate( SID_ATTR_ZOOM ); |
869 | 0 | Invalidate( SID_ATTR_ZOOMSLIDER ); |
870 | |
|
871 | 0 | bDone = true; |
872 | 0 | } |
873 | 0 | } |
874 | 0 | else |
875 | 0 | { |
876 | 0 | if( mpContentWindow.get() == pWin ) |
877 | 0 | { |
878 | 0 | double nScrollLines = pData->GetScrollLines(); |
879 | 0 | if(IsPageFlipMode()) |
880 | 0 | nScrollLines = COMMAND_WHEEL_PAGESCROLL; |
881 | 0 | const sal_uInt16 nScrollModifier |
882 | 0 | = bZoomWithWheel ? (pData->GetModifier() & ~KEY_MOD1) |
883 | 0 | : pData->GetModifier(); |
884 | 0 | constexpr CommandWheelMode eScrollMode = CommandWheelMode::SCROLL; |
885 | 0 | CommandWheelData aWheelData( pData->GetDelta(),pData->GetNotchDelta(), |
886 | 0 | nScrollLines,eScrollMode,nScrollModifier,pData->IsHorz() ); |
887 | 0 | CommandEvent aReWrite( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(), |
888 | 0 | rCEvt.IsMouseEvent(),static_cast<const void *>(&aWheelData) ); |
889 | 0 | bDone = pWin->HandleScrollCommand( aReWrite, |
890 | 0 | mpHorizontalScrollBar.get(), |
891 | 0 | mpVerticalScrollBar.get()); |
892 | 0 | } |
893 | 0 | } |
894 | 0 | } |
895 | 0 | } |
896 | 0 | break; |
897 | | |
898 | 0 | case CommandEventId::GesturePan: |
899 | 0 | { |
900 | 0 | bDone = pWin->HandleScrollCommand(rCEvt, mpHorizontalScrollBar.get(), |
901 | 0 | mpVerticalScrollBar.get()); |
902 | 0 | } |
903 | 0 | break; |
904 | | |
905 | 0 | case CommandEventId::GestureZoom: |
906 | 0 | { |
907 | 0 | const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); |
908 | |
|
909 | 0 | if (pData->meEventType == GestureEventZoomType::Begin) |
910 | 0 | { |
911 | 0 | mfLastZoomScale = pData->mfScaleDelta; |
912 | 0 | bDone = true; |
913 | 0 | break; |
914 | 0 | } |
915 | | |
916 | 0 | if (pData->meEventType == GestureEventZoomType::Update) |
917 | 0 | { |
918 | 0 | double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / mfLastZoomScale; |
919 | 0 | mfLastZoomScale = pData->mfScaleDelta; |
920 | |
|
921 | 0 | if (!GetDocSh()->IsUIActive() && !useInputForSlideShow()) //IASS |
922 | 0 | { |
923 | 0 | const ::tools::Long nOldZoom = GetActiveWindow()->GetZoom(); |
924 | 0 | ::tools::Long nNewZoom; |
925 | 0 | Point aOldMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); |
926 | | |
927 | | // Accumulate fractional zoom to avoid small zoom changes from being ignored |
928 | 0 | mfAccumulatedZoom += deltaBetweenEvents; |
929 | 0 | int nZoomChangePercent = mfAccumulatedZoom * 100; |
930 | 0 | mfAccumulatedZoom -= nZoomChangePercent / 100.0; |
931 | |
|
932 | 0 | nNewZoom = nOldZoom + nZoomChangePercent; |
933 | 0 | nNewZoom = std::max<::tools::Long>(pWin->GetMinZoom(), nNewZoom); |
934 | 0 | nNewZoom = std::min<::tools::Long>(pWin->GetMaxZoom(), nNewZoom); |
935 | |
|
936 | 0 | SetZoom(nNewZoom); |
937 | | |
938 | | // Keep mouse at same doc point before zoom |
939 | 0 | Point aNewMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); |
940 | 0 | SetWinViewPos(GetWinViewPos() - (aNewMousePos - aOldMousePos)); |
941 | |
|
942 | 0 | Invalidate(SID_ATTR_ZOOM); |
943 | 0 | Invalidate(SID_ATTR_ZOOMSLIDER); |
944 | 0 | } |
945 | 0 | } |
946 | |
|
947 | 0 | bDone = true; |
948 | 0 | } |
949 | 0 | break; |
950 | | |
951 | 0 | default: |
952 | 0 | break; |
953 | 0 | } |
954 | | |
955 | 0 | return bDone; |
956 | 0 | } |
957 | | |
958 | | void ViewShell::SetupRulers() |
959 | 0 | { |
960 | 0 | if(!mbHasRulers || !mpContentWindow ) |
961 | 0 | return; |
962 | | |
963 | 0 | if( SlideShow::IsRunning(GetViewShellBase()) && !SlideShow::IsInteractiveSlideshow(GetViewShellBase())) // IASS |
964 | 0 | return; |
965 | | |
966 | 0 | ::tools::Long nHRulerOfs = 0; |
967 | |
|
968 | 0 | if ( !mpVerticalRuler ) |
969 | 0 | { |
970 | 0 | mpVerticalRuler.reset(CreateVRuler(GetActiveWindow())); |
971 | 0 | if ( mpVerticalRuler ) |
972 | 0 | { |
973 | 0 | nHRulerOfs = mpVerticalRuler->GetSizePixel().Width(); |
974 | 0 | mpVerticalRuler->SetActive(); |
975 | 0 | mpVerticalRuler->Show(); |
976 | 0 | } |
977 | 0 | } |
978 | 0 | if ( !mpHorizontalRuler ) |
979 | 0 | { |
980 | 0 | mpHorizontalRuler.reset(CreateHRuler(GetActiveWindow())); |
981 | 0 | if ( mpHorizontalRuler ) |
982 | 0 | { |
983 | 0 | mpHorizontalRuler->SetWinPos(nHRulerOfs); |
984 | 0 | mpHorizontalRuler->SetActive(); |
985 | 0 | mpHorizontalRuler->Show(); |
986 | 0 | } |
987 | 0 | } |
988 | 0 | } |
989 | | |
990 | | const SvxNumBulletItem* ViewShell::GetNumBulletItem(SfxItemSet& aNewAttr, TypedWhichId<SvxNumBulletItem>& nNumItemId) |
991 | 0 | { |
992 | 0 | const SvxNumBulletItem* pTmpItem = aNewAttr.GetItemIfSet(nNumItemId, false); |
993 | 0 | if(pTmpItem) |
994 | 0 | return pTmpItem; |
995 | | |
996 | 0 | nNumItemId = aNewAttr.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); |
997 | 0 | pTmpItem = aNewAttr.GetItemIfSet(nNumItemId, false); |
998 | 0 | if(pTmpItem) |
999 | 0 | return pTmpItem; |
1000 | | |
1001 | 0 | bool bOutliner = false; |
1002 | 0 | bool bTitle = false; |
1003 | |
|
1004 | 0 | if( mpView ) |
1005 | 0 | { |
1006 | 0 | const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); |
1007 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
1008 | |
|
1009 | 0 | for(size_t nNum = 0; nNum < nCount; ++nNum) |
1010 | 0 | { |
1011 | 0 | SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj(); |
1012 | 0 | if( pObj->GetObjInventor() == SdrInventor::Default ) |
1013 | 0 | { |
1014 | 0 | switch(pObj->GetObjIdentifier()) |
1015 | 0 | { |
1016 | 0 | case SdrObjKind::TitleText: |
1017 | 0 | bTitle = true; |
1018 | 0 | break; |
1019 | 0 | case SdrObjKind::OutlineText: |
1020 | 0 | bOutliner = true; |
1021 | 0 | break; |
1022 | 0 | default: |
1023 | 0 | break; |
1024 | 0 | } |
1025 | 0 | } |
1026 | 0 | } |
1027 | 0 | } |
1028 | | |
1029 | 0 | const SvxNumBulletItem *pItem = nullptr; |
1030 | 0 | if(bOutliner) |
1031 | 0 | { |
1032 | 0 | SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool(); |
1033 | 0 | SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( STR_LAYOUT_OUTLINE + " 1", SfxStyleFamily::Pseudo); |
1034 | 0 | if( pFirstStyleSheet ) |
1035 | 0 | pItem = pFirstStyleSheet->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET, false); |
1036 | 0 | } |
1037 | |
|
1038 | 0 | if( pItem == nullptr ) |
1039 | 0 | pItem = aNewAttr.GetPool()->GetSecondaryPool()->GetUserDefaultItem(EE_PARA_NUMBULLET); |
1040 | |
|
1041 | 0 | aNewAttr.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET)); |
1042 | |
|
1043 | 0 | const SvxNumBulletItem* pBulletItem = nullptr; |
1044 | 0 | if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET, true, &pBulletItem) == SfxItemState::SET ) |
1045 | 0 | { |
1046 | 0 | const SvxNumRule& rRule = pBulletItem->GetNumRule(); |
1047 | 0 | SvxNumRule aNewRule( rRule ); |
1048 | 0 | aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); |
1049 | |
|
1050 | 0 | SvxNumBulletItem aNewItem( std::move(aNewRule), EE_PARA_NUMBULLET ); |
1051 | 0 | aNewAttr.Put(aNewItem); |
1052 | 0 | } |
1053 | |
|
1054 | 0 | pTmpItem = aNewAttr.GetItemIfSet(nNumItemId, false); |
1055 | |
|
1056 | 0 | return pTmpItem; |
1057 | 0 | } |
1058 | | |
1059 | | void ViewShell::Resize() |
1060 | 0 | { |
1061 | 0 | SetupRulers (); |
1062 | |
|
1063 | 0 | if (mpParentWindow == nullptr) |
1064 | 0 | return; |
1065 | | |
1066 | | // Make sure that the new size is not degenerate. |
1067 | 0 | const Size aSize (mpParentWindow->GetSizePixel()); |
1068 | 0 | if (aSize.IsEmpty()) |
1069 | 0 | return; |
1070 | | |
1071 | | // Remember the new position and size. |
1072 | 0 | maViewPos = Point(0,0); |
1073 | 0 | maViewSize = aSize; |
1074 | | |
1075 | | // Rearrange the UI elements to take care of the new position and size. |
1076 | 0 | ArrangeGUIElements (); |
1077 | | // end of included AdjustPosSizePixel. |
1078 | |
|
1079 | 0 | ::sd::View* pView = GetView(); |
1080 | |
|
1081 | 0 | if (pView) |
1082 | 0 | pView->VisAreaChanged(GetActiveWindow()->GetOutDev()); |
1083 | 0 | } |
1084 | | |
1085 | | SvBorder ViewShell::GetBorder() |
1086 | 0 | { |
1087 | 0 | SvBorder aBorder; |
1088 | | |
1089 | | // Horizontal scrollbar. |
1090 | 0 | if (mpHorizontalScrollBar |
1091 | 0 | && mpHorizontalScrollBar->IsVisible()) |
1092 | 0 | { |
1093 | 0 | aBorder.Bottom() = maScrBarWH.Height(); |
1094 | 0 | } |
1095 | | |
1096 | | // Vertical scrollbar. |
1097 | 0 | if (mpVerticalScrollBar |
1098 | 0 | && mpVerticalScrollBar->IsVisible()) |
1099 | 0 | { |
1100 | 0 | aBorder.Right() = maScrBarWH.Width(); |
1101 | 0 | } |
1102 | | |
1103 | | // Place horizontal ruler below tab bar. |
1104 | 0 | if (mbHasRulers && mpContentWindow) |
1105 | 0 | { |
1106 | 0 | SetupRulers(); |
1107 | 0 | if (mpHorizontalRuler) |
1108 | 0 | aBorder.Top() = mpHorizontalRuler->GetSizePixel().Height(); |
1109 | 0 | if (mpVerticalRuler) |
1110 | 0 | aBorder.Left() = mpVerticalRuler->GetSizePixel().Width(); |
1111 | 0 | } |
1112 | |
|
1113 | 0 | return aBorder; |
1114 | 0 | } |
1115 | | |
1116 | | void ViewShell::ArrangeGUIElements() |
1117 | 0 | { |
1118 | 0 | if (mpImpl->mbArrangeActive) |
1119 | 0 | return; |
1120 | 0 | if (maViewSize.IsEmpty()) |
1121 | 0 | return; |
1122 | 0 | mpImpl->mbArrangeActive = true; |
1123 | | |
1124 | | // Calculate border for in-place editing. |
1125 | 0 | ::tools::Long nLeft = maViewPos.X(); |
1126 | 0 | ::tools::Long nTop = maViewPos.Y(); |
1127 | 0 | ::tools::Long nRight = maViewPos.X() + maViewSize.Width(); |
1128 | 0 | ::tools::Long nBottom = maViewPos.Y() + maViewSize.Height(); |
1129 | | |
1130 | | // Horizontal scrollbar. |
1131 | 0 | if (mpHorizontalScrollBar |
1132 | 0 | && mpHorizontalScrollBar->IsVisible()) |
1133 | 0 | { |
1134 | 0 | nBottom -= maScrBarWH.Height(); |
1135 | 0 | if (mpLayerTabBar && mpLayerTabBar->IsVisible()) |
1136 | 0 | nBottom -= mpLayerTabBar->GetSizePixel().Height(); |
1137 | 0 | mpHorizontalScrollBar->SetPosSizePixel ( |
1138 | 0 | Point(nLeft, nBottom), |
1139 | 0 | Size(nRight - nLeft - maScrBarWH.Width(), maScrBarWH.Height())); |
1140 | 0 | } |
1141 | | |
1142 | | // Vertical scrollbar. |
1143 | 0 | if (mpVerticalScrollBar |
1144 | 0 | && mpVerticalScrollBar->IsVisible()) |
1145 | 0 | { |
1146 | 0 | nRight -= maScrBarWH.Width(); |
1147 | 0 | mpVerticalScrollBar->SetPosSizePixel ( |
1148 | 0 | Point(nRight,nTop), |
1149 | 0 | Size (maScrBarWH.Width(), nBottom-nTop)); |
1150 | 0 | } |
1151 | | |
1152 | | // Place horizontal ruler below tab bar. |
1153 | 0 | if (mbHasRulers && mpContentWindow) |
1154 | 0 | { |
1155 | 0 | if (mpHorizontalRuler) |
1156 | 0 | { |
1157 | 0 | Size aRulerSize = mpHorizontalRuler->GetSizePixel(); |
1158 | 0 | aRulerSize.setWidth( nRight - nLeft ); |
1159 | 0 | mpHorizontalRuler->SetPosSizePixel ( |
1160 | 0 | Point(nLeft,nTop), aRulerSize); |
1161 | 0 | if (mpVerticalRuler) |
1162 | 0 | mpHorizontalRuler->SetBorderPos( |
1163 | 0 | mpVerticalRuler->GetSizePixel().Width()-1); |
1164 | 0 | nTop += aRulerSize.Height(); |
1165 | 0 | } |
1166 | 0 | if (mpVerticalRuler) |
1167 | 0 | { |
1168 | 0 | Size aRulerSize = mpVerticalRuler->GetSizePixel(); |
1169 | 0 | aRulerSize.setHeight( nBottom - nTop ); |
1170 | 0 | mpVerticalRuler->SetPosSizePixel ( |
1171 | 0 | Point (nLeft,nTop), aRulerSize); |
1172 | 0 | nLeft += aRulerSize.Width(); |
1173 | 0 | } |
1174 | 0 | } |
1175 | |
|
1176 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
1177 | | |
1178 | | // The size of the window of the center pane is set differently from |
1179 | | // that of the windows in the docking windows. |
1180 | 0 | bool bSlideShowActive = (xSlideShow.is() && xSlideShow->isRunning()) //IASS |
1181 | 0 | && !xSlideShow->isFullScreen() && xSlideShow->getAnimationMode() == ANIMATIONMODE_SHOW; |
1182 | 0 | if ( !bSlideShowActive) |
1183 | 0 | { |
1184 | 0 | OSL_ASSERT (GetViewShell()!=nullptr); |
1185 | |
|
1186 | 0 | if (mpContentWindow) |
1187 | 0 | mpContentWindow->SetPosSizePixel( |
1188 | 0 | Point(nLeft,nTop), |
1189 | 0 | Size(nRight-nLeft,nBottom-nTop)); |
1190 | 0 | } |
1191 | | |
1192 | | // Windows in the center and rulers at the left and top side. |
1193 | 0 | maAllWindowRectangle = ::tools::Rectangle( |
1194 | 0 | maViewPos, |
1195 | 0 | Size(maViewSize.Width()-maScrBarWH.Width(), |
1196 | 0 | maViewSize.Height()-maScrBarWH.Height())); |
1197 | |
|
1198 | 0 | if (mpContentWindow) |
1199 | 0 | mpContentWindow->UpdateMapOrigin(); |
1200 | |
|
1201 | 0 | UpdateScrollBars(); |
1202 | |
|
1203 | 0 | mpImpl->mbArrangeActive = false; |
1204 | 0 | } |
1205 | | |
1206 | | void ViewShell::SetUIUnit(FieldUnit eUnit) |
1207 | 0 | { |
1208 | | // Set unit at horizontal and vertical rulers. |
1209 | 0 | if (mpHorizontalRuler) |
1210 | 0 | mpHorizontalRuler->SetUnit(eUnit); |
1211 | |
|
1212 | 0 | if (mpVerticalRuler) |
1213 | 0 | mpVerticalRuler->SetUnit(eUnit); |
1214 | 0 | } |
1215 | | |
1216 | | /** |
1217 | | * set DefTab at horizontal rulers |
1218 | | */ |
1219 | | void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab ) |
1220 | 0 | { |
1221 | 0 | if (mpHorizontalRuler) |
1222 | 0 | mpHorizontalRuler->SetDefTabDist( nDefTab ); |
1223 | 0 | } |
1224 | | |
1225 | | /** Tell the FmFormShell that the view shell is closing. Give it the |
1226 | | opportunity to prevent that. |
1227 | | */ |
1228 | | bool ViewShell::PrepareClose (bool bUI) |
1229 | 0 | { |
1230 | 0 | bool bResult = true; |
1231 | |
|
1232 | 0 | FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell(); |
1233 | 0 | if (pFormShell != nullptr) |
1234 | 0 | bResult = pFormShell->PrepareClose (bUI); |
1235 | |
|
1236 | 0 | return bResult; |
1237 | 0 | } |
1238 | | |
1239 | | void ViewShell::UpdatePreview (SdPage*) |
1240 | 0 | { |
1241 | | // Do nothing. After the actual preview has been removed, |
1242 | | // OutlineViewShell::UpdatePreview() is the place where something |
1243 | | // useful is still done. |
1244 | 0 | } |
1245 | | |
1246 | | SfxUndoManager* ViewShell::ImpGetUndoManager() const |
1247 | 0 | { |
1248 | 0 | const ViewShell* pMainViewShell = GetViewShellBase().GetMainViewShell().get(); |
1249 | |
|
1250 | 0 | if( pMainViewShell == nullptr ) |
1251 | 0 | pMainViewShell = this; |
1252 | |
|
1253 | 0 | ::sd::View* pView = pMainViewShell->GetView(); |
1254 | | |
1255 | | // check for text edit our outline view |
1256 | 0 | if( pView ) |
1257 | 0 | { |
1258 | 0 | if( pMainViewShell->GetShellType() == ViewShell::ST_OUTLINE ) |
1259 | 0 | { |
1260 | 0 | OutlineView* pOlView = dynamic_cast< OutlineView* >( pView ); |
1261 | 0 | if( pOlView ) |
1262 | 0 | { |
1263 | 0 | ::Outliner& rOutl = pOlView->GetOutliner(); |
1264 | 0 | return &rOutl.GetUndoManager(); |
1265 | 0 | } |
1266 | 0 | } |
1267 | 0 | else if( pView->IsTextEdit() ) |
1268 | 0 | { |
1269 | 0 | SdrOutliner* pOL = pView->GetTextEditOutliner(); |
1270 | 0 | if( pOL ) |
1271 | 0 | return &pOL->GetUndoManager(); |
1272 | 0 | } |
1273 | 0 | } |
1274 | | |
1275 | 0 | if( GetDocSh() ) |
1276 | 0 | return GetDocSh()->GetUndoManager(); |
1277 | | |
1278 | 0 | return nullptr; |
1279 | 0 | } |
1280 | | |
1281 | | void ViewShell::ImpGetUndoStrings(SfxItemSet &rSet) const |
1282 | 0 | { |
1283 | 0 | SfxUndoManager* pUndoManager = ImpGetUndoManager(); |
1284 | 0 | if(!pUndoManager) |
1285 | 0 | return; |
1286 | | |
1287 | 0 | sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); |
1288 | 0 | if(nCount) |
1289 | 0 | { |
1290 | | // prepare list |
1291 | 0 | std::vector<OUString> aStringList; |
1292 | 0 | aStringList.reserve(nCount); |
1293 | 0 | for (sal_uInt16 a = 0; a < nCount; ++a) |
1294 | 0 | { |
1295 | | // generate one String in list per undo step |
1296 | 0 | aStringList.push_back( pUndoManager->GetUndoActionComment(a) ); |
1297 | 0 | } |
1298 | | |
1299 | | // set item |
1300 | 0 | rSet.Put(SfxStringListItem(SID_GETUNDOSTRINGS, &aStringList)); |
1301 | 0 | } |
1302 | 0 | else |
1303 | 0 | { |
1304 | 0 | rSet.DisableItem(SID_GETUNDOSTRINGS); |
1305 | 0 | } |
1306 | 0 | } |
1307 | | |
1308 | | void ViewShell::ImpGetRedoStrings(SfxItemSet &rSet) const |
1309 | 0 | { |
1310 | 0 | SfxUndoManager* pUndoManager = ImpGetUndoManager(); |
1311 | 0 | if(!pUndoManager) |
1312 | 0 | return; |
1313 | | |
1314 | 0 | sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); |
1315 | 0 | if(nCount) |
1316 | 0 | { |
1317 | | // prepare list |
1318 | 0 | ::std::vector< OUString > aStringList; |
1319 | 0 | aStringList.reserve(nCount); |
1320 | 0 | for(sal_uInt16 a = 0; a < nCount; a++) |
1321 | | // generate one String in list per undo step |
1322 | 0 | aStringList.push_back( pUndoManager->GetRedoActionComment(a) ); |
1323 | | |
1324 | | // set item |
1325 | 0 | rSet.Put(SfxStringListItem(SID_GETREDOSTRINGS, &aStringList)); |
1326 | 0 | } |
1327 | 0 | else |
1328 | 0 | { |
1329 | 0 | rSet.DisableItem(SID_GETREDOSTRINGS); |
1330 | 0 | } |
1331 | 0 | } |
1332 | | |
1333 | | namespace { |
1334 | | |
1335 | | class KeepSlideSorterInSyncWithPageChanges |
1336 | | { |
1337 | | sd::slidesorter::view::SlideSorterView::DrawLock m_aDrawLock; |
1338 | | sd::slidesorter::controller::SlideSorterController::ModelChangeLock m_aModelLock; |
1339 | | sd::slidesorter::controller::PageSelector::UpdateLock m_aUpdateLock; |
1340 | | sd::slidesorter::controller::SelectionObserver::Context m_aContext; |
1341 | | |
1342 | | public: |
1343 | | explicit KeepSlideSorterInSyncWithPageChanges(sd::slidesorter::SlideSorter const & rSlideSorter) |
1344 | 0 | : m_aDrawLock(rSlideSorter) |
1345 | 0 | , m_aModelLock(rSlideSorter.GetController()) |
1346 | 0 | , m_aUpdateLock(rSlideSorter) |
1347 | 0 | , m_aContext(rSlideSorter) |
1348 | 0 | { |
1349 | 0 | } |
1350 | | }; |
1351 | | |
1352 | | } |
1353 | | |
1354 | | void ViewShell::ImpSidUndo(SfxRequest& rReq) |
1355 | 0 | { |
1356 | | //The xWatcher keeps the SlideSorter selection in sync |
1357 | | //with the page insertions/deletions that Undo may introduce |
1358 | 0 | std::unique_ptr<KeepSlideSorterInSyncWithPageChanges, o3tl::default_delete<KeepSlideSorterInSyncWithPageChanges>> xWatcher; |
1359 | 0 | slidesorter::SlideSorterViewShell* pSlideSorterViewShell |
1360 | 0 | = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase()); |
1361 | 0 | if (pSlideSorterViewShell) |
1362 | 0 | xWatcher.reset(new KeepSlideSorterInSyncWithPageChanges(pSlideSorterViewShell->GetSlideSorter())); |
1363 | |
|
1364 | 0 | SfxUndoManager* pUndoManager = ImpGetUndoManager(); |
1365 | 0 | sal_uInt16 nNumber(1); |
1366 | 0 | const SfxItemSet* pReqArgs = rReq.GetArgs(); |
1367 | 0 | bool bRepair = false; |
1368 | |
|
1369 | 0 | if(pReqArgs) |
1370 | 0 | { |
1371 | 0 | const SfxUInt16Item* pUIntItem = static_cast<const SfxUInt16Item*>(&pReqArgs->Get(SID_UNDO)); |
1372 | 0 | nNumber = pUIntItem->GetValue(); |
1373 | | |
1374 | | // Repair mode: allow undo/redo of all undo actions, even if access would |
1375 | | // be limited based on the view shell ID. |
1376 | 0 | if (const SfxBoolItem* pRepairItem = pReqArgs->GetItemIfSet(SID_REPAIRPACKAGE, false)) |
1377 | 0 | bRepair = pRepairItem->GetValue(); |
1378 | 0 | } |
1379 | |
|
1380 | 0 | if(nNumber && pUndoManager) |
1381 | 0 | { |
1382 | 0 | sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); |
1383 | 0 | if(nCount >= nNumber) |
1384 | 0 | { |
1385 | 0 | if (comphelper::LibreOfficeKit::isActive() && !bRepair) |
1386 | 0 | { |
1387 | | // If another view created the first undo action, prevent redoing it from this view. |
1388 | 0 | const SfxUndoAction* pAction = pUndoManager->GetUndoAction(); |
1389 | 0 | if (pAction->GetViewShellId() != GetViewShellBase().GetViewShellId()) |
1390 | 0 | { |
1391 | 0 | rReq.SetReturnValue(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); |
1392 | 0 | return; |
1393 | 0 | } |
1394 | 0 | } |
1395 | | |
1396 | 0 | try |
1397 | 0 | { |
1398 | | // when UndoStack is cleared by ModifyPageUndoAction |
1399 | | // the nCount may have changed, so test GetUndoActionCount() |
1400 | 0 | while (nNumber && pUndoManager->GetUndoActionCount()) |
1401 | 0 | { |
1402 | 0 | pUndoManager->Undo(); |
1403 | 0 | --nNumber; |
1404 | 0 | } |
1405 | 0 | } |
1406 | 0 | catch( const Exception& ) |
1407 | 0 | { |
1408 | | // no need to handle. By definition, the UndoManager handled this by clearing the |
1409 | | // Undo/Redo stacks |
1410 | 0 | } |
1411 | 0 | } |
1412 | | |
1413 | | // refresh rulers, maybe UNDO was move of TAB marker in ruler |
1414 | 0 | if (mbHasRulers) |
1415 | 0 | Invalidate(SID_ATTR_TABSTOP); |
1416 | 0 | } |
1417 | | |
1418 | | // This one is corresponding to the default handling |
1419 | | // of SID_UNDO in sfx2 |
1420 | 0 | GetViewFrame()->GetBindings().InvalidateAll(false); |
1421 | |
|
1422 | 0 | rReq.Done(); |
1423 | 0 | } |
1424 | | |
1425 | | void ViewShell::ImpSidRedo(SfxRequest& rReq) |
1426 | 0 | { |
1427 | | //The xWatcher keeps the SlideSorter selection in sync |
1428 | | //with the page insertions/deletions that Undo may introduce |
1429 | 0 | std::unique_ptr<KeepSlideSorterInSyncWithPageChanges, o3tl::default_delete<KeepSlideSorterInSyncWithPageChanges>> xWatcher; |
1430 | 0 | slidesorter::SlideSorterViewShell* pSlideSorterViewShell |
1431 | 0 | = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase()); |
1432 | 0 | if (pSlideSorterViewShell) |
1433 | 0 | xWatcher.reset(new KeepSlideSorterInSyncWithPageChanges(pSlideSorterViewShell->GetSlideSorter())); |
1434 | |
|
1435 | 0 | SfxUndoManager* pUndoManager = ImpGetUndoManager(); |
1436 | 0 | sal_uInt16 nNumber(1); |
1437 | 0 | const SfxItemSet* pReqArgs = rReq.GetArgs(); |
1438 | 0 | bool bRepair = false; |
1439 | |
|
1440 | 0 | if(pReqArgs) |
1441 | 0 | { |
1442 | 0 | const SfxUInt16Item* pUIntItem = static_cast<const SfxUInt16Item*>(&pReqArgs->Get(SID_REDO)); |
1443 | 0 | nNumber = pUIntItem->GetValue(); |
1444 | | // Repair mode: allow undo/redo of all undo actions, even if access would |
1445 | | // be limited based on the view shell ID. |
1446 | 0 | if (const SfxBoolItem* pRepairItem = pReqArgs->GetItemIfSet(SID_REPAIRPACKAGE, false)) |
1447 | 0 | bRepair = pRepairItem->GetValue(); |
1448 | 0 | } |
1449 | |
|
1450 | 0 | if(nNumber && pUndoManager) |
1451 | 0 | { |
1452 | 0 | sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); |
1453 | 0 | if(nCount >= nNumber) |
1454 | 0 | { |
1455 | 0 | if (comphelper::LibreOfficeKit::isActive() && !bRepair) |
1456 | 0 | { |
1457 | | // If another view created the first undo action, prevent redoing it from this view. |
1458 | 0 | const SfxUndoAction* pAction = pUndoManager->GetRedoAction(); |
1459 | 0 | if (pAction->GetViewShellId() != GetViewShellBase().GetViewShellId()) |
1460 | 0 | { |
1461 | 0 | rReq.SetReturnValue(SfxUInt32Item(SID_REDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); |
1462 | 0 | return; |
1463 | 0 | } |
1464 | 0 | } |
1465 | | |
1466 | 0 | try |
1467 | 0 | { |
1468 | | // when UndoStack is cleared by ModifyPageRedoAction |
1469 | | // the nCount may have changed, so test GetRedoActionCount() |
1470 | 0 | while (nNumber && pUndoManager->GetRedoActionCount()) |
1471 | 0 | { |
1472 | 0 | pUndoManager->Redo(); |
1473 | 0 | --nNumber; |
1474 | 0 | } |
1475 | 0 | } |
1476 | 0 | catch( const Exception& ) |
1477 | 0 | { |
1478 | | // no need to handle. By definition, the UndoManager handled this by clearing the |
1479 | | // Undo/Redo stacks |
1480 | 0 | } |
1481 | 0 | } |
1482 | | |
1483 | | // refresh rulers, maybe REDO was move of TAB marker in ruler |
1484 | 0 | if (mbHasRulers) |
1485 | 0 | { |
1486 | 0 | Invalidate(SID_ATTR_TABSTOP); |
1487 | 0 | } |
1488 | 0 | } |
1489 | | |
1490 | | // This one is corresponding to the default handling |
1491 | | // of SID_UNDO in sfx2 |
1492 | 0 | GetViewFrame()->GetBindings().InvalidateAll(false); |
1493 | |
|
1494 | 0 | rReq.Done(); |
1495 | 0 | } |
1496 | | |
1497 | | void ViewShell::ExecReq( SfxRequest& rReq ) |
1498 | 0 | { |
1499 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
1500 | 0 | switch( nSlot ) |
1501 | 0 | { |
1502 | 0 | case SID_MAIL_SCROLLBODY_PAGEDOWN: |
1503 | 0 | { |
1504 | 0 | rtl::Reference<FuPoor> xFunc( GetCurrentFunction() ); |
1505 | 0 | if( xFunc.is() ) |
1506 | 0 | ScrollLines( 0, -1 ); |
1507 | |
|
1508 | 0 | rReq.Done(); |
1509 | 0 | } |
1510 | 0 | break; |
1511 | | |
1512 | 0 | case SID_OUTPUT_QUALITY_COLOR: |
1513 | 0 | case SID_OUTPUT_QUALITY_GRAYSCALE: |
1514 | 0 | case SID_OUTPUT_QUALITY_BLACKWHITE: |
1515 | 0 | case SID_OUTPUT_QUALITY_CONTRAST: |
1516 | 0 | { |
1517 | 0 | DrawModeFlags nMode = OUTPUT_DRAWMODE_COLOR; |
1518 | |
|
1519 | 0 | switch( nSlot ) |
1520 | 0 | { |
1521 | 0 | case SID_OUTPUT_QUALITY_COLOR: nMode = OUTPUT_DRAWMODE_COLOR; break; |
1522 | 0 | case SID_OUTPUT_QUALITY_GRAYSCALE: nMode = OUTPUT_DRAWMODE_GRAYSCALE; break; |
1523 | 0 | case SID_OUTPUT_QUALITY_BLACKWHITE: nMode = OUTPUT_DRAWMODE_BLACKWHITE; break; |
1524 | 0 | case SID_OUTPUT_QUALITY_CONTRAST: nMode = OUTPUT_DRAWMODE_CONTRAST; break; |
1525 | 0 | } |
1526 | | |
1527 | 0 | GetActiveWindow()->GetOutDev()->SetDrawMode( nMode ); |
1528 | 0 | mpFrameView->SetDrawMode( nMode ); |
1529 | |
|
1530 | 0 | GetActiveWindow()->Invalidate(); |
1531 | |
|
1532 | 0 | Invalidate(); |
1533 | 0 | rReq.Done(); |
1534 | 0 | break; |
1535 | 0 | } |
1536 | 0 | } |
1537 | 0 | } |
1538 | | |
1539 | | /** This default implementation returns only an empty reference. See derived |
1540 | | classes for more interesting examples. |
1541 | | */ |
1542 | | rtl::Reference<comphelper::OAccessible> ViewShell::CreateAccessibleDocumentView(::sd::Window*) |
1543 | 0 | { |
1544 | 0 | OSL_FAIL("ViewShell::CreateAccessibleDocumentView should not be called!, perhaps Meyers, 3rd edition, Item 9:"); |
1545 | |
|
1546 | 0 | return {}; |
1547 | 0 | } |
1548 | | |
1549 | | ::sd::WindowUpdater* ViewShell::GetWindowUpdater() const |
1550 | 0 | { |
1551 | 0 | return mpWindowUpdater.get(); |
1552 | 0 | } |
1553 | | |
1554 | | ViewShellBase& ViewShell::GetViewShellBase() const |
1555 | 0 | { |
1556 | 0 | return *static_cast<ViewShellBase*>(GetViewShell()); |
1557 | 0 | } |
1558 | | |
1559 | | ViewShell::ShellType ViewShell::GetShellType() const |
1560 | 0 | { |
1561 | 0 | return meShellType; |
1562 | 0 | } |
1563 | | |
1564 | | DrawDocShell* ViewShell::GetDocSh() const |
1565 | 0 | { |
1566 | 0 | return GetViewShellBase().GetDocShell(); |
1567 | 0 | } |
1568 | | |
1569 | | SdDrawDocument* ViewShell::GetDoc() const |
1570 | 0 | { |
1571 | 0 | return GetViewShellBase().GetDocument(); |
1572 | 0 | } |
1573 | | |
1574 | | ErrCode ViewShell::DoVerb(sal_Int32 /*nVerb*/) |
1575 | 0 | { |
1576 | 0 | return ERRCODE_NONE; |
1577 | 0 | } |
1578 | | |
1579 | | void ViewShell::SetCurrentFunction( const rtl::Reference<FuPoor>& xFunction) |
1580 | 0 | { |
1581 | 0 | if( mxCurrentFunction.is() && (mxOldFunction != mxCurrentFunction) ) |
1582 | 0 | mxCurrentFunction->Dispose(); |
1583 | 0 | rtl::Reference<FuPoor> xDisposeAfterNewOne( mxCurrentFunction ); |
1584 | 0 | mxCurrentFunction = xFunction; |
1585 | 0 | } |
1586 | | |
1587 | | void ViewShell::SetOldFunction(const rtl::Reference<FuPoor>& xFunction) |
1588 | 0 | { |
1589 | 0 | if( mxOldFunction.is() && (xFunction != mxOldFunction) && (mxCurrentFunction != mxOldFunction) ) |
1590 | 0 | mxOldFunction->Dispose(); |
1591 | |
|
1592 | 0 | rtl::Reference<FuPoor> xDisposeAfterNewOne( mxOldFunction ); |
1593 | 0 | mxOldFunction = xFunction; |
1594 | 0 | } |
1595 | | |
1596 | | /** this method deactivates the current function. If an old function is |
1597 | | saved, this will become activated and current function. |
1598 | | */ |
1599 | | void ViewShell::Cancel() |
1600 | 0 | { |
1601 | 0 | if(mxCurrentFunction.is() && (mxCurrentFunction != mxOldFunction )) |
1602 | 0 | { |
1603 | 0 | rtl::Reference<FuPoor> xTemp( mxCurrentFunction ); |
1604 | 0 | mxCurrentFunction.clear(); |
1605 | 0 | xTemp->Deactivate(); |
1606 | 0 | xTemp->Dispose(); |
1607 | 0 | } |
1608 | |
|
1609 | 0 | if(mxOldFunction.is()) |
1610 | 0 | { |
1611 | 0 | mxCurrentFunction = mxOldFunction; |
1612 | 0 | mxCurrentFunction->Activate(); |
1613 | 0 | } |
1614 | 0 | } |
1615 | | |
1616 | | void ViewShell::DeactivateCurrentFunction( bool bPermanent /* == false */ ) |
1617 | 0 | { |
1618 | 0 | if( mxCurrentFunction.is() ) |
1619 | 0 | { |
1620 | 0 | if(bPermanent && (mxOldFunction == mxCurrentFunction)) |
1621 | 0 | mxOldFunction.clear(); |
1622 | |
|
1623 | 0 | mxCurrentFunction->Deactivate(); |
1624 | 0 | if( mxCurrentFunction != mxOldFunction ) |
1625 | 0 | mxCurrentFunction->Dispose(); |
1626 | |
|
1627 | 0 | rtl::Reference<FuPoor> xDisposeAfterNewOne( mxCurrentFunction ); |
1628 | 0 | mxCurrentFunction.clear(); |
1629 | 0 | } |
1630 | 0 | } |
1631 | | |
1632 | | void ViewShell::DisposeFunctions() |
1633 | 0 | { |
1634 | 0 | if(mxCurrentFunction.is()) |
1635 | 0 | { |
1636 | 0 | rtl::Reference<FuPoor> xTemp( mxCurrentFunction ); |
1637 | 0 | mxCurrentFunction.clear(); |
1638 | 0 | xTemp->Deactivate(); |
1639 | 0 | xTemp->Dispose(); |
1640 | 0 | } |
1641 | |
|
1642 | 0 | if(mxOldFunction.is()) |
1643 | 0 | { |
1644 | 0 | rtl::Reference<FuPoor> xDisposeAfterNewOne( mxOldFunction ); |
1645 | 0 | mxOldFunction->Dispose(); |
1646 | 0 | mxOldFunction.clear(); |
1647 | 0 | } |
1648 | 0 | } |
1649 | | |
1650 | | bool ViewShell::IsMainViewShell() const |
1651 | 0 | { |
1652 | 0 | return mpImpl->mbIsMainViewShell; |
1653 | 0 | } |
1654 | | |
1655 | | void ViewShell::SetIsMainViewShell (bool bIsMainViewShell) |
1656 | 0 | { |
1657 | 0 | if (bIsMainViewShell != mpImpl->mbIsMainViewShell) |
1658 | 0 | { |
1659 | 0 | mpImpl->mbIsMainViewShell = bIsMainViewShell; |
1660 | 0 | if (bIsMainViewShell) |
1661 | 0 | GetDocSh()->Connect (this); |
1662 | 0 | else |
1663 | 0 | GetDocSh()->Disconnect (this); |
1664 | 0 | } |
1665 | 0 | } |
1666 | | |
1667 | | void ViewShell::PrePaint() |
1668 | 0 | { |
1669 | 0 | } |
1670 | | |
1671 | | void ViewShell::Paint (const ::tools::Rectangle&, ::sd::Window* ) |
1672 | 0 | { |
1673 | 0 | } |
1674 | | |
1675 | | void ViewShell::ShowUIControls (bool bVisible) |
1676 | 0 | { |
1677 | 0 | if (mbHasRulers) |
1678 | 0 | { |
1679 | 0 | if (mpHorizontalRuler) |
1680 | 0 | mpHorizontalRuler->Show( bVisible ); |
1681 | |
|
1682 | 0 | if (mpVerticalRuler) |
1683 | 0 | mpVerticalRuler->Show( bVisible ); |
1684 | 0 | } |
1685 | |
|
1686 | 0 | if (mpVerticalScrollBar) |
1687 | 0 | mpVerticalScrollBar->Show( bVisible ); |
1688 | |
|
1689 | 0 | if (mpHorizontalScrollBar) |
1690 | 0 | mpHorizontalScrollBar->Show( bVisible ); |
1691 | |
|
1692 | 0 | if (mpContentWindow) |
1693 | 0 | mpContentWindow->Show( bVisible ); |
1694 | 0 | } |
1695 | | |
1696 | | bool ViewShell::RelocateToParentWindow (vcl::Window* pParentWindow) |
1697 | 0 | { |
1698 | 0 | mpParentWindow = pParentWindow; |
1699 | |
|
1700 | 0 | mpParentWindow->SetBackground (Wallpaper()); |
1701 | |
|
1702 | 0 | if (mpContentWindow) |
1703 | 0 | mpContentWindow->SetParent(pParentWindow); |
1704 | |
|
1705 | 0 | if (mpHorizontalScrollBar) |
1706 | 0 | mpHorizontalScrollBar->SetParent(mpParentWindow); |
1707 | 0 | if (mpVerticalScrollBar) |
1708 | 0 | mpVerticalScrollBar->SetParent(mpParentWindow); |
1709 | |
|
1710 | 0 | return true; |
1711 | 0 | } |
1712 | | |
1713 | | void ViewShell::SwitchViewFireFocus(const css::uno::Reference< css::accessibility::XAccessible >& xAcc ) |
1714 | 0 | { |
1715 | 0 | if (xAcc) |
1716 | 0 | { |
1717 | 0 | ::accessibility::AccessibleDocumentViewBase* pBase = static_cast< ::accessibility::AccessibleDocumentViewBase* >(xAcc.get()); |
1718 | 0 | if (pBase) |
1719 | 0 | pBase->SwitchViewActivated(); |
1720 | 0 | } |
1721 | 0 | } |
1722 | | void ViewShell::SwitchActiveViewFireFocus() |
1723 | 0 | { |
1724 | 0 | if (mpContentWindow) |
1725 | 0 | { |
1726 | 0 | SwitchViewFireFocus(mpContentWindow->GetAccessible(false)); |
1727 | 0 | } |
1728 | 0 | } |
1729 | | // move these two methods from DrawViewShell. |
1730 | | void ViewShell::fireSwitchCurrentPage(sal_Int32 pageIndex) |
1731 | 0 | { |
1732 | 0 | GetViewShellBase().GetDrawController()->fireSwitchCurrentPage(pageIndex); |
1733 | 0 | } |
1734 | | void ViewShell::NotifyAccUpdate( ) |
1735 | 0 | { |
1736 | 0 | GetViewShellBase().GetDrawController()->NotifyAccUpdate(); |
1737 | 0 | } |
1738 | | |
1739 | | weld::Window* ViewShell::GetFrameWeld() const |
1740 | 0 | { |
1741 | 0 | return mpActiveWindow ? mpActiveWindow->GetFrameWeld() : nullptr; |
1742 | 0 | } |
1743 | | |
1744 | | sd::Window* ViewShell::GetContentWindow() const |
1745 | 0 | { |
1746 | 0 | return mpContentWindow.get(); |
1747 | 0 | } |
1748 | | |
1749 | | } // end of namespace sd |
1750 | | |
1751 | | //===== ViewShellObjectBarFactory ============================================= |
1752 | | |
1753 | | namespace { |
1754 | | |
1755 | | ViewShellObjectBarFactory::ViewShellObjectBarFactory ( |
1756 | | ::sd::ViewShell& rViewShell) |
1757 | 0 | : mrViewShell (rViewShell) |
1758 | 0 | { |
1759 | 0 | } |
1760 | | |
1761 | | SfxShell* ViewShellObjectBarFactory::CreateShell( ::sd::ShellId nId ) |
1762 | 0 | { |
1763 | 0 | SfxShell* pShell = nullptr; |
1764 | |
|
1765 | 0 | ::sd::View* pView = mrViewShell.GetView(); |
1766 | 0 | switch (nId) |
1767 | 0 | { |
1768 | 0 | case ToolbarId::Bezier_Toolbox_Sd: |
1769 | 0 | pShell = new ::sd::BezierObjectBar(mrViewShell, pView); |
1770 | 0 | break; |
1771 | | |
1772 | 0 | case ToolbarId::Draw_Text_Toolbox_Sd: |
1773 | 0 | pShell = new ::sd::TextObjectBar( |
1774 | 0 | mrViewShell, mrViewShell.GetDoc()->GetPool(), pView); |
1775 | 0 | break; |
1776 | | |
1777 | 0 | case ToolbarId::Draw_Graf_Toolbox: |
1778 | 0 | pShell = new ::sd::GraphicObjectBar(mrViewShell, pView); |
1779 | 0 | break; |
1780 | | |
1781 | 0 | case ToolbarId::Draw_Media_Toolbox: |
1782 | 0 | pShell = new ::sd::MediaObjectBar(mrViewShell, pView); |
1783 | 0 | break; |
1784 | | |
1785 | 0 | case ToolbarId::Draw_Table_Toolbox: |
1786 | 0 | pShell = ::sd::ui::table::CreateTableObjectBar( mrViewShell, pView ); |
1787 | 0 | break; |
1788 | | |
1789 | 0 | case ToolbarId::Svx_Extrusion_Bar: |
1790 | 0 | pShell = new svx::ExtrusionBar( |
1791 | 0 | &mrViewShell.GetViewShellBase()); |
1792 | 0 | break; |
1793 | | |
1794 | 0 | case ToolbarId::Svx_Fontwork_Bar: |
1795 | 0 | pShell = new svx::FontworkBar( |
1796 | 0 | &mrViewShell.GetViewShellBase()); |
1797 | 0 | break; |
1798 | | |
1799 | 0 | default: |
1800 | 0 | pShell = nullptr; |
1801 | 0 | break; |
1802 | 0 | } |
1803 | | |
1804 | 0 | return pShell; |
1805 | 0 | } |
1806 | | |
1807 | | void ViewShellObjectBarFactory::ReleaseShell (SfxShell* pShell) |
1808 | 0 | { |
1809 | 0 | delete pShell; |
1810 | 0 | } |
1811 | | |
1812 | | } // end of anonymous namespace |
1813 | | |
1814 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |