15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
55b190011SAndrew Rist * distributed with this work for additional information
65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist * "License"); you may not use this file except in compliance
95b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist * software distributed under the License is distributed on an
155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist * KIND, either express or implied. See the License for the
175b190011SAndrew Rist * specific language governing permissions and limitations
185b190011SAndrew Rist * under the License.
19cdf0e10cSrcweir *
205b190011SAndrew Rist *************************************************************/
215b190011SAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sd.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include "Window.hxx"
26cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
27cdf0e10cSrcweir #include <sfx2/request.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
30cdf0e10cSrcweir #include <svx/svxids.hrc>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <editeng/outliner.hxx>
33cdf0e10cSrcweir #include <editeng/editview.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include "app.hrc"
36cdf0e10cSrcweir #include "helpids.h"
37cdf0e10cSrcweir #include "ViewShell.hxx"
38cdf0e10cSrcweir #include "DrawViewShell.hxx"
39cdf0e10cSrcweir #include "View.hxx"
40cdf0e10cSrcweir #include "FrameView.hxx"
41cdf0e10cSrcweir #include "OutlineViewShell.hxx"
42cdf0e10cSrcweir #include "drawdoc.hxx"
43cdf0e10cSrcweir #include "AccessibleDrawDocumentView.hxx"
44cdf0e10cSrcweir #include "WindowUpdater.hxx"
45cdf0e10cSrcweir
460deba7fbSSteve Yin #include <vcl/svapp.hxx>
470deba7fbSSteve Yin
48cdf0e10cSrcweir namespace sd {
49cdf0e10cSrcweir
50*5133a0b6Smseidel #define SCROLL_LINE_FACT 0.05 // Faktor für Zeilenscrolling
51*5133a0b6Smseidel #define SCROLL_PAGE_FACT 0.5 // Faktor für Seitenscrolling
52cdf0e10cSrcweir #define SCROLL_SENSITIVE 20 // Sensitiver Bereich (Pixel)
53cdf0e10cSrcweir #define ZOOM_MULTIPLICATOR 10000 // Multiplikator um Rundungsfehler zu vermeiden
54cdf0e10cSrcweir #define MIN_ZOOM 5 // Minimaler Zoomfaktor
55cdf0e10cSrcweir #define MAX_ZOOM 3000 // Maximaler Zoomfaktor
56cdf0e10cSrcweir
57cdf0e10cSrcweir /*************************************************************************
58cdf0e10cSrcweir |* Konstruktor
59cdf0e10cSrcweir \************************************************************************/
60cdf0e10cSrcweir
Window(::Window * pParent)61cdf0e10cSrcweir Window::Window(::Window* pParent)
62cdf0e10cSrcweir : ::Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
63cdf0e10cSrcweir DropTargetHelper( this ),
64cdf0e10cSrcweir mpShareWin(NULL),
65cdf0e10cSrcweir maWinPos(0, 0), // vorsichtshalber; die Werte sollten aber
66cdf0e10cSrcweir maViewOrigin(0, 0), // vom Besitzer des Fensters neu gesetzt
67cdf0e10cSrcweir maViewSize(1000, 1000), // werden
68cdf0e10cSrcweir mnMinZoom(MIN_ZOOM),
69cdf0e10cSrcweir mnMaxZoom(MAX_ZOOM),
70cdf0e10cSrcweir mbMinZoomAutoCalc(false),
71cdf0e10cSrcweir mbCalcMinZoomByMinSide(true),
72cdf0e10cSrcweir mbCenterAllowed(true),
73cdf0e10cSrcweir mnTicks (0),
74cdf0e10cSrcweir mbDraggedFrom(false),
75cdf0e10cSrcweir mpViewShell(NULL),
76cdf0e10cSrcweir mbUseDropScroll (true)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
79cdf0e10cSrcweir
80cdf0e10cSrcweir MapMode aMap(GetMapMode());
81cdf0e10cSrcweir aMap.SetMapUnit(MAP_100TH_MM);
82cdf0e10cSrcweir SetMapMode(aMap);
83cdf0e10cSrcweir
84cdf0e10cSrcweir // Damit im Diamodus die ::WindowColor genommen wird
85cdf0e10cSrcweir SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
86cdf0e10cSrcweir
87cdf0e10cSrcweir // adjust contrast mode initially
88cdf0e10cSrcweir bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
89cdf0e10cSrcweir SetDrawMode( bUseContrast
90cdf0e10cSrcweir ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
91cdf0e10cSrcweir : ViewShell::OUTPUT_DRAWMODE_COLOR );
92cdf0e10cSrcweir
93cdf0e10cSrcweir // Hilfe-ID setzen
94cdf0e10cSrcweir // SetHelpId(HID_SD_WIN_DOCUMENT);
95cdf0e10cSrcweir SetUniqueId(HID_SD_WIN_DOCUMENT);
96cdf0e10cSrcweir
97cdf0e10cSrcweir // #i78183# Added after discussed with AF
98cdf0e10cSrcweir EnableRTL(sal_False);
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir /*************************************************************************
102cdf0e10cSrcweir |* Destruktor
103cdf0e10cSrcweir \************************************************************************/
104cdf0e10cSrcweir
~Window(void)105cdf0e10cSrcweir Window::~Window (void)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir if (mpViewShell != NULL)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir WindowUpdater* pWindowUpdater = mpViewShell->GetWindowUpdater();
110cdf0e10cSrcweir if (pWindowUpdater != NULL)
111cdf0e10cSrcweir pWindowUpdater->UnregisterWindow (this);
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
SetViewShell(ViewShell * pViewSh)115cdf0e10cSrcweir void Window::SetViewShell (ViewShell* pViewSh)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir WindowUpdater* pWindowUpdater = NULL;
118cdf0e10cSrcweir // Unregister at device updater of old view shell.
119cdf0e10cSrcweir if (mpViewShell != NULL)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir pWindowUpdater = mpViewShell->GetWindowUpdater();
122cdf0e10cSrcweir if (pWindowUpdater != NULL)
123cdf0e10cSrcweir pWindowUpdater->UnregisterWindow (this);
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir mpViewShell = pViewSh;
127cdf0e10cSrcweir
128cdf0e10cSrcweir // Register at device updater of new view shell
129cdf0e10cSrcweir if (mpViewShell != NULL)
130cdf0e10cSrcweir {
131cdf0e10cSrcweir pWindowUpdater = mpViewShell->GetWindowUpdater();
132cdf0e10cSrcweir if (pWindowUpdater != NULL)
133cdf0e10cSrcweir pWindowUpdater->RegisterWindow (this);
134cdf0e10cSrcweir }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
CalcMinZoom()137cdf0e10cSrcweir void Window::CalcMinZoom()
138cdf0e10cSrcweir {
139cdf0e10cSrcweir // Are we entitled to change the minimal zoom factor?
140cdf0e10cSrcweir if ( mbMinZoomAutoCalc )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir // Get current zoom factor.
143cdf0e10cSrcweir long nZoom = GetZoom();
144cdf0e10cSrcweir
145cdf0e10cSrcweir if ( mpShareWin )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir mpShareWin->CalcMinZoom();
148cdf0e10cSrcweir mnMinZoom = mpShareWin->mnMinZoom;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir else
151cdf0e10cSrcweir {
152cdf0e10cSrcweir // Get the rectangle of the output area in logical coordinates
153cdf0e10cSrcweir // and calculate the scaling factors that would lead to the view
154cdf0e10cSrcweir // area (also called application area) to completely fill the
155cdf0e10cSrcweir // window.
156cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel());
157cdf0e10cSrcweir sal_uLong nX = (sal_uLong) ((double) aWinSize.Width()
158cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Width());
159cdf0e10cSrcweir sal_uLong nY = (sal_uLong) ((double) aWinSize.Height()
160cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Height());
161cdf0e10cSrcweir
162cdf0e10cSrcweir // Decide whether to take the larger or the smaller factor.
163cdf0e10cSrcweir sal_uLong nFact;
164cdf0e10cSrcweir if (mbCalcMinZoomByMinSide)
165cdf0e10cSrcweir nFact = Min(nX, nY);
166cdf0e10cSrcweir else
167cdf0e10cSrcweir nFact = Max(nX, nY);
168cdf0e10cSrcweir
169721f84f2Smseidel // The factor is transformed according to the current zoom factor.
170cdf0e10cSrcweir nFact = nFact * nZoom / ZOOM_MULTIPLICATOR;
171cdf0e10cSrcweir mnMinZoom = Max((sal_uInt16) MIN_ZOOM, (sal_uInt16) nFact);
172cdf0e10cSrcweir }
173cdf0e10cSrcweir // If the current zoom factor is smaller than the calculated minimal
174cdf0e10cSrcweir // zoom factor then set the new minimal factor as the current zoom
175cdf0e10cSrcweir // factor.
176cdf0e10cSrcweir if ( nZoom < (long) mnMinZoom )
177cdf0e10cSrcweir SetZoomFactor(mnMinZoom);
178cdf0e10cSrcweir }
179cdf0e10cSrcweir }
180cdf0e10cSrcweir
SetMinZoom(long int nMin)181cdf0e10cSrcweir void Window::SetMinZoom (long int nMin)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir mnMinZoom = (sal_uInt16) nMin;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
GetMinZoom(void) const186cdf0e10cSrcweir long Window::GetMinZoom (void) const
187cdf0e10cSrcweir {
188cdf0e10cSrcweir return mnMinZoom;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
SetMaxZoom(long int nMax)191cdf0e10cSrcweir void Window::SetMaxZoom (long int nMax)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir mnMaxZoom = (sal_uInt16) nMax;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
GetMaxZoom(void) const196cdf0e10cSrcweir long Window::GetMaxZoom (void) const
197cdf0e10cSrcweir {
198cdf0e10cSrcweir return mnMaxZoom;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
GetZoom(void) const201cdf0e10cSrcweir long Window::GetZoom (void) const
202cdf0e10cSrcweir {
203cdf0e10cSrcweir if( GetMapMode().GetScaleX().GetDenominator() )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir return GetMapMode().GetScaleX().GetNumerator() * 100L
206cdf0e10cSrcweir / GetMapMode().GetScaleX().GetDenominator();
207cdf0e10cSrcweir }
208cdf0e10cSrcweir else
209cdf0e10cSrcweir {
210cdf0e10cSrcweir return 0;
211cdf0e10cSrcweir }
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir /*************************************************************************
215cdf0e10cSrcweir |* Resize event
216cdf0e10cSrcweir \************************************************************************/
217cdf0e10cSrcweir
Resize()218cdf0e10cSrcweir void Window::Resize()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir ::Window::Resize();
221cdf0e10cSrcweir CalcMinZoom();
222cdf0e10cSrcweir
223cdf0e10cSrcweir if( mpViewShell && mpViewShell->GetViewFrame() )
224cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir /*************************************************************************
228cdf0e10cSrcweir |* PrePaint event
229cdf0e10cSrcweir \************************************************************************/
230cdf0e10cSrcweir
PrePaint()231cdf0e10cSrcweir void Window::PrePaint()
232cdf0e10cSrcweir {
233cdf0e10cSrcweir if ( mpViewShell )
234cdf0e10cSrcweir mpViewShell->PrePaint();
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir /*************************************************************************
238cdf0e10cSrcweir |* Paint event
239cdf0e10cSrcweir \************************************************************************/
240cdf0e10cSrcweir
Paint(const Rectangle & rRect)241cdf0e10cSrcweir void Window::Paint(const Rectangle& rRect)
242cdf0e10cSrcweir {
243cdf0e10cSrcweir if ( mpViewShell )
244cdf0e10cSrcweir mpViewShell->Paint(rRect, this);
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir /*************************************************************************
248cdf0e10cSrcweir |* Keyboard event
249cdf0e10cSrcweir \************************************************************************/
250cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)251cdf0e10cSrcweir void Window::KeyInput(const KeyEvent& rKEvt)
252cdf0e10cSrcweir {
253cdf0e10cSrcweir if (!(mpViewShell && mpViewShell->KeyInput(rKEvt, this)))
254cdf0e10cSrcweir {
255cdf0e10cSrcweir if (mpViewShell && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir mpViewShell->GetViewShell()->Escape();
258cdf0e10cSrcweir }
259cdf0e10cSrcweir else
260cdf0e10cSrcweir {
261cdf0e10cSrcweir ::Window::KeyInput(rKEvt);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
266cdf0e10cSrcweir /*************************************************************************
267cdf0e10cSrcweir |* MouseButtonDown event
268cdf0e10cSrcweir \************************************************************************/
269cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)270cdf0e10cSrcweir void Window::MouseButtonDown(const MouseEvent& rMEvt)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if ( mpViewShell )
273cdf0e10cSrcweir mpViewShell->MouseButtonDown(rMEvt, this);
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir /*************************************************************************
277cdf0e10cSrcweir |* MouseMove event
278cdf0e10cSrcweir \************************************************************************/
279cdf0e10cSrcweir
MouseMove(const MouseEvent & rMEvt)280cdf0e10cSrcweir void Window::MouseMove(const MouseEvent& rMEvt)
281cdf0e10cSrcweir {
282cdf0e10cSrcweir if ( mpViewShell )
283cdf0e10cSrcweir mpViewShell->MouseMove(rMEvt, this);
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286cdf0e10cSrcweir /*************************************************************************
287cdf0e10cSrcweir |* MouseButtonUp event
288cdf0e10cSrcweir \************************************************************************/
289cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rMEvt)290cdf0e10cSrcweir void Window::MouseButtonUp(const MouseEvent& rMEvt)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir mnTicks = 0;
293cdf0e10cSrcweir
294cdf0e10cSrcweir if ( mpViewShell )
295cdf0e10cSrcweir mpViewShell->MouseButtonUp(rMEvt, this);
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
298cdf0e10cSrcweir /*************************************************************************
299cdf0e10cSrcweir |* Command event
300cdf0e10cSrcweir \************************************************************************/
301cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)302cdf0e10cSrcweir void Window::Command(const CommandEvent& rCEvt)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir if ( mpViewShell )
305cdf0e10cSrcweir mpViewShell->Command(rCEvt, this);
306cdf0e10cSrcweir }
307cdf0e10cSrcweir
Notify(NotifyEvent & rNEvt)308cdf0e10cSrcweir long Window::Notify( NotifyEvent& rNEvt )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir long nResult = sal_False;
311cdf0e10cSrcweir if ( mpViewShell )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir nResult = mpViewShell->Notify(rNEvt, this);
314cdf0e10cSrcweir }
315cdf0e10cSrcweir if( !nResult )
316cdf0e10cSrcweir nResult = ::Window::Notify( rNEvt );
317cdf0e10cSrcweir
318cdf0e10cSrcweir return nResult;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir /*************************************************************************
322cdf0e10cSrcweir |* RequestHelp event
323cdf0e10cSrcweir \************************************************************************/
324cdf0e10cSrcweir
RequestHelp(const HelpEvent & rEvt)325cdf0e10cSrcweir void Window::RequestHelp(const HelpEvent& rEvt)
326cdf0e10cSrcweir {
327cdf0e10cSrcweir if ( mpViewShell )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir if( !mpViewShell->RequestHelp( rEvt, this) )
330cdf0e10cSrcweir ::Window::RequestHelp( rEvt );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir else
333cdf0e10cSrcweir ::Window::RequestHelp( rEvt );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
GetWinViewPos(void) const336cdf0e10cSrcweir Point Window::GetWinViewPos (void) const
337cdf0e10cSrcweir {
338cdf0e10cSrcweir return maWinPos;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
GetViewOrigin(void) const341cdf0e10cSrcweir Point Window::GetViewOrigin (void) const
342cdf0e10cSrcweir {
343cdf0e10cSrcweir return maViewOrigin;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
GetViewSize(void) const346cdf0e10cSrcweir Size Window::GetViewSize (void) const
347cdf0e10cSrcweir {
348cdf0e10cSrcweir return maViewSize;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir
351cdf0e10cSrcweir /*************************************************************************
352cdf0e10cSrcweir |* Position der linken oberen Ecke des im Fenster sichtbaren Bereichs
353cdf0e10cSrcweir |* setzen
354cdf0e10cSrcweir \************************************************************************/
355cdf0e10cSrcweir
SetWinViewPos(const Point & rPnt)356cdf0e10cSrcweir void Window::SetWinViewPos(const Point& rPnt)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir maWinPos = rPnt;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir /*************************************************************************
362*5133a0b6Smseidel |* Ursprung der Darstellung in Bezug zur gesamten Arbeitsfläche setzen
363cdf0e10cSrcweir \************************************************************************/
364cdf0e10cSrcweir
SetViewOrigin(const Point & rPnt)365cdf0e10cSrcweir void Window::SetViewOrigin(const Point& rPnt)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir maViewOrigin = rPnt;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir /*************************************************************************
371*5133a0b6Smseidel |* Größe der gesamten Arbeitsfläche, die mit dem Fenster betrachtet
372cdf0e10cSrcweir |* werden kann, setzen
373cdf0e10cSrcweir \************************************************************************/
374cdf0e10cSrcweir
SetViewSize(const Size & rSize)375cdf0e10cSrcweir void Window::SetViewSize(const Size& rSize)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir maViewSize = rSize;
378cdf0e10cSrcweir CalcMinZoom();
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
SetCenterAllowed(bool bIsAllowed)381cdf0e10cSrcweir void Window::SetCenterAllowed (bool bIsAllowed)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir mbCenterAllowed = bIsAllowed;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
SetZoomFactor(long nZoom)386cdf0e10cSrcweir long Window::SetZoomFactor(long nZoom)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir // Clip the zoom factor to the valid range marked by nMinZoom as
389cdf0e10cSrcweir // calculated by CalcMinZoom() and the constant MAX_ZOOM.
390cdf0e10cSrcweir if ( nZoom > MAX_ZOOM )
391cdf0e10cSrcweir nZoom = MAX_ZOOM;
392cdf0e10cSrcweir if ( nZoom < (long) mnMinZoom )
393cdf0e10cSrcweir nZoom = mnMinZoom;
394cdf0e10cSrcweir
395cdf0e10cSrcweir // Set the zoom factor at the window's map mode.
396cdf0e10cSrcweir MapMode aMap(GetMapMode());
397cdf0e10cSrcweir aMap.SetScaleX(Fraction(nZoom, 100));
398cdf0e10cSrcweir aMap.SetScaleY(Fraction(nZoom, 100));
399cdf0e10cSrcweir SetMapMode(aMap);
400cdf0e10cSrcweir
401cdf0e10cSrcweir // Update the map mode's origin (to what effect?).
402cdf0e10cSrcweir UpdateMapOrigin();
403cdf0e10cSrcweir
4047950f2afSmseidel // Update the view's snapping to the new zoom factor.
405cdf0e10cSrcweir if ( mpViewShell && mpViewShell->ISA(DrawViewShell) )
406cdf0e10cSrcweir ((DrawViewShell*) mpViewShell)->GetView()->
407cdf0e10cSrcweir RecalcLogicSnapMagnetic(*this);
408cdf0e10cSrcweir
409cdf0e10cSrcweir // Return the zoom factor just in case it has been changed above to lie
410cdf0e10cSrcweir // inside the valid range.
411cdf0e10cSrcweir return nZoom;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir
SetZoomIntegral(long nZoom)414cdf0e10cSrcweir void Window::SetZoomIntegral(long nZoom)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir // Clip the zoom factor to the valid range marked by nMinZoom as
417cdf0e10cSrcweir // previously calculated by <member>CalcMinZoom()</member> and the
418cdf0e10cSrcweir // MAX_ZOOM constant.
419cdf0e10cSrcweir if ( nZoom > MAX_ZOOM )
420cdf0e10cSrcweir nZoom = MAX_ZOOM;
421cdf0e10cSrcweir if ( nZoom < (long) mnMinZoom )
422cdf0e10cSrcweir nZoom = mnMinZoom;
423cdf0e10cSrcweir
424cdf0e10cSrcweir // Calculate the window's new origin.
425cdf0e10cSrcweir Size aSize = PixelToLogic(GetOutputSizePixel());
426cdf0e10cSrcweir long nW = aSize.Width() * GetZoom() / nZoom;
427cdf0e10cSrcweir long nH = aSize.Height() * GetZoom() / nZoom;
428cdf0e10cSrcweir maWinPos.X() += (aSize.Width() - nW) / 2;
429cdf0e10cSrcweir maWinPos.Y() += (aSize.Height() - nH) / 2;
430cdf0e10cSrcweir if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
431cdf0e10cSrcweir if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
432cdf0e10cSrcweir
433cdf0e10cSrcweir // Finally update this window's map mode to the given zoom factor that
434cdf0e10cSrcweir // has been clipped to the valid range.
435cdf0e10cSrcweir SetZoomFactor(nZoom);
436cdf0e10cSrcweir }
437cdf0e10cSrcweir
GetZoomForRect(const Rectangle & rZoomRect)438cdf0e10cSrcweir long Window::GetZoomForRect( const Rectangle& rZoomRect )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir long nRetZoom = 100;
441cdf0e10cSrcweir
442cdf0e10cSrcweir if( (rZoomRect.GetWidth() != 0) && (rZoomRect.GetHeight() != 0))
443cdf0e10cSrcweir {
444cdf0e10cSrcweir // Calculate the scale factors which will lead to the given
445cdf0e10cSrcweir // rectangle being fully visible (when translated accordingly) as
446cdf0e10cSrcweir // large as possible in the output area independently in both
447cdf0e10cSrcweir // coordinate directions .
448cdf0e10cSrcweir sal_uLong nX(0L);
449cdf0e10cSrcweir sal_uLong nY(0L);
450cdf0e10cSrcweir
451cdf0e10cSrcweir const Size aWinSize( PixelToLogic(GetOutputSizePixel()) );
452cdf0e10cSrcweir if(rZoomRect.GetHeight())
453cdf0e10cSrcweir {
454cdf0e10cSrcweir nX = (sal_uLong) ((double) aWinSize.Height()
455cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
458cdf0e10cSrcweir if(rZoomRect.GetWidth())
459cdf0e10cSrcweir {
460cdf0e10cSrcweir nY = (sal_uLong) ((double) aWinSize.Width()
461cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
462cdf0e10cSrcweir }
463cdf0e10cSrcweir
464cdf0e10cSrcweir // Use the smaller one of both so that the zoom rectangle will be
465cdf0e10cSrcweir // fully visible with respect to both coordinate directions.
466cdf0e10cSrcweir sal_uLong nFact = Min(nX, nY);
467cdf0e10cSrcweir
468cdf0e10cSrcweir // Transform the current zoom factor so that it leads to the desired
469cdf0e10cSrcweir // scaling.
470cdf0e10cSrcweir nRetZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
471cdf0e10cSrcweir
472cdf0e10cSrcweir // Calculate the new origin.
473cdf0e10cSrcweir if ( nFact == 0 )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir // Don't change anything if the scale factor is degenrate.
476cdf0e10cSrcweir nRetZoom = GetZoom();
477cdf0e10cSrcweir }
478cdf0e10cSrcweir else
479cdf0e10cSrcweir {
480cdf0e10cSrcweir // Clip the zoom factor to the valid range marked by nMinZoom as
481cdf0e10cSrcweir // previously calculated by <member>CalcMinZoom()</member> and the
482cdf0e10cSrcweir // MAX_ZOOM constant.
483cdf0e10cSrcweir if ( nRetZoom > MAX_ZOOM )
484cdf0e10cSrcweir nRetZoom = MAX_ZOOM;
485cdf0e10cSrcweir if ( nRetZoom < (long) mnMinZoom )
486cdf0e10cSrcweir nRetZoom = mnMinZoom;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir }
489cdf0e10cSrcweir
490cdf0e10cSrcweir return nRetZoom;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir
493cdf0e10cSrcweir /** Recalculate the zoom factor and translation so that the given rectangle
494cdf0e10cSrcweir is displayed centered and as large as possible while still being fully
495cdf0e10cSrcweir visible in the window.
496cdf0e10cSrcweir */
SetZoomRect(const Rectangle & rZoomRect)497cdf0e10cSrcweir long Window::SetZoomRect (const Rectangle& rZoomRect)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir long nNewZoom = 100;
500cdf0e10cSrcweir
501cdf0e10cSrcweir if (rZoomRect.GetWidth() == 0 || rZoomRect.GetHeight() == 0)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir // The given rectangle is degenerate. Use the default zoom factor
504cdf0e10cSrcweir // (above) of 100%.
505cdf0e10cSrcweir SetZoomIntegral(nNewZoom);
506cdf0e10cSrcweir }
507cdf0e10cSrcweir else
508cdf0e10cSrcweir {
509cdf0e10cSrcweir Point aPos = rZoomRect.TopLeft();
510cdf0e10cSrcweir // Transform the output area from pixel coordinates into logical
511cdf0e10cSrcweir // coordinates.
512cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel());
513cdf0e10cSrcweir // Paranoia! The degenerate case of zero width or height has been
514cdf0e10cSrcweir // taken care of above.
515cdf0e10cSrcweir DBG_ASSERT(rZoomRect.GetWidth(), "ZoomRect-Breite = 0!");
516cdf0e10cSrcweir DBG_ASSERT(rZoomRect.GetHeight(), "ZoomRect-Hoehe = 0!");
517cdf0e10cSrcweir
518cdf0e10cSrcweir // Calculate the scale factors which will lead to the given
519cdf0e10cSrcweir // rectangle being fully visible (when translated accordingly) as
520cdf0e10cSrcweir // large as possible in the output area independently in both
521cdf0e10cSrcweir // coordinate directions .
522cdf0e10cSrcweir sal_uLong nX(0L);
523cdf0e10cSrcweir sal_uLong nY(0L);
524cdf0e10cSrcweir
525cdf0e10cSrcweir if(rZoomRect.GetHeight())
526cdf0e10cSrcweir {
527cdf0e10cSrcweir nX = (sal_uLong) ((double) aWinSize.Height()
528cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
529cdf0e10cSrcweir }
530cdf0e10cSrcweir
531cdf0e10cSrcweir if(rZoomRect.GetWidth())
532cdf0e10cSrcweir {
533cdf0e10cSrcweir nY = (sal_uLong) ((double) aWinSize.Width()
534cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
535cdf0e10cSrcweir }
536cdf0e10cSrcweir
537cdf0e10cSrcweir // Use the smaller one of both so that the zoom rectangle will be
538cdf0e10cSrcweir // fully visible with respect to both coordinate directions.
539cdf0e10cSrcweir sal_uLong nFact = Min(nX, nY);
540cdf0e10cSrcweir
541cdf0e10cSrcweir // Transform the current zoom factor so that it leads to the desired
542cdf0e10cSrcweir // scaling.
543cdf0e10cSrcweir long nZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
544cdf0e10cSrcweir
545cdf0e10cSrcweir // Calculate the new origin.
546cdf0e10cSrcweir if ( nFact == 0 )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir // Don't change anything if the scale factor is degenrate.
549cdf0e10cSrcweir nNewZoom = GetZoom();
550cdf0e10cSrcweir }
551cdf0e10cSrcweir else
552cdf0e10cSrcweir {
553cdf0e10cSrcweir // Calculate the new window position that centers the given
554cdf0e10cSrcweir // rectangle on the screen.
555cdf0e10cSrcweir if ( nZoom > MAX_ZOOM )
556cdf0e10cSrcweir nFact = nFact * MAX_ZOOM / nZoom;
557cdf0e10cSrcweir
558cdf0e10cSrcweir maWinPos = maViewOrigin + aPos;
559cdf0e10cSrcweir
560cdf0e10cSrcweir aWinSize.Width() = (long) ((double) aWinSize.Width() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
561cdf0e10cSrcweir maWinPos.X() += (rZoomRect.GetWidth() - aWinSize.Width()) / 2;
562cdf0e10cSrcweir aWinSize.Height() = (long) ((double) aWinSize.Height() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
563cdf0e10cSrcweir maWinPos.Y() += (rZoomRect.GetHeight() - aWinSize.Height()) / 2;
564cdf0e10cSrcweir
565cdf0e10cSrcweir if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
566cdf0e10cSrcweir if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
567cdf0e10cSrcweir
568cdf0e10cSrcweir // Adapt the window's map mode to the new zoom factor.
569cdf0e10cSrcweir nNewZoom = SetZoomFactor(nZoom);
570cdf0e10cSrcweir }
571cdf0e10cSrcweir }
572cdf0e10cSrcweir
573cdf0e10cSrcweir return(nNewZoom);
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
SetMinZoomAutoCalc(bool bAuto)576cdf0e10cSrcweir void Window::SetMinZoomAutoCalc (bool bAuto)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir mbMinZoomAutoCalc = bAuto;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
581cdf0e10cSrcweir /*************************************************************************
582cdf0e10cSrcweir |* Neuen MapMode-Origin berechnen und setzen; wenn aWinPos.X()/Y()
583cdf0e10cSrcweir |* gleich -1 ist, wird die entsprechende Position zentriert
584*5133a0b6Smseidel |* (z.B. für Initialisierung)
585cdf0e10cSrcweir \************************************************************************/
586cdf0e10cSrcweir
UpdateMapOrigin(sal_Bool bInvalidate)587cdf0e10cSrcweir void Window::UpdateMapOrigin(sal_Bool bInvalidate)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir sal_Bool bChanged = sal_False;
590cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel());
591cdf0e10cSrcweir
592cdf0e10cSrcweir if ( mbCenterAllowed )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir maWinPos.X() = maViewSize.Width() - aWinSize.Width();
597cdf0e10cSrcweir bChanged = sal_True;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir if ( maWinPos.Y() > maViewSize.Height() - aWinSize.Height() )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir maWinPos.Y() = maViewSize.Height() - aWinSize.Height();
602cdf0e10cSrcweir bChanged = sal_True;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir if ( aWinSize.Width() > maViewSize.Width() || maWinPos.X() < 0 )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir maWinPos.X() = maViewSize.Width() / 2 - aWinSize.Width() / 2;
607cdf0e10cSrcweir bChanged = sal_True;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir if ( aWinSize.Height() > maViewSize.Height() || maWinPos.Y() < 0 )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir maWinPos.Y() = maViewSize.Height() / 2 - aWinSize.Height() / 2;
612cdf0e10cSrcweir bChanged = sal_True;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir UpdateMapMode ();
617cdf0e10cSrcweir
618cdf0e10cSrcweir if (bChanged && bInvalidate)
619cdf0e10cSrcweir Invalidate();
620cdf0e10cSrcweir }
621cdf0e10cSrcweir
UpdateMapMode(void)622cdf0e10cSrcweir void Window::UpdateMapMode (void)
623cdf0e10cSrcweir {
624cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel());
625cdf0e10cSrcweir maWinPos -= maViewOrigin;
626cdf0e10cSrcweir Size aPix(maWinPos.X(), maWinPos.Y());
627cdf0e10cSrcweir aPix = LogicToPixel(aPix);
628*5133a0b6Smseidel // Größe muss vielfaches von BRUSH_SIZE sein, damit Muster
629cdf0e10cSrcweir // richtig dargestellt werden
630cdf0e10cSrcweir // #i2237#
631cdf0e10cSrcweir // removed old stuff here which still forced zoom to be
632cdf0e10cSrcweir // %BRUSH_SIZE which is outdated now
633cdf0e10cSrcweir
634cdf0e10cSrcweir if (mpViewShell && mpViewShell->ISA(DrawViewShell))
635cdf0e10cSrcweir {
636cdf0e10cSrcweir Size aViewSizePixel = LogicToPixel(maViewSize);
637cdf0e10cSrcweir Size aWinSizePixel = LogicToPixel(aWinSize);
638cdf0e10cSrcweir
639cdf0e10cSrcweir // Seite soll nicht am Fensterrand "kleben"
640cdf0e10cSrcweir if (aPix.Width() == 0)
641cdf0e10cSrcweir {
642cdf0e10cSrcweir // #i2237#
643cdf0e10cSrcweir // Since BRUSH_SIZE alignment is outdated now, i use the
644cdf0e10cSrcweir // former constant here directly
645cdf0e10cSrcweir aPix.Width() -= 8;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir if (aPix.Height() == 0)
648cdf0e10cSrcweir {
649cdf0e10cSrcweir // #i2237#
650cdf0e10cSrcweir // Since BRUSH_SIZE alignment is outdated now, i use the
651cdf0e10cSrcweir // former constant here directly
652cdf0e10cSrcweir aPix.Height() -= 8;
653cdf0e10cSrcweir }
654cdf0e10cSrcweir }
655cdf0e10cSrcweir
656cdf0e10cSrcweir aPix = PixelToLogic(aPix);
657cdf0e10cSrcweir maWinPos.X() = aPix.Width();
658cdf0e10cSrcweir maWinPos.Y() = aPix.Height();
659cdf0e10cSrcweir Point aNewOrigin (-maWinPos.X(), -maWinPos.Y());
660cdf0e10cSrcweir maWinPos += maViewOrigin;
661cdf0e10cSrcweir
662cdf0e10cSrcweir MapMode aMap(GetMapMode());
663cdf0e10cSrcweir aMap.SetOrigin(aNewOrigin);
664cdf0e10cSrcweir SetMapMode(aMap);
665cdf0e10cSrcweir }
666cdf0e10cSrcweir
667cdf0e10cSrcweir /*************************************************************************
668cdf0e10cSrcweir |* X-Position des sichtbaren Bereichs als Bruchteil (< 1)
669*5133a0b6Smseidel |* der gesamten Arbeitsbereichbreite zurückgeben
670cdf0e10cSrcweir \************************************************************************/
671cdf0e10cSrcweir
GetVisibleX()672cdf0e10cSrcweir double Window::GetVisibleX()
673cdf0e10cSrcweir {
674cdf0e10cSrcweir return ((double) maWinPos.X() / maViewSize.Width());
675cdf0e10cSrcweir }
676cdf0e10cSrcweir
677cdf0e10cSrcweir /*************************************************************************
678cdf0e10cSrcweir |* Y-Position des sichtbaren Bereichs als Bruchteil (< 1)
679*5133a0b6Smseidel |* der gesamten Arbeitsbereichhöhe zurückgeben
680cdf0e10cSrcweir \************************************************************************/
681cdf0e10cSrcweir
GetVisibleY()682cdf0e10cSrcweir double Window::GetVisibleY()
683cdf0e10cSrcweir {
684cdf0e10cSrcweir return ((double) maWinPos.Y() / maViewSize.Height());
685cdf0e10cSrcweir }
686cdf0e10cSrcweir
687cdf0e10cSrcweir /*************************************************************************
688cdf0e10cSrcweir |* X- und Y-Position des sichtbaren Bereichs als Bruchteile (< 1)
689*5133a0b6Smseidel |* der gesamten Arbeitsbereichgröße setzen
690cdf0e10cSrcweir |* negative Werte werden ignoriert
691cdf0e10cSrcweir \************************************************************************/
692cdf0e10cSrcweir
SetVisibleXY(double fX,double fY)693cdf0e10cSrcweir void Window::SetVisibleXY(double fX, double fY)
694cdf0e10cSrcweir {
695cdf0e10cSrcweir long nOldX = maWinPos.X();
696cdf0e10cSrcweir long nOldY = maWinPos.Y();
697cdf0e10cSrcweir
698cdf0e10cSrcweir if ( fX >= 0 )
699cdf0e10cSrcweir maWinPos.X() = (long) (fX * maViewSize.Width());
700cdf0e10cSrcweir if ( fY >= 0 )
701cdf0e10cSrcweir maWinPos.Y() = (long) (fY * maViewSize.Height());
702cdf0e10cSrcweir UpdateMapOrigin(sal_False);
703cdf0e10cSrcweir //Size sz(nOldX - aWinPos.X(), nOldY - aWinPos.Y());
704cdf0e10cSrcweir //sz = LogicToPixel(sz);
705cdf0e10cSrcweir Scroll(nOldX - maWinPos.X(), nOldY - maWinPos.Y(), SCROLL_CHILDREN);
706cdf0e10cSrcweir Update();
707cdf0e10cSrcweir }
708cdf0e10cSrcweir
709cdf0e10cSrcweir /*************************************************************************
710*5133a0b6Smseidel |* Breite des sichtbaren Bereichs im Verhältnis zur
711*5133a0b6Smseidel |* gesamten Arbeitsbereichbreite zurückgeben
712cdf0e10cSrcweir \************************************************************************/
713cdf0e10cSrcweir
GetVisibleWidth()714cdf0e10cSrcweir double Window::GetVisibleWidth()
715cdf0e10cSrcweir {
716cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel());
717cdf0e10cSrcweir if ( aWinSize.Width() > maViewSize.Width() )
718cdf0e10cSrcweir aWinSize.Width() = maViewSize.Width();
719cdf0e10cSrcweir return ((double) aWinSize.Width() / maViewSize.Width());
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir /*************************************************************************
723*5133a0b6Smseidel |* Höhe des sichtbaren Bereichs im Verhältnis zur
724*5133a0b6Smseidel |* gesamten Arbeitsbereichhöhe zurückgeben
725cdf0e10cSrcweir \************************************************************************/
726cdf0e10cSrcweir
GetVisibleHeight()727cdf0e10cSrcweir double Window::GetVisibleHeight()
728cdf0e10cSrcweir {
729cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel());
730cdf0e10cSrcweir if ( aWinSize.Height() > maViewSize.Height() )
731cdf0e10cSrcweir aWinSize.Height() = maViewSize.Height();
732cdf0e10cSrcweir return ((double) aWinSize.Height() / maViewSize.Height());
733cdf0e10cSrcweir }
734cdf0e10cSrcweir
735cdf0e10cSrcweir /*************************************************************************
736*5133a0b6Smseidel |* Breite einer Scrollspalte im Verhältnis zur gesamten
737*5133a0b6Smseidel |* Arbeitsbereichbreite zurückgeben
738cdf0e10cSrcweir \************************************************************************/
739cdf0e10cSrcweir
GetScrlLineWidth()740cdf0e10cSrcweir double Window::GetScrlLineWidth()
741cdf0e10cSrcweir {
742cdf0e10cSrcweir return (GetVisibleWidth() * SCROLL_LINE_FACT);
743cdf0e10cSrcweir }
744cdf0e10cSrcweir
745cdf0e10cSrcweir /*************************************************************************
746*5133a0b6Smseidel |* Breite einer Scrollspalte im Verhältnis zur gesamten
747*5133a0b6Smseidel |* Arbeitsbereichhöhe zurückgeben
748cdf0e10cSrcweir \************************************************************************/
749cdf0e10cSrcweir
GetScrlLineHeight()750cdf0e10cSrcweir double Window::GetScrlLineHeight()
751cdf0e10cSrcweir {
752cdf0e10cSrcweir return (GetVisibleHeight() * SCROLL_LINE_FACT);
753cdf0e10cSrcweir }
754cdf0e10cSrcweir
755cdf0e10cSrcweir /*************************************************************************
756*5133a0b6Smseidel |* Breite einer Scrollpage im Verhältnis zur gesamten
757*5133a0b6Smseidel |* Arbeitsbereichbreite zurückgeben
758cdf0e10cSrcweir \************************************************************************/
759cdf0e10cSrcweir
GetScrlPageWidth()760cdf0e10cSrcweir double Window::GetScrlPageWidth()
761cdf0e10cSrcweir {
762cdf0e10cSrcweir return (GetVisibleWidth() * SCROLL_PAGE_FACT);
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir /*************************************************************************
766*5133a0b6Smseidel |* Breite einer Scrollpage im Verhältnis zur gesamten
767*5133a0b6Smseidel |* Arbeitsbereichhöhe zurückgeben
768cdf0e10cSrcweir \************************************************************************/
769cdf0e10cSrcweir
GetScrlPageHeight()770cdf0e10cSrcweir double Window::GetScrlPageHeight()
771cdf0e10cSrcweir {
772cdf0e10cSrcweir return (GetVisibleHeight() * SCROLL_PAGE_FACT);
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775cdf0e10cSrcweir /*************************************************************************
776cdf0e10cSrcweir |* Fenster deaktivieren
777cdf0e10cSrcweir \************************************************************************/
778cdf0e10cSrcweir
LoseFocus()779cdf0e10cSrcweir void Window::LoseFocus()
780cdf0e10cSrcweir {
781cdf0e10cSrcweir mnTicks = 0;
782cdf0e10cSrcweir ::Window::LoseFocus ();
783cdf0e10cSrcweir }
784cdf0e10cSrcweir
785cdf0e10cSrcweir /*************************************************************************
786cdf0e10cSrcweir |* Fenster aktivieren
787cdf0e10cSrcweir \************************************************************************/
788cdf0e10cSrcweir
GrabFocus()789cdf0e10cSrcweir void Window::GrabFocus()
790cdf0e10cSrcweir {
791cdf0e10cSrcweir mnTicks = 0;
792cdf0e10cSrcweir ::Window::GrabFocus ();
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
795cdf0e10cSrcweir /*************************************************************************
796cdf0e10cSrcweir |* DataChanged
797cdf0e10cSrcweir \************************************************************************/
798cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)799cdf0e10cSrcweir void Window::DataChanged( const DataChangedEvent& rDCEvt )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir ::Window::DataChanged( rDCEvt );
802cdf0e10cSrcweir
803cdf0e10cSrcweir // PRINTER bei allen Dokumenten weglassen, die keinen Printer benutzen.
804cdf0e10cSrcweir // FONTS und FONTSUBSTITUTION weglassen, wenn keine Textausgaben
805*5133a0b6Smseidel // vorhanden sind, bzw. wenn das Dokument keinen Text zulässt.
806cdf0e10cSrcweir
807cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
808cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
809cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTS) ||
810cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
811cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
812cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
815cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir // When the screen zoom factor has changed then reset the zoom
81830acf5e8Spfg // factor of the frame to always display the whole page.
819cdf0e10cSrcweir const AllSettings* pOldSettings = rDCEvt.GetOldSettings ();
820cdf0e10cSrcweir const AllSettings& rNewSettings = GetSettings ();
821cdf0e10cSrcweir if (pOldSettings)
822cdf0e10cSrcweir if (pOldSettings->GetStyleSettings().GetScreenZoom()
823cdf0e10cSrcweir != rNewSettings.GetStyleSettings().GetScreenZoom())
824cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetDispatcher()->
825cdf0e10cSrcweir Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
826cdf0e10cSrcweir
827cdf0e10cSrcweir // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
828cdf0e10cSrcweir // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
829cdf0e10cSrcweir // Resize-Handler aber auch die Groesse der ScrollBars aus
830cdf0e10cSrcweir // den Settings abgefragt werden.
831cdf0e10cSrcweir Resize();
832cdf0e10cSrcweir
833cdf0e10cSrcweir // Daten neu Setzen, die aus den Systemeinstellungen bzw. aus
834cdf0e10cSrcweir // den Settings uebernommen werden. Evtl. weitere Daten neu
835cdf0e10cSrcweir // berechnen, da sich auch die Aufloesung hierdurch geaendert
836cdf0e10cSrcweir // haben kann.
837cdf0e10cSrcweir if( mpViewShell )
838cdf0e10cSrcweir {
839cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
840cdf0e10cSrcweir SvtAccessibilityOptions aAccOptions;
841cdf0e10cSrcweir sal_uLong nOutputMode;
842cdf0e10cSrcweir sal_uInt16 nPreviewSlot;
843cdf0e10cSrcweir
844cdf0e10cSrcweir if( rStyleSettings.GetHighContrastMode() )
845cdf0e10cSrcweir nOutputMode = ViewShell::OUTPUT_DRAWMODE_CONTRAST;
846cdf0e10cSrcweir else
847cdf0e10cSrcweir nOutputMode = ViewShell::OUTPUT_DRAWMODE_COLOR;
848cdf0e10cSrcweir
849cdf0e10cSrcweir if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
850cdf0e10cSrcweir nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
851cdf0e10cSrcweir else
852cdf0e10cSrcweir nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
853cdf0e10cSrcweir
854cdf0e10cSrcweir if( mpViewShell->ISA( DrawViewShell ) )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir SetDrawMode( nOutputMode );
857cdf0e10cSrcweir mpViewShell->GetFrameView()->SetDrawMode( nOutputMode );
858cdf0e10cSrcweir // #110094#-7
859cdf0e10cSrcweir // mpViewShell->GetView()->ReleaseMasterPagePaintCache();
860cdf0e10cSrcweir Invalidate();
861cdf0e10cSrcweir }
862cdf0e10cSrcweir
863cdf0e10cSrcweir // #103100# Overwrite window color for OutlineView
864cdf0e10cSrcweir if( mpViewShell->ISA(OutlineViewShell ) )
865cdf0e10cSrcweir {
866cdf0e10cSrcweir svtools::ColorConfig aColorConfig;
867cdf0e10cSrcweir const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
868cdf0e10cSrcweir SetBackground( Wallpaper( aDocColor ) );
869cdf0e10cSrcweir }
870cdf0e10cSrcweir
871cdf0e10cSrcweir SfxRequest aReq( nPreviewSlot, 0, mpViewShell->GetDocSh()->GetDoc()->GetItemPool() );
872cdf0e10cSrcweir mpViewShell->ExecReq( aReq );
873cdf0e10cSrcweir mpViewShell->Invalidate();
874cdf0e10cSrcweir mpViewShell->ArrangeGUIElements();
875cdf0e10cSrcweir
876cdf0e10cSrcweir // #101928# re-create handles to show new outfit
877cdf0e10cSrcweir if(mpViewShell->ISA(DrawViewShell))
878cdf0e10cSrcweir {
879cdf0e10cSrcweir mpViewShell->GetView()->AdjustMarkHdl();
880cdf0e10cSrcweir }
881cdf0e10cSrcweir }
882cdf0e10cSrcweir }
883cdf0e10cSrcweir
884cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
885cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
886cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
887cdf0e10cSrcweir {
888*5133a0b6Smseidel // Virtuelle Device die auch von der Auflösung oder von
889*5133a0b6Smseidel // Systemeinstellungen abhängen, sollten geupdatet werden.
890cdf0e10cSrcweir // Ansonsten sollte zumindest bei DATACHANGED_DISPLAY
891cdf0e10cSrcweir // die virtuellen Devices geupdatet werden, da es einige
892*5133a0b6Smseidel // Systeme erlauben die Auflösung und Farbtiefe während
893*5133a0b6Smseidel // der Laufzeit zu ändern oder eben bei Palettenaenderungen
894*5133a0b6Smseidel // die virtuellen Device geupdatet werden müssen, da bei
895cdf0e10cSrcweir // Ausgaben ein anderes Farbmatching stattfinden kann.
896cdf0e10cSrcweir }
897cdf0e10cSrcweir
898cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_FONTS )
899cdf0e10cSrcweir {
900*5133a0b6Smseidel // Wenn das Dokument Font-AuswahlBoxen anbietet, müssen
901cdf0e10cSrcweir // diese geupdatet werden. Wie dies genau aussehen muss,
902cdf0e10cSrcweir // weiss ich leider auch nicht. Aber evtl. kann man das
903*5133a0b6Smseidel // ja global handeln. Dies müssten wir evtl. mal
904cdf0e10cSrcweir // mit PB absprechen, aber der ist derzeit leider Krank.
905cdf0e10cSrcweir // Also bevor dies hier gehandelt wird, vorher mit
906cdf0e10cSrcweir // PB und mir absprechen.
907cdf0e10cSrcweir }
908cdf0e10cSrcweir
909cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
910cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir // Formatierung neu durchfuehren, da Fonts die im Dokument
913cdf0e10cSrcweir // vorkommen, nicht mehr vorhanden sein muessen oder
914cdf0e10cSrcweir // jetzt vorhanden sind oder durch andere ersetzt wurden
915cdf0e10cSrcweir // sind.
916cdf0e10cSrcweir if( mpViewShell )
917cdf0e10cSrcweir {
918cdf0e10cSrcweir DrawDocShell* pDocSh = mpViewShell->GetDocSh();
919cdf0e10cSrcweir if( pDocSh )
920cdf0e10cSrcweir pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
921cdf0e10cSrcweir }
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
925cdf0e10cSrcweir {
926cdf0e10cSrcweir // Wie hier die Behandlung aussehen soll, weiss ich leider
927cdf0e10cSrcweir // selbst noch nicht. Evtl. mal einen Printer loeschen und
928cdf0e10cSrcweir // schauen was gemacht werden muss. Evtl. muesste ich in
929721f84f2Smseidel // VCL dafuer noch etwas einbauen, wenn der benutzte Printer
930cdf0e10cSrcweir // geloescht wird. Ansonsten wuerde ich hier evtl. die
931cdf0e10cSrcweir // Formatierung neu berechnen, wenn der aktuelle Drucker
932cdf0e10cSrcweir // zerstoert wurde.
933cdf0e10cSrcweir if( mpViewShell )
934cdf0e10cSrcweir {
935cdf0e10cSrcweir DrawDocShell* pDocSh = mpViewShell->GetDocSh();
936cdf0e10cSrcweir if( pDocSh )
937cdf0e10cSrcweir pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
938cdf0e10cSrcweir }
939cdf0e10cSrcweir }
940cdf0e10cSrcweir
941cdf0e10cSrcweir // Alles neu ausgeben
942cdf0e10cSrcweir Invalidate();
943cdf0e10cSrcweir }
944cdf0e10cSrcweir }
945cdf0e10cSrcweir
946cdf0e10cSrcweir /*************************************************************************
947cdf0e10cSrcweir |* DropTargetHelper::AcceptDrop
948cdf0e10cSrcweir \************************************************************************/
949cdf0e10cSrcweir
AcceptDrop(const AcceptDropEvent & rEvt)950cdf0e10cSrcweir sal_Int8 Window::AcceptDrop( const AcceptDropEvent& rEvt )
951cdf0e10cSrcweir {
952cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE;
953cdf0e10cSrcweir
954cdf0e10cSrcweir if( mpViewShell && !mpViewShell->GetDocSh()->IsReadOnly() )
955cdf0e10cSrcweir {
956cdf0e10cSrcweir if( mpViewShell )
957cdf0e10cSrcweir nRet = mpViewShell->AcceptDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
958cdf0e10cSrcweir
959cdf0e10cSrcweir if (mbUseDropScroll && ! mpViewShell->ISA(OutlineViewShell))
960cdf0e10cSrcweir DropScroll( rEvt.maPosPixel );
961cdf0e10cSrcweir }
962cdf0e10cSrcweir
963cdf0e10cSrcweir return nRet;
964cdf0e10cSrcweir }
965cdf0e10cSrcweir
966cdf0e10cSrcweir /*************************************************************************
967cdf0e10cSrcweir |* DropTargetHelper::ExecuteDrop
968cdf0e10cSrcweir \************************************************************************/
969cdf0e10cSrcweir
ExecuteDrop(const ExecuteDropEvent & rEvt)970cdf0e10cSrcweir sal_Int8 Window::ExecuteDrop( const ExecuteDropEvent& rEvt )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE;
973cdf0e10cSrcweir
974cdf0e10cSrcweir if( mpViewShell )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir nRet = mpViewShell->ExecuteDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
977cdf0e10cSrcweir }
978cdf0e10cSrcweir
979cdf0e10cSrcweir return nRet;
980cdf0e10cSrcweir }
981cdf0e10cSrcweir
SetUseDropScroll(bool bUseDropScroll)982cdf0e10cSrcweir void Window::SetUseDropScroll (bool bUseDropScroll)
983cdf0e10cSrcweir {
984cdf0e10cSrcweir mbUseDropScroll = bUseDropScroll;
985cdf0e10cSrcweir }
986cdf0e10cSrcweir
987cdf0e10cSrcweir /*************************************************************************
988cdf0e10cSrcweir |* Scrolling bei AcceptDrop-Events
989cdf0e10cSrcweir \************************************************************************/
990cdf0e10cSrcweir
DropScroll(const Point & rMousePos)991cdf0e10cSrcweir void Window::DropScroll(const Point& rMousePos)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir short nDx = 0;
994cdf0e10cSrcweir short nDy = 0;
995cdf0e10cSrcweir
996cdf0e10cSrcweir Size aSize = GetOutputSizePixel();
997cdf0e10cSrcweir
998cdf0e10cSrcweir if (aSize.Width() > SCROLL_SENSITIVE * 3)
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir if ( rMousePos.X() < SCROLL_SENSITIVE )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir nDx = -1;
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE )
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir nDx = 1;
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir if (aSize.Height() > SCROLL_SENSITIVE * 3)
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir if ( rMousePos.Y() < SCROLL_SENSITIVE )
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir nDy = -1;
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE )
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir nDy = 1;
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir if ( (nDx || nDy) && (rMousePos.X()!=0 || rMousePos.Y()!=0 ) )
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir if (mnTicks > 20)
1027cdf0e10cSrcweir mpViewShell->ScrollLines(nDx, nDy);
1028cdf0e10cSrcweir else
1029cdf0e10cSrcweir mnTicks ++;
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir ::com::sun::star::uno::Reference<
1034cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>
CreateAccessible(void)1035cdf0e10cSrcweir Window::CreateAccessible (void)
1036cdf0e10cSrcweir {
10370deba7fbSSteve Yin // If current viewshell is PresentationViewShell, just return empty because the correct ShowWin will be created later.
10380deba7fbSSteve Yin if (mpViewShell && mpViewShell->ISA(PresentationViewShell))
10390deba7fbSSteve Yin {
10400deba7fbSSteve Yin return ::Window::CreateAccessible ();
10410deba7fbSSteve Yin }
10420deba7fbSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc = GetAccessible(sal_False);
10430deba7fbSSteve Yin if (xAcc.get())
10440deba7fbSSteve Yin {
10450deba7fbSSteve Yin return xAcc;
10460deba7fbSSteve Yin }
1047cdf0e10cSrcweir if (mpViewShell != NULL)
10480deba7fbSSteve Yin {
10490deba7fbSSteve Yin xAcc = mpViewShell->CreateAccessibleDocumentView (this);
10500deba7fbSSteve Yin SetAccessible(xAcc);
10510deba7fbSSteve Yin return xAcc;
10520deba7fbSSteve Yin }
1053cdf0e10cSrcweir else
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir OSL_TRACE ("::sd::Window::CreateAccessible: no view shell");
1056cdf0e10cSrcweir return ::Window::CreateAccessible ();
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir
10600deba7fbSSteve Yin // MT: Removed Windows::SwitchView() introduced with IA2 CWS.
1061721f84f2Smseidel // There are other notifications for this when the active view has changed, so please update the code to use that event mechanism
SwitchView()10620deba7fbSSteve Yin void Window::SwitchView()
10630deba7fbSSteve Yin {
10640deba7fbSSteve Yin if (!Application::IsAccessibilityEnabled())
10650deba7fbSSteve Yin {
10660deba7fbSSteve Yin return ;
10670deba7fbSSteve Yin }
10680deba7fbSSteve Yin if (mpViewShell)
10690deba7fbSSteve Yin {
10700deba7fbSSteve Yin mpViewShell->SwitchViewFireFocus(GetAccessible(sal_False));
10710deba7fbSSteve Yin }
10720deba7fbSSteve Yin }
10730deba7fbSSteve Yin
GetSurroundingText() const1074cdf0e10cSrcweir XubString Window::GetSurroundingText() const
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir return XubString();
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir else if ( mpViewShell->GetView()->IsTextEdit() )
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
1083cdf0e10cSrcweir return pOLV->GetEditView().GetSurroundingText();
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir else
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir return XubString();
1088cdf0e10cSrcweir }
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir
GetSurroundingTextSelection() const1091cdf0e10cSrcweir Selection Window::GetSurroundingTextSelection() const
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir return Selection( 0, 0 );
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir else if ( mpViewShell->GetView()->IsTextEdit() )
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
1100cdf0e10cSrcweir return pOLV->GetEditView().GetSurroundingTextSelection();
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir else
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir return Selection( 0, 0 );
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir } // end of namespace sd
1109721f84f2Smseidel
1110721f84f2Smseidel /* vim: set noet sw=4 ts=4: */
1111