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