xref: /aoo42x/main/sc/source/ui/view/prevwsh.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "scitems.hxx"
36*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <sfx2/app.hxx>
39*cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
40*cdf0e10cSrcweir #include <svl/srchitem.hxx>
41*cdf0e10cSrcweir #include <svx/zoomslideritem.hxx>
42*cdf0e10cSrcweir #include <svx/svdview.hxx>
43*cdf0e10cSrcweir //CHINA001 #include <svx/zoom.hxx>
44*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
45*cdf0e10cSrcweir #include <sfx2/objface.hxx>
46*cdf0e10cSrcweir #include <sfx2/request.hxx>
47*cdf0e10cSrcweir #include <svl/stritem.hxx>
48*cdf0e10cSrcweir #include <svl/whiter.hxx>
49*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
50*cdf0e10cSrcweir #include <vcl/help.hxx>
51*cdf0e10cSrcweir #include <tools/urlobj.hxx>
52*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
53*cdf0e10cSrcweir #include <sfx2/printer.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #ifndef _SVX_ZOOMSLIDERITEM_HXX
56*cdf0e10cSrcweir #include <svx/zoomslideritem.hxx>
57*cdf0e10cSrcweir #endif
58*cdf0e10cSrcweir #include "prevwsh.hxx"
59*cdf0e10cSrcweir #include "preview.hxx"
60*cdf0e10cSrcweir #include "printfun.hxx"
61*cdf0e10cSrcweir #include "attrib.hxx"
62*cdf0e10cSrcweir #include "scmod.hxx"
63*cdf0e10cSrcweir #include "inputhdl.hxx"
64*cdf0e10cSrcweir #include "docsh.hxx"
65*cdf0e10cSrcweir #include "tabvwsh.hxx"
66*cdf0e10cSrcweir #include "stlpool.hxx"
67*cdf0e10cSrcweir #include "editutil.hxx"
68*cdf0e10cSrcweir #include "scresid.hxx"
69*cdf0e10cSrcweir #include "globstr.hrc"
70*cdf0e10cSrcweir #include "sc.hrc"
71*cdf0e10cSrcweir #include "ViewSettingsSequenceDefines.hxx"
72*cdf0e10cSrcweir #include "tpprint.hxx"
73*cdf0e10cSrcweir #include "printopt.hxx"
74*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
75*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
78*cdf0e10cSrcweir #include <svx/dialogs.hrc> //CHINA001
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir #ifndef _SVX_ZOOM_HXX
81*cdf0e10cSrcweir #include <svx/zoom_def.hxx>
82*cdf0e10cSrcweir #endif
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir #include "sc.hrc" //CHINA001
85*cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001
86*cdf0e10cSrcweir //	fuer Rad-Maus
87*cdf0e10cSrcweir #define SC_DELTA_ZOOM	10
88*cdf0e10cSrcweir #define MINZOOM_SLIDER 10
89*cdf0e10cSrcweir #define MAXZOOM_SLIDER 400
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir #define SC_USERDATA_SEP	';'
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir using namespace com::sun::star;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir // -----------------------------------------------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir #define ScPreviewShell
98*cdf0e10cSrcweir #include "scslots.hxx"
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir TYPEINIT1( ScPreviewShell, SfxViewShell );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir SFX_IMPL_INTERFACE( ScPreviewShell, SfxViewShell, ScResId(SCSTR_PREVIEWSHELL) )
103*cdf0e10cSrcweir {
104*cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
105*cdf0e10cSrcweir 								SFX_VISIBILITY_SERVER|SFX_VISIBILITY_READONLYDOC,
106*cdf0e10cSrcweir 								ScResId(RID_OBJECTBAR_PREVIEW));
107*cdf0e10cSrcweir 	SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_PREVIEW));
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir SFX_IMPL_NAMED_VIEWFACTORY( ScPreviewShell, "PrintPreview" )
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	SFX_VIEW_REGISTRATION(ScDocShell);
113*cdf0e10cSrcweir }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir //------------------------------------------------------------------
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir void ScPreviewShell::Construct( Window* pParent )
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir 	eZoom = SVX_ZOOM_WHOLEPAGE;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	pCorner = new ScrollBarBox( pParent, WB_SIZEABLE );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	pHorScroll = new ScrollBar(pParent, WB_HSCROLL );
124*cdf0e10cSrcweir 	pVerScroll = new ScrollBar(pParent, WB_VSCROLL);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     // SSA: --- RTL --- no mirroring for horizontal scrollbars
127*cdf0e10cSrcweir     pHorScroll->EnableRTL( sal_False );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	pHorScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) );
130*cdf0e10cSrcweir 	pVerScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 	pPreview = new ScPreview( pParent, pDocShell, this );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	SetPool( &SC_MOD()->GetPool() );
135*cdf0e10cSrcweir 	SetWindow( pPreview );
136*cdf0e10cSrcweir     StartListening(*pDocShell,sal_True);
137*cdf0e10cSrcweir     StartListening(*SFX_APP(),sal_True);        // #i62045# #i62046# application is needed for Calc's own hints
138*cdf0e10cSrcweir 	SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
139*cdf0e10cSrcweir 	if (pDrawBC)
140*cdf0e10cSrcweir 		StartListening(*pDrawBC);
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	pHorScroll->Show();
143*cdf0e10cSrcweir 	pVerScroll->Show();
144*cdf0e10cSrcweir 	pCorner->Show();
145*cdf0e10cSrcweir 	SetHelpId( HID_SCSHELL_PREVWSH );
146*cdf0e10cSrcweir 	SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Preview")));
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
150*cdf0e10cSrcweir 								SfxViewShell* pOldSh ) :
151*cdf0e10cSrcweir 	SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
152*cdf0e10cSrcweir 	pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ),
153*cdf0e10cSrcweir 	nSourceDesignMode( SC_FORCEMODE_NONE ),
154*cdf0e10cSrcweir 	pAccessibilityBroadcaster( NULL )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	Construct( &pViewFrame->GetWindow() );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	if ( pOldSh && pOldSh->ISA( ScTabViewShell ) )
159*cdf0e10cSrcweir 	{
160*cdf0e10cSrcweir 		//	store view settings, show table from TabView
161*cdf0e10cSrcweir 		//!	store live ScViewData instead, and update on ScTablesHint?
162*cdf0e10cSrcweir 		//!	or completely forget aSourceData on ScTablesHint?
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 		ScTabViewShell* pTabViewShell = ((ScTabViewShell*)pOldSh);
165*cdf0e10cSrcweir 		ScViewData* pData = pTabViewShell->GetViewData();
166*cdf0e10cSrcweir 		pData->WriteUserDataSequence( aSourceData );
167*cdf0e10cSrcweir 		InitStartTable( pData->GetTabNo() );
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 		//	#106334# also have to store the TabView's DesignMode state
170*cdf0e10cSrcweir 		//	(only if draw view exists)
171*cdf0e10cSrcweir 		SdrView* pDrawView = pTabViewShell->GetSdrView();
172*cdf0e10cSrcweir 		if ( pDrawView )
173*cdf0e10cSrcweir 			nSourceDesignMode = pDrawView->IsDesignMode();
174*cdf0e10cSrcweir 	}
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir __EXPORT ScPreviewShell::~ScPreviewShell()
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir     // #108333#; notify Accessibility that Shell is dying and before destroy all
180*cdf0e10cSrcweir     BroadcastAccessibility( SfxSimpleHint( SFX_HINT_DYING ) );
181*cdf0e10cSrcweir     DELETEZ(pAccessibilityBroadcaster);
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
184*cdf0e10cSrcweir 	if (pDrawBC)
185*cdf0e10cSrcweir 		EndListening(*pDrawBC);
186*cdf0e10cSrcweir 	EndListening(*SFX_APP());
187*cdf0e10cSrcweir 	EndListening(*pDocShell);
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	SetWindow(0);
190*cdf0e10cSrcweir 	delete pPreview;
191*cdf0e10cSrcweir 	delete pHorScroll;
192*cdf0e10cSrcweir 	delete pVerScroll;
193*cdf0e10cSrcweir 	delete pCorner;
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	//	#97612# normal mode of operation is switching back to default view in the same frame,
196*cdf0e10cSrcweir 	//	so there's no need to activate any other window here anymore
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir void ScPreviewShell::InitStartTable(SCTAB nTab)
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	pPreview->SetPageNo( pPreview->GetFirstPage(nTab) );
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir //------------------------------------------------------------------
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir String __EXPORT ScPreviewShell::GetDescription() const
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** "));
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir Size __EXPORT ScPreviewShell::GetOptimalSizePixel() const
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir 	Size aOptSize(100,100);
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 	ScTabViewShell*     pViewSh = pDocShell->GetBestViewShell();
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 	if ( pViewSh )
218*cdf0e10cSrcweir 	{
219*cdf0e10cSrcweir 		ScViewData*			pViewData	= pViewSh->GetViewData();
220*cdf0e10cSrcweir 		SCTAB				nCurTab		= pViewData->GetTabNo();
221*cdf0e10cSrcweir 		ScDocument*			pDoc		= pDocShell->GetDocument();
222*cdf0e10cSrcweir 		ScStyleSheetPool*	pStylePool  = pDoc->GetStyleSheetPool();
223*cdf0e10cSrcweir 		SfxStyleSheetBase*	pStyleSheet = pStylePool->Find(
224*cdf0e10cSrcweir 											pDoc->GetPageStyle( nCurTab ),
225*cdf0e10cSrcweir 											SFX_STYLE_FAMILY_PAGE );
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 		DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 		if ( pStyleSheet )
230*cdf0e10cSrcweir 		{
231*cdf0e10cSrcweir 			const SfxItemSet&  rSet 	 = pStyleSheet->GetItemSet();
232*cdf0e10cSrcweir 			const SvxSizeItem& rItem	 = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE );
233*cdf0e10cSrcweir 			const Size&		   rPageSize = rItem.GetSize();
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 			aOptSize.Width()  = (long) (rPageSize.Width()  * pViewData->GetPPTX());
236*cdf0e10cSrcweir 			aOptSize.Height() = (long) (rPageSize.Height() * pViewData->GetPPTY());
237*cdf0e10cSrcweir 		}
238*cdf0e10cSrcweir 	}
239*cdf0e10cSrcweir 	else
240*cdf0e10cSrcweir 	{
241*cdf0e10cSrcweir 		DBG_ERROR( "TabViewShell not found :-/" );
242*cdf0e10cSrcweir 	}
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	return aOptSize;
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir void __EXPORT ScPreviewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
248*cdf0e10cSrcweir {
249*cdf0e10cSrcweir 	long nBarW = GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetScrollBarSize();
250*cdf0e10cSrcweir 	long nBarH = nBarW;
251*cdf0e10cSrcweir //	long nBarW = pVerScroll->GetSizePixel().Width();
252*cdf0e10cSrcweir //	long nBarH = pHorScroll->GetSizePixel().Height();
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	Size aOutSize( rSize.Width()-nBarW, rSize.Height()-nBarH );
255*cdf0e10cSrcweir 	pPreview->SetPosSizePixel( rPos, aOutSize );
256*cdf0e10cSrcweir 	pHorScroll->SetPosSizePixel( Point( rPos.X(), rPos.Y() + aOutSize.Height() ),
257*cdf0e10cSrcweir 								 Size( aOutSize.Width(), nBarH ) );
258*cdf0e10cSrcweir 	pVerScroll->SetPosSizePixel( Point( rPos.X() + aOutSize.Width(), rPos.Y() ),
259*cdf0e10cSrcweir 								 Size( nBarW, aOutSize.Height() ) );
260*cdf0e10cSrcweir 	pCorner->SetPosSizePixel( Point( rPos.X() + aOutSize.Width(), rPos.Y() + aOutSize.Height() ),
261*cdf0e10cSrcweir 							  Size( nBarW, nBarH ) );
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir 	if ( SVX_ZOOM_WHOLEPAGE == eZoom )
264*cdf0e10cSrcweir 		pPreview->SetZoom( pPreview->GetOptimalZoom(sal_False) );
265*cdf0e10cSrcweir 	else if ( SVX_ZOOM_PAGEWIDTH == eZoom )
266*cdf0e10cSrcweir 		pPreview->SetZoom( pPreview->GetOptimalZoom(sal_True) );
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 	UpdateScrollBars();
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir void __EXPORT ScPreviewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	AdjustPosSizePixel( rOfs,rSize );
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir void __EXPORT ScPreviewShell::OuterResizePixel( const Point &rOfs, const Size &rSize )
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	AdjustPosSizePixel( rOfs,rSize );
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir void ScPreviewShell::UpdateScrollBars()
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
284*cdf0e10cSrcweir 	SCTAB nTab = pPreview->GetTab();
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	ScStyleSheetPool*	pStylePool	= pDoc->GetStyleSheetPool();
287*cdf0e10cSrcweir 	SfxStyleSheetBase*	pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ),
288*cdf0e10cSrcweir 														SFX_STYLE_FAMILY_PAGE );
289*cdf0e10cSrcweir 	DBG_ASSERT(pStyleSheet,"StyleSheet nicht gefunden");
290*cdf0e10cSrcweir 	if (!pStyleSheet) return;
291*cdf0e10cSrcweir 	const SfxItemSet* pParamSet = &pStyleSheet->GetItemSet();
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	Size aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
294*cdf0e10cSrcweir 	aPageSize.Width()  = (long) (aPageSize.Width()  * HMM_PER_TWIPS );
295*cdf0e10cSrcweir 	aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS );
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 	//	for centering, page size without the shadow is used
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 	Size aWindowSize = pPreview->GetOutputSize();
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 	Point aOfs = pPreview->GetOffset();
302*cdf0e10cSrcweir 	long nMaxPos;
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     if( pHorScroll )
305*cdf0e10cSrcweir     {
306*cdf0e10cSrcweir         pHorScroll->SetRange( Range( 0, aPageSize.Width() ) );
307*cdf0e10cSrcweir         pHorScroll->SetLineSize( aWindowSize.Width() / 16 );
308*cdf0e10cSrcweir         pHorScroll->SetPageSize( aWindowSize.Width() );
309*cdf0e10cSrcweir         pHorScroll->SetVisibleSize( aWindowSize.Width() );
310*cdf0e10cSrcweir         nMaxPos = aPageSize.Width() - aWindowSize.Width();
311*cdf0e10cSrcweir         if ( nMaxPos<0 )
312*cdf0e10cSrcweir         {
313*cdf0e10cSrcweir             //	page smaller than window -> center (but put scrollbar to 0)
314*cdf0e10cSrcweir             aOfs.X() = 0;
315*cdf0e10cSrcweir             pPreview->SetXOffset( nMaxPos / 2 );
316*cdf0e10cSrcweir         }
317*cdf0e10cSrcweir         else if (aOfs.X() < 0)
318*cdf0e10cSrcweir         {
319*cdf0e10cSrcweir             //	page larger than window -> never use negative offset
320*cdf0e10cSrcweir             aOfs.X() = 0;
321*cdf0e10cSrcweir             pPreview->SetXOffset( 0 );
322*cdf0e10cSrcweir         }
323*cdf0e10cSrcweir         else if (aOfs.X() > nMaxPos)
324*cdf0e10cSrcweir         {
325*cdf0e10cSrcweir             //	limit offset to align with right edge of window
326*cdf0e10cSrcweir             aOfs.X() = nMaxPos;
327*cdf0e10cSrcweir             pPreview->SetXOffset(nMaxPos);
328*cdf0e10cSrcweir         }
329*cdf0e10cSrcweir         pHorScroll->SetThumbPos( aOfs.X() );
330*cdf0e10cSrcweir     }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir     if( pVerScroll )
333*cdf0e10cSrcweir     {
334*cdf0e10cSrcweir         long nPageNo     = pPreview->GetPageNo();
335*cdf0e10cSrcweir         long nTotalPages = pPreview->GetTotalPages();
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir         nMaxVertPos = aPageSize.Height() - aWindowSize.Height();
338*cdf0e10cSrcweir         pVerScroll->SetLineSize( aWindowSize.Height() / 16  );
339*cdf0e10cSrcweir         pVerScroll->SetPageSize( aWindowSize.Height() );
340*cdf0e10cSrcweir         pVerScroll->SetVisibleSize( aWindowSize.Height() );
341*cdf0e10cSrcweir         if ( nMaxVertPos < 0 )
342*cdf0e10cSrcweir         {
343*cdf0e10cSrcweir             //	page smaller than window -> center (but put scrollbar to 0)
344*cdf0e10cSrcweir             aOfs.Y() = 0;
345*cdf0e10cSrcweir             pPreview->SetYOffset( nMaxVertPos / 2 );
346*cdf0e10cSrcweir             pVerScroll->SetThumbPos( nPageNo * aWindowSize.Height() );
347*cdf0e10cSrcweir             pVerScroll->SetRange( Range( 0, aWindowSize.Height() * nTotalPages ));
348*cdf0e10cSrcweir         }
349*cdf0e10cSrcweir         else if (aOfs.Y() < 0)
350*cdf0e10cSrcweir         {
351*cdf0e10cSrcweir             //	page larger than window -> never use negative offset
352*cdf0e10cSrcweir             pVerScroll->SetRange( Range( 0, aPageSize.Height() ) );
353*cdf0e10cSrcweir             aOfs.Y() = 0;
354*cdf0e10cSrcweir             pPreview->SetYOffset( 0 );
355*cdf0e10cSrcweir             pVerScroll->SetThumbPos( aOfs.Y() );
356*cdf0e10cSrcweir         }
357*cdf0e10cSrcweir         else if (aOfs.Y() > nMaxVertPos )
358*cdf0e10cSrcweir         {
359*cdf0e10cSrcweir             //	limit offset to align with window bottom
360*cdf0e10cSrcweir             pVerScroll->SetRange( Range( 0, aPageSize.Height() ) );
361*cdf0e10cSrcweir             aOfs.Y() = nMaxVertPos;
362*cdf0e10cSrcweir             pPreview->SetYOffset( nMaxVertPos );
363*cdf0e10cSrcweir             pVerScroll->SetThumbPos( aOfs.Y() );
364*cdf0e10cSrcweir         }
365*cdf0e10cSrcweir     }
366*cdf0e10cSrcweir }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir IMPL_LINK (ScPreviewShell,ScrollHandler, ScrollBar* ,pScroll )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     long nPos           = pScroll->GetThumbPos();
371*cdf0e10cSrcweir     long nDelta         = pScroll->GetDelta();
372*cdf0e10cSrcweir     long nMaxRange      = pScroll->GetRangeMax();
373*cdf0e10cSrcweir     long nTotalPages    = pPreview->GetTotalPages();
374*cdf0e10cSrcweir     long nPageNo        = 0;
375*cdf0e10cSrcweir     long nPerPageLength = 0;
376*cdf0e10cSrcweir     sal_Bool bIsDivide      = sal_True;
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir     if( nTotalPages )
379*cdf0e10cSrcweir         nPerPageLength = nMaxRange / nTotalPages;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir     if( nPerPageLength )
382*cdf0e10cSrcweir     {
383*cdf0e10cSrcweir         nPageNo = nPos / nPerPageLength;
384*cdf0e10cSrcweir         if( nPos % nPerPageLength )
385*cdf0e10cSrcweir         {
386*cdf0e10cSrcweir             bIsDivide = sal_False;
387*cdf0e10cSrcweir             nPageNo ++;
388*cdf0e10cSrcweir         }
389*cdf0e10cSrcweir     }
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir     sal_Bool bHoriz = ( pScroll == pHorScroll );
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     if( bHoriz )
394*cdf0e10cSrcweir         pPreview->SetXOffset( nPos );
395*cdf0e10cSrcweir     else
396*cdf0e10cSrcweir     {
397*cdf0e10cSrcweir         if( nMaxVertPos > 0 )
398*cdf0e10cSrcweir             pPreview->SetYOffset( nPos );
399*cdf0e10cSrcweir         else
400*cdf0e10cSrcweir         {
401*cdf0e10cSrcweir             Point  aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() );
402*cdf0e10cSrcweir             Point  aPos      = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() );
403*cdf0e10cSrcweir             String aHelpStr;
404*cdf0e10cSrcweir             Rectangle aRect;
405*cdf0e10cSrcweir             sal_uInt16   nAlign;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir             if( nDelta < 0 )
408*cdf0e10cSrcweir             {
409*cdf0e10cSrcweir                 if ( nTotalPages && nPageNo > 0 && !bIsDivide )
410*cdf0e10cSrcweir                     pPreview->SetPageNo( nPageNo-1 );
411*cdf0e10cSrcweir                 if( bIsDivide )
412*cdf0e10cSrcweir                     pPreview->SetPageNo( nPageNo );
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir                 aHelpStr = ScGlobal::GetRscString( STR_PAGE );
415*cdf0e10cSrcweir                 aHelpStr += ' ';
416*cdf0e10cSrcweir                 aHelpStr += String::CreateFromInt32( nPageNo );
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir                 aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
419*cdf0e10cSrcweir                 aHelpStr += String::CreateFromInt32( nTotalPages );
420*cdf0e10cSrcweir             }
421*cdf0e10cSrcweir             else if( nDelta > 0 )
422*cdf0e10cSrcweir             {
423*cdf0e10cSrcweir                 sal_Bool bAllTested	= pPreview->AllTested();
424*cdf0e10cSrcweir                 if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) )
425*cdf0e10cSrcweir                     pPreview->SetPageNo( nPageNo );
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir                 aHelpStr = ScGlobal::GetRscString( STR_PAGE );
428*cdf0e10cSrcweir                 aHelpStr += ' ';
429*cdf0e10cSrcweir                 aHelpStr += String::CreateFromInt32( nPageNo+1 );
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir                 aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
432*cdf0e10cSrcweir                 aHelpStr += String::CreateFromInt32( nTotalPages );
433*cdf0e10cSrcweir             }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir             aRect.Left()    = aPos.X() - 8;
436*cdf0e10cSrcweir             aRect.Top()	    = aMousePos.Y();
437*cdf0e10cSrcweir             aRect.Right() 	= aRect.Left();
438*cdf0e10cSrcweir             aRect.Top()		= aRect.Top();
439*cdf0e10cSrcweir             nAlign		    = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
440*cdf0e10cSrcweir             Help::ShowQuickHelp( pScroll->GetParent(), aRect, aHelpStr, nAlign );
441*cdf0e10cSrcweir         }
442*cdf0e10cSrcweir     }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 	return 0;
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir sal_Bool ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt )
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
450*cdf0e10cSrcweir 	const CommandWheelData* pData = rCEvt.GetWheelData();
451*cdf0e10cSrcweir 	if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM )
452*cdf0e10cSrcweir 	{
453*cdf0e10cSrcweir 		long nOld = pPreview->GetZoom();
454*cdf0e10cSrcweir 		long nNew = nOld;
455*cdf0e10cSrcweir 		if ( pData->GetDelta() < 0 )
456*cdf0e10cSrcweir 			nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) );
457*cdf0e10cSrcweir 		else
458*cdf0e10cSrcweir 			nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) );
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 		if ( nNew != nOld )
461*cdf0e10cSrcweir 		{
462*cdf0e10cSrcweir 			eZoom = SVX_ZOOM_PERCENT;
463*cdf0e10cSrcweir 			pPreview->SetZoom( (sal_uInt16)nNew );
464*cdf0e10cSrcweir 		}
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir 		bDone = sal_True;
467*cdf0e10cSrcweir 	}
468*cdf0e10cSrcweir 	else
469*cdf0e10cSrcweir 	{
470*cdf0e10cSrcweir 		bDone = pPreview->HandleScrollCommand( rCEvt, pHorScroll, pVerScroll );
471*cdf0e10cSrcweir 	}
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	return bDone;
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir SfxPrinter* __EXPORT ScPreviewShell::GetPrinter( sal_Bool bCreate )
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir 	return pDocShell->GetPrinter(bCreate);
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir sal_uInt16 __EXPORT ScPreviewShell::SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags, bool )
482*cdf0e10cSrcweir {
483*cdf0e10cSrcweir 	return pDocShell->SetPrinter( pNewPrinter, nDiffFlags );
484*cdf0e10cSrcweir }
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir SfxTabPage* ScPreviewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions )
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir 	ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
489*cdf0e10cSrcweir 	DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
490*cdf0e10cSrcweir 	//CHINA001 return ScTpPrintOptions::Create( pParent, rOptions );
491*cdf0e10cSrcweir 	::CreateTabPage ScTpPrintOptionsCreate = 	pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
492*cdf0e10cSrcweir 	if ( ScTpPrintOptionsCreate )
493*cdf0e10cSrcweir 		return  (*ScTpPrintOptionsCreate)( pParent, rOptions);
494*cdf0e10cSrcweir 	return 0;
495*cdf0e10cSrcweir }
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir //------------------------------------------------------------------------
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir void __EXPORT ScPreviewShell::Activate(sal_Bool bMDI)
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir 	SfxViewShell::Activate(bMDI);
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	//!	Basic etc. -> auslagern in eigene Datei (s. tabvwsh4)
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 	if (bMDI)
506*cdf0e10cSrcweir 	{
507*cdf0e10cSrcweir 		// InputHdl ist jetzt meistens Null, keine Assertion mehr!
508*cdf0e10cSrcweir 		ScInputHandler*	pInputHdl = SC_MOD()->GetInputHdl();
509*cdf0e10cSrcweir 		if ( pInputHdl )
510*cdf0e10cSrcweir 			pInputHdl->NotifyChange( NULL );
511*cdf0e10cSrcweir 	}
512*cdf0e10cSrcweir }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir void __EXPORT ScPreviewShell::Deactivate(sal_Bool bMDI)
515*cdf0e10cSrcweir {
516*cdf0e10cSrcweir 	SfxViewShell::Deactivate(bMDI);
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 	if (bMDI)
519*cdf0e10cSrcweir 	{
520*cdf0e10cSrcweir 	}
521*cdf0e10cSrcweir }
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir //------------------------------------------------------------------------
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir void __EXPORT ScPreviewShell::Execute( SfxRequest& rReq )
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
528*cdf0e10cSrcweir 	const SfxItemSet* pReqArgs = rReq.GetArgs();
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 	switch ( nSlot )
531*cdf0e10cSrcweir 	{
532*cdf0e10cSrcweir 		case SID_FORMATPAGE:
533*cdf0e10cSrcweir 		case SID_STATUS_PAGESTYLE:
534*cdf0e10cSrcweir 		case SID_HFEDIT:
535*cdf0e10cSrcweir 			pDocShell->ExecutePageStyle( *this, rReq, pPreview->GetTab() );
536*cdf0e10cSrcweir 			break;
537*cdf0e10cSrcweir 		case SID_REPAINT:
538*cdf0e10cSrcweir 			pPreview->Invalidate();
539*cdf0e10cSrcweir 			rReq.Done();
540*cdf0e10cSrcweir 			break;
541*cdf0e10cSrcweir 		case SID_PREV_TABLE: // Accelerator
542*cdf0e10cSrcweir 		case SID_PREVIEW_PREVIOUS:
543*cdf0e10cSrcweir 			{
544*cdf0e10cSrcweir 				long nPage = pPreview->GetPageNo();
545*cdf0e10cSrcweir 				long nTotal = pPreview->GetTotalPages();
546*cdf0e10cSrcweir 				if (nTotal && nPage > 0)
547*cdf0e10cSrcweir 					pPreview->SetPageNo( nPage-1 );
548*cdf0e10cSrcweir 			}
549*cdf0e10cSrcweir 			break;
550*cdf0e10cSrcweir 		case SID_NEXT_TABLE: // Accelerator
551*cdf0e10cSrcweir 		case SID_PREVIEW_NEXT:
552*cdf0e10cSrcweir 			{
553*cdf0e10cSrcweir 				sal_Bool bAllTested	= pPreview->AllTested();
554*cdf0e10cSrcweir 				long nPage = pPreview->GetPageNo();
555*cdf0e10cSrcweir 				long nTotal = pPreview->GetTotalPages();
556*cdf0e10cSrcweir 				if (nTotal && (nPage+1 < nTotal || !bAllTested))
557*cdf0e10cSrcweir 					pPreview->SetPageNo( nPage+1 );
558*cdf0e10cSrcweir 			}
559*cdf0e10cSrcweir 			break;
560*cdf0e10cSrcweir 		case SID_CURSORTOPOFFILE: // Accelerator
561*cdf0e10cSrcweir 		case SID_PREVIEW_FIRST:
562*cdf0e10cSrcweir 			{
563*cdf0e10cSrcweir 				long nPage = pPreview->GetPageNo();
564*cdf0e10cSrcweir 				long nTotal = pPreview->GetTotalPages();
565*cdf0e10cSrcweir 				if (nTotal && nPage != 0)
566*cdf0e10cSrcweir 					pPreview->SetPageNo( 0 );
567*cdf0e10cSrcweir 			}
568*cdf0e10cSrcweir 			break;
569*cdf0e10cSrcweir 		case SID_CURSORENDOFFILE: // Accelerator
570*cdf0e10cSrcweir 		case SID_PREVIEW_LAST:
571*cdf0e10cSrcweir 			{
572*cdf0e10cSrcweir 				if (!pPreview->AllTested())
573*cdf0e10cSrcweir 					pPreview->CalcAll();
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 				long nPage = pPreview->GetPageNo();
576*cdf0e10cSrcweir 				long nTotal = pPreview->GetTotalPages();
577*cdf0e10cSrcweir 				if (nTotal && nPage+1 != nTotal)
578*cdf0e10cSrcweir 					pPreview->SetPageNo( nTotal-1 );
579*cdf0e10cSrcweir 			}
580*cdf0e10cSrcweir 			break;
581*cdf0e10cSrcweir 		case SID_ATTR_ZOOM:
582*cdf0e10cSrcweir 		case FID_SCALE:
583*cdf0e10cSrcweir 			{
584*cdf0e10cSrcweir 				sal_uInt16		nZoom		= 100;
585*cdf0e10cSrcweir 				sal_Bool		bCancel		= sal_False;
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 				eZoom = SVX_ZOOM_PERCENT;
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 				if ( pReqArgs )
590*cdf0e10cSrcweir 				{
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir 					const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
593*cdf0e10cSrcweir 												   pReqArgs->Get(SID_ATTR_ZOOM);
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 					eZoom = rZoomItem.GetType();
596*cdf0e10cSrcweir 					nZoom = rZoomItem.GetValue();
597*cdf0e10cSrcweir 				}
598*cdf0e10cSrcweir 				else
599*cdf0e10cSrcweir 				{
600*cdf0e10cSrcweir 					SfxItemSet		aSet	 ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
601*cdf0e10cSrcweir 					SvxZoomItem		aZoomItem( SVX_ZOOM_PERCENT, pPreview->GetZoom(), SID_ATTR_ZOOM );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 					aSet.Put( aZoomItem );
604*cdf0e10cSrcweir 					//CHINA001 SvxZoomDialog* pDlg = pDlg = new SvxZoomDialog( NULL, aSet );
605*cdf0e10cSrcweir 					SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
606*cdf0e10cSrcweir 					if(pFact)
607*cdf0e10cSrcweir 					{
608*cdf0e10cSrcweir 						AbstractSvxZoomDialog* pDlg = pFact->CreateSvxZoomDialog(NULL, aSet);
609*cdf0e10cSrcweir 						DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
610*cdf0e10cSrcweir 						pDlg->SetLimits( 20, 400 );
611*cdf0e10cSrcweir 						pDlg->HideButton( ZOOMBTN_OPTIMAL );
612*cdf0e10cSrcweir 						bCancel = ( RET_CANCEL == pDlg->Execute() );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 						if ( !bCancel )
615*cdf0e10cSrcweir 						{
616*cdf0e10cSrcweir 							const SvxZoomItem&	rZoomItem = (const SvxZoomItem&)
617*cdf0e10cSrcweir 													pDlg->GetOutputItemSet()->
618*cdf0e10cSrcweir 														Get( SID_ATTR_ZOOM );
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 							eZoom = rZoomItem.GetType();
621*cdf0e10cSrcweir 							nZoom = rZoomItem.GetValue();
622*cdf0e10cSrcweir 						}
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir 						delete pDlg;
625*cdf0e10cSrcweir 					}
626*cdf0e10cSrcweir 				}
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 				if ( !bCancel )
629*cdf0e10cSrcweir 				{
630*cdf0e10cSrcweir 					switch ( eZoom )
631*cdf0e10cSrcweir 					{
632*cdf0e10cSrcweir 						case SVX_ZOOM_OPTIMAL:
633*cdf0e10cSrcweir 						case SVX_ZOOM_WHOLEPAGE:
634*cdf0e10cSrcweir 							nZoom = pPreview->GetOptimalZoom(sal_False);
635*cdf0e10cSrcweir 							break;
636*cdf0e10cSrcweir 						case SVX_ZOOM_PAGEWIDTH:
637*cdf0e10cSrcweir 							nZoom = pPreview->GetOptimalZoom(sal_True);
638*cdf0e10cSrcweir 							break;
639*cdf0e10cSrcweir                         default:
640*cdf0e10cSrcweir                         {
641*cdf0e10cSrcweir                             // added to avoid warnings
642*cdf0e10cSrcweir                         }
643*cdf0e10cSrcweir 					}
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 					pPreview->SetZoom( nZoom );
646*cdf0e10cSrcweir 					rReq.Done();
647*cdf0e10cSrcweir 				}
648*cdf0e10cSrcweir 			}
649*cdf0e10cSrcweir 			break;
650*cdf0e10cSrcweir 		case SID_PREVIEW_ZOOMIN:
651*cdf0e10cSrcweir 			{
652*cdf0e10cSrcweir 				sal_uInt16 nNew = pPreview->GetZoom() + 20 ;
653*cdf0e10cSrcweir 				nNew -= nNew % 20;
654*cdf0e10cSrcweir 				pPreview->SetZoom( nNew );
655*cdf0e10cSrcweir 				eZoom = SVX_ZOOM_PERCENT;
656*cdf0e10cSrcweir 				rReq.Done();
657*cdf0e10cSrcweir 			}
658*cdf0e10cSrcweir 			break;
659*cdf0e10cSrcweir 		case SID_PREVIEW_ZOOMOUT:
660*cdf0e10cSrcweir 			{
661*cdf0e10cSrcweir 				sal_uInt16 nNew = pPreview->GetZoom() - 1;
662*cdf0e10cSrcweir 				nNew -= nNew % 20;
663*cdf0e10cSrcweir 				pPreview->SetZoom( nNew );
664*cdf0e10cSrcweir 				eZoom = SVX_ZOOM_PERCENT;
665*cdf0e10cSrcweir 				rReq.Done();
666*cdf0e10cSrcweir 			}
667*cdf0e10cSrcweir 			break;
668*cdf0e10cSrcweir         case SID_PREVIEW_MARGIN:
669*cdf0e10cSrcweir             {
670*cdf0e10cSrcweir                 sal_Bool bMargin = pPreview->GetPageMargins();
671*cdf0e10cSrcweir                 pPreview->SetPageMargins( !bMargin );
672*cdf0e10cSrcweir                 pPreview->Invalidate();
673*cdf0e10cSrcweir                 rReq.Done();
674*cdf0e10cSrcweir             }
675*cdf0e10cSrcweir             break;
676*cdf0e10cSrcweir         case SID_ATTR_ZOOMSLIDER:
677*cdf0e10cSrcweir             {
678*cdf0e10cSrcweir                 const SfxPoolItem* pItem;
679*cdf0e10cSrcweir                 eZoom = SVX_ZOOM_PERCENT;
680*cdf0e10cSrcweir                 if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_ZOOMSLIDER, sal_True, &pItem ) )
681*cdf0e10cSrcweir                 {
682*cdf0e10cSrcweir                     const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem*)pItem)->GetValue();
683*cdf0e10cSrcweir                     if( nCurrentZoom )
684*cdf0e10cSrcweir                     {
685*cdf0e10cSrcweir                         pPreview->SetZoom( nCurrentZoom );
686*cdf0e10cSrcweir                         rReq.Done();
687*cdf0e10cSrcweir                     }
688*cdf0e10cSrcweir                 }
689*cdf0e10cSrcweir             }
690*cdf0e10cSrcweir             break;
691*cdf0e10cSrcweir         case SID_PREVIEW_SCALINGFACTOR:
692*cdf0e10cSrcweir             {
693*cdf0e10cSrcweir                 const SfxPoolItem* pItem;
694*cdf0e10cSrcweir                 SCTAB nTab                      = pPreview->GetTab();
695*cdf0e10cSrcweir                 String aOldName                 = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() );
696*cdf0e10cSrcweir                 ScStyleSheetPool* pStylePool    = pDocShell->GetDocument()->GetStyleSheetPool();
697*cdf0e10cSrcweir                 SfxStyleSheetBase* pStyleSheet  = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
698*cdf0e10cSrcweir                 DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir                 if ( pReqArgs && pStyleSheet && SFX_ITEM_SET == pReqArgs->GetItemState( SID_PREVIEW_SCALINGFACTOR, sal_True, &pItem ) )
701*cdf0e10cSrcweir                 {
702*cdf0e10cSrcweir                     const sal_uInt16 nCurrentZoom   = ((const SvxZoomSliderItem *)pItem)->GetValue();
703*cdf0e10cSrcweir                     SfxItemSet& rSet            = pStyleSheet->GetItemSet();
704*cdf0e10cSrcweir                     rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nCurrentZoom ) );
705*cdf0e10cSrcweir                     ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab );
706*cdf0e10cSrcweir                     aPrintFunc.UpdatePages();
707*cdf0e10cSrcweir                     rReq.Done();
708*cdf0e10cSrcweir                 }
709*cdf0e10cSrcweir                 GetViewFrame()->GetBindings().Invalidate( nSlot );
710*cdf0e10cSrcweir             }
711*cdf0e10cSrcweir             break;
712*cdf0e10cSrcweir 		case SID_PRINTPREVIEW:
713*cdf0e10cSrcweir 		case SID_PREVIEW_CLOSE:
714*cdf0e10cSrcweir 			//	print preview is now always in the same frame as the tab view
715*cdf0e10cSrcweir 			//	-> always switch this frame back to normal view
716*cdf0e10cSrcweir 			//	(ScTabViewShell ctor reads stored view data)
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir             GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_ASYNCHRON );
719*cdf0e10cSrcweir 			break;
720*cdf0e10cSrcweir 		case SID_CURSORPAGEUP:
721*cdf0e10cSrcweir 		case SID_CURSORPAGEDOWN:
722*cdf0e10cSrcweir 		case SID_CURSORHOME:
723*cdf0e10cSrcweir 		case SID_CURSOREND:
724*cdf0e10cSrcweir 		case SID_CURSORUP:
725*cdf0e10cSrcweir 		case SID_CURSORDOWN:
726*cdf0e10cSrcweir 		case SID_CURSORLEFT:
727*cdf0e10cSrcweir 		case SID_CURSORRIGHT:
728*cdf0e10cSrcweir 			DoScroll( nSlot );
729*cdf0e10cSrcweir 			break;
730*cdf0e10cSrcweir         case SID_CANCEL:
731*cdf0e10cSrcweir             if( ScViewUtil::IsFullScreen( *this ) )
732*cdf0e10cSrcweir                 ScViewUtil::SetFullScreen( *this, false );
733*cdf0e10cSrcweir             break;
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 		default:
736*cdf0e10cSrcweir 			break;
737*cdf0e10cSrcweir 	}
738*cdf0e10cSrcweir }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir void __EXPORT ScPreviewShell::GetState( SfxItemSet& rSet )
741*cdf0e10cSrcweir {
742*cdf0e10cSrcweir 	pPreview->SetInGetState(sal_True);
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir 	SCTAB nTab		= pPreview->GetTab();
745*cdf0e10cSrcweir 	long nPage		= pPreview->GetPageNo();
746*cdf0e10cSrcweir 	long nTotal		= pPreview->GetTotalPages();
747*cdf0e10cSrcweir 	sal_uInt16 nZoom	= pPreview->GetZoom();
748*cdf0e10cSrcweir 	sal_Bool bAllTested	= pPreview->AllTested();
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
751*cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
752*cdf0e10cSrcweir 	while ( nWhich )
753*cdf0e10cSrcweir 	{
754*cdf0e10cSrcweir 		switch (nWhich)
755*cdf0e10cSrcweir 		{
756*cdf0e10cSrcweir 			case SID_STATUS_PAGESTYLE:
757*cdf0e10cSrcweir 			case SID_HFEDIT:
758*cdf0e10cSrcweir 				pDocShell->GetStatePageStyle( *this, rSet, nTab );
759*cdf0e10cSrcweir 				break;
760*cdf0e10cSrcweir 			case SID_UNDO:
761*cdf0e10cSrcweir 			case SID_REDO:
762*cdf0e10cSrcweir 			case SID_REPEAT:
763*cdf0e10cSrcweir 				rSet.DisableItem(nWhich);
764*cdf0e10cSrcweir 				break;
765*cdf0e10cSrcweir 			case SID_PREVIEW_PREVIOUS:
766*cdf0e10cSrcweir 			case SID_PREVIEW_FIRST:
767*cdf0e10cSrcweir 				if (!nTotal || nPage==0)
768*cdf0e10cSrcweir 					rSet.DisableItem(nWhich);
769*cdf0e10cSrcweir 				break;
770*cdf0e10cSrcweir 			case SID_PREVIEW_NEXT:
771*cdf0e10cSrcweir 			case SID_PREVIEW_LAST:
772*cdf0e10cSrcweir 				if (bAllTested)
773*cdf0e10cSrcweir 					if (!nTotal || nPage==nTotal-1)
774*cdf0e10cSrcweir 						rSet.DisableItem(nWhich);
775*cdf0e10cSrcweir 				break;
776*cdf0e10cSrcweir 			case SID_PREVIEW_ZOOMIN:
777*cdf0e10cSrcweir 				if (nZoom >= 400)
778*cdf0e10cSrcweir 					rSet.DisableItem(nWhich);
779*cdf0e10cSrcweir 				break;
780*cdf0e10cSrcweir 			case SID_PREVIEW_ZOOMOUT:
781*cdf0e10cSrcweir 				if (nZoom <= 20)
782*cdf0e10cSrcweir 					rSet.DisableItem(nWhich);
783*cdf0e10cSrcweir 				break;
784*cdf0e10cSrcweir 			case SID_ATTR_ZOOM:
785*cdf0e10cSrcweir 				{
786*cdf0e10cSrcweir 					SvxZoomItem aZoom( eZoom, nZoom, nWhich );
787*cdf0e10cSrcweir 					aZoom.SetValueSet( SVX_ZOOM_ENABLE_ALL & ~SVX_ZOOM_ENABLE_OPTIMAL );
788*cdf0e10cSrcweir 					rSet.Put( aZoom );
789*cdf0e10cSrcweir 				}
790*cdf0e10cSrcweir 				break;
791*cdf0e10cSrcweir             case SID_ATTR_ZOOMSLIDER:
792*cdf0e10cSrcweir                 {
793*cdf0e10cSrcweir                     SvxZoomSliderItem aZoomSliderItem( nZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
794*cdf0e10cSrcweir                     aZoomSliderItem.AddSnappingPoint( 100 );
795*cdf0e10cSrcweir                     rSet.Put( aZoomSliderItem );
796*cdf0e10cSrcweir                 }
797*cdf0e10cSrcweir                 break;
798*cdf0e10cSrcweir             case SID_PREVIEW_SCALINGFACTOR:
799*cdf0e10cSrcweir                 {
800*cdf0e10cSrcweir                     if( pDocShell->IsReadOnly() )
801*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
802*cdf0e10cSrcweir                     else
803*cdf0e10cSrcweir                     {
804*cdf0e10cSrcweir                         String aOldName                 = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() );
805*cdf0e10cSrcweir                         ScStyleSheetPool* pStylePool    = pDocShell->GetDocument()->GetStyleSheetPool();
806*cdf0e10cSrcweir                         SfxStyleSheetBase* pStyleSheet  = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
807*cdf0e10cSrcweir                         DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir                         if ( pStyleSheet )
810*cdf0e10cSrcweir                         {
811*cdf0e10cSrcweir                             SfxItemSet& rStyleSet   = pStyleSheet->GetItemSet();
812*cdf0e10cSrcweir                             sal_uInt16 nCurrentZoom     = ((const SfxUInt16Item&)rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
813*cdf0e10cSrcweir                             if( nCurrentZoom )
814*cdf0e10cSrcweir                             {
815*cdf0e10cSrcweir                                 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM_SLIDER, MAXZOOM_SLIDER, SID_PREVIEW_SCALINGFACTOR );
816*cdf0e10cSrcweir                                 aZoomSliderItem.AddSnappingPoint( 100 );
817*cdf0e10cSrcweir                                 rSet.Put( aZoomSliderItem );
818*cdf0e10cSrcweir                             }
819*cdf0e10cSrcweir                             else
820*cdf0e10cSrcweir                                 rSet.DisableItem( nWhich );
821*cdf0e10cSrcweir                         }
822*cdf0e10cSrcweir                     }
823*cdf0e10cSrcweir                 }
824*cdf0e10cSrcweir                 break;
825*cdf0e10cSrcweir 			case SID_STATUS_DOCPOS:
826*cdf0e10cSrcweir 				rSet.Put( SfxStringItem( nWhich, pPreview->GetPosString() ) );
827*cdf0e10cSrcweir 				break;
828*cdf0e10cSrcweir 			case SID_PRINTPREVIEW:
829*cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, sal_True ) );
830*cdf0e10cSrcweir 				break;
831*cdf0e10cSrcweir 			case SID_FORMATPAGE:
832*cdf0e10cSrcweir             case SID_PREVIEW_MARGIN:
833*cdf0e10cSrcweir                 if( pDocShell->IsReadOnly() )
834*cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
835*cdf0e10cSrcweir 				break;
836*cdf0e10cSrcweir 		}
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
839*cdf0e10cSrcweir 	}
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir 	pPreview->SetInGetState(sal_False);
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir void ScPreviewShell::FillFieldData( ScHeaderFieldData& rData )
845*cdf0e10cSrcweir {
846*cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
847*cdf0e10cSrcweir 	SCTAB nTab = pPreview->GetTab();
848*cdf0e10cSrcweir 	pDoc->GetName( nTab, rData.aTabName );
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir 	rData.aTitle		= pDocShell->GetTitle();
851*cdf0e10cSrcweir 	const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
852*cdf0e10cSrcweir 	rData.aLongDocName	= rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
853*cdf0e10cSrcweir 	if ( rData.aLongDocName.Len() )
854*cdf0e10cSrcweir 		rData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
855*cdf0e10cSrcweir 	else
856*cdf0e10cSrcweir 		rData.aShortDocName = rData.aLongDocName = rData.aTitle;
857*cdf0e10cSrcweir 	rData.nPageNo		= pPreview->GetPageNo() + 1;
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir 	sal_Bool bAllTested	= pPreview->AllTested();
860*cdf0e10cSrcweir 	if (bAllTested)
861*cdf0e10cSrcweir 		rData.nTotalPages = pPreview->GetTotalPages();
862*cdf0e10cSrcweir 	else
863*cdf0e10cSrcweir 		rData.nTotalPages = 99;
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 	//	eNumType kennt der Dialog selber
866*cdf0e10cSrcweir }
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir void __EXPORT ScPreviewShell::WriteUserData(String& rData, sal_Bool /* bBrowse */)
869*cdf0e10cSrcweir {
870*cdf0e10cSrcweir 	//	nZoom
871*cdf0e10cSrcweir 	//	nPageNo
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir 	rData =  String::CreateFromInt32(pPreview->GetZoom());
874*cdf0e10cSrcweir 	rData += (sal_Unicode) SC_USERDATA_SEP;
875*cdf0e10cSrcweir 	rData += String::CreateFromInt32(pPreview->GetPageNo());
876*cdf0e10cSrcweir }
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir void __EXPORT ScPreviewShell::ReadUserData(const String& rData, sal_Bool /* bBrowse */)
879*cdf0e10cSrcweir {
880*cdf0e10cSrcweir 	xub_StrLen nCount = rData.GetTokenCount();
881*cdf0e10cSrcweir 	if (nCount)
882*cdf0e10cSrcweir 	{
883*cdf0e10cSrcweir 		xub_StrLen nIndex = 0;
884*cdf0e10cSrcweir 		pPreview->SetZoom((sal_uInt16)rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32());
885*cdf0e10cSrcweir 		pPreview->SetPageNo(rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32());
886*cdf0e10cSrcweir 		eZoom = SVX_ZOOM_PERCENT;
887*cdf0e10cSrcweir 	}
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir void __EXPORT ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue >& rSeq, sal_Bool /* bBrowse */)
891*cdf0e10cSrcweir {
892*cdf0e10cSrcweir 	rSeq.realloc(3);
893*cdf0e10cSrcweir 	beans::PropertyValue* pSeq = rSeq.getArray();
894*cdf0e10cSrcweir 	if(pSeq)
895*cdf0e10cSrcweir 	{
896*cdf0e10cSrcweir 		sal_uInt16 nViewID(GetViewFrame()->GetCurViewId());
897*cdf0e10cSrcweir 		pSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID));
898*cdf0e10cSrcweir 		rtl::OUStringBuffer sBuffer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW)));
899*cdf0e10cSrcweir 		SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
900*cdf0e10cSrcweir 		pSeq[0].Value <<= sBuffer.makeStringAndClear();
901*cdf0e10cSrcweir 		pSeq[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
902*cdf0e10cSrcweir 		pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom());
903*cdf0e10cSrcweir 		pSeq[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
904*cdf0e10cSrcweir 		pSeq[2].Value <<= pPreview->GetPageNo();
905*cdf0e10cSrcweir 	}
906*cdf0e10cSrcweir }
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir void __EXPORT ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyValue >& rSeq, sal_Bool /* bBrowse */)
909*cdf0e10cSrcweir {
910*cdf0e10cSrcweir 	sal_Int32 nCount(rSeq.getLength());
911*cdf0e10cSrcweir 	if (nCount)
912*cdf0e10cSrcweir 	{
913*cdf0e10cSrcweir 		sal_Int32 nTemp = 0;
914*cdf0e10cSrcweir 		const beans::PropertyValue* pSeq = rSeq.getConstArray();
915*cdf0e10cSrcweir 		if(pSeq)
916*cdf0e10cSrcweir 		{
917*cdf0e10cSrcweir 			for(sal_Int32 i = 0; i < nCount; i++, pSeq++)
918*cdf0e10cSrcweir 			{
919*cdf0e10cSrcweir 				rtl::OUString sName(pSeq->Name);
920*cdf0e10cSrcweir 				if(sName.compareToAscii(SC_ZOOMVALUE) == 0)
921*cdf0e10cSrcweir 				{
922*cdf0e10cSrcweir 					if (pSeq->Value >>= nTemp)
923*cdf0e10cSrcweir 						pPreview->SetZoom(sal_uInt16(nTemp));
924*cdf0e10cSrcweir 				}
925*cdf0e10cSrcweir 				else if (sName.compareToAscii("PageNumber") == 0)
926*cdf0e10cSrcweir 				{
927*cdf0e10cSrcweir 					if (pSeq->Value >>= nTemp)
928*cdf0e10cSrcweir 						pPreview->SetPageNo(nTemp);
929*cdf0e10cSrcweir 				}
930*cdf0e10cSrcweir 			}
931*cdf0e10cSrcweir 		}
932*cdf0e10cSrcweir 	}
933*cdf0e10cSrcweir }
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir void ScPreviewShell::DoScroll( sal_uInt16 nMode )
936*cdf0e10cSrcweir {
937*cdf0e10cSrcweir 	Point	aCurPos, aPrevPos;
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 	long nHRange	= pHorScroll->GetRange().Max();
940*cdf0e10cSrcweir 	long nHLine		= pHorScroll->GetLineSize();
941*cdf0e10cSrcweir 	long nHPage		= pHorScroll->GetPageSize();
942*cdf0e10cSrcweir 	long nVRange	= pVerScroll->GetRange().Max();
943*cdf0e10cSrcweir 	long nVLine		= pVerScroll->GetLineSize();
944*cdf0e10cSrcweir 	long nVPage		= pVerScroll->GetPageSize();
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 	aCurPos.X() = pHorScroll->GetThumbPos();
947*cdf0e10cSrcweir 	aCurPos.Y() = pVerScroll->GetThumbPos();
948*cdf0e10cSrcweir 	aPrevPos = aCurPos;
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir 	long nThumbPos	= pVerScroll->GetThumbPos();
951*cdf0e10cSrcweir 	long nRangeMax	= pVerScroll->GetRangeMax();
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir 	switch( nMode )
954*cdf0e10cSrcweir 	{
955*cdf0e10cSrcweir         case SID_CURSORUP:
956*cdf0e10cSrcweir             if( nMaxVertPos<0 )
957*cdf0e10cSrcweir             {
958*cdf0e10cSrcweir                 long nPage = pPreview->GetPageNo();
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir                 if( nPage>0 )
961*cdf0e10cSrcweir                 {
962*cdf0e10cSrcweir                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
963*cdf0e10cSrcweir                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
964*cdf0e10cSrcweir                     Execute( aSfxRequest );
965*cdf0e10cSrcweir                 }
966*cdf0e10cSrcweir             }
967*cdf0e10cSrcweir             else
968*cdf0e10cSrcweir                 aCurPos.Y() -= nVLine;
969*cdf0e10cSrcweir             break;
970*cdf0e10cSrcweir         case SID_CURSORDOWN:
971*cdf0e10cSrcweir             if( nMaxVertPos<0 )
972*cdf0e10cSrcweir             {
973*cdf0e10cSrcweir                 long nPage = pPreview->GetPageNo();
974*cdf0e10cSrcweir                 long nTotal = pPreview->GetTotalPages();
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir                 // before testing for last page, make sure all page counts are calculated
977*cdf0e10cSrcweir                 if ( nPage+1 == nTotal && !pPreview->AllTested() )
978*cdf0e10cSrcweir                 {
979*cdf0e10cSrcweir                     pPreview->CalcAll();
980*cdf0e10cSrcweir                     nTotal = pPreview->GetTotalPages();
981*cdf0e10cSrcweir                 }
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir                 if( nPage<nTotal-1 )
984*cdf0e10cSrcweir                 {
985*cdf0e10cSrcweir                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
986*cdf0e10cSrcweir                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
987*cdf0e10cSrcweir                     Execute( aSfxRequest );
988*cdf0e10cSrcweir                 }
989*cdf0e10cSrcweir             }
990*cdf0e10cSrcweir             else
991*cdf0e10cSrcweir                 aCurPos.Y() += nVLine;
992*cdf0e10cSrcweir             break;
993*cdf0e10cSrcweir         case SID_CURSORLEFT:
994*cdf0e10cSrcweir             aCurPos.X() -= nHLine;
995*cdf0e10cSrcweir             break;
996*cdf0e10cSrcweir         case SID_CURSORRIGHT:
997*cdf0e10cSrcweir             aCurPos.X() += nHLine;
998*cdf0e10cSrcweir             break;
999*cdf0e10cSrcweir         case SID_CURSORPAGEUP:
1000*cdf0e10cSrcweir             if( nThumbPos==0 || nMaxVertPos<0 )
1001*cdf0e10cSrcweir             {
1002*cdf0e10cSrcweir                 long nPage = pPreview->GetPageNo();
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir                 if( nPage>0 )
1005*cdf0e10cSrcweir                 {
1006*cdf0e10cSrcweir                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
1007*cdf0e10cSrcweir                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
1008*cdf0e10cSrcweir                     Execute( aSfxRequest );
1009*cdf0e10cSrcweir                     aCurPos.Y() = nVRange;
1010*cdf0e10cSrcweir                 }
1011*cdf0e10cSrcweir             }
1012*cdf0e10cSrcweir             else
1013*cdf0e10cSrcweir                 aCurPos.Y() -= nVPage;
1014*cdf0e10cSrcweir             break;
1015*cdf0e10cSrcweir         case SID_CURSORPAGEDOWN:
1016*cdf0e10cSrcweir             if( (abs(nVPage+nThumbPos-nRangeMax)<10) || nMaxVertPos<0 )
1017*cdf0e10cSrcweir             {
1018*cdf0e10cSrcweir                 long nPage = pPreview->GetPageNo();
1019*cdf0e10cSrcweir                 long nTotal = pPreview->GetTotalPages();
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir                 // before testing for last page, make sure all page counts are calculated
1022*cdf0e10cSrcweir                 if ( nPage+1 == nTotal && !pPreview->AllTested() )
1023*cdf0e10cSrcweir                 {
1024*cdf0e10cSrcweir                     pPreview->CalcAll();
1025*cdf0e10cSrcweir                     nTotal = pPreview->GetTotalPages();
1026*cdf0e10cSrcweir                 }
1027*cdf0e10cSrcweir                 if( nPage<nTotal-1 )
1028*cdf0e10cSrcweir                 {
1029*cdf0e10cSrcweir                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
1030*cdf0e10cSrcweir                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
1031*cdf0e10cSrcweir                     Execute( aSfxRequest );
1032*cdf0e10cSrcweir                     aCurPos.Y() = 0;
1033*cdf0e10cSrcweir                 }
1034*cdf0e10cSrcweir             }
1035*cdf0e10cSrcweir             else
1036*cdf0e10cSrcweir                 aCurPos.Y() += nVPage;
1037*cdf0e10cSrcweir             break;
1038*cdf0e10cSrcweir         case SID_CURSORHOME:
1039*cdf0e10cSrcweir             if( nMaxVertPos<0 )
1040*cdf0e10cSrcweir             {
1041*cdf0e10cSrcweir                 long nPage  = pPreview->GetPageNo();
1042*cdf0e10cSrcweir                 long nTotal = pPreview->GetTotalPages();
1043*cdf0e10cSrcweir                 if( nTotal && nPage != 0 )
1044*cdf0e10cSrcweir                 {
1045*cdf0e10cSrcweir                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
1046*cdf0e10cSrcweir                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_FIRST );
1047*cdf0e10cSrcweir                     Execute( aSfxRequest );
1048*cdf0e10cSrcweir                 }
1049*cdf0e10cSrcweir             }
1050*cdf0e10cSrcweir             else
1051*cdf0e10cSrcweir             {
1052*cdf0e10cSrcweir                 aCurPos.Y() = 0;
1053*cdf0e10cSrcweir                 aCurPos.X() = 0;
1054*cdf0e10cSrcweir             }
1055*cdf0e10cSrcweir             break;
1056*cdf0e10cSrcweir         case SID_CURSOREND:
1057*cdf0e10cSrcweir             if( nMaxVertPos<0 )
1058*cdf0e10cSrcweir             {
1059*cdf0e10cSrcweir                 if( !pPreview->AllTested() )
1060*cdf0e10cSrcweir                     pPreview->CalcAll();
1061*cdf0e10cSrcweir                 long nPage  = pPreview->GetPageNo();
1062*cdf0e10cSrcweir                 long nTotal = pPreview->GetTotalPages();
1063*cdf0e10cSrcweir                 if( nTotal && nPage+1 != nTotal )
1064*cdf0e10cSrcweir                 {
1065*cdf0e10cSrcweir                     SfxViewFrame* pSfxViewFrame = GetViewFrame();
1066*cdf0e10cSrcweir                     SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_LAST );
1067*cdf0e10cSrcweir                     Execute( aSfxRequest );
1068*cdf0e10cSrcweir                 }
1069*cdf0e10cSrcweir             }
1070*cdf0e10cSrcweir             else
1071*cdf0e10cSrcweir             {
1072*cdf0e10cSrcweir                 aCurPos.Y() = nVRange;
1073*cdf0e10cSrcweir                 aCurPos.X() = nHRange;
1074*cdf0e10cSrcweir             }
1075*cdf0e10cSrcweir             break;
1076*cdf0e10cSrcweir 	}
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir 		// nHRange-nHPage kann negativ sein, deshalb Abfrage auf < 0 hinterher
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir     if( aCurPos.Y() > (nVRange-nVPage) )
1081*cdf0e10cSrcweir         aCurPos.Y() = (nVRange-nVPage);
1082*cdf0e10cSrcweir     if( aCurPos.Y() < 0 )
1083*cdf0e10cSrcweir         aCurPos.Y() = 0;
1084*cdf0e10cSrcweir     if( aCurPos.X() > (nHRange-nHPage) )
1085*cdf0e10cSrcweir         aCurPos.X() = (nHRange-nHPage);
1086*cdf0e10cSrcweir     if( aCurPos.X() < 0 )
1087*cdf0e10cSrcweir         aCurPos.X() = 0;
1088*cdf0e10cSrcweir 
1089*cdf0e10cSrcweir     if( nMaxVertPos>=0 )
1090*cdf0e10cSrcweir     {
1091*cdf0e10cSrcweir 	    if( aCurPos.Y() != aPrevPos.Y() )
1092*cdf0e10cSrcweir 	    {
1093*cdf0e10cSrcweir 	    	pVerScroll->SetThumbPos( aCurPos.Y() );
1094*cdf0e10cSrcweir 	        pPreview->SetYOffset( aCurPos.Y() );
1095*cdf0e10cSrcweir 	    }
1096*cdf0e10cSrcweir     }
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir 	if( aCurPos.X() != aPrevPos.X() )
1099*cdf0e10cSrcweir 	{
1100*cdf0e10cSrcweir 		pHorScroll->SetThumbPos( aCurPos.X() );
1101*cdf0e10cSrcweir 		pPreview->SetXOffset( aCurPos.X() );
1102*cdf0e10cSrcweir 	}
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir }
1105*cdf0e10cSrcweir 
1106*cdf0e10cSrcweir void ScPreviewShell::AddAccessibilityObject( SfxListener& rObject )
1107*cdf0e10cSrcweir {
1108*cdf0e10cSrcweir 	if (!pAccessibilityBroadcaster)
1109*cdf0e10cSrcweir 		pAccessibilityBroadcaster = new SfxBroadcaster;
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir 	rObject.StartListening( *pAccessibilityBroadcaster );
1112*cdf0e10cSrcweir }
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir void ScPreviewShell::RemoveAccessibilityObject( SfxListener& rObject )
1115*cdf0e10cSrcweir {
1116*cdf0e10cSrcweir 	if (pAccessibilityBroadcaster)
1117*cdf0e10cSrcweir 		rObject.EndListening( *pAccessibilityBroadcaster );
1118*cdf0e10cSrcweir 	else
1119*cdf0e10cSrcweir 	{
1120*cdf0e10cSrcweir 		DBG_ERROR("kein Accessibility-Broadcaster?");
1121*cdf0e10cSrcweir 	}
1122*cdf0e10cSrcweir }
1123*cdf0e10cSrcweir 
1124*cdf0e10cSrcweir void ScPreviewShell::BroadcastAccessibility( const SfxHint &rHint )
1125*cdf0e10cSrcweir {
1126*cdf0e10cSrcweir 	if (pAccessibilityBroadcaster)
1127*cdf0e10cSrcweir 		pAccessibilityBroadcaster->Broadcast( rHint );
1128*cdf0e10cSrcweir }
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir sal_Bool ScPreviewShell::HasAccessibilityObjects()
1131*cdf0e10cSrcweir {
1132*cdf0e10cSrcweir 	return pAccessibilityBroadcaster && pAccessibilityBroadcaster->HasListeners();
1133*cdf0e10cSrcweir }
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir const ScPreviewLocationData& ScPreviewShell::GetLocationData()
1136*cdf0e10cSrcweir {
1137*cdf0e10cSrcweir 	return pPreview->GetLocationData();
1138*cdf0e10cSrcweir }
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir ScDocument* ScPreviewShell::GetDocument()
1141*cdf0e10cSrcweir {
1142*cdf0e10cSrcweir 	return pDocShell->GetDocument();
1143*cdf0e10cSrcweir }
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir 
1146