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 <officecfg/Office/Common.hxx>
24 #include <svtools/colorcfg.hxx>
25 #include <svx/fmview.hxx>
26 #include <editeng/sizeitem.hxx>
27 #include <svx/svdpagv.hxx>
28 #include <sfx2/bindings.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <sfx2/dispatch.hxx>
32 #include <svl/itemset.hxx>
33 #include <tools/multisel.hxx>
34 #include <vcl/commandevent.hxx>
35 #include <vcl/settings.hxx>
36 #include <o3tl/deleter.hxx>
37 #include <o3tl/unit_conversion.hxx>
38 
39 #include <preview.hxx>
40 #include <prevwsh.hxx>
41 #include <prevloc.hxx>
42 #include <docsh.hxx>
43 #include <docfunc.hxx>
44 #include <printfun.hxx>
45 #include <printopt.hxx>
46 #include <stlpool.hxx>
47 #include <undostyl.hxx>
48 #include <drwlayer.hxx>
49 #include <scmod.hxx>
50 #include <markdata.hxx>
51 #include <globstr.hrc>
52 #include <scresid.hxx>
53 #include <sc.hrc>
54 #include <helpids.h>
56 #include <editeng/lrspitem.hxx>
57 #include <editeng/ulspitem.hxx>
58 #include <editeng/colritem.hxx>
59 #include <editeng/fhgtitem.hxx>
60 #include <com/sun/star/accessibility/XAccessible.hpp>
61 #include <AccessibilityHints.hxx>
62 #include <vcl/svapp.hxx>
63 #include <viewutil.hxx>
64 #include <docpool.hxx>
65 #include <patattr.hxx>
66 #include <columnspanset.hxx>
67 
68 #include <memory>
69 
70 #define SC_PREVIEW_SHADOWSIZE 2
71 
72 static tools::Long lcl_GetDisplayStart( SCTAB nTab, const ScDocument* pDoc, std::vector<tools::Long>& nPages )
73 {
74  tools::Long nDisplayStart = 0;
75  for (SCTAB i=0; i<nTab; i++)
76  {
77  if ( pDoc->NeedPageResetAfterTab(i) )
78  nDisplayStart = 0;
79  else
80  nDisplayStart += nPages[i];
81  }
82  return nDisplayStart;
83 }
84 
86  Window( pParent ),
87  nPageNo( 0 ),
88  nZoom( 100 ),
89  nTabCount( 0 ),
90  nTabsTested( 0 ),
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  GetOutDev()->SetOutDevViewType( OutDevViewType::PrintPreview );
127  SetBackground();
128 
130 
131  GetOutDev()->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, GetOutDev()) );
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( GetOutDev(), 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  GetOutDev()->SetLineColor();
360  GetOutDev()->SetFillColor(aBackColor);
361 
362  Size aWinSize = GetOutDev()->GetOutputSize();
363  if ( aOffset.X() < 0 )
364  GetOutDev()->DrawRect(tools::Rectangle( 0, 0, -aOffset.X(), aWinSize.Height() ));
365  if ( aOffset.Y() < 0 )
366  GetOutDev()->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(GetOutDev(), pDocShell, aState, &aOptions));
387  else
388  pPrintFunc.reset(new ScPrintFunc(GetOutDev(), 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( officecfg::Office::Common::Accessibility::IsForPagePreviews::get() );
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(
457  aLocalPageSize.setHeight(
459 
460  nLeftMargin = o3tl::convert(nLeftMargin, o3tl::Length::twip, o3tl::Length::mm100);
461  nRightMargin = o3tl::convert(nRightMargin, o3tl::Length::twip, o3tl::Length::mm100);
462  nTopMargin = o3tl::convert(nTopMargin, o3tl::Length::twip, o3tl::Length::mm100);
463  nBottomMargin = o3tl::convert(nBottomMargin, o3tl::Length::twip, o3tl::Length::mm100);
464  constexpr auto md = o3tl::getConversionMulDiv(o3tl::Length::twip, o3tl::Length::mm10);
465  const auto m = md.first * mnScale, d = md.second * 100;
466  nHeaderHeight = o3tl::convert(nHeaderHeight, m, d) + nTopMargin;
467  nFooterHeight = o3tl::convert(nFooterHeight, m, d) + nBottomMargin;
468  }
469 
470  if (!bStateValid)
471  {
472  pPrintFunc->GetPrintState( aState );
474  bStateValid = true;
475  }
476  }
477 
478  if ( !bDoPrint )
479  return;
480 
481  tools::Long nPageEndX = aLocalPageSize.Width() - aOffset.X();
482  tools::Long nPageEndY = aLocalPageSize.Height() - aOffset.Y();
483  if ( !bValidPage )
484  nPageEndX = nPageEndY = 0;
485 
486  Size aWinSize = GetOutDev()->GetOutputSize();
487  Point aWinEnd( aWinSize.Width(), aWinSize.Height() );
488  bool bRight = nPageEndX <= aWinEnd.X();
489  bool bBottom = nPageEndY <= aWinEnd.Y();
490 
491  if (!nTotalPages)
492  {
493  // There is no data to print. Print a friendly warning message and
494  // bail out.
495 
496  SetMapMode(aMMMode);
497 
498  // Draw background first.
499  GetOutDev()->SetLineColor();
500  GetOutDev()->SetFillColor(aBackColor);
501  GetOutDev()->DrawRect(tools::Rectangle(0, 0, aWinEnd.X(), aWinEnd.Y()));
502 
503  const ScPatternAttr& rDefPattern =
505 
506  std::unique_ptr<ScEditEngineDefaulter> pEditEng(
507  new ScEditEngineDefaulter(EditEngine::CreatePool().get(), true));
508 
509  pEditEng->SetRefMapMode(aMMMode);
510  auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() );
511  rDefPattern.FillEditItemSet(pEditDefaults.get());
512  pEditDefaults->Put(SvxColorItem(COL_LIGHTGRAY, EE_CHAR_COLOR));
513  pEditEng->SetDefaults(std::move(pEditDefaults));
514 
515  OUString aEmptyMsg;
517  aEmptyMsg = ScResId(STR_PRINT_PREVIEW_EMPTY_RANGE);
518  else
519  aEmptyMsg = ScResId(STR_PRINT_PREVIEW_NODATA);
520 
521  tools::Long nHeight = 3000;
522  pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT));
523  pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
524  pEditEng->SetDefaultItem(SvxFontHeightItem(nHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
525 
526  pEditEng->SetTextCurrentDefaults(aEmptyMsg);
527 
528  Point aCenter(
529  (aWinEnd.X() - pEditEng->CalcTextWidth())/2,
530  (aWinEnd.Y() - pEditEng->GetTextHeight())/2);
531 
532  pEditEng->Draw(*GetOutDev(), aCenter);
533 
534  return;
535  }
536 
537  if( bPageMargin && bValidPage )
538  {
539  SetMapMode(aMMMode);
541  DrawInvert( static_cast<tools::Long>( nTopMargin - aOffset.Y() ), PointerStyle::VSizeBar );
542  DrawInvert( static_cast<tools::Long>(nPageEndY - nBottomMargin ), PointerStyle::VSizeBar );
543  DrawInvert( static_cast<tools::Long>( nLeftMargin - aOffset.X() ), PointerStyle::HSizeBar );
544  DrawInvert( static_cast<tools::Long>( nPageEndX - nRightMargin ) , PointerStyle::HSizeBar );
545  if( bHeaderOn )
546  {
547  DrawInvert( nHeaderHeight - aOffset.Y(), PointerStyle::VSizeBar );
548  }
549  if( bFooterOn )
550  {
551  DrawInvert( nPageEndY - nFooterHeight, PointerStyle::VSizeBar );
552  }
553 
554  SetMapMode( MapMode( MapUnit::MapPixel ) );
555  for( int i= aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
556  {
557  Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
560  GetOutDev()->DrawRect( tools::Rectangle( Point( mvRight[i] - 2, aColumnTop.Y() ),Point( mvRight[i] + 2 , 4 + aColumnTop.Y()) ));
561  GetOutDev()->DrawLine( Point( mvRight[i], aColumnTop.Y() ), Point( mvRight[i], 10 + aColumnTop.Y()) );
562  }
563  SetMapMode( aMMMode );
564  }
565 
566  if (bRight || bBottom)
567  {
568  SetMapMode(aMMMode);
569  GetOutDev()->SetLineColor();
570  GetOutDev()->SetFillColor(aBackColor);
571  if (bRight)
572  GetOutDev()->DrawRect(tools::Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y()));
573  if (bBottom)
574  {
575  if (bRight)
576  GetOutDev()->DrawRect(tools::Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Corner not duplicated
577  else
578  GetOutDev()->DrawRect(tools::Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y()));
579  }
580  }
581 
582  if ( !bValidPage )
583  return;
584 
585  Color aBorderColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
586 
587  // draw border
588 
589  if ( aOffset.X() <= 0 || aOffset.Y() <= 0 || bRight || bBottom )
590  {
591  GetOutDev()->SetLineColor( aBorderColor );
592  GetOutDev()->SetFillColor();
593 
594  tools::Rectangle aPixel( LogicToPixel( tools::Rectangle( -aOffset.X(), -aOffset.Y(), nPageEndX, nPageEndY ) ) );
595  aPixel.AdjustRight( -1 );
596  aPixel.AdjustBottom( -1 );
597  GetOutDev()->DrawRect( PixelToLogic( aPixel ) );
598  }
599 
600  // draw shadow
601 
602  GetOutDev()->SetLineColor();
603  GetOutDev()->SetFillColor( aBorderColor );
604 
605  tools::Rectangle aPixel;
606 
607  aPixel = LogicToPixel( tools::Rectangle( nPageEndX, -aOffset.Y(), nPageEndX, nPageEndY ) );
609  aPixel.AdjustRight(SC_PREVIEW_SHADOWSIZE - 1 );
610  aPixel.AdjustBottom(SC_PREVIEW_SHADOWSIZE - 1 );
611  GetOutDev()->DrawRect( PixelToLogic( aPixel ) );
612 
613  aPixel = LogicToPixel( tools::Rectangle( -aOffset.X(), nPageEndY, nPageEndX, nPageEndY ) );
615  aPixel.AdjustRight(SC_PREVIEW_SHADOWSIZE - 1 );
616  aPixel.AdjustBottom(SC_PREVIEW_SHADOWSIZE - 1 );
617  GetOutDev()->DrawRect( PixelToLogic( aPixel ) );
618 }
619 
620 void ScPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& /* rRect */ )
621 {
622  bool bWasInPaint = bInPaint; // nested calls shouldn't be necessary, but allow for now
623  bInPaint = true;
624 
625  if (bPageMargin)
626  GetLocationData(); // fill location data for column positions
627  DoPrint( nullptr );
629 
630  bInPaint = bWasInPaint;
631 }
632 
633 void ScPreview::Command( const CommandEvent& rCEvt )
634 {
635  CommandEventId nCmd = rCEvt.GetCommand();
636  if ( nCmd == CommandEventId::Wheel || nCmd == CommandEventId::StartAutoScroll || nCmd == CommandEventId::AutoScroll )
637  {
638  bool bDone = pViewShell->ScrollCommand( rCEvt );
639  if (!bDone)
640  Window::Command(rCEvt);
641  }
642  else if ( nCmd == CommandEventId::ContextMenu )
644  else
645  Window::Command( rCEvt );
646 }
647 
648 void ScPreview::KeyInput( const KeyEvent& rKEvt )
649 {
650  // The + and - keys can't be configured as accelerator entries, so they must be handled directly
651  // (in ScPreview, not ScPreviewShell -> only if the preview window has the focus)
652 
653  const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
654  sal_uInt16 nKey = rKeyCode.GetCode();
655  bool bHandled = false;
656  if(!rKeyCode.GetModifier())
657  {
658  sal_uInt16 nSlot = 0;
659  switch(nKey)
660  {
661  case KEY_ADD: nSlot = SID_ZOOM_IN; break;
662  case KEY_ESCAPE: nSlot = ScViewUtil::IsFullScreen( *pViewShell ) ? SID_CANCEL : SID_PREVIEW_CLOSE; break;
663  case KEY_SUBTRACT: nSlot = SID_ZOOM_OUT; break;
664  }
665  if(nSlot)
666  {
667  bHandled = true;
668  pViewShell->GetViewFrame()->GetDispatcher()->Execute( nSlot, SfxCallMode::ASYNCHRON );
669  }
670  }
671 
672  if ( !bHandled && !pViewShell->KeyInput(rKEvt) )
673  Window::KeyInput(rKEvt);
674 }
675 
677 {
678  if ( !pLocationData )
679  {
681  bLocationValid = false;
682  }
683  if ( !bLocationValid )
684  {
685  pLocationData->Clear();
686  DoPrint( pLocationData.get() );
687  bLocationValid = true;
688  }
689  return *pLocationData;
690 }
691 
692 void ScPreview::DataChanged(bool bNewTime)
693 {
694  if (bNewTime)
696 
697  bValid = false;
698  InvalidateLocationData( SfxHintId::ScDataChanged );
699  Invalidate();
700 }
701 
703 {
704  if (!bValid)
705  {
706  CalcPages();
707  UpdateDrawView(); // The table eventually changes
708  }
709 
710  OUString aString = ScResId( STR_PAGE ) +
711  " " + OUString::number(nPageNo+1);
712 
713  if (nTabsTested >= nTabCount)
714  aString += " / " + OUString::number(nTotalPages);
715 
716  return aString;
717 }
718 
719 void ScPreview::SetZoom(sal_uInt16 nNewZoom)
720 {
721  if (nNewZoom < 20)
722  nNewZoom = 20;
723  if (nNewZoom > 400)
724  nNewZoom = 400;
725  if (nNewZoom == nZoom)
726  return;
727 
728  nZoom = nNewZoom;
729 
730  // apply new MapMode and call UpdateScrollBars to update aOffset
731 
732  Fraction aPreviewZoom( nZoom, 100 );
733  Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
734  MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
735  SetMapMode( aMMMode );
736 
737  bInSetZoom = true; // don't scroll during SetYOffset in UpdateScrollBars
739  bInSetZoom = false;
740 
741  bStateValid = false;
742  InvalidateLocationData( SfxHintId::ScAccVisAreaChanged );
743  DoInvalidate();
744  Invalidate();
745 }
746 
748 {
749  nPageNo = nPage;
750  RecalcPages();
751  UpdateDrawView(); // The table eventually changes
752  InvalidateLocationData( SfxHintId::ScDataChanged );
753  Invalidate();
754 }
755 
757 {
758  SCTAB nDocTabCount = pDocShell->GetDocument().GetTableCount();
759  if (nTabP >= nDocTabCount)
760  nTabP = nDocTabCount-1;
761 
762  tools::Long nPage = 0;
763  if (nTabP>0)
764  {
765  CalcPages();
766  if (nTabP >= static_cast<SCTAB>(nPages.size()) )
767  OSL_FAIL("nPages out of bounds, FIX IT");
768  UpdateDrawView(); // The table eventually changes
769 
770  for (SCTAB i=0; i<nTabP; i++)
771  nPage += nPages[i];
772 
773  // An empty Table on the previous Page
774 
775  if ( nPages[nTabP]==0 && nPage > 0 )
776  --nPage;
777  }
778 
779  return nPage;
780 }
781 
782 static Size lcl_GetDocPageSize( const ScDocument* pDoc, SCTAB nTab )
783 {
784  OUString aName = pDoc->GetPageStyle( nTab );
785  ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
786  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aName, SfxStyleFamily::Page );
787  if ( pStyleSheet )
788  {
789  SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
790  return rStyleSet.Get(ATTR_PAGE_SIZE).GetSize();
791  }
792  else
793  {
794  OSL_FAIL( "PageStyle not found" );
795  return Size();
796  }
797 }
798 
799 sal_uInt16 ScPreview::GetOptimalZoom(bool bWidthOnly)
800 {
801  double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor();
802  double nWinScaleY = ScGlobal::nScreenPPTY;
803  Size aWinSize = GetOutputSizePixel();
804 
805  // desired margin is 0.25cm in default MapMode (like Writer),
806  // but some additional margin is introduced by integer scale values
807  // -> add only 0.10cm, so there is some margin in all cases.
808  Size aMarginSize( LogicToPixel(Size(100, 100), MapMode(MapUnit::Map100thMM)) );
809  aWinSize.AdjustWidth( -(2 * aMarginSize.Width()) );
810  aWinSize.AdjustHeight( -(2 * aMarginSize.Height()) );
811 
812  Size aLocalPageSize = lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab );
813  if ( aLocalPageSize.Width() && aLocalPageSize.Height() )
814  {
815  tools::Long nZoomX = static_cast<tools::Long>( aWinSize.Width() * 100 / ( aLocalPageSize.Width() * nWinScaleX ));
816  tools::Long nZoomY = static_cast<tools::Long>( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY ));
817 
818  tools::Long nOptimal = nZoomX;
819  if (!bWidthOnly && nZoomY<nOptimal)
820  nOptimal = nZoomY;
821 
822  if (nOptimal<20)
823  nOptimal = 20;
824  if (nOptimal>400)
825  nOptimal = 400;
826 
827  return static_cast<sal_uInt16>(nOptimal);
828  }
829  else
830  return nZoom;
831 }
832 
834 {
835  if ( aOffset.X() == nX )
836  return;
837 
838  if (bValid)
839  {
840  tools::Long nDif = LogicToPixel(aOffset).X() - LogicToPixel(Point(nX,0)).X();
841  aOffset.setX( nX );
842  if (nDif && !bInSetZoom)
843  {
844  MapMode aOldMode = GetMapMode();
845  SetMapMode(MapMode(MapUnit::MapPixel));
846  Scroll( nDif, 0 );
847  SetMapMode(aOldMode);
848  }
849  }
850  else
851  {
852  aOffset.setX( nX );
853  if (!bInSetZoom)
854  Invalidate();
855  }
856  InvalidateLocationData( SfxHintId::ScAccVisAreaChanged );
857  Invalidate();
858 }
859 
861 {
862  if ( aOffset.Y() == nY )
863  return;
864 
865  if (bValid)
866  {
867  tools::Long nDif = LogicToPixel(aOffset).Y() - LogicToPixel(Point(0,nY)).Y();
868  aOffset.setY( nY );
869  if (nDif && !bInSetZoom)
870  {
871  MapMode aOldMode = GetMapMode();
872  SetMapMode(MapMode(MapUnit::MapPixel));
873  Scroll( 0, nDif );
874  SetMapMode(aOldMode);
875  }
876  }
877  else
878  {
879  aOffset.setY( nY );
880  if (!bInSetZoom)
881  Invalidate();
882  }
883  InvalidateLocationData( SfxHintId::ScAccVisAreaChanged );
884  Invalidate();
885 }
886 
888 {
889  // If the whole GetState of the shell is called
890  // The Invalidate must come behind asynchronously
891 
892  if (bInGetState)
893  Application::PostUserEvent( LINK( this, ScPreview, InvalidateHdl ), nullptr, true );
894  else
895  StaticInvalidate(); // Immediately
896 }
897 
899 {
900  // static method, because it's called asynchronously
901  // -> must use current viewframe
902 
903  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
904  if (!pViewFrm)
905  return;
906 
907  SfxBindings& rBindings = pViewFrm->GetBindings();
908  rBindings.Invalidate(SID_STATUS_DOCPOS);
909  rBindings.Invalidate(SID_ROWCOL_SELCOUNT);
910  rBindings.Invalidate(SID_STATUS_PAGESTYLE);
911  rBindings.Invalidate(SID_PREVIEW_PREVIOUS);
912  rBindings.Invalidate(SID_PREVIEW_NEXT);
913  rBindings.Invalidate(SID_PREVIEW_FIRST);
914  rBindings.Invalidate(SID_PREVIEW_LAST);
915  rBindings.Invalidate(SID_ATTR_ZOOM);
916  rBindings.Invalidate(SID_ZOOM_IN);
917  rBindings.Invalidate(SID_ZOOM_OUT);
918  rBindings.Invalidate(SID_PREVIEW_SCALINGFACTOR);
919  rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
920 }
921 
922 IMPL_STATIC_LINK_NOARG( ScPreview, InvalidateHdl, void*, void )
923 {
924  StaticInvalidate();
925 }
926 
928 {
929  Window::DataChanged(rDCEvt);
930 
931  if ( !((rDCEvt.GetType() == DataChangedEventType::PRINTER) ||
932  (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
933  (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
934  (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
935  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
936  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) )
937  return;
938 
939  if ( rDCEvt.GetType() == DataChangedEventType::FONTS )
941 
942  // #i114518# Paint of form controls may modify the window's settings.
943  // Ignore the event if it is called from within Paint.
944  if ( !bInPaint )
945  {
946  if ( rDCEvt.GetType() == DataChangedEventType::SETTINGS &&
947  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
948  {
949  // scroll bar size may have changed
950  pViewShell->InvalidateBorder(); // calls OuterResizePixel
951  }
952  Invalidate();
953  InvalidateLocationData( SfxHintId::ScDataChanged );
954  }
955 }
956 
958 {
959  Fraction aPreviewZoom( nZoom, 100 );
960  Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
961  MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
962 
963  aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
964  aButtonDownPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
965 
966  CaptureMouse();
967 
968  if( rMEvt.IsLeft() && GetPointer() == PointerStyle::HSizeBar )
969  {
970  SetMapMode( aMMMode );
971  if( bLeftRulerChange )
972  {
973  DrawInvert( aButtonDownChangePoint.X(), PointerStyle::HSizeBar );
974  bLeftRulerMove = true;
975  bRightRulerMove = false;
976  }
977  else if( bRightRulerChange )
978  {
979  DrawInvert( aButtonDownChangePoint.X(), PointerStyle::HSizeBar );
980  bLeftRulerMove = false;
981  bRightRulerMove = true;
982  }
983  }
984 
985  if( rMEvt.IsLeft() && GetPointer() == PointerStyle::VSizeBar )
986  {
987  SetMapMode( aMMMode );
988  if( bTopRulerChange )
989  {
990  DrawInvert( aButtonDownChangePoint.Y(), PointerStyle::VSizeBar );
991  bTopRulerMove = true;
992  bBottomRulerMove = false;
993  }
994  else if( bBottomRulerChange )
995  {
996  DrawInvert( aButtonDownChangePoint.Y(), PointerStyle::VSizeBar );
997  bTopRulerMove = false;
998  bBottomRulerMove = true;
999  }
1000  else if( bHeaderRulerChange )
1001  {
1002  DrawInvert( aButtonDownChangePoint.Y(), PointerStyle::VSizeBar );
1003  bHeaderRulerMove = true;
1004  bFooterRulerMove = false;
1005  }
1006  else if( bFooterRulerChange )
1007  {
1008  DrawInvert( aButtonDownChangePoint.Y(), PointerStyle::VSizeBar );
1009  bHeaderRulerMove = false;
1010  bFooterRulerMove = true;
1011  }
1012  }
1013 
1014  if( !(rMEvt.IsLeft() && GetPointer() == PointerStyle::HSplit) )
1015  return;
1016 
1017  Point aNowPt = rMEvt.GetPosPixel();
1018  SCCOL i = 0;
1019  for( i = aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
1020  {
1021  if( aNowPt.X() < mvRight[i] + 2 && aNowPt.X() > mvRight[i] - 2 )
1022  {
1024  break;
1025  }
1026  }
1027  if( i == aPageArea.aEnd.Col()+1 )
1028  return;
1029 
1030  SetMapMode( aMMMode );
1032  DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,PointerStyle::HSplit );
1033  else
1034  DrawInvert( PixelToLogic( Point( mvRight[ nColNumberButtonDown-1 ], 0 ),aMMMode ).X() ,PointerStyle::HSplit );
1035 
1036  DrawInvert( aButtonDownChangePoint.X(), PointerStyle::HSplit );
1037  bColRulerMove = true;
1038 }
1039 
1041 {
1042  Fraction aPreviewZoom( nZoom, 100 );
1043  Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
1044  MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
1045 
1046  aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
1047 
1050 
1051  if( rMEvt.IsLeft() && GetPointer() == PointerStyle::HSizeBar )
1052  {
1053  SetPointer( PointerStyle::Arrow );
1054 
1055  ScDocument& rDoc = pDocShell->GetDocument();
1056  OUString aOldName = rDoc.GetPageStyle( nTab );
1057  bool bUndo = rDoc.IsUndoEnabled();
1058  ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
1059  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SfxStyleFamily::Page );
1060 
1061  if ( pStyleSheet )
1062  {
1063  bool bMoveRulerAction= true;
1064  ScStyleSaveData aOldData;
1065  if( bUndo )
1066  aOldData.InitFromStyle( pStyleSheet );
1067 
1068  SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1069 
1070  SvxLRSpaceItem aLRItem = rStyleSet.Get( ATTR_LRSPACE );
1071 
1073  {
1074  bMoveRulerAction = false;
1075  Invalidate(tools::Rectangle(0, 0, 10000, 10000));
1076  }
1078  {
1079  bMoveRulerAction = false;
1080  Invalidate(tools::Rectangle(0, 0, 10000, 10000));
1081  }
1083  {
1084  bMoveRulerAction = false;
1085  Invalidate(tools::Rectangle(0, 0, 10000, 10000));
1086  }
1087  else if( aButtonDownPt.X() == aButtonUpPt.X() )
1088  {
1089  bMoveRulerAction = false;
1090  DrawInvert( aButtonUpPt.X(), PointerStyle::HSizeBar );
1091  }
1092  if( bMoveRulerAction )
1093  {
1094  ScDocShellModificator aModificator( *pDocShell );
1096  {
1098  rStyleSet.Put( aLRItem );
1100  }
1101  else if( bRightRulerChange && bRightRulerMove )
1102  {
1104  rStyleSet.Put( aLRItem );
1106  }
1107 
1108  ScStyleSaveData aNewData;
1109  aNewData.InitFromStyle( pStyleSheet );
1110  if( bUndo )
1111  {
1113  std::make_unique<ScUndoModifyStyle>( pDocShell, SfxStyleFamily::Page,
1114  aOldData, aNewData ) );
1115  }
1116 
1117  if ( ValidTab( nTab ) )
1118  {
1119  ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, nTab );
1120  aPrintFunc.UpdatePages();
1121  }
1122 
1123  tools::Rectangle aRect(0,0,10000,10000);
1124  Invalidate(aRect);
1125  aModificator.SetDocumentModified();
1126  bLeftRulerChange = false;
1127  bRightRulerChange = false;
1128  }
1129  }
1130  bLeftRulerMove = false;
1131  bRightRulerMove = false;
1132  }
1133 
1134  if( rMEvt.IsLeft() && GetPointer() == PointerStyle::VSizeBar )
1135  {
1136  SetPointer( PointerStyle::Arrow );
1137 
1138  bool bMoveRulerAction = true;
1140  {
1141  bMoveRulerAction = false;
1142  Invalidate(tools::Rectangle(0, 0, 10000, 10000));
1143  }
1144  else if( aButtonDownPt.Y() == aButtonUpPt.Y() )
1145  {
1146  bMoveRulerAction = false;
1147  DrawInvert( aButtonUpPt.Y(), PointerStyle::VSizeBar );
1148  }
1149  if( bMoveRulerAction )
1150  {
1151  ScDocument& rDoc = pDocShell->GetDocument();
1152  bool bUndo = rDoc.IsUndoEnabled();
1153  ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
1154  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( rDoc.GetPageStyle( nTab ), SfxStyleFamily::Page );
1155  OSL_ENSURE( pStyleSheet, "PageStyle not found" );
1156  if ( pStyleSheet )
1157  {
1158  ScDocShellModificator aModificator( *pDocShell );
1159  ScStyleSaveData aOldData;
1160  if( bUndo )
1161  aOldData.InitFromStyle( pStyleSheet );
1162 
1163  SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1164 
1165  SvxULSpaceItem aULItem = rStyleSet.Get( ATTR_ULSPACE );
1166 
1168  {
1170  rStyleSet.Put( aULItem );
1172  }
1173  else if( bBottomRulerMove && bBottomRulerChange )
1174  {
1176  rStyleSet.Put( aULItem );
1178  }
1179  else if( bHeaderRulerMove && bHeaderRulerChange )
1180  {
1181  const SfxPoolItem* pItem = nullptr;
1182  if ( rStyleSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SfxItemState::SET )
1183  {
1184  const SfxItemSet& rHeaderSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
1185  Size aHeaderSize = rHeaderSet.Get(ATTR_PAGE_SIZE).GetSize();
1187  aHeaderSize.setHeight( aHeaderSize.Height() * 100 / mnScale );
1188  SvxSetItem aNewHeader( rStyleSet.Get(ATTR_PAGE_HEADERSET) );
1189  aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aHeaderSize ) );
1190  rStyleSet.Put( aNewHeader );
1192  }
1193  }
1194  else if( bFooterRulerMove && bFooterRulerChange )
1195  {
1196  const SfxPoolItem* pItem = nullptr;
1197  if( rStyleSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SfxItemState::SET )
1198  {
1199  const SfxItemSet& rFooterSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
1200  Size aFooterSize = rFooterSet.Get(ATTR_PAGE_SIZE).GetSize();
1202  aFooterSize.setHeight( aFooterSize.Height() * 100 / mnScale );
1203  SvxSetItem aNewFooter( rStyleSet.Get(ATTR_PAGE_FOOTERSET) );
1204  aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aFooterSize ) );
1205  rStyleSet.Put( aNewFooter );
1207  }
1208  }
1209 
1210  ScStyleSaveData aNewData;
1211  aNewData.InitFromStyle( pStyleSheet );
1212  if( bUndo )
1213  {
1215  std::make_unique<ScUndoModifyStyle>( pDocShell, SfxStyleFamily::Page,
1216  aOldData, aNewData ) );
1217  }
1218 
1219  if ( ValidTab( nTab ) )
1220  {
1221  ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, nTab );
1222  aPrintFunc.UpdatePages();
1223  }
1224 
1225  tools::Rectangle aRect(0, 0, 10000, 10000);
1226  Invalidate(aRect);
1227  aModificator.SetDocumentModified();
1228  bTopRulerChange = false;
1229  bBottomRulerChange = false;
1230  bHeaderRulerChange = false;
1231  bFooterRulerChange = false;
1232  }
1233  }
1234  bTopRulerMove = false;
1235  bBottomRulerMove = false;
1236  bHeaderRulerMove = false;
1237  bFooterRulerMove = false;
1238  }
1239  if( rMEvt.IsLeft() && GetPointer() == PointerStyle::HSplit )
1240  {
1241  SetPointer(PointerStyle::Arrow);
1242  ScDocument& rDoc = pDocShell->GetDocument();
1243  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
1244  bool bMoveRulerAction = true;
1245  if( aButtonDownPt.X() == aButtonUpPt.X() )
1246  {
1247  bMoveRulerAction = false;
1249  DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,PointerStyle::HSplit );
1250  else
1251  DrawInvert( PixelToLogic( Point( mvRight[ nColNumberButtonDown-1 ], 0 ),aMMMode ).X() ,PointerStyle::HSplit );
1252  DrawInvert( aButtonUpPt.X(), PointerStyle::HSplit );
1253  }
1254  if( bMoveRulerAction )
1255  {
1256  tools::Long nNewColWidth = 0;
1257  std::vector<sc::ColRowSpan> aCols(1, sc::ColRowSpan(nColNumberButtonDown,nColNumberButtonDown));
1258 
1259  constexpr auto md = o3tl::getConversionMulDiv(o3tl::Length::mm100, o3tl::Length::twip);
1260  const auto m = md.first * 100, d = md.second * mnScale;
1261  if( !bLayoutRTL )
1262  {
1263  nNewColWidth = o3tl::convert(PixelToLogic( Point( rMEvt.GetPosPixel().X() - mvRight[ nColNumberButtonDown ], 0), aMMMode ).X(), m, d);
1265  }
1266  else
1267  {
1268 
1269  nNewColWidth = o3tl::convert(PixelToLogic( Point( mvRight[ nColNumberButtonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X(), m, d);
1271  }
1272 
1273  if( nNewColWidth >= 0 )
1274  {
1276  true, aCols, nTab, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nNewColWidth), true, true);
1278  }
1279  if ( ValidTab( nTab ) )
1280  {
1281  ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, nTab );
1282  aPrintFunc.UpdatePages();
1283  }
1284  tools::Rectangle aRect(0, 0, 10000, 10000);
1285  Invalidate(aRect);
1286  }
1287  bColRulerMove = false;
1288  }
1289  ReleaseMouse();
1290 }
1291 
1292 void ScPreview::MouseMove( const MouseEvent& rMEvt )
1293 {
1294  Fraction aPreviewZoom( nZoom, 100 );
1295  Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
1296  MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
1297  Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode );
1298 
1301  tools::Long nTopMargin = 0;
1303 
1306 
1307  if ( nPageNo < nTotalPages )
1308  {
1309  ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
1310 
1311  std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
1312  if (bStateValid)
1313  pPrintFunc.reset(new ScPrintFunc( GetOutDev(), pDocShell, aState, &aOptions ));
1314  else
1315  pPrintFunc.reset(new ScPrintFunc( GetOutDev(), pDocShell, nTab, nFirstAttr[nTab], nTotalPages, nullptr, &aOptions ));
1316 
1317  nLeftMargin = o3tl::convert(pPrintFunc->GetLeftMargin(), o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X();
1318  nRightMargin = o3tl::convert(pPrintFunc->GetRightMargin(), o3tl::Length::twip, o3tl::Length::mm100);
1319  nRightMargin = o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - nRightMargin - aOffset.X();
1320  nTopMargin = o3tl::convert(pPrintFunc->GetTopMargin(), o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y();
1321  nBottomMargin = o3tl::convert(pPrintFunc->GetBottomMargin(), o3tl::Length::twip, o3tl::Length::mm100);
1322  nBottomMargin = o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - nBottomMargin - aOffset.Y();
1323  if( mnScale > 0 )
1324  {
1325  constexpr auto md = o3tl::getConversionMulDiv(o3tl::Length::twip, o3tl::Length::mm100);
1326  const auto m = md.first * mnScale, d = md.second * 100;
1327  nHeaderHeight = nTopMargin + o3tl::convert(pPrintFunc->GetHeader().nHeight, m, d);
1328  nFooterHeight = nBottomMargin - o3tl::convert(pPrintFunc->GetFooter().nHeight, m, d);
1329  }
1330  else
1331  {
1332  nHeaderHeight = nTopMargin + o3tl::convert(pPrintFunc->GetHeader().nHeight, o3tl::Length::twip, o3tl::Length::mm100);
1333  nFooterHeight = nBottomMargin - o3tl::convert(pPrintFunc->GetFooter().nHeight, o3tl::Length::twip, o3tl::Length::mm100);
1334  }
1335  }
1336 
1337  Point aPixPt( rMEvt.GetPosPixel() );
1338  Point aLeftTop = LogicToPixel( Point( nLeftMargin, -aOffset.Y() ) , aMMMode );
1339  Point aLeftBottom = LogicToPixel( Point( nLeftMargin, o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y()), aMMMode );
1340  Point aRightTop = LogicToPixel( Point( nRightMargin, -aOffset.Y() ), aMMMode );
1341  Point aTopLeft = LogicToPixel( Point( -aOffset.X(), nTopMargin ), aMMMode );
1342  Point aTopRight = LogicToPixel( Point( o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X(), nTopMargin ), aMMMode );
1343  Point aBottomLeft = LogicToPixel( Point( -aOffset.X(), nBottomMargin ), aMMMode );
1344  Point aHeaderLeft = LogicToPixel( Point( -aOffset.X(), nHeaderHeight ), aMMMode );
1345  Point aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode );
1346 
1347  bool bOnColRulerChange = false;
1348 
1349  for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
1350  {
1351  Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
1352  Point aColumnBottom = LogicToPixel( Point( 0, o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y()), aMMMode );
1353  tools::Long nRight = i < static_cast<SCCOL>(mvRight.size()) ? mvRight[i] : 0;
1354  if( aPixPt.X() < ( nRight + 2 ) && ( aPixPt.X() > ( nRight - 2 ) ) && ( aPixPt.X() < aRightTop.X() ) && ( aPixPt.X() > aLeftTop.X() )
1355  && ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove
1357  {
1358  bOnColRulerChange = true;
1359  if( !rMEvt.GetButtons() && GetPointer() == PointerStyle::HSplit )
1361  break;
1362  }
1363  }
1364 
1365  if( aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 ) && !bRightRulerMove )
1366  {
1367  bLeftRulerChange = true;
1368  bRightRulerChange = false;
1369  }
1370  else if( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) && !bLeftRulerMove )
1371  {
1372  bLeftRulerChange = false;
1373  bRightRulerChange = true;
1374  }
1375  else if( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1376  {
1377  bTopRulerChange = true;
1378  bBottomRulerChange = false;
1379  bHeaderRulerChange = false;
1380  bFooterRulerChange = false;
1381  }
1382  else if( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) && !bTopRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
1383  {
1384  bTopRulerChange = false;
1385  bBottomRulerChange = true;
1386  bHeaderRulerChange = false;
1387  bFooterRulerChange = false;
1388  }
1389  else if( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bFooterRulerMove )
1390  {
1391  bTopRulerChange = false;
1392  bBottomRulerChange = false;
1393  bHeaderRulerChange = true;
1394  bFooterRulerChange = false;
1395  }
1396  else if( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove )
1397  {
1398  bTopRulerChange = false;
1399  bBottomRulerChange = false;
1400  bHeaderRulerChange = false;
1401  bFooterRulerChange = true;
1402  }
1403 
1404  if( !bPageMargin )
1405  return;
1406 
1407  if(( (aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 )) || bLeftRulerMove ||
1408  ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) || bRightRulerMove || bOnColRulerChange || bColRulerMove )
1409  && aPixPt.Y() > aLeftTop.Y() && aPixPt.Y() < aLeftBottom.Y() )
1410  {
1411  if( bOnColRulerChange || bColRulerMove )
1412  {
1413  SetPointer( PointerStyle::HSplit );
1414  if( bColRulerMove )
1415  {
1416  if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() )
1417  DragMove( aMouseMovePoint.X(), PointerStyle::HSplit );
1418  }
1419  }
1420  else
1421  {
1423  {
1424  SetPointer( PointerStyle::HSizeBar );
1425  if( bLeftRulerMove )
1426  {
1427  if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() )
1428  DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar );
1429  }
1430  }
1432  {
1433  SetPointer( PointerStyle::HSizeBar );
1434  if( bRightRulerMove )
1435  {
1436  if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() )
1437  DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar );
1438  }
1439  }
1440  }
1441  }
1442  else
1443  {
1444  if( ( ( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) ) || bTopRulerMove ||
1445  ( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) ) || bBottomRulerMove ||
1446  ( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) ) || bHeaderRulerMove ||
1447  ( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) ) || bFooterRulerMove )
1448  && aPixPt.X() > aTopLeft.X() && aPixPt.X() < aTopRight.X() )
1449  {
1450  if( bTopRulerChange )
1451  {
1452  SetPointer( PointerStyle::VSizeBar );
1453  if( bTopRulerMove )
1454  {
1455  if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
1456  DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
1457  }
1458  }
1459  else if( bBottomRulerChange )
1460  {
1461  SetPointer( PointerStyle::VSizeBar );
1462  if( bBottomRulerMove )
1463  {
1464  if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
1465  DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
1466  }
1467  }
1468  else if( bHeaderRulerChange )
1469  {
1470  SetPointer( PointerStyle::VSizeBar );
1471  if( bHeaderRulerMove )
1472  {
1473  if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
1474  DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
1475  }
1476  }
1477  else if( bFooterRulerChange )
1478  {
1479  SetPointer( PointerStyle::VSizeBar );
1480  if( bFooterRulerMove )
1481  {
1482  if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
1483  DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
1484  }
1485  }
1486  }
1487  else
1488  SetPointer( PointerStyle::Arrow );
1489  }
1490 }
1491 
1493 {
1494  bLocationValid = false;
1497 }
1498 
1500 {
1501  Window::GetFocus();
1504 }
1505 
1507 {
1510  Window::LoseFocus();
1511 }
1512 
1513 css::uno::Reference<css::accessibility::XAccessible> ScPreview::CreateAccessible()
1514 {
1515  css::uno::Reference<css::accessibility::XAccessible> xAcc= GetAccessible(false);
1516  if (xAcc.is())
1517  {
1518  return xAcc;
1519  }
1520 
1523 
1524  xAcc = pAccessible;
1525  SetAccessible(xAcc);
1526  pAccessible->Init();
1527  return xAcc;
1528 }
1529 
1530 void ScPreview::DragMove( tools::Long nDragMovePos, PointerStyle nFlags )
1531 {
1532  Fraction aPreviewZoom( nZoom, 100 );
1533  Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
1534  MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
1535  SetMapMode( aMMMode );
1536  tools::Long nPos = nDragMovePos;
1537  if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
1538  {
1539  if( nDragMovePos != aButtonDownChangePoint.X() )
1540  {
1541  DrawInvert( aButtonDownChangePoint.X(), nFlags );
1542  aButtonDownChangePoint.setX( nPos );
1543  DrawInvert( aButtonDownChangePoint.X(), nFlags );
1544  }
1545  }
1546  else if( nFlags == PointerStyle::VSizeBar )
1547  {
1548  if( nDragMovePos != aButtonDownChangePoint.Y() )
1549  {
1550  DrawInvert( aButtonDownChangePoint.Y(), nFlags );
1551  aButtonDownChangePoint.setY( nPos );
1552  DrawInvert( aButtonDownChangePoint.Y(), nFlags );
1553  }
1554  }
1555 }
1556 
1558 {
1561  if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
1562  {
1563  tools::Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1, o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y());
1564  GetOutDev()->Invert( aRect, InvertFlags::N50 );
1565  }
1566  else if( nFlags == PointerStyle::VSizeBar )
1567  {
1568  tools::Rectangle aRect( -aOffset.X(), nDragPos, o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X(), nDragPos + 1 );
1569  GetOutDev()->Invert( aRect, InvertFlags::N50 );
1570  }
1571 }
1572 
1574 {
1575  maSelectedTabs = rMark.GetSelectedTabs();
1576 }
1577 
1578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long const nBottomMargin
SfxViewFrame * GetViewFrame() const
void SetDigitLanguage(LanguageType)
SCCOL nEndCol
Definition: printfun.hxx:154
bool bTopRulerChange
Definition: preview.hxx:73
bool bRightRulerMove
Definition: preview.hxx:66
void SetBackground()
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:353
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:294
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: preview.cxx:927
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
bool bInSetZoom
Definition: preview.hxx:64
void TestLastPage()
Definition: preview.cxx:177
OUString GetPosString()
Definition: preview.cxx:702
SCCOL nColNumberButtonDown
Definition: preview.hxx:85
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:89
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:1292
constexpr tools::Long Left() const
void SetZoom(sal_uInt16 nNewZoom)
Definition: preview.cxx:719
sal_uInt16 GetOptimalZoom(bool bWidthOnly)
Definition: preview.cxx:799
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:815
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
double GetOutputFactor() const
Definition: docsh.hxx:354
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)
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:332
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:151
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:782
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6088
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2926
constexpr tools::Long Width() const
static rtl::Reference< SfxItemPool > CreatePool()
weld::Window * GetFrameWeld() const
tools::Long nDisplayStart
Definition: preview.hxx:48
static void StaticInvalidate()
Definition: preview.cxx:898
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
void InvalidateBorder()
sal_uInt16 GetButtons() 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:314
AllSettingsFlags GetFlags() const
#define SC_PREVIEW_SHADOWSIZE
Definition: preview.cxx:70
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:1573
double d
std::vector< tools::Long > nFirstAttr
Definition: preview.hxx:44
virtual ~ScPreview() override
Definition: preview.cxx:134
void DrawRect(const tools::Rectangle &rRect)
void DoInvalidate()
Definition: preview.cxx:887
std::unique_ptr< ScPreviewLocationData > pLocationData
Definition: preview.hxx:52
virtual void dispose() override
Definition: preview.cxx:139
virtual void LoseFocus() override
Definition: preview.cxx:1506
void BroadcastAccessibility(const SfxHint &rHint)
Definition: prevwsh.cxx:1167
tools::Long nTabPages
Definition: printfun.hxx:160
void InitFromStyle(const SfxStyleSheetBase *pSource)
Definition: undostyl.cxx:59
tools::Long nTotalPages
Definition: printfun.hxx:161
PointerStyle GetPointer() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1057
void SetLineColor()
IMPL_STATIC_LINK_NOARG(ScPreview, InvalidateHdl, void *, void)
Definition: preview.cxx:922
bool UpdatePages()
Definition: printfun.cxx:2429
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
void DrawInvert(tools::Long nDragPos, PointerStyle nFlags)
Definition: preview.cxx:1557
Point LogicToPixel(const Point &rLogicPt) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
tools::Long GetTotalPages() const
Definition: printfun.hxx:332
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(184)
bool bFooterRulerChange
Definition: preview.hxx:76
bool bInPaint
Definition: preview.hxx:63
SC_DLLPUBLIC const ScPrintOptions & GetPrintOptions()
Definition: scmod.cxx:791
size_t nPagesX
Definition: printfun.hxx:158
void DoPrint(ScPreviewLocationData *pFillLocation)
Definition: preview.cxx:336
tools::Long nDocPages
Definition: printfun.hxx:163
sal_Int16 SCCOL
Definition: types.hxx:21
const MapMode & GetMapMode() const
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
Definition: global.hxx:579
#define SC_MOD()
Definition: scmod.hxx:250
SfxBindings & GetBindings()
SC_DLLPUBLIC void SetPageNo(tools::Long nPage)
Definition: preview.cxx:747
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Size GetOutputSize() const
void SetXOffset(tools::Long nX)
Definition: preview.cxx:833
tools::Long GetLeft() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SCROW nEndRow
Definition: printfun.hxx:155
constexpr tools::Long Right() const
void SetFillColor()
CommandEventId GetCommand() const
tools::Long nLeftPosition
Definition: preview.hxx:83
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
void SetLowerValue(const sal_uInt16 nL)
void UpdateScrollBars()
Definition: prevwsh.cxx:344
virtual void GetFocus() override
Definition: preview.cxx:1499
SCCOL nStartCol
Definition: printfun.hxx:152
virtual void Command(const CommandEvent &rCEvt) override
Definition: preview.cxx:633
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6213
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: preview.cxx:620
bool bBottomRulerChange
Definition: preview.hxx:74
std::vector< tools::Long > nPages
Definition: preview.hxx:43
bool HasPrintRange() const
Definition: printfun.hxx:346
tools::Long nPageStart
Definition: printfun.hxx:162
Point PixelToLogic(const Point &rDevicePt) const
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:676
ScPreview(vcl::Window *pParent, ScDocShell *pDocSh, ScPreviewShell *pViewSh)
Definition: preview.cxx:85
tools::Long nHeaderHeight
Definition: preview.hxx:89
#define RANGE_MAX
SCCOL Col() const
Definition: address.hxx:266
tools::Long AdjustTop(tools::Long nVertMoveDelta)
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:3645
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: preview.cxx:1040
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:1492
SC_DLLPUBLIC tools::Long GetFirstPage(SCTAB nTab)
Definition: preview.cxx:756
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)
::OutputDevice const * GetOutDev() const
bool IsLeft() const
size_t nPagesY
Definition: printfun.hxx:159
tools::Long AdjustWidth(tools::Long n)
bool bInGetState
Definition: preview.hxx:59
SC_DLLPUBLIC bool NeedPageResetAfterTab(SCTAB nTab) const
Definition: document.cxx:6379
#define HID_SC_WIN_PREVIEW
Definition: helpids.h:32
constexpr TypedWhichId< SvxULSpaceItem > ATTR_ULSPACE(158)
void SetYOffset(tools::Long nY)
Definition: preview.cxx:860
SCTAB nTabsTested
Definition: preview.hxx:42
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: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:648
tools::Long nTotalPages
Definition: preview.hxx:50
tools::Long AdjustHeight(tools::Long n)
PointerStyle
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6093
tools::Long nTabStart
Definition: preview.hxx:47
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:986
Size GetOutputSizePixel() const
tools::Long GetFirstPageNo() const
Definition: printfun.hxx:330
void UpdateDrawView()
Definition: preview.cxx:146
void SetDocumentModified()
Definition: docsh.cxx:3278
bool HasAccessibilityObjects() const
Definition: prevwsh.cxx:1173
void setHeight(tools::Long nHeight)
bool bHeaderRulerMove
Definition: preview.hxx:69
void UpdateFontList()
Definition: docsh3.cxx:456
virtual bool KeyInput(const KeyEvent &rKeyEvent)
void SetOutDevViewType(OutDevViewType eOutDevViewType)
virtual void SetModified(bool=true) override
Definition: docsh.cxx:2931
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
bool IsUndoEnabled() const
Definition: document.hxx:1534
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:72
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:4152
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:211
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(185)
static SCTAB GetCurTab()
Definition: docsh4.cxx:2585
sal_uInt16 nZoom
Definition: printfun.hxx:157
void SetMapMode()
bool ValidTab(SCTAB nTab)
Definition: address.hxx:104
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: preview.cxx:1513
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:452
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: preview.cxx:957
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
sal_uInt16 GetUpper() const
void DragMove(tools::Long nDragMovePos, PointerStyle nFlags)
Definition: preview.cxx:1530
SCROW nStartRow
Definition: printfun.hxx:153
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:775
bool bColRulerMove
Definition: preview.hxx:78
SCTAB nTab
Definition: preview.hxx:45