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