Coverage Report

Created: 2026-03-31 11:00

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