1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/request.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <svx/svxids.hrc>
28 #include <editeng/outliner.hxx>
29 #include <editeng/editview.hxx>
33 #include "ViewShell.hxx"
34 #include "DrawViewShell.hxx"
36 #include "FrameView.hxx"
37 #include "OutlineViewShell.hxx"
38 #include "drawdoc.hxx"
39 #include "AccessibleDrawDocumentView.hxx"
40 #include "WindowUpdater.hxx"
44 #define SCROLL_LINE_FACT 0.05 ///< factor for line scrolling
45 #define SCROLL_PAGE_FACT 0.5 ///< factor for page scrolling
46 #define SCROLL_SENSITIVE 20 ///< sensitive area in pixel
47 #define ZOOM_MULTIPLICATOR 10000 ///< multiplier to avoid rounding errors
48 #define MIN_ZOOM 5 ///< minimal zoom factor
49 #define MAX_ZOOM 3000 ///< maximal zoom factor
53 Window::Window(::Window
* pParent
)
54 : ::Window(pParent
, WinBits(WB_CLIPCHILDREN
| WB_DIALOGCONTROL
)),
55 DropTargetHelper( this ),
57 maWinPos(0, 0), // precautionary; but the values should be set
58 maViewOrigin(0, 0), // again from the owner of the window
59 maViewSize(1000, 1000),
63 mbMinZoomAutoCalc(false),
64 mbCalcMinZoomByMinSide(true),
65 mbCenterAllowed(true),
69 mbUseDropScroll (true)
71 SetDialogControlFlags( WINDOW_DLGCTRL_RETURN
| WINDOW_DLGCTRL_WANTFOCUS
);
73 MapMode
aMap(GetMapMode());
74 aMap
.SetMapUnit(MAP_100TH_MM
);
77 // whit it, the ::WindowColor is used in the slide mode
78 SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
80 // adjust contrast mode initially
81 bool bUseContrast
= GetSettings().GetStyleSettings().GetHighContrastMode();
82 SetDrawMode( bUseContrast
83 ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
84 : ViewShell::OUTPUT_DRAWMODE_COLOR
);
87 // SetHelpId(HID_SD_WIN_DOCUMENT);
88 SetUniqueId(HID_SD_WIN_DOCUMENT
);
90 // #i78183# Added after discussed with AF
95 Window::~Window (void)
97 if (mpViewShell
!= NULL
)
99 WindowUpdater
* pWindowUpdater
= mpViewShell
->GetWindowUpdater();
100 if (pWindowUpdater
!= NULL
)
101 pWindowUpdater
->UnregisterWindow (this);
108 void Window::SetViewShell (ViewShell
* pViewSh
)
110 WindowUpdater
* pWindowUpdater
= NULL
;
111 // Unregister at device updater of old view shell.
112 if (mpViewShell
!= NULL
)
114 pWindowUpdater
= mpViewShell
->GetWindowUpdater();
115 if (pWindowUpdater
!= NULL
)
116 pWindowUpdater
->UnregisterWindow (this);
119 mpViewShell
= pViewSh
;
121 // Register at device updater of new view shell
122 if (mpViewShell
!= NULL
)
124 pWindowUpdater
= mpViewShell
->GetWindowUpdater();
125 if (pWindowUpdater
!= NULL
)
126 pWindowUpdater
->RegisterWindow (this);
130 void Window::CalcMinZoom()
132 // Are we entitled to change the minimal zoom factor?
133 if ( mbMinZoomAutoCalc
)
135 // Get current zoom factor.
136 long nZoom
= GetZoom();
140 mpShareWin
->CalcMinZoom();
141 mnMinZoom
= mpShareWin
->mnMinZoom
;
145 // Get the rectangle of the output area in logical coordinates
146 // and calculate the scaling factors that would lead to the view
147 // area (also called application area) to completely fill the
149 Size aWinSize
= PixelToLogic(GetOutputSizePixel());
150 sal_uLong nX
= (sal_uLong
) ((double) aWinSize
.Width()
151 * (double) ZOOM_MULTIPLICATOR
/ (double) maViewSize
.Width());
152 sal_uLong nY
= (sal_uLong
) ((double) aWinSize
.Height()
153 * (double) ZOOM_MULTIPLICATOR
/ (double) maViewSize
.Height());
155 // Decide whether to take the larger or the smaller factor.
157 if (mbCalcMinZoomByMinSide
)
158 nFact
= std::min(nX
, nY
);
160 nFact
= std::max(nX
, nY
);
162 // The factor is tansfomed according to the current zoom factor.
163 nFact
= nFact
* nZoom
/ ZOOM_MULTIPLICATOR
;
164 mnMinZoom
= std::max((sal_uInt16
) MIN_ZOOM
, (sal_uInt16
) nFact
);
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
169 if ( nZoom
< (long) mnMinZoom
)
170 SetZoomFactor(mnMinZoom
);
177 void Window::SetMinZoom (long int nMin
)
179 mnMinZoom
= (sal_uInt16
) nMin
;
185 long Window::GetMinZoom (void) const
193 void Window::SetMaxZoom (long int nMax
)
195 mnMaxZoom
= (sal_uInt16
) nMax
;
201 long Window::GetMaxZoom (void) const
209 long Window::GetZoom (void) const
211 if( GetMapMode().GetScaleX().GetDenominator() )
213 return GetMapMode().GetScaleX().GetNumerator() * 100L
214 / GetMapMode().GetScaleX().GetDenominator();
226 void Window::Resize()
231 if( mpViewShell
&& mpViewShell
->GetViewFrame() )
232 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
236 void Window::PrePaint()
239 mpViewShell
->PrePaint();
243 void Window::Paint(const Rectangle
& rRect
)
246 mpViewShell
->Paint(rRect
, this);
250 void Window::KeyInput(const KeyEvent
& rKEvt
)
252 if (!(mpViewShell
&& mpViewShell
->KeyInput(rKEvt
, this)))
254 if (mpViewShell
&& rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
256 mpViewShell
->GetViewShell()->Escape();
260 ::Window::KeyInput(rKEvt
);
266 void Window::MouseButtonDown(const MouseEvent
& rMEvt
)
269 mpViewShell
->MouseButtonDown(rMEvt
, this);
273 void Window::MouseMove(const MouseEvent
& rMEvt
)
276 mpViewShell
->MouseMove(rMEvt
, this);
280 void Window::MouseButtonUp(const MouseEvent
& rMEvt
)
285 mpViewShell
->MouseButtonUp(rMEvt
, this);
289 void Window::Command(const CommandEvent
& rCEvt
)
292 mpViewShell
->Command(rCEvt
, this);
296 long Window::Notify( NotifyEvent
& rNEvt
)
298 long nResult
= sal_False
;
301 nResult
= mpViewShell
->Notify(rNEvt
, this);
304 nResult
= ::Window::Notify( rNEvt
);
310 void Window::RequestHelp(const HelpEvent
& rEvt
)
314 if( !mpViewShell
->RequestHelp( rEvt
, this) )
315 ::Window::RequestHelp( rEvt
);
318 ::Window::RequestHelp( rEvt
);
324 Point
Window::GetWinViewPos (void) const
332 Point
Window::GetViewOrigin (void) const
340 Size
Window::GetViewSize (void) const
349 * Set the position of the upper left corner from the visible area of the
352 void Window::SetWinViewPos(const Point
& rPnt
)
358 * Set origin of the representation in respect to the whole working area.
360 void Window::SetViewOrigin(const Point
& rPnt
)
366 * Set size of the whole working area which can be seen with the window.
368 void Window::SetViewSize(const Size
& rSize
)
377 void Window::SetCenterAllowed (bool bIsAllowed
)
379 mbCenterAllowed
= bIsAllowed
;
385 long Window::SetZoomFactor(long nZoom
)
387 // Clip the zoom factor to the valid range marked by nMinZoom as
388 // calculated by CalcMinZoom() and the constant MAX_ZOOM.
389 if ( nZoom
> MAX_ZOOM
)
391 if ( nZoom
< (long) mnMinZoom
)
394 // Set the zoom factor at the window's map mode.
395 MapMode
aMap(GetMapMode());
396 aMap
.SetScaleX(Fraction(nZoom
, 100));
397 aMap
.SetScaleY(Fraction(nZoom
, 100));
400 // invalidate previous size - it was relative to the old scaling
401 maPrevSize
= Size(-1,-1);
403 // Update the map mode's origin (to what effect?).
406 // Update the view's snapping to the new zoom factor.
407 if ( mpViewShell
&& mpViewShell
->ISA(DrawViewShell
) )
408 ((DrawViewShell
*) mpViewShell
)->GetView()->
409 RecalcLogicSnapMagnetic(*this);
411 // Return the zoom factor just in case it has been changed above to lie
412 // inside the valid range.
416 void Window::SetZoomIntegral(long nZoom
)
418 // Clip the zoom factor to the valid range marked by nMinZoom as
419 // previously calculated by <member>CalcMinZoom()</member> and the
420 // MAX_ZOOM constant.
421 if ( nZoom
> MAX_ZOOM
)
423 if ( nZoom
< (long) mnMinZoom
)
426 // Calculate the window's new origin.
427 Size aSize
= PixelToLogic(GetOutputSizePixel());
428 long nW
= aSize
.Width() * GetZoom() / nZoom
;
429 long nH
= aSize
.Height() * GetZoom() / nZoom
;
430 maWinPos
.X() += (aSize
.Width() - nW
) / 2;
431 maWinPos
.Y() += (aSize
.Height() - nH
) / 2;
432 if ( maWinPos
.X() < 0 ) maWinPos
.X() = 0;
433 if ( maWinPos
.Y() < 0 ) maWinPos
.Y() = 0;
435 // Finally update this window's map mode to the given zoom factor that
436 // has been clipped to the valid range.
437 SetZoomFactor(nZoom
);
440 long Window::GetZoomForRect( const Rectangle
& rZoomRect
)
444 if( (rZoomRect
.GetWidth() != 0) && (rZoomRect
.GetHeight() != 0))
446 // Calculate the scale factors which will lead to the given
447 // rectangle being fully visible (when translated accordingly) as
448 // large as possible in the output area independently in both
449 // coordinate directions .
453 const Size
aWinSize( PixelToLogic(GetOutputSizePixel()) );
454 if(rZoomRect
.GetHeight())
456 nX
= (sal_uLong
) ((double) aWinSize
.Height()
457 * (double) ZOOM_MULTIPLICATOR
/ (double) rZoomRect
.GetHeight());
460 if(rZoomRect
.GetWidth())
462 nY
= (sal_uLong
) ((double) aWinSize
.Width()
463 * (double) ZOOM_MULTIPLICATOR
/ (double) rZoomRect
.GetWidth());
466 // Use the smaller one of both so that the zoom rectangle will be
467 // fully visible with respect to both coordinate directions.
468 sal_uLong nFact
= std::min(nX
, nY
);
470 // Transform the current zoom factor so that it leads to the desired
472 nRetZoom
= nFact
* GetZoom() / ZOOM_MULTIPLICATOR
;
474 // Calculate the new origin.
477 // Don't change anything if the scale factor is degenrate.
478 nRetZoom
= GetZoom();
482 // Clip the zoom factor to the valid range marked by nMinZoom as
483 // previously calculated by <member>CalcMinZoom()</member> and the
484 // MAX_ZOOM constant.
485 if ( nRetZoom
> MAX_ZOOM
)
487 if ( nRetZoom
< (long) mnMinZoom
)
488 nRetZoom
= mnMinZoom
;
495 /** Recalculate the zoom factor and translation so that the given rectangle
496 is displayed centered and as large as possible while still being fully
497 visible in the window.
499 long Window::SetZoomRect (const Rectangle
& rZoomRect
)
503 if (rZoomRect
.GetWidth() == 0 || rZoomRect
.GetHeight() == 0)
505 // The given rectangle is degenerate. Use the default zoom factor
507 SetZoomIntegral(nNewZoom
);
511 Point aPos
= rZoomRect
.TopLeft();
512 // Transform the output area from pixel coordinates into logical
514 Size aWinSize
= PixelToLogic(GetOutputSizePixel());
515 // Paranoia! The degenerate case of zero width or height has been
516 // taken care of above.
517 DBG_ASSERT(rZoomRect
.GetWidth(), "ZoomRect-Width = 0!");
518 DBG_ASSERT(rZoomRect
.GetHeight(), "ZoomRect-Height = 0!");
520 // Calculate the scale factors which will lead to the given
521 // rectangle being fully visible (when translated accordingly) as
522 // large as possible in the output area independently in both
523 // coordinate directions .
527 if(rZoomRect
.GetHeight())
529 nX
= (sal_uLong
) ((double) aWinSize
.Height()
530 * (double) ZOOM_MULTIPLICATOR
/ (double) rZoomRect
.GetHeight());
533 if(rZoomRect
.GetWidth())
535 nY
= (sal_uLong
) ((double) aWinSize
.Width()
536 * (double) ZOOM_MULTIPLICATOR
/ (double) rZoomRect
.GetWidth());
539 // Use the smaller one of both so that the zoom rectangle will be
540 // fully visible with respect to both coordinate directions.
541 sal_uLong nFact
= std::min(nX
, nY
);
543 // Transform the current zoom factor so that it leads to the desired
545 long nZoom
= nFact
* GetZoom() / ZOOM_MULTIPLICATOR
;
547 // Calculate the new origin.
550 // Don't change anything if the scale factor is degenrate.
551 nNewZoom
= GetZoom();
555 // Calculate the new window position that centers the given
556 // rectangle on the screen.
557 if ( nZoom
> MAX_ZOOM
)
558 nFact
= nFact
* MAX_ZOOM
/ nZoom
;
560 maWinPos
= maViewOrigin
+ aPos
;
562 aWinSize
.Width() = (long) ((double) aWinSize
.Width() * (double) ZOOM_MULTIPLICATOR
/ (double) nFact
);
563 maWinPos
.X() += (rZoomRect
.GetWidth() - aWinSize
.Width()) / 2;
564 aWinSize
.Height() = (long) ((double) aWinSize
.Height() * (double) ZOOM_MULTIPLICATOR
/ (double) nFact
);
565 maWinPos
.Y() += (rZoomRect
.GetHeight() - aWinSize
.Height()) / 2;
567 if ( maWinPos
.X() < 0 ) maWinPos
.X() = 0;
568 if ( maWinPos
.Y() < 0 ) maWinPos
.Y() = 0;
570 // Adapt the window's map mode to the new zoom factor.
571 nNewZoom
= SetZoomFactor(nZoom
);
581 void Window::SetMinZoomAutoCalc (bool bAuto
)
583 mbMinZoomAutoCalc
= bAuto
;
590 * Calculate and set new MapMode origin.
591 * If aWinPos.X()/Y() == -1, then we center the corresponding position (e.g. for
594 void Window::UpdateMapOrigin(sal_Bool bInvalidate
)
596 sal_Bool bChanged
= sal_False
;
597 const Size aWinSize
= PixelToLogic(GetOutputSizePixel());
599 if ( mbCenterAllowed
)
601 if( maPrevSize
!= Size(-1,-1) )
603 // keep view centered around current pos, when window
605 maWinPos
.X() -= (aWinSize
.Width() - maPrevSize
.Width()) / 2;
606 maWinPos
.Y() -= (aWinSize
.Height() - maPrevSize
.Height()) / 2;
610 if ( maWinPos
.X() > maViewSize
.Width() - aWinSize
.Width() )
612 maWinPos
.X() = maViewSize
.Width() - aWinSize
.Width();
615 if ( maWinPos
.Y() > maViewSize
.Height() - aWinSize
.Height() )
617 maWinPos
.Y() = maViewSize
.Height() - aWinSize
.Height();
620 if ( aWinSize
.Width() > maViewSize
.Width() || maWinPos
.X() < 0 )
622 maWinPos
.X() = maViewSize
.Width() / 2 - aWinSize
.Width() / 2;
625 if ( aWinSize
.Height() > maViewSize
.Height() || maWinPos
.Y() < 0 )
627 maWinPos
.Y() = maViewSize
.Height() / 2 - aWinSize
.Height() / 2;
634 maPrevSize
= aWinSize
;
636 if (bChanged
&& bInvalidate
)
643 void Window::UpdateMapMode (void)
645 maWinPos
-= maViewOrigin
;
646 Size
aPix(maWinPos
.X(), maWinPos
.Y());
647 aPix
= LogicToPixel(aPix
);
648 // Size has to be a multiple of BRUSH_SIZE due to the correct depiction of
651 // removed old stuff here which still forced zoom to be
652 // %BRUSH_SIZE which is outdated now
654 if (mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
656 // page should not "stick" to the window border
657 if (aPix
.Width() == 0)
660 // Since BRUSH_SIZE alignment is outdated now, i use the
661 // former constant here directly
664 if (aPix
.Height() == 0)
667 // Since BRUSH_SIZE alignment is outdated now, i use the
668 // former constant here directly
673 aPix
= PixelToLogic(aPix
);
674 maWinPos
.X() = aPix
.Width();
675 maWinPos
.Y() = aPix
.Height();
676 Point
aNewOrigin (-maWinPos
.X(), -maWinPos
.Y());
677 maWinPos
+= maViewOrigin
;
679 MapMode
aMap(GetMapMode());
680 aMap
.SetOrigin(aNewOrigin
);
688 * @returns X position of the visible area as fraction (< 1) of the whole
691 double Window::GetVisibleX()
693 return ((double) maWinPos
.X() / maViewSize
.Width());
697 * @returns Y position of the visible area as fraction (< 1) of the whole
700 double Window::GetVisibleY()
702 return ((double) maWinPos
.Y() / maViewSize
.Height());
706 * Set x and y position of the visible area as fraction (< 1) of the whole
707 * working area. Negative values are ignored.
709 void Window::SetVisibleXY(double fX
, double fY
)
711 long nOldX
= maWinPos
.X();
712 long nOldY
= maWinPos
.Y();
715 maWinPos
.X() = (long) (fX
* maViewSize
.Width());
717 maWinPos
.Y() = (long) (fY
* maViewSize
.Height());
718 UpdateMapOrigin(sal_False
);
719 Scroll(nOldX
- maWinPos
.X(), nOldY
- maWinPos
.Y(), SCROLL_CHILDREN
);
724 * @returns width of the visible area in proportion to the width of the whole
727 double Window::GetVisibleWidth()
729 Size aWinSize
= PixelToLogic(GetOutputSizePixel());
730 if ( aWinSize
.Width() > maViewSize
.Width() )
731 aWinSize
.Width() = maViewSize
.Width();
732 return ((double) aWinSize
.Width() / maViewSize
.Width());
736 * @returns height of the visible area in proportion to the height of the whole
739 double Window::GetVisibleHeight()
741 Size aWinSize
= PixelToLogic(GetOutputSizePixel());
742 if ( aWinSize
.Height() > maViewSize
.Height() )
743 aWinSize
.Height() = maViewSize
.Height();
744 return ((double) aWinSize
.Height() / maViewSize
.Height());
748 * @returns width of a scroll column in proportion to the width of the whole
751 double Window::GetScrlLineWidth()
753 return (GetVisibleWidth() * SCROLL_LINE_FACT
);
757 * @returns height of a scroll column in proportion to the height of the whole
760 double Window::GetScrlLineHeight()
762 return (GetVisibleHeight() * SCROLL_LINE_FACT
);
766 * @returns width of a scroll page in proportion to the width of the whole
769 double Window::GetScrlPageWidth()
771 return (GetVisibleWidth() * SCROLL_PAGE_FACT
);
775 * @returns height of a scroll page in proportion to the height of the whole
778 double Window::GetScrlPageHeight()
780 return (GetVisibleHeight() * SCROLL_PAGE_FACT
);
786 void Window::LoseFocus()
789 ::Window::LoseFocus ();
795 void Window::GrabFocus()
798 ::Window::GrabFocus ();
803 void Window::DataChanged( const DataChangedEvent
& rDCEvt
)
805 ::Window::DataChanged( rDCEvt
);
807 /* Omit PRINTER by all documents which are not using a printer.
808 Omit FONTS and FONTSUBSTITUTION if no text output is available or if the
809 document does not allow text. */
811 if ( (rDCEvt
.GetType() == DATACHANGED_PRINTER
) ||
812 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
813 (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
814 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
815 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
816 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
818 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
819 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
821 // When the screen zoom factor has changed then reset the zoom
822 // factor of the frame to always display the whole page.
823 const AllSettings
* pOldSettings
= rDCEvt
.GetOldSettings ();
824 const AllSettings
& rNewSettings
= GetSettings ();
826 if (pOldSettings
->GetStyleSettings().GetScreenZoom()
827 != rNewSettings
.GetStyleSettings().GetScreenZoom())
828 mpViewShell
->GetViewFrame()->GetDispatcher()->
829 Execute(SID_SIZE_PAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
831 /* Rearrange or initiate Resize for scroll bars since the size of
832 the scroll bars my have changed. Within this, inside the resize-
833 handler, the size of the scroll bars will be asked from the
837 /* Re-set data, which are from system control or from Settings. May
838 have to re-set more data since the resolution may also has
842 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
843 SvtAccessibilityOptions aAccOptions
;
844 sal_uLong nOutputMode
;
845 sal_uInt16 nPreviewSlot
;
847 if( rStyleSettings
.GetHighContrastMode() )
848 nOutputMode
= ViewShell::OUTPUT_DRAWMODE_CONTRAST
;
850 nOutputMode
= ViewShell::OUTPUT_DRAWMODE_COLOR
;
852 if( rStyleSettings
.GetHighContrastMode() && aAccOptions
.GetIsForPagePreviews() )
853 nPreviewSlot
= SID_PREVIEW_QUALITY_CONTRAST
;
855 nPreviewSlot
= SID_PREVIEW_QUALITY_COLOR
;
857 if( mpViewShell
->ISA( DrawViewShell
) )
859 SetDrawMode( nOutputMode
);
860 mpViewShell
->GetFrameView()->SetDrawMode( nOutputMode
);
864 // Overwrite window color for OutlineView
865 if( mpViewShell
->ISA(OutlineViewShell
) )
867 svtools::ColorConfig aColorConfig
;
868 const Color
aDocColor( aColorConfig
.GetColorValue( svtools::DOCCOLOR
).nColor
);
869 SetBackground( Wallpaper( aDocColor
) );
872 SfxRequest
aReq( nPreviewSlot
, 0, mpViewShell
->GetDocSh()->GetDoc()->GetItemPool() );
873 mpViewShell
->ExecReq( aReq
);
874 mpViewShell
->Invalidate();
875 mpViewShell
->ArrangeGUIElements();
877 // re-create handles to show new outfit
878 if(mpViewShell
->ISA(DrawViewShell
))
880 mpViewShell
->GetView()->AdjustMarkHdl();
885 if ( (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
886 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
887 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
889 /* Virtual devices, which also depends on the resolution or the
890 system control, should be updated. Otherwise, we should update
891 the virtual devices at least at DATACHANGED_DISPLAY since some
892 systems allow to change the resolution and color depth during
893 runtime. Or the virtual devices have to be updated when the color
894 palette has changed since a different color matching can be used
898 if ( rDCEvt
.GetType() == DATACHANGED_FONTS
)
900 /* If the document provides font choose boxes, we have to update
901 them. I don't know how this looks like (also not really me, I
902 only translated the comment ;). We may can handle it global. We
903 have to discuss it with PB, but he is ill at the moment.
904 Before we handle it here, discuss it with PB and me. */
907 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
908 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) )
910 /* Do reformating since the fonts of the document may no longer
911 exist, or exist now, or are replaced with others. */
914 DrawDocShell
* pDocSh
= mpViewShell
->GetDocSh();
916 pDocSh
->SetPrinter( pDocSh
->GetPrinter( sal_True
) );
920 if ( rDCEvt
.GetType() == DATACHANGED_PRINTER
)
922 /* I don't know how the handling should look like. Maybe we delete a
923 printer and look what we have to do. Maybe I have to add
924 something to the VCL, in case the used printer is deleted.
925 Otherwise I may recalculate the formatting here if the current
926 printer is destroyed. */
929 DrawDocShell
* pDocSh
= mpViewShell
->GetDocSh();
931 pDocSh
->SetPrinter( pDocSh
->GetPrinter( sal_True
) );
944 sal_Int8
Window::AcceptDrop( const AcceptDropEvent
& rEvt
)
946 sal_Int8 nRet
= DND_ACTION_NONE
;
948 if( mpViewShell
&& !mpViewShell
->GetDocSh()->IsReadOnly() )
951 nRet
= mpViewShell
->AcceptDrop( rEvt
, *this, this, SDRPAGE_NOTFOUND
, SDRLAYER_NOTFOUND
);
953 if (mbUseDropScroll
&& ! mpViewShell
->ISA(OutlineViewShell
))
954 DropScroll( rEvt
.maPosPixel
);
961 sal_Int8
Window::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
963 sal_Int8 nRet
= DND_ACTION_NONE
;
967 nRet
= mpViewShell
->ExecuteDrop( rEvt
, *this, this, SDRPAGE_NOTFOUND
, SDRLAYER_NOTFOUND
);
976 void Window::SetUseDropScroll (bool bUseDropScroll
)
978 mbUseDropScroll
= bUseDropScroll
;
985 void Window::DropScroll(const Point
& rMousePos
)
990 Size aSize
= GetOutputSizePixel();
992 if (aSize
.Width() > SCROLL_SENSITIVE
* 3)
994 if ( rMousePos
.X() < SCROLL_SENSITIVE
)
999 if ( rMousePos
.X() >= aSize
.Width() - SCROLL_SENSITIVE
)
1005 if (aSize
.Height() > SCROLL_SENSITIVE
* 3)
1007 if ( rMousePos
.Y() < SCROLL_SENSITIVE
)
1012 if ( rMousePos
.Y() >= aSize
.Height() - SCROLL_SENSITIVE
)
1018 if ( (nDx
|| nDy
) && (rMousePos
.X()!=0 || rMousePos
.Y()!=0 ) )
1021 mpViewShell
->ScrollLines(nDx
, nDy
);
1030 ::com::sun::star::uno::Reference
<
1031 ::com::sun::star::accessibility::XAccessible
>
1032 Window::CreateAccessible (void)
1034 if (mpViewShell
!= NULL
)
1035 return mpViewShell
->CreateAccessibleDocumentView (this);
1038 OSL_TRACE ("::sd::Window::CreateAccessible: no view shell");
1039 return ::Window::CreateAccessible ();
1043 OUString
Window::GetSurroundingText() const
1045 if ( mpViewShell
->GetShellType() == ViewShell::ST_OUTLINE
)
1047 else if ( mpViewShell
->GetView()->IsTextEdit() )
1049 OutlinerView
*pOLV
= mpViewShell
->GetView()->GetTextEditOutlinerView();
1050 return pOLV
->GetEditView().GetSurroundingText();
1055 Selection
Window::GetSurroundingTextSelection() const
1057 if ( mpViewShell
->GetShellType() == ViewShell::ST_OUTLINE
)
1059 return Selection( 0, 0 );
1061 else if ( mpViewShell
->GetView()->IsTextEdit() )
1063 OutlinerView
*pOLV
= mpViewShell
->GetView()->GetTextEditOutlinerView();
1064 return pOLV
->GetEditView().GetSurroundingTextSelection();
1068 return Selection( 0, 0 );
1072 } // end of namespace sd
1074 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */