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