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