1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
30cdf0e10cSrcweir #include <tools/pstm.hxx>
31cdf0e10cSrcweir #include "scitems.hxx"
32cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
36cdf0e10cSrcweir #include <svx/fmview.hxx>
37cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
38cdf0e10cSrcweir #include <svx/svdpagv.hxx>
39cdf0e10cSrcweir #include <sfx2/bindings.hxx>
40cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
41cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
42cdf0e10cSrcweir #include <svtools/accessibilityoptions.hxx>
43cdf0e10cSrcweir #include <svl/itemset.hxx>
44cdf0e10cSrcweir #include <tools/multisel.hxx>
45cdf0e10cSrcweir #include <vcl/waitobj.hxx>
46cdf0e10cSrcweir #include <vcl/sound.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir #include "preview.hxx"
49cdf0e10cSrcweir #include "prevwsh.hxx"
50cdf0e10cSrcweir #include "prevloc.hxx"
51cdf0e10cSrcweir #include "docsh.hxx"
52cdf0e10cSrcweir #include "docfunc.hxx"
53cdf0e10cSrcweir #include "printfun.hxx"
54cdf0e10cSrcweir #include "printopt.hxx"
55cdf0e10cSrcweir #include "stlpool.hxx"
56cdf0e10cSrcweir #include "undostyl.hxx"
57cdf0e10cSrcweir #include "drwlayer.hxx"
58cdf0e10cSrcweir #include "scmod.hxx"
59cdf0e10cSrcweir #include "globstr.hrc"
60cdf0e10cSrcweir #include "sc.hrc" // fuer ShellInvalidate
61cdf0e10cSrcweir #include "AccessibleDocumentPagePreview.hxx"
62cdf0e10cSrcweir #include <vcl/lineinfo.hxx>
63cdf0e10cSrcweir #include <svx/algitem.hxx>
64cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
65cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
66cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
67cdf0e10cSrcweir #include "attrib.hxx"
68cdf0e10cSrcweir #include "pagepar.hxx"
69cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
70cdf0e10cSrcweir #include "AccessibilityHints.hxx"
71cdf0e10cSrcweir #include <vcl/svapp.hxx>
72cdf0e10cSrcweir #include "viewutil.hxx"
73cdf0e10cSrcweir
74cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
75cdf0e10cSrcweir
76cdf0e10cSrcweir //==================================================================
77cdf0e10cSrcweir
78*a246698eSmseidel //#define SC_PREVIEW_SHADOWSIZE 2
79cdf0e10cSrcweir
lcl_GetDisplayStart(SCTAB nTab,ScDocument * pDoc,long * pPages)80cdf0e10cSrcweir long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir long nDisplayStart = 0;
83cdf0e10cSrcweir for (SCTAB i=0; i<nTab; i++)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir if ( pDoc->NeedPageResetAfterTab(i) )
86cdf0e10cSrcweir nDisplayStart = 0;
87cdf0e10cSrcweir else
88cdf0e10cSrcweir nDisplayStart += pPages[i];
89cdf0e10cSrcweir }
90cdf0e10cSrcweir return nDisplayStart;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir
ScPreview(Window * pParent,ScDocShell * pDocSh,ScPreviewShell * pViewSh)94cdf0e10cSrcweir ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh ) :
95cdf0e10cSrcweir Window( pParent ),
96cdf0e10cSrcweir nPageNo( 0 ),
97cdf0e10cSrcweir nZoom( 100 ),
98cdf0e10cSrcweir bValid( sal_False ),
99cdf0e10cSrcweir nTabsTested( 0 ),
100cdf0e10cSrcweir nTab( 0 ),
101cdf0e10cSrcweir nTabStart( 0 ),
102cdf0e10cSrcweir nDisplayStart( 0 ),
103cdf0e10cSrcweir nTotalPages( 0 ),
104cdf0e10cSrcweir bStateValid( sal_False ),
105cdf0e10cSrcweir bLocationValid( sal_False ),
106cdf0e10cSrcweir pLocationData( NULL ),
107cdf0e10cSrcweir pDrawView( NULL ),
108cdf0e10cSrcweir bInPaint( false ),
109cdf0e10cSrcweir bInSetZoom( false ),
110cdf0e10cSrcweir bInGetState( sal_False ),
111cdf0e10cSrcweir pDocShell( pDocSh ),
112cdf0e10cSrcweir pViewShell( pViewSh ),
113cdf0e10cSrcweir bLeftRulerMove( sal_False ),
114cdf0e10cSrcweir bRightRulerMove( sal_False ),
115cdf0e10cSrcweir bTopRulerMove( sal_False ),
116cdf0e10cSrcweir bBottomRulerMove( sal_False ),
117cdf0e10cSrcweir bHeaderRulerMove( sal_False ),
118cdf0e10cSrcweir bFooterRulerMove( sal_False ),
119cdf0e10cSrcweir bLeftRulerChange( sal_False ),
120cdf0e10cSrcweir bRightRulerChange( sal_False ),
121cdf0e10cSrcweir bTopRulerChange( sal_False ),
122cdf0e10cSrcweir bBottomRulerChange( sal_False ),
123cdf0e10cSrcweir bHeaderRulerChange( sal_False ),
124cdf0e10cSrcweir bFooterRulerChange( sal_False ),
125cdf0e10cSrcweir bPageMargin ( sal_False ),
126cdf0e10cSrcweir bColRulerMove( sal_False ),
127cdf0e10cSrcweir mnScale( 0 ),
128cdf0e10cSrcweir nColNumberButttonDown( 0 ),
129cdf0e10cSrcweir nHeaderHeight ( 0 ),
130cdf0e10cSrcweir nFooterHeight ( 0 )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW ); //#106611#
133cdf0e10cSrcweir SetBackground();
134cdf0e10cSrcweir
135cdf0e10cSrcweir SetHelpId( HID_SC_WIN_PREVIEW );
136cdf0e10cSrcweir SetUniqueId( HID_SC_WIN_PREVIEW );
137cdf0e10cSrcweir
138cdf0e10cSrcweir SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
139cdf0e10cSrcweir
140cdf0e10cSrcweir for (SCCOL i=0; i<=MAXCOL; i++)
141cdf0e10cSrcweir nRight[i] = 0; // initialized with actual positions when markers are drawn
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir
~ScPreview()145cdf0e10cSrcweir __EXPORT ScPreview::~ScPreview()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir delete pDrawView;
148cdf0e10cSrcweir delete pLocationData;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
UpdateDrawView()151cdf0e10cSrcweir void ScPreview::UpdateDrawView() // nTab muss richtig sein
152cdf0e10cSrcweir {
153cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument();
154cdf0e10cSrcweir ScDrawLayer* pModel = pDoc->GetDrawLayer(); // ist nicht 0
155cdf0e10cSrcweir
156cdf0e10cSrcweir // #114135#
157cdf0e10cSrcweir if ( pModel )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(nTab);
160cdf0e10cSrcweir if ( pDrawView && ( !pDrawView->GetSdrPageView() || pDrawView->GetSdrPageView()->GetPage() != pPage ) )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir // die angezeigte Page der DrawView umzustellen (s.u.) funktioniert nicht ?!?
163cdf0e10cSrcweir delete pDrawView;
164cdf0e10cSrcweir pDrawView = NULL;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir if ( !pDrawView ) // neu anlegen?
168cdf0e10cSrcweir {
169cdf0e10cSrcweir pDrawView = new FmFormView( pModel, this );
170cdf0e10cSrcweir // #55259# die DrawView uebernimmt den Design-Modus vom Model
171cdf0e10cSrcweir // (Einstellung "Im Entwurfsmodus oeffnen"), darum hier zuruecksetzen
172cdf0e10cSrcweir pDrawView->SetDesignMode( sal_True );
173cdf0e10cSrcweir pDrawView->SetPrintPreview( sal_True );
174cdf0e10cSrcweir pDrawView->ShowSdrPage(pPage);
175cdf0e10cSrcweir }
176cdf0e10cSrcweir #if 0
177cdf0e10cSrcweir else if ( !pDrawView->GetSdrPageView()) // angezeigte Page umstellen
178cdf0e10cSrcweir {
179cdf0e10cSrcweir pDrawView->HideSdrPage();
180cdf0e10cSrcweir pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
181cdf0e10cSrcweir }
182cdf0e10cSrcweir #endif
183cdf0e10cSrcweir }
184cdf0e10cSrcweir else if ( pDrawView )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir delete pDrawView; // fuer diese Tabelle nicht gebraucht
187cdf0e10cSrcweir pDrawView = NULL;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir
TestLastPage()192cdf0e10cSrcweir void ScPreview::TestLastPage()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir if (nPageNo >= nTotalPages)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir if (nTotalPages)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir nPageNo = nTotalPages - 1;
199cdf0e10cSrcweir nTab = nTabCount - 1;
200cdf0e10cSrcweir while (nTab > 0 && !nPages[nTab]) // letzte nicht leere Tabelle
201cdf0e10cSrcweir --nTab;
202cdf0e10cSrcweir DBG_ASSERT(nPages[nTab],"alle Tabellen leer?");
203cdf0e10cSrcweir nTabPage = nPages[nTab] - 1;
204cdf0e10cSrcweir nTabStart = 0;
205cdf0e10cSrcweir for (sal_uInt16 i=0; i<nTab; i++)
206cdf0e10cSrcweir nTabStart += nPages[i];
207cdf0e10cSrcweir
208cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument();
209cdf0e10cSrcweir nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir else // leeres Dokument
212cdf0e10cSrcweir {
213cdf0e10cSrcweir nTab = 0;
214cdf0e10cSrcweir nPageNo = nTabPage = nTabStart = nDisplayStart = 0;
215cdf0e10cSrcweir aState.nPrintTab = 0;
216cdf0e10cSrcweir aState.nStartCol = aState.nEndCol = 0;
217cdf0e10cSrcweir aState.nStartRow = aState.nEndRow = 0;
218cdf0e10cSrcweir aState.nZoom = 0;
219cdf0e10cSrcweir aState.nPagesX = aState.nPagesY = 0;
220cdf0e10cSrcweir aState.nTabPages = aState.nTotalPages =
221cdf0e10cSrcweir aState.nPageStart = aState.nDocPages = 0;
222cdf0e10cSrcweir }
223cdf0e10cSrcweir }
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir
CalcPages(SCTAB)227cdf0e10cSrcweir void ScPreview::CalcPages( SCTAB /*nToWhichTab*/ )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir WaitObject( this );
230cdf0e10cSrcweir
231cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument();
232cdf0e10cSrcweir nTabCount = pDoc->GetTableCount();
233cdf0e10cSrcweir
234cdf0e10cSrcweir //SCTAB nAnz = Min( nTabCount, SCTAB(nToWhichTab+1) );
235cdf0e10cSrcweir SCTAB nAnz = nTabCount;
236cdf0e10cSrcweir SCTAB nStart = nTabsTested;
237cdf0e10cSrcweir if (!bValid)
238cdf0e10cSrcweir {
239cdf0e10cSrcweir nStart = 0;
240cdf0e10cSrcweir nTotalPages = 0;
241cdf0e10cSrcweir nTabsTested = 0;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
244cdf0e10cSrcweir // update all pending row heights with a single progress bar,
245cdf0e10cSrcweir // instead of a separate progress for each sheet from ScPrintFunc
246cdf0e10cSrcweir pDocShell->UpdatePendingRowHeights( nAnz-1, true );
247cdf0e10cSrcweir
248cdf0e10cSrcweir // PrintOptions is passed to PrintFunc for SkipEmpty flag,
249cdf0e10cSrcweir // but always all sheets are used (there is no selected sheet)
250cdf0e10cSrcweir ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
251cdf0e10cSrcweir
252cdf0e10cSrcweir for (SCTAB i=nStart; i<nAnz; i++)
253cdf0e10cSrcweir {
254cdf0e10cSrcweir long nAttrPage = i > 0 ? nFirstAttr[i-1] : 1;
255cdf0e10cSrcweir
256cdf0e10cSrcweir long nThisStart = nTotalPages;
257cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, pDocShell, i, nAttrPage, 0, NULL, &aOptions );
258cdf0e10cSrcweir long nThisTab = aPrintFunc.GetTotalPages();
259cdf0e10cSrcweir nPages[i] = nThisTab;
260cdf0e10cSrcweir nTotalPages += nThisTab;
261cdf0e10cSrcweir nFirstAttr[i] = aPrintFunc.GetFirstPageNo(); // behalten oder aus Vorlage
262cdf0e10cSrcweir
263cdf0e10cSrcweir if (nPageNo>=nThisStart && nPageNo<nTotalPages)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir nTab = i;
266cdf0e10cSrcweir nTabPage = nPageNo - nThisStart;
267cdf0e10cSrcweir nTabStart = nThisStart;
268cdf0e10cSrcweir
269cdf0e10cSrcweir aPrintFunc.GetPrintState( aState );
270cdf0e10cSrcweir aPageSize = aPrintFunc.GetPageSize();
271cdf0e10cSrcweir }
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
275cdf0e10cSrcweir
276cdf0e10cSrcweir if (nAnz > nTabsTested)
277cdf0e10cSrcweir nTabsTested = nAnz;
278cdf0e10cSrcweir
279cdf0e10cSrcweir // testen, ob hinter letzter Seite
280cdf0e10cSrcweir
281cdf0e10cSrcweir if ( nTabsTested >= nTabCount )
282cdf0e10cSrcweir TestLastPage();
283cdf0e10cSrcweir
284cdf0e10cSrcweir aState.nDocPages = nTotalPages;
285cdf0e10cSrcweir
286cdf0e10cSrcweir bValid = sal_True;
287cdf0e10cSrcweir bStateValid = sal_True;
288cdf0e10cSrcweir DoInvalidate();
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir
RecalcPages()292cdf0e10cSrcweir void ScPreview::RecalcPages() // nur nPageNo geaendert
293cdf0e10cSrcweir {
294cdf0e10cSrcweir if (!bValid)
295cdf0e10cSrcweir return; // dann wird CalcPages aufgerufen
296cdf0e10cSrcweir
297cdf0e10cSrcweir SCTAB nOldTab = nTab;
298cdf0e10cSrcweir
299cdf0e10cSrcweir sal_Bool bDone = sal_False;
300cdf0e10cSrcweir while (nPageNo >= nTotalPages && nTabsTested < nTabCount)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir CalcPages( nTabsTested );
303cdf0e10cSrcweir bDone = sal_True;
304cdf0e10cSrcweir }
305cdf0e10cSrcweir
306cdf0e10cSrcweir if (!bDone)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir long nPartPages = 0;
309cdf0e10cSrcweir for (SCTAB i=0; i<nTabsTested; i++)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir long nThisStart = nPartPages;
312cdf0e10cSrcweir nPartPages += nPages[i];
313cdf0e10cSrcweir
314cdf0e10cSrcweir if (nPageNo>=nThisStart && nPageNo<nPartPages)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir nTab = i;
317cdf0e10cSrcweir nTabPage = nPageNo - nThisStart;
318cdf0e10cSrcweir nTabStart = nThisStart;
319cdf0e10cSrcweir
320cdf0e10cSrcweir // aPageSize = aPrintFunc.GetPageSize();
321cdf0e10cSrcweir }
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
324cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument();
325cdf0e10cSrcweir nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir TestLastPage(); // testen, ob hinter letzter Seite
329cdf0e10cSrcweir
330cdf0e10cSrcweir if ( nTab != nOldTab )
331cdf0e10cSrcweir bStateValid = sal_False;
332cdf0e10cSrcweir
333cdf0e10cSrcweir DoInvalidate();
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
336cdf0e10cSrcweir
DoPrint(ScPreviewLocationData * pFillLocation)337cdf0e10cSrcweir void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir if (!bValid)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir CalcPages(0);
342cdf0e10cSrcweir RecalcPages();
343cdf0e10cSrcweir UpdateDrawView(); // Tabelle evtl. geaendert
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir Fraction aPreviewZoom( nZoom, 100 );
347cdf0e10cSrcweir Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
348cdf0e10cSrcweir MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
349cdf0e10cSrcweir
350cdf0e10cSrcweir sal_Bool bDoPrint = ( pFillLocation == NULL );
351cdf0e10cSrcweir sal_Bool bValidPage = ( nPageNo < nTotalPages );
352cdf0e10cSrcweir
353cdf0e10cSrcweir ScModule* pScMod = SC_MOD();
354cdf0e10cSrcweir const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
355cdf0e10cSrcweir Color aBackColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
356cdf0e10cSrcweir
357cdf0e10cSrcweir if ( bDoPrint && ( aOffset.X() < 0 || aOffset.Y() < 0 ) && bValidPage )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir SetMapMode( aMMMode );
360cdf0e10cSrcweir SetLineColor();
361cdf0e10cSrcweir SetFillColor(aBackColor);
362cdf0e10cSrcweir
363cdf0e10cSrcweir Size aWinSize = GetOutputSize();
364cdf0e10cSrcweir if ( aOffset.X() < 0 )
365cdf0e10cSrcweir DrawRect(Rectangle( 0, 0, -aOffset.X(), aWinSize.Height() ));
366cdf0e10cSrcweir if ( aOffset.Y() < 0 )
367cdf0e10cSrcweir DrawRect(Rectangle( 0, 0, aWinSize.Width(), -aOffset.Y() ));
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
370cdf0e10cSrcweir long nLeftMargin = 0;
371cdf0e10cSrcweir long nRightMargin = 0;
372cdf0e10cSrcweir long nTopMargin = 0;
373cdf0e10cSrcweir long nBottomMargin = 0;
374cdf0e10cSrcweir sal_Bool bHeaderOn = sal_False;
375cdf0e10cSrcweir sal_Bool bFooterOn = sal_False;
376cdf0e10cSrcweir
377cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument();
378cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
379cdf0e10cSrcweir
380cdf0e10cSrcweir Size aLocalPageSize;
381cdf0e10cSrcweir if ( bValidPage )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir ScPrintOptions aOptions = pScMod->GetPrintOptions();
384cdf0e10cSrcweir
385cdf0e10cSrcweir ScPrintFunc* pPrintFunc;
386cdf0e10cSrcweir if (bStateValid)
387cdf0e10cSrcweir pPrintFunc = new ScPrintFunc( this, pDocShell, aState, &aOptions );
388cdf0e10cSrcweir else
389cdf0e10cSrcweir pPrintFunc = new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
390cdf0e10cSrcweir
391cdf0e10cSrcweir pPrintFunc->SetOffset(aOffset);
392cdf0e10cSrcweir pPrintFunc->SetManualZoom(nZoom);
393cdf0e10cSrcweir pPrintFunc->SetDateTime(aDate,aTime);
394cdf0e10cSrcweir pPrintFunc->SetClearFlag(sal_True);
395cdf0e10cSrcweir pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() );
396cdf0e10cSrcweir
397cdf0e10cSrcweir pPrintFunc->SetDrawView( pDrawView );
398cdf0e10cSrcweir
399cdf0e10cSrcweir // MultiSelection fuer die eine Seite muss etwas umstaendlich erzeugt werden...
400cdf0e10cSrcweir Range aPageRange( nPageNo+1, nPageNo+1 );
401cdf0e10cSrcweir MultiSelection aPage( aPageRange );
402cdf0e10cSrcweir aPage.SetTotalRange( Range(0,RANGE_MAX) );
403cdf0e10cSrcweir aPage.Select( aPageRange );
404cdf0e10cSrcweir
405cdf0e10cSrcweir long nPrinted = pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart, bDoPrint, pFillLocation );
406cdf0e10cSrcweir DBG_ASSERT(nPrinted<=1, "was'n nu los?");
407cdf0e10cSrcweir
408cdf0e10cSrcweir SetMapMode(aMMMode);
409cdf0e10cSrcweir
410cdf0e10cSrcweir //init nLeftMargin ... in the ScPrintFunc::InitParam!!!
411cdf0e10cSrcweir nLeftMargin = pPrintFunc->GetLeftMargin();
412cdf0e10cSrcweir nRightMargin = pPrintFunc->GetRightMargin();
413cdf0e10cSrcweir nTopMargin = pPrintFunc->GetTopMargin();
414cdf0e10cSrcweir nBottomMargin = pPrintFunc->GetBottomMargin();
415cdf0e10cSrcweir nHeaderHeight = pPrintFunc->GetHeader().nHeight;
416cdf0e10cSrcweir nFooterHeight = pPrintFunc->GetFooter().nHeight;
417cdf0e10cSrcweir bHeaderOn = pPrintFunc->GetHeader().bEnable;
418cdf0e10cSrcweir bFooterOn = pPrintFunc->GetFooter().bEnable;
419cdf0e10cSrcweir mnScale = pPrintFunc->GetZoom();
420cdf0e10cSrcweir
421cdf0e10cSrcweir if ( bDoPrint && bPageMargin && pLocationData ) // don't make use of pLocationData while filling it
422cdf0e10cSrcweir {
423cdf0e10cSrcweir Rectangle aPixRect;
424cdf0e10cSrcweir Rectangle aRectCellPosition;
425cdf0e10cSrcweir Rectangle aRectPosition;
426cdf0e10cSrcweir pLocationData->GetMainCellRange( aPageArea, aPixRect );
427cdf0e10cSrcweir if( !bLayoutRTL )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir pLocationData->GetCellPosition( aPageArea.aStart, aRectPosition );
430cdf0e10cSrcweir nLeftPosition = aRectPosition.Left();
431cdf0e10cSrcweir for( SCCOL i = aPageArea.aStart.Col(); i <= aPageArea.aEnd.Col(); i++ )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir pLocationData->GetCellPosition( ScAddress( i,aPageArea.aStart.Row(),aPageArea.aStart.Tab()),aRectCellPosition );
434cdf0e10cSrcweir nRight[i] = aRectCellPosition.Right();
435cdf0e10cSrcweir }
436cdf0e10cSrcweir }
437cdf0e10cSrcweir else
438cdf0e10cSrcweir {
439cdf0e10cSrcweir pLocationData->GetCellPosition( aPageArea.aEnd, aRectPosition );
440cdf0e10cSrcweir nLeftPosition = aRectPosition.Right()+1;
441cdf0e10cSrcweir
442cdf0e10cSrcweir pLocationData->GetCellPosition( aPageArea.aStart,aRectCellPosition );
443cdf0e10cSrcweir nRight[ aPageArea.aEnd.Col() ] = aRectCellPosition.Left();
444cdf0e10cSrcweir for( SCCOL i = aPageArea.aEnd.Col(); i > aPageArea.aStart.Col(); i-- )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir pLocationData->GetCellPosition( ScAddress( i,aPageArea.aEnd.Row(),aPageArea.aEnd.Tab()),aRectCellPosition );
447cdf0e10cSrcweir nRight[ i-1 ] = nRight[ i ] + aRectCellPosition.Right() - aRectCellPosition.Left() + 1;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452cdf0e10cSrcweir if (nPrinted) // wenn nichts, alles grau zeichnen
453cdf0e10cSrcweir {
454cdf0e10cSrcweir aLocalPageSize = pPrintFunc->GetPageSize();
455cdf0e10cSrcweir aLocalPageSize.Width() = (long) (aLocalPageSize.Width() * HMM_PER_TWIPS );
456cdf0e10cSrcweir aLocalPageSize.Height() = (long) (aLocalPageSize.Height() * HMM_PER_TWIPS );
457cdf0e10cSrcweir
458cdf0e10cSrcweir nLeftMargin = (long) ( nLeftMargin * HMM_PER_TWIPS );
459cdf0e10cSrcweir nRightMargin = (long) ( nRightMargin * HMM_PER_TWIPS );
460cdf0e10cSrcweir nTopMargin = (long) ( nTopMargin * HMM_PER_TWIPS );
461cdf0e10cSrcweir nBottomMargin = (long) ( nBottomMargin * HMM_PER_TWIPS );
462cdf0e10cSrcweir nHeaderHeight = (long) ( nHeaderHeight * HMM_PER_TWIPS * mnScale / 100 + nTopMargin );
463cdf0e10cSrcweir nFooterHeight = (long) ( nFooterHeight * HMM_PER_TWIPS * mnScale / 100 + nBottomMargin );
464cdf0e10cSrcweir }
465cdf0e10cSrcweir
466cdf0e10cSrcweir if (!bStateValid)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir pPrintFunc->GetPrintState( aState );
469cdf0e10cSrcweir aState.nDocPages = nTotalPages;
470cdf0e10cSrcweir bStateValid = sal_True;
471cdf0e10cSrcweir }
472cdf0e10cSrcweir delete pPrintFunc;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir if ( bDoPrint )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir long nPageEndX = aLocalPageSize.Width() - aOffset.X();
478cdf0e10cSrcweir long nPageEndY = aLocalPageSize.Height() - aOffset.Y();
479cdf0e10cSrcweir if ( !bValidPage )
480cdf0e10cSrcweir nPageEndX = nPageEndY = 0;
481cdf0e10cSrcweir
482cdf0e10cSrcweir Size aWinSize = GetOutputSize();
483cdf0e10cSrcweir Point aWinEnd( aWinSize.Width(), aWinSize.Height() );
484cdf0e10cSrcweir sal_Bool bRight = nPageEndX <= aWinEnd.X();
485cdf0e10cSrcweir sal_Bool bBottom = nPageEndY <= aWinEnd.Y();
486cdf0e10cSrcweir
487cdf0e10cSrcweir if( bPageMargin && bValidPage )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir SetMapMode(aMMMode);
490cdf0e10cSrcweir SetLineColor( COL_BLACK );
491cdf0e10cSrcweir DrawInvert( (long)( nTopMargin - aOffset.Y() ), POINTER_VSIZEBAR );
492cdf0e10cSrcweir DrawInvert( (long)(nPageEndY - nBottomMargin ), POINTER_VSIZEBAR );
493cdf0e10cSrcweir DrawInvert( (long)( nLeftMargin - aOffset.X() ), POINTER_HSIZEBAR );
494cdf0e10cSrcweir DrawInvert( (long)( nPageEndX - nRightMargin ) , POINTER_HSIZEBAR );
495cdf0e10cSrcweir if( bHeaderOn )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir DrawInvert( nHeaderHeight - aOffset.Y(), POINTER_VSIZEBAR );
498cdf0e10cSrcweir }
499cdf0e10cSrcweir if( bFooterOn )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir DrawInvert( nPageEndY - nFooterHeight, POINTER_VSIZEBAR );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
504cdf0e10cSrcweir SetMapMode( MapMode( MAP_PIXEL ) );
505cdf0e10cSrcweir for( int i= aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
508cdf0e10cSrcweir SetLineColor( COL_BLACK );
509cdf0e10cSrcweir SetFillColor( COL_BLACK );
510cdf0e10cSrcweir DrawRect( Rectangle( Point( nRight[i] - 2, aColumnTop.Y() ),Point( nRight[i] + 2 , 4 + aColumnTop.Y()) ));
511cdf0e10cSrcweir DrawLine( Point( nRight[i], aColumnTop.Y() ), Point( nRight[i], 10 + aColumnTop.Y()) );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir SetMapMode( aMMMode );
514cdf0e10cSrcweir }
515cdf0e10cSrcweir
516cdf0e10cSrcweir if (bRight || bBottom)
517cdf0e10cSrcweir {
518cdf0e10cSrcweir SetMapMode(aMMMode);
519cdf0e10cSrcweir SetLineColor();
520cdf0e10cSrcweir SetFillColor(aBackColor);
521cdf0e10cSrcweir if (bRight)
522cdf0e10cSrcweir DrawRect(Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y()));
523cdf0e10cSrcweir if (bBottom)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir if (bRight)
526cdf0e10cSrcweir DrawRect(Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Ecke nicht doppelt
527cdf0e10cSrcweir else
528cdf0e10cSrcweir DrawRect(Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y()));
529cdf0e10cSrcweir }
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir if ( bValidPage )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir Color aBorderColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
535cdf0e10cSrcweir
536cdf0e10cSrcweir // draw border
537cdf0e10cSrcweir
538cdf0e10cSrcweir if ( aOffset.X() <= 0 || aOffset.Y() <= 0 || bRight || bBottom )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir SetLineColor( aBorderColor );
541cdf0e10cSrcweir SetFillColor();
542cdf0e10cSrcweir
543cdf0e10cSrcweir Rectangle aPixel( LogicToPixel( Rectangle( -aOffset.X(), -aOffset.Y(), nPageEndX, nPageEndY ) ) );
544cdf0e10cSrcweir --aPixel.Right();
545cdf0e10cSrcweir --aPixel.Bottom();
546cdf0e10cSrcweir DrawRect( PixelToLogic( aPixel ) );
547cdf0e10cSrcweir }
548cdf0e10cSrcweir
549cdf0e10cSrcweir // draw shadow
550cdf0e10cSrcweir
551*a246698eSmseidel // SetLineColor();
552*a246698eSmseidel // SetFillColor( aBorderColor );
553cdf0e10cSrcweir
554*a246698eSmseidel // Rectangle aPixel;
555cdf0e10cSrcweir
556*a246698eSmseidel // aPixel = LogicToPixel( Rectangle( nPageEndX, -aOffset.Y(), nPageEndX, nPageEndY ) );
557*a246698eSmseidel // aPixel.Top() += SC_PREVIEW_SHADOWSIZE;
558*a246698eSmseidel // aPixel.Right() += SC_PREVIEW_SHADOWSIZE - 1;
559*a246698eSmseidel // aPixel.Bottom() += SC_PREVIEW_SHADOWSIZE - 1;
560*a246698eSmseidel // DrawRect( PixelToLogic( aPixel ) );
561cdf0e10cSrcweir
562*a246698eSmseidel // aPixel = LogicToPixel( Rectangle( -aOffset.X(), nPageEndY, nPageEndX, nPageEndY ) );
563*a246698eSmseidel // aPixel.Left() += SC_PREVIEW_SHADOWSIZE;
564*a246698eSmseidel // aPixel.Right() += SC_PREVIEW_SHADOWSIZE - 1;
565*a246698eSmseidel // aPixel.Bottom() += SC_PREVIEW_SHADOWSIZE - 1;
566*a246698eSmseidel // DrawRect( PixelToLogic( aPixel ) );
567cdf0e10cSrcweir }
568cdf0e10cSrcweir }
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir //Issue51656 Add resizeable margin on page preview from maoyg
Paint(const Rectangle &)572cdf0e10cSrcweir void __EXPORT ScPreview::Paint( const Rectangle& /* rRect */ )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir bool bWasInPaint = bInPaint; // nested calls shouldn't be necessary, but allow for now
575cdf0e10cSrcweir bInPaint = true;
576cdf0e10cSrcweir
577cdf0e10cSrcweir if (bPageMargin)
578cdf0e10cSrcweir GetLocationData(); // fill location data for column positions
579cdf0e10cSrcweir DoPrint( NULL );
580cdf0e10cSrcweir pViewShell->UpdateScrollBars();
581cdf0e10cSrcweir
582cdf0e10cSrcweir bInPaint = bWasInPaint;
583cdf0e10cSrcweir }
584cdf0e10cSrcweir //Issue51656 Add resizeable margin on page preview from maoyg
585cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)586cdf0e10cSrcweir void __EXPORT ScPreview::Command( const CommandEvent& rCEvt )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir sal_uInt16 nCmd = rCEvt.GetCommand();
589cdf0e10cSrcweir if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir sal_Bool bDone = pViewShell->ScrollCommand( rCEvt );
592cdf0e10cSrcweir if (!bDone)
593cdf0e10cSrcweir Window::Command(rCEvt);
594cdf0e10cSrcweir }
595cdf0e10cSrcweir else if ( nCmd == COMMAND_CONTEXTMENU )
596cdf0e10cSrcweir SfxDispatcher::ExecutePopup();
597cdf0e10cSrcweir else
598cdf0e10cSrcweir Window::Command( rCEvt );
599cdf0e10cSrcweir }
600cdf0e10cSrcweir
601cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)602cdf0e10cSrcweir void __EXPORT ScPreview::KeyInput( const KeyEvent& rKEvt )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir // The + and - keys can't be configured as accelerator entries, so they must be handled directly
605cdf0e10cSrcweir // (in ScPreview, not ScPreviewShell -> only if the preview window has the focus)
606cdf0e10cSrcweir
607cdf0e10cSrcweir const KeyCode& rKeyCode = rKEvt.GetKeyCode();
608cdf0e10cSrcweir sal_uInt16 nKey = rKeyCode.GetCode();
609cdf0e10cSrcweir sal_Bool bHandled = sal_False;
610cdf0e10cSrcweir if(!rKeyCode.GetModifier())
611cdf0e10cSrcweir {
612cdf0e10cSrcweir sal_uInt16 nSlot = 0;
613cdf0e10cSrcweir switch(nKey)
614cdf0e10cSrcweir {
615cdf0e10cSrcweir case KEY_ADD: nSlot = SID_PREVIEW_ZOOMIN; break;
616cdf0e10cSrcweir case KEY_ESCAPE: nSlot = ScViewUtil::IsFullScreen( *pViewShell ) ? SID_CANCEL : SID_PREVIEW_CLOSE; break;
617cdf0e10cSrcweir case KEY_SUBTRACT: nSlot = SID_PREVIEW_ZOOMOUT; break;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir if(nSlot)
620cdf0e10cSrcweir {
621cdf0e10cSrcweir bHandled = sal_True;
622cdf0e10cSrcweir pViewShell->GetViewFrame()->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_ASYNCHRON );
623cdf0e10cSrcweir }
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir if ( !bHandled && !pViewShell->KeyInput(rKEvt) )
627cdf0e10cSrcweir Window::KeyInput(rKEvt);
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
630cdf0e10cSrcweir
GetLocationData()631cdf0e10cSrcweir const ScPreviewLocationData& ScPreview::GetLocationData()
632cdf0e10cSrcweir {
633cdf0e10cSrcweir if ( !pLocationData )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir pLocationData = new ScPreviewLocationData( pDocShell->GetDocument(), this );
636cdf0e10cSrcweir bLocationValid = sal_False;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir if ( !bLocationValid )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir pLocationData->Clear();
641cdf0e10cSrcweir DoPrint( pLocationData );
642cdf0e10cSrcweir bLocationValid = sal_True;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir return *pLocationData;
645cdf0e10cSrcweir }
646cdf0e10cSrcweir
647cdf0e10cSrcweir
DataChanged(sal_Bool bNewTime)648cdf0e10cSrcweir void ScPreview::DataChanged(sal_Bool bNewTime)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir if (bNewTime)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir aDate = Date();
653cdf0e10cSrcweir aTime = Time();
654cdf0e10cSrcweir }
655cdf0e10cSrcweir
656cdf0e10cSrcweir bValid = sal_False;
657cdf0e10cSrcweir InvalidateLocationData( SC_HINT_DATACHANGED );
658cdf0e10cSrcweir Invalidate();
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir
GetPosString()662cdf0e10cSrcweir String ScPreview::GetPosString()
663cdf0e10cSrcweir {
664cdf0e10cSrcweir if (!bValid)
665cdf0e10cSrcweir {
666cdf0e10cSrcweir CalcPages(nTab);
667cdf0e10cSrcweir UpdateDrawView(); // Tabelle evtl. geaendert
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
670cdf0e10cSrcweir String aString( ScGlobal::GetRscString( STR_PAGE ) );
671cdf0e10cSrcweir aString += ' ';
672cdf0e10cSrcweir aString += String::CreateFromInt32(nPageNo+1);
673cdf0e10cSrcweir
674cdf0e10cSrcweir if (nTabsTested >= nTabCount)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
677cdf0e10cSrcweir aString += String::CreateFromInt32(nTotalPages);
678cdf0e10cSrcweir }
679cdf0e10cSrcweir
680cdf0e10cSrcweir return aString;
681cdf0e10cSrcweir }
682cdf0e10cSrcweir
683cdf0e10cSrcweir
SetZoom(sal_uInt16 nNewZoom)684cdf0e10cSrcweir void ScPreview::SetZoom(sal_uInt16 nNewZoom)
685cdf0e10cSrcweir {
686cdf0e10cSrcweir if (nNewZoom < 20)
687cdf0e10cSrcweir nNewZoom = 20;
688cdf0e10cSrcweir if (nNewZoom > 400)
689cdf0e10cSrcweir nNewZoom = 400;
690cdf0e10cSrcweir if (nNewZoom != nZoom)
691cdf0e10cSrcweir {
692cdf0e10cSrcweir nZoom = nNewZoom;
693cdf0e10cSrcweir
694cdf0e10cSrcweir // apply new MapMode and call UpdateScrollBars to update aOffset
695cdf0e10cSrcweir
696cdf0e10cSrcweir Fraction aPreviewZoom( nZoom, 100 );
697cdf0e10cSrcweir Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
698cdf0e10cSrcweir MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
699cdf0e10cSrcweir SetMapMode( aMMMode );
700cdf0e10cSrcweir
701cdf0e10cSrcweir bInSetZoom = true; // don't scroll during SetYOffset in UpdateScrollBars
702cdf0e10cSrcweir pViewShell->UpdateScrollBars();
703cdf0e10cSrcweir bInSetZoom = false;
704cdf0e10cSrcweir
705cdf0e10cSrcweir bStateValid = sal_False;
706cdf0e10cSrcweir InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
707cdf0e10cSrcweir DoInvalidate();
708cdf0e10cSrcweir Invalidate();
709cdf0e10cSrcweir }
710cdf0e10cSrcweir }
711cdf0e10cSrcweir
712cdf0e10cSrcweir
SetPageNo(long nPage)713cdf0e10cSrcweir void ScPreview::SetPageNo( long nPage )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir nPageNo = nPage;
716cdf0e10cSrcweir RecalcPages();
717cdf0e10cSrcweir UpdateDrawView(); // Tabelle evtl. geaendert
718cdf0e10cSrcweir InvalidateLocationData( SC_HINT_DATACHANGED );
719cdf0e10cSrcweir Invalidate();
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir
GetFirstPage(SCTAB nTabP)723cdf0e10cSrcweir long ScPreview::GetFirstPage(SCTAB nTabP)
724cdf0e10cSrcweir {
725cdf0e10cSrcweir SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount();
726cdf0e10cSrcweir if (nTabP >= nDocTabCount)
727cdf0e10cSrcweir nTabP = nDocTabCount-1;
728cdf0e10cSrcweir
729cdf0e10cSrcweir long nPage = 0;
730cdf0e10cSrcweir if (nTabP>0)
731cdf0e10cSrcweir {
732cdf0e10cSrcweir CalcPages( nTabP );
733cdf0e10cSrcweir UpdateDrawView(); // Tabelle evtl. geaendert
734cdf0e10cSrcweir
735cdf0e10cSrcweir for (SCTAB i=0; i<nTabP; i++)
736cdf0e10cSrcweir nPage += nPages[i];
737cdf0e10cSrcweir
738cdf0e10cSrcweir // bei leerer Tabelle vorhergehende Seite
739cdf0e10cSrcweir
740cdf0e10cSrcweir if ( nPages[nTabP]==0 && nPage > 0 )
741cdf0e10cSrcweir --nPage;
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
744cdf0e10cSrcweir return nPage;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir
747cdf0e10cSrcweir
lcl_GetDocPageSize(ScDocument * pDoc,SCTAB nTab)748cdf0e10cSrcweir Size lcl_GetDocPageSize( ScDocument* pDoc, SCTAB nTab )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir String aName = pDoc->GetPageStyle( nTab );
751cdf0e10cSrcweir ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
752cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aName, SFX_STYLE_FAMILY_PAGE );
753cdf0e10cSrcweir if ( pStyleSheet )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
756cdf0e10cSrcweir return ((const SvxSizeItem&) rStyleSet.Get(ATTR_PAGE_SIZE)).GetSize();
757cdf0e10cSrcweir }
758cdf0e10cSrcweir else
759cdf0e10cSrcweir {
760cdf0e10cSrcweir DBG_ERROR( "PageStyle not found" );
761cdf0e10cSrcweir return Size();
762cdf0e10cSrcweir }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir
GetOptimalZoom(sal_Bool bWidthOnly)766cdf0e10cSrcweir sal_uInt16 ScPreview::GetOptimalZoom(sal_Bool bWidthOnly)
767cdf0e10cSrcweir {
768cdf0e10cSrcweir double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor();
769cdf0e10cSrcweir double nWinScaleY = ScGlobal::nScreenPPTY;
770cdf0e10cSrcweir Size aWinSize = GetOutputSizePixel();
771cdf0e10cSrcweir
772cdf0e10cSrcweir // desired margin is 0.25cm in default MapMode (like Writer),
773cdf0e10cSrcweir // but some additional margin is introduced by integer scale values
774cdf0e10cSrcweir // -> add only 0.10cm, so there is some margin in all cases.
775cdf0e10cSrcweir Size aMarginSize( LogicToPixel( Size( 100, 100 ), MAP_100TH_MM ) );
776cdf0e10cSrcweir aWinSize.Width() -= 2 * aMarginSize.Width();
777cdf0e10cSrcweir aWinSize.Height() -= 2 * aMarginSize.Height();
778cdf0e10cSrcweir
779cdf0e10cSrcweir Size aLocalPageSize = lcl_GetDocPageSize( pDocShell->GetDocument(), nTab );
780cdf0e10cSrcweir if ( aLocalPageSize.Width() && aLocalPageSize.Height() )
781cdf0e10cSrcweir {
782cdf0e10cSrcweir long nZoomX = (long) ( aWinSize.Width() * 100 / ( aLocalPageSize.Width() * nWinScaleX ));
783cdf0e10cSrcweir long nZoomY = (long) ( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY ));
784cdf0e10cSrcweir
785cdf0e10cSrcweir long nOptimal = nZoomX;
786cdf0e10cSrcweir if (!bWidthOnly && nZoomY<nOptimal)
787cdf0e10cSrcweir nOptimal = nZoomY;
788cdf0e10cSrcweir
789cdf0e10cSrcweir if (nOptimal<20)
790cdf0e10cSrcweir nOptimal = 20;
791cdf0e10cSrcweir if (nOptimal>400)
792cdf0e10cSrcweir nOptimal = 400;
793cdf0e10cSrcweir
794cdf0e10cSrcweir return (sal_uInt16) nOptimal;
795cdf0e10cSrcweir }
796cdf0e10cSrcweir else
797cdf0e10cSrcweir return nZoom;
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
800cdf0e10cSrcweir
SetXOffset(long nX)801cdf0e10cSrcweir void ScPreview::SetXOffset( long nX )
802cdf0e10cSrcweir {
803cdf0e10cSrcweir if ( aOffset.X() == nX )
804cdf0e10cSrcweir return;
805cdf0e10cSrcweir
806cdf0e10cSrcweir if (bValid)
807cdf0e10cSrcweir {
808cdf0e10cSrcweir long nDif = LogicToPixel(aOffset).X() - LogicToPixel(Point(nX,0)).X();
809cdf0e10cSrcweir aOffset.X() = nX;
810cdf0e10cSrcweir if (nDif && !bInSetZoom)
811cdf0e10cSrcweir {
812cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL);
813cdf0e10cSrcweir Scroll( nDif, 0 );
814cdf0e10cSrcweir SetMapMode(aOldMode);
815cdf0e10cSrcweir }
816cdf0e10cSrcweir }
817cdf0e10cSrcweir else
818cdf0e10cSrcweir {
819cdf0e10cSrcweir aOffset.X() = nX;
820cdf0e10cSrcweir if (!bInSetZoom)
821cdf0e10cSrcweir Invalidate();
822cdf0e10cSrcweir }
823cdf0e10cSrcweir InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
824cdf0e10cSrcweir Paint(Rectangle());
825cdf0e10cSrcweir }
826cdf0e10cSrcweir
827cdf0e10cSrcweir
SetYOffset(long nY)828cdf0e10cSrcweir void ScPreview::SetYOffset( long nY )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir if ( aOffset.Y() == nY )
831cdf0e10cSrcweir return;
832cdf0e10cSrcweir
833cdf0e10cSrcweir if (bValid)
834cdf0e10cSrcweir {
835cdf0e10cSrcweir long nDif = LogicToPixel(aOffset).Y() - LogicToPixel(Point(0,nY)).Y();
836cdf0e10cSrcweir aOffset.Y() = nY;
837cdf0e10cSrcweir if (nDif && !bInSetZoom)
838cdf0e10cSrcweir {
839cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL);
840cdf0e10cSrcweir Scroll( 0, nDif );
841cdf0e10cSrcweir SetMapMode(aOldMode);
842cdf0e10cSrcweir }
843cdf0e10cSrcweir }
844cdf0e10cSrcweir else
845cdf0e10cSrcweir {
846cdf0e10cSrcweir aOffset.Y() = nY;
847cdf0e10cSrcweir if (!bInSetZoom)
848cdf0e10cSrcweir Invalidate();
849cdf0e10cSrcweir }
850cdf0e10cSrcweir InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
851cdf0e10cSrcweir Paint(Rectangle());
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
854cdf0e10cSrcweir
DoInvalidate()855cdf0e10cSrcweir void ScPreview::DoInvalidate()
856cdf0e10cSrcweir {
857cdf0e10cSrcweir // Wenn das ganze aus dem GetState der Shell gerufen wird,
858cdf0e10cSrcweir // muss das Invalidate hinterher asynchron kommen...
859cdf0e10cSrcweir
860cdf0e10cSrcweir if (bInGetState)
861cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK( this, ScPreview, InvalidateHdl ) );
862cdf0e10cSrcweir else
863cdf0e10cSrcweir StaticInvalidate(); // sofort
864cdf0e10cSrcweir }
865cdf0e10cSrcweir
StaticInvalidate()866cdf0e10cSrcweir void ScPreview::StaticInvalidate()
867cdf0e10cSrcweir {
868cdf0e10cSrcweir // static method, because it's called asynchronously
869cdf0e10cSrcweir // -> must use current viewframe
870cdf0e10cSrcweir
871cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current();
872cdf0e10cSrcweir if (!pViewFrm)
873cdf0e10cSrcweir return;
874cdf0e10cSrcweir
875cdf0e10cSrcweir SfxBindings& rBindings = pViewFrm->GetBindings();
876cdf0e10cSrcweir rBindings.Invalidate(SID_STATUS_DOCPOS);
877cdf0e10cSrcweir rBindings.Invalidate(SID_STATUS_PAGESTYLE);
878cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_PREVIOUS);
879cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_NEXT);
880cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_FIRST);
881cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_LAST);
882cdf0e10cSrcweir rBindings.Invalidate(SID_ATTR_ZOOM);
883cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_ZOOMIN);
884cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_ZOOMOUT);
885cdf0e10cSrcweir rBindings.Invalidate(SID_PREVIEW_SCALINGFACTOR);
886cdf0e10cSrcweir rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
887cdf0e10cSrcweir }
888cdf0e10cSrcweir
IMPL_STATIC_LINK(ScPreview,InvalidateHdl,void *,EMPTYARG)889cdf0e10cSrcweir IMPL_STATIC_LINK( ScPreview, InvalidateHdl, void*, EMPTYARG )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir (void)pThis; // avoid warning
892cdf0e10cSrcweir
893cdf0e10cSrcweir StaticInvalidate();
894cdf0e10cSrcweir return 0;
895cdf0e10cSrcweir }
896cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)897cdf0e10cSrcweir void ScPreview::DataChanged( const DataChangedEvent& rDCEvt )
898cdf0e10cSrcweir {
899cdf0e10cSrcweir Window::DataChanged(rDCEvt);
900cdf0e10cSrcweir
901cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
902cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
903cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTS) ||
904cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
905cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
906cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
907cdf0e10cSrcweir {
908cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_FONTS )
909cdf0e10cSrcweir pDocShell->UpdateFontList();
910cdf0e10cSrcweir
911cdf0e10cSrcweir // #i114518# Paint of form controls may modify the window's settings.
912cdf0e10cSrcweir // Ignore the event if it is called from within Paint.
913cdf0e10cSrcweir if ( !bInPaint )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
916cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) )
917cdf0e10cSrcweir {
918cdf0e10cSrcweir // scroll bar size may have changed
919cdf0e10cSrcweir pViewShell->InvalidateBorder(); // calls OuterResizePixel
920cdf0e10cSrcweir }
921cdf0e10cSrcweir
922cdf0e10cSrcweir Invalidate();
923cdf0e10cSrcweir InvalidateLocationData( SC_HINT_DATACHANGED );
924cdf0e10cSrcweir }
925cdf0e10cSrcweir }
926cdf0e10cSrcweir }
927cdf0e10cSrcweir
928cdf0e10cSrcweir //Issue51656 Add resizeable margin on page preview from maoyg
MouseButtonDown(const MouseEvent & rMEvt)929cdf0e10cSrcweir void __EXPORT ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir Fraction aPreviewZoom( nZoom, 100 );
932cdf0e10cSrcweir Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
933cdf0e10cSrcweir MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
934cdf0e10cSrcweir
935cdf0e10cSrcweir aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
936cdf0e10cSrcweir aButtonDownPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
937cdf0e10cSrcweir
938cdf0e10cSrcweir CaptureMouse();
939cdf0e10cSrcweir
940cdf0e10cSrcweir if( rMEvt.IsLeft() && GetPointer() == POINTER_HSIZEBAR )
941cdf0e10cSrcweir {
942cdf0e10cSrcweir SetMapMode( aMMMode );
943cdf0e10cSrcweir if( bLeftRulerChange )
944cdf0e10cSrcweir {
945cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
946cdf0e10cSrcweir bLeftRulerMove = sal_True;
947cdf0e10cSrcweir bRightRulerMove = sal_False;
948cdf0e10cSrcweir }
949cdf0e10cSrcweir else if( bRightRulerChange )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
952cdf0e10cSrcweir bLeftRulerMove = sal_False;
953cdf0e10cSrcweir bRightRulerMove = sal_True;
954cdf0e10cSrcweir }
955cdf0e10cSrcweir }
956cdf0e10cSrcweir
957cdf0e10cSrcweir if( rMEvt.IsLeft() && GetPointer() == POINTER_VSIZEBAR )
958cdf0e10cSrcweir {
959cdf0e10cSrcweir SetMapMode( aMMMode );
960cdf0e10cSrcweir if( bTopRulerChange )
961cdf0e10cSrcweir {
962cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
963cdf0e10cSrcweir bTopRulerMove = sal_True;
964cdf0e10cSrcweir bBottomRulerMove = sal_False;
965cdf0e10cSrcweir }
966cdf0e10cSrcweir else if( bBottomRulerChange )
967cdf0e10cSrcweir {
968cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
969cdf0e10cSrcweir bTopRulerMove = sal_False;
970cdf0e10cSrcweir bBottomRulerMove = sal_True;
971cdf0e10cSrcweir }
972cdf0e10cSrcweir else if( bHeaderRulerChange )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
975cdf0e10cSrcweir bHeaderRulerMove = sal_True;
976cdf0e10cSrcweir bFooterRulerMove = sal_False;
977cdf0e10cSrcweir }
978cdf0e10cSrcweir else if( bFooterRulerChange )
979cdf0e10cSrcweir {
980cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
981cdf0e10cSrcweir bHeaderRulerMove = sal_False;
982cdf0e10cSrcweir bFooterRulerMove = sal_True;
983cdf0e10cSrcweir }
984cdf0e10cSrcweir }
985cdf0e10cSrcweir
986cdf0e10cSrcweir if( rMEvt.IsLeft() && GetPointer() == POINTER_HSPLIT )
987cdf0e10cSrcweir {
988cdf0e10cSrcweir Point aNowPt = rMEvt.GetPosPixel();
989cdf0e10cSrcweir SCCOL i = 0;
990cdf0e10cSrcweir for( i = aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir if( aNowPt.X() < nRight[i] + 2 && aNowPt.X() > nRight[i] - 2 )
993cdf0e10cSrcweir {
994cdf0e10cSrcweir nColNumberButttonDown = i;
995cdf0e10cSrcweir break;
996cdf0e10cSrcweir }
997cdf0e10cSrcweir }
998cdf0e10cSrcweir if( i == aPageArea.aEnd.Col()+1 )
999cdf0e10cSrcweir return;
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir SetMapMode( aMMMode );
1002cdf0e10cSrcweir if( nColNumberButttonDown == aPageArea.aStart.Col() )
1003cdf0e10cSrcweir DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,POINTER_HSPLIT );
1004cdf0e10cSrcweir else
1005cdf0e10cSrcweir DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.X(), POINTER_HSPLIT );
1008cdf0e10cSrcweir bColRulerMove = sal_True;
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rMEvt)1012cdf0e10cSrcweir void __EXPORT ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir Fraction aPreviewZoom( nZoom, 100 );
1015cdf0e10cSrcweir Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
1016cdf0e10cSrcweir MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir long nWidth = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width();
1021cdf0e10cSrcweir long nHeight = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height();
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir if( rMEvt.IsLeft() && GetPointer() == POINTER_HSIZEBAR )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) );
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir sal_Bool bMoveRulerAction= sal_True;
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir ScDocument * pDoc = pDocShell->GetDocument();
1030cdf0e10cSrcweir String aOldName = pDoc->GetPageStyle( nTab );
1031cdf0e10cSrcweir sal_Bool bUndo( pDoc->IsUndoEnabled() );
1032cdf0e10cSrcweir ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1033cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir if ( pStyleSheet )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir ScStyleSaveData aOldData;
1038cdf0e10cSrcweir if( bUndo )
1039cdf0e10cSrcweir aOldData.InitFromStyle( pStyleSheet );
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir SvxLRSpaceItem aLRItem = ( const SvxLRSpaceItem& ) rStyleSet.Get( ATTR_LRSPACE );
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir if(( bLeftRulerChange || bRightRulerChange ) && ( aButtonUpPt.X() <= ( 0 - aOffset.X() ) || aButtonUpPt.X() > nWidth * HMM_PER_TWIPS - aOffset.X() ) )
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir bMoveRulerAction = sal_False;
1048cdf0e10cSrcweir Paint(Rectangle(0,0,10000,10000));
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir else if( bLeftRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS > nWidth - aLRItem.GetRight() - aOffset.X() / HMM_PER_TWIPS ) )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir bMoveRulerAction = sal_False;
1053cdf0e10cSrcweir Paint(Rectangle(0,0,10000,10000));
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir else if( bRightRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS < aLRItem.GetLeft() - aOffset.X() / HMM_PER_TWIPS ) )
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir bMoveRulerAction = sal_False;
1058cdf0e10cSrcweir Paint(Rectangle(0,0,10000,10000));
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir else if( aButtonDownPt.X() == aButtonUpPt.X() )
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir bMoveRulerAction = sal_False;
1063cdf0e10cSrcweir DrawInvert( aButtonUpPt.X(), POINTER_HSIZEBAR );
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir if( bMoveRulerAction )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir ScDocShellModificator aModificator( *pDocShell );
1068cdf0e10cSrcweir if( bLeftRulerChange && bLeftRulerMove )
1069cdf0e10cSrcweir {
1070cdf0e10cSrcweir aLRItem.SetLeft( (long)( aButtonUpPt.X() / HMM_PER_TWIPS + aOffset.X() / HMM_PER_TWIPS ));
1071cdf0e10cSrcweir rStyleSet.Put( aLRItem );
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir else if( bRightRulerChange && bRightRulerMove )
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir aLRItem.SetRight( (long)( nWidth - aButtonUpPt.X() / HMM_PER_TWIPS - aOffset.X() / HMM_PER_TWIPS ));
1076cdf0e10cSrcweir rStyleSet.Put( aLRItem );
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir
1079cdf0e10cSrcweir ScStyleSaveData aNewData;
1080cdf0e10cSrcweir aNewData.InitFromStyle( pStyleSheet );
1081cdf0e10cSrcweir if( bUndo )
1082cdf0e10cSrcweir {
1083cdf0e10cSrcweir pDocShell->GetUndoManager()->AddUndoAction(
1084cdf0e10cSrcweir new ScUndoModifyStyle( pDocShell, SFX_STYLE_FAMILY_PAGE,
1085cdf0e10cSrcweir aOldData, aNewData ) );
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir if ( ValidTab( nTab ) )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, pDocShell, nTab );
1091cdf0e10cSrcweir aPrintFunc.UpdatePages();
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir Rectangle aRect(0,0,10000,10000);
1095cdf0e10cSrcweir Paint( aRect );
1096cdf0e10cSrcweir aModificator.SetDocumentModified();
1097cdf0e10cSrcweir bLeftRulerChange = sal_False;
1098cdf0e10cSrcweir bRightRulerChange = sal_False;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir bLeftRulerMove = sal_False;
1102cdf0e10cSrcweir bRightRulerMove = sal_False;
1103cdf0e10cSrcweir }
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir if( rMEvt.IsLeft() && GetPointer() == POINTER_VSIZEBAR )
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir SetPointer( POINTER_ARROW );
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir sal_Bool bMoveRulerAction = sal_True;
1110cdf0e10cSrcweir if( ( bTopRulerChange || bBottomRulerChange || bHeaderRulerChange || bFooterRulerChange ) && ( aButtonUpPt.Y() <= ( 0 - aOffset.Y() ) || aButtonUpPt.Y() > nHeight * HMM_PER_TWIPS -aOffset.Y() ) )
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir bMoveRulerAction = sal_False;
1113cdf0e10cSrcweir Paint( Rectangle(0,0,10000,10000) );
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir else if( aButtonDownPt.Y() == aButtonUpPt.Y() )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir bMoveRulerAction = sal_False;
1118cdf0e10cSrcweir DrawInvert( aButtonUpPt.Y(), POINTER_VSIZEBAR );
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir if( bMoveRulerAction )
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir ScDocument * pDoc = pDocShell->GetDocument();
1123cdf0e10cSrcweir sal_Bool bUndo( pDoc->IsUndoEnabled() );
1124cdf0e10cSrcweir ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1125cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
1126cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found" );
1127cdf0e10cSrcweir if ( pStyleSheet )
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir ScDocShellModificator aModificator( *pDocShell );
1130cdf0e10cSrcweir ScStyleSaveData aOldData;
1131cdf0e10cSrcweir if( bUndo )
1132cdf0e10cSrcweir aOldData.InitFromStyle( pStyleSheet );
1133cdf0e10cSrcweir
1134cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir SvxULSpaceItem aULItem = ( const SvxULSpaceItem&)rStyleSet.Get( ATTR_ULSPACE );
1137cdf0e10cSrcweir
1138cdf0e10cSrcweir if( bTopRulerMove && bTopRulerChange )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir aULItem.SetUpperValue( (sal_uInt16)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS ) );
1141cdf0e10cSrcweir rStyleSet.Put( aULItem );
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir else if( bBottomRulerMove && bBottomRulerChange )
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir aULItem.SetLowerValue( (sal_uInt16)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS ) );
1146cdf0e10cSrcweir rStyleSet.Put( aULItem );
1147cdf0e10cSrcweir }
1148cdf0e10cSrcweir else if( bHeaderRulerMove && bHeaderRulerChange )
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir const SfxPoolItem* pItem = NULL;
1151cdf0e10cSrcweir if ( rStyleSet.GetItemState( ATTR_PAGE_HEADERSET, sal_False, &pItem ) == SFX_ITEM_SET )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir SfxItemSet& pHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
1154cdf0e10cSrcweir Size aHeaderSize = ((const SvxSizeItem&)pHeaderSet.Get(ATTR_PAGE_SIZE)).GetSize();
1155cdf0e10cSrcweir aHeaderSize.Height() = (long)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS - aULItem.GetUpper());
1156cdf0e10cSrcweir aHeaderSize.Height() = aHeaderSize.Height() * 100 / mnScale;
1157cdf0e10cSrcweir SvxSetItem aNewHeader( (const SvxSetItem&)rStyleSet.Get(ATTR_PAGE_HEADERSET) );
1158cdf0e10cSrcweir aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aHeaderSize ) );
1159cdf0e10cSrcweir rStyleSet.Put( aNewHeader );
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir }
1162cdf0e10cSrcweir else if( bFooterRulerMove && bFooterRulerChange )
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir const SfxPoolItem* pItem = NULL;
1165cdf0e10cSrcweir if( rStyleSet.GetItemState( ATTR_PAGE_FOOTERSET, sal_False, &pItem ) == SFX_ITEM_SET )
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir SfxItemSet& pFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
1168cdf0e10cSrcweir Size aFooterSize = ((const SvxSizeItem&)pFooterSet.Get(ATTR_PAGE_SIZE)).GetSize();
1169cdf0e10cSrcweir aFooterSize.Height() = (long)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS - aULItem.GetLower() );
1170cdf0e10cSrcweir aFooterSize.Height() = aFooterSize.Height() * 100 / mnScale;
1171cdf0e10cSrcweir SvxSetItem aNewFooter( (const SvxSetItem&)rStyleSet.Get(ATTR_PAGE_FOOTERSET) );
1172cdf0e10cSrcweir aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aFooterSize ) );
1173cdf0e10cSrcweir rStyleSet.Put( aNewFooter );
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir ScStyleSaveData aNewData;
1178cdf0e10cSrcweir aNewData.InitFromStyle( pStyleSheet );
1179cdf0e10cSrcweir if( bUndo )
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir pDocShell->GetUndoManager()->AddUndoAction(
1182cdf0e10cSrcweir new ScUndoModifyStyle( pDocShell, SFX_STYLE_FAMILY_PAGE,
1183cdf0e10cSrcweir aOldData, aNewData ) );
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir if ( ValidTab( nTab ) )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, pDocShell, nTab );
1189cdf0e10cSrcweir aPrintFunc.UpdatePages();
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir Rectangle aRect(0,0,10000,10000);
1193cdf0e10cSrcweir Paint( aRect );
1194cdf0e10cSrcweir aModificator.SetDocumentModified();
1195cdf0e10cSrcweir bTopRulerChange = sal_False;
1196cdf0e10cSrcweir bBottomRulerChange = sal_False;
1197cdf0e10cSrcweir bHeaderRulerChange = sal_False;
1198cdf0e10cSrcweir bFooterRulerChange = sal_False;
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir bTopRulerMove = sal_False;
1202cdf0e10cSrcweir bBottomRulerMove = sal_False;
1203cdf0e10cSrcweir bHeaderRulerMove = sal_False;
1204cdf0e10cSrcweir bFooterRulerMove = sal_False;
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir if( rMEvt.IsLeft() && GetPointer() == POINTER_HSPLIT )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir SetPointer(POINTER_ARROW);
1209cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument();
1210cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
1211cdf0e10cSrcweir sal_Bool bMoveRulerAction = sal_True;
1212cdf0e10cSrcweir if( aButtonDownPt.X() == aButtonUpPt.X() )
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir bMoveRulerAction = sal_False;
1215cdf0e10cSrcweir if( nColNumberButttonDown == aPageArea.aStart.Col() )
1216cdf0e10cSrcweir DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,POINTER_HSPLIT );
1217cdf0e10cSrcweir else
1218cdf0e10cSrcweir DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
1219cdf0e10cSrcweir DrawInvert( aButtonUpPt.X(), POINTER_HSPLIT );
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir if( bMoveRulerAction )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir long nNewColWidth = 0;
1224cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell);
1225cdf0e10cSrcweir SCCOLROW nCols[2] = { nColNumberButttonDown, nColNumberButttonDown };
1226cdf0e10cSrcweir
1227cdf0e10cSrcweir if( !bLayoutRTL )
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir nNewColWidth = (long) ( PixelToLogic( Point( rMEvt.GetPosPixel().X() - nRight[ nColNumberButttonDown ], 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
1230cdf0e10cSrcweir nNewColWidth += pDocShell->GetDocument()->GetColWidth( nColNumberButttonDown, nTab );
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir else
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir nNewColWidth = (long) ( PixelToLogic( Point( nRight[ nColNumberButttonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
1236cdf0e10cSrcweir nNewColWidth += pDocShell->GetDocument()->GetColWidth( nColNumberButttonDown, nTab );
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir if( nNewColWidth >= 0 )
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir aFunc.SetWidthOrHeight( sal_True, 1,nCols, nTab, SC_SIZE_DIRECT, (sal_uInt16)nNewColWidth, sal_True, sal_True);
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir if ( ValidTab( nTab ) )
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, pDocShell, nTab );
1246cdf0e10cSrcweir aPrintFunc.UpdatePages();
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir Rectangle nRect(0,0,10000,10000);
1249cdf0e10cSrcweir Paint( nRect );
1250cdf0e10cSrcweir }
1251cdf0e10cSrcweir bColRulerMove = sal_False;
1252cdf0e10cSrcweir }
1253cdf0e10cSrcweir ReleaseMouse();
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir
MouseMove(const MouseEvent & rMEvt)1256cdf0e10cSrcweir void __EXPORT ScPreview::MouseMove( const MouseEvent& rMEvt )
1257cdf0e10cSrcweir {
1258cdf0e10cSrcweir Fraction aPreviewZoom( nZoom, 100 );
1259cdf0e10cSrcweir Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
1260cdf0e10cSrcweir MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
1261cdf0e10cSrcweir Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode );
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir long nLeftMargin = 0;
1264cdf0e10cSrcweir long nRightMargin = 0;
1265cdf0e10cSrcweir long nTopMargin = 0;
1266cdf0e10cSrcweir long nBottomMargin = 0;
1267cdf0e10cSrcweir Size PageSize;
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir long nWidth = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width();
1270cdf0e10cSrcweir long nHeight = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height();
1271cdf0e10cSrcweir
1272cdf0e10cSrcweir if ( nPageNo < nTotalPages )
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir ScPrintFunc* pPrintFunc;
1277cdf0e10cSrcweir
1278cdf0e10cSrcweir if (bStateValid)
1279cdf0e10cSrcweir pPrintFunc = new ScPrintFunc( this, pDocShell, aState, &aOptions );
1280cdf0e10cSrcweir else
1281cdf0e10cSrcweir pPrintFunc = new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir nLeftMargin = (long)( pPrintFunc->GetLeftMargin() * HMM_PER_TWIPS - aOffset.X() );
1284cdf0e10cSrcweir nRightMargin = (long)( pPrintFunc->GetRightMargin() * HMM_PER_TWIPS );
1285cdf0e10cSrcweir nRightMargin = (long)( nWidth * HMM_PER_TWIPS - nRightMargin - aOffset.X() );
1286cdf0e10cSrcweir nTopMargin = (long)( pPrintFunc->GetTopMargin() * HMM_PER_TWIPS - aOffset.Y() );
1287cdf0e10cSrcweir nBottomMargin = (long)( pPrintFunc->GetBottomMargin() * HMM_PER_TWIPS );
1288cdf0e10cSrcweir nBottomMargin = (long)( nHeight * HMM_PER_TWIPS - nBottomMargin - aOffset.Y() );
1289cdf0e10cSrcweir if( mnScale > 0 )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS * mnScale / 100 );
1292cdf0e10cSrcweir nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS * mnScale / 100 );
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir else
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS );
1297cdf0e10cSrcweir nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS );
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir delete pPrintFunc;
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir Point aPixPt( rMEvt.GetPosPixel() );
1303cdf0e10cSrcweir Point aLeftTop = LogicToPixel( Point( nLeftMargin, -aOffset.Y() ) , aMMMode );
1304cdf0e10cSrcweir Point aLeftBottom = LogicToPixel( Point( nLeftMargin ,(long)(nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
1305cdf0e10cSrcweir Point aRightTop = LogicToPixel( Point( nRightMargin, -aOffset.Y() ), aMMMode );
1306cdf0e10cSrcweir Point aTopLeft = LogicToPixel( Point( -aOffset.X(), nTopMargin ), aMMMode );
1307cdf0e10cSrcweir Point aTopRight = LogicToPixel( Point( (long)(nWidth * HMM_PER_TWIPS - aOffset.X()), nTopMargin ), aMMMode );
1308cdf0e10cSrcweir Point aBottomLeft = LogicToPixel( Point( -aOffset.X(), nBottomMargin ), aMMMode );
1309cdf0e10cSrcweir Point aHeaderLeft = LogicToPixel( Point( -aOffset.X(), nHeaderHeight ), aMMMode );
1310cdf0e10cSrcweir Point aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode );
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir sal_Bool bOnColRulerChange = sal_False;
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
1317cdf0e10cSrcweir Point aColumnBottom = LogicToPixel( Point( 0, (long)( nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
1318cdf0e10cSrcweir if( aPixPt.X() < ( nRight[i] + 2 ) && ( aPixPt.X() > ( nRight[i] - 2 ) ) && ( aPixPt.X() < aRightTop.X() ) && ( aPixPt.X() > aLeftTop.X() )
1319cdf0e10cSrcweir && ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove
1320cdf0e10cSrcweir && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir bOnColRulerChange = sal_True;
1323cdf0e10cSrcweir if( !rMEvt.GetButtons() && GetPointer() == POINTER_HSPLIT )
1324cdf0e10cSrcweir nColNumberButttonDown = i;
1325cdf0e10cSrcweir break;
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir
1329cdf0e10cSrcweir if( aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 ) && !bRightRulerMove )
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir bLeftRulerChange = sal_True;
1332cdf0e10cSrcweir bRightRulerChange = sal_False;
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir else if( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) && !bLeftRulerMove )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir bLeftRulerChange = sal_False;
1337cdf0e10cSrcweir bRightRulerChange = sal_True;
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir else if( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir bTopRulerChange = sal_True;
1342cdf0e10cSrcweir bBottomRulerChange = sal_False;
1343cdf0e10cSrcweir bHeaderRulerChange = sal_False;
1344cdf0e10cSrcweir bFooterRulerChange = sal_False;
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir else if( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) && !bTopRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir bTopRulerChange = sal_False;
1349cdf0e10cSrcweir bBottomRulerChange = sal_True;
1350cdf0e10cSrcweir bHeaderRulerChange = sal_False;
1351cdf0e10cSrcweir bFooterRulerChange = sal_False;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir else if( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bFooterRulerMove )
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir bTopRulerChange = sal_False;
1356cdf0e10cSrcweir bBottomRulerChange = sal_False;
1357cdf0e10cSrcweir bHeaderRulerChange = sal_True;
1358cdf0e10cSrcweir bFooterRulerChange = sal_False;
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir else if( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove )
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir bTopRulerChange = sal_False;
1363cdf0e10cSrcweir bBottomRulerChange = sal_False;
1364cdf0e10cSrcweir bHeaderRulerChange = sal_False;
1365cdf0e10cSrcweir bFooterRulerChange = sal_True;
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir
1368cdf0e10cSrcweir if( bPageMargin )
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir if(( (aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 )) || bLeftRulerMove ||
1371cdf0e10cSrcweir ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) || bRightRulerMove || bOnColRulerChange || bColRulerMove )
1372cdf0e10cSrcweir && aPixPt.Y() > aLeftTop.Y() && aPixPt.Y() < aLeftBottom.Y() )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir if( bOnColRulerChange || bColRulerMove )
1375cdf0e10cSrcweir {
1376cdf0e10cSrcweir SetPointer( Pointer( POINTER_HSPLIT ) );
1377cdf0e10cSrcweir if( bColRulerMove )
1378cdf0e10cSrcweir {
1379cdf0e10cSrcweir if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
1380cdf0e10cSrcweir DragMove( aMouseMovePoint.X(), POINTER_HSPLIT );
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir else
1384cdf0e10cSrcweir {
1385cdf0e10cSrcweir if( bLeftRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir SetPointer( Pointer( POINTER_HSIZEBAR ) );
1388cdf0e10cSrcweir if( bLeftRulerMove )
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
1391cdf0e10cSrcweir DragMove( aMouseMovePoint.X(), POINTER_HSIZEBAR );
1392cdf0e10cSrcweir }
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir else if( bRightRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir SetPointer( Pointer( POINTER_HSIZEBAR ) );
1397cdf0e10cSrcweir if( bRightRulerMove )
1398cdf0e10cSrcweir {
1399cdf0e10cSrcweir if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
1400cdf0e10cSrcweir DragMove( aMouseMovePoint.X(), POINTER_HSIZEBAR );
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir else
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir if( ( ( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) ) || bTopRulerMove ||
1408cdf0e10cSrcweir ( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) ) || bBottomRulerMove ||
1409cdf0e10cSrcweir ( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) ) || bHeaderRulerMove ||
1410cdf0e10cSrcweir ( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) ) || bFooterRulerMove )
1411cdf0e10cSrcweir && aPixPt.X() > aTopLeft.X() && aPixPt.X() < aTopRight.X() )
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir if( bTopRulerChange )
1414cdf0e10cSrcweir {
1415cdf0e10cSrcweir SetPointer( Pointer( POINTER_VSIZEBAR ) );
1416cdf0e10cSrcweir if( bTopRulerMove )
1417cdf0e10cSrcweir {
1418cdf0e10cSrcweir if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
1419cdf0e10cSrcweir DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir else if( bBottomRulerChange )
1423cdf0e10cSrcweir {
1424cdf0e10cSrcweir SetPointer( Pointer( POINTER_VSIZEBAR ) );
1425cdf0e10cSrcweir if( bBottomRulerMove )
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
1428cdf0e10cSrcweir DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir else if( bHeaderRulerChange )
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir SetPointer( Pointer( POINTER_VSIZEBAR ) );
1434cdf0e10cSrcweir if( bHeaderRulerMove )
1435cdf0e10cSrcweir {
1436cdf0e10cSrcweir if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
1437cdf0e10cSrcweir DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir else if( bFooterRulerChange )
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir SetPointer( Pointer( POINTER_VSIZEBAR ) );
1443cdf0e10cSrcweir if( bFooterRulerMove )
1444cdf0e10cSrcweir {
1445cdf0e10cSrcweir if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
1446cdf0e10cSrcweir DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir }
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir else
1451cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) );
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir //Issue51656 Add resizeable margin on page preview from maoyg
InvalidateLocationData(sal_uLong nId)1456cdf0e10cSrcweir void ScPreview::InvalidateLocationData(sal_uLong nId)
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir bLocationValid = sal_False;
1459cdf0e10cSrcweir if (pViewShell->HasAccessibilityObjects())
1460cdf0e10cSrcweir pViewShell->BroadcastAccessibility( SfxSimpleHint( nId ) );
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir
GetFocus()1463cdf0e10cSrcweir void ScPreview::GetFocus()
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir if (pViewShell->HasAccessibilityObjects())
1466cdf0e10cSrcweir pViewShell->BroadcastAccessibility( ScAccWinFocusGotHint(GetAccessible()) );
1467cdf0e10cSrcweir }
1468cdf0e10cSrcweir
LoseFocus()1469cdf0e10cSrcweir void ScPreview::LoseFocus()
1470cdf0e10cSrcweir {
1471cdf0e10cSrcweir if (pViewShell->HasAccessibilityObjects())
1472cdf0e10cSrcweir pViewShell->BroadcastAccessibility( ScAccWinFocusLostHint(GetAccessible()) );
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir
CreateAccessible()1475cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> ScPreview::CreateAccessible()
1476cdf0e10cSrcweir {
14770deba7fbSSteve Yin com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> xAcc= GetAccessible(sal_False);
14780deba7fbSSteve Yin if (xAcc.is())
14790deba7fbSSteve Yin {
14800deba7fbSSteve Yin return xAcc;
14810deba7fbSSteve Yin }
1482cdf0e10cSrcweir ScAccessibleDocumentPagePreview* pAccessible =
1483cdf0e10cSrcweir new ScAccessibleDocumentPagePreview( GetAccessibleParentWindow()->GetAccessible(), pViewShell );
14840deba7fbSSteve Yin xAcc = pAccessible;
14850deba7fbSSteve Yin SetAccessible(xAcc);
1486cdf0e10cSrcweir pAccessible->Init();
14870deba7fbSSteve Yin return xAcc;
1488cdf0e10cSrcweir }
14890deba7fbSSteve Yin // MT: Removed Windows::SwitchView() introduced with IA2 CWS.
14900deba7fbSSteve Yin // There are other notifications for this when the active view has chnaged, so please update the code to use that event mechanism
SwitchView()14910deba7fbSSteve Yin void ScPreview::SwitchView()
14920deba7fbSSteve Yin {
14930deba7fbSSteve Yin if (!Application::IsAccessibilityEnabled())
14940deba7fbSSteve Yin {
14950deba7fbSSteve Yin return ;
14960deba7fbSSteve Yin }
14970deba7fbSSteve Yin ScAccessibleDocumentBase* pAccDoc = static_cast<ScAccessibleDocumentBase*>(GetAccessible(sal_False).get());
14980deba7fbSSteve Yin if (pAccDoc)
14990deba7fbSSteve Yin {
15000deba7fbSSteve Yin pAccDoc->SwitchViewFireFocus();
15010deba7fbSSteve Yin }
15020deba7fbSSteve Yin }
1503cdf0e10cSrcweir //Issue51656 Add resizeable margin on page preview from maoyg
DragMove(long nDragMovePos,sal_uInt16 nFlags)1504cdf0e10cSrcweir void ScPreview::DragMove( long nDragMovePos, sal_uInt16 nFlags )
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir Fraction aPreviewZoom( nZoom, 100 );
1507cdf0e10cSrcweir Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
1508cdf0e10cSrcweir MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
1509cdf0e10cSrcweir SetMapMode( aMMMode );
1510cdf0e10cSrcweir long nPos = nDragMovePos;
1511cdf0e10cSrcweir if( nFlags == POINTER_HSIZEBAR || nFlags == POINTER_HSPLIT )
1512cdf0e10cSrcweir {
1513cdf0e10cSrcweir if( nDragMovePos != aButtonDownChangePoint.X() )
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.X(), nFlags );
1516cdf0e10cSrcweir aButtonDownChangePoint.X() = nPos;
1517cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.X(), nFlags );
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir else if( nFlags == POINTER_VSIZEBAR )
1521cdf0e10cSrcweir {
1522cdf0e10cSrcweir if( nDragMovePos != aButtonDownChangePoint.Y() )
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.Y(), nFlags );
1525cdf0e10cSrcweir aButtonDownChangePoint.Y() = nPos;
1526cdf0e10cSrcweir DrawInvert( aButtonDownChangePoint.Y(), nFlags );
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir }
1530cdf0e10cSrcweir
DrawInvert(long nDragPos,sal_uInt16 nFlags)1531cdf0e10cSrcweir void ScPreview::DrawInvert( long nDragPos, sal_uInt16 nFlags )
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir long nHeight = (long) lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ).Height();
1534cdf0e10cSrcweir long nWidth = (long) lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ).Width();
1535cdf0e10cSrcweir if( nFlags == POINTER_HSIZEBAR || nFlags == POINTER_HSPLIT )
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,(long)( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y()));
1538cdf0e10cSrcweir Invert( aRect,INVERT_50 );
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir else if( nFlags == POINTER_VSIZEBAR )
1541cdf0e10cSrcweir {
1542cdf0e10cSrcweir Rectangle aRect( -aOffset.X(), nDragPos,(long)( ( nWidth * HMM_PER_TWIPS ) - aOffset.X() ), nDragPos + 1 );
1543cdf0e10cSrcweir Invert( aRect,INVERT_50 );
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir }
1546cdf0e10cSrcweir //Issue51656 Add resizeable margin on page preview from maoyg
1547