LibreOffice Module sc (master)  1
viewdata.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #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 #define SC_SIZE_NONE 65535
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 
43 
47 
48 inline ScHSplitPos WhichH( ScSplitPos ePos );
49 inline ScVSplitPos WhichV( ScSplitPos ePos );
50 
53 
57 
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.
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.
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 ScDocument;
102 class ScDBFunc;
103 class ScTabViewShell;
104 class ScDrawView;
106 class EditView;
107 class EditStatus;
108 class Outliner;
109 namespace vcl { class Window; }
110 class SfxObjectShell;
111 class SfxBindings;
112 class SfxDispatcher;
113 class ScPatternAttr;
114 class ScExtDocOptions;
115 class ScViewData;
116 class ScMarkData;
117 class ScGridWindow;
118 
120 {
121 public:
123  typedef std::pair<index_type, tools::Long> value_type;
124  static_assert(std::numeric_limits<index_type>::is_signed, "ScPositionCache: index type is not signed");
125 
126 private:
127  static const index_type null = std::numeric_limits<index_type>::min();
128 
129  class Comp
130  {
131  public:
132  bool operator() (const value_type& rValue1, const value_type& rValue2) const;
133  };
134 
135  index_type MAX_INDEX;
136  std::set<value_type, Comp> mData;
137 
138 public:
139  ScPositionHelper(const ScDocument *pDoc, bool bColumn);
140  void setDocument(const ScDocument& rDoc, bool bColumn);
141 
142  void insert(index_type nIndex, tools::Long nPos);
143  void removeByIndex(index_type nIndex);
144  void invalidateByIndex(index_type nIndex);
146  const value_type& getNearestByIndex(index_type nIndex) const;
147  const value_type& getNearestByPosition(tools::Long nPos) const;
148  tools::Long getPosition(index_type nIndex) const;
149  tools::Long computePosition(index_type nIndex, const std::function<long (index_type)>& getSizePx);
150 };
151 
153 {
156 
158  const SCTAB nTab;
159  const bool bColumnHeader;
160  const index_type MAX_INDEX;
161 
162  double mfPPTX;
163  double mfPPTY;
164  index_type nFirstIndex;
165  index_type nSecondIndex;
168 
169 public:
170  ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader);
171 
172  void GetStartIndexAndPosition(SCCOL& nIndex, tools::Long& nPosition) const;
173  void GetEndIndexAndPosition(SCCOL& nIndex, tools::Long& nPosition) const;
174  void GetStartIndexAndPosition(SCROW& nIndex, tools::Long& nPosition) const;
175  void GetEndIndexAndPosition(SCROW& nIndex, tools::Long& nPosition) const;
176 
177  void Compute(value_type aFirstNearest, value_type aSecondNearest,
178  tools::Long nFirstBound, tools::Long nSecondBound);
179 
180  void EnlargeStartBy(tools::Long nOffset);
181 
182  void EnlargeEndBy(tools::Long nOffset);
183 
184  void EnlargeBy(tools::Long nOffset)
185  {
186  EnlargeStartBy(nOffset);
187  EnlargeEndBy(nOffset);
188  }
189 
190 private:
191  tools::Long GetSize(index_type nIndex) const;
192 
193  void GetIndexAndPos(index_type nNearestIndex, tools::Long nNearestPosition,
194  tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
195  bool bTowards, tools::Long nDiff);
196 
197  void GeIndexBackwards(index_type nNearestIndex, tools::Long nNearestPosition,
198  tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
199  bool bTowards);
200 
201  void GetIndexTowards(index_type nNearestIndex, tools::Long nNearestPosition,
202  tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
203  bool bTowards);
204 };
205 
206 class ScViewDataTable // per-sheet data
207 {
208 friend class ScViewData;
209 private:
210  SvxZoomType eZoomType; // selected zoom type (normal view)
211  Fraction aZoomX; // selected zoom X
212  Fraction aZoomY; // selected zoom Y (displayed)
213  Fraction aPageZoomX; // zoom in page break preview mode
215 
216  tools::Long nTPosX[2]; // MapMode - Offset (Twips)
218  tools::Long nMPosX[2]; // MapMode - Offset (1/100 mm)
220  tools::Long nPixPosX[2]; // Offset in Pixels
224 
228 
229  SCCOL nFixPosX; // Cell position of the splitter when freeze pane
231 
236 
239 
244 
245  bool bShowGrid; // per sheet show grid lines option.
246  bool mbOldCursorValid; // "virtual" Cursor position when combined
247  ScViewDataTable(const ScDocument *pDoc = nullptr);
248 
249  void InitData(const ScDocument& rDoc);
251  css::uno::Sequence <css::beans::PropertyValue>& rSettings,
252  const ScViewData& rViewData, SCTAB nTab ) const;
253 
255  const css::uno::Sequence <css::beans::PropertyValue>& rSettings,
256  ScViewData& rViewData, SCTAB nTab, bool& rHasZoom);
257 
267  [[nodiscard]] ScSplitPos SanitizeWhichActive() const;
268 };
269 
271 {
272 private:
273  double nPPTX, nPPTY; // Scaling factors
274 
275  ::std::vector<std::unique_ptr<ScViewDataTable>> maTabData;
277  ScViewDataTable* pThisTab; // Data of the displayed sheet
281  std::unique_ptr<EditView> pEditView[4]; // Belongs to the window
284 
286 
288  MapMode aLogicMode; // skalierter 1/100mm-MapMode
289 
290  SvxZoomType eDefZoomType; // default zoom and type for missing TabData
293  Fraction aDefPageZoomX; // zoom in page break preview mode
295 
297 
298  SCTAB nTabNo; // displayed sheet
299  SCTAB nRefTabNo; // sheet which contains RefInput
306  SCCOL nFillStartX; // Fill Cursor
310  SCCOL nEditCol; // Related position
313  SCCOL nEditEndCol; // End of Edit View
315  SCCOL nTabStartCol; // for Enter after Tab
316  ScRange aDelRange; // for delete AutoFill
317 
319 
320  ScSplitPos eEditActivePart; // the part that was active when edit mode was started
323  bool bEditActive[4] = {}; // Active?
324  bool bActive:1; // Active Window ?
325  bool bIsRefMode:1; // Reference input
326  bool bDelMarkValid:1; // Only valid at SC_REFTYPE_FILL
327  bool bPagebreak:1; // Page break preview mode
328  bool bSelCtrlMouseClick:1; // special selection handling for ctrl-mouse-click
329  bool bMoveArea:1;
330 
331  bool bGrowing;
332 
335 
336  DECL_DLLPRIVATE_LINK( EditEngineHdl, EditStatus&, void );
337 
338 
339  SAL_DLLPRIVATE void CalcPPT();
340  SAL_DLLPRIVATE void CreateTabData( SCTAB nNewTab );
341  SAL_DLLPRIVATE void CreateTabData( std::vector< SCTAB >& rvTabs );
342  SAL_DLLPRIVATE void CreateSelectedTabData();
343  SAL_DLLPRIVATE void EnsureTabDataSize(size_t nSize);
344  SAL_DLLPRIVATE void UpdateCurrentTab();
345 
346  ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pViewSh);
347 
348 public:
349  ScViewData( ScDocShell& rDocSh, ScTabViewShell* pViewSh );
350  ScViewData( ScDocument& rDoc );
351  ~ScViewData() COVERITY_NOEXCEPT_FALSE;
352 
353  ScDocShell* GetDocShell() const { return pDocShell; }
354  ScDocFunc& GetDocFunc() const;
355  ScDBFunc* GetView() const;
356  ScTabViewShell* GetViewShell() const { return pView; }
357  SfxObjectShell* GetSfxDocShell() const { return pDocShell; }
358  SfxBindings& GetBindings(); // from ViewShell's ViewFrame
359  SfxDispatcher& GetDispatcher(); // from ViewShell's ViewFrame
360 
361  ScMarkData& GetMarkData();
362  const ScMarkData& GetMarkData() const;
363 
364  weld::Window* GetDialogParent(); // forwarded from tabvwsh
365  ScGridWindow* GetActiveWin(); // from View
366  const ScGridWindow* GetActiveWin() const;
367  ScDrawView* GetScDrawView(); // from View
368  bool IsMinimized() const; // from View
369 
370  void UpdateInputHandler( bool bForce = false );
371 
372  void WriteUserData(OUString& rData);
373  void ReadUserData(const OUString& rData);
374  void WriteExtOptions( ScExtDocOptions& rOpt ) const;
375  void ReadExtOptions( const ScExtDocOptions& rOpt );
376  void WriteUserDataSequence(css::uno::Sequence <css::beans::PropertyValue>& rSettings) const;
377  void ReadUserDataSequence(const css::uno::Sequence <css::beans::PropertyValue>& rSettings);
378 
379  ScDocument& GetDocument() const { return mrDoc; }
380 
381  bool IsActive() const { return bActive; }
382  void Activate(bool bActivate) { bActive = bActivate; }
383 
384  void InsertTab( SCTAB nTab );
385  void InsertTabs( SCTAB nTab, SCTAB nNewSheets );
386  void DeleteTab( SCTAB nTab );
387  void DeleteTabs( SCTAB nTab, SCTAB nSheets );
388  void CopyTab( SCTAB nSrcTab, SCTAB nDestTab );
389  void MoveTab( SCTAB nSrcTab, SCTAB nDestTab );
390 
391  SCTAB GetRefTabNo() const { return nRefTabNo; }
392  void SetRefTabNo( SCTAB nNewTab ) { nRefTabNo = nNewTab; }
393 
394  SCTAB GetTabNo() const { return nTabNo; }
395  SCCOL MaxCol() const { return mrDoc.MaxCol(); }
396  SCROW MaxRow() const { return mrDoc.MaxRow(); }
397  ScSplitPos GetActivePart() const { return pThisTab->eWhichActive; }
398  SCCOL GetPosX( ScHSplitPos eWhich, SCTAB nForTab = -1 ) const;
399  SCROW GetPosY( ScVSplitPos eWhich, SCTAB nForTab = -1 ) const;
400  SCCOL GetCurX() const { return pThisTab->nCurX; }
401  SCROW GetCurY() const { return pThisTab->nCurY; }
402  SCCOL GetCurXForTab( SCTAB nTabIndex ) const;
403  SCROW GetCurYForTab( SCTAB nTabIndex ) const;
404  SCCOL GetOldCurX() const;
405  SCROW GetOldCurY() const;
406  tools::Long GetLOKDocWidthPixel() const { return pThisTab->aWidthHelper.getPosition(pThisTab->nMaxTiledCol); }
407  tools::Long GetLOKDocHeightPixel() const { return pThisTab->aHeightHelper.getPosition(pThisTab->nMaxTiledRow); }
408 
411 
412  ScPositionHelper* GetLOKWidthHelper(SCTAB nTabIndex);
413  ScPositionHelper* GetLOKHeightHelper(SCTAB nTabIndex);
414 
415  ScSplitMode GetHSplitMode() const { return pThisTab->eHSplitMode; }
416  ScSplitMode GetVSplitMode() const { return pThisTab->eVSplitMode; }
417  tools::Long GetHSplitPos() const { return pThisTab->nHSplitPos; }
418  tools::Long GetVSplitPos() const { return pThisTab->nVSplitPos; }
419  SCCOL GetFixPosX() const { return pThisTab->nFixPosX; }
420  SCROW GetFixPosY() const { return pThisTab->nFixPosY; }
421  SCCOL GetMaxTiledCol() const { return pThisTab->nMaxTiledCol; }
422  SCROW GetMaxTiledRow() const { return pThisTab->nMaxTiledRow; }
423 
424  bool IsPagebreakMode() const { return bPagebreak; }
425  bool IsPasteMode() const { return bool(nPasteFlags & ScPasteFlags::Mode); }
426  bool ShowPasteSource() const { return bool(nPasteFlags & ScPasteFlags::Border); }
427 
428  void SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX );
429  void SetPosY( ScVSplitPos eWhich, SCROW nNewPosY );
430  void SetCurX( SCCOL nNewCurX ) { pThisTab->nCurX = nNewCurX; }
431  void SetCurY( SCROW nNewCurY ) { pThisTab->nCurY = nNewCurY; }
432  void SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex );
433  void SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex );
434  void SetOldCursor( SCCOL nNewX, SCROW nNewY );
435  void ResetOldCursor();
436 
437  void SetHSplitMode( ScSplitMode eMode ) { pThisTab->eHSplitMode = eMode; }
438  void SetVSplitMode( ScSplitMode eMode ) { pThisTab->eVSplitMode = eMode; }
439  void SetHSplitPos( tools::Long nPos ) { pThisTab->nHSplitPos = nPos; }
440  void SetVSplitPos( tools::Long nPos ) { pThisTab->nVSplitPos = nPos; }
441  void SetFixPosX( SCCOL nPos ) { pThisTab->nFixPosX = nPos; }
442  void SetFixPosY( SCROW nPos ) { pThisTab->nFixPosY = nPos; }
443  void SetMaxTiledCol( SCCOL nCol );
444  void SetMaxTiledRow( SCROW nRow );
445 
446  void SetPagebreakMode( bool bSet );
447  void SetPasteMode ( ScPasteFlags nFlags ) { nPasteFlags = nFlags; }
448 
449  void SetZoomType( SvxZoomType eNew, bool bAll );
450  void SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs );
451  void SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs );
452  void SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll );
453  void RefreshZoom();
454 
455  void SetSelCtrlMouseClick( bool bTmp ) { bSelCtrlMouseClick = bTmp; }
456 
457  SvxZoomType GetZoomType() const { return pThisTab->eZoomType; }
458  const Fraction& GetZoomX() const { return bPagebreak ? pThisTab->aPageZoomX : pThisTab->aZoomX; }
459  const Fraction& GetZoomY() const { return bPagebreak ? pThisTab->aPageZoomY : pThisTab->aZoomY; }
460 
461  void SetShowGrid( bool bShow );
462  bool GetShowGrid() const { return pThisTab->bShowGrid; }
463 
464  const MapMode& GetLogicMode( ScSplitPos eWhich );
465  const MapMode& GetLogicMode(); // Offset 0
466 
467  double GetPPTX() const { return nPPTX; }
468  double GetPPTY() const { return nPPTY; }
469 
470  ScMarkType GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
471  SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const;
472  ScMarkType GetSimpleArea( ScRange& rRange ) const;
474  ScMarkType GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const;
475  void GetMultiArea( ScRangeListRef& rRange ) const;
476 
477  bool SimpleColMarked();
478  bool SimpleRowMarked();
479 
480  bool IsMultiMarked() const;
481 
487  bool SelectionForbidsPaste( ScDocument* pClipDoc = nullptr );
488  bool SelectionForbidsPaste( SCCOL nSrcCols, SCROW nSrcRows );
489 
494  bool SelectionForbidsCellFill();
496  static bool SelectionFillDOOM( const ScRange& rRange );
497 
498  void SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
499  void SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
500  ScFillMode nMode );
501  void GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
502  SCCOL& rEndCol, SCROW& rEndRow );
503  void ResetFillMode();
504  bool IsAnyFillMode() const { return nFillMode != ScFillMode::NONE; }
505  bool IsFillMode() const { return nFillMode == ScFillMode::FILL; }
506  ScFillMode GetFillMode() const { return nFillMode; }
507 
508  SvxAdjust GetEditAdjust() const {return eEditAdjust; }
509  void SetEditAdjust( SvxAdjust eNewEditAdjust ) { eEditAdjust = eNewEditAdjust; }
510 
511  // TRUE: Cell is merged
512  bool GetMergeSizePixel( SCCOL nX, SCROW nY, tools::Long& rSizeXPix, tools::Long& rSizeYPix ) const;
513  bool GetMergeSizePrintTwips( SCCOL nX, SCROW nY, tools::Long& rSizeXTwips, tools::Long& rSizeYTwips ) const;
514  void GetPosFromPixel( tools::Long nClickX, tools::Long nClickY, ScSplitPos eWhich,
515  SCCOL& rPosX, SCROW& rPosY,
516  bool bTestMerge = true, bool bRepair = false, SCTAB nForTab = -1 );
517  void GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
518  SCCOL nPosX, SCROW nPosY, bool& rLeft, bool& rTop );
519 
520  bool IsRefMode() const { return bIsRefMode; }
521  ScRefType GetRefType() const { return eRefType; }
522  SCCOL GetRefStartX() const { return nRefStartX; }
523  SCROW GetRefStartY() const { return nRefStartY; }
524  SCTAB GetRefStartZ() const { return nRefStartZ; }
525  SCCOL GetRefEndX() const { return nRefEndX; }
526  SCROW GetRefEndY() const { return nRefEndY; }
527  SCTAB GetRefEndZ() const { return nRefEndZ; }
528 
529  void SetRefMode( bool bNewMode, ScRefType eNewType )
530  { bIsRefMode = bNewMode; eRefType = eNewType; }
531 
532  void SetRefStart( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ );
533  void SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ );
534 
535  void ResetDelMark() { bDelMarkValid = false; }
536  void SetDelMark( const ScRange& rRange )
537  { aDelRange = rRange; bDelMarkValid = true; }
538 
539  bool GetDelMark( ScRange& rRange ) const
540  { rRange = aDelRange; return bDelMarkValid; }
541 
542  inline void GetMoveCursor( SCCOL& rCurX, SCROW& rCurY );
543 
544  const ScViewOptions& GetOptions() const { return maOptions; }
545  void SetOptions( const ScViewOptions& rOpt );
546 
547  bool IsGridMode () const { return maOptions.GetOption(VOPT_GRID); }
548  bool IsSyntaxMode () const { return maOptions.GetOption(VOPT_SYNTAX); }
549  void SetSyntaxMode ( bool bNewMode ) { maOptions.SetOption(VOPT_SYNTAX, bNewMode); }
550  bool IsHeaderMode () const { return maOptions.GetOption(VOPT_HEADER); }
551  void SetHeaderMode ( bool bNewMode ) { maOptions.SetOption(VOPT_HEADER, bNewMode); }
552  bool IsTabMode () const { return maOptions.GetOption(VOPT_TABCONTROLS); }
553  bool IsVScrollMode () const { return maOptions.GetOption(VOPT_VSCROLL); }
554  bool IsHScrollMode () const { return maOptions.GetOption(VOPT_HSCROLL); }
555  bool IsOutlineMode () const { return maOptions.GetOption(VOPT_OUTLINER); }
556  bool IsThemedCursor () const { return maOptions.GetOption(VOPT_THEMEDCURSOR); }
557 
559  void ForcePageUpDownOffset(tools::Long nTwips) { m_nLOKPageUpDownOffset = nTwips; }
560  tools::Long GetPageUpDownOffset() const { return m_nLOKPageUpDownOffset; }
561 
563  const tools::Rectangle& getLOKVisibleArea() const { return maLOKVisibleArea; }
564  void setLOKVisibleArea(const tools::Rectangle& rArea) { maLOKVisibleArea = rArea; }
565 
566  void KillEditView();
567  void ResetEditView();
568  void SetEditEngine( ScSplitPos eWhich,
569  ScEditEngineDefaulter* pNewEngine,
570  vcl::Window* pWin, SCCOL nNewX, SCROW nNewY );
571  void GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow );
572  bool HasEditView( ScSplitPos eWhich ) const
573  { return pEditView[eWhich] && bEditActive[eWhich]; }
574  EditView* GetEditView( ScSplitPos eWhich ) const
575  { return pEditView[eWhich].get(); }
576 
581  void EditGrowX();
582 
590  void EditGrowY( bool bInitial = false );
591 
592  ScSplitPos GetEditActivePart() const { return eEditActivePart; }
593  SCCOL GetEditViewCol() const { return nEditCol; }
594  SCROW GetEditViewRow() const { return nEditRow; }
595  SCCOL GetEditStartCol() const { return nEditStartCol; }
596  SCROW GetEditStartRow() const { return nEditRow; } // never editing above the cell
597  SCCOL GetEditEndCol() const { return nEditEndCol; }
598  SCROW GetEditEndRow() const { return nEditEndRow; }
599 
600  tools::Rectangle GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, vcl::Window* pWin,
601  const ScPatternAttr* pPattern, bool bForceToTop, bool bInPrintTwips = false );
602 
603  void SetTabNo( SCTAB nNewTab );
604  void SetActivePart( ScSplitPos eNewActive );
605 
606  Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
607  bool bAllowNeg = false, SCTAB nForTab = -1 ) const;
608  Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const;
609  Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const;
611  Point GetPrintTwipsPos( SCCOL nCol, SCROW nRow ) const;
612  Point GetPrintTwipsPosFromTileTwips(const Point& rTileTwipsPos) const;
613 
615  OString describeCellCursor() const { return describeCellCursorAt(GetCurX(), GetCurY()); }
616  OString describeCellCursorInPrintTwips() const { return describeCellCursorAt(GetCurX(), GetCurY(), false); }
617  OString describeCellCursorAt( SCCOL nCol, SCROW nRow, bool bPixelAligned = true ) const;
618 
619  SCCOL CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeY = SC_SIZE_NONE ) const;
620  SCROW CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeX = SC_SIZE_NONE ) const;
621 
622  SCCOL VisibleCellsX( ScHSplitPos eWhichX ) const; // Completely visible cell
623  SCROW VisibleCellsY( ScVSplitPos eWhichY ) const;
624  SCCOL PrevCellsX( ScHSplitPos eWhichX ) const; // Cells on the preceding page
625  SCROW PrevCellsY( ScVSplitPos eWhichY ) const;
626 
627  bool IsOle() const;
628  void SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
629  void SetScreen( const tools::Rectangle& rVisArea );
630  void SetScreenPos( const Point& rVisAreaStart );
631 
632  void UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY );
633 
634  const Size& GetScrSize() const { return aScrSize; }
635 
636  void RecalcPixPos();
637  Point GetPixPos( ScSplitPos eWhich ) const
638  { return Point( pThisTab->nPixPosX[WhichH(eWhich)],
639  pThisTab->nPixPosY[WhichV(eWhich)] ); }
640  void SetSpellingView( EditView* pSpView) { pSpellingView = pSpView; }
641  EditView* GetSpellingView() const { return pSpellingView; }
642 
643  void UpdateOutlinerFlags( Outliner& rOutl ) const;
644 
645  Point GetMousePosPixel();
646 
647  bool UpdateFixX(SCTAB nTab = MAXTAB+1);
648  bool UpdateFixY(SCTAB nTab = MAXTAB+1);
649 
650  SCCOL GetTabStartCol() const { return nTabStartCol; }
651  void SetTabStartCol(SCCOL nNew) { nTabStartCol = nNew; }
652 
653  ScAddress GetCurPos() const;
654 
655  const Size& GetScenButSize() const { return aScenButSize; }
656  void SetScenButSize(const Size& rNew) { aScenButSize = rNew; }
657 
658  bool IsSelCtrlMouseClick() const { return bSelCtrlMouseClick; }
659 
660  SCCOLROW GetLOKSheetFreezeIndex(bool bIsCol) const;
661  bool SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab = -1);
662  bool RemoveLOKFreeze();
663  void DeriveLOKFreezeAllSheets();
664  void DeriveLOKFreezeIfNeeded(SCTAB nForTab);
665  void OverrideWithLOKFreeze(ScSplitMode& eExHSplitMode, ScSplitMode& eExVSplitMode,
666  SCCOL& nExFixPosX, SCROW& nExFixPosY,
667  tools::Long& nExHSplitPos, tools::Long& nExVSplitPos, SCTAB nForTab) const;
668 
669  static inline tools::Long ToPixel( sal_uInt16 nTwips, double nFactor );
670 
676  static void AddPixelsWhile( tools::Long & rScrY, tools::Long nEndPixels,
677  SCROW & rPosY, SCROW nEndRow, double nPPTY,
678  const ScDocument * pDoc, SCTAB nTabNo );
679 
685  static void AddPixelsWhileBackward( tools::Long & rScrY, tools::Long nEndPixels,
686  SCROW & rPosY, SCROW nStartRow, double nPPTY,
687  const ScDocument * pDoc, SCTAB nTabNo );
688 };
689 
690 inline tools::Long ScViewData::ToPixel( sal_uInt16 nTwips, double nFactor )
691 {
692  tools::Long nRet = static_cast<tools::Long>( nTwips * nFactor );
693  if ( !nRet && nTwips )
694  nRet = 1;
695  return nRet;
696 }
697 
698 inline void ScViewData::GetMoveCursor( SCCOL& rCurX, SCROW& rCurY )
699 {
700  if ( bIsRefMode )
701  {
702  rCurX = nRefEndX;
703  rCurY = nRefEndY;
704  }
705  else
706  {
707  rCurX = GetCurX();
708  rCurY = GetCurY();
709  }
710 }
711 
713 {
714  return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_BOTTOMLEFT) ?
716 }
717 
719 {
720  return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_TOPRIGHT) ?
722 }
723 
724 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsAnyFillMode() const
Definition: viewdata.hxx:504
tools::Long nPixPosX[2]
Definition: viewdata.hxx:220
Fraction aZoomY
Definition: viewdata.hxx:212
void SetVSplitMode(ScSplitMode eMode)
Definition: viewdata.hxx:438
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:87
constexpr double nPPTY
ScRefType eRefType
Definition: viewdata.hxx:296
SCCOL GetTabStartCol() const
Definition: viewdata.hxx:650
SvxZoomType eDefZoomType
Definition: viewdata.hxx:290
OString describeCellCursor() const
return json for our cursor position.
Definition: viewdata.hxx:615
tools::Rectangle maLOKVisibleArea
The visible area in the LibreOfficeKit client.
Definition: viewdata.hxx:334
index_type nSecondIndex
Definition: viewdata.hxx:165
void SetDelMark(const ScRange &rRange)
Definition: viewdata.hxx:536
void SetEditAdjust(SvxAdjust eNewEditAdjust)
Definition: viewdata.hxx:509
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
void Compute(value_type aFirstNearest, value_type aSecondNearest, tools::Long nFirstBound, tools::Long nSecondBound)
Definition: viewdata.cxx:345
ScRefType GetRefType() const
Definition: viewdata.hxx:521
ScRange aDelRange
Definition: viewdata.hxx:316
void SetCurX(SCCOL nNewCurX)
Definition: viewdata.hxx:430
SCROW GetRefEndY() const
Definition: viewdata.hxx:526
ScDocShell * pDocShell
Definition: viewdata.hxx:278
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:718
void SetFixPosY(SCROW nPos)
Definition: viewdata.hxx:442
ScVSplitPos
Definition: viewdata.hxx:46
SCTAB nRefTabNo
Definition: viewdata.hxx:299
SCCOL MaxCol() const
Definition: viewdata.hxx:395
bool IsVScrollMode() const
Definition: viewdata.hxx:553
const tools::Rectangle & getLOKVisibleArea() const
The visible area in the client (set by setClientVisibleArea).
Definition: viewdata.hxx:563
ScTabViewShell * pView
Definition: viewdata.hxx:280
tools::Long nHSplitPos
Definition: viewdata.hxx:222
const Fraction & GetZoomX() const
Definition: viewdata.hxx:458
ScPositionHelper aHeightHelper
Definition: viewdata.hxx:238
Fraction aDefPageZoomX
Definition: viewdata.hxx:293
SvxAdjust eEditAdjust
Definition: viewdata.hxx:322
void SetHSplitPos(tools::Long nPos)
Definition: viewdata.hxx:439
Size aScenButSize
Definition: viewdata.hxx:285
bool GetDelMark(ScRange &rRange) const
Definition: viewdata.hxx:539
Fraction aDefPageZoomY
Definition: viewdata.hxx:294
void SetHeaderMode(bool bNewMode)
Definition: viewdata.hxx:551
tools::Long nFirstPositionPx
Definition: viewdata.hxx:166
::std::vector< std::unique_ptr< ScViewDataTable > > maTabData
Definition: viewdata.hxx:275
SCROW GetRefStartY() const
Definition: viewdata.hxx:523
long Long
Fraction aPageZoomY
Definition: viewdata.hxx:214
void SetPasteMode(ScPasteFlags nFlags)
Definition: viewdata.hxx:447
void invalidateByPosition(tools::Long nPos)
Definition: viewdata.cxx:175
SCROW GetCurY() const
Definition: viewdata.hxx:401
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:712
SvxZoomType GetZoomType() const
Definition: viewdata.hxx:457
const bool bColumnHeader
Definition: viewdata.hxx:159
SCCOL nPosX[2]
X position of the top left cell of the visible area.
Definition: viewdata.hxx:240
ScPasteFlags nPasteFlags
Definition: viewdata.hxx:318
ScViewOptions maOptions
Definition: viewdata.hxx:282
ScFollowMode
Screen behavior related to cursor movements.
Definition: viewdata.hxx:52
SCROW GetMaxTiledRow() const
Definition: viewdata.hxx:422
void GetMoveCursor(SCCOL &rCurX, SCROW &rCurY)
Definition: viewdata.hxx:698
SvxAdjust GetEditAdjust() const
Definition: viewdata.hxx:508
void SetSpellingView(EditView *pSpView)
Definition: viewdata.hxx:640
double GetPPTX() const
Definition: viewdata.hxx:467
SCCOL nTabStartCol
Definition: viewdata.hxx:315
SCROW GetFixPosY() const
Definition: viewdata.hxx:420
bool HasEditView(ScSplitPos eWhich) const
Definition: viewdata.hxx:572
SCTAB GetTabNo() const
Definition: viewdata.hxx:394
bool IsSyntaxMode() const
Definition: viewdata.hxx:548
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:76
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:397
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
SCCOL nEditEndCol
Definition: viewdata.hxx:313
tools::Long getPosition(index_type nIndex) const
Definition: viewdata.cxx:252
void insert(index_type nIndex, tools::Long nPos)
Definition: viewdata.cxx:135
Mode
void SetSelCtrlMouseClick(bool bTmp)
Definition: viewdata.hxx:455
ScSplitPos SanitizeWhichActive() const
Sanitize the active split range value to not point into a grid window that would never be initialized...
Definition: viewdata.cxx:741
void GetIndexTowards(index_type nNearestIndex, tools::Long nNearestPosition, tools::Long nBound, index_type &nFoundIndex, tools::Long &nPosition, bool bTowards)
Definition: viewdata.cxx:457
SCROW GetEditEndRow() const
Definition: viewdata.hxx:598
void Activate(bool bActivate)
Definition: viewdata.hxx:382
std::set< value_type, Comp > mData
Definition: viewdata.hxx:136
SCCOL GetEditViewCol() const
Definition: viewdata.hxx:593
ScSplitPos
Definition: viewdata.hxx:44
SCROW nEditEndRow
Definition: viewdata.hxx:314
bool IsTabMode() const
Definition: viewdata.hxx:552
ScPositionHelper(const ScDocument *pDoc, bool bColumn)
Definition: viewdata.cxx:124
bool ShowPasteSource() const
Definition: viewdata.hxx:426
static tools::Long ToPixel(sal_uInt16 nTwips, double nFactor)
Definition: viewdata.hxx:690
SCTAB nTabNo
Definition: viewdata.hxx:298
tools::Long GetVSplitPos() const
Definition: viewdata.hxx:418
Fraction aPageZoomX
Definition: viewdata.hxx:213
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
SCCOL nRefStartX
Definition: viewdata.hxx:300
tools::Long nMPosX[2]
Definition: viewdata.hxx:218
void SetFixPosX(SCCOL nPos)
Definition: viewdata.hxx:441
SCCOLROW index_type
Definition: viewdata.hxx:155
void SetRefTabNo(SCTAB nNewTab)
Definition: viewdata.hxx:392
tools::Long GetLOKDocHeightPixel() const
Definition: viewdata.hxx:407
tools::Long nTPosY[2]
Definition: viewdata.hxx:217
EditView * pSpellingView
Definition: viewdata.hxx:283
tools::Long nPixPosY[2]
Definition: viewdata.hxx:221
BOOL IsMinimized(HWND hWnd)
SCCOL GetMaxTiledCol() const
Definition: viewdata.hxx:421
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:415
const Fraction & GetZoomY() const
Definition: viewdata.hxx:459
ScSplitMode eVSplitMode
Definition: viewdata.hxx:226
bool IsFillMode() const
Definition: viewdata.hxx:505
tools::Long nTPosX[2]
Definition: viewdata.hxx:216
EditView * GetSpellingView() const
Definition: viewdata.hxx:641
const Size & GetScenButSize() const
Definition: viewdata.hxx:655
ScPasteFlags
Definition: viewdata.hxx:80
ScDocument & rDoc
Definition: viewdata.hxx:157
Point GetPixPos(ScSplitPos eWhich) const
Definition: viewdata.hxx:637
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:356
SCROW nFillStartY
Definition: viewdata.hxx:307
constexpr double nPPTX
void ResetDelMark()
Definition: viewdata.hxx:535
SCROW MaxRow() const
Definition: viewdata.hxx:396
bool IsHScrollMode() const
Definition: viewdata.hxx:554
void GetIndexAndPos(index_type nNearestIndex, tools::Long nNearestPosition, tools::Long nBound, index_type &nFoundIndex, tools::Long &nPosition, bool bTowards, tools::Long nDiff)
Definition: viewdata.cxx:333
EditView * GetEditView(ScSplitPos eWhich) const
Definition: viewdata.hxx:574
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:871
ScDragSrc
Definition: viewdata.hxx:91
tools::Long nMPosY[2]
Definition: viewdata.hxx:219
void setDocument(const ScDocument &rDoc, bool bColumn)
Definition: viewdata.cxx:130
Size aScrSize
Definition: viewdata.hxx:287
SCTAB GetRefEndZ() const
Definition: viewdata.hxx:527
SvxAdjust
void EnlargeEndBy(tools::Long nOffset)
Definition: viewdata.cxx:420
void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &rSettings, const ScViewData &rViewData, SCTAB nTab) const
Definition: viewdata.cxx:526
tools::Long nVSplitPos
Definition: viewdata.hxx:223
static const index_type null
Definition: viewdata.hxx:127
const SCTAB nTab
Definition: viewdata.hxx:158
void invalidateByIndex(index_type nIndex)
Definition: viewdata.cxx:160
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:60
sal_Int16 SCCOL
Definition: types.hxx:21
SCCOL nMaxTiledCol
Definition: viewdata.hxx:242
void SetCurY(SCROW nNewCurY)
Definition: viewdata.hxx:431
index_type nFirstIndex
Definition: viewdata.hxx:164
ScSplitPos GetEditActivePart() const
Definition: viewdata.hxx:592
tools::Long GetHSplitPos() const
Definition: viewdata.hxx:417
void InitData(const ScDocument &rDoc)
Definition: viewdata.cxx:520
tools::Long nSecondPositionPx
Definition: viewdata.hxx:167
std::pair< index_type, tools::Long > value_type
Definition: viewdata.hxx:123
void GetStartIndexAndPosition(SCCOL &nIndex, tools::Long &nPosition) const
Definition: viewdata.cxx:299
SCROW nRefStartY
Definition: viewdata.hxx:301
bool IsActive() const
Definition: viewdata.hxx:381
void GeIndexBackwards(index_type nNearestIndex, tools::Long nNearestPosition, tools::Long nBound, index_type &nFoundIndex, tools::Long &nPosition, bool bTowards)
Definition: viewdata.cxx:433
bool IsPasteMode() const
Definition: viewdata.hxx:425
ScViewDataTable(const ScDocument *pDoc=nullptr)
Definition: viewdata.cxx:486
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
void SetRefMode(bool bNewMode, ScRefType eNewType)
Definition: viewdata.hxx:529
const Size & GetScrSize() const
Definition: viewdata.hxx:634
void SetVSplitPos(tools::Long nPos)
Definition: viewdata.hxx:440
SCTAB nRefStartZ
Definition: viewdata.hxx:302
tools::Long GetSize(index_type nIndex) const
Definition: viewdata.cxx:327
bool mbOldCursorValid
Definition: viewdata.hxx:246
#define SC_SIZE_NONE
Definition: viewdata.hxx:31
ScPositionHelper::value_type value_type
Definition: viewdata.hxx:154
ScViewDataTable * pThisTab
Definition: viewdata.hxx:277
tools::Long computePosition(index_type nIndex, const std::function< long(index_type)> &getSizePx)
Definition: viewdata.cxx:259
const SCTAB MAXTAB
Definition: address.hxx:70
SCCOL GetRefEndX() const
Definition: viewdata.hxx:525
MapMode aLogicMode
Definition: viewdata.hxx:288
SCCOL nFillStartX
Definition: viewdata.hxx:306
void GetEndIndexAndPosition(SCCOL &nIndex, tools::Long &nPosition) const
Definition: viewdata.cxx:306
void EnlargeStartBy(tools::Long nOffset)
Definition: viewdata.cxx:405
SCCOL GetRefStartX() const
Definition: viewdata.hxx:522
SCROW nMaxTiledRow
Definition: viewdata.hxx:243
SCCOL GetFixPosX() const
Definition: viewdata.hxx:419
SvxZoomType eZoomType
Definition: viewdata.hxx:210
tools::Long GetPageUpDownOffset() const
Definition: viewdata.hxx:560
SCTAB GetRefStartZ() const
Definition: viewdata.hxx:524
ScHSplitPos
Definition: viewdata.hxx:45
sal_Int32 SCROW
Definition: types.hxx:17
double GetPPTY() const
Definition: viewdata.hxx:468
tools::Long GetLOKDocWidthPixel() const
Definition: viewdata.hxx:406
SfxDispatcher * GetDispatcher()
ScFillMode GetFillMode() const
Definition: viewdata.hxx:506
SCROW nFillEndY
Definition: viewdata.hxx:309
SCCOL GetEditStartCol() const
Definition: viewdata.hxx:595
ScMarkData maMarkData
Definition: viewdata.hxx:276
SCCOL nFillEndX
Definition: viewdata.hxx:308
bool GetShowGrid() const
Definition: viewdata.hxx:462
bool IsGridMode() const
Definition: viewdata.hxx:547
bool IsHeaderMode() const
Definition: viewdata.hxx:550
SCCOL nEditStartCol
Definition: viewdata.hxx:312
ScSplitMode eHSplitMode
Definition: viewdata.hxx:225
OString describeCellCursorInPrintTwips() const
Definition: viewdata.hxx:616
SCROW nRefEndY
Definition: viewdata.hxx:304
SCTAB nRefEndZ
Definition: viewdata.hxx:305
bool IsSelCtrlMouseClick() const
Definition: viewdata.hxx:658
Fraction aDefZoomX
Definition: viewdata.hxx:291
ScRefType
Mouse mode to select areas.
Definition: viewdata.hxx:55
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:544
const value_type & getNearestByPosition(tools::Long nPos) const
Definition: viewdata.cxx:221
SCCOL GetEditEndCol() const
Definition: viewdata.hxx:597
ScSplitPos eWhichActive
Definition: viewdata.hxx:227
bool IsThemedCursor() const
Definition: viewdata.hxx:556
SCROW GetEditViewRow() const
Definition: viewdata.hxx:594
void setLOKVisibleArea(const tools::Rectangle &rArea)
Definition: viewdata.hxx:564
SCROW nPosY[2]
Y position of the top left cell of the visible area.
Definition: viewdata.hxx:241
ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader)
Definition: viewdata.cxx:286
ScPositionHelper & GetLOKWidthHelper()
Definition: viewdata.hxx:409
ScSplitMode
Definition: viewdata.hxx:42
bool IsOutlineMode() const
Definition: viewdata.hxx:555
bool operator()(const value_type &rValue1, const value_type &rValue2) const
Definition: viewdata.cxx:112
Fraction aDefZoomY
Definition: viewdata.hxx:292
const value_type & getNearestByIndex(index_type nIndex) const
Definition: viewdata.cxx:191
SCTAB GetRefTabNo() const
Definition: viewdata.hxx:391
double nPPTY
Definition: viewdata.hxx:273
void SetTabStartCol(SCCOL nNew)
Definition: viewdata.hxx:651
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:357
index_type MAX_INDEX
Definition: viewdata.hxx:135
void SetSyntaxMode(bool bNewMode)
Definition: viewdata.hxx:549
Fraction aZoomX
Definition: viewdata.hxx:211
bool bIsRefMode
Definition: viewdata.hxx:325
void SetHSplitMode(ScSplitMode eMode)
Definition: viewdata.hxx:437
SvxZoomType
ScDocument & mrDoc
Definition: viewdata.hxx:279
ScPositionHelper & GetLOKHeightHelper()
Definition: viewdata.hxx:410
void removeByIndex(index_type nIndex)
Definition: viewdata.cxx:147
SCCOLROW index_type
Definition: viewdata.hxx:122
void SetScenButSize(const Size &rNew)
Definition: viewdata.hxx:656
bool IsPagebreakMode() const
Definition: viewdata.hxx:424
ScSplitPos eEditActivePart
Definition: viewdata.hxx:320
SCCOL nEditCol
Definition: viewdata.hxx:310
void EnlargeBy(tools::Long nOffset)
Definition: viewdata.hxx:184
bool IsRefMode() const
Definition: viewdata.hxx:520
void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &rSettings, ScViewData &rViewData, SCTAB nTab, bool &rHasZoom)
Definition: viewdata.cxx:603
ScFillMode
Definition: viewdata.hxx:33
bool bGrowing
Definition: viewdata.hxx:331
SCCOL nRefEndX
Definition: viewdata.hxx:303
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
ScPositionHelper aWidthHelper
Definition: viewdata.hxx:237
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:416
sal_Int16 SCTAB
Definition: types.hxx:22
tools::Long m_nLOKPageUpDownOffset
Definition: viewdata.hxx:333
SCCOL GetCurX() const
Definition: viewdata.hxx:400
SCROW GetEditStartRow() const
Definition: viewdata.hxx:596
ScFillMode nFillMode
Definition: viewdata.hxx:321
void ForcePageUpDownOffset(tools::Long nTwips)
Force page size for PgUp/PgDown to overwrite the computation based on m_aVisArea. ...
Definition: viewdata.hxx:559
SCROW nEditRow
Definition: viewdata.hxx:311
const index_type MAX_INDEX
Definition: viewdata.hxx:160