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