LibreOffice Module sd (master) 1
sdwindow.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <Window.hxx>
21#include <sfx2/bindings.hxx>
22#include <sfx2/request.hxx>
23
24#include <sfx2/viewfrm.hxx>
25#include <svx/svxids.hrc>
26
27#include <editeng/outliner.hxx>
28#include <editeng/editview.hxx>
29#include <editeng/editeng.hxx>
30
31#include <app.hrc>
32#include <ViewShell.hxx>
33#include <DrawViewShell.hxx>
34#include <DrawDocShell.hxx>
36#include <View.hxx>
37#include <FrameView.hxx>
38#include <OutlineViewShell.hxx>
39#include <OutlineView.hxx>
40#include <drawdoc.hxx>
41#include <WindowUpdater.hxx>
42#include <ViewShellBase.hxx>
43#include <uiobject.hxx>
44
45#include <officecfg/Office/Common.hxx>
46#include <sal/log.hxx>
47#include <tools/debug.hxx>
48#include <vcl/commandevent.hxx>
49#include <vcl/settings.hxx>
50#include <comphelper/lok.hxx>
51#include <sfx2/lokhelper.hxx>
52
53namespace sd {
54
55#define SCROLL_LINE_FACT 0.05
56#define SCROLL_PAGE_FACT 0.5
57#define SCROLL_SENSITIVE 20
58#define ZOOM_MULTIPLICATOR 10000
59#define MIN_ZOOM 5
60#define MAX_ZOOM 3000
61
63 : vcl::DocWindow(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
64 DropTargetHelper( this ),
65 maWinPos(0, 0), // precautionary; but the values should be set
66 maViewOrigin(0, 0), // again from the owner of the window
67 maViewSize(1000, 1000),
68 maPrevSize(-1,-1),
69 mnMinZoom(MIN_ZOOM),
70 mnMaxZoom(MAX_ZOOM),
71 mbMinZoomAutoCalc(false),
72 mbCenterAllowed(true),
73 mnTicks (0),
74 mpViewShell(nullptr),
75 mbUseDropScroll (true)
76{
77 SetDialogControlFlags( DialogControlFlags::Return | DialogControlFlags::WantFocus );
78
80 aMap.SetMapUnit(MapUnit::Map100thMM);
82
83 // with it, the vcl::WindowColor is used in the slide mode
84 SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
85
86 // adjust contrast mode initially
87 bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
88 GetOutDev()->SetDrawMode( bUseContrast
91
92 // #i78183# Added after discussed with AF
93 EnableRTL(false);
94}
95
97{
99}
100
102{
103 if (mpViewShell != nullptr)
104 {
105 WindowUpdater* pWindowUpdater = mpViewShell->GetWindowUpdater();
106 if (pWindowUpdater != nullptr)
107 pWindowUpdater->UnregisterWindow (this);
108 }
109 DropTargetHelper::dispose();
111}
112
114{
115 WindowUpdater* pWindowUpdater = nullptr;
116 // Unregister at device updater of old view shell.
117 if (mpViewShell != nullptr)
118 {
119 pWindowUpdater = mpViewShell->GetWindowUpdater();
120 if (pWindowUpdater != nullptr)
121 pWindowUpdater->UnregisterWindow (this);
122 }
123
124 mpViewShell = pViewSh;
125
126 // Register at device updater of new view shell
127 if (mpViewShell != nullptr)
128 {
129 pWindowUpdater = mpViewShell->GetWindowUpdater();
130 if (pWindowUpdater != nullptr)
131 pWindowUpdater->RegisterWindow (this);
132 }
133}
134
136{
137 return mpViewShell;
138}
139
141{
142 // Are we entitled to change the minimal zoom factor?
143 if ( !mbMinZoomAutoCalc )
144 return;
145
146 // Get current zoom factor.
147 ::tools::Long nZoom = GetZoom();
148
149 // Get the rectangle of the output area in logical coordinates
150 // and calculate the scaling factors that would lead to the view
151 // area (also called application area) to completely fill the
152 // window.
154 sal_uLong nX = static_cast<sal_uLong>(static_cast<double>(aWinSize.Width())
155 * double(ZOOM_MULTIPLICATOR) / static_cast<double>(maViewSize.Width()));
156 sal_uLong nY = static_cast<sal_uLong>(static_cast<double>(aWinSize.Height())
157 * double(ZOOM_MULTIPLICATOR) / static_cast<double>(maViewSize.Height()));
158
159 // Decide whether to take the larger or the smaller factor.
160 sal_uLong nFact = std::min(nX, nY);
161
162 // The factor is transformed according to the current zoom factor.
163 nFact = nFact * nZoom / ZOOM_MULTIPLICATOR;
164 mnMinZoom = std::max(sal_uInt16(MIN_ZOOM), static_cast<sal_uInt16>(nFact));
165
166 // If the current zoom factor is smaller than the calculated minimal
167 // zoom factor then set the new minimal factor as the current zoom
168 // factor.
169 if ( nZoom < static_cast<::tools::Long>(mnMinZoom) )
171}
172
174{
175 mnMinZoom = static_cast<sal_uInt16>(nMin);
176}
177
179{
180 mnMaxZoom = static_cast<sal_uInt16>(nMax);
181}
182
184{
185 if( GetMapMode().GetScaleX().GetDenominator() )
186 {
187 return ::tools::Long(GetMapMode().GetScaleX() * 100);
188 }
189 else
190 {
191 return 0;
192 }
193}
194
196{
198 CalcMinZoom();
199
201 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
202}
203
204void Window::PrePaint(vcl::RenderContext& /*rRenderContext*/)
205{
206 if ( mpViewShell )
208}
209
210void Window::Paint(vcl::RenderContext& /*rRenderContext*/, const ::tools::Rectangle& rRect)
211{
212 if ( mpViewShell )
213 mpViewShell->Paint(rRect, this);
214}
215
216void Window::KeyInput(const KeyEvent& rKEvt)
217{
218 if (getenv("SD_DEBUG") && rKEvt.GetKeyCode().GetCode() == KEY_F12 && mpViewShell)
219 {
220 mpViewShell->GetDoc()->dumpAsXml(nullptr);
222 pOLV->GetEditView().GetEditEngine()->dumpAsXmlEditDoc(nullptr);
223 return;
224 }
225
226 if (!(mpViewShell && mpViewShell->KeyInput(rKEvt, this)))
227 {
228 if (mpViewShell && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
229 {
231 }
232 else
233 {
235 }
236 }
237}
238
240{
241 if ( mpViewShell )
242 mpViewShell->MouseButtonDown(rMEvt, this);
243}
244
246{
247 if ( mpViewShell )
248 mpViewShell->MouseMove(rMEvt, this);
249}
250
252{
253 mnTicks = 0;
254
255 if ( mpViewShell )
256 mpViewShell->MouseButtonUp(rMEvt, this);
257}
258
260{
261 if (mpViewShell)
262 mpViewShell->Command(rCEvt, this);
263 //pass at least alt press/release to parent impl
264 if (rCEvt.GetCommand() == CommandEventId::ModKeyChange)
266 //show the text edit outliner view cursor
267 else if (mpViewShell && !HasFocus() && rCEvt.GetCommand() == CommandEventId::CursorPos)
268 {
269 // tdf#138855 Getting Focus may destroy TextEditOutlinerView so Grab if
270 // text editing active, but fetch the TextEditOutlinerView post-grab
272 {
273 GrabFocus();
275 if (pOLV && this == pOLV->GetWindow())
276 pOLV->ShowCursor();
277 }
278 }
279}
280
282{
283 bool bResult = false;
284 if ( mpViewShell )
285 {
286 bResult = mpViewShell->Notify(rNEvt, this);
287 }
288 if( !bResult )
289 bResult = vcl::Window::EventNotify(rNEvt);
290
291 return bResult;
292}
293
295{
296 if (!mpViewShell || !mpViewShell->RequestHelp(rEvt))
298}
299
305{
306 maWinPos = rPnt;
307}
308
313{
314 maViewOrigin = rPnt;
315}
316
320void Window::SetViewSize(const Size& rSize)
321{
322 maViewSize = rSize;
323 CalcMinZoom();
324}
325
326void Window::SetCenterAllowed (bool bIsAllowed)
327{
328 mbCenterAllowed = bIsAllowed;
329}
330
332{
333 // Clip the zoom factor to the valid range marked by nMinZoom as
334 // calculated by CalcMinZoom() and the constant MAX_ZOOM.
335 if ( nZoom > MAX_ZOOM )
336 nZoom = MAX_ZOOM;
337 if ( nZoom < static_cast<::tools::Long>(mnMinZoom) )
338 nZoom = mnMinZoom;
339
340 // Set the zoom factor at the window's map mode.
342 {
344 aMap.SetScaleX(Fraction(nZoom, 100));
345 aMap.SetScaleY(Fraction(nZoom, 100));
347 }
348
349 // invalidate previous size - it was relative to the old scaling
350 maPrevSize = Size(-1,-1);
351
352 // Update the map mode's origin (to what effect?).
354
355 // Update the view's snapping to the new zoom factor.
356 if ( auto pDrawViewShell = dynamic_cast< DrawViewShell *>( mpViewShell ) )
357 pDrawViewShell->GetView()->RecalcLogicSnapMagnetic(*GetOutDev());
358
359 // Return the zoom factor just in case it has been changed above to lie
360 // inside the valid range.
361 return nZoom;
362}
363
365{
366 // Clip the zoom factor to the valid range marked by nMinZoom as
367 // previously calculated by <member>CalcMinZoom()</member> and the
368 // MAX_ZOOM constant.
369 if ( nZoom > MAX_ZOOM )
370 nZoom = MAX_ZOOM;
371 if ( nZoom < static_cast<::tools::Long>(mnMinZoom) )
372 nZoom = mnMinZoom;
373
374 // Calculate the window's new origin.
376 ::tools::Long nW = aSize.Width() * GetZoom() / nZoom;
377 ::tools::Long nH = aSize.Height() * GetZoom() / nZoom;
378 maWinPos.AdjustX((aSize.Width() - nW) / 2 );
379 maWinPos.AdjustY((aSize.Height() - nH) / 2 );
380 if ( maWinPos.X() < 0 ) maWinPos.setX( 0 );
381 if ( maWinPos.Y() < 0 ) maWinPos.setY( 0 );
382
383 // Finally update this window's map mode to the given zoom factor that
384 // has been clipped to the valid range.
385 SetZoomFactor(nZoom);
386}
387
388::tools::Long Window::GetZoomForRect( const ::tools::Rectangle& rZoomRect )
389{
390 ::tools::Long nRetZoom = 100;
391
392 if( (rZoomRect.GetWidth() != 0) && (rZoomRect.GetHeight() != 0))
393 {
394 // Calculate the scale factors which will lead to the given
395 // rectangle being fully visible (when translated accordingly) as
396 // large as possible in the output area independently in both
397 // coordinate directions .
398 sal_uLong nX(0);
399 sal_uLong nY(0);
400
401 const Size aWinSize( PixelToLogic(GetOutputSizePixel()) );
402 if(rZoomRect.GetHeight())
403 {
404 nX = static_cast<sal_uLong>(static_cast<double>(aWinSize.Height())
405 * double(ZOOM_MULTIPLICATOR) / static_cast<double>(rZoomRect.GetHeight()));
406 }
407
408 if(rZoomRect.GetWidth())
409 {
410 nY = static_cast<sal_uLong>(static_cast<double>(aWinSize.Width())
411 * double(ZOOM_MULTIPLICATOR) / static_cast<double>(rZoomRect.GetWidth()));
412 }
413
414 // Use the smaller one of both so that the zoom rectangle will be
415 // fully visible with respect to both coordinate directions.
416 sal_uLong nFact = std::min(nX, nY);
417
418 // Transform the current zoom factor so that it leads to the desired
419 // scaling.
420 nRetZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
421
422 // Calculate the new origin.
423 if ( nFact == 0 )
424 {
425 // Don't change anything if the scale factor is degenerate.
426 nRetZoom = GetZoom();
427 }
428 else
429 {
430 // Clip the zoom factor to the valid range marked by nMinZoom as
431 // previously calculated by <member>CalcMinZoom()</member> and the
432 // MAX_ZOOM constant.
433 if ( nRetZoom > MAX_ZOOM )
434 nRetZoom = MAX_ZOOM;
435 if ( nRetZoom < static_cast<::tools::Long>(mnMinZoom) )
436 nRetZoom = mnMinZoom;
437 }
438 }
439
440 return nRetZoom;
441}
442
447::tools::Long Window::SetZoomRect (const ::tools::Rectangle& rZoomRect)
448{
449 ::tools::Long nNewZoom = 100;
450
451 if (rZoomRect.GetWidth() == 0 || rZoomRect.GetHeight() == 0)
452 {
453 // The given rectangle is degenerate. Use the default zoom factor
454 // (above) of 100%.
455 SetZoomIntegral(nNewZoom);
456 }
457 else
458 {
459 Point aPos = rZoomRect.TopLeft();
460 // Transform the output area from pixel coordinates into logical
461 // coordinates.
463 // Paranoia! The degenerate case of zero width or height has been
464 // taken care of above.
465 DBG_ASSERT(rZoomRect.GetWidth(), "ZoomRect-Width = 0!");
466 DBG_ASSERT(rZoomRect.GetHeight(), "ZoomRect-Height = 0!");
467
468 // Calculate the scale factors which will lead to the given
469 // rectangle being fully visible (when translated accordingly) as
470 // large as possible in the output area independently in both
471 // coordinate directions .
472 sal_uLong nX(0);
473 sal_uLong nY(0);
474
475 if(rZoomRect.GetHeight())
476 {
477 nX = static_cast<sal_uLong>(static_cast<double>(aWinSize.Height())
478 * double(ZOOM_MULTIPLICATOR) / static_cast<double>(rZoomRect.GetHeight()));
479 }
480
481 if(rZoomRect.GetWidth())
482 {
483 nY = static_cast<sal_uLong>(static_cast<double>(aWinSize.Width())
484 * double(ZOOM_MULTIPLICATOR) / static_cast<double>(rZoomRect.GetWidth()));
485 }
486
487 // Use the smaller one of both so that the zoom rectangle will be
488 // fully visible with respect to both coordinate directions.
489 sal_uLong nFact = std::min(nX, nY);
490
491 // Transform the current zoom factor so that it leads to the desired
492 // scaling.
493 ::tools::Long nZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
494
495 // Calculate the new origin.
496 if ( nFact == 0 )
497 {
498 // Don't change anything if the scale factor is degenerate.
499 nNewZoom = GetZoom();
500 }
501 else
502 {
503 // Calculate the new window position that centers the given
504 // rectangle on the screen.
505 if ( nZoom > MAX_ZOOM )
506 nFact = nFact * MAX_ZOOM / nZoom;
507
508 maWinPos = maViewOrigin + aPos;
509
510 aWinSize.setWidth( static_cast<::tools::Long>(static_cast<double>(aWinSize.Width()) * double(ZOOM_MULTIPLICATOR) / static_cast<double>(nFact)) );
511 maWinPos.AdjustX((rZoomRect.GetWidth() - aWinSize.Width()) / 2 );
512 aWinSize.setHeight( static_cast<::tools::Long>(static_cast<double>(aWinSize.Height()) * double(ZOOM_MULTIPLICATOR) / static_cast<double>(nFact)) );
513 maWinPos.AdjustY((rZoomRect.GetHeight() - aWinSize.Height()) / 2 );
514
515 if ( maWinPos.X() < 0 ) maWinPos.setX( 0 );
516 if ( maWinPos.Y() < 0 ) maWinPos.setY( 0 );
517
518 // Adapt the window's map mode to the new zoom factor.
519 nNewZoom = SetZoomFactor(nZoom);
520 }
521 }
522
523 return nNewZoom;
524}
525
527{
528 mbMinZoomAutoCalc = bAuto;
529}
530
536void Window::UpdateMapOrigin(bool bInvalidate)
537{
538 bool bChanged = false;
539 const Size aWinSize = PixelToLogic(GetOutputSizePixel());
540
541 if ( mbCenterAllowed )
542 {
543 if( maPrevSize != Size(-1,-1) )
544 {
545 // keep view centered around current pos, when window
546 // resizes
547 maWinPos.AdjustX( -((aWinSize.Width() - maPrevSize.Width()) / 2) );
548 maWinPos.AdjustY( -((aWinSize.Height() - maPrevSize.Height()) / 2) );
549 bChanged = true;
550 }
551
552 if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() )
553 {
554 maWinPos.setX( maViewSize.Width() - aWinSize.Width() );
555 bChanged = true;
556 }
557 if ( maWinPos.Y() > maViewSize.Height() - aWinSize.Height() )
558 {
559 maWinPos.setY( maViewSize.Height() - aWinSize.Height() );
560 bChanged = true;
561 }
562 if ( aWinSize.Width() > maViewSize.Width() || maWinPos.X() < 0 )
563 {
564 maWinPos.setX( maViewSize.Width() / 2 - aWinSize.Width() / 2 );
565 bChanged = true;
566 }
567 if ( aWinSize.Height() > maViewSize.Height() || maWinPos.Y() < 0 )
568 {
569 maWinPos.setY( maViewSize.Height() / 2 - aWinSize.Height() / 2 );
570 bChanged = true;
571 }
572 }
573
574 UpdateMapMode ();
575
576 maPrevSize = aWinSize;
577
578 // When tiled rendering, the above UpdateMapMode() call doesn't touch the map mode.
579 if (bChanged && bInvalidate && !comphelper::LibreOfficeKit::isActive())
580 Invalidate();
581}
582
584{
586 Size aPix(maWinPos.X(), maWinPos.Y());
587 aPix = LogicToPixel(aPix);
588 // Size has to be a multiple of BRUSH_SIZE due to the correct depiction of
589 // pattern
590 // #i2237#
591 // removed old stuff here which still forced zoom to be
592 // %BRUSH_SIZE which is outdated now
593
594 if (dynamic_cast< DrawViewShell *>( mpViewShell ))
595 {
596 // page should not "stick" to the window border
597 if (aPix.Width() == 0)
598 {
599 // #i2237#
600 // Since BRUSH_SIZE alignment is outdated now, i use the
601 // former constant here directly
602 aPix.AdjustWidth( -8 );
603 }
604 if (aPix.Height() == 0)
605 {
606 // #i2237#
607 // Since BRUSH_SIZE alignment is outdated now, i use the
608 // former constant here directly
609 aPix.AdjustHeight( -8 );
610 }
611 }
612
613 aPix = PixelToLogic(aPix);
614 maWinPos.setX( aPix.Width() );
615 maWinPos.setY( aPix.Height() );
616 Point aNewOrigin (-maWinPos.X(), -maWinPos.Y());
618
620 {
622 aMap.SetOrigin(aNewOrigin);
624 }
625}
626
632{
633 return maViewSize.Width() == 0 ? 0 : (static_cast<double>(maWinPos.X()) / maViewSize.Width());
634}
635
641{
642 return maViewSize.Height() == 0 ? 0 : (static_cast<double>(maWinPos.Y()) / maViewSize.Height());
643}
644
649void Window::SetVisibleXY(double fX, double fY)
650{
651 ::tools::Long nOldX = maWinPos.X();
652 ::tools::Long nOldY = maWinPos.Y();
653
654 if ( fX >= 0 )
655 maWinPos.setX( static_cast<::tools::Long>(fX * maViewSize.Width()) );
656 if ( fY >= 0 )
657 maWinPos.setY( static_cast<::tools::Long>(fY * maViewSize.Height()) );
658 UpdateMapOrigin(false);
659 Scroll(nOldX - maWinPos.X(), nOldY - maWinPos.Y(), ScrollFlags::Children);
661}
662
668{
670 if ( aWinSize.Width() > maViewSize.Width() )
671 aWinSize.setWidth( maViewSize.Width() );
672 return
673 maViewSize.Width() == 0 ? 0 : (static_cast<double>(aWinSize.Width()) / maViewSize.Width());
674}
675
681{
683 if ( aWinSize.Height() > maViewSize.Height() )
684 aWinSize.setHeight( maViewSize.Height() );
685 return maViewSize.Height() == 0
686 ? 0 : (static_cast<double>(aWinSize.Height()) / maViewSize.Height());
687}
688
690{
692
693 // For LOK
694 bool bMapModeWasEnabled(IsMapModeEnabled());
695 EnableMapMode(/*true*/);
696 aPos = PixelToLogic(aPos);
697 EnableMapMode(bMapModeWasEnabled);
698
699 return aPos;
700}
701
707{
709}
710
716{
718}
719
725{
727}
728
734{
736}
737
742{
743 mnTicks = 0;
745}
746
751{
752 mnTicks = 0;
754}
755
757{
758 vcl::Window::DataChanged( rDCEvt );
759
760 /* Omit PRINTER by all documents which are not using a printer.
761 Omit FONTS and FONTSUBSTITUTION if no text output is available or if the
762 document does not allow text. */
763
764 if ( !((rDCEvt.GetType() == DataChangedEventType::PRINTER) ||
765 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
766 (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
767 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
768 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
769 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) )
770 return;
771
772 if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
773 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
774 {
775 /* Rearrange or initiate Resize for scroll bars since the size of
776 the scroll bars my have changed. Within this, inside the resize-
777 handler, the size of the scroll bars will be asked from the
778 Settings. */
779 Resize();
780
781 /* Re-set data, which are from system control or from Settings. May
782 have to re-set more data since the resolution may also has
783 changed. */
784 if( mpViewShell )
785 {
786 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
787 DrawModeFlags nOutputMode;
788 sal_uInt16 nPreviewSlot;
789
790 if( rStyleSettings.GetHighContrastMode() )
791 nOutputMode = sd::OUTPUT_DRAWMODE_CONTRAST;
792 else
793 nOutputMode = sd::OUTPUT_DRAWMODE_COLOR;
794
795 if( rStyleSettings.GetHighContrastMode()
796 && officecfg::Office::Common::Accessibility::IsForPagePreviews::get() )
797 nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
798 else
799 nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
800
801 if( dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr )
802 {
803 GetOutDev()->SetDrawMode( nOutputMode );
804 mpViewShell->GetFrameView()->SetDrawMode( nOutputMode );
805 Invalidate();
806 }
807
808 // Overwrite window color for OutlineView
809 if( dynamic_cast< OutlineViewShell *>( mpViewShell ) != nullptr )
810 {
811 svtools::ColorConfig aColorConfig;
812 const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
813 SetBackground( Wallpaper( aDocColor ) );
814 }
815
816 SfxRequest aReq( nPreviewSlot, SfxCallMode::SLOT, mpViewShell->GetDocSh()->GetDoc()->GetItemPool() );
817 mpViewShell->ExecReq( aReq );
820
821 // re-create handles to show new outfit
822 if(dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr)
823 {
825 }
826 }
827 }
828
829 if ( (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
830 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
831 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
832 {
833 /* Virtual devices, which also depends on the resolution or the
834 system control, should be updated. Otherwise, we should update
835 the virtual devices at least at DataChangedEventType::DISPLAY since some
836 systems allow to change the resolution and color depth during
837 runtime. Or the virtual devices have to be updated when the color
838 palette has changed since a different color matching can be used
839 when outputting. */
840 }
841
842 if ( rDCEvt.GetType() == DataChangedEventType::FONTS )
843 {
844 /* If the document provides font choose boxes, we have to update
845 them. I don't know how this looks like (also not really me, I
846 only translated the comment ;). We may can handle it global. We
847 have to discuss it with PB, but he is ill at the moment.
848 Before we handle it here, discuss it with PB and me. */
849 }
850
851 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
852 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) )
853 {
854 /* Do reformatting since the fonts of the document may no longer
855 exist, or exist now, or are replaced with others. */
856 if( mpViewShell )
857 {
858 DrawDocShell* pDocSh = mpViewShell->GetDocSh();
859 if( pDocSh )
860 pDocSh->SetPrinter( pDocSh->GetPrinter( true ) );
861 }
862 }
863
864 if ( rDCEvt.GetType() == DataChangedEventType::PRINTER )
865 {
866 /* I don't know how the handling should look like. Maybe we delete a
867 printer and look what we have to do. Maybe I have to add
868 something to the VCL, in case the used printer is deleted.
869 Otherwise I may recalculate the formatting here if the current
870 printer is destroyed. */
871 if( mpViewShell )
872 {
873 DrawDocShell* pDocSh = mpViewShell->GetDocSh();
874 if( pDocSh )
875 pDocSh->SetPrinter( pDocSh->GetPrinter( true ) );
876 }
877 }
878
879 // Update everything
880 Invalidate();
881}
882
884{
886
888 {
889 nRet = mpViewShell->AcceptDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
890
891 if (mbUseDropScroll && dynamic_cast< OutlineViewShell *>( mpViewShell ) == nullptr)
892 DropScroll( rEvt.maPosPixel );
893 }
894
895 return nRet;
896}
897
899{
901
902 if( mpViewShell )
903 {
904 nRet = mpViewShell->ExecuteDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
905 }
906
907 return nRet;
908}
909
910void Window::SetUseDropScroll (bool bUseDropScroll)
911{
912 mbUseDropScroll = bUseDropScroll;
913}
914
915void Window::DropScroll(const Point& rMousePos)
916{
917 short nDx = 0;
918 short nDy = 0;
919
920 Size aSize = GetOutputSizePixel();
921
922 if (aSize.Width() > SCROLL_SENSITIVE * 3)
923 {
924 if ( rMousePos.X() < SCROLL_SENSITIVE )
925 {
926 nDx = -1;
927 }
928
929 if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE )
930 {
931 nDx = 1;
932 }
933 }
934
935 if (aSize.Height() > SCROLL_SENSITIVE * 3)
936 {
937 if ( rMousePos.Y() < SCROLL_SENSITIVE )
938 {
939 nDy = -1;
940 }
941
942 if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE )
943 {
944 nDy = 1;
945 }
946 }
947
948 if ( (nDx || nDy) && (rMousePos.X()!=0 || rMousePos.Y()!=0 ) )
949 {
950 if (mnTicks > 20)
951 mpViewShell->ScrollLines(nDx, nDy);
952 else
953 mnTicks ++;
954 }
955}
956
957css::uno::Reference<css::accessibility::XAccessible>
959{
960 // If current viewshell is PresentationViewShell, just return empty because the correct ShowWin will be created later.
961 if (dynamic_cast< PresentationViewShell *>( mpViewShell ))
962 {
964 }
965 css::uno::Reference< css::accessibility::XAccessible > xAcc = GetAccessible(false);
966 if (xAcc)
967 {
968 return xAcc;
969 }
970 if (mpViewShell != nullptr)
971 {
973 SetAccessible(xAcc);
974 return xAcc;
975 }
976 else
977 {
978 SAL_WARN("sd", "::sd::Window::CreateAccessible: no view shell");
980 }
981}
982
984{
985 OutlinerView *pOLV = nullptr;
986 sd::View* pView = mpViewShell->GetView();
988 {
989 if (OutlineView* pOView = dynamic_cast<OutlineView*>(pView))
990 pOLV = pOView->GetViewByWindow(this);
991 }
992 else if (pView->IsTextEdit())
993 {
994 pOLV = pView->GetTextEditOutlinerView();
995 }
996 return pOLV;
997}
998
1000{
1001 OutlinerView *pOLV = GetOutlinerView();
1002 if (pOLV)
1003 return pOLV->GetEditView().GetSurroundingText();
1004 return OUString();
1005}
1006
1008{
1009 OutlinerView *pOLV = GetOutlinerView();
1010 if (pOLV)
1012 return Selection( 0, 0 );
1013}
1014
1016{
1017 OutlinerView *pOLV = GetOutlinerView();
1018 if (pOLV)
1019 return pOLV->GetEditView().DeleteSurroundingText(rSelection);
1020 return false;
1021}
1022
1023void Window::LogicInvalidate(const ::tools::Rectangle* pRectangle)
1024{
1025 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
1026 if (!pDrawViewShell || pDrawViewShell->IsInSwitchPage())
1027 return;
1028
1030 return;
1031 ::tools::Rectangle aRectangle;
1032 ::tools::Rectangle* pResultRectangle;
1033 if (!pRectangle)
1034 pResultRectangle = nullptr;
1035 else
1036 {
1037 aRectangle = *pRectangle;
1038 if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
1039 {
1040 aRectangle = o3tl::convert(aRectangle, o3tl::Length::mm100, o3tl::Length::twip);
1041 }
1042 pResultRectangle = &aRectangle;
1043 }
1044 SfxViewShell& rSfxViewShell = pDrawViewShell->GetViewShellBase();
1045 SfxLokHelper::notifyInvalidation(&rSfxViewShell, pResultRectangle);
1046}
1047
1049{
1050 if (get_id() == "impress_win")
1052
1054}
1055
1056} // end of namespace sd
1057
1058/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawModeFlags
const StyleSettings & GetStyleSettings() const
CommandEventId GetCommand() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
bool DeleteSurroundingText(const Selection &rRange)
OUString GetSurroundingText() const
Selection GetSurroundingTextSelection() const
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: uiobject.cxx:177
const vcl::KeyCode & GetKeyCode() const
MapUnit GetMapUnit() const
vcl::Window * GetWindow() const
EditView & GetEditView() const
void ShowCursor(bool bGotoCursor=true, bool bActivate=false)
void SetDrawMode(DrawModeFlags nDrawMode)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: drawdoc.cxx:1179
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
const SfxItemPool & GetItemPool() const
const OutlinerView * GetTextEditOutlinerView() const
virtual bool IsTextEdit() const final override
void Invalidate(sal_uInt16 nId)
static void notifyInvalidation(SfxViewShell const *pThisView, tools::Rectangle const *)
bool IsReadOnly() const
virtual void Invalidate(sal_uInt16 nId=0)
SfxViewShell * GetViewShell() const
SfxBindings & GetBindings()
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
bool GetHighContrastMode() const
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
void SetPrinter(SfxPrinter *pNewPrinter)
Set new SfxPrinter (transfer of ownership)
Definition: docshel4.cxx:142
SfxPrinter * GetPrinter(bool bCreate)
Creates (if necessary) and returns a SfxPrinter.
Definition: docshel4.cxx:95
SdDrawDocument * GetDoc()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
bool IsInSwitchPage() const
void SetDrawMode(DrawModeFlags nNewDrawMode)
Definition: FrameView.hxx:159
Show a textual overview of the text contents of all slides.
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
This view shell is responsible for showing the presentation of an Impress document.
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
virtual bool KeyInput(const KeyEvent &rKEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:391
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
bool RequestHelp(const HelpEvent &rEvt)
Definition: viewshe2.cxx:583
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
Definition: viewshe2.cxx:856
virtual void PrePaint()
Definition: viewshel.cxx:1510
virtual void Paint(const ::tools::Rectangle &rRect, ::sd::Window *pWin)
Definition: viewshel.cxx:1514
virtual void MouseMove(const MouseEvent &rMEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:551
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
Definition: viewshe2.cxx:867
virtual void Command(const CommandEvent &rCEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:621
virtual void MouseButtonUp(const MouseEvent &rMEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:584
::sd::WindowUpdater * GetWindowUpdater() const
Return the window updater of this view shell.
Definition: viewshel.cxx:1392
virtual void ArrangeGUIElements()
Set position and size of the GUI elements that are controlled by the view shell like rulers and scrol...
Definition: viewshel.cxx:965
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleDocumentView(::sd::Window *pWindow)
Create an accessible object representing the specified window.
Definition: viewshel.cxx:1385
FrameView * GetFrameView()
Definition: ViewShell.hxx:221
void ScrollLines(::tools::Long nX, ::tools::Long nY)
Scroll a specific number of lines.
Definition: viewshe2.cxx:251
::sd::View * GetView() const
Definition: ViewShell.hxx:144
virtual void MouseButtonDown(const MouseEvent &rMEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:458
bool Notify(NotifyEvent const &rNEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:645
void ExecReq(SfxRequest &rReq)
Definition: viewshel.cxx:1339
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
SD_DLLPUBLIC ShellType GetShellType() const
Return the type of the shell.
Definition: viewshel.cxx:1402
The purpose of the <type>WindowUpdater</type> is to update output devices to take care of modified gl...
void RegisterWindow(vcl::Window *pWindow)
Add the given device to the list of devices which will be updated when one of the monitored values ch...
void UnregisterWindow(vcl::Window *pWindow)
Remove the given device from the list of devices which will be updated when one of the monitored valu...
sal_uInt16 mnMinZoom
Definition: Window.hxx:162
::tools::Long mnTicks
Definition: Window.hxx:170
void DropScroll(const Point &rMousePos)
Definition: sdwindow.cxx:915
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: sdwindow.cxx:883
double GetVisibleWidth() const
Definition: sdwindow.cxx:667
::tools::Long SetZoomFactor(::tools::Long nZoom)
This internally used method performs the actual adaptation of the window's map mode to the specified ...
Definition: sdwindow.cxx:331
bool DeleteSurroundingText(const Selection &rSelection) override
Definition: sdwindow.cxx:1015
double GetScrlPageHeight() const
Definition: sdwindow.cxx:733
Size maViewSize
Definition: Window.hxx:160
OUString GetSurroundingText() const override
Definition: sdwindow.cxx:999
void GrabFocus()
Activate window.
Definition: sdwindow.cxx:750
Point maViewOrigin
Definition: Window.hxx:159
Selection GetSurroundingTextSelection() const override
Definition: sdwindow.cxx:1007
double GetVisibleX() const
Definition: sdwindow.cxx:631
virtual void LoseFocus() override
Deactivate window.
Definition: sdwindow.cxx:741
double GetVisibleY() const
Definition: sdwindow.cxx:640
FactoryFunction GetUITestFactory() const override
Definition: sdwindow.cxx:1048
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: sdwindow.cxx:898
sal_uInt16 mnMaxZoom
Definition: Window.hxx:163
void UpdateMapMode()
Definition: sdwindow.cxx:583
virtual void PrePaint(vcl::RenderContext &rRenderContext) override
Definition: sdwindow.cxx:204
void SetViewShell(ViewShell *pViewSh)
Definition: sdwindow.cxx:113
void SetViewSize(const Size &rSize)
Set size of the whole working area which can be seen with the window.
Definition: sdwindow.cxx:320
void CalcMinZoom()
Calculate the minimal zoom factor as the value at which the application area would completely fill th...
Definition: sdwindow.cxx:140
void SetMaxZoom(::tools::Long nMax)
Definition: sdwindow.cxx:178
double GetVisibleHeight() const
Definition: sdwindow.cxx:680
virtual ~Window() override
Definition: sdwindow.cxx:96
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
Definition: sdwindow.cxx:210
Size maPrevSize
Definition: Window.hxx:161
void SetUseDropScroll(bool bUseDropScroll)
The DropScroll() method is used by AcceptDrop() to scroll the content of the window while dragging an...
Definition: sdwindow.cxx:910
bool mbMinZoomAutoCalc
This flag tells whether to re-calculate the minimal zoom factor depending on the current zoom factor.
Definition: Window.hxx:168
void SetCenterAllowed(bool bIsAllowed)
Definition: sdwindow.cxx:326
double GetScrlLineHeight() const
Definition: sdwindow.cxx:715
void SetMinZoomAutoCalc(bool bAuto)
Definition: sdwindow.cxx:526
void SetMinZoom(::tools::Long nMin)
Definition: sdwindow.cxx:173
ViewShell * GetViewShell()
Definition: sdwindow.cxx:135
virtual void dispose() override
Definition: sdwindow.cxx:101
::tools::Long GetZoomForRect(const ::tools::Rectangle &rZoomRect)
Definition: sdwindow.cxx:388
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: sdwindow.cxx:216
void LogicInvalidate(const ::tools::Rectangle *pRectangle) override
Definition: sdwindow.cxx:1023
bool mbUseDropScroll
Definition: Window.hxx:173
void SetWinViewPos(const Point &rPnt)
Set the position of the upper left corner from the visible area of the window.
Definition: sdwindow.cxx:304
::tools::Long SetZoomRect(const ::tools::Rectangle &rZoomRect)
This method is called when the whole page shall be displayed in the window.
Definition: sdwindow.cxx:447
Window(vcl::Window *pParent)
Definition: sdwindow.cxx:62
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: sdwindow.cxx:756
Point maWinPos
Definition: Window.hxx:158
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: sdwindow.cxx:281
virtual void Command(const CommandEvent &rCEvt) override
Definition: sdwindow.cxx:259
virtual void RequestHelp(const HelpEvent &rEvt) override
Definition: sdwindow.cxx:294
void SetViewOrigin(const Point &rPnt)
Set origin of the representation in respect to the whole working area.
Definition: sdwindow.cxx:312
::tools::Long GetZoom() const
Definition: sdwindow.cxx:183
double GetScrlPageWidth() const
Definition: sdwindow.cxx:724
Point GetVisibleCenter()
Definition: sdwindow.cxx:689
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Create an accessibility object that makes this window accessible.
Definition: sdwindow.cxx:958
double GetScrlLineWidth() const
Definition: sdwindow.cxx:706
void SetVisibleXY(double fX, double fY)
Set x and y position of the visible area as fraction (< 1) of the whole working area.
Definition: sdwindow.cxx:649
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: sdwindow.cxx:251
OutlinerView * GetOutlinerView() const
Definition: sdwindow.cxx:983
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: sdwindow.cxx:239
bool mbCenterAllowed
Definition: Window.hxx:169
void UpdateMapOrigin(bool bInvalidate=true)
Calculate origin of the map mode according to the size of the view and window (its size in model coor...
Definition: sdwindow.cxx:536
ViewShell * mpViewShell
Definition: Window.hxx:172
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: sdwindow.cxx:245
void SetZoomIntegral(::tools::Long nZoom)
Set the zoom factor to the specified value and center the display area around the zoom center.
Definition: sdwindow.cxx:364
virtual void Resize() override
Definition: sdwindow.cxx:195
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
constexpr Point Center() const
sal_uInt16 GetCode() const
virtual void dispose() override
virtual void RequestHelp(const HelpEvent &rHEvt)
void PaintImmediately()
Point LogicToPixel(const Point &rLogicPt) const
const OUString & get_id() const
virtual void Resize()
virtual void Command(const CommandEvent &rCEvt)
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
void GrabFocus()
bool HasFocus() const
virtual void EnableRTL(bool bEnable=true)
void SetMapMode()
bool IsMapModeEnabled() const
const AllSettings & GetSettings() const
virtual void KeyInput(const KeyEvent &rKEvt)
const MapMode & GetMapMode() const
::OutputDevice const * GetOutDev() const
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Point PixelToLogic(const Point &rDevicePt) const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
Size GetOutputSizePixel() const
virtual void DataChanged(const DataChangedEvent &rDCEvt)
virtual void LoseFocus()
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
void EnableMapMode(bool bEnable=true)
void SetDialogControlFlags(DialogControlFlags nFlags)
virtual bool EventNotify(NotifyEvent &rNEvt)
void SetBackground()
#define DBG_ASSERT(sCon, aError)
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_F12
#define SAL_WARN(area, stream)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
const DrawModeFlags OUTPUT_DRAWMODE_CONTRAST
Definition: ViewShell.hxx:72
const DrawModeFlags OUTPUT_DRAWMODE_COLOR
Definition: ViewShell.hxx:62
long Long
HashMap_OWString_Interface aMap
#define MAX_ZOOM
maximal zoom factor
Definition: sdwindow.cxx:60
#define MIN_ZOOM
minimal zoom factor
Definition: sdwindow.cxx:59
#define SCROLL_PAGE_FACT
factor for page scrolling
Definition: sdwindow.cxx:56
#define SCROLL_SENSITIVE
sensitive area in pixel
Definition: sdwindow.cxx:57
#define SCROLL_LINE_FACT
factor for line scrolling
Definition: sdwindow.cxx:55
#define ZOOM_MULTIPLICATOR
multiplier to avoid rounding errors
Definition: sdwindow.cxx:58
sal_uIntPtr sal_uLong
#define SDRPAGE_NOTFOUND
constexpr SdrLayerID SDRLAYER_NOTFOUND(-1)
#define DND_ACTION_NONE
signed char sal_Int8
sal_Int64 WinBits
WinBits const WB_DIALOGCONTROL
WinBits const WB_CLIPCHILDREN