Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sc/source/ui/inc/viewdata.hxx
Line
Count
Source (jump to first uncovered line)
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
#pragma once
20
21
#include <tools/fract.hxx>
22
#include <sfx2/zoomitem.hxx>
23
#include <rangelst.hxx>
24
#include <scdllapi.h>
25
#include <viewopti.hxx>
26
#include "docsh.hxx"
27
28
#include <memory>
29
#include <o3tl/typed_flags_set.hxx>
30
31
constexpr auto SC_SIZE_NONE = std::numeric_limits<tools::Long>::max();
32
33
enum class ScFillMode
34
{
35
    NONE        = 0,
36
    FILL        = 1,
37
    EMBED_LT    = 2,
38
    EMBED_RB    = 3,
39
    MATRIX      = 4,
40
};
41
42
enum ScSplitMode { SC_SPLIT_NONE = 0, SC_SPLIT_NORMAL, SC_SPLIT_FIX, SC_SPLIT_MODE_MAX_ENUM = SC_SPLIT_FIX };
43
44
enum ScSplitPos { SC_SPLIT_TOPLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_BOTTOMRIGHT, SC_SPLIT_POS_MAX_ENUM = SC_SPLIT_BOTTOMRIGHT };
45
enum ScHSplitPos { SC_SPLIT_LEFT, SC_SPLIT_RIGHT };
46
enum ScVSplitPos { SC_SPLIT_TOP, SC_SPLIT_BOTTOM };
47
48
inline ScHSplitPos WhichH( ScSplitPos ePos );
49
inline ScVSplitPos WhichV( ScSplitPos ePos );
50
51
/**  Screen behavior related to cursor movements */
52
enum ScFollowMode { SC_FOLLOW_NONE, SC_FOLLOW_LINE, SC_FOLLOW_FIX, SC_FOLLOW_JUMP, SC_FOLLOW_JUMP_END };
53
54
/** Mouse mode to select areas */
55
enum ScRefType { SC_REFTYPE_NONE, SC_REFTYPE_REF, SC_REFTYPE_FILL,
56
                    SC_REFTYPE_EMBED_LT, SC_REFTYPE_EMBED_RB };
57
58
/** States GetSimpleArea() returns for the underlying selection marks, so the
59
    caller can react if the result is not of type SC_MARK_SIMPLE. */
60
enum ScMarkType
61
{
62
    SC_MARK_NONE            = 0,    // Not returned by GetSimpleArea(), used internally.
63
                                    // Nothing marked always results in the
64
                                    // current cursor position being selected and a simple mark.
65
    SC_MARK_SIMPLE          = 1,    // Simple rectangular area marked, no filtered rows.
66
    SC_MARK_FILTERED        = 2,    // At least one mark contains filtered rows.
67
    SC_MARK_SIMPLE_FILTERED =       // Simple rectangular area marked containing filtered rows.
68
        SC_MARK_SIMPLE |
69
        SC_MARK_FILTERED,  // 3
70
    SC_MARK_MULTI           = 4     // Multiple selection marks.
71
    /* TODO: if filtered multi-selection was implemented, this would be the value to use. */
72
#if 0
73
        ,
74
    SC_MARK_MULTI_FILTERED  =       // Multiple selection marks containing filtered rows.
75
        SC_MARK_MULTI |
76
        SC_MARK_FILTERED   // 6
77
#endif
78
};
79
80
enum class ScPasteFlags
81
{
82
    NONE   = 0,    // No flags specified
83
    Mode   = 1,    // Enable paste-mode
84
    Border = 2,    // Show a border around the source cells
85
};
86
namespace o3tl {
87
    template<> struct typed_flags<ScPasteFlags> : is_typed_flags<ScPasteFlags, 0x03> {};
88
}
89
90
// for internal Drag&Drop:
91
enum class ScDragSrc{
92
    Undefined = 0,
93
    Navigator = 1,
94
    Table     = 2
95
};
96
namespace o3tl {
97
    template<> struct typed_flags<ScDragSrc> : is_typed_flags<ScDragSrc, 0x00000003> {};
98
}
99
100
class ScDocFunc;
101
class ScDBFunc;
102
class ScTabViewShell;
103
class ScDrawView;
104
class ScEditEngineDefaulter;
105
class EditView;
106
class EditStatus;
107
class Outliner;
108
namespace vcl { class Window; }
109
class SfxObjectShell;
110
class SfxBindings;
111
class SfxDispatcher;
112
class ScPatternAttr;
113
class ScExtDocOptions;
114
class ScViewData;
115
class ScGridWindow;
116
class ScSizeDeviceProvider;
117
118
class ScPositionHelper
119
{
120
public:
121
    typedef SCCOLROW index_type;
122
    typedef std::pair<index_type, tools::Long> value_type;
123
    static_assert(std::numeric_limits<index_type>::is_signed, "ScPositionCache: index type is not signed");
124
125
private:
126
    static const index_type null = std::numeric_limits<index_type>::min();
127
128
    class Comp
129
    {
130
    public:
131
        bool operator() (const value_type& rValue1, const value_type& rValue2) const;
132
    };
133
134
    index_type MAX_INDEX;
135
    std::set<value_type, Comp> mData;
136
137
public:
138
    ScPositionHelper(const ScDocument& rDoc, bool bColumn);
139
140
    void insert(index_type nIndex, tools::Long nPos);
141
    void removeByIndex(index_type nIndex);
142
    void invalidateByIndex(index_type nIndex);
143
    void invalidateByPosition(tools::Long nPos);
144
    const value_type& getNearestByIndex(index_type nIndex) const;
145
    const value_type& getNearestByPosition(tools::Long nPos) const;
146
    tools::Long getPosition(index_type nIndex) const;
147
    tools::Long computePosition(index_type nIndex, const std::function<long (index_type)>& getSizePx);
148
};
149
150
class ScBoundsProvider
151
{
152
    typedef ScPositionHelper::value_type value_type;
153
    typedef SCCOLROW index_type;
154
155
    ScDocument& rDoc;
156
    const SCTAB nTab;
157
    const bool bColumnHeader;
158
    const index_type MAX_INDEX;
159
160
    double mfPPTX;
161
    double mfPPTY;
162
    index_type nFirstIndex;
163
    index_type nSecondIndex;
164
    tools::Long nFirstPositionPx;
165
    tools::Long nSecondPositionPx;
166
167
public:
168
    ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader);
169
170
    void GetStartIndexAndPosition(SCCOL& nIndex, tools::Long& nPosition) const;
171
    void GetEndIndexAndPosition(SCCOL& nIndex, tools::Long& nPosition) const;
172
    void GetStartIndexAndPosition(SCROW& nIndex, tools::Long& nPosition) const;
173
    void GetEndIndexAndPosition(SCROW& nIndex, tools::Long& nPosition) const;
174
175
    void Compute(value_type aFirstNearest, value_type aSecondNearest,
176
                 tools::Long nFirstBound, tools::Long nSecondBound);
177
178
    void EnlargeStartBy(tools::Long nOffset);
179
180
    void EnlargeEndBy(tools::Long nOffset);
181
182
    void EnlargeBy(tools::Long nOffset)
183
0
    {
184
0
        EnlargeStartBy(nOffset);
185
0
        EnlargeEndBy(nOffset);
186
0
    }
187
188
private:
189
    tools::Long GetSize(index_type nIndex) const;
190
191
    void GetIndexAndPos(index_type nNearestIndex, tools::Long nNearestPosition,
192
                        tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
193
                        bool bTowards, tools::Long nDiff);
194
195
    void GeIndexBackwards(index_type nNearestIndex, tools::Long nNearestPosition,
196
                          tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
197
                          bool bTowards);
198
199
    void GetIndexTowards(index_type nNearestIndex, tools::Long nNearestPosition,
200
                         tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
201
                         bool bTowards);
202
};
203
204
class ScViewDataTable                           // per-sheet data
205
{
206
friend class ScViewData;
207
private:
208
    SvxZoomType     eZoomType;                  // selected zoom type (normal view)
209
    Fraction        aZoomX;                     // selected zoom X
210
    Fraction        aZoomY;                     // selected zoom Y (displayed)
211
    Fraction        aPageZoomX;                 // zoom in page break preview mode
212
    Fraction        aPageZoomY;
213
214
    tools::Long            nTPosX[2];                  // MapMode - Offset (Twips)
215
    tools::Long            nTPosY[2];
216
    tools::Long            nMPosX[2];                  // MapMode - Offset (1/100 mm)
217
    tools::Long            nMPosY[2];
218
    tools::Long            nPixPosX[2];                // Offset in Pixels
219
    tools::Long            nPixPosY[2];
220
    tools::Long            nHSplitPos;
221
    tools::Long            nVSplitPos;
222
223
    ScSplitMode     eHSplitMode;
224
    ScSplitMode     eVSplitMode;
225
    ScSplitPos      eWhichActive;
226
227
    SCCOL           nFixPosX;                   // Cell position of the splitter when freeze pane
228
    SCROW           nFixPosY;
229
230
    SCCOL           nCurX;
231
    SCROW           nCurY;
232
    SCCOL           nOldCurX;
233
    SCROW           nOldCurY;
234
235
    ScPositionHelper aWidthHelper;
236
    ScPositionHelper aHeightHelper;
237
238
    SCCOL           nPosX[2];                   ///< X position of the top left cell of the visible area.
239
    SCROW           nPosY[2];                   ///< Y position of the top left cell of the visible area.
240
    SCCOL           nMaxTiledCol;
241
    SCROW           nMaxTiledRow;
242
243
    bool            bShowGrid;                  // per sheet show grid lines option.
244
    bool            mbOldCursorValid;           // "virtual" Cursor position when combined
245
                    ScViewDataTable(const ScDocument& rDoc);
246
247
    void            WriteUserDataSequence(
248
                        css::uno::Sequence <css::beans::PropertyValue>& rSettings,
249
                        const ScViewData& rViewData, SCTAB nTab ) const;
250
251
    void            ReadUserDataSequence(
252
                        const css::uno::Sequence <css::beans::PropertyValue>& rSettings,
253
                        ScViewData& rViewData, SCTAB nTab, bool& rHasZoom);
254
255
    /** Sanitize the active split range value to not point into a grid window
256
        that would never be initialized due to non-matching split modes.
257
258
        This is to be done when reading settings from file formats or
259
        configurations that could have arbitrary values. The caller is
260
        responsible for actually assigning the new value to eWhichActive because
261
        we want this function to be const to be able to call the check from
262
        anywhere.
263
     */
264
    [[nodiscard]] ScSplitPos SanitizeWhichActive() const;
265
};
266
267
class ScViewData
268
{
269
private:
270
    double              nPPTX, nPPTY;               // Scaling factors
271
272
    ::std::vector<std::unique_ptr<ScViewDataTable>> maTabData;
273
    ScDocShell&         mrDocShell;
274
    ScDocument&         mrDoc;
275
    ScMarkData          maMarkData;
276
    ScMarkData          maHighlightData;
277
    ScViewDataTable*    pThisTab;                   // Data of the displayed sheet
278
    ScTabViewShell*     pView;
279
    std::unique_ptr<EditView> pEditView[4];               // Belongs to the window
280
    ScViewOptions       maOptions;
281
    EditView*           pSpellingView;
282
283
    Size                aScenButSize;
284
285
    Size                aScrSize;
286
    MapMode             aLogicMode;                 // skalierter 1/100mm-MapMode
287
288
    SvxZoomType         eDefZoomType;               // default zoom and type for missing TabData
289
    Fraction            aDefZoomX;
290
    Fraction            aDefZoomY;
291
    Fraction            aDefPageZoomX;              // zoom in page break preview mode
292
    Fraction            aDefPageZoomY;
293
294
    ScRefType           eRefType;
295
296
    SCTAB               nTabNo;                     // displayed sheet
297
    SCTAB               nRefTabNo;                  // sheet which contains RefInput
298
    SCCOL               nRefStartX;
299
    SCROW               nRefStartY;
300
    SCTAB               nRefStartZ;
301
    SCCOL               nRefEndX;
302
    SCROW               nRefEndY;
303
    SCTAB               nRefEndZ;
304
    SCCOL               nFillStartX;                // Fill Cursor
305
    SCROW               nFillStartY;
306
    SCCOL               nFillEndX;
307
    SCROW               nFillEndY;
308
    SCCOL               nEditCol;                   // Related position
309
    SCROW               nEditRow;
310
    SCCOL               nEditStartCol;
311
    SCCOL               nEditEndCol;                // End of Edit View
312
    SCROW               nEditEndRow;
313
    SCCOL               nTabStartCol;               // for Enter after Tab
314
    ScRange             aDelRange;                  // for delete AutoFill
315
316
    ScPasteFlags        nPasteFlags;
317
318
    ScSplitPos          eEditActivePart;            // the part that was active when edit mode was started
319
    ScFillMode          nFillMode;
320
    SvxAdjust           eEditAdjust;
321
    bool                bEditActive[4] = {};        // Active?
322
    bool                bActive:1;                  // Active Window ?
323
    bool                bIsRefMode:1;               // Reference input
324
    bool                bDelMarkValid:1;            // Only valid at SC_REFTYPE_FILL
325
    bool                bPagebreak:1;               // Page break preview mode
326
    bool                bSelCtrlMouseClick:1;       // special selection handling for ctrl-mouse-click
327
    bool                bMoveArea:1;
328
    bool                bEditHighlight:1;
329
330
    bool                bGrowing;
331
    sal_Int16           nFormulaBarLines;           // Visible lines in the formula bar
332
333
    tools::Long                m_nLOKPageUpDownOffset;
334
    tools::Rectangle    maLOKVisibleArea;///< The visible area in the LibreOfficeKit client.
335
336
    DECL_LINK( EditEngineHdl, EditStatus&, void );
337
338
339
    void          CalcPPT();
340
    void          CreateTabData( SCTAB nNewTab );
341
    void          CreateTabData( std::vector< SCTAB >& rvTabs );
342
    void          CreateSelectedTabData();
343
    void          EnsureTabDataSize(size_t nSize);
344
    void          UpdateCurrentTab();
345
    ScViewDataTable* FetchTableData(SCTAB) const;
346
347
public:
348
    ScViewData( ScDocShell& rDocSh, ScTabViewShell* pViewSh );
349
    ~ScViewData() COVERITY_NOEXCEPT_FALSE;
350
351
0
    ScDocShell&     GetDocShell() const     { return mrDocShell; }
352
    ScDocFunc&      GetDocFunc() const;
353
    SC_DLLPUBLIC ScDBFunc* GetView() const;
354
0
    ScTabViewShell* GetViewShell() const    { return pView; }
355
0
    SfxObjectShell& GetSfxDocShell() const  { return mrDocShell; }
356
    SfxBindings&    GetBindings();          // from ViewShell's ViewFrame
357
    SC_DLLPUBLIC SfxDispatcher& GetDispatcher();        // from ViewShell's ViewFrame
358
359
    SC_DLLPUBLIC ScMarkData& GetMarkData();
360
    ScMarkData&     GetHighlightData();
361
    SC_DLLPUBLIC const ScMarkData& GetMarkData() const;
362
363
    weld::Window*   GetDialogParent();          // forwarded from tabvwsh
364
    SC_DLLPUBLIC ScGridWindow* GetActiveWin();             // from View
365
    const ScGridWindow* GetActiveWin() const;
366
    SC_DLLPUBLIC ScDrawView* GetScDrawView();            // from View
367
    bool            IsMinimized() const;        // from View
368
369
    void            UpdateInputHandler( bool bForce = false );
370
371
    void            WriteUserData(OUString& rData);
372
    void            ReadUserData(std::u16string_view rData);
373
    SC_DLLPUBLIC void WriteExtOptions( ScExtDocOptions& rOpt ) const;
374
    void            ReadExtOptions( const ScExtDocOptions& rOpt );
375
    void            WriteUserDataSequence(css::uno::Sequence <css::beans::PropertyValue>& rSettings) const;
376
    void            ReadUserDataSequence(const css::uno::Sequence <css::beans::PropertyValue>& rSettings);
377
378
0
    ScDocument&     GetDocument() const { return mrDoc; }
379
380
0
    bool            IsActive() const            { return bActive; }
381
0
    void            Activate(bool bActivate)    { bActive = bActivate; }
382
383
    void            InsertTab( SCTAB nTab );
384
    void            InsertTabs( SCTAB nTab, SCTAB nNewSheets );
385
    void            DeleteTab( SCTAB nTab );
386
    void            DeleteTabs( SCTAB nTab, SCTAB nSheets );
387
    void            CopyTab( SCTAB nSrcTab, SCTAB nDestTab );
388
    void            MoveTab( SCTAB nSrcTab, SCTAB nDestTab );
389
390
0
    SCTAB           GetRefTabNo() const                     { return nRefTabNo; }
391
0
    void            SetRefTabNo( SCTAB nNewTab )            { nRefTabNo = nNewTab; }
392
393
0
    SCTAB           GetTabNo() const                        { return nTabNo; }
394
0
    SCCOL           MaxCol() const                          { return mrDoc.MaxCol(); }
395
0
    SCROW           MaxRow() const                          { return mrDoc.MaxRow(); }
396
0
    ScSplitPos      GetActivePart() const                   { return pThisTab->eWhichActive; }
397
    SC_DLLPUBLIC SCCOL GetPosX( ScHSplitPos eWhich, SCTAB nForTab = -1 ) const;
398
    SC_DLLPUBLIC SCROW GetPosY( ScVSplitPos eWhich, SCTAB nForTab = -1 ) const;
399
0
    SCCOL           GetCurX() const                         { return pThisTab->nCurX; }
400
0
    SCROW           GetCurY() const                         { return pThisTab->nCurY; }
401
    SCCOL           GetCurXForTab( SCTAB nTabIndex ) const;
402
    SCROW           GetCurYForTab( SCTAB nTabIndex ) const;
403
    SCCOL           GetOldCurX() const;
404
    SCROW           GetOldCurY() const;
405
0
    tools::Long            GetLOKDocWidthPixel() const             { return pThisTab->aWidthHelper.getPosition(pThisTab->nMaxTiledCol); }
406
0
    tools::Long            GetLOKDocHeightPixel() const            { return pThisTab->aHeightHelper.getPosition(pThisTab->nMaxTiledRow); }
407
408
0
    ScPositionHelper& GetLOKWidthHelper()                   { return pThisTab->aWidthHelper; }
409
0
    ScPositionHelper& GetLOKHeightHelper()                  { return pThisTab->aHeightHelper; }
410
411
    ScPositionHelper* GetLOKWidthHelper(SCTAB nTabIndex);
412
    ScPositionHelper* GetLOKHeightHelper(SCTAB nTabIndex);
413
414
0
    ScSplitMode     GetHSplitMode() const                   { return pThisTab->eHSplitMode; }
415
0
    ScSplitMode     GetVSplitMode() const                   { return pThisTab->eVSplitMode; }
416
0
    tools::Long            GetHSplitPos() const                    { return pThisTab->nHSplitPos; }
417
0
    tools::Long            GetVSplitPos() const                    { return pThisTab->nVSplitPos; }
418
0
    SCCOL           GetFixPosX() const                      { return pThisTab->nFixPosX; }
419
0
    SCROW           GetFixPosY() const                      { return pThisTab->nFixPosY; }
420
0
    SCCOL           GetMaxTiledCol() const                  { return pThisTab->nMaxTiledCol; }
421
0
    SCROW           GetMaxTiledRow() const                  { return pThisTab->nMaxTiledRow; }
422
423
0
    bool            IsPagebreakMode() const                 { return bPagebreak; }
424
0
    bool            IsPasteMode() const                     { return bool(nPasteFlags & ScPasteFlags::Mode); }
425
0
    bool            ShowPasteSource() const                 { return bool(nPasteFlags & ScPasteFlags::Border); }
426
427
    void            SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX );
428
    void            SetPosY( ScVSplitPos eWhich, SCROW nNewPosY );
429
0
    void            SetCurX( SCCOL nNewCurX )                       { pThisTab->nCurX = nNewCurX; }
430
0
    void            SetCurY( SCROW nNewCurY )                       { pThisTab->nCurY = nNewCurY; }
431
    void            SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex );
432
    void            SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex );
433
    void            SetOldCursor( SCCOL nNewX, SCROW nNewY );
434
    void            ResetOldCursor();
435
436
0
    void            SetHSplitMode( ScSplitMode eMode )              { pThisTab->eHSplitMode = eMode; }
437
0
    void            SetVSplitMode( ScSplitMode eMode )              { pThisTab->eVSplitMode = eMode; }
438
0
    void            SetHSplitPos( tools::Long nPos )                       { pThisTab->nHSplitPos = nPos; }
439
0
    void            SetVSplitPos( tools::Long nPos )                       { pThisTab->nVSplitPos = nPos; }
440
0
    void            SetFixPosX( SCCOL nPos )                        { pThisTab->nFixPosX = nPos; }
441
0
    void            SetFixPosY( SCROW nPos )                        { pThisTab->nFixPosY = nPos; }
442
    void            SetMaxTiledCol( SCCOL nCol );
443
    void            SetMaxTiledRow( SCROW nRow );
444
445
    void            SetPagebreakMode( bool bSet );
446
0
    void            SetPasteMode ( ScPasteFlags nFlags )            { nPasteFlags = nFlags; }
447
448
    void            SetZoomType( SvxZoomType eNew, bool bAll );
449
    void            SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs );
450
    SC_DLLPUBLIC void SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs );
451
    void            SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll );
452
    void            RefreshZoom();
453
454
0
    void            SetSelCtrlMouseClick( bool bTmp ) { bSelCtrlMouseClick = bTmp; }
455
456
0
    SvxZoomType     GetZoomType() const     { return pThisTab->eZoomType; }
457
0
    const Fraction& GetZoomX() const        { return bPagebreak ? pThisTab->aPageZoomX : pThisTab->aZoomX; }
458
0
    const Fraction& GetZoomY() const        { return bPagebreak ? pThisTab->aPageZoomY : pThisTab->aZoomY; }
459
460
    void            SetShowGrid( bool bShow );
461
0
    bool            GetShowGrid() const { return pThisTab->bShowGrid; }
462
463
    const MapMode&  GetLogicMode( ScSplitPos eWhich );
464
    const MapMode&  GetLogicMode();                     // Offset 0
465
466
0
    double          GetPPTX() const { return nPPTX; }
467
0
    double          GetPPTY() const { return nPPTY; }
468
469
    void SetFormulaBarLines(sal_Int16 nLines)
470
0
    {
471
        // Formula bar must be between 1 and 25 lines (see SpreadsheetViewSettings.idl)
472
0
        nLines = std::max(nLines, static_cast<sal_Int16>(1));
473
0
        nLines = std::min(nLines, static_cast<sal_Int16>(25));
474
0
        nFormulaBarLines = nLines;
475
0
    }
476
0
    sal_Int16 GetFormulaBarLines() const { return nFormulaBarLines; };
477
478
    SC_DLLPUBLIC ScMarkType GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
479
                                    SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const;
480
    SC_DLLPUBLIC ScMarkType GetSimpleArea( ScRange& rRange ) const;
481
                    /// May modify rNewMark using MarkToSimple().
482
    ScMarkType      GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const;
483
    void            GetMultiArea( ScRangeListRef& rRange ) const;
484
485
    bool            SimpleColMarked();
486
    bool            SimpleRowMarked();
487
488
    bool            IsMultiMarked() const;
489
490
                    /** Disallow Paste on Ctrl+A all selected or another high
491
                        amount of selected cells that is not the same size in
492
                        one direction as the clipboard source.
493
                        To prevent DOOM.
494
                     */
495
    bool            SelectionForbidsPaste( ScDocument* pClipDoc = nullptr );
496
    bool            SelectionForbidsPaste( SCCOL nSrcCols, SCROW nSrcRows );
497
498
                    /** Disallow cell fill (Fill,Enter,...) on Ctrl+A all
499
                        selected or another high amount of selected cells.
500
                        We'd go DOOM.
501
                     */
502
    bool            SelectionForbidsCellFill();
503
                    /// Determine DOOM condition, i.e. from selected range.
504
    static bool     SelectionFillDOOM( const ScRange& rRange );
505
506
    void            SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
507
    void            SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
508
                                    ScFillMode nMode );
509
    void            GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
510
                                 SCCOL& rEndCol, SCROW& rEndRow );
511
    void            ResetFillMode();
512
0
    bool            IsAnyFillMode() const       { return nFillMode != ScFillMode::NONE; }
513
0
    bool            IsFillMode() const          { return nFillMode == ScFillMode::FILL; }
514
0
    ScFillMode      GetFillMode() const         { return nFillMode; }
515
516
0
    SvxAdjust       GetEditAdjust() const {return eEditAdjust; }
517
0
    void            SetEditAdjust( SvxAdjust eNewEditAdjust ) { eEditAdjust = eNewEditAdjust; }
518
519
                    // TRUE: Cell is merged
520
    bool            GetMergeSizePixel( SCCOL nX, SCROW nY, tools::Long& rSizeXPix, tools::Long& rSizeYPix ) const;
521
    bool            GetMergeSizePrintTwips( SCCOL nX, SCROW nY, tools::Long& rSizeXTwips, tools::Long& rSizeYTwips ) const;
522
    void            GetPosFromPixel( tools::Long nClickX, tools::Long nClickY, ScSplitPos eWhich,
523
                                        SCCOL& rPosX, SCROW& rPosY,
524
                                        bool bTestMerge = true, bool bRepair = false, SCTAB nForTab = -1 );
525
    void            GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
526
                                        SCCOL nPosX, SCROW nPosY, bool& rLeft, bool& rTop );
527
528
0
    bool            IsRefMode() const                       { return bIsRefMode; }
529
0
    ScRefType       GetRefType() const                      { return eRefType; }
530
0
    SCCOL           GetRefStartX() const                    { return nRefStartX; }
531
0
    SCROW           GetRefStartY() const                    { return nRefStartY; }
532
0
    SCTAB           GetRefStartZ() const                    { return nRefStartZ; }
533
0
    SCCOL           GetRefEndX() const                      { return nRefEndX; }
534
0
    SCROW           GetRefEndY() const                      { return nRefEndY; }
535
0
    SCTAB           GetRefEndZ() const                      { return nRefEndZ; }
536
537
    void            SetRefMode( bool bNewMode, ScRefType eNewType )
538
0
                                    { bIsRefMode = bNewMode; eRefType = eNewType; }
539
540
    void            SetRefStart( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ );
541
    void            SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ );
542
543
0
    void            ResetDelMark()                          { bDelMarkValid = false; }
544
    void            SetDelMark( const ScRange& rRange )
545
0
                            { aDelRange = rRange; bDelMarkValid = true; }
546
547
    bool            GetDelMark( ScRange& rRange ) const
548
0
                            { rRange = aDelRange; return bDelMarkValid; }
549
550
    inline void     GetMoveCursor( SCCOL& rCurX, SCROW& rCurY );
551
552
0
    const ScViewOptions&    GetOptions() const { return maOptions; }
553
    SC_DLLPUBLIC void       SetOptions( const ScViewOptions& rOpt );
554
555
0
    bool    IsGridMode      () const            { return maOptions.GetOption(sc::ViewOption::GRID); }
556
0
    bool    IsSyntaxMode    () const            { return maOptions.GetOption(sc::ViewOption::SYNTAX); }
557
0
    void    SetSyntaxMode   ( bool bNewMode )   { maOptions.SetOption(sc::ViewOption::SYNTAX, bNewMode); }
558
0
    bool    IsHeaderMode    () const            { return maOptions.GetOption(sc::ViewOption::HEADER); }
559
0
    void    SetHeaderMode   ( bool bNewMode )   { maOptions.SetOption(sc::ViewOption::HEADER, bNewMode); }
560
0
    bool    IsTabMode       () const            { return maOptions.GetOption(sc::ViewOption::TABCONTROLS); }
561
0
    bool    IsVScrollMode   () const            { return maOptions.GetOption(sc::ViewOption::VSCROLL); }
562
0
    bool    IsHScrollMode   () const            { return maOptions.GetOption(sc::ViewOption::HSCROLL); }
563
0
    bool    IsOutlineMode   () const            { return maOptions.GetOption(sc::ViewOption::OUTLINER); }
564
0
    bool    IsThemedCursor  () const            { return maOptions.GetOption(sc::ViewOption::THEMEDCURSOR); }
565
566
0
    bool    GetEditHighlight() const            { return bEditHighlight; }
567
0
    void    SetEditHighlight(bool bNewHighlight) { bEditHighlight = bNewHighlight; }
568
569
    /// Force page size for PgUp/PgDown to overwrite the computation based on m_aVisArea.
570
0
    void ForcePageUpDownOffset(tools::Long nTwips) { m_nLOKPageUpDownOffset = nTwips; }
571
0
    tools::Long GetPageUpDownOffset() const { return m_nLOKPageUpDownOffset; }
572
573
    /// The visible area in the client (set by setClientVisibleArea).
574
0
    const tools::Rectangle& getLOKVisibleArea() const { return maLOKVisibleArea; }
575
0
    void setLOKVisibleArea(const tools::Rectangle& rArea) { maLOKVisibleArea = rArea; }
576
577
    void            KillEditView();
578
    void            ResetEditView();
579
    void            SetEditEngine( ScSplitPos eWhich,
580
                                    ScEditEngineDefaulter& rNewEngine,
581
                                    vcl::Window* pWin, SCCOL nNewX, SCROW nNewY );
582
    void            GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow );
583
    bool            HasEditView( ScSplitPos eWhich ) const
584
0
                                        { return pEditView[eWhich] && bEditActive[eWhich]; }
585
    EditView*       GetEditView( ScSplitPos eWhich ) const
586
0
                                        { return pEditView[eWhich].get(); }
587
588
    /**
589
     * Extend the output area for the edit engine view in a horizontal
590
     * direction as needed.
591
     */
592
    void            EditGrowX();
593
594
    /**
595
     * Extend the output area for the edit engine view in a vertical direction
596
     * as needed.
597
     *
598
     * @param bInitial when true, then the call originates from a brand-new
599
     *                 edit engine instance.
600
     */
601
    void            EditGrowY( bool bInitial = false );
602
603
0
    ScSplitPos      GetEditActivePart() const       { return eEditActivePart; }
604
0
    SCCOL           GetEditViewCol() const          { return nEditCol; }
605
0
    SCROW           GetEditViewRow() const          { return nEditRow; }
606
0
    SCCOL           GetEditStartCol() const         { return nEditStartCol; }
607
0
    SCROW           GetEditStartRow() const         { return nEditRow; }        // never editing above the cell
608
0
    SCCOL           GetEditEndCol() const           { return nEditEndCol; }
609
0
    SCROW           GetEditEndRow() const           { return nEditEndRow; }
610
611
    tools::Rectangle       GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, vcl::Window* pWin,
612
                                    const ScPatternAttr* pPattern, bool bForceToTop, bool bInPrintTwips = false );
613
614
    void            SetTabNo( SCTAB nNewTab );
615
    void            SetActivePart( ScSplitPos eNewActive );
616
617
    SC_DLLPUBLIC Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
618
                                bool bAllowNeg = false, SCTAB nForTab = -1 ) const;
619
    Point           GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const;
620
    Point           GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const;
621
    /// returns the position (top-left corner) of the requested cell in print twips coordinates.
622
    SC_DLLPUBLIC Point GetPrintTwipsPos( SCCOL nCol, SCROW nRow ) const;
623
    Point           GetPrintTwipsPosFromTileTwips(const Point& rTileTwipsPos) const;
624
625
    /// return json for our cursor position.
626
0
    OString         describeCellCursor() const { return describeCellCursorAt(GetCurX(), GetCurY()); }
627
0
    OString         describeCellCursorInPrintTwips() const { return describeCellCursorAt(GetCurX(), GetCurY(), false); }
628
    OString         describeCellCursorAt( SCCOL nCol, SCROW nRow, bool bPixelAligned = true ) const;
629
630
    SCCOL           CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX,
631
                              tools::Long nScrSizeY = SC_SIZE_NONE ) const;
632
    SCROW           CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY,
633
                              tools::Long nScrSizeX = SC_SIZE_NONE ) const;
634
635
    SCCOL           VisibleCellsX( ScHSplitPos eWhichX ) const;     // Completely visible cell
636
    SCROW           VisibleCellsY( ScVSplitPos eWhichY ) const;
637
    SCCOL           PrevCellsX( ScHSplitPos eWhichX ) const;        // Cells on the preceding page
638
    SCROW           PrevCellsY( ScVSplitPos eWhichY ) const;
639
640
    bool            IsOle() const;
641
    void            SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
642
    void            SetScreen( const tools::Rectangle& rVisArea );
643
    void            SetScreenPos( const Point& rVisAreaStart );
644
645
    void            UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY );
646
647
0
    const Size&     GetScrSize() const              { return aScrSize; }
648
649
    void            RecalcPixPos();
650
    Point           GetPixPos( ScSplitPos eWhich ) const
651
0
                    { return Point( pThisTab->nPixPosX[WhichH(eWhich)],
652
0
                                    pThisTab->nPixPosY[WhichV(eWhich)] ); }
653
0
    void            SetSpellingView( EditView* pSpView) { pSpellingView = pSpView; }
654
0
    EditView*       GetSpellingView() const { return pSpellingView; }
655
656
    void            UpdateOutlinerFlags( Outliner& rOutl ) const;
657
658
    Point           GetMousePosPixel();
659
660
    bool            UpdateFixX(SCTAB nTab = MAXTAB+1);
661
    bool            UpdateFixY(SCTAB nTab = MAXTAB+1);
662
663
0
    SCCOL           GetTabStartCol() const          { return nTabStartCol; }
664
0
    void            SetTabStartCol(SCCOL nNew)      { nTabStartCol = nNew; }
665
666
    ScAddress       GetCurPos() const;
667
668
0
    const Size&     GetScenButSize() const              { return aScenButSize; }
669
0
    void            SetScenButSize(const Size& rNew)    { aScenButSize = rNew; }
670
671
0
    bool            IsSelCtrlMouseClick() const { return bSelCtrlMouseClick; }
672
673
    SCCOLROW        GetLOKSheetFreezeIndex(bool bIsCol) const;
674
    bool            SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab = -1);
675
    bool            RemoveLOKFreeze();
676
    void            DeriveLOKFreezeAllSheets();
677
    void            DeriveLOKFreezeIfNeeded(SCTAB nForTab);
678
    void            OverrideWithLOKFreeze(ScSplitMode& eExHSplitMode, ScSplitMode& eExVSplitMode,
679
                                          SCCOL& nExFixPosX, SCROW& nExFixPosY,
680
                                          tools::Long& nExHSplitPos, tools::Long& nExVSplitPos, SCTAB nForTab) const;
681
682
    static inline tools::Long ToPixel( sal_uInt16 nTwips, double nFactor );
683
684
    /** while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row
685
        heights converted with nPPTY to rScrY, optimized for row height
686
        segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY
687
        may be > nEndPixels!
688
     */
689
    static void     AddPixelsWhile( tools::Long & rScrY, tools::Long nEndPixels,
690
                                    SCROW & rPosY, SCROW nEndRow, double nPPTY,
691
                                    const ScDocument * pDoc, SCTAB nTabNo );
692
693
    /** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row
694
        heights converted with nPPTY to rScrY, optimized for row height
695
        segments. Upon return rPosY is the last row evaluated >= nStartRow,
696
        rScrY may be > nEndPixels!
697
     */
698
    static void     AddPixelsWhileBackward( tools::Long & rScrY, tools::Long nEndPixels,
699
                                    SCROW & rPosY, SCROW nStartRow, double nPPTY,
700
                                    const ScDocument * pDoc, SCTAB nTabNo );
701
702
    void setupSizeDeviceProviderForColWidth(const ScSizeDeviceProvider& rProv, Fraction& rZoomX, Fraction& rZoomY, double& rPPTX, double &rPPTY);
703
};
704
705
inline tools::Long ScViewData::ToPixel( sal_uInt16 nTwips, double nFactor )
706
0
{
707
0
    tools::Long nRet = static_cast<tools::Long>( nTwips * nFactor );
708
0
    if ( !nRet && nTwips )
709
0
        nRet = 1;
710
0
    return nRet;
711
0
}
712
713
inline void ScViewData::GetMoveCursor( SCCOL& rCurX, SCROW& rCurY )
714
0
{
715
0
    if ( bIsRefMode )
716
0
    {
717
0
        rCurX = nRefEndX;
718
0
        rCurY = nRefEndY;
719
0
    }
720
0
    else
721
0
    {
722
0
        rCurX = GetCurX();
723
0
        rCurY = GetCurY();
724
0
    }
725
0
}
726
727
inline ScHSplitPos WhichH( ScSplitPos ePos )
728
0
{
729
0
    return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_BOTTOMLEFT) ?
730
0
                SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
731
0
}
732
733
inline ScVSplitPos WhichV( ScSplitPos ePos )
734
0
{
735
0
    return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_TOPRIGHT) ?
736
0
                SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
737
0
}
738
739
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */