xref: /aoo41x/main/sw/source/ui/uiview/pview.cxx (revision 90386390)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sfx2/objface.hxx>
28cdf0e10cSrcweir #include <vcl/timer.hxx>
29cdf0e10cSrcweir #include <vcl/field.hxx>
30cdf0e10cSrcweir #include <vcl/fixed.hxx>
31cdf0e10cSrcweir #include <vcl/help.hxx>
32cdf0e10cSrcweir #include <vcl/cmdevt.hxx>
33cdf0e10cSrcweir #include <vcl/button.hxx>
34cdf0e10cSrcweir #include <svl/whiter.hxx>
35cdf0e10cSrcweir #include <svl/stritem.hxx>
36cdf0e10cSrcweir #include <svl/eitem.hxx>
37cdf0e10cSrcweir #include <sfx2/printer.hxx>
38cdf0e10cSrcweir #include <sfx2/progress.hxx>
39cdf0e10cSrcweir #include <sfx2/app.hxx>
40cdf0e10cSrcweir #include <sfx2/bindings.hxx>
41cdf0e10cSrcweir #include <sfx2/request.hxx>
42cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
43cdf0e10cSrcweir #include <vcl/msgbox.hxx>
44cdf0e10cSrcweir #include <svx/stddlg.hxx>
45cdf0e10cSrcweir #include <editeng/paperinf.hxx>
46cdf0e10cSrcweir #include <svl/srchitem.hxx>
47cdf0e10cSrcweir #include <svx/svdview.hxx>
48cdf0e10cSrcweir #include <svx/dlgutil.hxx>
49cdf0e10cSrcweir #include <svx/zoomslideritem.hxx>
50cdf0e10cSrcweir #include <svx/svxids.hrc>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include <swwait.hxx>
53cdf0e10cSrcweir #include <globdoc.hxx>
54cdf0e10cSrcweir #include <wdocsh.hxx>
55cdf0e10cSrcweir #include <pvprtdat.hxx>
56cdf0e10cSrcweir #include <swmodule.hxx>
57cdf0e10cSrcweir #include <modcfg.hxx>
58cdf0e10cSrcweir #include <wrtsh.hxx>
59cdf0e10cSrcweir #include <docsh.hxx>
60cdf0e10cSrcweir #include <viewopt.hxx>
61cdf0e10cSrcweir #include <doc.hxx>
62cdf0e10cSrcweir #include <pview.hxx>
63cdf0e10cSrcweir #include <view.hxx>
64cdf0e10cSrcweir #include <textsh.hxx>
65cdf0e10cSrcweir #include <scroll.hxx>
66cdf0e10cSrcweir #include <prtopt.hxx>
67cdf0e10cSrcweir #include <docstat.hxx>
68cdf0e10cSrcweir #include <usrpref.hxx>
69cdf0e10cSrcweir #include <viewfunc.hxx>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir #include <helpid.h>
72cdf0e10cSrcweir #include <cmdid.h>
73cdf0e10cSrcweir #include <globals.hrc>
74cdf0e10cSrcweir #include <popup.hrc>
75cdf0e10cSrcweir #include <pview.hrc>
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #define SwPagePreView
78cdf0e10cSrcweir #include <sfx2/msg.hxx>
79cdf0e10cSrcweir #include <swslots.hxx>
80cdf0e10cSrcweir // OD 12.12.2002 #103492#
81cdf0e10cSrcweir #include <pagepreviewlayout.hxx>
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #include <svx/svxdlg.hxx>
84cdf0e10cSrcweir #include <svx/dialogs.hrc>
85cdf0e10cSrcweir #include <vos/mutex.hxx>
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir using namespace ::com::sun::star;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreView, "PrintPreview")
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	SFX_VIEW_REGISTRATION(SwDocShell);
93cdf0e10cSrcweir 	SFX_VIEW_REGISTRATION(SwWebDocShell);
94cdf0e10cSrcweir 	SFX_VIEW_REGISTRATION(SwGlobalDocShell);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
SFX_IMPL_INTERFACE(SwPagePreView,SfxViewShell,SW_RES (RID_PVIEW_TOOLBOX))97cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwPagePreView, SfxViewShell, SW_RES(RID_PVIEW_TOOLBOX))
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU));
100cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
101cdf0e10cSrcweir 								SFX_VISIBILITY_CLIENT|SFX_VISIBILITY_FULLSCREEN|
102cdf0e10cSrcweir 								SFX_VISIBILITY_READONLYDOC,
103cdf0e10cSrcweir 								SW_RES(RID_PVIEW_TOOLBOX));
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
TYPEINIT1(SwPagePreView,SfxViewShell)107cdf0e10cSrcweir TYPEINIT1(SwPagePreView,SfxViewShell)
108cdf0e10cSrcweir 
109cdf0e10cSrcweir #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS )
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #define MIN_PREVIEW_ZOOM 25
112cdf0e10cSrcweir #define MAX_PREVIEW_ZOOM 600
113cdf0e10cSrcweir /*  */
114cdf0e10cSrcweir /* -----------------26.11.2002 10:41-----------------
115cdf0e10cSrcweir  *
116cdf0e10cSrcweir  * --------------------------------------------------*/
117cdf0e10cSrcweir sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, sal_Bool bZoomIn)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     static sal_uInt16 aZoomArr[] =
120cdf0e10cSrcweir     {
121cdf0e10cSrcweir         25, 50, 75, 100, 150, 200, 400, 600
122cdf0e10cSrcweir     };
123cdf0e10cSrcweir     const sal_uInt16 nZoomArrSize = sizeof(aZoomArr)/sizeof(sal_uInt16);
124cdf0e10cSrcweir     if(bZoomIn)
125cdf0e10cSrcweir         for(int i = nZoomArrSize - 1; i >= 0; --i)
126cdf0e10cSrcweir         {
127cdf0e10cSrcweir             if(nCurrentZoom > aZoomArr[i] || !i)
128cdf0e10cSrcweir                 return aZoomArr[i];
129cdf0e10cSrcweir         }
130cdf0e10cSrcweir     else
131cdf0e10cSrcweir         for(int i = 0; i < nZoomArrSize; ++i)
132cdf0e10cSrcweir         {
133cdf0e10cSrcweir             if(nCurrentZoom < aZoomArr[i])
134cdf0e10cSrcweir                 return aZoomArr[i];
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir     return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM;
137cdf0e10cSrcweir };
138cdf0e10cSrcweir /* -----------------02.12.2002 09:11-----------------
139cdf0e10cSrcweir  *
140cdf0e10cSrcweir  * --------------------------------------------------*/
lcl_InvalidateZoomSlots(SfxBindings & rBindings)141cdf0e10cSrcweir void lcl_InvalidateZoomSlots(SfxBindings& rBindings)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInval[] =
144cdf0e10cSrcweir     {
145cdf0e10cSrcweir         SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM,
146cdf0e10cSrcweir         0
147cdf0e10cSrcweir     };
148cdf0e10cSrcweir     rBindings.Invalidate( aInval );
149cdf0e10cSrcweir }
150cdf0e10cSrcweir /*--------------------------------------------------------------------
151cdf0e10cSrcweir 	Beschreibung:
152cdf0e10cSrcweir  --------------------------------------------------------------------*/
153cdf0e10cSrcweir 
154cdf0e10cSrcweir // erstmal der Zoom-Dialog
155cdf0e10cSrcweir 
156cdf0e10cSrcweir class SwPreViewZoomDlg : public SvxStandardDialog
157cdf0e10cSrcweir {
158cdf0e10cSrcweir 	FixedText		aRowLbl;
159cdf0e10cSrcweir 	NumericField 	aRowEdit;
160cdf0e10cSrcweir 	FixedText		aColLbl;
161cdf0e10cSrcweir 	NumericField 	aColEdit;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	OKButton	 	aOkBtn;
164cdf0e10cSrcweir 	CancelButton 	aCancelBtn;
165cdf0e10cSrcweir 	HelpButton 		aHelpBtn;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	virtual void 	Apply();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir public:
170cdf0e10cSrcweir 	SwPreViewZoomDlg( SwPagePreViewWin& rParent );
171cdf0e10cSrcweir 	~SwPreViewZoomDlg();
172cdf0e10cSrcweir };
173cdf0e10cSrcweir 
174cdf0e10cSrcweir /*--------------------------------------------------------------------
175cdf0e10cSrcweir 	Beschreibung:
176cdf0e10cSrcweir  --------------------------------------------------------------------*/
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
SwPreViewZoomDlg(SwPagePreViewWin & rParent)179cdf0e10cSrcweir SwPreViewZoomDlg::SwPreViewZoomDlg( SwPagePreViewWin& rParent ) :
180cdf0e10cSrcweir 	SvxStandardDialog( &rParent, SW_RES(DLG_PAGEPREVIEW_ZOOM) ),
181cdf0e10cSrcweir 	aRowLbl(this,SW_RES(FT_ROW)),
182cdf0e10cSrcweir 	aRowEdit(this,SW_RES(ED_ROW)),
183cdf0e10cSrcweir 	aColLbl(this,SW_RES(FT_COL)),
184cdf0e10cSrcweir 	aColEdit(this,SW_RES(ED_COL)),
185cdf0e10cSrcweir 	aOkBtn(this,SW_RES(BT_OK)),
186cdf0e10cSrcweir 	aCancelBtn(this,SW_RES(BT_CANCEL)),
187cdf0e10cSrcweir     aHelpBtn(this,SW_RES(BT_HELP))
188cdf0e10cSrcweir {
189cdf0e10cSrcweir 	FreeResource();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	aRowEdit.SetValue( rParent.GetRow() );
192cdf0e10cSrcweir 	aColEdit.SetValue( rParent.GetCol() );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir /*--------------------------------------------------------------------
196cdf0e10cSrcweir 	Beschreibung:
197cdf0e10cSrcweir  --------------------------------------------------------------------*/
198cdf0e10cSrcweir 
~SwPreViewZoomDlg()199cdf0e10cSrcweir SwPreViewZoomDlg::~SwPreViewZoomDlg() {}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 
Apply()202cdf0e10cSrcweir void  SwPreViewZoomDlg::Apply()
203cdf0e10cSrcweir {
204cdf0e10cSrcweir 	((SwPagePreViewWin*)GetParent())->CalcWish(
205cdf0e10cSrcweir 				sal_uInt8(aRowEdit.GetValue()),
206cdf0e10cSrcweir 				sal_uInt8(aColEdit.GetValue()) );
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir /*--------------------------------------------------------------------
210cdf0e10cSrcweir 	Beschreibung:
211cdf0e10cSrcweir  --------------------------------------------------------------------*/
212cdf0e10cSrcweir 
213cdf0e10cSrcweir // alles fuers SwPagePreViewWin
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 
SwPagePreViewWin(Window * pParent,SwPagePreView & rPView)216cdf0e10cSrcweir SwPagePreViewWin::SwPagePreViewWin( Window *pParent, SwPagePreView& rPView )
217cdf0e10cSrcweir 	: Window( pParent, WinBits( WB_CLIPCHILDREN) ),
218cdf0e10cSrcweir     mpViewShell( 0 ),
219cdf0e10cSrcweir     mrView( rPView ),
220cdf0e10cSrcweir     mbCalcScaleForPreviewLayout( true ),
221cdf0e10cSrcweir     maPaintedPreviewDocRect( Rectangle(0,0,0,0) )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW ); //#106611#
224cdf0e10cSrcweir 	SetHelpId(HID_PAGEPREVIEW);
225cdf0e10cSrcweir 	SetFillColor( GetBackground().GetColor() );
226cdf0e10cSrcweir 	SetLineColor( GetBackground().GetColor());
227cdf0e10cSrcweir 	SetMapMode( MapMode(MAP_TWIP) );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(sal_False);
230cdf0e10cSrcweir     mnRow = pUsrPref->GetPagePrevRow();     // 1 Zeile
231cdf0e10cSrcweir     mnCol = pUsrPref->GetPagePrevCol();     // 1 Spalte
232cdf0e10cSrcweir     // OD 24.03.2003 #108282# - member <mnVirtPage> no longer exists.
233cdf0e10cSrcweir     mnSttPage = USHRT_MAX;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir /*--------------------------------------------------------------------
237cdf0e10cSrcweir 	Beschreibung:
238cdf0e10cSrcweir  --------------------------------------------------------------------*/
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 
~SwPagePreViewWin()241cdf0e10cSrcweir SwPagePreViewWin::~SwPagePreViewWin()
242cdf0e10cSrcweir {
243ca62e2c2SSteve Yin 	// Remove to the deconstruction of SwPagePreView.
244ca62e2c2SSteve Yin 	//if( mpViewShell)
245ca62e2c2SSteve Yin 	//	delete mpViewShell;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir /*--------------------------------------------------------------------
249cdf0e10cSrcweir 	Beschreibung:
250cdf0e10cSrcweir  --------------------------------------------------------------------*/
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 
Paint(const Rectangle & rRect)253cdf0e10cSrcweir void  SwPagePreViewWin::Paint( const Rectangle& rRect )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     if( !mpViewShell || !mpViewShell->GetLayout() )
256cdf0e10cSrcweir 		return;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     if( USHRT_MAX == mnSttPage )        // wurde noch nie berechnet ? (Init-Phase!)
259cdf0e10cSrcweir 	{
260cdf0e10cSrcweir 		// das ist die Size, auf die ich mich immer beziehe
261cdf0e10cSrcweir         if( !maPxWinSize.Height() || !maPxWinSize.Width() )
262cdf0e10cSrcweir             maPxWinSize = GetOutputSizePixel();
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 		Rectangle aRect( LogicToPixel( rRect ));
265cdf0e10cSrcweir         mpPgPrevwLayout->Prepare( 1, Point(0,0), maPxWinSize,
266cdf0e10cSrcweir                                   mnSttPage, maPaintedPreviewDocRect );
267cdf0e10cSrcweir         SetSelectedPage( 1 );
268cdf0e10cSrcweir         mpPgPrevwLayout->Paint( PixelToLogic( aRect ) );
269cdf0e10cSrcweir         SetPagePreview(mnRow, mnCol);
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 	else
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir         MapMode aMM( GetMapMode() );
274cdf0e10cSrcweir         aMM.SetScaleX( maScale );
275cdf0e10cSrcweir         aMM.SetScaleY( maScale );
276cdf0e10cSrcweir 		SetMapMode( aMM );
277cdf0e10cSrcweir         mpPgPrevwLayout->Paint( rRect );
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir /*--------------------------------------------------------------------
282cdf0e10cSrcweir 	Beschreibung:
283cdf0e10cSrcweir  --------------------------------------------------------------------*/
CalcWish(sal_uInt8 nNewRow,sal_uInt8 nNewCol)284cdf0e10cSrcweir void SwPagePreViewWin::CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir     if( !mpViewShell || !mpViewShell->GetLayout() )
287cdf0e10cSrcweir 		return;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     sal_uInt16 nOldCol = mnCol;
290cdf0e10cSrcweir     // OD 02.12.2002 #103492# - update <mnRow> and <mnCol>.
291cdf0e10cSrcweir     mnRow = nNewRow;
292cdf0e10cSrcweir     mnCol = nNewCol;
293cdf0e10cSrcweir     sal_uInt16 nPages = mnRow * mnCol,
294cdf0e10cSrcweir            nLastSttPg = mrView.GetPageCount()+1 > nPages
295cdf0e10cSrcweir                             ? mrView.GetPageCount()+1 - nPages : 0;
296cdf0e10cSrcweir     if( mnSttPage > nLastSttPg )
297cdf0e10cSrcweir         mnSttPage = nLastSttPg;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir     mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true );
300cdf0e10cSrcweir     mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
301cdf0e10cSrcweir                               mnSttPage, maPaintedPreviewDocRect );
302cdf0e10cSrcweir     SetSelectedPage( mnSttPage );
303cdf0e10cSrcweir     SetPagePreview(mnRow, mnCol);
304cdf0e10cSrcweir     maScale = GetMapMode().GetScaleX();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     // falls an der Spaltigkeit gedreht wurde, so muss der Sonderfall
307cdf0e10cSrcweir     // Einspaltig beachtet und ggfs. der Scrollbar korrigiert werden
308cdf0e10cSrcweir     if( (1 == nOldCol) ^ (1 == mnCol) )
309cdf0e10cSrcweir         mrView.ScrollDocSzChg();
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     // Sortierung muss eingehalten werden!!
312cdf0e10cSrcweir     // OD 24.03.2003 #108282# - additional invalidate page status.
313cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInval[] =
314cdf0e10cSrcweir     {
315cdf0e10cSrcweir         SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN,
316cdf0e10cSrcweir         FN_PREVIEW_ZOOM,
317cdf0e10cSrcweir         FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
318cdf0e10cSrcweir         FN_STAT_PAGE, FN_STAT_ZOOM,
319cdf0e10cSrcweir         FN_SHOW_TWO_PAGES, FN_SHOW_MULTIPLE_PAGES,
320cdf0e10cSrcweir         0
321cdf0e10cSrcweir     };
322cdf0e10cSrcweir     SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
323cdf0e10cSrcweir     rBindings.Invalidate( aInval );
324cdf0e10cSrcweir     rBindings.Update( FN_SHOW_TWO_PAGES );
325cdf0e10cSrcweir     rBindings.Update( FN_SHOW_MULTIPLE_PAGES );
326cdf0e10cSrcweir     // OD 18.12.2002 #103492# - adjust scrollbars
327cdf0e10cSrcweir     mrView.ScrollViewSzChg();
328cdf0e10cSrcweir }
329cdf0e10cSrcweir /*--------------------------------------------------------------------
330cdf0e10cSrcweir 	Beschreibung:, mnSttPage is Absolute
331cdf0e10cSrcweir  --------------------------------------------------------------------*/
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 
MovePage(int eMoveMode)334cdf0e10cSrcweir int SwPagePreViewWin::MovePage( int eMoveMode )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	// soviele Seiten hoch
337cdf0e10cSrcweir     sal_uInt16 nPages = mnRow * mnCol;
338cdf0e10cSrcweir     sal_uInt16 nNewSttPage = mnSttPage;
339cdf0e10cSrcweir     // OD 04.12.2002 #103492#
340cdf0e10cSrcweir     sal_uInt16 nPageCount = mrView.GetPageCount();
341cdf0e10cSrcweir 	sal_uInt16 nDefSttPg = GetDefSttPage();
342cdf0e10cSrcweir     // OD 06.12.2002 #103492#
343cdf0e10cSrcweir     bool bPaintPageAtFirstCol = true;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	switch( eMoveMode )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir     case MV_PAGE_UP:
348cdf0e10cSrcweir     {
349cdf0e10cSrcweir         const sal_uInt16 nRelSttPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
350cdf0e10cSrcweir         const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ?
351cdf0e10cSrcweir                                           mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) :
352cdf0e10cSrcweir                                           nDefSttPg;
353cdf0e10cSrcweir         nNewSttPage = nNewAbsSttPage;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir         const sal_uInt16 nRelSelPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
356cdf0e10cSrcweir         const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ?
357cdf0e10cSrcweir                                           nRelSelPage - nPages :
358cdf0e10cSrcweir                                           1;
359cdf0e10cSrcweir         SetSelectedPage( mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nNewRelSelPage ) );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         break;
362cdf0e10cSrcweir     }
363cdf0e10cSrcweir     case MV_PAGE_DOWN:
364cdf0e10cSrcweir     {
365cdf0e10cSrcweir         const sal_uInt16 nRelSttPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
366cdf0e10cSrcweir         const sal_uInt16 nNewAbsSttPage = mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages );
367cdf0e10cSrcweir         nNewSttPage = nNewAbsSttPage < nPageCount ? nNewAbsSttPage : nPageCount;
368cdf0e10cSrcweir 
369cdf0e10cSrcweir         const sal_uInt16 nRelSelPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
370cdf0e10cSrcweir         const sal_uInt16 nNewAbsSelPage = mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages );
371cdf0e10cSrcweir         SetSelectedPage( nNewAbsSelPage < nPageCount ? nNewAbsSelPage : nPageCount );
372cdf0e10cSrcweir 
373cdf0e10cSrcweir         break;
374cdf0e10cSrcweir     }
375cdf0e10cSrcweir     case MV_DOC_STT:
376cdf0e10cSrcweir         nNewSttPage = nDefSttPg;
377cdf0e10cSrcweir         SetSelectedPage( mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) );
378cdf0e10cSrcweir         break;
379cdf0e10cSrcweir     case MV_DOC_END:
380cdf0e10cSrcweir         // OD 03.12.2002 #103492# - correct calculation of new start page.
381cdf0e10cSrcweir         nNewSttPage = nPageCount;
382cdf0e10cSrcweir         SetSelectedPage( nPageCount );
383cdf0e10cSrcweir         break;
384cdf0e10cSrcweir     // OD 12.12.2002 #103492# - add new move mode
385cdf0e10cSrcweir     case MV_SELPAGE:
386cdf0e10cSrcweir         // <nNewSttPage> and <SelectedPage()> are already set.
387cdf0e10cSrcweir         // OD 20.02.2003 #107369# - not start at first column, only if the
388cdf0e10cSrcweir         // complete preview layout columns doesn't fit into window.
389cdf0e10cSrcweir         if ( !mpPgPrevwLayout->DoesPreviewLayoutColsFitIntoWindow() )
390cdf0e10cSrcweir             bPaintPageAtFirstCol = false;
391cdf0e10cSrcweir         break;
392cdf0e10cSrcweir     case MV_SCROLL:
393cdf0e10cSrcweir         // OD 17.01.2003 #103492# - check, if paint page at first column
394cdf0e10cSrcweir         // has to be avoided
395cdf0e10cSrcweir         if ( !mpPgPrevwLayout->DoesPreviewLayoutRowsFitIntoWindow() ||
396cdf0e10cSrcweir              !mpPgPrevwLayout->DoesPreviewLayoutColsFitIntoWindow() )
397cdf0e10cSrcweir             bPaintPageAtFirstCol = false;
398cdf0e10cSrcweir         break;
399cdf0e10cSrcweir     case MV_NEWWINSIZE:
400cdf0e10cSrcweir         // OD 18.12.2002 #103492# - nothing special to do.
401cdf0e10cSrcweir         break;
402cdf0e10cSrcweir     case MV_CALC:
403cdf0e10cSrcweir         // OD 18.12.2002 #103492# - re-init page preview layout.
404cdf0e10cSrcweir         mpPgPrevwLayout->ReInit();
405cdf0e10cSrcweir 
406cdf0e10cSrcweir         // OD 03.12.2002 #103492# - correct calculation of new start page.
407cdf0e10cSrcweir         if( nNewSttPage > nPageCount )
408cdf0e10cSrcweir             nNewSttPage = nPageCount;
409cdf0e10cSrcweir 
410cdf0e10cSrcweir         // OD 18.12.2002 #103492# - correct selected page number
411cdf0e10cSrcweir         if( SelectedPage() > nPageCount )
412cdf0e10cSrcweir             SetSelectedPage( nNewSttPage ? nNewSttPage : 1 );
413cdf0e10cSrcweir 	}
414cdf0e10cSrcweir 
415cdf0e10cSrcweir     mpPgPrevwLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize,
416cdf0e10cSrcweir                               nNewSttPage,
417cdf0e10cSrcweir                               maPaintedPreviewDocRect, bPaintPageAtFirstCol );
418cdf0e10cSrcweir     if( nNewSttPage == mnSttPage &&
419cdf0e10cSrcweir         eMoveMode != MV_SELPAGE )
420cdf0e10cSrcweir         return sal_False;
421cdf0e10cSrcweir 
422cdf0e10cSrcweir     SetPagePreview(mnRow, mnCol);
423cdf0e10cSrcweir     mnSttPage = nNewSttPage;
424cdf0e10cSrcweir 
425cdf0e10cSrcweir     // OD 24.03.2003 #108282# - additional invalidate page status.
426cdf0e10cSrcweir 	static sal_uInt16 __READONLY_DATA aInval[] =
427cdf0e10cSrcweir 	{
428cdf0e10cSrcweir         FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
429cdf0e10cSrcweir         FN_STAT_PAGE, 0
430cdf0e10cSrcweir 	};
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
433cdf0e10cSrcweir 	rBindings.Invalidate( aInval );
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	return sal_True;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir /*--------------------------------------------------------------------
439cdf0e10cSrcweir 	Beschreibung:
440cdf0e10cSrcweir  --------------------------------------------------------------------*/
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 
SetWinSize(const Size & rNewSize)443cdf0e10cSrcweir void SwPagePreViewWin::SetWinSize( const Size& rNewSize )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	// die Size wollen wir aber immer in Pixel-Einheiten haben
446cdf0e10cSrcweir     maPxWinSize = LogicToPixel( rNewSize );
447cdf0e10cSrcweir 
448cdf0e10cSrcweir     if( USHRT_MAX == mnSttPage )
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir         mnSttPage = GetDefSttPage();
451cdf0e10cSrcweir         SetSelectedPage( GetDefSttPage() );
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir     if ( mbCalcScaleForPreviewLayout )
455cdf0e10cSrcweir     {
456cdf0e10cSrcweir         mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true );
457cdf0e10cSrcweir         maScale = GetMapMode().GetScaleX();
458cdf0e10cSrcweir     }
459cdf0e10cSrcweir     mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
460cdf0e10cSrcweir                               mnSttPage, maPaintedPreviewDocRect );
461cdf0e10cSrcweir     if ( mbCalcScaleForPreviewLayout )
462cdf0e10cSrcweir     {
463cdf0e10cSrcweir         SetSelectedPage( mnSttPage );
464cdf0e10cSrcweir         mbCalcScaleForPreviewLayout = false;
465cdf0e10cSrcweir     }
466cdf0e10cSrcweir     SetPagePreview(mnRow, mnCol);
467cdf0e10cSrcweir     maScale = GetMapMode().GetScaleX();
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 
471cdf0e10cSrcweir /*--------------------------------------------------------------------
472cdf0e10cSrcweir 	Beschreibung:
473cdf0e10cSrcweir  --------------------------------------------------------------------*/
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 
GetStatusStr(String & rStr,sal_uInt16 nPageCnt) const476cdf0e10cSrcweir void SwPagePreViewWin::GetStatusStr( String& rStr, sal_uInt16 nPageCnt ) const
477cdf0e10cSrcweir {
478cdf0e10cSrcweir     // OD 24.03.2003 #108282# - show physical and virtual page number of
479cdf0e10cSrcweir     // selected page, if it's visible.
480cdf0e10cSrcweir     sal_uInt16 nPageNum;
481cdf0e10cSrcweir     if ( mpPgPrevwLayout->IsPageVisible( mpPgPrevwLayout->SelectedPage() ) )
482cdf0e10cSrcweir     {
483cdf0e10cSrcweir         nPageNum = mpPgPrevwLayout->SelectedPage();
484cdf0e10cSrcweir     }
485cdf0e10cSrcweir     else
486cdf0e10cSrcweir     {
487cdf0e10cSrcweir         nPageNum = mnSttPage > 1 ? mnSttPage : 1;
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir     sal_uInt16 nVirtPageNum = mpPgPrevwLayout->GetVirtPageNumByPageNum( nPageNum );
490cdf0e10cSrcweir     if( nVirtPageNum && nVirtPageNum != nPageNum )
491cdf0e10cSrcweir 	{
492cdf0e10cSrcweir         rStr += String::CreateFromInt32( nVirtPageNum );
493cdf0e10cSrcweir 		rStr += ' ';
494cdf0e10cSrcweir 	}
495cdf0e10cSrcweir     rStr += String::CreateFromInt32( nPageNum );
496cdf0e10cSrcweir 	rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
497cdf0e10cSrcweir 	rStr += String::CreateFromInt32( nPageCnt );
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
500cdf0e10cSrcweir /*--------------------------------------------------------------------
501cdf0e10cSrcweir 	Beschreibung:
502cdf0e10cSrcweir  --------------------------------------------------------------------*/
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)505cdf0e10cSrcweir void  SwPagePreViewWin::KeyInput( const KeyEvent &rKEvt )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
508cdf0e10cSrcweir     sal_uInt16 nKey = rKeyCode.GetCode();
509cdf0e10cSrcweir     sal_Bool bHandled = sal_False;
510cdf0e10cSrcweir     if(!rKeyCode.GetModifier())
511cdf0e10cSrcweir     {
512cdf0e10cSrcweir         sal_uInt16 nSlot = 0;
513cdf0e10cSrcweir         switch(nKey)
514cdf0e10cSrcweir         {
515cdf0e10cSrcweir             case KEY_ADD : nSlot = SID_ZOOM_OUT;         break;
516cdf0e10cSrcweir             case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break;
517cdf0e10cSrcweir             case KEY_SUBTRACT : nSlot = SID_ZOOM_IN;    break;
518cdf0e10cSrcweir         }
519cdf0e10cSrcweir         if(nSlot)
520cdf0e10cSrcweir         {
521cdf0e10cSrcweir             bHandled = sal_True;
522cdf0e10cSrcweir             mrView.GetViewFrame()->GetDispatcher()->Execute(
523cdf0e10cSrcweir                                 nSlot, SFX_CALLMODE_ASYNCHRON );
524cdf0e10cSrcweir         }
525cdf0e10cSrcweir     }
526cdf0e10cSrcweir     if( !bHandled && !mrView.KeyInput( rKEvt ) )
527cdf0e10cSrcweir 		Window::KeyInput( rKEvt );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir /******************************************************************************
531cdf0e10cSrcweir  *	Beschreibung:
532cdf0e10cSrcweir  ******************************************************************************/
533cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)534cdf0e10cSrcweir void SwPagePreViewWin::Command( const CommandEvent& rCEvt )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	sal_Bool bCallBase = sal_True;
537cdf0e10cSrcweir 	switch( rCEvt.GetCommand() )
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir         case COMMAND_CONTEXTMENU:
540cdf0e10cSrcweir             mrView.GetViewFrame()->GetDispatcher()->ExecutePopup();
541cdf0e10cSrcweir             bCallBase = sal_False;
542cdf0e10cSrcweir         break;
543cdf0e10cSrcweir 
544cdf0e10cSrcweir         case COMMAND_WHEEL:
545cdf0e10cSrcweir         case COMMAND_STARTAUTOSCROLL:
546cdf0e10cSrcweir         case COMMAND_AUTOSCROLL:
547cdf0e10cSrcweir         {
548cdf0e10cSrcweir             const CommandWheelData* pData = rCEvt.GetWheelData();
549cdf0e10cSrcweir             if( pData )
550cdf0e10cSrcweir             {
551cdf0e10cSrcweir                 const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL,
552cdf0e10cSrcweir                     pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel());
553cdf0e10cSrcweir                 const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew);
554cdf0e10cSrcweir                     bCallBase = !mrView.HandleWheelCommands( aEvent );
555cdf0e10cSrcweir             }
556cdf0e10cSrcweir             else
557cdf0e10cSrcweir                 bCallBase = !mrView.HandleWheelCommands( rCEvt );
558cdf0e10cSrcweir        }
559cdf0e10cSrcweir        break;
560cdf0e10cSrcweir        default:
561cdf0e10cSrcweir            // OD 17.12.2002 #103492# - delete assertion
562cdf0e10cSrcweir            ;
563cdf0e10cSrcweir 	}
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 	if( bCallBase )
566cdf0e10cSrcweir 		Window::Command( rCEvt );
567cdf0e10cSrcweir }
568cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)569cdf0e10cSrcweir void SwPagePreViewWin::MouseButtonDown( const MouseEvent& rMEvt )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir     // OD 17.12.2002 #103492# - consider single-click to set selected page
572cdf0e10cSrcweir     if( MOUSE_LEFT == ( rMEvt.GetModifier() + rMEvt.GetButtons() ) )
573cdf0e10cSrcweir 	{
574cdf0e10cSrcweir         Point aPrevwPos( PixelToLogic( rMEvt.GetPosPixel() ) );
575cdf0e10cSrcweir         Point aDocPos;
576cdf0e10cSrcweir         bool bPosInEmptyPage;
577cdf0e10cSrcweir         sal_uInt16 nNewSelectedPage;
578cdf0e10cSrcweir         bool bIsDocPos =
579cdf0e10cSrcweir             mpPgPrevwLayout->IsPrevwPosInDocPrevwPage( aPrevwPos,
580cdf0e10cSrcweir                                     aDocPos, bPosInEmptyPage, nNewSelectedPage );
581cdf0e10cSrcweir         if ( bIsDocPos && rMEvt.GetClicks() == 2 )
582cdf0e10cSrcweir         {
583cdf0e10cSrcweir             // close page preview, set new cursor position and switch to
584cdf0e10cSrcweir             // normal view.
585cdf0e10cSrcweir             String sNewCrsrPos( String::CreateFromInt32( aDocPos.X() ));
586cdf0e10cSrcweir             ((( sNewCrsrPos += ';' )
587cdf0e10cSrcweir                             += String::CreateFromInt32( aDocPos.Y() )) )
588cdf0e10cSrcweir                             += ';';
589cdf0e10cSrcweir             mrView.SetNewCrsrPos( sNewCrsrPos );
590cdf0e10cSrcweir 
591cdf0e10cSrcweir             SfxViewFrame *pTmpFrm = mrView.GetViewFrame();
592cdf0e10cSrcweir             pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
593cdf0e10cSrcweir                                                     SFX_CALLMODE_ASYNCHRON );
594cdf0e10cSrcweir         }
595cdf0e10cSrcweir         else if ( bIsDocPos || bPosInEmptyPage )
596cdf0e10cSrcweir         // OD 2004-03-04 #i20684# - add missing parenthesis
597cdf0e10cSrcweir         {
598cdf0e10cSrcweir             // show clicked page as the selected one
599cdf0e10cSrcweir             mpPgPrevwLayout->MarkNewSelectedPage( nNewSelectedPage );
600cdf0e10cSrcweir             GetViewShell()->ShowPreViewSelection( nNewSelectedPage );
601cdf0e10cSrcweir             // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
602cdf0e10cSrcweir             if ( mpPgPrevwLayout->DoesPreviewLayoutRowsFitIntoWindow() )
603cdf0e10cSrcweir             {
604cdf0e10cSrcweir                 mrView.SetVScrollbarThumbPos( nNewSelectedPage );
605cdf0e10cSrcweir             }
606cdf0e10cSrcweir             // OD 24.03.2003 #108282# - invalidate page status.
607cdf0e10cSrcweir             static sal_uInt16 __READONLY_DATA aInval[] =
608cdf0e10cSrcweir             {
609cdf0e10cSrcweir                 FN_STAT_PAGE, 0
610cdf0e10cSrcweir             };
611cdf0e10cSrcweir             SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
612cdf0e10cSrcweir             rBindings.Invalidate( aInval );
613cdf0e10cSrcweir         }
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir /******************************************************************************
618cdf0e10cSrcweir  *	Beschreibung: Userprefs bzw Viewoptions setzen
619cdf0e10cSrcweir  ******************************************************************************/
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 
SetPagePreview(sal_uInt8 nRow,sal_uInt8 nCol)622cdf0e10cSrcweir void SwPagePreViewWin::SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir 	SwMasterUsrPref *pOpt = (SwMasterUsrPref *)SW_MOD()->GetUsrPref(sal_False);
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 	if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol())
627cdf0e10cSrcweir 	{
628cdf0e10cSrcweir 		pOpt->SetPagePrevRow( nRow );
629cdf0e10cSrcweir 		pOpt->SetPagePrevCol( nCol );
630cdf0e10cSrcweir 		pOpt->SetModified();
631cdf0e10cSrcweir 
632cdf0e10cSrcweir         //Scrollbar updaten!
633cdf0e10cSrcweir         mrView.ScrollViewSzChg();
634cdf0e10cSrcweir 	}
635cdf0e10cSrcweir }
636cdf0e10cSrcweir 
637cdf0e10cSrcweir /** get selected page in document preview
638cdf0e10cSrcweir 
639cdf0e10cSrcweir     OD 13.12.2002 #103492#
640cdf0e10cSrcweir 
641cdf0e10cSrcweir     @author OD
642cdf0e10cSrcweir */
SelectedPage() const643cdf0e10cSrcweir sal_uInt16 SwPagePreViewWin::SelectedPage() const
644cdf0e10cSrcweir {
645cdf0e10cSrcweir     return mpPgPrevwLayout->SelectedPage();
646cdf0e10cSrcweir }
647cdf0e10cSrcweir 
648cdf0e10cSrcweir /** set selected page number in document preview
649cdf0e10cSrcweir 
650cdf0e10cSrcweir     OD 13.12.2002 #103492#
651cdf0e10cSrcweir 
652cdf0e10cSrcweir     @author OD
653cdf0e10cSrcweir */
SetSelectedPage(sal_uInt16 _nSelectedPageNum)654cdf0e10cSrcweir void SwPagePreViewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir     mpPgPrevwLayout->SetSelectedPage( _nSelectedPageNum );
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir /** method to enable/disable book preview
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     OD 2004-03-05 #i18143#
662cdf0e10cSrcweir 
663cdf0e10cSrcweir     @author OD
664cdf0e10cSrcweir */
SetBookPreviewMode(const bool _bBookPreview)665cdf0e10cSrcweir bool SwPagePreViewWin::SetBookPreviewMode( const bool _bBookPreview )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir     return mpPgPrevwLayout->SetBookPreviewMode( _bBookPreview,
668cdf0e10cSrcweir                                                 mnSttPage,
669cdf0e10cSrcweir                                                 maPaintedPreviewDocRect );
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)672cdf0e10cSrcweir void SwPagePreViewWin::DataChanged( const DataChangedEvent& rDCEvt )
673cdf0e10cSrcweir {
674cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 	switch( rDCEvt.GetType() )
677cdf0e10cSrcweir 	{
678cdf0e10cSrcweir 	case DATACHANGED_SETTINGS:
679cdf0e10cSrcweir 		// ScrollBars neu anordnen bzw. Resize ausloesen, da sich
680cdf0e10cSrcweir 		// ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
681cdf0e10cSrcweir 		// Resize-Handler aber auch die Groesse der ScrollBars aus
682cdf0e10cSrcweir 		// den Settings abgefragt werden.
683cdf0e10cSrcweir 		if( rDCEvt.GetFlags() & SETTINGS_STYLE )
684cdf0e10cSrcweir             mrView.InvalidateBorder();              //Scrollbarbreiten
685cdf0e10cSrcweir         //#106746# zoom has to be disabled if Accessibility support is switched on
686cdf0e10cSrcweir         lcl_InvalidateZoomSlots(mrView.GetViewFrame()->GetBindings());
687cdf0e10cSrcweir         break;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 	case DATACHANGED_PRINTER:
690cdf0e10cSrcweir 	case DATACHANGED_DISPLAY:
691cdf0e10cSrcweir 	case DATACHANGED_FONTS:
692cdf0e10cSrcweir 	case DATACHANGED_FONTSUBSTITUTION:
693cdf0e10cSrcweir         mrView.GetDocShell()->UpdateFontList(); //Fontwechsel
694cdf0e10cSrcweir         if ( mpViewShell->GetWin() )
695cdf0e10cSrcweir             mpViewShell->GetWin()->Invalidate();
696cdf0e10cSrcweir 		break;
697cdf0e10cSrcweir 	}
698cdf0e10cSrcweir }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir /** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN
701cdf0e10cSrcweir 
702cdf0e10cSrcweir     OD 04.03.2003 #107369#
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     @author OD
705cdf0e10cSrcweir */
_ExecPgUpAndPgDown(const bool _bPgUp,SfxRequest * _pReq)706cdf0e10cSrcweir void SwPagePreView::_ExecPgUpAndPgDown( const bool  _bPgUp,
707cdf0e10cSrcweir                                         SfxRequest* _pReq )
708cdf0e10cSrcweir {
709cdf0e10cSrcweir     SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
710cdf0e10cSrcweir     // check, if top/bottom of preview is *not* already visible.
711cdf0e10cSrcweir     if( pPagePrevwLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 )
712cdf0e10cSrcweir     {
713cdf0e10cSrcweir         if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() &&
714cdf0e10cSrcweir              pPagePrevwLay->DoesPreviewLayoutColsFitIntoWindow() )
715cdf0e10cSrcweir         {
716cdf0e10cSrcweir             const int eMvMode = _bPgUp ?
717cdf0e10cSrcweir                                 SwPagePreViewWin::MV_PAGE_UP :
718cdf0e10cSrcweir                                 SwPagePreViewWin::MV_PAGE_DOWN;
719cdf0e10cSrcweir             if ( ChgPage( eMvMode, sal_True ) )
720ca62e2c2SSteve Yin                 pViewWin->Invalidate();
721cdf0e10cSrcweir         }
722cdf0e10cSrcweir         else
723cdf0e10cSrcweir         {
724cdf0e10cSrcweir             SwTwips nScrollAmount;
725cdf0e10cSrcweir             sal_uInt16 nNewSelectedPageNum = 0;
726ca62e2c2SSteve Yin             const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
727cdf0e10cSrcweir             if( _bPgUp )
728cdf0e10cSrcweir             {
729cdf0e10cSrcweir                 if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() )
730cdf0e10cSrcweir                 {
731cdf0e10cSrcweir                     nScrollAmount = pPagePrevwLay->GetWinPagesScrollAmount( -1 );
732ca62e2c2SSteve Yin                     if ( (pViewWin->SelectedPage() - nVisPages) > 0 )
733ca62e2c2SSteve Yin                         nNewSelectedPageNum = pViewWin->SelectedPage() - nVisPages;
734cdf0e10cSrcweir                     else
735cdf0e10cSrcweir                         nNewSelectedPageNum = 1;
736cdf0e10cSrcweir                 }
737cdf0e10cSrcweir                 else
738ca62e2c2SSteve Yin                     nScrollAmount = - Min( pViewWin->GetOutputSize().Height(),
739ca62e2c2SSteve Yin                                            pViewWin->GetPaintedPreviewDocRect().Top() );
740cdf0e10cSrcweir             }
741cdf0e10cSrcweir             else
742cdf0e10cSrcweir             {
743cdf0e10cSrcweir                 if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() )
744cdf0e10cSrcweir                 {
745cdf0e10cSrcweir                     nScrollAmount = pPagePrevwLay->GetWinPagesScrollAmount( 1 );
746ca62e2c2SSteve Yin                     if ( (pViewWin->SelectedPage() + nVisPages) <= mnPageCount )
747ca62e2c2SSteve Yin                         nNewSelectedPageNum = pViewWin->SelectedPage() + nVisPages;
748cdf0e10cSrcweir                     else
749cdf0e10cSrcweir                         nNewSelectedPageNum = mnPageCount;
750cdf0e10cSrcweir                 }
751cdf0e10cSrcweir                 else
752ca62e2c2SSteve Yin                     nScrollAmount = Min( pViewWin->GetOutputSize().Height(),
753cdf0e10cSrcweir                                          ( pPagePrevwLay->GetPrevwDocSize().Height() -
754ca62e2c2SSteve Yin                                            pViewWin->GetPaintedPreviewDocRect().Bottom() ) );
755cdf0e10cSrcweir             }
756ca62e2c2SSteve Yin             pViewWin->Scroll( 0, nScrollAmount );
757cdf0e10cSrcweir             if ( nNewSelectedPageNum != 0 )
758cdf0e10cSrcweir             {
759ca62e2c2SSteve Yin                 pViewWin->SetSelectedPage( nNewSelectedPageNum );
760cdf0e10cSrcweir             }
761cdf0e10cSrcweir             ScrollViewSzChg();
762cdf0e10cSrcweir 			// OD 24.03.2003 #108282# - additional invalidate page status.
763cdf0e10cSrcweir             static sal_uInt16 __READONLY_DATA aInval[] =
764cdf0e10cSrcweir             {
765cdf0e10cSrcweir                 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
766cdf0e10cSrcweir 				FN_STAT_PAGE, 0
767cdf0e10cSrcweir             };
768cdf0e10cSrcweir             SfxBindings& rBindings = GetViewFrame()->GetBindings();
769cdf0e10cSrcweir             rBindings.Invalidate( aInval );
770ca62e2c2SSteve Yin             pViewWin->Invalidate();
771cdf0e10cSrcweir         }
772cdf0e10cSrcweir     }
773cdf0e10cSrcweir 
774cdf0e10cSrcweir     if ( _pReq )
775cdf0e10cSrcweir         _pReq->Done();
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir /*--------------------------------------------------------------------
779cdf0e10cSrcweir 	Beschreibung:
780cdf0e10cSrcweir  --------------------------------------------------------------------*/
781cdf0e10cSrcweir // dann mal alles fuer die SwPagePreView
Execute(SfxRequest & rReq)782cdf0e10cSrcweir void  SwPagePreView::Execute( SfxRequest &rReq )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir     int eMvMode;
785cdf0e10cSrcweir 	sal_uInt8 nRow = 1;
786cdf0e10cSrcweir     sal_Bool bRetVal = sal_False;
787cdf0e10cSrcweir     bool bRefresh = true;
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 	switch(rReq.GetSlot())
790cdf0e10cSrcweir 	{
791cdf0e10cSrcweir 		case FN_REFRESH_VIEW:
792cdf0e10cSrcweir 		case FN_STAT_PAGE:
793cdf0e10cSrcweir 		case FN_STAT_ZOOM:
794cdf0e10cSrcweir 			break;
795cdf0e10cSrcweir 
796cdf0e10cSrcweir         case FN_SHOW_MULTIPLE_PAGES:
797cdf0e10cSrcweir         {
798cdf0e10cSrcweir             const SfxItemSet *pArgs = rReq.GetArgs();
799cdf0e10cSrcweir             if( pArgs && pArgs->Count() >= 2 )
800cdf0e10cSrcweir             {
801cdf0e10cSrcweir                 sal_uInt8 nCols = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(
802cdf0e10cSrcweir                                         SID_ATTR_TABLE_COLUMN)).GetValue();
803cdf0e10cSrcweir                 sal_uInt8 nRows = (sal_uInt8)((SfxUInt16Item &)pArgs->Get(
804cdf0e10cSrcweir                                         SID_ATTR_TABLE_ROW)).GetValue();
805ca62e2c2SSteve Yin                 pViewWin->CalcWish( nRows, nCols );
806cdf0e10cSrcweir 
807cdf0e10cSrcweir             }
808cdf0e10cSrcweir             else
809ca62e2c2SSteve Yin                 SwPreViewZoomDlg( *pViewWin ).Execute();
810cdf0e10cSrcweir 
811cdf0e10cSrcweir         }
812cdf0e10cSrcweir 		break;
813cdf0e10cSrcweir 		case FN_SHOW_BOOKVIEW:
814cdf0e10cSrcweir 		{
815cdf0e10cSrcweir             const SfxItemSet* pArgs = rReq.GetArgs();
816cdf0e10cSrcweir             const SfxPoolItem* pItem;
817cdf0e10cSrcweir             bool bBookPreview = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
818cdf0e10cSrcweir             if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_SHOW_BOOKVIEW, sal_False, &pItem ) )
819cdf0e10cSrcweir             {
820cdf0e10cSrcweir                 bBookPreview = static_cast< const SfxBoolItem* >( pItem )->GetValue();
821cdf0e10cSrcweir                 ( ( SwViewOption* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview );
822cdf0e10cSrcweir 					// cast is not gentleman like, but it's common use in writer and in this case
823cdf0e10cSrcweir             }
824ca62e2c2SSteve Yin             if ( pViewWin->SetBookPreviewMode( bBookPreview ) )
825cdf0e10cSrcweir             {
826cdf0e10cSrcweir                 // book preview mode changed. Thus, adjust scrollbars and
827cdf0e10cSrcweir                 // invalidate corresponding states.
828cdf0e10cSrcweir                 ScrollViewSzChg();
829cdf0e10cSrcweir                 static sal_uInt16 __READONLY_DATA aInval[] =
830cdf0e10cSrcweir                 {
831cdf0e10cSrcweir                     FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
832cdf0e10cSrcweir                     FN_STAT_PAGE, FN_SHOW_BOOKVIEW, 0
833cdf0e10cSrcweir                 };
834cdf0e10cSrcweir                 SfxBindings& rBindings = GetViewFrame()->GetBindings();
835cdf0e10cSrcweir                 rBindings.Invalidate( aInval );
836ca62e2c2SSteve Yin                 pViewWin->Invalidate();
837cdf0e10cSrcweir             }
838cdf0e10cSrcweir 
839cdf0e10cSrcweir         }
840cdf0e10cSrcweir 		break;
841cdf0e10cSrcweir         case FN_SHOW_TWO_PAGES:
842ca62e2c2SSteve Yin 			pViewWin->CalcWish( nRow, 2 );
843cdf0e10cSrcweir 			break;
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 		case FN_PREVIEW_ZOOM:
846cdf0e10cSrcweir 		case SID_ATTR_ZOOM:
847cdf0e10cSrcweir 		{
848cdf0e10cSrcweir 			const SfxItemSet *pArgs = rReq.GetArgs();
849cdf0e10cSrcweir             const SfxPoolItem* pItem;
850cdf0e10cSrcweir 			AbstractSvxZoomDialog *pDlg = 0;
851cdf0e10cSrcweir             if(!pArgs)
852cdf0e10cSrcweir             {
853cdf0e10cSrcweir                 SfxItemSet aCoreSet(GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM);
854cdf0e10cSrcweir                 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
855cdf0e10cSrcweir                 SvxZoomItem aZoom( (SvxZoomType)pVOpt->GetZoomType(),
856cdf0e10cSrcweir                                             pVOpt->GetZoom() );
857cdf0e10cSrcweir                 aZoom.SetValueSet(
858cdf0e10cSrcweir                         SVX_ZOOM_ENABLE_50|
859cdf0e10cSrcweir                         SVX_ZOOM_ENABLE_75|
860cdf0e10cSrcweir                         SVX_ZOOM_ENABLE_100|
861cdf0e10cSrcweir                         SVX_ZOOM_ENABLE_150|
862cdf0e10cSrcweir                         SVX_ZOOM_ENABLE_200|
863cdf0e10cSrcweir                         SVX_ZOOM_ENABLE_WHOLEPAGE);
864cdf0e10cSrcweir                 aCoreSet.Put( aZoom );
865cdf0e10cSrcweir 
866cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
867cdf0e10cSrcweir 				if(pFact)
868cdf0e10cSrcweir 				{
869cdf0e10cSrcweir                     pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
870cdf0e10cSrcweir                     DBG_ASSERT(pDlg, "Dialogdiet fail!");
871cdf0e10cSrcweir 				}
872cdf0e10cSrcweir 
873cdf0e10cSrcweir                 pDlg->SetLimits( MINZOOM, MAXZOOM );
874cdf0e10cSrcweir 
875cdf0e10cSrcweir                 if( pDlg->Execute() != RET_CANCEL )
876cdf0e10cSrcweir                     pArgs = pDlg->GetOutputItemSet();
877cdf0e10cSrcweir             }
878cdf0e10cSrcweir             if( pArgs )
879cdf0e10cSrcweir             {
880cdf0e10cSrcweir                 enum SvxZoomType eType = SVX_ZOOM_PERCENT;
881cdf0e10cSrcweir                 sal_uInt16 nZoomFactor = USHRT_MAX;
882cdf0e10cSrcweir                 if(SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOM, sal_True, &pItem))
883cdf0e10cSrcweir                 {
884cdf0e10cSrcweir                     eType = ((const SvxZoomItem *)pItem)->GetType();
885cdf0e10cSrcweir                     nZoomFactor = ((const SvxZoomItem *)pItem)->GetValue();
886cdf0e10cSrcweir                 }
887cdf0e10cSrcweir                 else if(SFX_ITEM_SET == pArgs->GetItemState(FN_PREVIEW_ZOOM, sal_True, &pItem))
888cdf0e10cSrcweir                     nZoomFactor = ((const SfxUInt16Item *)pItem)->GetValue();
889cdf0e10cSrcweir                 if(USHRT_MAX != nZoomFactor)
890cdf0e10cSrcweir                     SetZoom(eType, nZoomFactor);
891cdf0e10cSrcweir             }
892cdf0e10cSrcweir 			delete pDlg;
893cdf0e10cSrcweir         }
894cdf0e10cSrcweir 		break;
895cdf0e10cSrcweir         case SID_ATTR_ZOOMSLIDER :
896cdf0e10cSrcweir         {
897cdf0e10cSrcweir             const SfxItemSet *pArgs = rReq.GetArgs();
898cdf0e10cSrcweir             const SfxPoolItem* pItem;
899cdf0e10cSrcweir 
900cdf0e10cSrcweir             if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem ) )
901cdf0e10cSrcweir             {
902cdf0e10cSrcweir                 const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
903cdf0e10cSrcweir                 SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
904cdf0e10cSrcweir             }
905cdf0e10cSrcweir         }
906cdf0e10cSrcweir         break;
907cdf0e10cSrcweir         case SID_ZOOM_IN:
908cdf0e10cSrcweir         case SID_ZOOM_OUT:
909cdf0e10cSrcweir         {
910cdf0e10cSrcweir             enum SvxZoomType eType = SVX_ZOOM_PERCENT;
911cdf0e10cSrcweir             const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
912cdf0e10cSrcweir             SetZoom(eType,
913cdf0e10cSrcweir                     lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot()));
914cdf0e10cSrcweir         }
915cdf0e10cSrcweir         break;
916cdf0e10cSrcweir         case FN_CHAR_LEFT:
917cdf0e10cSrcweir         case FN_CHAR_RIGHT:
918cdf0e10cSrcweir         case FN_LINE_UP:
919cdf0e10cSrcweir         case FN_LINE_DOWN:
920cdf0e10cSrcweir         {
921cdf0e10cSrcweir             SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
922cdf0e10cSrcweir             sal_uInt16 nNewSelectedPage;
923cdf0e10cSrcweir             sal_uInt16 nNewStartPage;
924cdf0e10cSrcweir             Point aNewStartPos;
925cdf0e10cSrcweir             sal_Int16 nHoriMove = 0;
926cdf0e10cSrcweir             sal_Int16 nVertMove = 0;
927cdf0e10cSrcweir             switch(rReq.GetSlot())
928cdf0e10cSrcweir             {
929cdf0e10cSrcweir                 case FN_CHAR_LEFT:  nHoriMove = -1; break;
930cdf0e10cSrcweir                 case FN_CHAR_RIGHT: nHoriMove = 1;  break;
931cdf0e10cSrcweir                 case FN_LINE_UP:    nVertMove = -1; break;
932cdf0e10cSrcweir                 case FN_LINE_DOWN:  nVertMove = 1;  break;
933cdf0e10cSrcweir             }
934cdf0e10cSrcweir             pPagePrevwLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove,
935cdf0e10cSrcweir                                 nNewSelectedPage, nNewStartPage, aNewStartPos );
936ca62e2c2SSteve Yin             if ( pViewWin->SelectedPage() != nNewSelectedPage )
937cdf0e10cSrcweir             {
938cdf0e10cSrcweir                 if ( pPagePrevwLay->IsPageVisible( nNewSelectedPage ) )
939cdf0e10cSrcweir                 {
940cdf0e10cSrcweir                     pPagePrevwLay->MarkNewSelectedPage( nNewSelectedPage );
941cdf0e10cSrcweir                     // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
942cdf0e10cSrcweir                     SetVScrollbarThumbPos( nNewSelectedPage );
943cdf0e10cSrcweir                     bRefresh = false;
944cdf0e10cSrcweir                 }
945cdf0e10cSrcweir                 else
946cdf0e10cSrcweir                 {
947ca62e2c2SSteve Yin                     pViewWin->SetSelectedPage( nNewSelectedPage );
948ca62e2c2SSteve Yin                     pViewWin->SetSttPage( nNewStartPage );
949cdf0e10cSrcweir                     int nRet = ChgPage( SwPagePreViewWin::MV_SELPAGE, sal_True );
950cdf0e10cSrcweir                     bRefresh = 0 != nRet;
951cdf0e10cSrcweir                 }
952cdf0e10cSrcweir                 GetViewShell()->ShowPreViewSelection( nNewSelectedPage );
953cdf0e10cSrcweir                 // OD 24.03.2003 #108282# - invalidate page status.
954cdf0e10cSrcweir                 static sal_uInt16 __READONLY_DATA aInval[] =
955cdf0e10cSrcweir                 {
956cdf0e10cSrcweir                     FN_STAT_PAGE, 0
957cdf0e10cSrcweir                 };
958cdf0e10cSrcweir                 SfxBindings& rBindings = GetViewFrame()->GetBindings();
959cdf0e10cSrcweir                 rBindings.Invalidate( aInval );
960cdf0e10cSrcweir                 rReq.Done();
961cdf0e10cSrcweir             }
962cdf0e10cSrcweir 			else
963cdf0e10cSrcweir 			{
964cdf0e10cSrcweir 				bRefresh = false;
965cdf0e10cSrcweir 			}
966cdf0e10cSrcweir             break;
967cdf0e10cSrcweir         }
968cdf0e10cSrcweir 		case FN_PAGEUP:
969cdf0e10cSrcweir         case FN_PAGEDOWN:
970cdf0e10cSrcweir         {
971cdf0e10cSrcweir             _ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq );
972cdf0e10cSrcweir             break;
973cdf0e10cSrcweir         }
974cdf0e10cSrcweir         case FN_START_OF_LINE:
975cdf0e10cSrcweir         case FN_START_OF_DOCUMENT:
976ca62e2c2SSteve Yin             pViewWin->SetSelectedPage( 1 );
977cdf0e10cSrcweir 			eMvMode = SwPagePreViewWin::MV_DOC_STT;	bRetVal = sal_True;	goto MOVEPAGE;
978cdf0e10cSrcweir         case FN_END_OF_LINE:
979cdf0e10cSrcweir         case FN_END_OF_DOCUMENT:
980ca62e2c2SSteve Yin             pViewWin->SetSelectedPage( mnPageCount );
981cdf0e10cSrcweir             eMvMode = SwPagePreViewWin::MV_DOC_END; bRetVal = sal_True; goto MOVEPAGE;
982cdf0e10cSrcweir MOVEPAGE:
983cdf0e10cSrcweir 			{
984cdf0e10cSrcweir 				int nRet = ChgPage( eMvMode, sal_True );
985cdf0e10cSrcweir 				// return value fuer Basic
986cdf0e10cSrcweir 				if(bRetVal)
987cdf0e10cSrcweir 					rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), nRet == 0));
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 				bRefresh = 0 != nRet;
990cdf0e10cSrcweir 				rReq.Done();
991cdf0e10cSrcweir 			}
992cdf0e10cSrcweir 			break;
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 		case FN_PRINT_PAGEPREVIEW:
995cdf0e10cSrcweir 		{
996ca62e2c2SSteve Yin 			const SwPagePreViewPrtData* pPPVPD = pViewWin->GetViewShell()->GetDoc()->GetPreViewPrtData();
997cdf0e10cSrcweir 			// die Sache mit der Orientation
998cdf0e10cSrcweir 			if(pPPVPD)
999cdf0e10cSrcweir 			{
1000cdf0e10cSrcweir 				SfxPrinter* pPrinter = GetPrinter( sal_True );
1001cdf0e10cSrcweir 				if((pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE)
1002cdf0e10cSrcweir 						!= pPPVPD->GetLandscape())
1003cdf0e10cSrcweir 					pPrinter->SetOrientation(pPPVPD->GetLandscape() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
1004cdf0e10cSrcweir 			}
1005ca62e2c2SSteve Yin 			::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False );
1006cdf0e10cSrcweir 			bNormalPrint = sal_False;
1007cdf0e10cSrcweir 			sal_uInt16 nPrtSlot = SID_PRINTDOC;
1008cdf0e10cSrcweir 			rReq.SetSlot( nPrtSlot );
1009cdf0e10cSrcweir 			SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
1010cdf0e10cSrcweir 			rReq.SetSlot( FN_PRINT_PAGEPREVIEW );
1011cdf0e10cSrcweir 			return;
1012cdf0e10cSrcweir 		}
1013cdf0e10cSrcweir 		case SID_PRINTDOCDIRECT:
1014cdf0e10cSrcweir 		case SID_PRINTDOC:
1015ca62e2c2SSteve Yin 			::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False );
1016cdf0e10cSrcweir 			bNormalPrint = sal_True;
1017cdf0e10cSrcweir 			SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
1018cdf0e10cSrcweir 			return;
1019cdf0e10cSrcweir         case FN_CLOSE_PAGEPREVIEW:
1020cdf0e10cSrcweir         case SID_PRINTPREVIEW:
1021cdf0e10cSrcweir 			//	print preview is now always in the same frame as the tab view
1022cdf0e10cSrcweir 			//	-> always switch this frame back to normal view
1023cdf0e10cSrcweir 			//	(ScTabViewShell ctor reads stored view data)
1024cdf0e10cSrcweir             GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, 0, 0, SFX_CALLMODE_ASYNCHRON );
1025cdf0e10cSrcweir 			break;
1026cdf0e10cSrcweir         case FN_INSERT_BREAK:
1027cdf0e10cSrcweir         {
1028ca62e2c2SSteve Yin             sal_uInt16 nSelPage = pViewWin->SelectedPage();
1029cdf0e10cSrcweir             //if a dummy page is selected (e.g. a non-existing right/left page)
1030cdf0e10cSrcweir             //the direct neighbor is used
1031cdf0e10cSrcweir             if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
1032cdf0e10cSrcweir                 nSelPage +=2;
1033cdf0e10cSrcweir             SetNewPage( nSelPage );
1034cdf0e10cSrcweir             SfxViewFrame *pTmpFrm = GetViewFrame();
1035cdf0e10cSrcweir 			pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
1036cdf0e10cSrcweir 													SFX_CALLMODE_ASYNCHRON );
1037cdf0e10cSrcweir 		}
1038cdf0e10cSrcweir         break;
1039cdf0e10cSrcweir         default:
1040cdf0e10cSrcweir 			ASSERT(!this, falscher Dispatcher);
1041cdf0e10cSrcweir 			return;
1042cdf0e10cSrcweir 	}
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 	if( bRefresh )
1045ca62e2c2SSteve Yin 		pViewWin->Invalidate();
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir /*--------------------------------------------------------------------
1049cdf0e10cSrcweir 	Beschreibung:
1050cdf0e10cSrcweir  --------------------------------------------------------------------*/
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir 
GetState(SfxItemSet & rSet)1053cdf0e10cSrcweir void  SwPagePreView::GetState( SfxItemSet& rSet )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
1056cdf0e10cSrcweir 	sal_uInt8 nRow = 1;
1057cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
1058cdf0e10cSrcweir     ASSERT(nWhich, leeres Set);
1059cdf0e10cSrcweir     SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
1060cdf0e10cSrcweir     //#106746# zoom has to be disabled if Accessibility support is switched on
1061cdf0e10cSrcweir     // MT 2010/01, see #110498#
1062cdf0e10cSrcweir     sal_Bool bZoomEnabled = sal_True; // !Application::GetSettings().GetMiscSettings().GetEnableATToolSupport();
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 	while(nWhich)
1065cdf0e10cSrcweir 	{
1066cdf0e10cSrcweir 		switch(nWhich)
1067cdf0e10cSrcweir 		{
1068cdf0e10cSrcweir 		case SID_BROWSER_MODE:
1069cdf0e10cSrcweir 		case FN_PRINT_LAYOUT:
1070cdf0e10cSrcweir 			rSet.DisableItem(nWhich);
1071cdf0e10cSrcweir 			break;
1072cdf0e10cSrcweir 		case FN_START_OF_DOCUMENT:
1073cdf0e10cSrcweir         {
1074cdf0e10cSrcweir             if ( pPagePrevwLay->IsPageVisible( 1 ) )
1075cdf0e10cSrcweir                 rSet.DisableItem(nWhich);
1076cdf0e10cSrcweir             break;
1077cdf0e10cSrcweir         }
1078cdf0e10cSrcweir         case FN_END_OF_DOCUMENT:
1079cdf0e10cSrcweir         {
1080cdf0e10cSrcweir             if ( pPagePrevwLay->IsPageVisible( mnPageCount ) )
1081cdf0e10cSrcweir                 rSet.DisableItem(nWhich);
1082cdf0e10cSrcweir             break;
1083cdf0e10cSrcweir         }
1084cdf0e10cSrcweir         case FN_PAGEUP:
1085cdf0e10cSrcweir         {
1086cdf0e10cSrcweir             if( pPagePrevwLay->GetWinPagesScrollAmount( -1 ) == 0 )
1087cdf0e10cSrcweir 				rSet.DisableItem(nWhich);
1088cdf0e10cSrcweir 			break;
1089cdf0e10cSrcweir         }
1090cdf0e10cSrcweir 		case FN_PAGEDOWN:
1091cdf0e10cSrcweir         {
1092cdf0e10cSrcweir             if( pPagePrevwLay->GetWinPagesScrollAmount( 1 ) == 0 )
1093cdf0e10cSrcweir                 rSet.DisableItem(nWhich);
1094cdf0e10cSrcweir             break;
1095cdf0e10cSrcweir         }
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir 		case FN_STAT_PAGE:
1098cdf0e10cSrcweir 			{
1099cdf0e10cSrcweir 				String aStr( sPageStr );
1100ca62e2c2SSteve Yin                 pViewWin->GetStatusStr( aStr, mnPageCount );
1101cdf0e10cSrcweir 				rSet.Put( SfxStringItem( nWhich, aStr) );
1102cdf0e10cSrcweir 			}
1103cdf0e10cSrcweir 			break;
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 		case SID_ATTR_ZOOM:
1106cdf0e10cSrcweir 		case FN_STAT_ZOOM:
1107cdf0e10cSrcweir 			{
1108cdf0e10cSrcweir                 if(bZoomEnabled)
1109cdf0e10cSrcweir                 {
1110cdf0e10cSrcweir                     const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1111cdf0e10cSrcweir                     SvxZoomItem aZoom((SvxZoomType)pVOpt->GetZoomType(),
1112cdf0e10cSrcweir                                         pVOpt->GetZoom());
1113cdf0e10cSrcweir                     aZoom.SetValueSet(
1114cdf0e10cSrcweir                             SVX_ZOOM_ENABLE_50|
1115cdf0e10cSrcweir                             SVX_ZOOM_ENABLE_75|
1116cdf0e10cSrcweir                             SVX_ZOOM_ENABLE_100|
1117cdf0e10cSrcweir                             SVX_ZOOM_ENABLE_150|
1118cdf0e10cSrcweir                             SVX_ZOOM_ENABLE_200);
1119cdf0e10cSrcweir                     rSet.Put( aZoom );
1120cdf0e10cSrcweir                 }
1121cdf0e10cSrcweir                 else
1122cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
1123cdf0e10cSrcweir             }
1124cdf0e10cSrcweir         break;
1125cdf0e10cSrcweir         case SID_ATTR_ZOOMSLIDER :
1126cdf0e10cSrcweir             {
1127cdf0e10cSrcweir                 if(bZoomEnabled)
1128cdf0e10cSrcweir                 {
1129cdf0e10cSrcweir                     const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1130cdf0e10cSrcweir                     const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1131cdf0e10cSrcweir                     SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1132cdf0e10cSrcweir                     aZoomSliderItem.AddSnappingPoint( 100 );
1133cdf0e10cSrcweir                     rSet.Put( aZoomSliderItem );
1134cdf0e10cSrcweir                 }
1135cdf0e10cSrcweir                 else
1136cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
1137cdf0e10cSrcweir             }
1138cdf0e10cSrcweir         break;
1139cdf0e10cSrcweir 		case FN_PREVIEW_ZOOM:
1140cdf0e10cSrcweir 		{
1141cdf0e10cSrcweir             if(bZoomEnabled)
1142cdf0e10cSrcweir             {
1143cdf0e10cSrcweir                 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1144cdf0e10cSrcweir                 rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
1145cdf0e10cSrcweir             }
1146cdf0e10cSrcweir             else
1147cdf0e10cSrcweir                 rSet.DisableItem(nWhich);
1148cdf0e10cSrcweir         }
1149cdf0e10cSrcweir 		break;
1150cdf0e10cSrcweir         case SID_ZOOM_IN:
1151cdf0e10cSrcweir         case SID_ZOOM_OUT:
1152cdf0e10cSrcweir         {
1153cdf0e10cSrcweir             const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1154cdf0e10cSrcweir             if(!bZoomEnabled || (SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)||
1155cdf0e10cSrcweir               (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
1156cdf0e10cSrcweir             {
1157cdf0e10cSrcweir                 rSet.DisableItem(nWhich);
1158cdf0e10cSrcweir             }
1159cdf0e10cSrcweir         }
1160cdf0e10cSrcweir         break;
1161cdf0e10cSrcweir         case FN_SHOW_MULTIPLE_PAGES:
1162cdf0e10cSrcweir         //should never be disabled
1163cdf0e10cSrcweir         break;
1164cdf0e10cSrcweir 		case FN_SHOW_BOOKVIEW:
1165cdf0e10cSrcweir 		{
1166cdf0e10cSrcweir 			sal_Bool b = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
1167cdf0e10cSrcweir 			rSet.Put(SfxBoolItem(nWhich, b));
1168cdf0e10cSrcweir 		}
1169cdf0e10cSrcweir 		break;
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 		case FN_SHOW_TWO_PAGES:
1172ca62e2c2SSteve Yin 			if( 2 == pViewWin->GetCol() && nRow == pViewWin->GetRow() )
1173cdf0e10cSrcweir 				rSet.DisableItem( nWhich );
1174cdf0e10cSrcweir 			break;
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir 		case FN_PRINT_PAGEPREVIEW:
1177cdf0e10cSrcweir 			// hat den gleichen Status wie das normale Drucken
1178cdf0e10cSrcweir 			{
1179cdf0e10cSrcweir 				const SfxPoolItem* pItem;
1180cdf0e10cSrcweir 				SfxItemSet aSet( *rSet.GetPool(), SID_PRINTDOC, SID_PRINTDOC );
1181cdf0e10cSrcweir 				GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
1182cdf0e10cSrcweir 				if( SFX_ITEM_DISABLED == aSet.GetItemState( SID_PRINTDOC,
1183cdf0e10cSrcweir 						sal_False, &pItem ))
1184cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
1185cdf0e10cSrcweir 				else if( SFX_ITEM_SET == aSet.GetItemState( SID_PRINTDOC,
1186cdf0e10cSrcweir 						sal_False, &pItem ))
1187cdf0e10cSrcweir 				{
1188cdf0e10cSrcweir 					((SfxPoolItem*)pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
1189cdf0e10cSrcweir 					rSet.Put( *pItem );
1190cdf0e10cSrcweir 				}
1191cdf0e10cSrcweir 			}
1192cdf0e10cSrcweir 			break;
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 		case SID_PRINTPREVIEW:
1195cdf0e10cSrcweir 			rSet.Put( SfxBoolItem( nWhich, sal_True ) );
1196cdf0e10cSrcweir 			break;
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir 		case SID_PRINTDOC:
1199cdf0e10cSrcweir 		case SID_PRINTDOCDIRECT:
1200cdf0e10cSrcweir 			GetSlotState( nWhich, SfxViewShell::GetInterface(),	&rSet );
1201cdf0e10cSrcweir 			break;
1202cdf0e10cSrcweir 		}
1203cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
1204cdf0e10cSrcweir 	}
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir /*--------------------------------------------------------------------
1208cdf0e10cSrcweir 	Beschreibung:
1209cdf0e10cSrcweir  --------------------------------------------------------------------*/
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 
StateUndo(SfxItemSet & rSet)1212cdf0e10cSrcweir void  SwPagePreView::StateUndo(SfxItemSet& rSet)
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
1215cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 	while (nWhich)
1218cdf0e10cSrcweir 	{
1219cdf0e10cSrcweir 		rSet.DisableItem(nWhich);
1220cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
1221cdf0e10cSrcweir 	}
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir /*--------------------------------------------------------------------
1225cdf0e10cSrcweir 	Beschreibung:
1226cdf0e10cSrcweir  --------------------------------------------------------------------*/
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir 
Init(const SwViewOption * pPrefs)1229cdf0e10cSrcweir void SwPagePreView::Init(const SwViewOption * pPrefs)
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir     if ( GetViewShell()->HasDrawView() )
1232cdf0e10cSrcweir         GetViewShell()->GetDrawView()->SetAnimationEnabled( sal_False );
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir 	bNormalPrint = sal_True;
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir 	// Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
1237cdf0e10cSrcweir 	// die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
1238cdf0e10cSrcweir 	// nicht in der SFX-Verwaltung bekannt ist.
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir 	if( !pPrefs )
1241cdf0e10cSrcweir 		pPrefs = SW_MOD()->GetUsrPref(sal_False);
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir 	// die Felder aktualisieren
1244cdf0e10cSrcweir 	// ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen.
1245cdf0e10cSrcweir 	//			In den Methoden wird auf die akt. Shell abgefragt!
1246cdf0e10cSrcweir     SwEditShell* pESh = (SwEditShell*)GetViewShell();
1247cdf0e10cSrcweir 	sal_Bool bIsModified = pESh->IsModified();
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir 	SwViewOption aOpt( *pPrefs );
1251cdf0e10cSrcweir     aOpt.SetPagePreview(sal_True);
1252cdf0e10cSrcweir 	aOpt.SetTab( sal_False );
1253cdf0e10cSrcweir 	aOpt.SetBlank( sal_False );
1254cdf0e10cSrcweir 	aOpt.SetHardBlank( sal_False );
1255cdf0e10cSrcweir 	aOpt.SetParagraph( sal_False );
1256cdf0e10cSrcweir 	aOpt.SetLineBreak( sal_False );
1257cdf0e10cSrcweir 	aOpt.SetPageBreak( sal_False );
1258cdf0e10cSrcweir 	aOpt.SetColumnBreak( sal_False );
1259cdf0e10cSrcweir 	aOpt.SetSoftHyph( sal_False );
1260cdf0e10cSrcweir 	aOpt.SetFldName( sal_False );
1261cdf0e10cSrcweir 	aOpt.SetPostIts( sal_False );
1262cdf0e10cSrcweir     aOpt.SetShowHiddenChar( sal_False );
1263cdf0e10cSrcweir     aOpt.SetShowHiddenField( sal_False );
1264cdf0e10cSrcweir     aOpt.SetShowHiddenPara( sal_False );
1265cdf0e10cSrcweir     aOpt.SetViewHRuler( sal_False );
1266cdf0e10cSrcweir     aOpt.SetViewVRuler( sal_False );
1267cdf0e10cSrcweir 	aOpt.SetGraphic( sal_True );
1268cdf0e10cSrcweir     aOpt.SetTable( sal_True );
1269cdf0e10cSrcweir     aOpt.SetSnap( sal_False );
1270cdf0e10cSrcweir 	aOpt.SetGridVisible( sal_False );
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir     GetViewShell()->ApplyViewOptions( aOpt );
1273cdf0e10cSrcweir     GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir     // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print
1276cdf0e10cSrcweir     SwPrintData const aPrintOptions = *SW_MOD()->GetPrtOptions(false);
1277cdf0e10cSrcweir     GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir     GetViewShell()->CalcLayout();
1280cdf0e10cSrcweir     DocSzChgd( GetViewShell()->GetDocSize() );
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 	if( !bIsModified )
1283cdf0e10cSrcweir 		pESh->ResetModified();
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir     pVScrollbar->ExtendedShow(pPrefs->IsViewVScrollBar());
1286cdf0e10cSrcweir     pHScrollbar->ExtendedShow(pPrefs->IsViewHScrollBar());
1287cdf0e10cSrcweir     pScrollFill->Show(pPrefs->IsViewVScrollBar() && pPrefs->IsViewHScrollBar());
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir /*--------------------------------------------------------------------
1292cdf0e10cSrcweir 	Beschreibung:
1293cdf0e10cSrcweir  --------------------------------------------------------------------*/
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 
SwPagePreView(SfxViewFrame * pViewFrame,SfxViewShell * pOldSh)1296cdf0e10cSrcweir SwPagePreView::SwPagePreView(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh):
1297cdf0e10cSrcweir 	SfxViewShell( pViewFrame, SWVIEWFLAGS ),
1298*90386390SHerbert Dürr 	pViewWin( new SwPagePreViewWin(&(GetViewFrame())->GetWindow(), *this ) ),
1299*90386390SHerbert Dürr 	nNewPage(USHRT_MAX),
1300cdf0e10cSrcweir 	pHScrollbar(0),
1301cdf0e10cSrcweir 	pVScrollbar(0),
1302cdf0e10cSrcweir 	pPageUpBtn(0),
1303cdf0e10cSrcweir 	pPageDownBtn(0),
1304cdf0e10cSrcweir     pScrollFill(new ScrollBarBox( &pViewFrame->GetWindow(),
1305cdf0e10cSrcweir         pViewFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
1306cdf0e10cSrcweir     mnPageCount( 0 ),
1307cdf0e10cSrcweir     // OD 09.01.2003 #106334#
1308cdf0e10cSrcweir     mbResetFormDesignMode( false ),
1309cdf0e10cSrcweir     mbFormDesignModeToReset( false )
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir 	SetName(String::CreateFromAscii("PageView" ));
1312ca62e2c2SSteve Yin 	SetWindow( pViewWin );
1313cdf0e10cSrcweir 	SetHelpId(SW_PAGEPREVIEW);
1314cdf0e10cSrcweir     _CreateScrollbar( sal_True );
1315cdf0e10cSrcweir     _CreateScrollbar( sal_False );
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir     SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
1318cdf0e10cSrcweir 	if ( !pOldSh )
1319cdf0e10cSrcweir 	{
1320cdf0e10cSrcweir 		//Gibt es schon eine Sicht auf das Dokument?
1321cdf0e10cSrcweir 		SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
1322cdf0e10cSrcweir 		if ( pF == pViewFrame )
1323cdf0e10cSrcweir 			pF = SfxViewFrame::GetNext( *pF, pObjShell );
1324cdf0e10cSrcweir 		if ( pF )
1325cdf0e10cSrcweir 			pOldSh = pF->GetViewShell();
1326cdf0e10cSrcweir 	}
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 	ViewShell *pVS, *pNew;
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir 	if( pOldSh && pOldSh->IsA( TYPE( SwPagePreView ) ) )
1331cdf0e10cSrcweir         pVS = ((SwPagePreView*)pOldSh)->GetViewShell();
1332cdf0e10cSrcweir 	else
1333cdf0e10cSrcweir 	{
1334cdf0e10cSrcweir 		if( pOldSh && pOldSh->IsA( TYPE( SwView ) ) )
1335cdf0e10cSrcweir 		{
1336cdf0e10cSrcweir 			pVS = ((SwView*)pOldSh)->GetWrtShellPtr();
1337cdf0e10cSrcweir 			// save the current ViewData of the previous SwView
1338cdf0e10cSrcweir 			pOldSh->WriteUserData( sSwViewData, sal_False );
1339cdf0e10cSrcweir 		}
1340cdf0e10cSrcweir 		else
1341cdf0e10cSrcweir 			pVS = GetDocShell()->GetWrtShell();
1342cdf0e10cSrcweir 		if( pVS )
1343cdf0e10cSrcweir 		{
1344cdf0e10cSrcweir 			// setze die akt. Seite als die erste
1345cdf0e10cSrcweir 			sal_uInt16 nPhysPg, nVirtPg;
1346cdf0e10cSrcweir 			((SwCrsrShell*)pVS)->GetPageNum( nPhysPg, nVirtPg, /*sal_False*/sal_True, sal_False );
1347ca62e2c2SSteve Yin 			if( 1 != pViewWin->GetCol() && 1 == nPhysPg )
1348cdf0e10cSrcweir 				--nPhysPg;
1349ca62e2c2SSteve Yin 			pViewWin->SetSttPage( nPhysPg );
1350cdf0e10cSrcweir 		}
1351cdf0e10cSrcweir 	}
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir     // OD 09.01.2003 #106334# - for form shell remember design mode of draw view
1354cdf0e10cSrcweir     // of previous view shell
1355cdf0e10cSrcweir     if ( pVS && pVS->HasDrawView() )
1356cdf0e10cSrcweir     {
1357cdf0e10cSrcweir         mbResetFormDesignMode = true;
1358cdf0e10cSrcweir         mbFormDesignModeToReset = pVS->GetDrawView()->IsDesignMode();
1359cdf0e10cSrcweir     }
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir     if( pVS )
1362ca62e2c2SSteve Yin 		pNew = new ViewShell( *pVS, pViewWin, 0, VSHELLFLAG_ISPREVIEW );
1363cdf0e10cSrcweir 	else
1364cdf0e10cSrcweir 		pNew = new ViewShell(
1365cdf0e10cSrcweir 				*((SwDocShell*)pViewFrame->GetObjectShell())->GetDoc(),
1366ca62e2c2SSteve Yin 				pViewWin, 0, 0, VSHELLFLAG_ISPREVIEW );
1367cdf0e10cSrcweir 
1368ca62e2c2SSteve Yin     pViewWin->SetViewShell( pNew );
1369cdf0e10cSrcweir 	pNew->SetSfxViewShell( this );
1370cdf0e10cSrcweir 	Init();
1371cdf0e10cSrcweir }
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir /*--------------------------------------------------------------------
1375cdf0e10cSrcweir 	Beschreibung:
1376cdf0e10cSrcweir  --------------------------------------------------------------------*/
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir 
~SwPagePreView()1379cdf0e10cSrcweir  SwPagePreView::~SwPagePreView()
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir 	SetWindow( 0 );
1382ca62e2c2SSteve Yin 	ViewShell* pVShell =  pViewWin->GetViewShell();
1383ca62e2c2SSteve Yin 	pVShell->SetWin(0);
1384ca62e2c2SSteve Yin 	//pViewWin->Hide();
1385ca62e2c2SSteve Yin 	if( pVShell)
1386ca62e2c2SSteve Yin 		delete pVShell;
1387ca62e2c2SSteve Yin 	delete pViewWin;
1388ca62e2c2SSteve Yin 	//pViewWin->Hide();
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 	delete pScrollFill;
1391cdf0e10cSrcweir 	delete pHScrollbar;
1392cdf0e10cSrcweir 	delete pVScrollbar;
1393cdf0e10cSrcweir 	delete pPageUpBtn;
1394cdf0e10cSrcweir 	delete pPageDownBtn;
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir /*    SfxObjectShell* pDocSh = GetDocShell();
1397cdf0e10cSrcweir 	for( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocSh );
1398cdf0e10cSrcweir 		pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh ) )
1399cdf0e10cSrcweir 		if( pFrame != GetViewFrame() )
1400cdf0e10cSrcweir 		{
1401cdf0e10cSrcweir 			// es gibt noch eine weitere Sicht auf unser Dokument, also
1402cdf0e10cSrcweir 			// aktiviere dieses
1403cdf0e10cSrcweir 			pFrame->GetFrame().Appear();
1404cdf0e10cSrcweir 			break;
1405cdf0e10cSrcweir 		}
1406cdf0e10cSrcweir */}
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir /*--------------------------------------------------------------------
1409cdf0e10cSrcweir 	Beschreibung:
1410cdf0e10cSrcweir  --------------------------------------------------------------------*/
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir 
GetDocShell()1413cdf0e10cSrcweir SwDocShell* SwPagePreView::GetDocShell()
1414cdf0e10cSrcweir {
1415cdf0e10cSrcweir 	return PTR_CAST(SwDocShell, GetViewFrame()->GetObjectShell());
1416cdf0e10cSrcweir }
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir /*--------------------------------------------------------------------
1419cdf0e10cSrcweir 	Beschreibung:
1420cdf0e10cSrcweir  --------------------------------------------------------------------*/
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir 
_CreateScrollbar(sal_Bool bHori)1423cdf0e10cSrcweir int SwPagePreView::_CreateScrollbar( sal_Bool bHori )
1424cdf0e10cSrcweir {
1425cdf0e10cSrcweir 	Window *pMDI = &GetViewFrame()->GetWindow();
1426cdf0e10cSrcweir 	SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar;
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir 	ASSERT( !*ppScrollbar, "vorher abpruefen!" )
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 	if( !bHori )
1431cdf0e10cSrcweir 	{
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir 		pPageUpBtn		= new ImageButton(pMDI, SW_RES( BTN_PAGEUP ) );
1434cdf0e10cSrcweir 		pPageUpBtn->SetHelpId(GetStaticInterface()->GetSlot(FN_PAGEUP)->GetCommand());
1435cdf0e10cSrcweir 		pPageDownBtn	= new ImageButton(pMDI, SW_RES( BTN_PAGEDOWN ) );
1436cdf0e10cSrcweir 		pPageDownBtn->SetHelpId(GetStaticInterface()->GetSlot(FN_PAGEDOWN)->GetCommand());
1437cdf0e10cSrcweir 		Link aLk( LINK( this, SwPagePreView, BtnPage ) );
1438cdf0e10cSrcweir 		pPageUpBtn->SetClickHdl( aLk );
1439cdf0e10cSrcweir 		pPageDownBtn->SetClickHdl( aLk );
1440cdf0e10cSrcweir 		pPageUpBtn->Show();
1441cdf0e10cSrcweir 		pPageDownBtn->Show();
1442cdf0e10cSrcweir 	}
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir 	*ppScrollbar = new SwScrollbar( pMDI, bHori );
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir     ScrollDocSzChg();
1447cdf0e10cSrcweir     (*ppScrollbar)->EnableDrag( sal_True );
1448cdf0e10cSrcweir     (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwPagePreView, EndScrollHdl ));
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir 	(*ppScrollbar)->SetScrollHdl( LINK( this, SwPagePreView, ScrollHdl ));
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir 	InvalidateBorder();
1454cdf0e10cSrcweir     (*ppScrollbar)->ExtendedShow();
1455cdf0e10cSrcweir 	return 1;
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir /*--------------------------------------------------------------------
1459cdf0e10cSrcweir 	Beschreibung:
1460cdf0e10cSrcweir  --------------------------------------------------------------------*/
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir /*--------------------------------------------------------------------
1465cdf0e10cSrcweir 	Beschreibung:
1466cdf0e10cSrcweir  --------------------------------------------------------------------*/
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir /*
1469cdf0e10cSrcweir  * Button-Handler
1470cdf0e10cSrcweir  */
IMPL_LINK_INLINE_START(SwPagePreView,BtnPage,Button *,pButton)1471cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwPagePreView, BtnPage, Button *, pButton )
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir     // OD 04.03.2003 #107369# - use new helper method to perform page up
1474cdf0e10cSrcweir     // respectively page down.
1475cdf0e10cSrcweir     _ExecPgUpAndPgDown( pButton == pPageUpBtn );
1476cdf0e10cSrcweir 	return 0;
1477cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwPagePreView,BtnPage,Button *,pButton)1478cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwPagePreView, BtnPage, Button *, pButton )
1479cdf0e10cSrcweir 
1480cdf0e10cSrcweir /*--------------------------------------------------------------------
1481cdf0e10cSrcweir 	Beschreibung:
1482cdf0e10cSrcweir  --------------------------------------------------------------------*/
1483cdf0e10cSrcweir 
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir int SwPagePreView::ChgPage( int eMvMode, int bUpdateScrollbar )
1486cdf0e10cSrcweir {
1487ca62e2c2SSteve Yin 	Rectangle aPixVisArea( pViewWin->LogicToPixel( aVisArea ) );
1488ca62e2c2SSteve Yin 	int bChg = pViewWin->MovePage( eMvMode ) ||
1489cdf0e10cSrcweir                eMvMode == SwPagePreViewWin::MV_CALC ||
1490cdf0e10cSrcweir                eMvMode == SwPagePreViewWin::MV_NEWWINSIZE;
1491ca62e2c2SSteve Yin 	aVisArea = pViewWin->PixelToLogic( aPixVisArea );
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir 	if( bChg )
1494cdf0e10cSrcweir 	{
1495cdf0e10cSrcweir 		// Statusleiste updaten
1496cdf0e10cSrcweir 		String aStr( sPageStr );
1497ca62e2c2SSteve Yin         pViewWin->GetStatusStr( aStr, mnPageCount );
1498cdf0e10cSrcweir 		SfxBindings& rBindings = GetViewFrame()->GetBindings();
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 		if( bUpdateScrollbar )
1501cdf0e10cSrcweir 		{
1502cdf0e10cSrcweir             ScrollViewSzChg();
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir 			static sal_uInt16 __READONLY_DATA aInval[] =
1505cdf0e10cSrcweir 			{
1506cdf0e10cSrcweir 				FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
1507cdf0e10cSrcweir 				FN_PAGEUP, FN_PAGEDOWN, 0
1508cdf0e10cSrcweir 			};
1509cdf0e10cSrcweir 			rBindings.Invalidate( aInval );
1510cdf0e10cSrcweir 		}
1511cdf0e10cSrcweir 		rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) );
1512cdf0e10cSrcweir 	}
1513cdf0e10cSrcweir 	return bChg;
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir /*  */
1518cdf0e10cSrcweir /*--------------------------------------------------------------------
1519cdf0e10cSrcweir 	Beschreibung:
1520cdf0e10cSrcweir  --------------------------------------------------------------------*/
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir // ab hier alles aus der SwView uebernommen
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir 
CalcAndSetBorderPixel(SvBorder & rToFill,sal_Bool)1526cdf0e10cSrcweir void SwPagePreView::CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool /*bInner*/ )
1527cdf0e10cSrcweir {
1528cdf0e10cSrcweir //	const long nAdd = bInner ? 0 : ScrollBar::GetWindowOverlapPixel();
1529ca62e2c2SSteve Yin 	const StyleSettings &rSet = pViewWin->GetSettings().GetStyleSettings();
1530cdf0e10cSrcweir 	const long nTmp = rSet.GetScrollBarSize();// - nAdd;
1531cdf0e10cSrcweir     if ( pVScrollbar->IsVisible( sal_False ))
1532cdf0e10cSrcweir 		rToFill.Right()  = nTmp;
1533cdf0e10cSrcweir 	if ( pHScrollbar->IsVisible( sal_False ) )
1534cdf0e10cSrcweir 		rToFill.Bottom() = nTmp;
1535cdf0e10cSrcweir 	SetBorderPixel( rToFill );
1536cdf0e10cSrcweir }
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir /*--------------------------------------------------------------------
1539cdf0e10cSrcweir 	Beschreibung:
1540cdf0e10cSrcweir  --------------------------------------------------------------------*/
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir 
InnerResizePixel(const Point & rOfst,const Size & rSize)1543cdf0e10cSrcweir void  SwPagePreView::InnerResizePixel( const Point &rOfst, const Size &rSize )
1544cdf0e10cSrcweir {
1545cdf0e10cSrcweir 	SvBorder aBorder;
1546cdf0e10cSrcweir 	CalcAndSetBorderPixel( aBorder, sal_True );
1547cdf0e10cSrcweir 	Rectangle aRect( rOfst, rSize );
1548cdf0e10cSrcweir 	aRect += aBorder;
1549ca62e2c2SSteve Yin 	ViewResizePixel( *pViewWin, aRect.TopLeft(), aRect.GetSize(),
1550ca62e2c2SSteve Yin 					pViewWin->GetOutputSizePixel(),
1551cdf0e10cSrcweir 					sal_True,
1552cdf0e10cSrcweir                     *pVScrollbar, *pHScrollbar, pPageUpBtn, pPageDownBtn, 0,
1553cdf0e10cSrcweir                     *pScrollFill );
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir 	//EditWin niemals einstellen!
1556cdf0e10cSrcweir 	//VisArea niemals einstellen!
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir /*--------------------------------------------------------------------
1560cdf0e10cSrcweir 	Beschreibung:
1561cdf0e10cSrcweir  --------------------------------------------------------------------*/
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir 
OuterResizePixel(const Point & rOfst,const Size & rSize)1564cdf0e10cSrcweir void  SwPagePreView::OuterResizePixel( const Point &rOfst, const Size &rSize )
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir 	SvBorder aBorder;
1567cdf0e10cSrcweir 	CalcAndSetBorderPixel( aBorder, sal_False );
1568ca62e2c2SSteve Yin 	ViewResizePixel( *pViewWin, rOfst, rSize, pViewWin->GetOutputSizePixel(),
1569cdf0e10cSrcweir                         sal_False, *pVScrollbar,
1570cdf0e10cSrcweir                         *pHScrollbar, pPageUpBtn, pPageDownBtn, 0, *pScrollFill );
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir 	//EditWin niemals einstellen!
1573cdf0e10cSrcweir 
1574ca62e2c2SSteve Yin 	Size aTmpSize( pViewWin->GetOutputSizePixel() );
1575ca62e2c2SSteve Yin 	Point aBottomRight( pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
1576cdf0e10cSrcweir 	SetVisArea( Rectangle( Point(), aBottomRight ) );
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir 	//Aufruf der DocSzChgd-Methode der Scrollbars ist noetig, da vom maximalen
1579cdf0e10cSrcweir 	//Scrollrange immer die halbe Hoehe der VisArea abgezogen wird.
1580cdf0e10cSrcweir 	if ( pVScrollbar &&
1581cdf0e10cSrcweir              aTmpSize.Width() > 0 && aTmpSize.Height() > 0 )
1582cdf0e10cSrcweir         {
1583cdf0e10cSrcweir             ScrollDocSzChg();
1584cdf0e10cSrcweir         }
1585cdf0e10cSrcweir }
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir /*--------------------------------------------------------------------
1588cdf0e10cSrcweir 	Beschreibung:
1589cdf0e10cSrcweir  --------------------------------------------------------------------*/
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir 
SetVisArea(const Rectangle & rRect,sal_Bool bUpdateScrollbar)1592cdf0e10cSrcweir void SwPagePreView::SetVisArea( const Rectangle &rRect, sal_Bool bUpdateScrollbar )
1593cdf0e10cSrcweir {
1594cdf0e10cSrcweir 	const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
1595cdf0e10cSrcweir 	const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
1596cdf0e10cSrcweir 	Rectangle aLR(aTopLeft,aBottomRight);
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir 	if(aLR == aVisArea)
1599cdf0e10cSrcweir 		return;
1600cdf0e10cSrcweir 		// keine negative Position, keine neg. Groesse
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir 	if(aLR.Top() < 0)
1603cdf0e10cSrcweir 	{
1604cdf0e10cSrcweir 		aLR.Bottom() += Abs(aLR.Top());
1605cdf0e10cSrcweir 		aLR.Top() = 0;
1606cdf0e10cSrcweir 	}
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir 	if(aLR.Left() < 0)
1609cdf0e10cSrcweir 	{
1610cdf0e10cSrcweir 		aLR.Right() += Abs(aLR.Left());
1611cdf0e10cSrcweir 		aLR.Left() = 0;
1612cdf0e10cSrcweir 	}
1613cdf0e10cSrcweir 	if(aLR.Right() < 0) aLR.Right() = 0;
1614cdf0e10cSrcweir 	if(aLR.Bottom() < 0) aLR.Bottom() = 0;
1615cdf0e10cSrcweir 	if(aLR == aVisArea ||
1616cdf0e10cSrcweir 		// JP 29.10.97: Bug 45173 - Leeres Rechteck nicht beachten
1617cdf0e10cSrcweir 		( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
1618cdf0e10cSrcweir 		return;
1619cdf0e10cSrcweir 
1620cdf0e10cSrcweir 	if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
1621cdf0e10cSrcweir 		return;
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 	//Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
1624cdf0e10cSrcweir 	//sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
1625cdf0e10cSrcweir 	//umgerechnet werden.
1626cdf0e10cSrcweir 	//Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
1627cdf0e10cSrcweir 	//denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
1628cdf0e10cSrcweir 	//lediglich (in Dokumentkoordinaten) vorgemerkt.
1629cdf0e10cSrcweir     if( GetViewShell()->ActionPend() )
1630ca62e2c2SSteve Yin 		pViewWin->Update();
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 	// setze am View-Win die aktuelle Size
1633cdf0e10cSrcweir 	aVisArea = aLR;
1634ca62e2c2SSteve Yin 	pViewWin->SetWinSize( aLR.GetSize() );
1635cdf0e10cSrcweir     // OD 18.12.2002 #103492# - use new mode
1636cdf0e10cSrcweir     ChgPage( SwPagePreViewWin::MV_NEWWINSIZE, bUpdateScrollbar );
1637cdf0e10cSrcweir 
1638ca62e2c2SSteve Yin 	pViewWin->Invalidate();
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir 
1641cdf0e10cSrcweir /*--------------------------------------------------------------------
1642cdf0e10cSrcweir 	Beschreibung:
1643cdf0e10cSrcweir  --------------------------------------------------------------------*/
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir 
IMPL_LINK(SwPagePreView,ScrollHdl,SwScrollbar *,pScrollbar)1646cdf0e10cSrcweir IMPL_LINK( SwPagePreView, ScrollHdl, SwScrollbar *, pScrollbar )
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir     if(!GetViewShell())
1649cdf0e10cSrcweir         return 0;
1650cdf0e10cSrcweir     if( !pScrollbar->IsHoriScroll() &&
1651cdf0e10cSrcweir         pScrollbar->GetType() == SCROLL_DRAG &&
1652cdf0e10cSrcweir         Help::IsQuickHelpEnabled() &&
1653cdf0e10cSrcweir         GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1654cdf0e10cSrcweir 	{
1655cdf0e10cSrcweir 		// wieviele Seiten scrollen ??
1656cdf0e10cSrcweir 		String sStateStr(sPageStr);
1657cdf0e10cSrcweir 		sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos();
1658ca62e2c2SSteve Yin 		if( 1 == pViewWin->GetCol() || !nThmbPos )
1659cdf0e10cSrcweir 			++nThmbPos;
1660cdf0e10cSrcweir 		sStateStr += String::CreateFromInt32( nThmbPos );
1661cdf0e10cSrcweir 		Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
1662cdf0e10cSrcweir 										pScrollbar->GetPosPixel());
1663cdf0e10cSrcweir 		aPos.Y() = pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y();
1664cdf0e10cSrcweir 		Size aSize = pScrollbar->GetSizePixel();
1665cdf0e10cSrcweir 		Rectangle aRect;
1666cdf0e10cSrcweir 		aRect.Left() 	= aPos.X() -8;
1667cdf0e10cSrcweir 		aRect.Right() 	= aRect.Left();
1668cdf0e10cSrcweir 		aRect.Top()		= aPos.Y();
1669cdf0e10cSrcweir 		aRect.Bottom()	= aRect.Top();
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir 		Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
1672cdf0e10cSrcweir 				QUICKHELP_RIGHT|QUICKHELP_VCENTER);
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir 	}
1675cdf0e10cSrcweir 	else
1676cdf0e10cSrcweir 		EndScrollHdl( pScrollbar );
1677cdf0e10cSrcweir 	return 0;
1678cdf0e10cSrcweir }
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir /*--------------------------------------------------------------------
1681cdf0e10cSrcweir 	Beschreibung:
1682cdf0e10cSrcweir  --------------------------------------------------------------------*/
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir 
IMPL_LINK(SwPagePreView,EndScrollHdl,SwScrollbar *,pScrollbar)1685cdf0e10cSrcweir IMPL_LINK( SwPagePreView, EndScrollHdl, SwScrollbar *, pScrollbar )
1686cdf0e10cSrcweir {
1687cdf0e10cSrcweir     if(!GetViewShell())
1688cdf0e10cSrcweir         return 0;
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir     // OD 04.03.2003 #107369# - boolean to avoid unnecessary invalidation of the window.
1691cdf0e10cSrcweir     bool bInvalidateWin = true;
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir     if( !pScrollbar->IsHoriScroll() )       // scroll vertically
1694cdf0e10cSrcweir 	{
1695cdf0e10cSrcweir         if ( Help::IsQuickHelpEnabled() )
1696cdf0e10cSrcweir 			Help::ShowQuickHelp(pScrollbar, Rectangle(), aEmptyStr, 0);
1697cdf0e10cSrcweir         if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
1698cdf0e10cSrcweir         {
1699cdf0e10cSrcweir             // wieviele Seiten scrollen ??
1700cdf0e10cSrcweir             sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos();
1701cdf0e10cSrcweir             // OD 05.12.2002 #103492# - adjust to new preview functionality
1702ca62e2c2SSteve Yin             if( nThmbPos != pViewWin->SelectedPage() )
1703cdf0e10cSrcweir             {
1704cdf0e10cSrcweir                 // OD 17.01.2003 #103492# - consider case that page <nThmbPos>
1705cdf0e10cSrcweir                 // is already visible
1706cdf0e10cSrcweir                 SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
1707cdf0e10cSrcweir                 if ( pPagePrevwLay->IsPageVisible( nThmbPos ) )
1708cdf0e10cSrcweir                 {
1709cdf0e10cSrcweir                     pPagePrevwLay->MarkNewSelectedPage( nThmbPos );
1710cdf0e10cSrcweir                     // OD 04.03.2003 #107369# - invalidation of window is unnecessary
1711cdf0e10cSrcweir                     bInvalidateWin = false;
1712cdf0e10cSrcweir                 }
1713cdf0e10cSrcweir                 else
1714cdf0e10cSrcweir                 {
1715cdf0e10cSrcweir                     // OD 17.01.2003 #103492# - consider whether layout columns
1716cdf0e10cSrcweir                     // fit or not.
1717cdf0e10cSrcweir                     if ( !pPagePrevwLay->DoesPreviewLayoutColsFitIntoWindow() )
1718cdf0e10cSrcweir                     {
1719ca62e2c2SSteve Yin                         pViewWin->SetSttPage( nThmbPos );
1720ca62e2c2SSteve Yin                         pViewWin->SetSelectedPage( nThmbPos );
1721cdf0e10cSrcweir                         ChgPage( SwPagePreViewWin::MV_SCROLL, sal_False );
1722cdf0e10cSrcweir                         // OD 20.01.2003 #103492# - update scrollbars
1723cdf0e10cSrcweir                         ScrollViewSzChg();
1724cdf0e10cSrcweir                     }
1725cdf0e10cSrcweir                     else
1726cdf0e10cSrcweir                     {
1727cdf0e10cSrcweir                         // OD 04.03.2003 #107369# - correct scroll amount
1728ca62e2c2SSteve Yin                         const sal_Int16 nPageDiff = nThmbPos - pViewWin->SelectedPage();
1729ca62e2c2SSteve Yin                         const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
1730cdf0e10cSrcweir                         sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages;
1731cdf0e10cSrcweir                         if ( nPageDiff % nVisPages )
1732cdf0e10cSrcweir                         {
1733cdf0e10cSrcweir                             // decrease/increase number of preview pages to scroll
1734cdf0e10cSrcweir                             nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll;
1735cdf0e10cSrcweir                         }
1736ca62e2c2SSteve Yin                         pViewWin->SetSelectedPage( nThmbPos );
1737ca62e2c2SSteve Yin                         pViewWin->Scroll( 0, pPagePrevwLay->GetWinPagesScrollAmount( nWinPagesToScroll ) );
1738cdf0e10cSrcweir                     }
1739cdf0e10cSrcweir                 }
1740cdf0e10cSrcweir                 // OD 17.01.2003 #103492# - update accessibility
1741cdf0e10cSrcweir                 GetViewShell()->ShowPreViewSelection( nThmbPos );
1742cdf0e10cSrcweir             }
1743cdf0e10cSrcweir             else
1744cdf0e10cSrcweir             {
1745cdf0e10cSrcweir                 // OD 04.03.2003 #107369# - invalidation of window is unnecessary
1746cdf0e10cSrcweir                 bInvalidateWin = false;
1747cdf0e10cSrcweir             }
1748cdf0e10cSrcweir         }
1749cdf0e10cSrcweir         else
1750cdf0e10cSrcweir         {
1751cdf0e10cSrcweir             long nThmbPos = pScrollbar->GetThumbPos();
1752ca62e2c2SSteve Yin             pViewWin->Scroll(0, nThmbPos - pViewWin->GetPaintedPreviewDocRect().Top());
1753cdf0e10cSrcweir         }
1754cdf0e10cSrcweir 	}
1755cdf0e10cSrcweir     else
1756cdf0e10cSrcweir     {
1757cdf0e10cSrcweir         long nThmbPos = pScrollbar->GetThumbPos();
1758ca62e2c2SSteve Yin         pViewWin->Scroll(nThmbPos - pViewWin->GetPaintedPreviewDocRect().Left(), 0);
1759cdf0e10cSrcweir     }
1760cdf0e10cSrcweir     // OD 24.03.2003 #108282# - additional invalidate page status.
1761cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInval[] =
1762cdf0e10cSrcweir     {
1763cdf0e10cSrcweir         FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
1764cdf0e10cSrcweir         FN_STAT_PAGE, 0
1765cdf0e10cSrcweir     };
1766cdf0e10cSrcweir     SfxBindings& rBindings = GetViewFrame()->GetBindings();
1767cdf0e10cSrcweir     rBindings.Invalidate( aInval );
1768cdf0e10cSrcweir     // OD 04.03.2003 #107369# - control invalidation of window
1769cdf0e10cSrcweir     if ( bInvalidateWin )
1770cdf0e10cSrcweir     {
1771ca62e2c2SSteve Yin         pViewWin->Invalidate();
1772cdf0e10cSrcweir     }
1773cdf0e10cSrcweir     return 0;
1774cdf0e10cSrcweir }
1775cdf0e10cSrcweir /*--------------------------------------------------------------------
1776cdf0e10cSrcweir 	Beschreibung:
1777cdf0e10cSrcweir  --------------------------------------------------------------------*/
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir 
AlignToPixel(const Point & rPt) const1780cdf0e10cSrcweir Point SwPagePreView::AlignToPixel(const Point &rPt) const
1781cdf0e10cSrcweir {
1782ca62e2c2SSteve Yin 	return pViewWin->PixelToLogic( pViewWin->LogicToPixel( rPt ) );
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir /*--------------------------------------------------------------------
1786cdf0e10cSrcweir 	Beschreibung:
1787cdf0e10cSrcweir  --------------------------------------------------------------------*/
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir 
DocSzChgd(const Size & rSz)1790cdf0e10cSrcweir void SwPagePreView::DocSzChgd( const Size &rSz )
1791cdf0e10cSrcweir {
1792cdf0e10cSrcweir 	if( aDocSz == rSz )
1793cdf0e10cSrcweir 		return;
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir 	aDocSz = rSz;
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir     // --> OD 2009-08-20 #i96726#
1798cdf0e10cSrcweir     // Due to the multiple page layout it is needed to trigger recalculation
1799cdf0e10cSrcweir     // of the page preview layout, even if the count of pages is not changing.
1800cdf0e10cSrcweir     mnPageCount = GetViewShell()->GetNumPages();
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir     if( aVisArea.GetWidth() )
1803cdf0e10cSrcweir 	{
1804cdf0e10cSrcweir 		ChgPage( SwPagePreViewWin::MV_CALC, sal_True );
1805cdf0e10cSrcweir         ScrollDocSzChg();
1806cdf0e10cSrcweir 
1807ca62e2c2SSteve Yin 		pViewWin->Invalidate();
1808cdf0e10cSrcweir 	}
1809cdf0e10cSrcweir     // <--
1810cdf0e10cSrcweir }
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir /*--------------------------------------------------------------------
1813cdf0e10cSrcweir 	Beschreibung:
1814cdf0e10cSrcweir  --------------------------------------------------------------------*/
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 
ScrollViewSzChg()1817cdf0e10cSrcweir void SwPagePreView::ScrollViewSzChg()
1818cdf0e10cSrcweir {
1819cdf0e10cSrcweir     if(!GetViewShell())
1820cdf0e10cSrcweir         return ;
1821cdf0e10cSrcweir     if(pVScrollbar)
1822cdf0e10cSrcweir     {
1823cdf0e10cSrcweir         if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1824cdf0e10cSrcweir         {
1825cdf0e10cSrcweir             //vertical scrolling by row
1826cdf0e10cSrcweir             // OD 04.12.2002 #103492# - adjust to new preview functionality
1827ca62e2c2SSteve Yin             sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol();
1828cdf0e10cSrcweir             pVScrollbar->SetVisibleSize( nVisPages );
1829cdf0e10cSrcweir             // OD 19.02.2003 #107369# - set selected page as scroll bar position,
1830cdf0e10cSrcweir             // if it is visible.
1831cdf0e10cSrcweir             SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
1832ca62e2c2SSteve Yin             if ( pPagePrevwLay->IsPageVisible( pViewWin->SelectedPage() ) )
1833cdf0e10cSrcweir             {
1834ca62e2c2SSteve Yin                 pVScrollbar->SetThumbPos( pViewWin->SelectedPage() );
1835cdf0e10cSrcweir             }
1836cdf0e10cSrcweir             else
1837cdf0e10cSrcweir             {
1838ca62e2c2SSteve Yin                 pVScrollbar->SetThumbPos( pViewWin->GetSttPage() );
1839cdf0e10cSrcweir             }
1840ca62e2c2SSteve Yin             pVScrollbar->SetLineSize( pViewWin->GetCol() );
1841cdf0e10cSrcweir             pVScrollbar->SetPageSize( nVisPages );
1842cdf0e10cSrcweir             // calculate and set scrollbar range
1843cdf0e10cSrcweir             Range aScrollbarRange( 1, mnPageCount );
1844cdf0e10cSrcweir             // increase range by one, because left-top-corner is left blank.
1845cdf0e10cSrcweir             ++aScrollbarRange.Max();
1846cdf0e10cSrcweir             // OD 17.01.2003 #103492# - increase range in order to access all pages
1847cdf0e10cSrcweir             aScrollbarRange.Max() += ( nVisPages - 1 );
1848cdf0e10cSrcweir             pVScrollbar->SetRange( aScrollbarRange );
1849cdf0e10cSrcweir         }
1850cdf0e10cSrcweir         else //vertical scrolling by pixel
1851cdf0e10cSrcweir         {
1852ca62e2c2SSteve Yin             const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect();
1853cdf0e10cSrcweir             const Size& rPreviewSize =
1854cdf0e10cSrcweir                     GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
1855cdf0e10cSrcweir             pVScrollbar->SetRangeMax(rPreviewSize.Height()) ;
1856cdf0e10cSrcweir             long nVisHeight = rDocRect.GetHeight();
1857cdf0e10cSrcweir             pVScrollbar->SetVisibleSize( nVisHeight );
1858cdf0e10cSrcweir             pVScrollbar->SetThumbPos( rDocRect.Top() );
1859cdf0e10cSrcweir             pVScrollbar->SetLineSize( nVisHeight / 10 );
1860cdf0e10cSrcweir             pVScrollbar->SetPageSize( nVisHeight / 2 );
1861cdf0e10cSrcweir         }
1862cdf0e10cSrcweir     }
1863cdf0e10cSrcweir     if(pHScrollbar)
1864cdf0e10cSrcweir     {
1865ca62e2c2SSteve Yin         const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect();
1866cdf0e10cSrcweir         const Size& rPreviewSize =
1867cdf0e10cSrcweir                 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
1868cdf0e10cSrcweir         long nVisWidth = 0;
1869cdf0e10cSrcweir         long nThumb   = 0;
1870cdf0e10cSrcweir         Range aRange(0,0);
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir         if(rDocRect.GetWidth() < rPreviewSize.Width())
1873cdf0e10cSrcweir         {
1874cdf0e10cSrcweir             nVisWidth = rDocRect.GetWidth();
1875cdf0e10cSrcweir             nThumb = rDocRect.Left();
1876cdf0e10cSrcweir             aRange = Range(0, rPreviewSize.Width());
1877cdf0e10cSrcweir         }
1878cdf0e10cSrcweir         pHScrollbar->SetRange( aRange );
1879cdf0e10cSrcweir         pHScrollbar->SetVisibleSize( nVisWidth );
1880cdf0e10cSrcweir         pHScrollbar->SetThumbPos( nThumb );
1881cdf0e10cSrcweir         pHScrollbar->SetLineSize( nVisWidth / 10 );
1882cdf0e10cSrcweir         pHScrollbar->SetPageSize( nVisWidth / 2 );
1883cdf0e10cSrcweir     }
1884cdf0e10cSrcweir }
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir /*--------------------------------------------------------------------
1887cdf0e10cSrcweir 	Beschreibung:
1888cdf0e10cSrcweir  --------------------------------------------------------------------*/
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir 
ScrollDocSzChg()1891cdf0e10cSrcweir void SwPagePreView::ScrollDocSzChg()
1892cdf0e10cSrcweir {
1893cdf0e10cSrcweir     ScrollViewSzChg();
1894cdf0e10cSrcweir }
1895cdf0e10cSrcweir 
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir /*  */
1898cdf0e10cSrcweir /*--------------------------------------------------------------------
1899cdf0e10cSrcweir 	Beschreibung:
1900cdf0e10cSrcweir  --------------------------------------------------------------------*/
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir 
1903cdf0e10cSrcweir // alles zum Thema Drucken
1904cdf0e10cSrcweir 
GetPrinter(sal_Bool bCreate)1905cdf0e10cSrcweir SfxPrinter*  SwPagePreView::GetPrinter( sal_Bool bCreate )
1906cdf0e10cSrcweir {
1907ca62e2c2SSteve Yin     return pViewWin->GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate );
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir 
1910cdf0e10cSrcweir /*--------------------------------------------------------------------
1911cdf0e10cSrcweir 	Beschreibung:
1912cdf0e10cSrcweir  --------------------------------------------------------------------*/
1913cdf0e10cSrcweir 
1914cdf0e10cSrcweir 
SetPrinter(SfxPrinter * pNew,sal_uInt16 nDiffFlags,bool)1915cdf0e10cSrcweir sal_uInt16  SwPagePreView::SetPrinter( SfxPrinter *pNew, sal_uInt16 nDiffFlags, bool )
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir     ViewShell &rSh = *GetViewShell();
1918cdf0e10cSrcweir     SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
1919cdf0e10cSrcweir     if ( pOld && pOld->IsPrinting() )
1920cdf0e10cSrcweir         return SFX_PRINTERROR_BUSY;
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir 	SwEditShell &rESh = (SwEditShell&)rSh;	//Buh...
1923cdf0e10cSrcweir 	if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags )
1924cdf0e10cSrcweir 	{
1925cdf0e10cSrcweir         rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
1926cdf0e10cSrcweir 		if( nDiffFlags & SFX_PRINTER_PRINTER )
1927cdf0e10cSrcweir 			rESh.SetModified();
1928cdf0e10cSrcweir 	}
1929cdf0e10cSrcweir 	if ( ( nDiffFlags & SFX_PRINTER_OPTIONS ) == SFX_PRINTER_OPTIONS )
1930cdf0e10cSrcweir 		::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, sal_False );
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir 	const sal_Bool bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? sal_True : sal_False;
1933cdf0e10cSrcweir 	const sal_Bool bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? sal_True : sal_False;
1934cdf0e10cSrcweir 	if ( bChgOri || bChgSize )
1935cdf0e10cSrcweir 	{
1936cdf0e10cSrcweir 		rESh.StartAllAction();
1937cdf0e10cSrcweir 		if ( bChgOri )
1938cdf0e10cSrcweir 			rSh.ChgAllPageOrientation( sal_uInt16(pNew->GetOrientation()) );
1939cdf0e10cSrcweir 		if ( bChgSize )
1940cdf0e10cSrcweir 		{
1941cdf0e10cSrcweir 			Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
1942cdf0e10cSrcweir 			rSh.ChgAllPageSize( aSz );
1943cdf0e10cSrcweir 		}
1944cdf0e10cSrcweir 		if( !bNormalPrint )
1945ca62e2c2SSteve Yin 			pViewWin->CalcWish( pViewWin->GetRow(), pViewWin->GetCol() );
1946cdf0e10cSrcweir 		rESh.SetModified();
1947cdf0e10cSrcweir 		rESh.EndAllAction();
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir 		static sal_uInt16 __READONLY_DATA aInval[] =
1950cdf0e10cSrcweir 		{
1951cdf0e10cSrcweir 			SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
1952cdf0e10cSrcweir 			SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
1953cdf0e10cSrcweir 		};
1954cdf0e10cSrcweir #ifdef DBG_UTIL
1955cdf0e10cSrcweir 	{
1956cdf0e10cSrcweir 		const sal_uInt16* pPtr = aInval + 1;
1957cdf0e10cSrcweir 		do {
1958cdf0e10cSrcweir 			ASSERT( *(pPtr - 1) < *pPtr, "falsche Sortierung!" );
1959cdf0e10cSrcweir 		} while( *++pPtr );
1960cdf0e10cSrcweir 	}
1961cdf0e10cSrcweir #endif
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir 		GetViewFrame()->GetBindings().Invalidate(aInval);
1964cdf0e10cSrcweir 	}
1965cdf0e10cSrcweir 
1966cdf0e10cSrcweir 	return 0;
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir /*--------------------------------------------------------------------
1970cdf0e10cSrcweir 	Beschreibung:
1971cdf0e10cSrcweir  --------------------------------------------------------------------*/
1972cdf0e10cSrcweir 
1973cdf0e10cSrcweir 
CreatePrintOptionsPage(Window * pParent,const SfxItemSet & rOptions)1974cdf0e10cSrcweir SfxTabPage*  SwPagePreView::CreatePrintOptionsPage( Window *pParent,
1975cdf0e10cSrcweir 												const SfxItemSet &rOptions )
1976cdf0e10cSrcweir {
1977cdf0e10cSrcweir 	return ::CreatePrintOptionsPage( pParent, rOptions, !bNormalPrint );
1978cdf0e10cSrcweir }
1979cdf0e10cSrcweir 
1980cdf0e10cSrcweir /*--------------------------------------------------------------------
1981cdf0e10cSrcweir 	Beschreibung:
1982cdf0e10cSrcweir  --------------------------------------------------------------------*/
1983cdf0e10cSrcweir 
1984cdf0e10cSrcweir 
1985cdf0e10cSrcweir // OD 18.12.2002 #103492# - no longer needed ??
GetOptimalSizePixel() const1986cdf0e10cSrcweir Size  SwPagePreView::GetOptimalSizePixel() const
1987cdf0e10cSrcweir {
1988cdf0e10cSrcweir     ASSERT( false, "overloaded virtual method <SwPagePreView::GetOptimalSizePixel()> needed ??" )
1989cdf0e10cSrcweir     return Size( -1, -1 );
1990cdf0e10cSrcweir /*
1991cdf0e10cSrcweir     //JP 09.06.99: was wird hier errechnet ?????
1992cdf0e10cSrcweir // ALT:
1993cdf0e10cSrcweir //   SfxApplicationWindow* pWin = SFX_APPWINDOW ;
1994cdf0e10cSrcweir //   Rectangle aRect = pWin->GetClientAreaPixel();
1995cdf0e10cSrcweir 
1996cdf0e10cSrcweir 	Window& rWin = GetViewFrame()->GetWindow();
1997cdf0e10cSrcweir 	Rectangle aRect( Point(0, 0), rWin.GetOutputSizePixel() );
1998cdf0e10cSrcweir 	Size aMaxSize( aRect.GetWidth(), aRect.GetHeight() );
1999cdf0e10cSrcweir 	Size aInSize = rWin.GetOutputSizePixel();
2000cdf0e10cSrcweir 	Size aOutSize = rWin.GetSizePixel();
2001cdf0e10cSrcweir 	sal_uInt16 nXBorder = sal_uInt16(aOutSize.Width() - aInSize.Width());
2002cdf0e10cSrcweir 	sal_uInt16 nYBorder = sal_uInt16(aOutSize.Height() - aInSize.Height());
2003cdf0e10cSrcweir 	aMaxSize.Width() -= nXBorder;
2004cdf0e10cSrcweir 	//'auf Verdacht' etwas vom Border abziehen (Menue)
2005cdf0e10cSrcweir 	nYBorder -= (nYBorder - nXBorder) / 2;
2006cdf0e10cSrcweir 	aMaxSize.Height() -= nYBorder;
2007cdf0e10cSrcweir 	//mit der max. moeglichen Outputsize guenstigstes Verhaeltnis ausrechnen
2008ca62e2c2SSteve Yin 	pViewWin->GetOptimalSize(aMaxSize);
2009cdf0e10cSrcweir 	// Border wieder dazuzaehlen
2010cdf0e10cSrcweir 	aMaxSize.Height() += nYBorder;
2011cdf0e10cSrcweir 	aMaxSize.Width() += nXBorder;
2012cdf0e10cSrcweir 	return aMaxSize;
2013cdf0e10cSrcweir */
2014cdf0e10cSrcweir }
2015cdf0e10cSrcweir 
2016cdf0e10cSrcweir /*--------------------------------------------------------------------
2017cdf0e10cSrcweir 	Beschreibung:
2018cdf0e10cSrcweir  --------------------------------------------------------------------*/
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir // OD 12.12.2002 #103492#
SetViewShell(ViewShell * pShell)2021cdf0e10cSrcweir void SwPagePreViewWin::SetViewShell( ViewShell* pShell )
2022cdf0e10cSrcweir {
2023cdf0e10cSrcweir     mpViewShell = pShell;
2024cdf0e10cSrcweir     if ( mpViewShell && mpViewShell->IsPreView() )
2025cdf0e10cSrcweir     {
2026cdf0e10cSrcweir         mpPgPrevwLayout = mpViewShell->PagePreviewLayout();
2027cdf0e10cSrcweir     }
2028cdf0e10cSrcweir }
2029cdf0e10cSrcweir 
RepaintCoreRect(const SwRect & rRect)2030cdf0e10cSrcweir void SwPagePreViewWin::RepaintCoreRect( const SwRect& rRect )
2031cdf0e10cSrcweir {
2032cdf0e10cSrcweir     // OD 2004-03-04 #i24183#
2033cdf0e10cSrcweir     if ( mpPgPrevwLayout->PreviewLayoutValid() )
2034cdf0e10cSrcweir     {
2035cdf0e10cSrcweir         mpPgPrevwLayout->Repaint( Rectangle( rRect.Pos(), rRect.SSize() ) );
2036cdf0e10cSrcweir     }
2037cdf0e10cSrcweir }
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir /** method to adjust preview to a new zoom factor
2040cdf0e10cSrcweir 
2041cdf0e10cSrcweir     OD 02.12.2002 #103492#
2042cdf0e10cSrcweir     OD 24.09.2003 #i19975# - also consider zoom type - adding parameter <_eZoomType>
2043cdf0e10cSrcweir */
AdjustPreviewToNewZoom(const sal_uInt16 _nZoomFactor,const SvxZoomType _eZoomType)2044cdf0e10cSrcweir void SwPagePreViewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
2045cdf0e10cSrcweir                                                const SvxZoomType _eZoomType )
2046cdf0e10cSrcweir {
2047cdf0e10cSrcweir     // OD 24.09.2003 #i19975# - consider zoom type
2048cdf0e10cSrcweir     if ( _eZoomType == SVX_ZOOM_WHOLEPAGE )
2049cdf0e10cSrcweir     {
2050cdf0e10cSrcweir         mnRow = 1;
2051cdf0e10cSrcweir         mnCol = 1;
2052cdf0e10cSrcweir         mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true );
2053cdf0e10cSrcweir         mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
2054cdf0e10cSrcweir                                   mnSttPage, maPaintedPreviewDocRect );
2055cdf0e10cSrcweir         SetSelectedPage( mnSttPage );
2056cdf0e10cSrcweir         SetPagePreview(mnRow, mnCol);
2057cdf0e10cSrcweir         maScale = GetMapMode().GetScaleX();
2058cdf0e10cSrcweir     }
2059cdf0e10cSrcweir     else if ( _nZoomFactor != 0 )
2060cdf0e10cSrcweir     {
2061cdf0e10cSrcweir         // calculate new scaling and set mapping mode appropriately.
2062cdf0e10cSrcweir         Fraction aNewScale( _nZoomFactor, 100 );
2063cdf0e10cSrcweir         MapMode aNewMapMode = GetMapMode();
2064cdf0e10cSrcweir         aNewMapMode.SetScaleX( aNewScale );
2065cdf0e10cSrcweir         aNewMapMode.SetScaleY( aNewScale );
2066cdf0e10cSrcweir         SetMapMode( aNewMapMode );
2067cdf0e10cSrcweir 
2068cdf0e10cSrcweir         // calculate new start position for preview paint
2069cdf0e10cSrcweir         Size aNewWinSize = PixelToLogic( maPxWinSize );
2070cdf0e10cSrcweir         Point aNewPaintStartPos =
2071cdf0e10cSrcweir                 mpPgPrevwLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir         // remember new scaling and prepare preview paint
2074cdf0e10cSrcweir         // Note: paint of preview will be performed by a corresponding invalidate
2075cdf0e10cSrcweir         //          due to property changes.
2076cdf0e10cSrcweir         maScale = aNewScale;
2077cdf0e10cSrcweir         mpPgPrevwLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
2078cdf0e10cSrcweir                                   mnSttPage, maPaintedPreviewDocRect );
2079cdf0e10cSrcweir     }
2080cdf0e10cSrcweir 
2081cdf0e10cSrcweir }
2082cdf0e10cSrcweir /* -----------------04.12.2002 10:46-----------------
2083cdf0e10cSrcweir  * pixel scrolling - horizontally always or vertically
2084cdf0e10cSrcweir  * when less than the desired number of rows fits into
2085cdf0e10cSrcweir  * the view
2086cdf0e10cSrcweir  * --------------------------------------------------*/
Scroll(long nXMove,long nYMove,sal_uInt16)2087cdf0e10cSrcweir void SwPagePreViewWin::Scroll(long nXMove, long nYMove, sal_uInt16 /*nFlags*/)
2088cdf0e10cSrcweir {
2089cdf0e10cSrcweir     maPaintedPreviewDocRect.Move(nXMove, nYMove);
2090cdf0e10cSrcweir     mpPgPrevwLayout->Prepare( 0, maPaintedPreviewDocRect.TopLeft(),
2091cdf0e10cSrcweir                               maPxWinSize, mnSttPage,
2092cdf0e10cSrcweir                               maPaintedPreviewDocRect );
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir }
2095cdf0e10cSrcweir 
HandleWheelCommands(const CommandEvent & rCEvt)2096cdf0e10cSrcweir sal_Bool SwPagePreView::HandleWheelCommands( const CommandEvent& rCEvt )
2097cdf0e10cSrcweir {
2098cdf0e10cSrcweir 	sal_Bool bOk = sal_False;
2099cdf0e10cSrcweir 	const CommandWheelData* pWData = rCEvt.GetWheelData();
2100cdf0e10cSrcweir 	if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
2101cdf0e10cSrcweir 	{
2102ca62e2c2SSteve Yin 	//IAccessibility2 Implementation 2009-----, only the Preference shouldn't control the Zoom, it is better to detect AT tools running. So the bridge can be used here
2103ca62e2c2SSteve Yin         //if(!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport())
2104ca62e2c2SSteve Yin 	if ( !Application::IsAccessibilityEnabled() )
2105cdf0e10cSrcweir         {
2106cdf0e10cSrcweir             sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom();
2107cdf0e10cSrcweir             const sal_uInt16 nOffset = 10;
2108cdf0e10cSrcweir             if( 0L > pWData->GetDelta() )
2109cdf0e10cSrcweir             {
2110cdf0e10cSrcweir                 nFactor -= nOffset;
2111cdf0e10cSrcweir                 if(nFactor < MIN_PREVIEW_ZOOM)
2112cdf0e10cSrcweir                         nFactor = MIN_PREVIEW_ZOOM;
2113cdf0e10cSrcweir             }
2114cdf0e10cSrcweir             else
2115cdf0e10cSrcweir             {
2116cdf0e10cSrcweir                 nFactor += nOffset;
2117cdf0e10cSrcweir                 if(nFactor > MAX_PREVIEW_ZOOM)
2118cdf0e10cSrcweir                         nFactor = MAX_PREVIEW_ZOOM;
2119cdf0e10cSrcweir             }
2120cdf0e10cSrcweir             SetZoom(SVX_ZOOM_PERCENT, nFactor);
2121cdf0e10cSrcweir         }
2122cdf0e10cSrcweir 		bOk = sal_True;
2123cdf0e10cSrcweir 	}
2124cdf0e10cSrcweir 	else
2125ca62e2c2SSteve Yin         bOk = pViewWin->HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
2126cdf0e10cSrcweir 	return bOk;
2127cdf0e10cSrcweir }
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir 
2130cdf0e10cSrcweir uno::Reference< ::com::sun::star::accessibility::XAccessible >
CreateAccessible()2131cdf0e10cSrcweir     SwPagePreViewWin::CreateAccessible()
2132cdf0e10cSrcweir {
2133cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());	// this should have
2134cdf0e10cSrcweir 														// happend already!!!
2135cdf0e10cSrcweir 
2136cdf0e10cSrcweir     DBG_ASSERT( GetViewShell() != NULL, "We need a view shell" );
2137ca62e2c2SSteve Yin 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc = GetAccessible( sal_False );
2138ca62e2c2SSteve Yin 	if (xAcc.is())
2139ca62e2c2SSteve Yin 	{
2140ca62e2c2SSteve Yin 		return xAcc;
2141ca62e2c2SSteve Yin 	}
2142ca62e2c2SSteve Yin 	if (mpViewShell)
2143ca62e2c2SSteve Yin 	{
2144ca62e2c2SSteve Yin 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview();
2145ca62e2c2SSteve Yin 		SetAccessible(xAccPreview);
2146ca62e2c2SSteve Yin 	}
2147ca62e2c2SSteve Yin 	return GetAccessible( sal_False );
2148ca62e2c2SSteve Yin }
2149ca62e2c2SSteve Yin // MT: Removed Windows::SwitchView() introduced with IA2 CWS.
2150ca62e2c2SSteve Yin // There are other notifications for this when the active view has chnaged, so please update the code to use that event mechanism
SwitchView()2151ca62e2c2SSteve Yin void SwPagePreViewWin::SwitchView()
2152ca62e2c2SSteve Yin {
2153ca62e2c2SSteve Yin #ifdef ACCESSIBLE_LAYOUT
2154ca62e2c2SSteve Yin 	if (!Application::IsAccessibilityEnabled())
2155ca62e2c2SSteve Yin 	{
2156ca62e2c2SSteve Yin 		return ;
2157ca62e2c2SSteve Yin 	}
2158ca62e2c2SSteve Yin 	if (mpViewShell)
2159ca62e2c2SSteve Yin 	{
2160ca62e2c2SSteve Yin 		mpViewShell->InvalidateAccessibleFocus();
2161ca62e2c2SSteve Yin 	}
2162ca62e2c2SSteve Yin #endif
2163cdf0e10cSrcweir }
2164cdf0e10cSrcweir 
2165cdf0e10cSrcweir /* -----------------------------06.05.2002 13:18------------------------------
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
ApplyAccessiblityOptions(SvtAccessibilityOptions & rAccessibilityOptions)2168cdf0e10cSrcweir void SwPagePreView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
2169cdf0e10cSrcweir {
2170cdf0e10cSrcweir     GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions);
2171cdf0e10cSrcweir }
2172cdf0e10cSrcweir /* -----------------------------2002/06/26 14:30------------------------------
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
ShowHScrollbar(sal_Bool bShow)2175cdf0e10cSrcweir void SwPagePreView::ShowHScrollbar(sal_Bool bShow)
2176cdf0e10cSrcweir {
2177cdf0e10cSrcweir     pHScrollbar->Show(bShow);
2178cdf0e10cSrcweir 	InvalidateBorder();
2179cdf0e10cSrcweir }
2180cdf0e10cSrcweir 
2181cdf0e10cSrcweir /* -----------------------------2002/06/26 14:30------------------------------
2182cdf0e10cSrcweir 
2183cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
ShowVScrollbar(sal_Bool bShow)2184cdf0e10cSrcweir void SwPagePreView::ShowVScrollbar(sal_Bool bShow)
2185cdf0e10cSrcweir {
2186cdf0e10cSrcweir     pVScrollbar->Show(bShow);
2187cdf0e10cSrcweir 	InvalidateBorder();
2188cdf0e10cSrcweir }
2189cdf0e10cSrcweir 
2190cdf0e10cSrcweir /* -----------------25.11.2002 16:36-----------------
2191cdf0e10cSrcweir  *
2192cdf0e10cSrcweir  * --------------------------------------------------*/
SetZoom(SvxZoomType eType,sal_uInt16 nFactor)2193cdf0e10cSrcweir void SwPagePreView::SetZoom(SvxZoomType eType, sal_uInt16 nFactor)
2194cdf0e10cSrcweir {
2195cdf0e10cSrcweir     ViewShell& rSh = *GetViewShell();
2196cdf0e10cSrcweir     SwViewOption aOpt(*rSh.GetViewOptions());
2197cdf0e10cSrcweir     // OD 16.12.2002 #103492# - perform action only on changes of zoom or zoom type.
2198cdf0e10cSrcweir     if ( aOpt.GetZoom() != nFactor ||
2199cdf0e10cSrcweir          aOpt.GetZoomType() != eType )
2200cdf0e10cSrcweir     {
2201cdf0e10cSrcweir         aOpt.SetZoom(nFactor);
2202cdf0e10cSrcweir         aOpt.SetZoomType(eType);
2203cdf0e10cSrcweir         rSh.ApplyViewOptions( aOpt );
2204cdf0e10cSrcweir         lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
2205cdf0e10cSrcweir         // OD 02.12.2002 #103492#
2206cdf0e10cSrcweir         // OD 24.09.2003 #i19975# - also consider zoom type
2207ca62e2c2SSteve Yin         pViewWin->AdjustPreviewToNewZoom( nFactor, eType );
2208cdf0e10cSrcweir         ScrollViewSzChg();
2209cdf0e10cSrcweir     }
2210cdf0e10cSrcweir }
2211cdf0e10cSrcweir 
2212cdf0e10cSrcweir /** adjust position of vertical scrollbar
2213cdf0e10cSrcweir 
2214cdf0e10cSrcweir     OD 19.02.2003 #107369
2215cdf0e10cSrcweir 
2216cdf0e10cSrcweir     @author OD
2217cdf0e10cSrcweir */
SetVScrollbarThumbPos(const sal_uInt16 _nNewThumbPos)2218cdf0e10cSrcweir void SwPagePreView::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
2219cdf0e10cSrcweir {
2220cdf0e10cSrcweir     if ( pVScrollbar )
2221cdf0e10cSrcweir     {
2222cdf0e10cSrcweir         pVScrollbar->SetThumbPos( _nNewThumbPos );
2223cdf0e10cSrcweir     }
2224cdf0e10cSrcweir }
2225