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