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