LibreOffice Module sc (master)  1
printfun.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 <printfun.hxx>
24 
25 #include <editeng/adjustitem.hxx>
26 #include <editeng/borderline.hxx>
27 #include <editeng/boxitem.hxx>
28 #include <editeng/brushitem.hxx>
29 #include <svtools/colorcfg.hxx>
30 #include <editeng/editstat.hxx>
31 #include <svx/fmview.hxx>
32 #include <editeng/frmdiritem.hxx>
33 #include <editeng/lrspitem.hxx>
34 #include <editeng/paperinf.hxx>
35 #include <editeng/pbinitem.hxx>
36 #include <editeng/shaditem.hxx>
37 #include <editeng/sizeitem.hxx>
38 #include <editeng/fhgtitem.hxx>
39 #include <editeng/ulspitem.hxx>
40 #include <sfx2/printer.hxx>
41 #include <tools/multisel.hxx>
42 #include <sfx2/docfile.hxx>
43 #include <tools/urlobj.hxx>
44 #include <osl/diagnose.h>
45 
46 #include <editutil.hxx>
47 #include <docsh.hxx>
48 #include <output.hxx>
49 #include <viewdata.hxx>
50 #include <viewopti.hxx>
51 #include <stlpool.hxx>
52 #include <pagepar.hxx>
53 #include <attrib.hxx>
54 #include <patattr.hxx>
55 #include <docpool.hxx>
56 #include <dociter.hxx>
57 #include <globstr.hrc>
58 #include <scresid.hxx>
59 #include <pagedata.hxx>
60 #include <printopt.hxx>
61 #include <prevloc.hxx>
62 #include <scmod.hxx>
63 #include <drwlayer.hxx>
64 #include <fillinfo.hxx>
65 #include <postit.hxx>
66 
67 #include <memory>
68 #include <com/sun/star/document/XDocumentProperties.hpp>
69 
70 #define ZOOM_MIN 10
71 
72 namespace{
73 
74 bool lcl_GetBool(const SfxItemSet* pSet, sal_uInt16 nWhich)
75 {
76  return static_cast<const SfxBoolItem&>(pSet->Get(nWhich)).GetValue();
77 }
78 
79 sal_uInt16 lcl_GetUShort(const SfxItemSet* pSet, sal_uInt16 nWhich)
80 {
81  return static_cast<const SfxUInt16Item&>(pSet->Get(nWhich)).GetValue();
82 }
83 
84 bool lcl_GetShow(const SfxItemSet* pSet, sal_uInt16 nWhich)
85 {
86  return ScVObjMode::VOBJ_MODE_SHOW == static_cast<const ScViewObjectModeItem&>(pSet->Get(nWhich)).GetValue();
87 }
88 
89 
90 } // namespace
91 
93 {
94  nStartRow = r.nStartRow;
95  nEndRow = r.nEndRow;
96  nPagesX = r.nPagesX;
97  aHidden = r.aHidden;
98  aHidden.resize(nPagesX, false);
99 }
100 
102 {
103  nStartRow = r.nStartRow;
104  nEndRow = r.nEndRow;
105  nPagesX = r.nPagesX;
106  aHidden = r.aHidden;
107  aHidden.resize(nPagesX, false);
108  return *this;
109 }
110 
111 void ScPageRowEntry::SetPagesX(size_t nNew)
112 {
113  nPagesX = nNew;
114  aHidden.resize(nPagesX, false);
115 }
116 
118 {
119  if ( nX < nPagesX )
120  {
121  if ( nX+1 == nPagesX ) // last page?
122  --nPagesX;
123  else
124  {
125  aHidden.resize(nPagesX, false);
126  aHidden[nX] = true;
127  }
128  }
129 }
130 
131 bool ScPageRowEntry::IsHidden(size_t nX) const
132 {
133  return nX >= nPagesX || aHidden[nX];
134 }
135 
137 {
138  if (!aHidden.empty())
139  {
140  size_t nVis = 0;
141  for (size_t i=0; i<nPagesX; i++)
142  if (!aHidden[i])
143  ++nVis;
144  return nVis;
145  }
146  else
147  return nPagesX;
148 }
149 
150 static tools::Long lcl_LineTotal(const ::editeng::SvxBorderLine* pLine)
151 {
152  return pLine ? ( pLine->GetScaledWidth() ) : 0;
153 }
154 
155 void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
156 {
158 
159  SfxPrinter* pDocPrinter = rDoc.GetPrinter(); // use the printer, even for preview
160  if (pDocPrinter)
161  aOldPrinterMode = pDocPrinter->GetMapMode();
162 
163  // unified MapMode for all calls (e.g. Repaint!!!)
164  // else, EditEngine outputs different text heights
165  pDev->SetMapMode(MapMode(MapUnit::MapPixel));
166 
167  pBorderItem = nullptr;
168  pBackgroundItem = nullptr;
169  pShadowItem = nullptr;
170 
171  pEditEngine = nullptr;
172  pEditDefaults = nullptr;
173 
174  ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
175  SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
177  SfxStyleFamily::Page );
178  if (pStyleSheet)
179  pParamSet = &pStyleSheet->GetItemSet();
180  else
181  {
182  OSL_FAIL("Template not found" );
183  pParamSet = nullptr;
184  }
185 
186  if (!bFromPrintState)
187  nZoom = 100;
188  nManualZoom = 100;
189  bClearWin = false;
190  bUseStyleColor = false;
191  bIsRender = false;
192 
193  InitParam(pOptions);
194 
195  pPageData = nullptr; // is only needed for initialisation
196 }
197 
199  tools::Long nPage, tools::Long nDocP, const ScRange* pArea,
200  const ScPrintOptions* pOptions,
201  ScPageBreakData* pData )
202  : pDocShell ( pShell ),
203  rDoc(pDocShell->GetDocument()),
204  pPrinter ( pNewPrinter ),
205  pDrawView ( nullptr ),
206  nPrintTab ( nTab ),
207  nPageStart ( nPage ),
208  nDocPages ( nDocP ),
209  pUserArea ( pArea ),
210  bFromPrintState ( false ),
211  bSourceRangeValid ( false ),
212  bPrintCurrentTable ( false ),
213  bMultiArea ( false ),
214  mbHasPrintRange(true),
215  nTabPages ( 0 ),
216  nTotalPages ( 0 ),
217  bPrintAreaValid ( false ),
218  pPageData ( pData )
219 {
220  pDev = pPrinter.get();
221  aSrcOffset = pPrinter->PixelToLogic(pPrinter->GetPageOffsetPixel(), MapMode(MapUnit::Map100thMM));
222  m_aRanges.m_xPageEndX = std::make_shared<std::vector<SCCOL>>();
223  m_aRanges.m_xPageEndY = std::make_shared<std::vector<SCROW>>();
224  m_aRanges.m_xPageRows = std::make_shared<std::map<size_t, ScPageRowEntry>>();
225  Construct( pOptions );
226 }
227 
229  const ScPrintState& rState, const ScPrintOptions* pOptions)
230  : pDocShell ( pShell ),
231  rDoc(pDocShell->GetDocument()),
232  pPrinter ( pNewPrinter ),
233  pDrawView ( nullptr ),
234  pUserArea ( nullptr ),
235  bSourceRangeValid ( false ),
236  bPrintCurrentTable ( false ),
237  bMultiArea ( false ),
238  mbHasPrintRange(true),
239  pPageData ( nullptr )
240 {
241  pDev = pPrinter.get();
242 
243  nPrintTab = rState.nPrintTab;
244  nStartCol = rState.nStartCol;
245  nStartRow = rState.nStartRow;
246  nEndCol = rState.nEndCol;
247  nEndRow = rState.nEndRow;
249  nZoom = rState.nZoom;
250  m_aRanges.m_nPagesX = rState.nPagesX;
251  m_aRanges.m_nPagesY = rState.nPagesY;
252  nTabPages = rState.nTabPages;
253  nTotalPages = rState.nTotalPages;
254  nPageStart = rState.nPageStart;
255  nDocPages = rState.nDocPages;
256  bFromPrintState = true;
257 
258  if (rState.bSavedStateRanges)
259  {
260  m_aRanges.m_nTotalY = rState.nTotalY;
265  }
266  else
267  {
268  m_aRanges.m_xPageEndX = std::make_shared<std::vector<SCCOL>>();
269  m_aRanges.m_xPageEndY = std::make_shared<std::vector<SCROW>>();
270  m_aRanges.m_xPageRows = std::make_shared<std::map<size_t, ScPageRowEntry>>();
271  }
272 
273  aSrcOffset = pPrinter->PixelToLogic(pPrinter->GetPageOffsetPixel(), MapMode(MapUnit::Map100thMM));
274  Construct( pOptions );
275 }
276 
278  tools::Long nPage, tools::Long nDocP, const ScRange* pArea,
279  const ScPrintOptions* pOptions )
280  : pDocShell ( pShell ),
281  rDoc(pDocShell->GetDocument()),
282  pPrinter ( nullptr ),
283  pDrawView ( nullptr ),
284  nPrintTab ( nTab ),
285  nPageStart ( nPage ),
286  nDocPages ( nDocP ),
287  pUserArea ( pArea ),
288  bFromPrintState ( false ),
289  bSourceRangeValid ( false ),
290  bPrintCurrentTable ( false ),
291  bMultiArea ( false ),
292  mbHasPrintRange(true),
293  nTabPages ( 0 ),
294  nTotalPages ( 0 ),
295  bPrintAreaValid ( false ),
296  pPageData ( nullptr )
297 {
298  pDev = pOutDev;
299  m_aRanges.m_xPageEndX = std::make_shared<std::vector<SCCOL>>();
300  m_aRanges.m_xPageEndY = std::make_shared<std::vector<SCROW>>();
301  m_aRanges.m_xPageRows = std::make_shared<std::map<size_t, ScPageRowEntry>>();
302  Construct( pOptions );
303 }
304 
306  const ScPrintState& rState, const ScPrintOptions* pOptions )
307  : pDocShell ( pShell ),
308  rDoc(pDocShell->GetDocument()),
309  pPrinter ( nullptr ),
310  pDrawView ( nullptr ),
311  pUserArea ( nullptr ),
312  bSourceRangeValid ( false ),
313  bPrintCurrentTable ( false ),
314  bMultiArea ( false ),
315  mbHasPrintRange(true),
316  pPageData ( nullptr )
317 {
318  pDev = pOutDev;
319 
320  nPrintTab = rState.nPrintTab;
321  nStartCol = rState.nStartCol;
322  nStartRow = rState.nStartRow;
323  nEndCol = rState.nEndCol;
324  nEndRow = rState.nEndRow;
326  nZoom = rState.nZoom;
327  m_aRanges.m_nPagesX = rState.nPagesX;
328  m_aRanges.m_nPagesY = rState.nPagesY;
329  nTabPages = rState.nTabPages;
330  nTotalPages = rState.nTotalPages;
331  nPageStart = rState.nPageStart;
332  nDocPages = rState.nDocPages;
333  bFromPrintState = true;
334 
335  if (rState.bSavedStateRanges)
336  {
337  m_aRanges.m_nTotalY = rState.nTotalY;
342  }
343  else
344  {
345  m_aRanges.m_xPageEndX = std::make_shared<std::vector<SCCOL>>();
346  m_aRanges.m_xPageEndY = std::make_shared<std::vector<SCROW>>();
347  m_aRanges.m_xPageRows = std::make_shared<std::map<size_t, ScPageRowEntry>>();
348  }
349 
350  Construct( pOptions );
351 }
352 
353 void ScPrintFunc::GetPrintState(ScPrintState& rState, bool bSavePageRanges)
354 {
355  rState.nPrintTab = nPrintTab;
356  rState.nStartCol = nStartCol;
357  rState.nStartRow = nStartRow;
358  rState.nEndCol = nEndCol;
359  rState.nEndRow = nEndRow;
361  rState.nZoom = nZoom;
362  rState.nPagesX = m_aRanges.m_nPagesX;
363  rState.nPagesY = m_aRanges.m_nPagesY;
364  rState.nTabPages = nTabPages;
365  rState.nTotalPages = nTotalPages;
366  rState.nPageStart = nPageStart;
367  rState.nDocPages = nDocPages;
368  if (bSavePageRanges)
369  {
370  rState.bSavedStateRanges = true;
371  rState.nTotalY = m_aRanges.m_nTotalY;
376  }
377 }
378 
380 {
381  rRange = aLastSourceRange;
382  return bSourceRangeValid;
383 }
384 
386 {
387  if (!pPageData)
388  return;
389 
390  sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
391  ScPrintRangeData& rData = pPageData->GetData(nCount); // count up
392 
393  assert( bPrintAreaValid );
394  rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab,
395  nEndCol, nEndRow, nPrintTab ) );
396  // #i123672#
397  if(m_aRanges.m_xPageEndX->empty())
398  {
399  OSL_ENSURE(false, "vector access error for maPageEndX (!)");
400  }
401  else
402  {
403  rData.SetPagesX( m_aRanges.m_nPagesX, m_aRanges.m_xPageEndX->data());
404  }
405 
406  // #i123672#
407  if(m_aRanges.m_xPageEndY->empty())
408  {
409  OSL_ENSURE(false, "vector access error for maPageEndY (!)");
410  }
411  else
412  {
413  rData.SetPagesY( m_aRanges.m_nTotalY, m_aRanges.m_xPageEndY->data());
414  }
415 
416  // Settings
417  rData.SetTopDown( aTableParam.bTopDown );
418  rData.SetAutomatic( !aAreaParam.bPrintArea );
419 }
420 
422 {
423  pEditDefaults.reset();
424  pEditEngine.reset();
425 
426  // Printer settings are now restored from outside
427 
428  // For DrawingLayer/Charts, the MapMode of the printer (RefDevice) must always be correct
429  SfxPrinter* pDocPrinter = rDoc.GetPrinter(); // use Preview also for the printer
430  if (pDocPrinter)
431  pDocPrinter->SetMapMode(aOldPrinterMode);
432 }
433 
435 {
436  pDrawView = pNew;
437 }
438 
439 static void lcl_HidePrint( const ScTableInfo& rTabInfo, SCCOL nX1, SCCOL nX2 )
440 {
441  for (SCSIZE nArrY=1; nArrY+1<rTabInfo.mnArrCount; nArrY++)
442  {
443  RowInfo* pThisRowInfo = &rTabInfo.mpRowInfo[nArrY];
444  for (SCCOL nX=nX1; nX<=nX2; nX++)
445  {
446  ScCellInfo& rCellInfo = pThisRowInfo->cellInfo(nX);
447  ScBasicCellInfo& rBasicCellInfo = pThisRowInfo->basicCellInfo(nX);
448  if (!rBasicCellInfo.bEmptyCellText)
449  if (rCellInfo.pPatternAttr->
450  GetItem(ATTR_PROTECTION, rCellInfo.pConditionSet).GetHidePrint())
451  {
452  rCellInfo.maCell.clear();
453  rBasicCellInfo.bEmptyCellText = true;
454  }
455  }
456  }
457 }
458 
459 // output to Device (static)
460 //
461 // us used for:
462 // - Clipboard/Bitmap
463 // - Ole-Object (DocShell::Draw)
464 // - Preview of templates
465 
466 void ScPrintFunc::DrawToDev(ScDocument& rDoc, OutputDevice* pDev, double /* nPrintFactor */,
467  const tools::Rectangle& rBound, ScViewData* pViewData, bool bMetaFile)
468 {
470 
471  SCTAB nTab = 0;
472  if (pViewData)
473  nTab = pViewData->GetTabNo();
474 
475  bool bDoGrid, bNullVal, bFormula;
476  ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
477  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( rDoc.GetPageStyle( nTab ), SfxStyleFamily::Page );
478  if (pStyleSheet)
479  {
480  SfxItemSet& rSet = pStyleSheet->GetItemSet();
481  bDoGrid = rSet.Get(ATTR_PAGE_GRID).GetValue();
482  bNullVal = rSet.Get(ATTR_PAGE_NULLVALS).GetValue();
483  bFormula = rSet.Get(ATTR_PAGE_FORMULAS).GetValue();
484  }
485  else
486  {
487  const ScViewOptions& rOpt = rDoc.GetViewOptions();
488  bDoGrid = rOpt.GetOption(VOPT_GRID);
489  bNullVal = rOpt.GetOption(VOPT_NULLVALS);
490  bFormula = rOpt.GetOption(VOPT_FORMULAS);
491  }
492 
493  MapMode aMode = pDev->GetMapMode();
494 
495  tools::Rectangle aRect = rBound;
496 
497  if (aRect.Right() < aRect.Left() || aRect.Bottom() < aRect.Top())
498  aRect = tools::Rectangle( Point(), pDev->GetOutputSize() );
499 
500  SCCOL nX1 = 0;
501  SCROW nY1 = 0;
502  SCCOL nX2 = OLE_STD_CELLS_X - 1;
503  SCROW nY2 = OLE_STD_CELLS_Y - 1;
504  if (bMetaFile)
505  {
506  ScRange aRange = rDoc.GetRange( nTab, rBound );
507  nX1 = aRange.aStart.Col();
508  nY1 = aRange.aStart.Row();
509  nX2 = aRange.aEnd.Col();
510  nY2 = aRange.aEnd.Row();
511  }
512  else if (pViewData)
513  {
514  ScSplitPos eWhich = pViewData->GetActivePart();
515  ScHSplitPos eHWhich = WhichH(eWhich);
516  ScVSplitPos eVWhich = WhichV(eWhich);
517  nX1 = pViewData->GetPosX(eHWhich);
518  nY1 = pViewData->GetPosY(eVWhich);
519  nX2 = nX1 + pViewData->VisibleCellsX(eHWhich);
520  if (nX2>nX1) --nX2;
521  nY2 = nY1 + pViewData->VisibleCellsY(eVWhich);
522  if (nY2>nY1) --nY2;
523  }
524 
525  if (nX1 > rDoc.MaxCol()) nX1 = rDoc.MaxCol();
526  if (nX2 > rDoc.MaxCol()) nX2 = rDoc.MaxCol();
527  if (nY1 > rDoc.MaxRow()) nY1 = rDoc.MaxRow();
528  if (nY2 > rDoc.MaxRow()) nY2 = rDoc.MaxRow();
529 
530  tools::Long nDevSizeX = aRect.Right()-aRect.Left()+1;
531  tools::Long nDevSizeY = aRect.Bottom()-aRect.Top()+1;
532 
533  tools::Long nTwipsSizeX = 0;
534  for (SCCOL i=nX1; i<=nX2; i++)
535  nTwipsSizeX += rDoc.GetColWidth( i, nTab );
536  tools::Long nTwipsSizeY = rDoc.GetRowHeight( nY1, nY2, nTab );
537 
538  // if no lines, still space for the outline frame (20 Twips = 1pt)
539  // (HasLines initializes aLines to 0,0,0,0)
540  nTwipsSizeX += 20;
541  nTwipsSizeY += 20;
542 
543  double nScaleX = static_cast<double>(nDevSizeX) / nTwipsSizeX;
544  double nScaleY = static_cast<double>(nDevSizeY) / nTwipsSizeY;
545 
547  ScRange aERange;
548  bool bEmbed = rDoc.IsEmbedded();
549  if (bEmbed)
550  {
551  rDoc.GetEmbedded(aERange);
552  rDoc.ResetEmbedded();
553  }
554 
555  // Assemble data
556 
557  ScTableInfo aTabInfo;
558  rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
559  nScaleX, nScaleY, false, bFormula );
560  lcl_HidePrint( aTabInfo, nX1, nX2 );
561 
562  if (bEmbed)
563  rDoc.SetEmbedded(aERange);
564 
565  tools::Long nScrX = aRect.Left();
566  tools::Long nScrY = aRect.Top();
567 
568  // If no lines, still leave space for grid lines
569  // (would be elseways cut away)
570  nScrX += 1;
571  nScrY += 1;
572 
573  ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, &rDoc, nTab,
574  nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
575  aOutputData.SetMetaFileMode(bMetaFile);
576  aOutputData.SetShowNullValues(bNullVal);
577  aOutputData.SetShowFormulas(bFormula);
578 
579  ScDrawLayer* pModel = rDoc.GetDrawLayer();
580  std::unique_ptr<FmFormView> pDrawView;
581 
582  if( pModel )
583  {
584  pDrawView.reset(
585  new FmFormView(
586  *pModel,
587  pDev));
588  pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
589  pDrawView->SetPrintPreview();
590  aOutputData.SetDrawView( pDrawView.get() );
591  }
592 
594 
595  if ( bMetaFile && pDev->IsVirtual() )
596  aOutputData.SetSnapPixel();
597 
598  Point aLogStart = pDev->PixelToLogic(Point(nScrX, nScrY), MapMode(MapUnit::Map100thMM));
599  tools::Long nLogStX = aLogStart.X();
600  tools::Long nLogStY = aLogStart.Y();
601 
603 
604  if (!bMetaFile && pViewData)
605  pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
606 
607  // #i72502#
608  const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
609  aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
610 
611  if (!bMetaFile && pViewData)
612  pDev->SetMapMode(aMode);
613 
614  aOutputData.DrawBackground(*pDev);
615 
616  aOutputData.DrawShadow();
617  aOutputData.DrawFrame(*pDev);
618  aOutputData.DrawSparklines(*pDev);
619  aOutputData.DrawStrings();
620 
621  if (!bMetaFile && pViewData)
622  pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
623 
624  aOutputData.DrawEdit(!bMetaFile);
625 
626  if (bDoGrid)
627  {
628  if (!bMetaFile && pViewData)
629  pDev->SetMapMode(aMode);
630 
631  aOutputData.DrawGrid(*pDev, true, false); // no page breaks
632 
633  pDev->SetLineColor( COL_BLACK );
634 
635  Size aOne = pDev->PixelToLogic( Size(1,1) );
636  if (bMetaFile)
637  aOne = Size(1,1); // compatible with DrawGrid
638  tools::Long nRight = nScrX + aOutputData.GetScrW() - aOne.Width();
639  tools::Long nBottom = nScrY + aOutputData.GetScrH() - aOne.Height();
640 
641  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
642 
643  // extra line at the left edge for left-to-right, right for right-to-left
644  if ( bLayoutRTL )
645  pDev->DrawLine( Point(nRight,nScrY), Point(nRight,nBottom) );
646  else
647  pDev->DrawLine( Point(nScrX,nScrY), Point(nScrX,nBottom) );
648  // extra line at the top in both cases
649  pDev->DrawLine( Point(nScrX,nScrY), Point(nRight,nScrY) );
650  }
651 
652  // #i72502#
653  aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
654  aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
655  aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
656 }
657 
658 // Printing
659 
660 static void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet )
661 {
662  // nDistance must be initialized differently before
663 
664  if ( pHFSet == nullptr )
665  {
666  rParam.bEnable = false;
667  rParam.pBorder = nullptr;
668  rParam.pBack = nullptr;
669  rParam.pShadow = nullptr;
670  }
671  else
672  {
673  rParam.bEnable = pHFSet->Get(ATTR_PAGE_ON).GetValue();
674  rParam.bDynamic = pHFSet->Get(ATTR_PAGE_DYNAMIC).GetValue();
675  rParam.bShared = pHFSet->Get(ATTR_PAGE_SHARED).GetValue();
676  rParam.bSharedFirst = pHFSet->Get(ATTR_PAGE_SHARED_FIRST).GetValue();
677  rParam.nHeight = pHFSet->Get(ATTR_PAGE_SIZE).GetSize().Height();
678  const SvxLRSpaceItem* pHFLR = &pHFSet->Get(ATTR_LRSPACE);
679  tools::Long nTmp;
680  nTmp = pHFLR->GetLeft();
681  rParam.nLeft = nTmp < 0 ? 0 : sal_uInt16(nTmp);
682  nTmp = pHFLR->GetRight();
683  rParam.nRight = nTmp < 0 ? 0 : sal_uInt16(nTmp);
684  rParam.pBorder = &pHFSet->Get(ATTR_BORDER);
685  rParam.pBack = &pHFSet->Get(ATTR_BACKGROUND);
686  rParam.pShadow = &pHFSet->Get(ATTR_SHADOW);
687 
688 // now back in the dialog:
689 // rParam.nHeight += rParam.nDistance; // not in the dialog any more ???
690 
691  rParam.nHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
692  lcl_LineTotal( rParam.pBorder->GetBottom() );
693 
694  rParam.nManHeight = rParam.nHeight;
695  }
696 
697  if (!rParam.bEnable)
698  rParam.nHeight = 0;
699 }
700 
701 // bNew = TRUE: search for used part of the document
702 // bNew = FALSE: only limit whole lines/columns
703 
705 {
706  SCCOL nOldEndCol = nEndCol; // only important for !bNew
707  SCROW nOldEndRow = nEndRow;
708  bool bChangeCol = true; // at bNew both are being adjusted
709  bool bChangeRow = true;
710 
711  bool bNotes = aTableParam.bNotes;
712  if ( bNew )
713  {
714  nStartCol = 0;
715  nStartRow = 0;
716  if (!rDoc.GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ))
717  return false; // nothing
718  bPrintAreaValid = true;
719  }
720  else
721  {
722  bool bFound = true;
723  bChangeCol = ( nStartCol == 0 && nEndCol == rDoc.MaxCol() );
724  bChangeRow = ( nStartRow == 0 && nEndRow == rDoc.MaxRow() );
725  bool bForcedChangeRow = false;
726 
727  // #i53558# Crop entire column of old row limit to real print area with
728  // some fuzzyness.
729  if (!bChangeRow && nStartRow == 0)
730  {
731  SCROW nPAEndRow;
732  bFound = rDoc.GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nPAEndRow, bNotes );
733  // Say we don't want to print more than ~1000 empty rows, which are
734  // about 14 pages intentionally left blank...
735  const SCROW nFuzzy = 23*42;
736  if (nPAEndRow + nFuzzy < nEndRow)
737  {
738  bForcedChangeRow = true;
739  nEndRow = nPAEndRow;
740  }
741  else
742  bFound = true; // user seems to _want_ to print some empty rows
743  }
744  // TODO: in case we extend the number of columns we may have to do the
745  // same for horizontal cropping.
746 
747  if ( bChangeCol && bChangeRow )
748  bFound = rDoc.GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes );
749  else if ( bChangeCol )
751  else if ( bChangeRow )
752  bFound = rDoc.GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nEndRow, bNotes );
753 
754  if (!bFound)
755  return false; // empty
756 
757  bPrintAreaValid = true;
758  if (bForcedChangeRow)
759  bChangeRow = true;
760  }
761 
762  assert( bPrintAreaValid );
763  rDoc.ExtendMerge( nStartCol,nStartRow, nEndCol,nEndRow, nPrintTab ); // no Refresh, incl. Attrs
764 
765  if ( bChangeCol )
766  {
767  OutputDevice* pRefDev = rDoc.GetPrinter(); // use the printer also for Preview
768  pRefDev->SetMapMode(MapMode(MapUnit::MapPixel)); // important for GetNeededSize
769 
770  rDoc.ExtendPrintArea( pRefDev,
772  // changing nEndCol
773  }
774 
775  if ( nEndCol < rDoc.MaxCol() && rDoc.HasAttrib(
777  ++nEndCol;
778  if ( nEndRow < rDoc.MaxRow() && rDoc.HasAttrib(
780  ++nEndRow;
781 
782  if (!bChangeCol) nEndCol = nOldEndCol;
783  if (!bChangeRow) nEndRow = nOldEndRow;
784 
785  return true;
786 }
787 
789 {
790  if (!pObject)
791  return 0;
792 
793  pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
794 
795  return static_cast<tools::Long>(pEditEngine->GetTextHeight());
796 }
797 
798 // nZoom must be set !!!
799 // and the respective Twip-MapMode configured
800 
802 {
803  OSL_ENSURE( aPageSize.Width(), "UpdateHFHeight without aPageSize");
804 
805  if (!(rParam.bEnable && rParam.bDynamic))
806  return;
807 
808  // calculate nHeight from content
809 
810  MakeEditEngine();
811  tools::Long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin -
812  rParam.nLeft - rParam.nRight ) * 100 / nZoom;
813  if (rParam.pBorder)
814  nPaperWidth -= ( rParam.pBorder->GetDistance(SvxBoxItemLine::LEFT) +
815  rParam.pBorder->GetDistance(SvxBoxItemLine::RIGHT) +
816  lcl_LineTotal(rParam.pBorder->GetLeft()) +
817  lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom;
818 
819  if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE)
820  nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT) +
821  rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT) ) * 100 / nZoom;
822 
823  pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) );
824 
825  tools::Long nMaxHeight = 0;
826  if ( rParam.pLeft )
827  {
828  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) );
829  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) );
830  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) );
831  }
832  if ( rParam.pRight )
833  {
834  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) );
835  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) );
836  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) );
837  }
838  if ( rParam.pFirst )
839  {
840  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pFirst->GetLeftArea() ) );
841  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pFirst->GetCenterArea() ) );
842  nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pFirst->GetRightArea() ) );
843  }
844 
845  rParam.nHeight = nMaxHeight + rParam.nDistance;
846  if (rParam.pBorder)
847  rParam.nHeight += rParam.pBorder->GetDistance(SvxBoxItemLine::TOP) +
848  rParam.pBorder->GetDistance(SvxBoxItemLine::BOTTOM) +
849  lcl_LineTotal( rParam.pBorder->GetTop() ) +
850  lcl_LineTotal( rParam.pBorder->GetBottom() );
851  if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE)
852  rParam.nHeight += rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) +
853  rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM);
854 
855  if (rParam.nHeight < rParam.nManHeight)
856  rParam.nHeight = rParam.nManHeight; // configured minimum
857 }
858 
859 void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
860 {
861  if (!pParamSet)
862  return;
863 
864  // TabPage "Page"
865  const SvxLRSpaceItem* pLRItem = &pParamSet->Get( ATTR_LRSPACE );
866  tools::Long nTmp;
867  nTmp = pLRItem->GetLeft();
868  nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
869  nTmp = pLRItem->GetRight();
870  nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
871  const SvxULSpaceItem* pULItem = &pParamSet->Get( ATTR_ULSPACE );
872  nTopMargin = pULItem->GetUpper();
873  nBottomMargin = pULItem->GetLower();
874 
875  const SvxPageItem* pPageItem = &pParamSet->Get( ATTR_PAGE );
876  nPageUsage = pPageItem->GetPageUsage();
877  bLandscape = pPageItem->IsLandscape();
878  aFieldData.eNumType = pPageItem->GetNumType();
879 
882 
883  aPageSize = pParamSet->Get(ATTR_PAGE_SIZE).GetSize();
884  if ( !aPageSize.Width() || !aPageSize.Height() )
885  {
886  OSL_FAIL("PageSize Null ?!?!?");
888  }
889 
893 
894  // TabPage "Headline"
895 
896  aHdr.pLeft = &pParamSet->Get(ATTR_PAGE_HEADERLEFT); // Content
899 
900  const SfxItemSet* pHeaderSet = nullptr;
901  if ( const SvxSetItem* pHeaderSetItem = pParamSet->GetItemIfSet( ATTR_PAGE_HEADERSET, false ) )
902  {
903  pHeaderSet = &pHeaderSetItem->GetItemSet();
904  // Headline has space below
905  aHdr.nDistance = pHeaderSet->Get(ATTR_ULSPACE).GetLower();
906  }
907  lcl_FillHFParam( aHdr, pHeaderSet );
908 
909  // TabPage "Footline"
910 
911  aFtr.pLeft = &pParamSet->Get(ATTR_PAGE_FOOTERLEFT); // Content
914 
915  const SfxItemSet* pFooterSet = nullptr;
916  if ( const SvxSetItem* pFooterSetItem = pParamSet->GetItemIfSet( ATTR_PAGE_FOOTERSET, false ) )
917  {
918  pFooterSet = &pFooterSetItem->GetItemSet();
919  // Footline has space above
920  aFtr.nDistance = pFooterSet->Get(ATTR_ULSPACE).GetUpper();
921  }
922  lcl_FillHFParam( aFtr, pFooterSet );
923 
924  // Compile Table-/Area-Params from single Items
925 
926  // TabPage "Table"
927 
928  const SfxUInt16Item* pScaleItem = nullptr;
929  const ScPageScaleToItem* pScaleToItem = nullptr;
930  const SfxUInt16Item* pScaleToPagesItem = nullptr;
931  SfxItemState eState;
932 
933  eState = pParamSet->GetItemState( ATTR_PAGE_SCALE, false,
934  reinterpret_cast<const SfxPoolItem**>(&pScaleItem) );
935  if ( SfxItemState::DEFAULT == eState )
936  pScaleItem = &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALE );
937 
938  eState = pParamSet->GetItemState( ATTR_PAGE_SCALETO, false,
939  reinterpret_cast<const SfxPoolItem**>(&pScaleToItem) );
940  if ( SfxItemState::DEFAULT == eState )
941  pScaleToItem = &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETO );
942 
944  reinterpret_cast<const SfxPoolItem**>(&pScaleToPagesItem) );
945  if ( SfxItemState::DEFAULT == eState )
946  pScaleToPagesItem = &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETOPAGES );
947 
948  OSL_ENSURE( pScaleItem && pScaleToItem && pScaleToPagesItem, "Missing ScaleItem! :-/" );
949 
950  aTableParam.bCellContent = true;
952  aTableParam.bGrid = lcl_GetBool(pParamSet,ATTR_PAGE_GRID);
963  aTableParam.nFirstPageNo = static_cast<sal_uInt16>(nPageStart); // from previous table
964 
965  if ( pScaleItem && pScaleToItem && pScaleToPagesItem )
966  {
967  sal_uInt16 nScaleAll = pScaleItem->GetValue();
968  sal_uInt16 nScaleToPages = pScaleToPagesItem->GetValue();
969 
970  aTableParam.bScaleNone = (nScaleAll == 100);
971  aTableParam.bScaleAll = (nScaleAll > 0 );
972  aTableParam.bScaleTo = pScaleToItem->IsValid();
973  aTableParam.bScalePageNum = (nScaleToPages > 0 );
974  aTableParam.nScaleAll = nScaleAll;
975  aTableParam.nScaleWidth = pScaleToItem->GetWidth();
976  aTableParam.nScaleHeight = pScaleToItem->GetHeight();
977  aTableParam.nScalePageNum = nScaleToPages;
978  }
979  else
980  {
981  aTableParam.bScaleNone = true;
982  aTableParam.bScaleAll = false;
983  aTableParam.bScaleTo = false;
984  aTableParam.bScalePageNum = false;
989  }
990 
991  // skip empty pages only if options with that flag are passed
992  aTableParam.bSkipEmpty = pOptions && pOptions->GetSkipEmpty();
993  if ( pPageData )
994  aTableParam.bSkipEmpty = false;
995  // If pPageData is set, only the breaks are interesting for the
996  // pagebreak preview, empty pages are not addressed separately.
997 
998  aTableParam.bForceBreaks = pOptions && pOptions->GetForceBreaks();
999 
1000  // TabPage "Parts":
1001 
1003  const ScRange* pPrintArea = rDoc.GetPrintRange( nPrintTab, 0 );
1004  const ScRange* pRepeatCol = rDoc.GetRepeatColRange( nPrintTab );
1005  const ScRange* pRepeatRow = rDoc.GetRepeatRowRange( nPrintTab );
1006 
1007  // ignoring ATTR_PAGE_PRINTTABLES
1008 
1009  bool bHasPrintRange = rDoc.HasPrintRange();
1010  sal_uInt16 nPrintRangeCount = rDoc.GetPrintRangeCount(nPrintTab);
1011  bool bPrintEntireSheet = rDoc.IsPrintEntireSheet(nPrintTab);
1012 
1013  if (!bPrintEntireSheet && !nPrintRangeCount)
1014  mbHasPrintRange = false;
1015 
1016  if ( pUserArea ) // UserArea (selection) has priority
1017  {
1019  aAreaParam.bPrintArea = true; // Selection
1021 
1022  // The table-query is already in DocShell::Print, here always
1025  }
1026  else if (bHasPrintRange)
1027  {
1028  if ( pPrintArea ) // at least one set?
1029  {
1031  aAreaParam.bPrintArea = true;
1032  aAreaParam.aPrintArea = *pPrintArea;
1033 
1034  bMultiArea = nPrintRangeCount > 1;
1035  }
1036  else
1037  {
1038  // do not print hidden sheets with "Print entire sheet" flag
1040  aAreaParam.bPrintArea = !bPrintCurrentTable; // otherwise the table is always counted
1041  }
1042  }
1043  else
1044  {
1045  // don't print hidden tables if there's no print range defined there
1046  if ( rDoc.IsVisible( nPrintTab ) )
1047  {
1048  aAreaParam.bPrintArea = false;
1049  bPrintCurrentTable = true;
1050  }
1051  else
1052  {
1053  aAreaParam.bPrintArea = true; // otherwise the table is always counted
1054  bPrintCurrentTable = false;
1055  }
1056  }
1057 
1058  if ( pRepeatCol )
1059  {
1060  aAreaParam.bRepeatCol = true;
1061  nRepeatStartCol = pRepeatCol->aStart.Col();
1062  nRepeatEndCol = pRepeatCol->aEnd .Col();
1063  }
1064  else
1065  {
1066  aAreaParam.bRepeatCol = false;
1068  }
1069 
1070  if ( pRepeatRow )
1071  {
1072  aAreaParam.bRepeatRow = true;
1073  nRepeatStartRow = pRepeatRow->aStart.Row();
1074  nRepeatEndRow = pRepeatRow->aEnd .Row();
1075  }
1076  else
1077  {
1078  aAreaParam.bRepeatRow = false;
1080  }
1081 
1082  // Split pages
1083 
1084  if (!bPrintAreaValid)
1085  {
1086  nTabPages = CountPages(); // also calculates zoom
1089  }
1090  else
1091  {
1092  CalcPages(); // search breaks only
1093  CountNotePages(); // Count notes, even if number of pages is already known
1094  }
1095 
1096  if (nDocPages)
1098  else
1100 
1102 
1103  if( pDocShell->getDocProperties()->getTitle().getLength() != 0 )
1104  aFieldData.aTitle = pDocShell->getDocProperties()->getTitle();
1105  else
1107 
1108  const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
1110  if ( !aFieldData.aLongDocName.isEmpty() )
1112  else
1114 
1115  // Printer settings (Orientation, Paper) at DoPrint
1116 }
1117 
1119 {
1120  Size aSize = aPageSize;
1121  aSize.AdjustWidth( -(nLeftMargin + nRightMargin) );
1122  aSize.AdjustHeight( -(nTopMargin + nBottomMargin) );
1123  aSize.AdjustHeight( -(aHdr.nHeight + aFtr.nHeight) );
1124  return aSize;
1125 }
1126 
1127 void ScPrintFunc::GetScaleData( Size& rPhysSize, tools::Long& rDocHdr, tools::Long& rDocFtr )
1128 {
1129  rPhysSize = aPageSize;
1130  rPhysSize.AdjustWidth( -(nLeftMargin + nRightMargin) );
1131  rPhysSize.AdjustHeight( -(nTopMargin + nBottomMargin) );
1132 
1133  rDocHdr = aHdr.nHeight;
1134  rDocFtr = aFtr.nHeight;
1135 }
1136 
1137 void ScPrintFunc::SetDateTime( const DateTime& rDateTime )
1138 {
1139  aFieldData.aDateTime = rDateTime;
1140 }
1141 
1142 static void lcl_DrawGraphic( const Graphic &rGraphic, vcl::RenderContext& rOutDev,
1143  const tools::Rectangle &rGrf, const tools::Rectangle &rOut )
1144 {
1145  const bool bNotInside = !rOut.Contains( rGrf );
1146  if ( bNotInside )
1147  {
1148  rOutDev.Push();
1149  rOutDev.IntersectClipRegion( rOut );
1150  }
1151 
1152  rGraphic.Draw(rOutDev, rGrf.TopLeft(), rGrf.GetSize());
1153 
1154  if ( bNotInside )
1155  rOutDev.Pop();
1156 }
1157 
1158 static void lcl_DrawGraphic( const SvxBrushItem &rBrush, vcl::RenderContext& rOutDev, const OutputDevice* pRefDev,
1159  const tools::Rectangle &rOrg, const tools::Rectangle &rOut,
1160  OUString const & referer )
1161 {
1162  Size aGrfSize(0,0);
1163  const Graphic *pGraphic = rBrush.GetGraphic(referer);
1165  if ( pGraphic && pGraphic->IsSupportedGraphic() )
1166  {
1167  const MapMode aMapMM( MapUnit::Map100thMM );
1168  if ( pGraphic->GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
1169  aGrfSize = pRefDev->PixelToLogic( pGraphic->GetPrefSize(), aMapMM );
1170  else
1171  aGrfSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
1172  pGraphic->GetPrefMapMode(), aMapMM );
1173  ePos = rBrush.GetGraphicPos();
1174  }
1175  else
1176  ePos = GPOS_NONE;
1177 
1178  Point aPos;
1179  Size aDrawSize = aGrfSize;
1180 
1181  bool bDraw = true;
1182  switch ( ePos )
1183  {
1184  case GPOS_LT: aPos = rOrg.TopLeft();
1185  break;
1186  case GPOS_MT: aPos.setY( rOrg.Top() );
1187  aPos.setX( rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2 );
1188  break;
1189  case GPOS_RT: aPos.setY( rOrg.Top() );
1190  aPos.setX( rOrg.Right() - aGrfSize.Width() );
1191  break;
1192 
1193  case GPOS_LM: aPos.setY( rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2 );
1194  aPos.setX( rOrg.Left() );
1195  break;
1196  case GPOS_MM: aPos.setY( rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2 );
1197  aPos.setX( rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2 );
1198  break;
1199  case GPOS_RM: aPos.setY( rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2 );
1200  aPos.setX( rOrg.Right() - aGrfSize.Width() );
1201  break;
1202 
1203  case GPOS_LB: aPos.setY( rOrg.Bottom() - aGrfSize.Height() );
1204  aPos.setX( rOrg.Left() );
1205  break;
1206  case GPOS_MB: aPos.setY( rOrg.Bottom() - aGrfSize.Height() );
1207  aPos.setX( rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2 );
1208  break;
1209  case GPOS_RB: aPos.setY( rOrg.Bottom() - aGrfSize.Height() );
1210  aPos.setX( rOrg.Right() - aGrfSize.Width() );
1211  break;
1212 
1213  case GPOS_AREA:
1214  aPos = rOrg.TopLeft();
1215  aDrawSize = rOrg.GetSize();
1216  break;
1217  case GPOS_TILED:
1218  {
1219  // use GraphicObject::DrawTiled instead of an own loop
1220  // (pixel rounding is handled correctly, and a very small bitmap
1221  // is duplicated into a bigger one for better performance)
1222 
1223  GraphicObject aObject( *pGraphic );
1224 
1225  if( rOutDev.GetOutDevType() == OUTDEV_PDF &&
1226  (aObject.GetType() == GraphicType::Bitmap || aObject.GetType() == GraphicType::Default) )
1227  {
1228  // For PDF export, every draw
1229  // operation for bitmaps takes a noticeable
1230  // amount of place (~50 characters). Thus,
1231  // optimize between tile bitmap size and
1232  // number of drawing operations here.
1233  //
1234  // A_out
1235  // n_chars = k1 * ---------- + k2 * A_bitmap
1236  // A_bitmap
1237  //
1238  // minimum n_chars is obtained for (derive for
1239  // A_bitmap, set to 0, take positive
1240  // solution):
1241  // k1
1242  // A_bitmap = Sqrt( ---- A_out )
1243  // k2
1244  //
1245  // where k1 is the number of chars per draw
1246  // operation, and k2 is the number of chars
1247  // per bitmap pixel. This is approximately 50
1248  // and 7 for current PDF writer, respectively.
1249 
1250  const double k1( 50 );
1251  const double k2( 7 );
1252  const Size aSize( rOrg.GetSize() );
1253  const double Abitmap( k1/k2 * aSize.Width()*aSize.Height() );
1254 
1255  aObject.DrawTiled( rOutDev, rOrg, aGrfSize, Size(0,0),
1256  ::std::max( 128, static_cast<int>( sqrt(sqrt( Abitmap)) + .5 ) ) );
1257  }
1258  else
1259  {
1260  aObject.DrawTiled( rOutDev, rOrg, aGrfSize, Size(0,0) );
1261  }
1262 
1263  bDraw = false;
1264  }
1265  break;
1266 
1267  case GPOS_NONE:
1268  bDraw = false;
1269  break;
1270 
1271  default: OSL_ENSURE( false, "new Graphic position?" );
1272  }
1273  tools::Rectangle aGrf( aPos,aDrawSize );
1274  if ( bDraw && aGrf.Overlaps( rOut ) )
1275  {
1276  lcl_DrawGraphic( *pGraphic, rOutDev, aGrf, rOut );
1277  }
1278 }
1279 
1280 // The frame is drawn inwards
1281 
1283  const SvxBoxItem* pBorderData, const SvxBrushItem* pBackground,
1284  const SvxShadowItem* pShadow )
1285 {
1287 
1288  if (pBorderData)
1289  if ( !pBorderData->GetTop() && !pBorderData->GetBottom() && !pBorderData->GetLeft() &&
1290  !pBorderData->GetRight() )
1291  pBorderData = nullptr;
1292 
1293  if (!pBorderData && !pBackground && !pShadow)
1294  return; // nothing to do
1295 
1296  tools::Long nLeft = 0;
1297  tools::Long nRight = 0;
1298  tools::Long nTop = 0;
1299  tools::Long nBottom = 0;
1300 
1301  // aFrameRect - outside around frame, without shadow
1302  if ( pShadow && pShadow->GetLocation() != SvxShadowLocation::NONE )
1303  {
1304  nLeft += static_cast<tools::Long>( pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT) * nScaleX );
1305  nRight += static_cast<tools::Long>( pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT) * nScaleX );
1306  nTop += static_cast<tools::Long>( pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) * nScaleY );
1307  nBottom += static_cast<tools::Long>( pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM) * nScaleY );
1308  }
1309  tools::Rectangle aFrameRect( Point(nScrX+nLeft, nScrY+nTop),
1310  Size(nScrW-nLeft-nRight, nScrH-nTop-nBottom) );
1311 
1312  // center of frame, to paint lines through OutputData
1313  if (pBorderData)
1314  {
1315  nLeft += static_cast<tools::Long>( lcl_LineTotal(pBorderData->GetLeft()) * nScaleX / 2 );
1316  nRight += static_cast<tools::Long>( lcl_LineTotal(pBorderData->GetRight()) * nScaleX / 2 );
1317  nTop += static_cast<tools::Long>( lcl_LineTotal(pBorderData->GetTop()) * nScaleY / 2 );
1318  nBottom += static_cast<tools::Long>( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 );
1319  }
1320  tools::Long nEffHeight = nScrH - nTop - nBottom;
1321  tools::Long nEffWidth = nScrW - nLeft - nRight;
1322  if (nEffHeight<=0 || nEffWidth<=0)
1323  return; // empty
1324 
1325  if ( pBackground )
1326  {
1327  if (pBackground->GetGraphicPos() != GPOS_NONE)
1328  {
1329  OutputDevice* pRefDev;
1330  if ( bIsRender )
1331  pRefDev = pDev; // don't use printer for PDF
1332  else
1333  pRefDev = rDoc.GetPrinter(); // use printer also for preview
1334  OUString referer;
1335  if (pDocShell->HasName()) {
1336  referer = pDocShell->GetMedium()->GetName();
1337  }
1338  lcl_DrawGraphic(*pBackground, *pDev, pRefDev, aFrameRect, aFrameRect, referer);
1339  }
1340  else
1341  {
1342  pDev->SetFillColor(pBackground->GetColor());
1343  pDev->SetLineColor();
1344  pDev->DrawRect(aFrameRect);
1345  }
1346  }
1347 
1348  if ( pShadow && pShadow->GetLocation() != SvxShadowLocation::NONE )
1349  {
1350  pDev->SetFillColor(pShadow->GetColor());
1351  pDev->SetLineColor();
1352  tools::Long nShadowX = static_cast<tools::Long>( pShadow->GetWidth() * nScaleX );
1353  tools::Long nShadowY = static_cast<tools::Long>( pShadow->GetWidth() * nScaleY );
1354  switch (pShadow->GetLocation())
1355  {
1356  case SvxShadowLocation::TopLeft:
1358  aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
1359  aFrameRect.Right()-nShadowX, aFrameRect.Top() ) );
1361  aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
1362  aFrameRect.Left(), aFrameRect.Bottom()-nShadowY ) );
1363  break;
1364  case SvxShadowLocation::TopRight:
1366  aFrameRect.Left()+nShadowX, aFrameRect.Top()-nShadowY,
1367  aFrameRect.Right()+nShadowX, aFrameRect.Top() ) );
1369  aFrameRect.Right(), aFrameRect.Top()-nShadowY,
1370  aFrameRect.Right()+nShadowX, aFrameRect.Bottom()-nShadowY ) );
1371  break;
1372  case SvxShadowLocation::BottomLeft:
1374  aFrameRect.Left()-nShadowX, aFrameRect.Bottom(),
1375  aFrameRect.Right()-nShadowX, aFrameRect.Bottom()+nShadowY ) );
1377  aFrameRect.Left()-nShadowX, aFrameRect.Top()+nShadowY,
1378  aFrameRect.Left(), aFrameRect.Bottom()+nShadowY ) );
1379  break;
1380  case SvxShadowLocation::BottomRight:
1382  aFrameRect.Left()+nShadowX, aFrameRect.Bottom(),
1383  aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
1385  aFrameRect.Right(), aFrameRect.Top()+nShadowY,
1386  aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
1387  break;
1388  default:
1389  {
1390  // added to avoid warnings
1391  }
1392  }
1393  }
1394 
1395  if (!pBorderData)
1396  return;
1397 
1398  ScDocumentUniquePtr pBorderDoc(new ScDocument( SCDOCMODE_UNDO ));
1399  pBorderDoc->InitUndo( rDoc, 0,0, true,true );
1400  pBorderDoc->ApplyAttr( 0,0,0, *pBorderData );
1401 
1402  ScTableInfo aTabInfo;
1403  pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0,
1404  nScaleX, nScaleY, false, false );
1405  OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0");
1406 
1407  aTabInfo.mpRowInfo[1].nHeight = static_cast<sal_uInt16>(nEffHeight);
1408  aTabInfo.mpRowInfo[0].basicCellInfo(0).nWidth =
1409  aTabInfo.mpRowInfo[1].basicCellInfo(0).nWidth = static_cast<sal_uInt16>(nEffWidth);
1410 
1411  ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc.get(), 0,
1412  nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY );
1413  aOutputData.SetUseStyleColor( bUseStyleColor );
1414 
1415  aOutputData.DrawFrame(*pDev);
1416 }
1417 
1419 {
1420  bool bLayoutRTL = rDoc.IsLayoutRTL( nPrintTab );
1421  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
1422 
1423  Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1424  tools::Long nOneX = aOnePixel.Width();
1425  tools::Long nOneY = aOnePixel.Height();
1426  SCCOL nCol;
1427 
1428  tools::Long nHeight = static_cast<tools::Long>(PRINT_HEADER_HEIGHT * nScaleY);
1429  tools::Long nEndY = nScrY + nHeight - nOneY;
1430 
1431  tools::Long nPosX = nScrX;
1432  if ( bLayoutRTL )
1433  {
1434  for (nCol=nX1; nCol<=nX2; nCol++)
1435  nPosX += static_cast<tools::Long>( rDoc.GetColWidth( nCol, nPrintTab ) * nScaleX );
1436  }
1437  else
1438  nPosX -= nOneX;
1439  tools::Long nPosY = nScrY - nOneY;
1440  OUString aText;
1441 
1442  for (nCol=nX1; nCol<=nX2; nCol++)
1443  {
1444  sal_uInt16 nDocW = rDoc.GetColWidth( nCol, nPrintTab );
1445  if (nDocW)
1446  {
1447  tools::Long nWidth = static_cast<tools::Long>(nDocW * nScaleX);
1448  tools::Long nEndX = nPosX + nWidth * nLayoutSign;
1449 
1450  pDev->DrawRect( tools::Rectangle( nPosX,nPosY,nEndX,nEndY ) );
1451 
1452  aText = ::ScColToAlpha( nCol);
1453  tools::Long nTextWidth = pDev->GetTextWidth(aText);
1454  tools::Long nTextHeight = pDev->GetTextHeight();
1455  tools::Long nAddX = ( nWidth - nTextWidth ) / 2;
1456  tools::Long nAddY = ( nHeight - nTextHeight ) / 2;
1457  tools::Long nTextPosX = nPosX+nAddX;
1458  if ( bLayoutRTL )
1459  nTextPosX -= nWidth;
1460  pDev->DrawText( Point( nTextPosX,nPosY+nAddY ), aText );
1461 
1462  nPosX = nEndX;
1463  }
1464  }
1465 }
1466 
1468 {
1469  Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1470  tools::Long nOneX = aOnePixel.Width();
1471  tools::Long nOneY = aOnePixel.Height();
1472 
1473  bool bLayoutRTL = rDoc.IsLayoutRTL( nPrintTab );
1474 
1475  tools::Long nWidth = static_cast<tools::Long>(PRINT_HEADER_WIDTH * nScaleX);
1476  tools::Long nEndX = nScrX + nWidth;
1477  tools::Long nPosX = nScrX;
1478  if ( !bLayoutRTL )
1479  {
1480  nEndX -= nOneX;
1481  nPosX -= nOneX;
1482  }
1483  tools::Long nPosY = nScrY - nOneY;
1484  OUString aText;
1485 
1486  for (SCROW nRow=nY1; nRow<=nY2; nRow++)
1487  {
1488  sal_uInt16 nDocH = rDoc.GetRowHeight( nRow, nPrintTab );
1489  if (nDocH)
1490  {
1491  tools::Long nHeight = static_cast<tools::Long>(nDocH * nScaleY);
1492  tools::Long nEndY = nPosY + nHeight;
1493 
1494  pDev->DrawRect( tools::Rectangle( nPosX,nPosY,nEndX,nEndY ) );
1495 
1496  aText = OUString::number( nRow+1 );
1497  tools::Long nTextWidth = pDev->GetTextWidth(aText);
1498  tools::Long nTextHeight = pDev->GetTextHeight();
1499  tools::Long nAddX = ( nWidth - nTextWidth ) / 2;
1500  tools::Long nAddY = ( nHeight - nTextHeight ) / 2;
1501  pDev->DrawText( Point( nPosX+nAddX,nPosY+nAddY ), aText );
1502 
1503  nPosY = nEndY;
1504  }
1505  }
1506 }
1507 
1509  bool bRepCol, ScPreviewLocationData& rLocationData )
1510 {
1511  Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1512  tools::Long nOneX = aOnePixel.Width();
1513  tools::Long nOneY = aOnePixel.Height();
1514 
1515  tools::Long nHeight = static_cast<tools::Long>(PRINT_HEADER_HEIGHT * nScaleY);
1516  tools::Long nEndY = nScrY + nHeight - nOneY;
1517 
1518  tools::Long nPosX = nScrX - nOneX;
1519  for (SCCOL nCol=nX1; nCol<=nX2; nCol++)
1520  {
1521  sal_uInt16 nDocW = rDoc.GetColWidth( nCol, nPrintTab );
1522  if (nDocW)
1523  nPosX += static_cast<tools::Long>(nDocW * nScaleX);
1524  }
1525  tools::Rectangle aCellRect( nScrX, nScrY, nPosX, nEndY );
1526  rLocationData.AddColHeaders( aCellRect, nX1, nX2, bRepCol );
1527 }
1528 
1530  bool bRepRow, ScPreviewLocationData& rLocationData )
1531 {
1532  Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1533  tools::Long nOneX = aOnePixel.Width();
1534  tools::Long nOneY = aOnePixel.Height();
1535 
1536  bool bLayoutRTL = rDoc.IsLayoutRTL( nPrintTab );
1537 
1538  tools::Long nWidth = static_cast<tools::Long>(PRINT_HEADER_WIDTH * nScaleX);
1539  tools::Long nEndX = nScrX + nWidth;
1540  if ( !bLayoutRTL )
1541  nEndX -= nOneX;
1542 
1543  tools::Long nPosY = nScrY - nOneY;
1544  nPosY += rDoc.GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
1545  tools::Rectangle aCellRect( nScrX, nScrY, nEndX, nPosY );
1546  rLocationData.AddRowHeaders( aCellRect, nY1, nY2, bRepRow );
1547 }
1548 
1549 void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1550  tools::Long nScrX, tools::Long nScrY, bool bRepCol, bool bRepRow,
1551  ScPreviewLocationData& rLocationData )
1552 {
1553  // get MapMode for drawing objects (same MapMode as in ScOutputData::PrintDrawingLayer)
1554 
1555  Point aLogPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
1556  tools::Long nLogStX = aLogPos.X();
1557  tools::Long nLogStY = aLogPos.Y();
1558 
1559  SCCOL nCol;
1560  Point aTwipOffset;
1561  for (nCol=0; nCol<nX1; nCol++)
1562  aTwipOffset.AdjustX( -(rDoc.GetColWidth( nCol, nPrintTab )) );
1563  aTwipOffset.AdjustY( -sal_Int32(rDoc.GetRowHeight( 0, nY1-1, nPrintTab )) );
1564 
1565  Point aMMOffset(o3tl::convert(aTwipOffset, o3tl::Length::twip, o3tl::Length::mm100));
1566  aMMOffset += Point( nLogStX, nLogStY );
1567  MapMode aDrawMapMode( MapUnit::Map100thMM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() );
1568 
1569  // get pixel rectangle
1570 
1571  Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1572  tools::Long nOneX = aOnePixel.Width();
1573  tools::Long nOneY = aOnePixel.Height();
1574 
1575  tools::Long nPosX = nScrX - nOneX;
1576  for (nCol=nX1; nCol<=nX2; nCol++)
1577  {
1578  sal_uInt16 nDocW = rDoc.GetColWidth( nCol, nPrintTab );
1579  if (nDocW)
1580  nPosX += static_cast<tools::Long>(nDocW * nScaleX);
1581  }
1582 
1583  tools::Long nPosY = nScrY - nOneY;
1584  nPosY += rDoc.GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
1585  tools::Rectangle aCellRect( nScrX, nScrY, nPosX, nPosY );
1586  rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ),
1587  bRepCol, bRepRow, aDrawMapMode );
1588 }
1589 
1590 void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1591  tools::Long nScrX, tools::Long nScrY,
1592  bool bShLeft, bool bShTop, bool bShRight, bool bShBottom )
1593 {
1594  // #i47547# nothing to do if the end of the print area is before the end of
1595  // the repeat columns/rows (don't use negative size for ScOutputData)
1596  if ( nX2 < nX1 || nY2 < nY1 )
1597  return;
1598 
1600  ScRange aERange;
1601  bool bEmbed = rDoc.IsEmbedded();
1602  if (bEmbed)
1603  {
1604  rDoc.GetEmbedded(aERange);
1605  rDoc.ResetEmbedded();
1606  }
1607 
1609  tools::Long nLogStX = aPos.X();
1610  tools::Long nLogStY = aPos.Y();
1611 
1612  // Assemble data
1613 
1614  ScTableInfo aTabInfo;
1615  rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nPrintTab,
1617  lcl_HidePrint( aTabInfo, nX1, nX2 );
1618 
1619  if (bEmbed)
1620  rDoc.SetEmbedded(aERange);
1621 
1622  ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, &rDoc, nPrintTab,
1623  nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
1624 
1625  aOutputData.SetDrawView( pDrawView );
1626 
1627  // test if all paint parts are hidden, then a paint is not necessary at all
1628  const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
1629  const bool bHideAllDrawingLayer( pDrawView && pDrawView->getHideOle() && pDrawView->getHideChart()
1631 
1632  if(!bHideAllDrawingLayer)
1633  {
1635  // don's set Clipping here (Mapmode is being moved)
1636 
1637  // #i72502#
1638  aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
1639  }
1640 
1642 
1643  aOutputData.SetShowFormulas( aTableParam.bFormulas );
1644  aOutputData.SetShowNullValues( aTableParam.bNullVals );
1645  aOutputData.SetUseStyleColor( bUseStyleColor );
1646 
1647  Color aGridColor( COL_BLACK );
1648  if ( bUseStyleColor )
1649  aGridColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
1650  aOutputData.SetGridColor( aGridColor );
1651 
1652  if ( !pPrinter )
1653  {
1654  OutputDevice* pRefDev = rDoc.GetPrinter(); // use the printer also for Preview
1655  Fraction aPrintFrac( nZoom, 100 ); // without nManualZoom
1656  // MapMode, as it would arrive at the printer:
1657  pRefDev->SetMapMode( MapMode( MapUnit::Map100thMM, Point(), aPrintFrac, aPrintFrac ) );
1658 
1659  // when rendering (PDF), don't use printer as ref device, but printer's MapMode
1660  // has to be set anyway, as charts still use it (#106409#)
1661  if ( !bIsRender )
1662  aOutputData.SetRefDevice( pRefDev );
1663  }
1664 
1666  aOutputData.DrawBackground(*pDev);
1667 
1669  aPos, Size(aOutputData.GetScrW(), aOutputData.GetScrH()))));
1670  pDev->SetClipRegion();
1671 
1673  {
1674  aOutputData.DrawExtraShadow( bShLeft, bShTop, bShRight, bShBottom );
1675  aOutputData.DrawFrame(*pDev);
1676  aOutputData.DrawSparklines(*pDev);
1677  aOutputData.DrawStrings();
1678  aOutputData.DrawEdit(false);
1679  }
1680 
1681  if (aTableParam.bGrid)
1682  aOutputData.DrawGrid(*pDev, true, false); // no page breaks
1683 
1684  aOutputData.AddPDFNotes(); // has no effect if not rendering PDF with notes enabled
1685 
1686  // test if all paint parts are hidden, then a paint is not necessary at all
1687  if(!bHideAllDrawingLayer)
1688  {
1689  // #i72502#
1690  aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
1691  }
1692 
1693  // #i72502#
1694  aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
1695  aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
1696 }
1697 
1698 bool ScPrintFunc::IsMirror( tools::Long nPageNo ) // Mirror margins?
1699 {
1700  return nPageUsage == SvxPageUsage::Mirror && (nPageNo & 1);
1701 }
1702 
1703 bool ScPrintFunc::IsLeft( tools::Long nPageNo ) // left foot notes?
1704 {
1705  bool bLeft;
1706  if (nPageUsage == SvxPageUsage::Left)
1707  bLeft = true;
1708  else if (nPageUsage == SvxPageUsage::Right)
1709  bLeft = false;
1710  else
1711  bLeft = (nPageNo & 1) != 0;
1712  return bLeft;
1713 }
1714 
1716 {
1717  OUString aTmp;
1718  rDoc.GetName(nPrintTab, aTmp);
1719  aFieldData.aTabName = aTmp;
1720 }
1721 
1723 {
1724  if (!pEditEngine)
1725  {
1726  // can't use document's edit engine pool here,
1727  // because pool must have twips as default metric
1728  pEditEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool().get() ) );
1729 
1730  pEditEngine->EnableUndo(false);
1731  //fdo#45869 we want text to be positioned as it would be for the
1732  //high dpi printed output, not as would be ideal for the 96dpi preview
1733  //window itself
1734  pEditEngine->SetRefDevice(pPrinter ? pPrinter : rDoc.GetRefDevice());
1735  pEditEngine->SetWordDelimiters(
1736  ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
1737  pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EEControlBits::RTFSTYLESHEETS );
1739  pEditEngine->EnableAutoColor( bUseStyleColor );
1740 
1741  // Default-Set for alignment
1742  pEditDefaults.reset( new SfxItemSet( pEditEngine->GetEmptyItemSet() ) );
1743 
1744  const ScPatternAttr& rPattern = rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN);
1745  rPattern.FillEditItemSet( pEditDefaults.get() );
1746  // FillEditItemSet adjusts font height to 1/100th mm,
1747  // but for header/footer twips is needed, as in the PatternAttr:
1751  // don't use font color, because background color is not used
1753  pEditDefaults->ClearItem( EE_CHAR_COLOR );
1754  if (ScGlobal::IsSystemRTL())
1755  pEditDefaults->Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) );
1756  }
1757 
1758  pEditEngine->SetData( aFieldData ); // Set page count etc.
1759 }
1760 
1761 // nStartY = logic
1762 void ScPrintFunc::PrintHF( tools::Long nPageNo, bool bHeader, tools::Long nStartY,
1763  bool bDoPrint, ScPreviewLocationData* pLocationData )
1764 {
1765  const ScPrintHFParam& rParam = bHeader ? aHdr : aFtr;
1766 
1767  pDev->SetMapMode( aTwipMode ); // Head-/Footlines in Twips
1768 
1769  bool bFirst = 0 == nPageNo && !rParam.bSharedFirst;
1770  bool bLeft = IsLeft(nPageNo) && !rParam.bShared;
1771  const ScPageHFItem* pHFItem = bFirst ? rParam.pFirst : (bLeft ? rParam.pLeft : rParam.pRight);
1772 
1773  tools::Long nLineStartX = aPageRect.Left() + rParam.nLeft;
1774  tools::Long nLineEndX = aPageRect.Right() - rParam.nRight;
1775  tools::Long nLineWidth = nLineEndX - nLineStartX + 1;
1776 
1777  // Edit-Engine
1778 
1779  Point aStart( nLineStartX, nStartY );
1780  Size aPaperSize( nLineWidth, rParam.nHeight-rParam.nDistance );
1781  if ( rParam.pBorder )
1782  {
1783  tools::Long nLeft = lcl_LineTotal( rParam.pBorder->GetLeft() ) + rParam.pBorder->GetDistance(SvxBoxItemLine::LEFT);
1784  tools::Long nTop = lcl_LineTotal( rParam.pBorder->GetTop() ) + rParam.pBorder->GetDistance(SvxBoxItemLine::TOP);
1785  aStart.AdjustX(nLeft );
1786  aStart.AdjustY(nTop );
1787  aPaperSize.AdjustWidth( -(nLeft + lcl_LineTotal( rParam.pBorder->GetRight() ) + rParam.pBorder->GetDistance(SvxBoxItemLine::RIGHT)) );
1788  aPaperSize.AdjustHeight( -(nTop + lcl_LineTotal( rParam.pBorder->GetBottom() ) + rParam.pBorder->GetDistance(SvxBoxItemLine::BOTTOM)) );
1789  }
1790 
1791  if ( rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE )
1792  {
1793  tools::Long nLeft = rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT);
1794  tools::Long nTop = rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::TOP);
1795  aStart.AdjustX(nLeft );
1796  aStart.AdjustY(nTop );
1797  aPaperSize.AdjustWidth( -(nLeft + rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT)) );
1798  aPaperSize.AdjustHeight( -(nTop + rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM)) );
1799  }
1800 
1802  MakeEditEngine();
1803 
1804  pEditEngine->SetPaperSize(aPaperSize);
1805 
1806  // Frame / Background
1807 
1808  Point aBorderStart( nLineStartX, nStartY );
1809  Size aBorderSize( nLineWidth, rParam.nHeight-rParam.nDistance );
1810  if ( rParam.bDynamic )
1811  {
1812  // adjust here again, for even/odd head-/footlines
1813  // and probably other breaks by variable (page number etc.)
1814 
1815  tools::Long nMaxHeight = 0;
1816  nMaxHeight = std::max( nMaxHeight, TextHeight( pHFItem->GetLeftArea() ) );
1817  nMaxHeight = std::max( nMaxHeight, TextHeight( pHFItem->GetCenterArea() ) );
1818  nMaxHeight = std::max( nMaxHeight, TextHeight( pHFItem->GetRightArea() ) );
1819  if (rParam.pBorder)
1820  nMaxHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
1821  lcl_LineTotal( rParam.pBorder->GetBottom() ) +
1822  rParam.pBorder->GetDistance(SvxBoxItemLine::TOP) +
1823  rParam.pBorder->GetDistance(SvxBoxItemLine::BOTTOM);
1824  if (rParam.pShadow && rParam.pShadow->GetLocation() != SvxShadowLocation::NONE)
1825  nMaxHeight += rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) +
1826  rParam.pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM);
1827 
1828  if (nMaxHeight < rParam.nManHeight-rParam.nDistance)
1829  nMaxHeight = rParam.nManHeight-rParam.nDistance; // configured Minimum
1830 
1831  aBorderSize.setHeight( nMaxHeight );
1832  }
1833 
1834  if ( bDoPrint )
1835  {
1836  double nOldScaleX = nScaleX;
1837  double nOldScaleY = nScaleY;
1838  nScaleX = nScaleY = 1.0; // output directly in Twips
1839  DrawBorder( aBorderStart.X(), aBorderStart.Y(), aBorderSize.Width(), aBorderSize.Height(),
1840  rParam.pBorder, rParam.pBack, rParam.pShadow );
1841  nScaleX = nOldScaleX;
1842  nScaleY = nOldScaleY;
1843 
1844  // Clipping for Text
1845 
1846  pDev->SetClipRegion(vcl::Region(tools::Rectangle(aStart, aPaperSize)));
1847 
1848  // left
1849 
1850  const EditTextObject* pObject = pHFItem->GetLeftArea();
1851  if (pObject)
1852  {
1853  pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
1854  pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
1855  Point aDraw = aStart;
1856  tools::Long nDif = aPaperSize.Height() - static_cast<tools::Long>(pEditEngine->GetTextHeight());
1857  if (nDif > 0)
1858  aDraw.AdjustY(nDif / 2 );
1859  pEditEngine->Draw(*pDev, aDraw);
1860  }
1861 
1862  // center
1863 
1864  pObject = pHFItem->GetCenterArea();
1865  if (pObject)
1866  {
1867  pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
1868  pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
1869  Point aDraw = aStart;
1870  tools::Long nDif = aPaperSize.Height() - static_cast<tools::Long>(pEditEngine->GetTextHeight());
1871  if (nDif > 0)
1872  aDraw.AdjustY(nDif / 2 );
1873  pEditEngine->Draw(*pDev, aDraw);
1874  }
1875 
1876  // right
1877 
1878  pObject = pHFItem->GetRightArea();
1879  if (pObject)
1880  {
1881  pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
1882  pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
1883  Point aDraw = aStart;
1884  tools::Long nDif = aPaperSize.Height() - static_cast<tools::Long>(pEditEngine->GetTextHeight());
1885  if (nDif > 0)
1886  aDraw.AdjustY(nDif / 2 );
1887  pEditEngine->Draw(*pDev, aDraw);
1888  }
1889 
1890  pDev->SetClipRegion();
1891  }
1892 
1893  if ( pLocationData )
1894  {
1895  tools::Rectangle aHeaderRect( aBorderStart, aBorderSize );
1896  pLocationData->AddHeaderFooter( aHeaderRect, bHeader, bLeft );
1897  }
1898 }
1899 
1900 tools::Long ScPrintFunc::DoNotes( tools::Long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData )
1901 {
1902  if (bDoPrint)
1904 
1905  MakeEditEngine();
1906  pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
1907  pEditEngine->SetDefaults( *pEditDefaults );
1908 
1909  vcl::Font aMarkFont;
1911  rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN).GetFont( aMarkFont, eColorMode );
1912  pDev->SetFont( aMarkFont );
1913  tools::Long nMarkLen = pDev->GetTextWidth("GW99999:");
1914  // without Space-Char, because it rarely arrives there
1915 
1916  Size aDataSize = aPageRect.GetSize();
1917  if ( nMarkLen > aDataSize.Width() / 2 ) // everything much too small?
1918  nMarkLen = aDataSize.Width() / 2; // split the page appropriately
1919  aDataSize.AdjustWidth( -nMarkLen );
1920 
1921  pEditEngine->SetPaperSize( aDataSize );
1922  tools::Long nPosX = aPageRect.Left() + nMarkLen;
1923  tools::Long nPosY = aPageRect.Top();
1924 
1925  tools::Long nCount = 0;
1926  tools::Long nSize = aNotePosList.size();
1927  bool bOk;
1928  do
1929  {
1930  bOk = false;
1931  if ( nNoteStart + nCount < nSize)
1932  {
1933  ScAddress &rPos = aNotePosList[ nNoteStart + nCount ];
1934 
1935  if( const ScPostIt* pNote = rDoc.GetNote( rPos ) )
1936  {
1937  if(const EditTextObject *pEditText = pNote->GetEditTextObject())
1938  pEditEngine->SetTextCurrentDefaults(*pEditText);
1939  tools::Long nTextHeight = pEditEngine->GetTextHeight();
1940  if ( nPosY + nTextHeight < aPageRect.Bottom() )
1941  {
1942  if (bDoPrint)
1943  {
1944  pEditEngine->Draw(*pDev, Point(nPosX, nPosY));
1945 
1946  OUString aMarkStr(rPos.Format(ScRefFlags::VALID, &rDoc, rDoc.GetAddressConvention()) + ":");
1947 
1948  // cell position also via EditEngine, for correct positioning
1949  pEditEngine->SetTextCurrentDefaults(aMarkStr);
1950  pEditEngine->Draw(*pDev, Point(aPageRect.Left(), nPosY));
1951  }
1952 
1953  if ( pLocationData )
1954  {
1955  tools::Rectangle aTextRect( Point( nPosX, nPosY ), Size( aDataSize.Width(), nTextHeight ) );
1956  pLocationData->AddNoteText( aTextRect, rPos );
1957  tools::Rectangle aMarkRect( Point( aPageRect.Left(), nPosY ), Size( nMarkLen, nTextHeight ) );
1958  pLocationData->AddNoteMark( aMarkRect, rPos );
1959  }
1960 
1961  nPosY += nTextHeight;
1962  nPosY += 200; // Distance
1963  ++nCount;
1964  bOk = true;
1965  }
1966  }
1967  }
1968  }
1969  while (bOk);
1970 
1971  return nCount;
1972 }
1973 
1974 tools::Long ScPrintFunc::PrintNotes( tools::Long nPageNo, tools::Long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData )
1975 {
1976  if ( nNoteStart >= static_cast<tools::Long>(aNotePosList.size()) || !aTableParam.bNotes )
1977  return 0;
1978 
1979  if ( bDoPrint && bClearWin )
1980  {
1982 
1983  Color aBackgroundColor( COL_WHITE );
1984  if ( bUseStyleColor )
1985  aBackgroundColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
1986 
1988  pDev->SetLineColor();
1989  pDev->SetFillColor(aBackgroundColor);
1991  Size(static_cast<tools::Long>(aPageSize.Width() * nScaleX * 100 / nZoom),
1992  static_cast<tools::Long>(aPageSize.Height() * nScaleY * 100 / nZoom))));
1993  }
1994 
1995  // adjust aPageRect for left/right page
1996 
1997  tools::Rectangle aTempRect( Point(), aPageSize );
1998  if (IsMirror(nPageNo))
1999  {
2000  aPageRect.SetLeft( ( aTempRect.Left() + nRightMargin ) * 100 / nZoom );
2001  aPageRect.SetRight( ( aTempRect.Right() - nLeftMargin ) * 100 / nZoom );
2002  }
2003  else
2004  {
2005  aPageRect.SetLeft( ( aTempRect.Left() + nLeftMargin ) * 100 / nZoom );
2006  aPageRect.SetRight( ( aTempRect.Right() - nRightMargin ) * 100 / nZoom );
2007  }
2008 
2009  if ( pPrinter && bDoPrint )
2010  {
2011  OSL_FAIL( "StartPage does not exist anymore" );
2012  }
2013 
2014  if ( bDoPrint || pLocationData )
2015  {
2016  // Head and foot lines
2017 
2018  if (aHdr.bEnable)
2019  {
2020  tools::Long nHeaderY = aPageRect.Top()-aHdr.nHeight;
2021  PrintHF( nPageNo, true, nHeaderY, bDoPrint, pLocationData );
2022  }
2023  if (aFtr.bEnable)
2024  {
2025  tools::Long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
2026  PrintHF( nPageNo, false, nFooterY, bDoPrint, pLocationData );
2027  }
2028  }
2029 
2030  tools::Long nCount = DoNotes( nNoteStart, bDoPrint, pLocationData );
2031 
2032  if ( pPrinter && bDoPrint )
2033  {
2034  OSL_FAIL( "EndPage does not exist anymore" );
2035  }
2036 
2037  return nCount;
2038 }
2039 
2040 void ScPrintFunc::PrintPage( tools::Long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
2041  bool bDoPrint, ScPreviewLocationData* pLocationData )
2042 {
2043  bool bLayoutRTL = rDoc.IsLayoutRTL( nPrintTab );
2044  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
2045 
2046  // nPageNo is the page number within all sheets of one "start page" setting
2047 
2048  if ( bClearWin && bDoPrint )
2049  {
2050  // must exactly fit to painting the frame in preview.cxx !!!
2051 
2052  Color aBackgroundColor( COL_WHITE );
2053  if ( bUseStyleColor )
2054  aBackgroundColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
2055 
2057  pDev->SetLineColor();
2058  pDev->SetFillColor(aBackgroundColor);
2060  Size(static_cast<tools::Long>(aPageSize.Width() * nScaleX * 100 / nZoom),
2061  static_cast<tools::Long>(aPageSize.Height() * nScaleY * 100 / nZoom))));
2062  }
2063 
2064  // adjust aPageRect for left/right page
2065 
2066  tools::Rectangle aTempRect( Point(), aPageSize );
2067  if (IsMirror(nPageNo))
2068  {
2069  aPageRect.SetLeft( ( aTempRect.Left() + nRightMargin ) * 100 / nZoom );
2070  aPageRect.SetRight( ( aTempRect.Right() - nLeftMargin ) * 100 / nZoom );
2071  }
2072  else
2073  {
2074  aPageRect.SetLeft( ( aTempRect.Left() + nLeftMargin ) * 100 / nZoom );
2075  aPageRect.SetRight( ( aTempRect.Right() - nRightMargin ) * 100 / nZoom );
2076  }
2077 
2078  if ( aAreaParam.bRepeatCol )
2079  if ( nX1 > nRepeatStartCol && nX1 <= nRepeatEndCol )
2080  nX1 = nRepeatEndCol + 1;
2081  bool bDoRepCol = (aAreaParam.bRepeatCol && nX1 > nRepeatEndCol);
2082  if ( aAreaParam.bRepeatRow )
2083  if ( nY1 > nRepeatStartRow && nY1 <= nRepeatEndRow )
2084  nY1 = nRepeatEndRow + 1;
2085  bool bDoRepRow = (aAreaParam.bRepeatRow && nY1 > nRepeatEndRow);
2086 
2087  // use new object hide flags in SdrPaintView
2088  if(pDrawView)
2089  {
2094  }
2095 
2096  if ( pPrinter && bDoPrint )
2097  {
2098  OSL_FAIL( "StartPage does not exist anymore" );
2099  }
2100 
2101  // head and foot lines (without centering)
2102 
2103  if (aHdr.bEnable)
2104  {
2105  tools::Long nHeaderY = aPageRect.Top()-aHdr.nHeight;
2106  PrintHF( nPageNo, true, nHeaderY, bDoPrint, pLocationData );
2107  }
2108  if (aFtr.bEnable)
2109  {
2110  tools::Long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
2111  PrintHF( nPageNo, false, nFooterY, bDoPrint, pLocationData );
2112  }
2113 
2114  // Position ( margins / centering )
2115 
2116  tools::Long nLeftSpace = aPageRect.Left(); // Document-Twips
2117  tools::Long nTopSpace = aPageRect.Top();
2118  if ( bCenterHor || bLayoutRTL )
2119  {
2120  tools::Long nDataWidth = 0;
2121  SCCOL i;
2122  for (i=nX1; i<=nX2; i++)
2123  nDataWidth += rDoc.GetColWidth( i,nPrintTab );
2124  if (bDoRepCol)
2125  for (i=nRepeatStartCol; i<=nRepeatEndCol; i++)
2126  nDataWidth += rDoc.GetColWidth( i,nPrintTab );
2127  if (aTableParam.bHeaders)
2128  nDataWidth += tools::Long(PRINT_HEADER_WIDTH);
2129  if (pBorderItem)
2130  nDataWidth += pBorderItem->GetDistance(SvxBoxItemLine::LEFT) +
2131  pBorderItem->GetDistance(SvxBoxItemLine::RIGHT);
2132  if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE)
2133  nDataWidth += pShadowItem->CalcShadowSpace(SvxShadowItemSide::LEFT) +
2134  pShadowItem->CalcShadowSpace(SvxShadowItemSide::RIGHT);
2135  if ( bCenterHor )
2136  {
2137  nLeftSpace += ( aPageRect.GetWidth() - nDataWidth ) / 2; // LTR or RTL
2138  if (pBorderItem)
2139  nLeftSpace -= lcl_LineTotal(pBorderItem->GetLeft());
2140  }
2141  else if ( bLayoutRTL )
2142  nLeftSpace += aPageRect.GetWidth() - nDataWidth; // align to the right edge of the page
2143  }
2144  if ( bCenterVer )
2145  {
2146  tools::Long nDataHeight = rDoc.GetRowHeight( nY1, nY2, nPrintTab);
2147  if (bDoRepRow)
2148  nDataHeight += rDoc.GetRowHeight( nRepeatStartRow,
2150  if (aTableParam.bHeaders)
2151  nDataHeight += tools::Long(PRINT_HEADER_HEIGHT);
2152  if (pBorderItem)
2153  nDataHeight += pBorderItem->GetDistance(SvxBoxItemLine::TOP) +
2154  pBorderItem->GetDistance(SvxBoxItemLine::BOTTOM);
2155  if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE)
2156  nDataHeight += pShadowItem->CalcShadowSpace(SvxShadowItemSide::TOP) +
2157  pShadowItem->CalcShadowSpace(SvxShadowItemSide::BOTTOM);
2158  nTopSpace += ( aPageRect.GetHeight() - nDataHeight ) / 2;
2159  if (pBorderItem)
2160  nTopSpace -= lcl_LineTotal(pBorderItem->GetTop());
2161  }
2162 
2163  // calculate sizes of the elements for partitioning
2164  // (header, repeat, data)
2165 
2166  tools::Long nHeaderWidth = 0;
2167  tools::Long nHeaderHeight = 0;
2168  tools::Long nRepeatWidth = 0;
2169  tools::Long nRepeatHeight = 0;
2170  tools::Long nContentWidth = 0; // scaled - not the same as nDataWidth above
2171  tools::Long nContentHeight = 0;
2172  if (aTableParam.bHeaders)
2173  {
2174  nHeaderWidth = static_cast<tools::Long>(PRINT_HEADER_WIDTH * nScaleX);
2175  nHeaderHeight = static_cast<tools::Long>(PRINT_HEADER_HEIGHT * nScaleY);
2176  }
2177  if (bDoRepCol)
2178  for (SCCOL i=nRepeatStartCol; i<=nRepeatEndCol; i++)
2179  nRepeatWidth += static_cast<tools::Long>(rDoc.GetColWidth(i,nPrintTab) * nScaleX);
2180  if (bDoRepRow)
2181  nRepeatHeight += rDoc.GetScaledRowHeight( nRepeatStartRow,
2183  for (SCCOL i=nX1; i<=nX2; i++)
2184  nContentWidth += static_cast<tools::Long>(rDoc.GetColWidth(i,nPrintTab) * nScaleX);
2185  nContentHeight += rDoc.GetScaledRowHeight( nY1, nY2, nPrintTab,
2186  nScaleY);
2187 
2188  // partition the page
2189 
2190  tools::Long nStartX = static_cast<tools::Long>( nLeftSpace * nScaleX );
2191  tools::Long nStartY = static_cast<tools::Long>( nTopSpace * nScaleY );
2192  tools::Long nInnerStartX = nStartX;
2193  tools::Long nInnerStartY = nStartY;
2194  if (pBorderItem)
2195  {
2196  nInnerStartX += static_cast<tools::Long>( ( lcl_LineTotal(pBorderItem->GetLeft()) +
2197  pBorderItem->GetDistance(SvxBoxItemLine::LEFT) ) * nScaleX );
2198  nInnerStartY += static_cast<tools::Long>( ( lcl_LineTotal(pBorderItem->GetTop()) +
2199  pBorderItem->GetDistance(SvxBoxItemLine::TOP) ) * nScaleY );
2200  }
2201  if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE)
2202  {
2203  nInnerStartX += static_cast<tools::Long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::LEFT) * nScaleX );
2204  nInnerStartY += static_cast<tools::Long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::TOP) * nScaleY );
2205  }
2206 
2207  if ( bLayoutRTL )
2208  {
2209  // arrange elements starting from the right edge
2210  nInnerStartX += nHeaderWidth + nRepeatWidth + nContentWidth;
2211 
2212  // make rounding easier so the elements are really next to each other in preview
2213  Size aOffsetOnePixel = pDev->PixelToLogic( Size(1,1), aOffsetMode );
2214  tools::Long nOffsetOneX = aOffsetOnePixel.Width();
2215  nInnerStartX += nOffsetOneX / 2;
2216  }
2217 
2218  tools::Long nFrameStartX = nInnerStartX;
2219  tools::Long nFrameStartY = nInnerStartY;
2220 
2221  tools::Long nRepStartX = nInnerStartX + nHeaderWidth * nLayoutSign; // widths/heights are 0 if not used
2222  tools::Long nRepStartY = nInnerStartY + nHeaderHeight;
2223  tools::Long nDataX = nRepStartX + nRepeatWidth * nLayoutSign;
2224  tools::Long nDataY = nRepStartY + nRepeatHeight;
2225  tools::Long nEndX = nDataX + nContentWidth * nLayoutSign;
2226  tools::Long nEndY = nDataY + nContentHeight;
2227  tools::Long nFrameEndX = nEndX;
2228  tools::Long nFrameEndY = nEndY;
2229 
2230  if ( bLayoutRTL )
2231  {
2232  // each element's start position is its left edge
2234  nInnerStartX -= nHeaderWidth; // used for header
2235  nRepStartX -= nRepeatWidth;
2236  nDataX -= nContentWidth;
2237 
2238  // continue right of the main elements again
2239  nEndX += nHeaderWidth + nRepeatWidth + nContentWidth;
2240  }
2241 
2242  // Page frame / background
2243 
2245 
2246  tools::Long nBorderEndX = nEndX;
2247  tools::Long nBorderEndY = nEndY;
2248  if (pBorderItem)
2249  {
2250  nBorderEndX += static_cast<tools::Long>( ( lcl_LineTotal(pBorderItem->GetRight()) +
2251  pBorderItem->GetDistance(SvxBoxItemLine::RIGHT) ) * nScaleX );
2252  nBorderEndY += static_cast<tools::Long>( ( lcl_LineTotal(pBorderItem->GetBottom()) +
2253  pBorderItem->GetDistance(SvxBoxItemLine::BOTTOM) ) * nScaleY );
2254  }
2255  if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE)
2256  {
2257  nBorderEndX += static_cast<tools::Long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::RIGHT) * nScaleX );
2258  nBorderEndY += static_cast<tools::Long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::BOTTOM) * nScaleY );
2259  }
2260 
2261  if ( bDoPrint )
2262  {
2264  DrawBorder( nStartX, nStartY, nBorderEndX-nStartX, nBorderEndY-nStartY,
2266 
2268  }
2269 
2271 
2272  // Output repeating rows/columns
2273 
2274  if (bDoRepCol && bDoRepRow)
2275  {
2276  if ( bDoPrint )
2278  nRepStartX,nRepStartY, true, true, false, false );
2279  if ( pLocationData )
2281  nRepStartX,nRepStartY, true, true, *pLocationData );
2282  }
2283  if (bDoRepCol)
2284  {
2285  if ( bDoPrint )
2286  PrintArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY,
2287  true, !bDoRepRow, false, true );
2288  if ( pLocationData )
2289  LocateArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY, true, false, *pLocationData );
2290  }
2291  if (bDoRepRow)
2292  {
2293  if ( bDoPrint )
2294  PrintArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY,
2295  !bDoRepCol, true, true, false );
2296  if ( pLocationData )
2297  LocateArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY, false, true, *pLocationData );
2298  }
2299 
2300  // output data
2301 
2302  if ( bDoPrint )
2303  PrintArea( nX1,nY1, nX2,nY2, nDataX,nDataY, !bDoRepCol,!bDoRepRow, true, true );
2304  if ( pLocationData )
2305  LocateArea( nX1,nY1, nX2,nY2, nDataX,nDataY, false,false, *pLocationData );
2306 
2307  // output column/row headers
2308  // after data (through probably shadow)
2309 
2310  Color aGridColor( COL_BLACK );
2311  if ( bUseStyleColor )
2312  aGridColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
2313 
2314  if (aTableParam.bHeaders)
2315  {
2316  if ( bDoPrint )
2317  {
2318  pDev->SetLineColor( aGridColor );
2319  pDev->SetFillColor();
2321  }
2322 
2323  ScPatternAttr aPattern( rDoc.GetPool() );
2324  vcl::Font aFont;
2326  aPattern.GetFont( aFont, eColorMode, pDev );
2327  pDev->SetFont( aFont );
2328 
2329  if (bDoRepCol)
2330  {
2331  if ( bDoPrint )
2332  PrintColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY );
2333  if ( pLocationData )
2334  LocateColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY, true, *pLocationData );
2335  }
2336  if ( bDoPrint )
2337  PrintColHdr( nX1,nX2, nDataX,nInnerStartY );
2338  if ( pLocationData )
2339  LocateColHdr( nX1,nX2, nDataX,nInnerStartY, false, *pLocationData );
2340  if (bDoRepRow)
2341  {
2342  if ( bDoPrint )
2343  PrintRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY );
2344  if ( pLocationData )
2345  LocateRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY, true, *pLocationData );
2346  }
2347  if ( bDoPrint )
2348  PrintRowHdr( nY1,nY2, nInnerStartX,nDataY );
2349  if ( pLocationData )
2350  LocateRowHdr( nY1,nY2, nInnerStartX,nDataY, false, *pLocationData );
2351  }
2352 
2353  // simple frame
2354 
2355  if ( bDoPrint && ( aTableParam.bGrid || aTableParam.bHeaders ) )
2356  {
2357  Size aOnePixel = pDev->PixelToLogic(Size(1,1));
2358  tools::Long nOneX = aOnePixel.Width();
2359  tools::Long nOneY = aOnePixel.Height();
2360 
2361  tools::Long nLeftX = nFrameStartX;
2362  tools::Long nTopY = nFrameStartY - nOneY;
2363  tools::Long nRightX = nFrameEndX;
2364  tools::Long nBottomY = nFrameEndY - nOneY;
2365  if ( !bLayoutRTL )
2366  {
2367  nLeftX -= nOneX;
2368  nRightX -= nOneX;
2369  }
2371  pDev->SetLineColor( aGridColor );
2372  pDev->SetFillColor();
2373  pDev->DrawRect( tools::Rectangle( nLeftX, nTopY, nRightX, nBottomY ) );
2374  // nEndX/Y without frame-adaptation
2375  }
2376 
2377  if ( pPrinter && bDoPrint )
2378  {
2379  OSL_FAIL( "EndPage does not exist anymore" );
2380  }
2381 
2382  aLastSourceRange = ScRange( nX1, nY1, nPrintTab, nX2, nY2, nPrintTab );
2383  bSourceRangeValid = true;
2384 }
2385 
2386 void ScPrintFunc::SetOffset( const Point& rOfs )
2387 {
2388  aSrcOffset = rOfs;
2389 }
2390 
2391 void ScPrintFunc::SetManualZoom( sal_uInt16 nNewZoom )
2392 {
2393  nManualZoom = nNewZoom;
2394 }
2395 
2396 void ScPrintFunc::SetClearFlag( bool bFlag )
2397 {
2398  bClearWin = bFlag;
2399 }
2400 
2402 {
2403  bUseStyleColor = bFlag;
2404  if (pEditEngine)
2405  pEditEngine->EnableAutoColor( bUseStyleColor );
2406 }
2407 
2408 void ScPrintFunc::SetRenderFlag( bool bFlag )
2409 {
2410  bIsRender = bFlag; // set when using XRenderable (PDF)
2411 }
2412 
2414 {
2415  aTableParam.bCellContent = false;
2416  aTableParam.bNotes = false;
2417  aTableParam.bGrid = false;
2418  aTableParam.bHeaders = false;
2419  aTableParam.bFormulas = false;
2420  aTableParam.bNullVals = false;
2421 }
2422 
2423 // UpdatePages is only called from outside to set the breaks correctly for viewing
2424 // - always without UserArea
2425 
2427 {
2428  if (!pParamSet)
2429  return false;
2430 
2431  // Zoom
2432 
2433  nZoom = 100;
2435  nZoom = ZOOM_MIN; // correct for breaks
2436  else if (aTableParam.bScaleAll)
2437  {
2439  if ( nZoom <= ZOOM_MIN )
2440  nZoom = ZOOM_MIN;
2441  }
2442 
2443  OUString aName = rDoc.GetPageStyle( nPrintTab );
2444  SCTAB nTabCount = rDoc.GetTableCount();
2445  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
2446  if ( nTab==nPrintTab || rDoc.GetPageStyle(nTab)==aName )
2447  {
2448  // Repeating rows/columns
2450 
2451  // set breaks
2452  ResetBreaks(nTab);
2454  }
2455 
2456  return true;
2457 }
2458 
2459 tools::Long ScPrintFunc::CountPages() // sets also nPagesX, nPagesY
2460 {
2461  bool bAreaOk = false;
2462 
2463  if (rDoc.HasTable( nPrintTab ))
2464  {
2465  if (aAreaParam.bPrintArea) // Specify print area?
2466  {
2467  if ( bPrintCurrentTable )
2468  {
2469  ScRange& rRange = aAreaParam.aPrintArea;
2470 
2471  // Here, no comparison of the tables any more. Area is always valid for this table
2472  // If comparison should be done here, the table of print ranges must be adjusted
2473  // when inserting tables etc.!
2474 
2475  nStartCol = rRange.aStart.Col();
2476  nStartRow = rRange.aStart.Row();
2477  nEndCol = rRange.aEnd .Col();
2478  nEndRow = rRange.aEnd .Row();
2479  bAreaOk = AdjustPrintArea(false); // limit
2480  }
2481  else
2482  bAreaOk = false;
2483  }
2484  else // search from document
2485  bAreaOk = AdjustPrintArea(true);
2486  }
2487 
2488  if (bAreaOk)
2489  {
2490  tools::Long nPages = 0;
2491  size_t nY;
2492  if (bMultiArea)
2493  {
2494  sal_uInt16 nRCount = rDoc.GetPrintRangeCount( nPrintTab );
2495  for (sal_uInt16 i=0; i<nRCount; i++)
2496  {
2497  CalcZoom(i);
2498  if ( aTableParam.bSkipEmpty )
2499  for (nY=0; nY< m_aRanges.m_nPagesY; nY++)
2500  nPages += (*m_aRanges.m_xPageRows)[nY].CountVisible();
2501  else
2502  nPages += static_cast<tools::Long>(m_aRanges.m_nPagesX) * m_aRanges.m_nPagesY;
2503  if ( pPageData )
2504  FillPageData();
2505  }
2506  }
2507  else
2508  {
2509  CalcZoom(RANGENO_NORANGE); // calculate Zoom
2510  if ( aTableParam.bSkipEmpty )
2511  for (nY=0; nY<m_aRanges.m_nPagesY; nY++)
2512  nPages += (*m_aRanges.m_xPageRows)[nY].CountVisible();
2513  else
2514  nPages += static_cast<tools::Long>(m_aRanges.m_nPagesX) * m_aRanges.m_nPagesY;
2515  if ( pPageData )
2516  FillPageData();
2517  }
2518  return nPages;
2519  }
2520  else
2521  {
2523  return 0;
2524  }
2525 }
2526 
2528 {
2530  return 0;
2531 
2532  bool bError = false;
2533  if (!aAreaParam.bPrintArea)
2534  bError = !AdjustPrintArea(true); // completely search in Doc
2535 
2536  sal_uInt16 nRepeats = 1; // how often go through it ?
2537  if (bMultiArea)
2538  nRepeats = rDoc.GetPrintRangeCount(nPrintTab);
2539  if (bError)
2540  nRepeats = 0;
2541 
2542  for (sal_uInt16 nStep=0; nStep<nRepeats; nStep++)
2543  {
2544  bool bDoThis = true;
2545  if (bMultiArea) // go through all Areas
2546  {
2547  const ScRange* pThisRange = rDoc.GetPrintRange( nPrintTab, nStep );
2548  if ( pThisRange )
2549  {
2550  nStartCol = pThisRange->aStart.Col();
2551  nStartRow = pThisRange->aStart.Row();
2552  nEndCol = pThisRange->aEnd .Col();
2553  nEndRow = pThisRange->aEnd .Row();
2554  bDoThis = AdjustPrintArea(false);
2555  }
2556  }
2557 
2558  if (bDoThis)
2559  {
2560  assert( bPrintAreaValid );
2561  for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
2562  {
2563  if (rDoc.HasColNotes(nCol, nPrintTab))
2564  {
2565  for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
2566  {
2567  if ( rDoc.HasNote(nCol, nRow, nPrintTab) )
2568  aNotePosList.emplace_back( nCol, nRow, nPrintTab );
2569  }
2570  }
2571  }
2572  }
2573  }
2574 
2575  tools::Long nPages = 0;
2576  tools::Long nNoteNr = 0;
2577  tools::Long nNoteAdd;
2578  do
2579  {
2580  nNoteAdd = PrintNotes( nPages, nNoteNr, false, nullptr );
2581  if (nNoteAdd)
2582  {
2583  nNoteNr += nNoteAdd;
2584  ++nPages;
2585  }
2586  }
2587  while (nNoteAdd);
2588 
2589  return nPages;
2590 }
2591 
2592 void ScPrintFunc::InitModes() // set MapModes from nZoom etc.
2593 {
2594  aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom );
2595 
2596  tools::Long nEffZoom = nZoom * static_cast<tools::Long>(nManualZoom);
2598  nScaleX = nScaleY = HMM_PER_TWIPS; // output in 1/100 mm
2599 
2600  Fraction aZoomFract( nEffZoom,10000 );
2601  Fraction aHorFract = aZoomFract;
2602 
2603  if ( !pPrinter && !bIsRender ) // adjust scale for preview
2604  {
2605  double nFact = pDocShell->GetOutputFactor();
2606  aHorFract = Fraction( static_cast<tools::Long>( nEffZoom / nFact ), 10000 );
2607  }
2608 
2609  aLogicMode = MapMode( MapUnit::Map100thMM, Point(), aHorFract, aZoomFract );
2610 
2611  Point aLogicOfs( -aOffset.X(), -aOffset.Y() );
2612  aOffsetMode = MapMode( MapUnit::Map100thMM, aLogicOfs, aHorFract, aZoomFract );
2613 
2614  Point aTwipsOfs( static_cast<tools::Long>( -aOffset.X() / nScaleX + 0.5 ), static_cast<tools::Long>( -aOffset.Y() / nScaleY + 0.5 ) );
2615  aTwipMode = MapMode( MapUnit::MapTwip, aTwipsOfs, aHorFract, aZoomFract );
2616 }
2617 
2619 {
2620  if ( !pPrinter )
2621  return;
2622 
2623  // Configure Printer to Printing
2624 
2625  Size aEnumSize = aPageSize;
2626 
2627  pPrinter->SetOrientation( bLandscape ? Orientation::Landscape : Orientation::Portrait );
2628  if ( bLandscape )
2629  {
2630  // landscape is always interpreted as a rotation by 90 degrees !
2631  // this leads to non WYSIWIG but at least it prints!
2632  // #i21775#
2633  tools::Long nTemp = aEnumSize.Width();
2634  aEnumSize.setWidth( aEnumSize.Height() );
2635  aEnumSize.setHeight( nTemp );
2636  }
2637  Paper ePaper = SvxPaperInfo::GetSvxPaper( aEnumSize, MapUnit::MapTwip );
2638  sal_uInt16 nPaperBin = pParamSet->Get(ATTR_PAGE_PAPERBIN).GetValue();
2639 
2640  pPrinter->SetPaper( ePaper );
2641  if ( PAPER_USER == ePaper )
2642  {
2643  MapMode aPrinterMode = pPrinter->GetMapMode();
2644  MapMode aLocalMode( MapUnit::MapTwip );
2645  pPrinter->SetMapMode( aLocalMode );
2646  pPrinter->SetPaperSizeUser( aEnumSize );
2647  pPrinter->SetMapMode( aPrinterMode );
2648  }
2649 
2650  pPrinter->SetPaperBin( nPaperBin );
2651 }
2652 
2653 // rPageRanges = range for all tables
2654 // nStartPage = rPageRanges starts at nStartPage
2655 // nDisplayStart = continuous number for displaying the page number
2656 
2658  tools::Long nStartPage, tools::Long nDisplayStart, bool bDoPrint,
2659  ScPreviewLocationData* pLocationData )
2660 {
2661  OSL_ENSURE(pDev,"Device == NULL");
2662  if (!pParamSet)
2663  return 0;
2664 
2665  if ( pPrinter && bDoPrint )
2667 
2668  InitModes();
2669  if ( pLocationData )
2670  {
2671  pLocationData->SetCellMapMode( aOffsetMode );
2672  pLocationData->SetPrintTab( nPrintTab );
2673  }
2674 
2675  MakeTableString();
2676 
2677  tools::Long nPageNo = 0;
2678  tools::Long nPrinted = 0;
2679  tools::Long nEndPage = rPageRanges.GetTotalRange().Max();
2680 
2681  sal_uInt16 nRepeats = 1;
2682  if (bMultiArea)
2683  nRepeats = rDoc.GetPrintRangeCount(nPrintTab);
2684  for (sal_uInt16 nStep=0; nStep<nRepeats; nStep++)
2685  {
2686  if (bMultiArea) // replace area
2687  {
2688  CalcZoom(nStep); // also sets nStartCol etc. new
2689  InitModes();
2690  }
2691 
2692  SCCOL nX1;
2693  SCROW nY1;
2694  SCCOL nX2;
2695  SCROW nY2;
2696  size_t nCountX;
2697  size_t nCountY;
2698 
2699  if (aTableParam.bTopDown) // top-bottom
2700  {
2701  nX1 = nStartCol;
2702  for (nCountX=0; nCountX<m_aRanges.m_nPagesX; nCountX++)
2703  {
2704  OSL_ENSURE(nCountX < m_aRanges.m_xPageEndX->size(), "vector access error for aPageEndX (!)");
2705  nX2 = (*m_aRanges.m_xPageEndX)[nCountX];
2706  for (nCountY=0; nCountY<m_aRanges.m_nPagesY; nCountY++)
2707  {
2708  auto& rPageRow = (*m_aRanges.m_xPageRows)[nCountY];
2709  nY1 = rPageRow.GetStartRow();
2710  nY2 = rPageRow.GetEndRow();
2711  if ( !aTableParam.bSkipEmpty || !rPageRow.IsHidden(nCountX) )
2712  {
2713  if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
2714  {
2715  PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
2716  bDoPrint, pLocationData );
2717  ++nPrinted;
2718  }
2719  ++nPageNo;
2720  }
2721  }
2722  nX1 = nX2 + 1;
2723  }
2724  }
2725  else // left to right
2726  {
2727  for (nCountY=0; nCountY<m_aRanges.m_nPagesY; nCountY++)
2728  {
2729  auto& rPageRow = (*m_aRanges.m_xPageRows)[nCountY];
2730  nY1 = rPageRow.GetStartRow();
2731  nY2 = rPageRow.GetEndRow();
2732  nX1 = nStartCol;
2733  for (nCountX=0; nCountX<m_aRanges.m_nPagesX; nCountX++)
2734  {
2735  OSL_ENSURE(nCountX < m_aRanges.m_xPageEndX->size(), "vector access error for aPageEndX");
2736  nX2 = (*m_aRanges.m_xPageEndX)[nCountX];
2737  if ( !aTableParam.bSkipEmpty || !rPageRow.IsHidden(nCountX) )
2738  {
2739  if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
2740  {
2741  PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
2742  bDoPrint, pLocationData );
2743  ++nPrinted;
2744  }
2745  ++nPageNo;
2746  }
2747  nX1 = nX2 + 1;
2748  }
2749  }
2750  }
2751  }
2752 
2753  aFieldData.aTabName = ScResId( STR_NOTES );
2754 
2755  tools::Long nNoteNr = 0;
2756  tools::Long nNoteAdd;
2757  do
2758  {
2759  if ( nPageNo+nStartPage <= nEndPage )
2760  {
2761  bool bPageSelected = rPageRanges.IsSelected( nPageNo+nStartPage+1 );
2762  nNoteAdd = PrintNotes( nPageNo+nStartPage, nNoteNr, bDoPrint && bPageSelected,
2763  ( bPageSelected ? pLocationData : nullptr ) );
2764  if ( nNoteAdd )
2765  {
2766  nNoteNr += nNoteAdd;
2767  if (bPageSelected)
2768  {
2769  ++nPrinted;
2770  bSourceRangeValid = false; // last page was no cell range
2771  }
2772  ++nPageNo;
2773  }
2774  }
2775  else
2776  nNoteAdd = 0;
2777  }
2778  while (nNoteAdd);
2779 
2780  if ( bMultiArea )
2781  ResetBreaks(nPrintTab); //breaks correct for displaying
2782 
2783  return nPrinted;
2784 }
2785 
2786 void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo ) // calculate zoom
2787 {
2788  sal_uInt16 nRCount = rDoc.GetPrintRangeCount( nPrintTab );
2789  const ScRange* pThisRange = nullptr;
2790  if (nRangeNo != RANGENO_NORANGE && nRangeNo < nRCount)
2791  pThisRange = rDoc.GetPrintRange( nPrintTab, nRangeNo );
2792  if ( pThisRange )
2793  {
2794  nStartCol = pThisRange->aStart.Col();
2795  nStartRow = pThisRange->aStart.Row();
2796  nEndCol = pThisRange->aEnd .Col();
2797  nEndRow = pThisRange->aEnd .Row();
2798  }
2799 
2800  if (!AdjustPrintArea(false)) // empty
2801  {
2802  nZoom = 100;
2804  return;
2805  }
2806 
2808 
2810  {
2811  nZoom = 100;
2812  sal_uInt16 nPagesToFit = aTableParam.nScalePageNum;
2813 
2814  // If manual breaks are forced, calculate minimum # pages required
2816  {
2817  sal_uInt16 nMinPages = 0;
2818  std::set<SCROW> aRowBreaks;
2819  std::set<SCCOL> aColBreaks;
2820  rDoc.GetAllRowBreaks(aRowBreaks, nPrintTab, false, true);
2821  rDoc.GetAllColBreaks(aColBreaks, nPrintTab, false, true);
2822  nMinPages = (aRowBreaks.size() + 1) * (aColBreaks.size() + 1);
2823 
2824  // #i54993# use min forced by breaks if it's > # pages in
2825  // scale parameter to avoid bottoming out at <= ZOOM_MIN
2826  nPagesToFit = std::max(nMinPages, nPagesToFit);
2827  }
2828 
2829  sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
2830  while (true)
2831  {
2832  if (nZoom <= ZOOM_MIN)
2833  break;
2834 
2835  CalcPages();
2836  bool bFitsPage = (m_aRanges.m_nPagesX * m_aRanges.m_nPagesY <= nPagesToFit);
2837 
2838  if (bFitsPage)
2839  {
2840  if (nZoom == 100)
2841  // If it fits at 100%, it's good enough for me.
2842  break;
2843 
2844  nLastFitZoom = nZoom;
2845  nZoom = (nLastNonFitZoom + nZoom) / 2;
2846 
2847  if (nLastFitZoom == nZoom)
2848  // It converged. Use this zoom level.
2849  break;
2850  }
2851  else
2852  {
2853  if (nZoom - nLastFitZoom <= 1)
2854  {
2855  nZoom = nLastFitZoom;
2856  CalcPages();
2857  break;
2858  }
2859 
2860  nLastNonFitZoom = nZoom;
2861  nZoom = (nLastFitZoom + nZoom) / 2;
2862  }
2863  }
2864  }
2865  else if (aTableParam.bScaleTo)
2866  {
2867  nZoom = 100;
2868  sal_uInt16 nW = aTableParam.nScaleWidth;
2869  sal_uInt16 nH = aTableParam.nScaleHeight;
2870 
2871  // If manual breaks are forced, calculate minimum # pages required
2873  {
2874  sal_uInt16 nMinPagesW = 0, nMinPagesH = 0;
2875  std::set<SCROW> aRowBreaks;
2876  std::set<SCCOL> aColBreaks;
2877  rDoc.GetAllRowBreaks(aRowBreaks, nPrintTab, false, true);
2878  rDoc.GetAllColBreaks(aColBreaks, nPrintTab, false, true);
2879  nMinPagesW = aColBreaks.size() + 1;
2880  nMinPagesH = aRowBreaks.size() + 1;
2881 
2882  // #i54993# use min forced by breaks if it's > # pages in
2883  // scale parameters to avoid bottoming out at <= ZOOM_MIN
2884  nW = std::max(nMinPagesW, nW);
2885  nH = std::max(nMinPagesH, nH);
2886  }
2887 
2888  sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
2889  while (true)
2890  {
2891  if (nZoom <= ZOOM_MIN)
2892  break;
2893 
2894  CalcPages();
2895  bool bFitsPage = ((!nW || (m_aRanges.m_nPagesX <= nW)) && (!nH || (m_aRanges.m_nPagesY <= nH)));
2896 
2897  if (bFitsPage)
2898  {
2899  if (nZoom == 100)
2900  // If it fits at 100%, it's good enough for me.
2901  break;
2902 
2903  nLastFitZoom = nZoom;
2904  nZoom = (nLastNonFitZoom + nZoom) / 2;
2905 
2906  if (nLastFitZoom == nZoom)
2907  // It converged. Use this zoom level.
2908  break;
2909  }
2910  else
2911  {
2912  if (nZoom - nLastFitZoom <= 1)
2913  {
2914  nZoom = nLastFitZoom;
2915  CalcPages();
2916  break;
2917  }
2918 
2919  nLastNonFitZoom = nZoom;
2920  nZoom = (nLastFitZoom + nZoom) / 2;
2921  }
2922  }
2923  // tdf#103516 remove the almost blank page(s) for better
2924  // interoperability by using slightly smaller zoom
2925  if (nW > 0 && nH == 0 && m_aRanges.m_nPagesY > 1)
2926  {
2927  sal_uInt32 nLastPagesY = m_aRanges.m_nPagesY;
2928  nLastFitZoom = nZoom;
2929  nZoom *= 0.98;
2930  if (nZoom < nLastFitZoom)
2931  {
2932  CalcPages();
2933  // same page count with smaller zoom: use the original zoom
2934  if (m_aRanges.m_nPagesY == nLastPagesY)
2935  {
2936  nZoom = nLastFitZoom;
2937  CalcPages();
2938  }
2939  }
2940  }
2941  }
2942  else if (aTableParam.bScaleAll)
2943  {
2945  if ( nZoom <= ZOOM_MIN )
2946  nZoom = ZOOM_MIN;
2947  CalcPages();
2948  }
2949  else
2950  {
2951  OSL_ENSURE( aTableParam.bScaleNone, "no scale flag is set" );
2952  nZoom = 100;
2953  CalcPages();
2954  }
2955 }
2956 
2958 {
2959  // Adjust height of head/foot line
2960 
2961  InitModes(); // initialize aTwipMode from nZoom
2962  pDev->SetMapMode( aTwipMode ); // head/foot line in Twips
2963  UpdateHFHeight( aHdr );
2964  UpdateHFHeight( aFtr );
2965 
2966  // Page size in Document-Twips
2967  // Calculating Left / Right also in PrintPage
2968 
2970  aPageRect.SetLeft( ( aPageRect.Left() + nLeftMargin ) * 100 / nZoom );
2971  aPageRect.SetRight( ( aPageRect.Right() - nRightMargin ) * 100 / nZoom );
2972  aPageRect.SetTop( ( aPageRect.Top() + nTopMargin ) * 100 / nZoom + aHdr.nHeight );
2974 
2975  Size aDocPageSize = aPageRect.GetSize();
2976  if (aTableParam.bHeaders)
2977  {
2978  aDocPageSize.AdjustWidth( -(tools::Long(PRINT_HEADER_WIDTH)) );
2979  aDocPageSize.AdjustHeight( -(tools::Long(PRINT_HEADER_HEIGHT)) );
2980  }
2981  if (pBorderItem)
2982  {
2983  aDocPageSize.AdjustWidth( -(lcl_LineTotal(pBorderItem->GetLeft()) +
2985  pBorderItem->GetDistance(SvxBoxItemLine::LEFT) +
2986  pBorderItem->GetDistance(SvxBoxItemLine::RIGHT)) );
2987  aDocPageSize.AdjustHeight( -(lcl_LineTotal(pBorderItem->GetTop()) +
2989  pBorderItem->GetDistance(SvxBoxItemLine::TOP) +
2990  pBorderItem->GetDistance(SvxBoxItemLine::BOTTOM)) );
2991  }
2992  if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE)
2993  {
2994  aDocPageSize.AdjustWidth( -(pShadowItem->CalcShadowSpace(SvxShadowItemSide::LEFT) +
2995  pShadowItem->CalcShadowSpace(SvxShadowItemSide::RIGHT)) );
2996  aDocPageSize.AdjustHeight( -(pShadowItem->CalcShadowSpace(SvxShadowItemSide::TOP) +
2997  pShadowItem->CalcShadowSpace(SvxShadowItemSide::BOTTOM)) );
2998  }
2999  return aDocPageSize;
3000 }
3001 
3002 void ScPrintFunc::ResetBreaks( SCTAB nTab ) // Set Breaks correctly for view
3003 {
3004  rDoc.SetPageSize( nTab, GetDocPageSize() );
3005  rDoc.UpdatePageBreaks( nTab );
3006 }
3007 
3008 static void lcl_SetHidden( const ScDocument& rDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowEntry,
3009  SCCOL nStartCol, const std::vector< SCCOL >& rPageEndX )
3010 {
3011  size_t nPagesX = rPageRowEntry.GetPagesX();
3012  SCROW nStartRow = rPageRowEntry.GetStartRow();
3013  SCROW nEndRow = rPageRowEntry.GetEndRow();
3014 
3015  bool bLeftIsEmpty = false;
3016  ScRange aTempRange;
3017  tools::Rectangle aTempRect = rDoc.GetMMRect( 0,0, 0,0, 0 );
3018 
3019  for (size_t i=0; i<nPagesX; i++)
3020  {
3021  OSL_ENSURE(i < rPageEndX.size(), "vector access error for aPageEndX");
3022  SCCOL nEndCol = rPageEndX[i];
3023  if ( rDoc.IsPrintEmpty( nStartCol, nStartRow, nEndCol, nEndRow, nPrintTab,
3024  bLeftIsEmpty, &aTempRange, &aTempRect ) )
3025  {
3026  rPageRowEntry.SetHidden(i);
3027  bLeftIsEmpty = true;
3028  }
3029  else
3030  bLeftIsEmpty = false;
3031 
3032  nStartCol = nEndCol+1;
3033  }
3034 }
3035 
3036 void ScPrintFunc::CalcPages() // calculates aPageRect and pages from nZoom
3037 {
3038  assert( bPrintAreaValid );
3040 }
3041 
3042 namespace sc
3043 {
3044 
3046  : m_nPagesX(0)
3047  , m_nPagesY(0)
3048  , m_nTotalY(0)
3049 {}
3050 
3052  bool bSkipEmpty, bool bPrintArea,
3053  SCROW nStartRow, SCROW nEndRow,
3054  SCCOL nStartCol, SCCOL nEndCol,
3055  SCTAB nPrintTab, Size const & rDocSize)
3056 {
3057  if (bSkipEmpty == m_aInput.m_bSkipEmpty &&
3058  bPrintArea == m_aInput.m_bPrintArea &&
3059  nStartRow == m_aInput.m_nStartRow && nEndRow == m_aInput.m_nEndRow &&
3060  nStartCol == m_aInput.m_nStartCol && nEndCol == m_aInput.m_nEndCol &&
3061  nPrintTab == m_aInput.m_nPrintTab &&
3062  rDocSize == m_aInput.m_aDocSize)
3063  {
3064  return true;
3065  }
3066 
3067  m_aInput.m_bSkipEmpty = bSkipEmpty;
3068  m_aInput.m_bPrintArea = bPrintArea;
3069  m_aInput.m_nStartRow = nStartRow;
3070  m_aInput.m_nEndRow = nEndRow;
3071  m_aInput.m_nStartCol = nStartCol;
3072  m_aInput.m_nEndCol = nEndCol;
3073  m_aInput.m_nPrintTab = nPrintTab;
3074  m_aInput.m_aDocSize = rDocSize;
3075 
3076  return false;
3077 }
3078 
3080  bool bSkipEmpty, bool bPrintArea,
3081  SCROW nStartRow, SCROW nEndRow,
3082  SCCOL nStartCol, SCCOL nEndCol,
3083  SCTAB nPrintTab, Size const & rDocSize)
3084 {
3085  // Already calculated?
3086  if (checkIfAlreadyCalculatedAndSet(bSkipEmpty, bPrintArea,
3087  nStartRow, nEndRow, nStartCol, nEndCol,
3088  nPrintTab, rDocSize))
3089  return;
3090 
3091  rDoc.SetPageSize(nPrintTab, rDocSize);
3092 
3093  // #i123672# use dynamic mem to react on size changes
3094  if (m_xPageEndX->size() < static_cast<size_t>(rDoc.MaxCol()) + 1)
3095  {
3096  m_xPageEndX->resize(rDoc.MaxCol()+1, SCCOL());
3097  }
3098 
3099  if (bPrintArea)
3100  {
3101  ScRange aRange(nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab);
3102  rDoc.UpdatePageBreaks(nPrintTab, &aRange);
3103  }
3104  else
3105  {
3106  rDoc.UpdatePageBreaks(nPrintTab); // else, end is marked
3107  }
3108 
3109  const size_t nRealCnt = nEndRow - nStartRow + 1;
3110 
3111  // #i123672# use dynamic mem to react on size changes
3112  if (m_xPageEndY->size() < nRealCnt+1)
3113  {
3114  m_xPageEndY->resize(nRealCnt + 1, SCROW());
3115  }
3116 
3117  // Page alignment/splitting after breaks in Col/RowFlags
3118  // Of several breaks in a hidden area, only one counts.
3119 
3120  m_nPagesX = 0;
3121  m_nPagesY = 0;
3122  m_nTotalY = 0;
3123 
3124  bool bVisCol = false;
3125  for (SCCOL i = nStartCol; i <= nEndCol; i++)
3126  {
3127  bool bHidden = rDoc.ColHidden(i, nPrintTab);
3128  bool bPageBreak(rDoc.HasColBreak(i, nPrintTab) & ScBreakType::Page);
3129  if (i > nStartCol && bVisCol && bPageBreak)
3130  {
3131  OSL_ENSURE(m_nPagesX < m_xPageEndX->size(), "vector access error for aPageEndX");
3132  (*m_xPageEndX)[m_nPagesX] = i-1;
3133  ++m_nPagesX;
3134  bVisCol = false;
3135  }
3136  if (!bHidden)
3137  bVisCol = true;
3138  }
3139  if (bVisCol) // also at the end, no empty pages
3140  {
3141  OSL_ENSURE(m_nPagesX < m_xPageEndX->size(), "vector access error for aPageEndX");
3142  (*m_xPageEndX)[m_nPagesX] = nEndCol;
3143  ++m_nPagesX;
3144  }
3145 
3146  bool bVisRow = false;
3147  SCROW nPageStartRow = nStartRow;
3148  SCROW nLastVisibleRow = -1;
3149 
3150  std::unique_ptr<ScRowBreakIterator> pRowBreakIter(rDoc.GetRowBreakIterator(nPrintTab));
3151  SCROW nNextPageBreak = pRowBreakIter->first();
3152  while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND && nNextPageBreak < nStartRow)
3153  // Skip until the page break position is at the start row or greater.
3154  nNextPageBreak = pRowBreakIter->next();
3155 
3156  for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
3157  {
3158  bool bPageBreak = (nNextPageBreak == nRow);
3159  if (bPageBreak)
3160  nNextPageBreak = pRowBreakIter->next();
3161 
3162  if (nRow > nStartRow && bVisRow && bPageBreak)
3163  {
3164  OSL_ENSURE(m_nTotalY < m_xPageEndY->size(), "vector access error for rPageEndY");
3165  (*m_xPageEndY)[m_nTotalY] = nRow - 1;
3166  ++m_nTotalY;
3167 
3168  if (!bSkipEmpty || !rDoc.IsPrintEmpty(nStartCol, nPageStartRow, nEndCol, nRow-1, nPrintTab))
3169  {
3170  auto& rPageRow = (*m_xPageRows)[m_nPagesY];
3171  rPageRow.SetStartRow(nPageStartRow);
3172  rPageRow.SetEndRow(nRow - 1);
3173  rPageRow.SetPagesX(m_nPagesX);
3174  if (bSkipEmpty)
3175  lcl_SetHidden(rDoc, nPrintTab, rPageRow, nStartCol, *m_xPageEndX);
3176  ++m_nPagesY;
3177  }
3178 
3179  nPageStartRow = nRow;
3180  bVisRow = false;
3181  }
3182 
3183  if (nRow <= nLastVisibleRow)
3184  {
3185  // This row is still visible. Don't bother calling RowHidden() to
3186  // find out, for speed optimization.
3187  bVisRow = true;
3188  continue;
3189  }
3190 
3191  SCROW nLastRow = -1;
3192  if (!rDoc.RowHidden(nRow, nPrintTab, nullptr, &nLastRow))
3193  {
3194  bVisRow = true;
3195  nLastVisibleRow = nLastRow;
3196  }
3197  else
3198  {
3199  // Skip all hidden rows until next pagebreak.
3200  nRow = ((nNextPageBreak == ScRowBreakIterator::NOT_FOUND) ? nLastRow :
3201  std::min(nLastRow, nNextPageBreak - 1));
3202  }
3203  }
3204 
3205  if (!bVisRow)
3206  return;
3207 
3208  OSL_ENSURE(m_nTotalY < m_xPageEndY->size(), "vector access error for maPageEndY");
3209  (*m_xPageEndY)[m_nTotalY] = nEndRow;
3210  ++m_nTotalY;
3211 
3212  if (!bSkipEmpty || !rDoc.IsPrintEmpty(nStartCol, nPageStartRow, nEndCol, nEndRow, nPrintTab))
3213  {
3214  auto& rPageRow = (*m_xPageRows)[m_nPagesY];
3215  rPageRow.SetStartRow(nPageStartRow);
3216  rPageRow.SetEndRow(nEndRow);
3217  rPageRow.SetPagesX(m_nPagesX);
3218  if (bSkipEmpty)
3219  lcl_SetHidden(rDoc, nPrintTab, rPageRow, nStartCol, *m_xPageEndX);
3220  ++m_nPagesY;
3221  }
3222 }
3223 
3224 } // end namespace sc
3225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsSystemRTL()
Definition: global.cxx:855
bool IsLandscape() const
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:594
std::shared_ptr< std::map< size_t, ScPageRowEntry > > xPageRows
Definition: printfun.hxx:172
void SetClipRegion()
const Fraction & GetScaleX() const
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_FOOTERFIRST(183)
std::shared_ptr< std::vector< SCROW > > xPageEndY
Definition: printfun.hxx:171
std::unique_ptr< RowInfo[]> mpRowInfo
Definition: fillinfo.hxx:259
OutDevType GetOutDevType() const
FmFormView * pDrawView
Definition: printfun.hxx:200
void FillInfo(ScTableInfo &rTabInfo, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale, double fRowScale, bool bPageMode, bool bFormulaMode, const ScMarkData *pMarkData=nullptr)
Definition: fillinfo.cxx:354
OUString aLongDocName
Definition: editutil.hxx:202
sal_uInt16 GetHeight() const
Definition: attrib.hxx:243
bool bMultiArea
Definition: printfun.hxx:245
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
Definition: document.cxx:6323
SCCOL nEndCol
Definition: printfun.hxx:154
bool IsHidden(size_t nX) const
Definition: printfun.cxx:131
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
Definition: address.cxx:2074
#define OLE_STD_CELLS_Y
Definition: global.hxx:104
void GetPrintState(ScPrintState &rState, bool bSavePageRanges=false)
Definition: printfun.cxx:353
void GetScaleData(Size &rPhysSize, tools::Long &rDocHdr, tools::Long &rDocFtr)
Definition: printfun.cxx:1127
SC_DLLPUBLIC const ScRange * GetRepeatColRange(SCTAB nTab)
Definition: document.cxx:6389
MapMode aOffsetMode
Definition: printfun.hxx:253
ScAddress aStart
Definition: address.hxx:497
sal_uInt16 nTopMargin
Definition: printfun.hxx:222
Size GetDocPageSize()
Definition: printfun.cxx:2957
void DrawFrame(vcl::RenderContext &rRenderContext)
Definition: output.cxx:1387
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
Definition: docsh5.cxx:432
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_DYNAMIC(165)
constexpr TypedWhichId< ScViewObjectModeItem > ATTR_PAGE_DRAWINGS(173)
SC_DLLPUBLIC bool HasPrintRange()
Definition: document.cxx:6352
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:728
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
void CalcZoom(sal_uInt16 nRangeNo)
Definition: printfun.cxx:2786
void SetShowNullValues(bool bSet)
Definition: output.cxx:252
void SetManualZoom(sal_uInt16 nNewZoom)
Definition: printfun.cxx:2391
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
#define RANGENO_NORANGE
Definition: printfun.hxx:43
void SetUseStyleColor(bool bFlag)
Definition: printfun.cxx:2401
ScRange aPrintArea
Definition: pagepar.hxx:59
sal_uInt16 GetLower() const
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
SCROW Row() const
Definition: address.hxx:274
ScVSplitPos
Definition: viewdata.hxx:46
SCROW GetEndRow() const
Definition: printfun.hxx:84
void setWidth(tools::Long nWidth)
GPOS_RM
void SetUseStyleColor(bool bSet)
Definition: output.hxx:323
OUString GetTitle(sal_uInt16 nMaxLen=0) const
virtual bool IsVirtual() const
double nScaleX
Definition: printfun.hxx:255
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_GRID(169)
std::shared_ptr< std::vector< SCROW > > m_xPageEndY
Definition: printfun.hxx:128
Point PrePrintDrawingLayer(tools::Long nLogStX, tools::Long nLogStY)
Definition: output3.cxx:38
SCROW nStartRow
Definition: printfun.hxx:71
std::string GetValue
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
ScPrintFunc(ScDocShell *pShell, SfxPrinter *pNewPrinter, SCTAB nTab, tools::Long nPage=0, tools::Long nDocP=0, const ScRange *pArea=nullptr, const ScPrintOptions *pOptions=nullptr, ScPageBreakData *pData=nullptr)
Definition: printfun.cxx:198
tools::Long nDocPages
Definition: printfun.hxx:213
static void DrawToDev(ScDocument &rDoc, OutputDevice *pDev, double nPrintFactor, const tools::Rectangle &rBound, ScViewData *pViewData, bool bMetaFile)
Definition: printfun.cxx:466
void SetRepeatArea(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow)
Definition: document.cxx:6311
void MakeTableString()
Definition: printfun.cxx:1715
bool IsLeft(tools::Long nPageNo)
Definition: printfun.cxx:1703
constexpr tools::Long Left() const
void PrintPage(tools::Long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, bool bDoPrint, ScPreviewLocationData *pLocationData)
Definition: printfun.cxx:2040
void SetPagesX(size_t nNew)
Definition: printfun.cxx:111
GPOS_NONE
GPOS_LT
bool Contains(const Point &rPOINT) const
constexpr TypedWhichId< ScViewObjectModeItem > ATTR_PAGE_CHARTS(171)
std::shared_ptr< std::vector< SCCOL > > m_xPageEndX
Definition: printfun.hxx:127
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_HEADERLEFT(178)
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
#define OLE_STD_CELLS_X
Definition: global.hxx:103
const OUString & GetName() const
long Long
sal_uInt16 nScaleHeight
Definition: pagepar.hxx:45
tools::Long GetRight() const
const EditTextObject * GetCenterArea() const
Definition: attrib.hxx:186
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:722
void ResetBreaks(SCTAB nTab)
Definition: printfun.cxx:3002
SCSIZE mnArrCount
Definition: fillinfo.hxx:260
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
double GetOutputFactor() const
Definition: docsh.hxx:358
void ScColToAlpha(OUStringBuffer &rBuf, SCCOL nCol)
append alpha representation of column to buffer
Definition: address.cxx:1884
void AddNoteText(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:248
void SetSnapPixel()
Definition: output.cxx:267
const SvxShadowItem * pShadow
Definition: printfun.hxx:65
bool IsSupportedGraphic() const
const SfxItemSet * pParamSet
Definition: printfun.hxx:217
sal_uInt16 GetValue() const
ScPrintRangeData & GetData(size_t i)
Definition: pagedata.cxx:60
void PrintRowHdr(SCROW nY1, SCROW nY2, tools::Long nScrX, tools::Long nScrY)
Definition: printfun.cxx:1467
virtual SdrPageView * ShowSdrPage(SdrPage *pPage) override
const ScPageHFItem * pRight
Definition: printfun.hxx:61
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
const ContentProperties & rData
sal_uInt16 nLeftMargin
Definition: printfun.hxx:221
const MapMode & GetMapMode() const
tools::Long TextHeight(const EditTextObject *pObject)
Definition: printfun.cxx:788
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
bool mbHasPrintRange
Definition: printfun.hxx:246
constexpr SdrLayerID SC_LAYER_BACK(1)
constexpr auto HMM_PER_TWIPS
Definition: output2.cxx:96
sal_uInt16 nBottomMargin
Definition: printfun.hxx:224
ScAddress aEnd
Definition: address.hxx:498
void Draw(OutputDevice &rOutDev, const Point &rDestPt) const
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
void PrintArea(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, tools::Long nScrX, tools::Long nScrY, bool bShLeft, bool bShTop, bool bShRight, bool bShBottom)
Definition: printfun.cxx:1590
void IntersectClipRegion(const tools::Rectangle &rRect)
void SetShowFormulas(bool bSet)
Definition: output.cxx:257
sal_uInt16 nFirstPageNo
Definition: pagepar.hxx:47
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+15)
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual SfxItemSet & GetItemSet()
bool GetLastSourceRange(ScRange &rRange) const
Definition: printfun.cxx:379
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
void GetEmbedded(ScRange &rRange) const
Definition: documen3.cxx:1711
SC_DLLPUBLIC ScRange GetRange(SCTAB nTab, const tools::Rectangle &rMMRect, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1805
void ApplyAsianEditSettings(ScEditEngineDefaulter &rEngine)
Definition: documen9.cxx:674
const editeng::SvxBorderLine * GetRight() const
EmbeddedObjectRef * pObject
ScRefCellValue maCell
Definition: fillinfo.hxx:148
EEControlBits
css::chart::ChartAxisLabelPosition ePos
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:494
Size GetDataSize() const
Definition: printfun.cxx:1118
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1402
SCTAB nPrintTab
Definition: printfun.hxx:151
SCROW GetStartRow() const
Definition: printfun.hxx:83
void SetMapMode()
bool bClearWin
Definition: printfun.hxx:207
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5264
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< ScViewObjectModeItem > ATTR_PAGE_OBJECTS(172)
bool bSourceRangeValid
Definition: printfun.hxx:228
const ScPageHFItem * pFirst
Definition: printfun.hxx:62
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4211
tools::Rectangle aPageRect
Definition: printfun.hxx:250
std::vector< ScAddress > aNotePosList
Definition: printfun.hxx:276
ScSplitPos
Definition: viewdata.hxx:44
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6156
ScPageTableParam aTableParam
Definition: printfun.hxx:239
constexpr tools::Long Width() const
static rtl::Reference< SfxItemPool > CreatePool()
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_HEADERRIGHT(180)
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: documen8.cxx:114
GPOS_TILED
SC_DLLPUBLIC bool GetPrintAreaVer(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW &rEndRow, bool bNotes) const
Definition: documen2.cxx:640
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Definition: document.cxx:6716
SvxGraphicPosition GetGraphicPos() const
SvxNumType GetNumType() const
SvxShadowLocation GetLocation() const
GPOS_LM
const ScRange * pUserArea
Definition: printfun.hxx:215
bool IsPrintEmpty(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bLeftIsEmpty=false, ScRange *pLastRange=nullptr, tools::Rectangle *pLastMM=nullptr) const
Definition: documen9.cxx:435
void FillPageData()
Definition: printfun.cxx:385
bool IsValid() const
Definition: attrib.hxx:244
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:891
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
const Fraction & GetScaleY() const
constexpr TypedWhichId< SvxShadowItem > ATTR_SHADOW(152)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:315
ScCellInfo & cellInfo(SCCOL nCol)
Definition: fillinfo.hxx:191
static void lcl_DrawGraphic(const Graphic &rGraphic, vcl::RenderContext &rOutDev, const tools::Rectangle &rGrf, const tools::Rectangle &rOut)
Definition: printfun.cxx:1142
Additional class containing cell annotation data.
Definition: postit.hxx:160
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2701
void DrawExtraShadow(bool bLeft, bool bTop, bool bRight, bool bBottom)
Definition: output.cxx:1191
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_TOPDOWN(174)
int nCount
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_VERCENTER(163)
void AddNoteMark(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:240
void LocateColHdr(SCCOL nX1, SCCOL nX2, tools::Long nScrX, tools::Long nScrY, bool bRepCol, ScPreviewLocationData &rLocationData)
Definition: printfun.cxx:1508
void InitParam(const ScPrintOptions *pOptions)
Definition: printfun.cxx:859
const SvxBoxItem * pBorder
Definition: printfun.hxx:63
MapMode aLogicMode
Definition: printfun.hxx:252
bool IsSelected(sal_Int32 nIndex) const
constexpr tools::Long GetWidth() const
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:193
SvxPageUsage nPageUsage
Definition: printfun.hxx:230
void SetDrawView(FmFormView *pNew)
Definition: output.hxx:320
SC_DLLPUBLIC const ScRange * GetPrintRange(SCTAB nTab, sal_uInt16 nPos)
Definition: document.cxx:6381
OUString aShortDocName
Definition: editutil.hxx:203
const Graphic * GetGraphic(OUString const &referer=OUString()) const
tools::Long DoPrint(const MultiSelection &rPageRanges, tools::Long nStartPage, tools::Long nDisplayStart, bool bDoPrint, ScPreviewLocationData *pLocationData)
Definition: printfun.cxx:2657
ScPageAreaParam aAreaParam
Definition: printfun.hxx:240
void AddHeaderFooter(const tools::Rectangle &rRect, bool bHeader, bool bLeft)
Definition: prevloc.cxx:228
SCROW GetPosY(ScVSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1416
size_t GetCount() const
Definition: pagedata.hxx:73
void DrawLine(const Point &rStartPt, const Point &rEndPt)
ScDocShell * pDocShell
Definition: printfun.hxx:196
bool IsPrintEntireSheet(SCTAB nTab) const
Returns true, if the specified sheet is always printed.
Definition: document.cxx:6368
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_SHARED_FIRST(167)
bool GetForceBreaks() const
Definition: printopt.hxx:40
constexpr sal_Int64 PRINT_HEADER_WIDTH
Definition: printfun.hxx:45
constexpr TypedWhichId< SvxPaperBinItem > ATTR_PAGE_PAPERBIN(160)
void setHideOle(bool bNew)
void DrawRect(const tools::Rectangle &rRect)
tools::Long PrintNotes(tools::Long nPageNo, tools::Long nNoteStart, bool bDoPrint, ScPreviewLocationData *pLocationData)
Definition: printfun.cxx:1974
bool bPrintAreaValid
Definition: printfun.hxx:267
bool bPrintAreaValid
Definition: printfun.hxx:156
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_HEADERFIRST(182)
void ResetEmbedded()
Definition: documen3.cxx:1752
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2706
constexpr void SetLeft(tools::Long v)
SCROW nStartRow
Definition: printfun.hxx:264
sc::PrintPageRanges m_aRanges
Definition: printfun.hxx:269
const Color & GetColor() const
tools::Long nTabPages
Definition: printfun.hxx:160
ScPrintHFParam aFtr
Definition: printfun.hxx:238
tools::Long nTotalPages
Definition: printfun.hxx:161
const Color & GetColor() const
static void lcl_HidePrint(const ScTableInfo &rTabInfo, SCCOL nX1, SCCOL nX2)
Definition: printfun.cxx:439
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
sal_uInt16 GetWidth() const
Definition: attrib.hxx:242
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1081
const editeng::SvxBorderLine * GetTop() const
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:890
void SetLineColor()
tools::Long CountNotePages()
Definition: printfun.cxx:2527
bool UpdatePages()
Definition: printfun.cxx:2426
tools::Long nTabPages
Definition: printfun.hxx:247
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4495
SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount(SCTAB nTab)
Definition: document.cxx:6373
void MakeEditEngine()
Definition: printfun.cxx:1722
bool bCenterHor
Definition: printfun.hxx:225
SCTAB nPrintTab
Definition: printfun.hxx:211
tools::Long nTotalPages
Definition: editutil.hxx:207
tools::Long DoNotes(tools::Long nNoteStart, bool bDoPrint, ScPreviewLocationData *pLocationData)
Definition: printfun.cxx:1900
Point aOffset
Definition: printfun.hxx:205
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const editeng::SvxBorderLine * GetLeft() const
int i
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(184)
sal_uInt16 nScalePageNum
Definition: pagepar.hxx:46
bool bUseStyleColor
Definition: printfun.hxx:208
void LocateArea(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, tools::Long nScrX, tools::Long nScrY, bool bRepCol, bool bRepRow, ScPreviewLocationData &rLocationData)
Definition: printfun.cxx:1549
size_t nPagesX
Definition: printfun.hxx:158
tools::Long nDocPages
Definition: printfun.hxx:163
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2715
SC_DLLPUBLIC void GetAllColBreaks(std::set< SCCOL > &rBreaks, SCTAB nTab, bool bPage, bool bManual) const
Definition: document.cxx:4401
OUTDEV_PDF
sal_Int16 SCCOL
Definition: types.hxx:21
bool Overlaps(const tools::Rectangle &rRect) const
sal_uInt16 CalcShadowSpace(SvxShadowItemSide nShadow) const
#define SC_MOD()
Definition: scmod.hxx:249
bool bFromPrintState
Definition: printfun.hxx:218
void ExtendPrintArea(OutputDevice *pDev, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW nEndRow) const
Find the maximum column position that contains printable data for the specified row range...
Definition: documen3.cxx:2106
ScRange aLastSourceRange
Definition: printfun.hxx:236
CAUTION! The following defines must be in the same namespace as the respective type.
Size GetOutputSize() const
OUString aTabName
Definition: editutil.hxx:204
tools::Long GetLeft() const
const ScPatternAttr * pPatternAttr
Definition: fillinfo.hxx:150
SCROW nEndRow
Definition: printfun.hxx:155
constexpr tools::Long Right() const
void SetFillColor()
GPOS_MT
bool getHideFormControl() const
SvxGraphicPosition
void DrawBackground(vcl::RenderContext &rRenderContext)
Definition: output.cxx:1022
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_HORCENTER(162)
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
const SfxItemSet * pConditionSet
Definition: fillinfo.hxx:151
void ApplyPrintSettings()
Definition: printfun.cxx:2618
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_FORMULAS(186)
GPOS_MM
SCCOL nStartCol
Definition: printfun.hxx:152
constexpr tools::Long Top() const
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6288
size
void DrawStrings(bool bPixelToLogic=false)
Definition: output2.cxx:1469
void DrawTiled(OutputDevice &rOut, const tools::Rectangle &rArea, const Size &rSize, const Size &rOffset, int nTileCacheSize1D=128)
sal_uInt16 nZoom
Definition: printfun.hxx:243
PrintPageRangesInput m_aInput
Definition: printfun.hxx:135
ScDocument & rDoc
Definition: printfun.hxx:197
bool bIsRender
Definition: printfun.hxx:209
bool HasName() const
constexpr void SetRight(tools::Long v)
bool IsMirror(tools::Long nPageNo)
Definition: printfun.cxx:1698
ScBasicCellInfo & basicCellInfo(SCCOL nCol)
Definition: fillinfo.hxx:204
void LocateRowHdr(SCROW nY1, SCROW nY2, tools::Long nScrX, tools::Long nScrY, bool bRepRow, ScPreviewLocationData &rLocationData)
Definition: printfun.cxx:1529
ScPageBreakData * pPageData
Definition: printfun.hxx:278
Paper
MapUnit GetMapUnit() const
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1996
constexpr void SetBottom(tools::Long v)
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
tools::Long nPageStart
Definition: printfun.hxx:162
void AddColHeaders(const tools::Rectangle &rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol)
Definition: prevloc.cxx:210
ScPageRowEntry & operator=(const ScPageRowEntry &r)
Definition: printfun.cxx:101
VclPtr< SfxPrinter > pPrinter
Definition: printfun.hxx:198
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_NOTES(168)
sal_uInt16 nRight
Definition: printfun.hxx:59
sal_uInt16 nScaleWidth
Definition: pagepar.hxx:44
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_FIRSTPAGENO(177)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_HEADERS(170)
GPOS_AREA
void SetOffset(const Point &rOfs)
Definition: printfun.cxx:2386
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const SvxBoxItem * pBorderItem
Definition: printfun.hxx:232
constexpr TypedWhichId< SvxLRSpaceItem > ATTR_LRSPACE(157)
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5662
SfxItemPool * GetPool() const
SC_DLLPUBLIC bool HasNote(const ScAddress &rPos) const
Definition: document.cxx:6741
sal_uInt16 nScaleAll
Definition: pagepar.hxx:43
SCCOL nRepeatEndCol
Definition: printfun.hxx:259
sc::PrintPageRangesInput aPrintPageRangesInput
Definition: printfun.hxx:167
const SCROW SCROW_REPEAT_NONE
Definition: address.hxx:94
sal_Int32 nLineWidth
constexpr void SetTop(tools::Long v)
void SetGridColor(const Color &rColor)
Definition: output.cxx:242
constexpr TypedWhichId< ScPageScaleToItem > ATTR_PAGE_SCALETO(188)
Size aPageSize
Definition: printfun.hxx:231
void SetPrintTab(SCTAB nNew)
Definition: prevloc.cxx:166
GraphicType GetType() const
const SvxBrushItem * pBackgroundItem
Definition: printfun.hxx:233
SCCOL Col() const
Definition: address.hxx:279
bool bCenterVer
Definition: printfun.hxx:226
void calculate(ScDocument &rDoc, bool bSkipEmpty, bool bPrintArea, SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL nEndCol, SCTAB nPrintTab, Size const &aDocSize)
Definition: printfun.cxx:3079
GPOS_MB
constexpr Point TopLeft() const
SC_DLLPUBLIC const ScViewOptions & GetViewOptions() const
Definition: documen3.cxx:1961
ScAutoFontColorMode
how to treat COL_AUTO in GetFont:
Definition: patattr.hxx:42
void PrintColHdr(SCCOL nX1, SCCOL nX2, tools::Long nScrX, tools::Long nScrY)
Definition: printfun.cxx:1418
sal_uInt16 nLeft
Definition: printfun.hxx:58
SCCOL nRepeatStartCol
Definition: printfun.hxx:258
ScHeaderFieldData aFieldData
Definition: printfun.hxx:274
bool AdjustPrintArea(bool bNew)
Definition: printfun.cxx:704
constexpr tools::Long Bottom() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Size GetPrefSize() const
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
void SetDateTime(const DateTime &)
Definition: printfun.cxx:1137
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void AddRowHeaders(const tools::Rectangle &rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow)
Definition: prevloc.cxx:219
static tools::Long lcl_LineTotal(const ::editeng::SvxBorderLine *pLine)
Definition: printfun.cxx:150
double nScaleY
Definition: printfun.hxx:256
ScHSplitPos
Definition: viewdata.hxx:45
bool bLandscape
Definition: printfun.hxx:227
SvxPageUsage GetPageUsage() const
void SetHidden(size_t nX)
Definition: printfun.cxx:117
void DrawGrid(vcl::RenderContext &rRenderContext, bool bGrid, bool bPage, bool bMergeCover=false)
Definition: output.cxx:296
void SetEmbedded(const ScRange &rRange)
Definition: documen3.cxx:1746
sal_Int32 SCROW
Definition: types.hxx:17
static constexpr SCROW NOT_FOUND
Definition: dociter.hxx:431
bool getHideChart() const
bool bScalePageNum
Definition: pagepar.hxx:41
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_FOOTERLEFT(179)
constexpr Size GetSize() const
sal_uInt16 nManualZoom
Definition: printfun.hxx:206
void PrintHF(tools::Long nPageNo, bool bHeader, tools::Long nStartY, bool bDoPrint, ScPreviewLocationData *pLocationData)
Definition: printfun.cxx:1762
SC_DLLPUBLIC OutputDevice * GetRefDevice()
Definition: documen8.cxx:199
PAPER_USER
sal_uInt16 nDistance
Definition: printfun.hxx:57
SCROW nRepeatEndRow
Definition: printfun.hxx:261
Point aSrcOffset
Definition: printfun.hxx:204
SfxItemState
void SetDrawView(FmFormView *pNew)
Definition: printfun.cxx:434
size_t CountVisible() const
Definition: printfun.cxx:136
Contains the "scale to width/height" attribute in page styles.
Definition: attrib.hxx:224
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr sal_Int64 PRINT_HEADER_HEIGHT
Definition: printfun.hxx:46
SC_DLLPUBLIC const ScRange * GetRepeatRowRange(SCTAB nTab)
Definition: document.cxx:6397
MapMode GetPrefMapMode() const
SC_DLLPUBLIC bool GetPrintAreaHor(SCTAB nTab, SCROW nStartRow, SCROW nEndRow, SCCOL &rEndCol) const
Definition: documen2.cxx:618
constexpr tools::Long Height() const
VclPtr< OutputDevice > pDev
Definition: printfun.hxx:199
const Range & GetTotalRange() const
MapMode aTwipMode
Definition: printfun.hxx:254
const EditTextObject * GetRightArea() const
Definition: attrib.hxx:187
bool bSavedStateRanges
Definition: printfun.hxx:166
void PostPrintDrawingLayer(const Point &rMMOffset)
Definition: output3.cxx:104
void SetFont(const vcl::Font &rNewFont)
const EditTextObject * GetLeftArea() const
Definition: attrib.hxx:185
void Construct(const ScPrintOptions *pOptions)
Definition: printfun.cxx:155
ScRowBreakIterator * GetRowBreakIterator(SCTAB nTab) const
Definition: document.cxx:6493
void AddCellRange(const tools::Rectangle &rRect, const ScRange &rRange, bool bRepCol, bool bRepRow, const MapMode &rDrawMap)
Definition: prevloc.cxx:178
void CalcPages()
Definition: printfun.cxx:3036
constexpr SdrLayerID SC_LAYER_FRONT(0)
bool getHideOle() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
tools::Long GetTextHeight() const
SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const
Definition: document.cxx:4424
OUString aName
size_t GetPagesX() const
Definition: printfun.hxx:85
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
black or white, depending on background
void setHideFormControl(bool bNew)
tools::Long CountPages()
Definition: printfun.cxx:2459
size_t nPagesY
Definition: printfun.hxx:159
void DrawSparklines(vcl::RenderContext &rRenderContext)
Definition: output.cxx:2322
constexpr SdrLayerID SC_LAYER_INTERN(2)
tools::Long AdjustWidth(tools::Long n)
SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const
Definition: document.cxx:6776
static OUString ModifyDelimiters(const OUString &rOld)
Definition: editutil.cxx:65
bool IsEmbedded() const
Definition: document.hxx:950
void DrawBorder(tools::Long nScrX, tools::Long nScrY, tools::Long nScrW, tools::Long nScrH, const SvxBoxItem *pBorderData, const SvxBrushItem *pBackground, const SvxShadowItem *pShadow)
Definition: printfun.cxx:1282
MapMode aOldPrinterMode
Definition: printfun.hxx:202
SCCOL nEndCol
Definition: printfun.hxx:265
const INetURLObject & GetURLObject() const
constexpr TypedWhichId< SvxULSpaceItem > ATTR_ULSPACE(158)
void InitModes()
Definition: printfun.cxx:2592
const SvxShadowItem * pShadowItem
Definition: printfun.hxx:234
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
tools::Long nTotalPages
Definition: printfun.hxx:248
constexpr TypedWhichId< SvxPageItem > ATTR_PAGE(159)
DateTime aDateTime
Definition: editutil.hxx:205
bool checkIfAlreadyCalculatedAndSet(bool bSkipEmpty, bool bPrintArea, SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL nEndCol, SCTAB nPrintTab, Size const &aDocSize)
Definition: printfun.cxx:3051
tools::Long AdjustHeight(tools::Long n)
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6161
const SvxBrushItem * pBack
Definition: printfun.hxx:64
std::unique_ptr< ScHeaderEditEngine > pEditEngine
Definition: printfun.hxx:271
bool bPrintCurrentTable
Definition: printfun.hxx:244
tools::Long GetScrH() const
Definition: output.hxx:335
tools::Long nHeight
Definition: printfun.hxx:55
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:989
from style settings, or black/white if needed
SCCOL nStartCol
Definition: printfun.hxx:263
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4479
void setHideDraw(bool bNew)
static void lcl_FillHFParam(ScPrintHFParam &rParam, const SfxItemSet *pHFSet)
Definition: printfun.cxx:660
tools::Long nPageNo
Definition: editutil.hxx:206
void SetCellMapMode(const MapMode &rMapMode)
Definition: prevloc.cxx:161
void setHeight(tools::Long nHeight)
tools::Long GetScrW() const
Definition: output.hxx:334
void setHideChart(bool bNew)
reference_type * get() const
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:911
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
void SetClearFlag(bool bFlag)
Definition: printfun.cxx:2396
void SetMetaFileMode(bool bNewMode)
Definition: output.cxx:279
GPOS_RB
static void lcl_SetHidden(const ScDocument &rDoc, SCTAB nPrintTab, ScPageRowEntry &rPageRowEntry, SCCOL nStartCol, const std::vector< SCCOL > &rPageEndX)
Definition: printfun.cxx:3008
bool GetSkipEmpty() const
Definition: printopt.hxx:36
const MapMode & GetLogicMode(ScSplitPos eWhich)
Definition: viewdata.cxx:3009
std::shared_ptr< std::vector< SCCOL > > xPageEndX
Definition: printfun.hxx:170
#define ZOOM_MIN
Definition: printfun.cxx:70
std::shared_ptr< std::map< size_t, ScPageRowEntry > > m_xPageRows
Definition: printfun.hxx:129
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_FOOTERRIGHT(181)
sal_uInt16 nRightMargin
Definition: printfun.hxx:223
SC_DLLPUBLIC void GetAllRowBreaks(std::set< SCROW > &rBreaks, SCTAB nTab, bool bPage, bool bManual) const
Definition: document.cxx:4394
SvxNumType eNumType
Definition: editutil.hxx:208
void DrawEdit(bool bPixelToLogic)
Definition: output2.cxx:4294
void UpdateHFHeight(ScPrintHFParam &rParam)
Definition: printfun.cxx:801
void SetRenderFlag(bool bFlag)
Definition: printfun.cxx:2408
GPOS_LB
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_ON(164)
size_t nPagesX
Definition: printfun.hxx:73
void DrawShadow()
Definition: output.cxx:1186
void SetRefDevice(OutputDevice *pRDev)
Definition: output.hxx:316
void SetPageSize(SCTAB nTab, const Size &rSize)
Definition: document.cxx:6296
void AddPDFNotes()
Definition: output.cxx:2463
bool bSharedFirst
Definition: printfun.hxx:54
std::vector< bool > aHidden
Definition: printfun.hxx:74
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_NULLVALS(187)
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4170
PAPER_A4
tools::Long Max() const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
GPOS_RT
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(185)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
ScPageRowEntry()
Cache Number of really visible?
Definition: printfun.hxx:78
sal_uInt16 nZoom
Definition: printfun.hxx:157
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
void SetExclusivelyDrawOleAndDrawObjects()
Definition: printfun.cxx:2413
bool getHideDraw() const
const ScPageHFItem * pLeft
Definition: printfun.hxx:60
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:215
const editeng::SvxBorderLine * GetBottom() const
tools::Long GetScaledRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale, const tools::Long *pnMaxHeight=nullptr) const
Definition: document.cxx:4248
tools::Long nPageStart
Definition: printfun.hxx:212
tools::Long nManHeight
Definition: printfun.hxx:56
const SCCOL SCCOL_REPEAT_NONE
Definition: address.hxx:93
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_SHARED(166)
SCROW nEndRow
Definition: printfun.hxx:266
sal_Int16 SCTAB
Definition: types.hxx:22
size_t nTotalY
Definition: printfun.hxx:168
sal_uInt16 GetUpper() const
SCROW nStartRow
Definition: printfun.hxx:153
std::unique_ptr< SfxItemSet > pEditDefaults
Definition: printfun.hxx:272
void PrintDrawingLayer(SdrLayerID nLayer, const Point &rMMOffset)
Definition: output3.cxx:135
bool m_bDetectedRangeSegmentation false
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:827
constexpr tools::Long GetHeight() const
sal_uInt16 GetWidth() const
static Paper GetSvxPaper(const Size &rSize, MapUnit eUnit)
ScPrintHFParam aHdr
Definition: printfun.hxx:237
SCROW nRepeatStartRow
Definition: printfun.hxx:260
SfxMedium * GetMedium() const