1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <tools/fract.hxx>
22 #include <sfx2/zoomitem.hxx>
23 #include <rangelst.hxx>
25 #include <viewopti.hxx>
29 #include <o3tl/typed_flags_set.hxx>
31 #define SC_SIZE_NONE 65535
42 enum ScSplitMode
{ SC_SPLIT_NONE
= 0, SC_SPLIT_NORMAL
, SC_SPLIT_FIX
, SC_SPLIT_MODE_MAX_ENUM
= SC_SPLIT_FIX
};
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
};
48 inline ScHSplitPos
WhichH( ScSplitPos ePos
);
49 inline ScVSplitPos
WhichV( ScSplitPos ePos
);
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
};
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
};
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. */
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. */
74 SC_MARK_MULTI_FILTERED
= // Multiple selection marks containing filtered rows.
80 enum class ScPasteFlags
82 NONE
= 0, // No flags specified
83 Mode
= 1, // Enable paste-mode
84 Border
= 2, // Show a border around the source cells
87 template<> struct typed_flags
<ScPasteFlags
> : is_typed_flags
<ScPasteFlags
, 0x03> {};
90 // for internal Drag&Drop:
97 template<> struct typed_flags
<ScDragSrc
> : is_typed_flags
<ScDragSrc
, 0x00000003> {};
103 class ScTabViewShell
;
105 class ScEditEngineDefaulter
;
109 namespace vcl
{ class Window
; }
110 class SfxObjectShell
;
114 class ScExtDocOptions
;
118 class ScSizeDeviceProvider
;
120 class ScPositionHelper
123 typedef SCCOLROW index_type
;
124 typedef std::pair
<index_type
, tools::Long
> value_type
;
125 static_assert(std::numeric_limits
<index_type
>::is_signed
, "ScPositionCache: index type is not signed");
128 static const index_type null
= std::numeric_limits
<index_type
>::min();
133 bool operator() (const value_type
& rValue1
, const value_type
& rValue2
) const;
136 index_type MAX_INDEX
;
137 std::set
<value_type
, Comp
> mData
;
140 ScPositionHelper(const ScDocument
*pDoc
, bool bColumn
);
141 void setDocument(const ScDocument
& rDoc
, bool bColumn
);
143 void insert(index_type nIndex
, tools::Long nPos
);
144 void removeByIndex(index_type nIndex
);
145 void invalidateByIndex(index_type nIndex
);
146 void invalidateByPosition(tools::Long nPos
);
147 const value_type
& getNearestByIndex(index_type nIndex
) const;
148 const value_type
& getNearestByPosition(tools::Long nPos
) const;
149 tools::Long
getPosition(index_type nIndex
) const;
150 tools::Long
computePosition(index_type nIndex
, const std::function
<long (index_type
)>& getSizePx
);
153 class ScBoundsProvider
155 typedef ScPositionHelper::value_type value_type
;
156 typedef SCCOLROW index_type
;
160 const bool bColumnHeader
;
161 const index_type MAX_INDEX
;
165 index_type nFirstIndex
;
166 index_type nSecondIndex
;
167 tools::Long nFirstPositionPx
;
168 tools::Long nSecondPositionPx
;
171 ScBoundsProvider(const ScViewData
&rView
, SCTAB nT
, bool bColumnHeader
);
173 void GetStartIndexAndPosition(SCCOL
& nIndex
, tools::Long
& nPosition
) const;
174 void GetEndIndexAndPosition(SCCOL
& nIndex
, tools::Long
& nPosition
) const;
175 void GetStartIndexAndPosition(SCROW
& nIndex
, tools::Long
& nPosition
) const;
176 void GetEndIndexAndPosition(SCROW
& nIndex
, tools::Long
& nPosition
) const;
178 void Compute(value_type aFirstNearest
, value_type aSecondNearest
,
179 tools::Long nFirstBound
, tools::Long nSecondBound
);
181 void EnlargeStartBy(tools::Long nOffset
);
183 void EnlargeEndBy(tools::Long nOffset
);
185 void EnlargeBy(tools::Long nOffset
)
187 EnlargeStartBy(nOffset
);
188 EnlargeEndBy(nOffset
);
192 tools::Long
GetSize(index_type nIndex
) const;
194 void GetIndexAndPos(index_type nNearestIndex
, tools::Long nNearestPosition
,
195 tools::Long nBound
, index_type
& nFoundIndex
, tools::Long
& nPosition
,
196 bool bTowards
, tools::Long nDiff
);
198 void GeIndexBackwards(index_type nNearestIndex
, tools::Long nNearestPosition
,
199 tools::Long nBound
, index_type
& nFoundIndex
, tools::Long
& nPosition
,
202 void GetIndexTowards(index_type nNearestIndex
, tools::Long nNearestPosition
,
203 tools::Long nBound
, index_type
& nFoundIndex
, tools::Long
& nPosition
,
207 class ScViewDataTable
// per-sheet data
209 friend class ScViewData
;
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
217 tools::Long nTPosX
[2]; // MapMode - Offset (Twips)
218 tools::Long nTPosY
[2];
219 tools::Long nMPosX
[2]; // MapMode - Offset (1/100 mm)
220 tools::Long nMPosY
[2];
221 tools::Long nPixPosX
[2]; // Offset in Pixels
222 tools::Long nPixPosY
[2];
223 tools::Long nHSplitPos
;
224 tools::Long nVSplitPos
;
226 ScSplitMode eHSplitMode
;
227 ScSplitMode eVSplitMode
;
228 ScSplitPos eWhichActive
;
230 SCCOL nFixPosX
; // Cell position of the splitter when freeze pane
238 ScPositionHelper aWidthHelper
;
239 ScPositionHelper aHeightHelper
;
241 SCCOL nPosX
[2]; ///< X position of the top left cell of the visible area.
242 SCROW nPosY
[2]; ///< Y position of the top left cell of the visible area.
246 bool bShowGrid
; // per sheet show grid lines option.
247 bool mbOldCursorValid
; // "virtual" Cursor position when combined
248 ScViewDataTable(const ScDocument
*pDoc
= nullptr);
250 void InitData(const ScDocument
& rDoc
);
251 void WriteUserDataSequence(
252 css::uno::Sequence
<css::beans::PropertyValue
>& rSettings
,
253 const ScViewData
& rViewData
, SCTAB nTab
) const;
255 void ReadUserDataSequence(
256 const css::uno::Sequence
<css::beans::PropertyValue
>& rSettings
,
257 ScViewData
& rViewData
, SCTAB nTab
, bool& rHasZoom
);
259 /** Sanitize the active split range value to not point into a grid window
260 that would never be initialized due to non-matching split modes.
262 This is to be done when reading settings from file formats or
263 configurations that could have arbitrary values. The caller is
264 responsible for actually assigning the new value to eWhichActive because
265 we want this function to be const to be able to call the check from
268 [[nodiscard
]] ScSplitPos
SanitizeWhichActive() const;
274 double nPPTX
, nPPTY
; // Scaling factors
276 ::std::vector
<std::unique_ptr
<ScViewDataTable
>> maTabData
;
277 ScMarkData maMarkData
;
278 ScMarkData maHighlightData
;
279 ScViewDataTable
* pThisTab
; // Data of the displayed sheet
280 ScDocShell
* pDocShell
;
282 ScTabViewShell
* pView
;
283 std::unique_ptr
<EditView
> pEditView
[4]; // Belongs to the window
284 ScViewOptions maOptions
;
285 EditView
* pSpellingView
;
290 MapMode aLogicMode
; // skalierter 1/100mm-MapMode
292 SvxZoomType eDefZoomType
; // default zoom and type for missing TabData
295 Fraction aDefPageZoomX
; // zoom in page break preview mode
296 Fraction aDefPageZoomY
;
300 SCTAB nTabNo
; // displayed sheet
301 SCTAB nRefTabNo
; // sheet which contains RefInput
308 SCCOL nFillStartX
; // Fill Cursor
312 SCCOL nEditCol
; // Related position
315 SCCOL nEditEndCol
; // End of Edit View
317 SCCOL nTabStartCol
; // for Enter after Tab
318 ScRange aDelRange
; // for delete AutoFill
320 ScPasteFlags nPasteFlags
;
322 ScSplitPos eEditActivePart
; // the part that was active when edit mode was started
323 ScFillMode nFillMode
;
324 SvxAdjust eEditAdjust
;
325 bool bEditActive
[4] = {}; // Active?
326 bool bActive
:1; // Active Window ?
327 bool bIsRefMode
:1; // Reference input
328 bool bDelMarkValid
:1; // Only valid at SC_REFTYPE_FILL
329 bool bPagebreak
:1; // Page break preview mode
330 bool bSelCtrlMouseClick
:1; // special selection handling for ctrl-mouse-click
332 bool bEditHighlight
:1;
335 sal_Int16 nFormulaBarLines
; // Visible lines in the formula bar
337 tools::Long m_nLOKPageUpDownOffset
;
338 tools::Rectangle maLOKVisibleArea
;///< The visible area in the LibreOfficeKit client.
340 DECL_LINK( EditEngineHdl
, EditStatus
&, void );
344 void CreateTabData( SCTAB nNewTab
);
345 void CreateTabData( std::vector
< SCTAB
>& rvTabs
);
346 void CreateSelectedTabData();
347 void EnsureTabDataSize(size_t nSize
);
348 void UpdateCurrentTab();
349 ScViewDataTable
* FetchTableData(SCTAB
) const;
351 ScViewData(ScDocument
* pDoc
, ScDocShell
* pDocSh
, ScTabViewShell
* pViewSh
);
354 ScViewData( ScDocShell
& rDocSh
, ScTabViewShell
* pViewSh
);
355 ScViewData( ScDocument
& rDoc
);
356 ~ScViewData() COVERITY_NOEXCEPT_FALSE
;
358 ScDocShell
* GetDocShell() const { return pDocShell
; }
359 ScDocFunc
& GetDocFunc() const;
360 SC_DLLPUBLIC ScDBFunc
* GetView() const;
361 ScTabViewShell
* GetViewShell() const { return pView
; }
362 SfxObjectShell
* GetSfxDocShell() const { return pDocShell
; }
363 SfxBindings
& GetBindings(); // from ViewShell's ViewFrame
364 SC_DLLPUBLIC SfxDispatcher
& GetDispatcher(); // from ViewShell's ViewFrame
366 SC_DLLPUBLIC ScMarkData
& GetMarkData();
367 ScMarkData
& GetHighlightData();
368 SC_DLLPUBLIC
const ScMarkData
& GetMarkData() const;
370 weld::Window
* GetDialogParent(); // forwarded from tabvwsh
371 SC_DLLPUBLIC ScGridWindow
* GetActiveWin(); // from View
372 const ScGridWindow
* GetActiveWin() const;
373 SC_DLLPUBLIC ScDrawView
* GetScDrawView(); // from View
374 bool IsMinimized() const; // from View
376 void UpdateInputHandler( bool bForce
= false );
378 void WriteUserData(OUString
& rData
);
379 void ReadUserData(std::u16string_view rData
);
380 SC_DLLPUBLIC
void WriteExtOptions( ScExtDocOptions
& rOpt
) const;
381 void ReadExtOptions( const ScExtDocOptions
& rOpt
);
382 void WriteUserDataSequence(css::uno::Sequence
<css::beans::PropertyValue
>& rSettings
) const;
383 void ReadUserDataSequence(const css::uno::Sequence
<css::beans::PropertyValue
>& rSettings
);
385 ScDocument
& GetDocument() const { return mrDoc
; }
387 bool IsActive() const { return bActive
; }
388 void Activate(bool bActivate
) { bActive
= bActivate
; }
390 void InsertTab( SCTAB nTab
);
391 void InsertTabs( SCTAB nTab
, SCTAB nNewSheets
);
392 void DeleteTab( SCTAB nTab
);
393 void DeleteTabs( SCTAB nTab
, SCTAB nSheets
);
394 void CopyTab( SCTAB nSrcTab
, SCTAB nDestTab
);
395 void MoveTab( SCTAB nSrcTab
, SCTAB nDestTab
);
397 SCTAB
GetRefTabNo() const { return nRefTabNo
; }
398 void SetRefTabNo( SCTAB nNewTab
) { nRefTabNo
= nNewTab
; }
400 SCTAB
GetTabNo() const { return nTabNo
; }
401 SCCOL
MaxCol() const { return mrDoc
.MaxCol(); }
402 SCROW
MaxRow() const { return mrDoc
.MaxRow(); }
403 ScSplitPos
GetActivePart() const { return pThisTab
->eWhichActive
; }
404 SC_DLLPUBLIC SCCOL
GetPosX( ScHSplitPos eWhich
, SCTAB nForTab
= -1 ) const;
405 SC_DLLPUBLIC SCROW
GetPosY( ScVSplitPos eWhich
, SCTAB nForTab
= -1 ) const;
406 SCCOL
GetCurX() const { return pThisTab
->nCurX
; }
407 SCROW
GetCurY() const { return pThisTab
->nCurY
; }
408 SCCOL
GetCurXForTab( SCTAB nTabIndex
) const;
409 SCROW
GetCurYForTab( SCTAB nTabIndex
) const;
410 SCCOL
GetOldCurX() const;
411 SCROW
GetOldCurY() const;
412 tools::Long
GetLOKDocWidthPixel() const { return pThisTab
->aWidthHelper
.getPosition(pThisTab
->nMaxTiledCol
); }
413 tools::Long
GetLOKDocHeightPixel() const { return pThisTab
->aHeightHelper
.getPosition(pThisTab
->nMaxTiledRow
); }
415 ScPositionHelper
& GetLOKWidthHelper() { return pThisTab
->aWidthHelper
; }
416 ScPositionHelper
& GetLOKHeightHelper() { return pThisTab
->aHeightHelper
; }
418 ScPositionHelper
* GetLOKWidthHelper(SCTAB nTabIndex
);
419 ScPositionHelper
* GetLOKHeightHelper(SCTAB nTabIndex
);
421 ScSplitMode
GetHSplitMode() const { return pThisTab
->eHSplitMode
; }
422 ScSplitMode
GetVSplitMode() const { return pThisTab
->eVSplitMode
; }
423 tools::Long
GetHSplitPos() const { return pThisTab
->nHSplitPos
; }
424 tools::Long
GetVSplitPos() const { return pThisTab
->nVSplitPos
; }
425 SCCOL
GetFixPosX() const { return pThisTab
->nFixPosX
; }
426 SCROW
GetFixPosY() const { return pThisTab
->nFixPosY
; }
427 SCCOL
GetMaxTiledCol() const { return pThisTab
->nMaxTiledCol
; }
428 SCROW
GetMaxTiledRow() const { return pThisTab
->nMaxTiledRow
; }
430 bool IsPagebreakMode() const { return bPagebreak
; }
431 bool IsPasteMode() const { return bool(nPasteFlags
& ScPasteFlags::Mode
); }
432 bool ShowPasteSource() const { return bool(nPasteFlags
& ScPasteFlags::Border
); }
434 void SetPosX( ScHSplitPos eWhich
, SCCOL nNewPosX
);
435 void SetPosY( ScVSplitPos eWhich
, SCROW nNewPosY
);
436 void SetCurX( SCCOL nNewCurX
) { pThisTab
->nCurX
= nNewCurX
; }
437 void SetCurY( SCROW nNewCurY
) { pThisTab
->nCurY
= nNewCurY
; }
438 void SetCurXForTab( SCCOL nNewCurX
, SCTAB nTabIndex
);
439 void SetCurYForTab( SCCOL nNewCurY
, SCTAB nTabIndex
);
440 void SetOldCursor( SCCOL nNewX
, SCROW nNewY
);
441 void ResetOldCursor();
443 void SetHSplitMode( ScSplitMode eMode
) { pThisTab
->eHSplitMode
= eMode
; }
444 void SetVSplitMode( ScSplitMode eMode
) { pThisTab
->eVSplitMode
= eMode
; }
445 void SetHSplitPos( tools::Long nPos
) { pThisTab
->nHSplitPos
= nPos
; }
446 void SetVSplitPos( tools::Long nPos
) { pThisTab
->nVSplitPos
= nPos
; }
447 void SetFixPosX( SCCOL nPos
) { pThisTab
->nFixPosX
= nPos
; }
448 void SetFixPosY( SCROW nPos
) { pThisTab
->nFixPosY
= nPos
; }
449 void SetMaxTiledCol( SCCOL nCol
);
450 void SetMaxTiledRow( SCROW nRow
);
452 void SetPagebreakMode( bool bSet
);
453 void SetPasteMode ( ScPasteFlags nFlags
) { nPasteFlags
= nFlags
; }
455 void SetZoomType( SvxZoomType eNew
, bool bAll
);
456 void SetZoomType( SvxZoomType eNew
, std::vector
< SCTAB
>& tabs
);
457 SC_DLLPUBLIC
void SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, std::vector
< SCTAB
>& tabs
);
458 void SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, bool bAll
);
461 void SetSelCtrlMouseClick( bool bTmp
) { bSelCtrlMouseClick
= bTmp
; }
463 SvxZoomType
GetZoomType() const { return pThisTab
->eZoomType
; }
464 const Fraction
& GetZoomX() const { return bPagebreak
? pThisTab
->aPageZoomX
: pThisTab
->aZoomX
; }
465 const Fraction
& GetZoomY() const { return bPagebreak
? pThisTab
->aPageZoomY
: pThisTab
->aZoomY
; }
467 void SetShowGrid( bool bShow
);
468 bool GetShowGrid() const { return pThisTab
->bShowGrid
; }
470 const MapMode
& GetLogicMode( ScSplitPos eWhich
);
471 const MapMode
& GetLogicMode(); // Offset 0
473 double GetPPTX() const { return nPPTX
; }
474 double GetPPTY() const { return nPPTY
; }
476 void SetFormulaBarLines(sal_Int16 nLines
)
478 // Formula bar must be between 1 and 25 lines (see SpreadsheetViewSettings.idl)
479 nLines
= std::max(nLines
, static_cast<sal_Int16
>(1));
480 nLines
= std::min(nLines
, static_cast<sal_Int16
>(25));
481 nFormulaBarLines
= nLines
;
483 sal_Int16
GetFormulaBarLines() const { return nFormulaBarLines
; };
485 SC_DLLPUBLIC ScMarkType
GetSimpleArea( SCCOL
& rStartCol
, SCROW
& rStartRow
, SCTAB
& rStartTab
,
486 SCCOL
& rEndCol
, SCROW
& rEndRow
, SCTAB
& rEndTab
) const;
487 SC_DLLPUBLIC ScMarkType
GetSimpleArea( ScRange
& rRange
) const;
488 /// May modify rNewMark using MarkToSimple().
489 ScMarkType
GetSimpleArea( ScRange
& rRange
, ScMarkData
& rNewMark
) const;
490 void GetMultiArea( ScRangeListRef
& rRange
) const;
492 bool SimpleColMarked();
493 bool SimpleRowMarked();
495 bool IsMultiMarked() const;
497 /** Disallow Paste on Ctrl+A all selected or another high
498 amount of selected cells that is not the same size in
499 one direction as the clipboard source.
502 bool SelectionForbidsPaste( ScDocument
* pClipDoc
= nullptr );
503 bool SelectionForbidsPaste( SCCOL nSrcCols
, SCROW nSrcRows
);
505 /** Disallow cell fill (Fill,Enter,...) on Ctrl+A all
506 selected or another high amount of selected cells.
509 bool SelectionForbidsCellFill();
510 /// Determine DOOM condition, i.e. from selected range.
511 static bool SelectionFillDOOM( const ScRange
& rRange
);
513 void SetFillMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
);
514 void SetDragMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
516 void GetFillData( SCCOL
& rStartCol
, SCROW
& rStartRow
,
517 SCCOL
& rEndCol
, SCROW
& rEndRow
);
518 void ResetFillMode();
519 bool IsAnyFillMode() const { return nFillMode
!= ScFillMode::NONE
; }
520 bool IsFillMode() const { return nFillMode
== ScFillMode::FILL
; }
521 ScFillMode
GetFillMode() const { return nFillMode
; }
523 SvxAdjust
GetEditAdjust() const {return eEditAdjust
; }
524 void SetEditAdjust( SvxAdjust eNewEditAdjust
) { eEditAdjust
= eNewEditAdjust
; }
526 // TRUE: Cell is merged
527 bool GetMergeSizePixel( SCCOL nX
, SCROW nY
, tools::Long
& rSizeXPix
, tools::Long
& rSizeYPix
) const;
528 bool GetMergeSizePrintTwips( SCCOL nX
, SCROW nY
, tools::Long
& rSizeXTwips
, tools::Long
& rSizeYTwips
) const;
529 void GetPosFromPixel( tools::Long nClickX
, tools::Long nClickY
, ScSplitPos eWhich
,
530 SCCOL
& rPosX
, SCROW
& rPosY
,
531 bool bTestMerge
= true, bool bRepair
= false, SCTAB nForTab
= -1 );
532 void GetMouseQuadrant( const Point
& rClickPos
, ScSplitPos eWhich
,
533 SCCOL nPosX
, SCROW nPosY
, bool& rLeft
, bool& rTop
);
535 bool IsRefMode() const { return bIsRefMode
; }
536 ScRefType
GetRefType() const { return eRefType
; }
537 SCCOL
GetRefStartX() const { return nRefStartX
; }
538 SCROW
GetRefStartY() const { return nRefStartY
; }
539 SCTAB
GetRefStartZ() const { return nRefStartZ
; }
540 SCCOL
GetRefEndX() const { return nRefEndX
; }
541 SCROW
GetRefEndY() const { return nRefEndY
; }
542 SCTAB
GetRefEndZ() const { return nRefEndZ
; }
544 void SetRefMode( bool bNewMode
, ScRefType eNewType
)
545 { bIsRefMode
= bNewMode
; eRefType
= eNewType
; }
547 void SetRefStart( SCCOL nNewX
, SCROW nNewY
, SCTAB nNewZ
);
548 void SetRefEnd( SCCOL nNewX
, SCROW nNewY
, SCTAB nNewZ
);
550 void ResetDelMark() { bDelMarkValid
= false; }
551 void SetDelMark( const ScRange
& rRange
)
552 { aDelRange
= rRange
; bDelMarkValid
= true; }
554 bool GetDelMark( ScRange
& rRange
) const
555 { rRange
= aDelRange
; return bDelMarkValid
; }
557 inline void GetMoveCursor( SCCOL
& rCurX
, SCROW
& rCurY
);
559 const ScViewOptions
& GetOptions() const { return maOptions
; }
560 SC_DLLPUBLIC
void SetOptions( const ScViewOptions
& rOpt
);
562 bool IsGridMode () const { return maOptions
.GetOption(VOPT_GRID
); }
563 bool IsSyntaxMode () const { return maOptions
.GetOption(VOPT_SYNTAX
); }
564 void SetSyntaxMode ( bool bNewMode
) { maOptions
.SetOption(VOPT_SYNTAX
, bNewMode
); }
565 bool IsHeaderMode () const { return maOptions
.GetOption(VOPT_HEADER
); }
566 void SetHeaderMode ( bool bNewMode
) { maOptions
.SetOption(VOPT_HEADER
, bNewMode
); }
567 bool IsTabMode () const { return maOptions
.GetOption(VOPT_TABCONTROLS
); }
568 bool IsVScrollMode () const { return maOptions
.GetOption(VOPT_VSCROLL
); }
569 bool IsHScrollMode () const { return maOptions
.GetOption(VOPT_HSCROLL
); }
570 bool IsOutlineMode () const { return maOptions
.GetOption(VOPT_OUTLINER
); }
571 bool IsThemedCursor () const { return maOptions
.GetOption(VOPT_THEMEDCURSOR
); }
573 bool GetEditHighlight() const { return bEditHighlight
; }
574 void SetEditHighlight(bool bNewHighlight
) { bEditHighlight
= bNewHighlight
; }
576 /// Force page size for PgUp/PgDown to overwrite the computation based on m_aVisArea.
577 void ForcePageUpDownOffset(tools::Long nTwips
) { m_nLOKPageUpDownOffset
= nTwips
; }
578 tools::Long
GetPageUpDownOffset() const { return m_nLOKPageUpDownOffset
; }
580 /// The visible area in the client (set by setClientVisibleArea).
581 const tools::Rectangle
& getLOKVisibleArea() const { return maLOKVisibleArea
; }
582 void setLOKVisibleArea(const tools::Rectangle
& rArea
) { maLOKVisibleArea
= rArea
; }
585 void ResetEditView();
586 void SetEditEngine( ScSplitPos eWhich
,
587 ScEditEngineDefaulter
* pNewEngine
,
588 vcl::Window
* pWin
, SCCOL nNewX
, SCROW nNewY
);
589 void GetEditView( ScSplitPos eWhich
, EditView
*& rViewPtr
, SCCOL
& rCol
, SCROW
& rRow
);
590 bool HasEditView( ScSplitPos eWhich
) const
591 { return pEditView
[eWhich
] && bEditActive
[eWhich
]; }
592 EditView
* GetEditView( ScSplitPos eWhich
) const
593 { return pEditView
[eWhich
].get(); }
596 * Extend the output area for the edit engine view in a horizontal
597 * direction as needed.
602 * Extend the output area for the edit engine view in a vertical direction
605 * @param bInitial when true, then the call originates from a brand-new
606 * edit engine instance.
608 void EditGrowY( bool bInitial
= false );
610 ScSplitPos
GetEditActivePart() const { return eEditActivePart
; }
611 SCCOL
GetEditViewCol() const { return nEditCol
; }
612 SCROW
GetEditViewRow() const { return nEditRow
; }
613 SCCOL
GetEditStartCol() const { return nEditStartCol
; }
614 SCROW
GetEditStartRow() const { return nEditRow
; } // never editing above the cell
615 SCCOL
GetEditEndCol() const { return nEditEndCol
; }
616 SCROW
GetEditEndRow() const { return nEditEndRow
; }
618 tools::Rectangle
GetEditArea( ScSplitPos eWhich
, SCCOL nPosX
, SCROW nPosY
, vcl::Window
* pWin
,
619 const ScPatternAttr
* pPattern
, bool bForceToTop
, bool bInPrintTwips
= false );
621 void SetTabNo( SCTAB nNewTab
);
622 void SetActivePart( ScSplitPos eNewActive
);
624 SC_DLLPUBLIC Point
GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScSplitPos eWhich
,
625 bool bAllowNeg
= false, SCTAB nForTab
= -1 ) const;
626 Point
GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScHSplitPos eWhich
) const;
627 Point
GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScVSplitPos eWhich
) const;
628 /// returns the position (top-left corner) of the requested cell in print twips coordinates.
629 SC_DLLPUBLIC Point
GetPrintTwipsPos( SCCOL nCol
, SCROW nRow
) const;
630 Point
GetPrintTwipsPosFromTileTwips(const Point
& rTileTwipsPos
) const;
632 /// return json for our cursor position.
633 OString
describeCellCursor() const { return describeCellCursorAt(GetCurX(), GetCurY()); }
634 OString
describeCellCursorInPrintTwips() const { return describeCellCursorAt(GetCurX(), GetCurY(), false); }
635 OString
describeCellCursorAt( SCCOL nCol
, SCROW nRow
, bool bPixelAligned
= true ) const;
637 SCCOL
CellsAtX( SCCOL nPosX
, SCCOL nDir
, ScHSplitPos eWhichX
, sal_uInt16 nScrSizeY
= SC_SIZE_NONE
) const;
638 SCROW
CellsAtY( SCROW nPosY
, SCROW nDir
, ScVSplitPos eWhichY
, sal_uInt16 nScrSizeX
= SC_SIZE_NONE
) const;
640 SCCOL
VisibleCellsX( ScHSplitPos eWhichX
) const; // Completely visible cell
641 SCROW
VisibleCellsY( ScVSplitPos eWhichY
) const;
642 SCCOL
PrevCellsX( ScHSplitPos eWhichX
) const; // Cells on the preceding page
643 SCROW
PrevCellsY( ScVSplitPos eWhichY
) const;
646 void SetScreen( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
647 void SetScreen( const tools::Rectangle
& rVisArea
);
648 void SetScreenPos( const Point
& rVisAreaStart
);
650 void UpdateScreenZoom( const Fraction
& rNewX
, const Fraction
& rNewY
);
652 const Size
& GetScrSize() const { return aScrSize
; }
655 Point
GetPixPos( ScSplitPos eWhich
) const
656 { return Point( pThisTab
->nPixPosX
[WhichH(eWhich
)],
657 pThisTab
->nPixPosY
[WhichV(eWhich
)] ); }
658 void SetSpellingView( EditView
* pSpView
) { pSpellingView
= pSpView
; }
659 EditView
* GetSpellingView() const { return pSpellingView
; }
661 void UpdateOutlinerFlags( Outliner
& rOutl
) const;
663 Point
GetMousePosPixel();
665 bool UpdateFixX(SCTAB nTab
= MAXTAB
+1);
666 bool UpdateFixY(SCTAB nTab
= MAXTAB
+1);
668 SCCOL
GetTabStartCol() const { return nTabStartCol
; }
669 void SetTabStartCol(SCCOL nNew
) { nTabStartCol
= nNew
; }
671 ScAddress
GetCurPos() const;
673 const Size
& GetScenButSize() const { return aScenButSize
; }
674 void SetScenButSize(const Size
& rNew
) { aScenButSize
= rNew
; }
676 bool IsSelCtrlMouseClick() const { return bSelCtrlMouseClick
; }
678 SCCOLROW
GetLOKSheetFreezeIndex(bool bIsCol
) const;
679 bool SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex
, bool bIsCol
, SCTAB nForTab
= -1);
680 bool RemoveLOKFreeze();
681 void DeriveLOKFreezeAllSheets();
682 void DeriveLOKFreezeIfNeeded(SCTAB nForTab
);
683 void OverrideWithLOKFreeze(ScSplitMode
& eExHSplitMode
, ScSplitMode
& eExVSplitMode
,
684 SCCOL
& nExFixPosX
, SCROW
& nExFixPosY
,
685 tools::Long
& nExHSplitPos
, tools::Long
& nExVSplitPos
, SCTAB nForTab
) const;
687 static inline tools::Long
ToPixel( sal_uInt16 nTwips
, double nFactor
);
689 /** while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row
690 heights converted with nPPTY to rScrY, optimized for row height
691 segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY
694 static void AddPixelsWhile( tools::Long
& rScrY
, tools::Long nEndPixels
,
695 SCROW
& rPosY
, SCROW nEndRow
, double nPPTY
,
696 const ScDocument
* pDoc
, SCTAB nTabNo
);
698 /** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row
699 heights converted with nPPTY to rScrY, optimized for row height
700 segments. Upon return rPosY is the last row evaluated >= nStartRow,
701 rScrY may be > nEndPixels!
703 static void AddPixelsWhileBackward( tools::Long
& rScrY
, tools::Long nEndPixels
,
704 SCROW
& rPosY
, SCROW nStartRow
, double nPPTY
,
705 const ScDocument
* pDoc
, SCTAB nTabNo
);
707 void setupSizeDeviceProviderForColWidth(ScSizeDeviceProvider
& rProv
, Fraction
& rZoomX
, Fraction
& rZoomY
, double& rPPTX
, double &rPPTY
);
710 inline tools::Long
ScViewData::ToPixel( sal_uInt16 nTwips
, double nFactor
)
712 tools::Long nRet
= static_cast<tools::Long
>( nTwips
* nFactor
);
713 if ( !nRet
&& nTwips
)
718 inline void ScViewData::GetMoveCursor( SCCOL
& rCurX
, SCROW
& rCurY
)
732 inline ScHSplitPos
WhichH( ScSplitPos ePos
)
734 return (ePos
==SC_SPLIT_TOPLEFT
|| ePos
==SC_SPLIT_BOTTOMLEFT
) ?
735 SC_SPLIT_LEFT
: SC_SPLIT_RIGHT
;
738 inline ScVSplitPos
WhichV( ScSplitPos ePos
)
740 return (ePos
==SC_SPLIT_TOPLEFT
|| ePos
==SC_SPLIT_TOPRIGHT
) ?
741 SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
;
744 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */