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