Coverage Report

Created: 2025-12-08 09:28

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