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