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