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