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