LibreOffice Module sc (master) 1
viewdata.cxx
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
20#include <scitems.hxx>
21#include <editeng/eeitem.hxx>
22#include <o3tl/safeint.hxx>
24#include <o3tl/string_view.hxx>
25#include <sfx2/lokhelper.hxx>
26#include <sfx2/viewfrm.hxx>
28#include <editeng/brushitem.hxx>
29#include <svtools/colorcfg.hxx>
30#include <editeng/editview.hxx>
31#include <editeng/editstat.hxx>
32#include <editeng/outliner.hxx>
33#include <editeng/unolingu.hxx>
35
36#include <vcl/svapp.hxx>
37#include <rtl/math.hxx>
38#include <sal/log.hxx>
39
40#include <viewdata.hxx>
41#include <docoptio.hxx>
42#include <scmod.hxx>
43#include <global.hxx>
44#include <document.hxx>
45#include <drwlayer.hxx>
46#include <attrib.hxx>
47#include <tabview.hxx>
48#include <tabvwsh.hxx>
49#include <docsh.hxx>
50#include <patattr.hxx>
51#include <editutil.hxx>
52#include <scextopt.hxx>
53#include <miscuno.hxx>
54#include <unonames.hxx>
55#include <inputopt.hxx>
56#include <inputhdl.hxx>
57#include <inputwin.hxx>
58#include <viewutil.hxx>
59#include <markdata.hxx>
61#include <gridwin.hxx>
62#include <transobj.hxx>
63#include <clipparam.hxx>
65#include <comphelper/lok.hxx>
67#include <comphelper/string.hxx>
68
69#include <vcl/uitest/logger.hxx>
71
72#include <com/sun/star/container/XNameContainer.hpp>
73#include <com/sun/star/document/NamedPropertyValues.hpp>
74
75using namespace com::sun::star;
76
77#define SC_GROWY_SMALL_EXTRA 100
78#define SC_GROWY_BIG_EXTRA 200
79
80constexpr OUStringLiteral TAG_TABBARWIDTH = u"tw:";
81
82namespace {
83
84void lcl_LOKRemoveWindow(ScTabViewShell* pTabViewShell, ScSplitPos eWhich)
85{
87 {
88 auto lRemoveWindows =
89 [pTabViewShell, eWhich] (ScTabViewShell* pOtherViewShell)
90 { pOtherViewShell->RemoveWindowFromForeignEditView(pTabViewShell, eWhich); };
91
92 SfxLokHelper::forEachOtherView(pTabViewShell, lRemoveWindows);
93 }
94}
95
96} // anonymous namespace
97
98namespace {
99
100void collectUIInformation(std::map<OUString, OUString>&& aParameters, const OUString& rAction)
101{
102 EventDescription aDescription;
103 aDescription.aID = "grid_window";
104 aDescription.aAction = rAction;
105 aDescription.aParameters = std::move(aParameters);
106 aDescription.aParent = "MainWindow";
107 aDescription.aKeyWord = "ScGridWinUIObject";
108
109 UITestLogger::getInstance().logEvent(aDescription);
110}
111}
112
114
115bool ScPositionHelper::Comp::operator() (const value_type& rValue1, const value_type& rValue2) const
116{
117 if (rValue1.first == null || rValue2.first == null)
118 {
119 return rValue1.second < rValue2.second;
120 }
121 else
122 {
123 return rValue1.first < rValue2.first;
124 }
125}
126
128 : MAX_INDEX(bColumn ? (pDoc ? pDoc->MaxCol() : -1) : MAXTILEDROW)
129{
130 mData.insert(std::make_pair(-1, 0));
131}
132
133void ScPositionHelper::setDocument(const ScDocument& rDoc, bool bColumn)
134{
135 MAX_INDEX = bColumn ? rDoc.MaxCol() : MAXTILEDROW;
136}
137
139{
140 if (nIndex < 0) return;
141 SAL_INFO("sc.lok.poshelper", "ScPositionHelper::insert: nIndex: "
142 << nIndex << ", nPos: " << nPos << ", size: " << mData.size());
143 value_type aValue = std::make_pair(nIndex, nPos);
144 mData.erase(aValue);
145 mData.insert(aValue);
146 SAL_INFO("sc.lok.poshelper",
147 "ScPositionHelper::insert: after insert: size: " << mData.size());
148}
149
151{
152 if (nIndex < 0)
153 return;
154 SAL_INFO("sc.lok.poshelper", "ScPositionHelper::remove: nIndex: " << nIndex
155 << ", size: " << mData.size());
156 auto it = mData.find(std::make_pair(nIndex, 0));
157 if (it == mData.end()) return;
158 mData.erase(it);
159 SAL_INFO("sc.lok.poshelper",
160 "ScPositionHelper::remove: after erase: size: " << mData.size());
161}
162
164{
165 SAL_INFO("sc.lok.poshelper", "ScPositionHelper::invalidate: nIndex: " << nIndex);
166 if (nIndex < 0)
167 {
168 mData.clear();
169 mData.insert(std::make_pair(-1, 0));
170 }
171 else
172 {
173 auto it = mData.lower_bound(std::make_pair(nIndex, 0));
174 mData.erase(it, mData.end());
175 }
176}
177
179{
180 SAL_INFO("sc.lok.poshelper", "ScPositionHelper::invalidate: nPos: " << nPos);
181 if (nPos <= 0)
182 {
183 mData.clear();
184 mData.insert(std::make_pair(-1, 0));
185 }
186 else
187 {
188 auto it = mData.lower_bound(std::make_pair(null, nPos));
189 mData.erase(it, mData.end());
190 }
191}
192
195{
196 SAL_INFO("sc.lok.poshelper",
197 "ScPositionHelper::getNearest: nIndex: " << nIndex << ", size: " << mData.size());
198 auto posUB = mData.upper_bound(std::make_pair(nIndex, 0));
199 if (posUB == mData.begin())
200 {
201 return *posUB;
202 }
203
204 auto posLB = std::prev(posUB);
205 // coverity[copy_paste_error : FALSE] - posUB is correct
206 if (posUB == mData.end())
207 {
208 return *posLB;
209 }
210
211 tools::Long nDiffUB = posUB->first - nIndex;
212 tools::Long nDiffLB = posLB->first - nIndex;
213 if (nDiffUB < -nDiffLB)
214 {
215 return *posUB;
216 }
217 else
218 {
219 return *posLB;
220 }
221}
222
225{
226 SAL_INFO("sc.lok.poshelper",
227 "ScPositionHelper::getNearest: nPos: " << nPos << ", size: " << mData.size());
228 auto posUB = mData.upper_bound(std::make_pair(null, nPos));
229
230 if (posUB == mData.begin())
231 {
232 return *posUB;
233 }
234
235 auto posLB = std::prev(posUB);
236 // coverity[copy_paste_error : FALSE] - posUB is correct
237 if (posUB == mData.end())
238 {
239 return *posLB;
240 }
241
242 tools::Long nDiffUB = posUB->second - nPos;
243 tools::Long nDiffLB = posLB->second - nPos;
244
245 if (nDiffUB < -nDiffLB)
246 {
247 return *posUB;
248 }
249 else
250 {
251 return *posLB;
252 }
253}
254
256{
257 auto it = mData.find(std::make_pair(nIndex, 0));
258 if (it == mData.end()) return -1;
259 return it->second;
260}
261
262tools::Long ScPositionHelper::computePosition(index_type nIndex, const std::function<long (index_type)>& getSizePx)
263{
264 assert(MAX_INDEX > 0);
265 if (nIndex < 0) nIndex = 0;
267
268 const auto& rNearest = getNearestByIndex(nIndex);
269 index_type nStartIndex = rNearest.first;
270 tools::Long nTotalPixels = rNearest.second;
271
272 if (nStartIndex < nIndex)
273 {
274 for (index_type nIdx = nStartIndex + 1; nIdx <= nIndex; ++nIdx)
275 {
276 nTotalPixels += getSizePx(nIdx);
277 }
278 }
279 else
280 {
281 for (index_type nIdx = nStartIndex; nIdx > nIndex; --nIdx)
282 {
283 nTotalPixels -= getSizePx(nIdx);
284 }
285 }
286 return nTotalPixels;
287}
288
289ScBoundsProvider::ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColHeader)
290 : rDoc(rView.GetDocument())
291 , nTab(nT)
292 , bColumnHeader(bColHeader)
293 , MAX_INDEX(bColHeader ? rDoc.MaxCol() : MAXTILEDROW)
294 , mfPPTX(rView.GetPPTX())
295 , mfPPTY(rView.GetPPTY())
296 , nFirstIndex(-1)
297 , nSecondIndex(-1)
298 , nFirstPositionPx(-1)
299 , nSecondPositionPx(-1)
300{}
301
303{
304 assert(bColumnHeader);
306 nPosition = nFirstPositionPx;
307}
308
310{
311 assert(bColumnHeader);
313 nPosition = nSecondPositionPx;
314}
315
317{
318 assert(!bColumnHeader);
320 nPosition = nFirstPositionPx;
321}
322
324{
325 assert(!bColumnHeader);
327 nPosition = nSecondPositionPx;
328}
329
331{
332 const sal_uInt16 nSize = bColumnHeader ? rDoc.GetColWidth(nIndex, nTab) : rDoc.GetRowHeight(nIndex, nTab);
334}
335
336void ScBoundsProvider::GetIndexAndPos(index_type nNearestIndex, tools::Long nNearestPosition,
337 tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition,
338 bool bTowards, tools::Long nDiff)
339{
340 if (nDiff > 0) // nBound < nNearestPosition
341 GeIndexBackwards(nNearestIndex, nNearestPosition, nBound,
342 nFoundIndex, nPosition, bTowards);
343 else
344 GetIndexTowards(nNearestIndex, nNearestPosition, nBound,
345 nFoundIndex, nPosition, bTowards);
346}
347
349 value_type aFirstNearest, value_type aSecondNearest,
350 tools::Long nFirstBound, tools::Long nSecondBound)
351{
352 SAL_INFO("sc.lok.header", "BoundsProvider: nFirstBound: " << nFirstBound
353 << ", nSecondBound: " << nSecondBound);
354
355 tools::Long nFirstDiff = aFirstNearest.second - nFirstBound;
356 tools::Long nSecondDiff = aSecondNearest.second - nSecondBound;
357 SAL_INFO("sc.lok.header", "BoundsProvider: rTopNearest: index: " << aFirstNearest.first
358 << ", pos: " << aFirstNearest.second << ", diff: " << nFirstDiff);
359 SAL_INFO("sc.lok.header", "BoundsProvider: rBottomNearest: index: " << aSecondNearest.first
360 << ", pos: " << aSecondNearest.second << ", diff: " << nSecondDiff);
361
362 bool bReverse = (std::abs(nFirstDiff) >= std::abs(nSecondDiff));
363
364 if(bReverse)
365 {
366 std::swap(aFirstNearest, aSecondNearest);
367 std::swap(nFirstBound, nSecondBound);
368 std::swap(nFirstDiff, nSecondDiff);
369 }
370
371 index_type nNearestIndex = aFirstNearest.first;
372 tools::Long nNearestPosition = aFirstNearest.second;
373 SAL_INFO("sc.lok.header", "BoundsProvider: nearest to first bound: nNearestIndex: "
374 << nNearestIndex << ", nNearestPosition: " << nNearestPosition);
375
376 GetIndexAndPos(nNearestIndex, nNearestPosition, nFirstBound,
377 nFirstIndex, nFirstPositionPx, !bReverse, nFirstDiff);
378 SAL_INFO("sc.lok.header", "BoundsProvider: nFirstIndex: " << nFirstIndex
379 << ", nFirstPositionPx: " << nFirstPositionPx);
380
381 if (std::abs(nSecondDiff) < std::abs(nSecondBound - nFirstPositionPx))
382 {
383 nNearestIndex = aSecondNearest.first;
384 nNearestPosition = aSecondNearest.second;
385 }
386 else
387 {
388 nNearestPosition = nFirstPositionPx;
389 nNearestIndex = nFirstIndex;
390 nSecondDiff = !bReverse ? -1 : 1;
391 }
392 SAL_INFO("sc.lok.header", "BoundsProvider: nearest to second bound: nNearestIndex: "
393 << nNearestIndex << ", nNearestPosition: " << nNearestPosition
394 << ", diff: " << nSecondDiff);
395
396 GetIndexAndPos(nNearestIndex, nNearestPosition, nSecondBound,
397 nSecondIndex, nSecondPositionPx, bReverse, nSecondDiff);
398 SAL_INFO("sc.lok.header", "BoundsProvider: nSecondIndex: " << nSecondIndex
399 << ", nSecondPositionPx: " << nSecondPositionPx);
400
401 if (bReverse)
402 {
403 std::swap(nFirstIndex, nSecondIndex);
405 }
406}
407
409{
410 const index_type nNewFirstIndex =
411 std::max(static_cast<index_type>(-1),
412 static_cast<index_type>(nFirstIndex - nOffset));
413 for (index_type nIndex = nFirstIndex; nIndex > nNewFirstIndex; --nIndex)
414 {
415 const tools::Long nSizePx = GetSize(nIndex);
416 nFirstPositionPx -= nSizePx;
417 }
418 nFirstIndex = nNewFirstIndex;
419 SAL_INFO("sc.lok.header", "BoundsProvider: added offset: nFirstIndex: " << nFirstIndex
420 << ", nFirstPositionPx: " << nFirstPositionPx);
421}
422
424{
425 const index_type nNewSecondIndex = std::min(MAX_INDEX, static_cast<index_type>(nSecondIndex + nOffset));
426 for (index_type nIndex = nSecondIndex + 1; nIndex <= nNewSecondIndex; ++nIndex)
427 {
428 const tools::Long nSizePx = GetSize(nIndex);
429 nSecondPositionPx += nSizePx;
430 }
431 nSecondIndex = nNewSecondIndex;
432 SAL_INFO("sc.lok.header", "BoundsProvider: added offset: nSecondIndex: " << nSecondIndex
433 << ", nSecondPositionPx: " << nSecondPositionPx);
434}
435
437 index_type nNearestIndex, tools::Long nNearestPosition,
438 tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition, bool bTowards)
439{
440 nFoundIndex = -1;
441 for (index_type nIndex = nNearestIndex; nIndex >= 0; --nIndex)
442 {
443 if (nBound >= nNearestPosition)
444 {
445 nFoundIndex = nIndex; // last index whose nPosition is less than nBound
446 nPosition = nNearestPosition;
447 break;
448 }
449
450 const tools::Long nSizePx = GetSize(nIndex);
451 nNearestPosition -= nSizePx;
452 }
453 if (!bTowards && nFoundIndex != -1)
454 {
455 nFoundIndex += 1;
456 nPosition += GetSize(nFoundIndex);
457 }
458}
459
461 index_type nNearestIndex, tools::Long nNearestPosition,
462 tools::Long nBound, index_type& nFoundIndex, tools::Long& nPosition, bool bTowards)
463{
464 nFoundIndex = -2;
465 for (index_type nIndex = nNearestIndex + 1; nIndex <= MAX_INDEX; ++nIndex)
466 {
467 const tools::Long nSizePx = GetSize(nIndex);
468 nNearestPosition += nSizePx;
469
470 if (nNearestPosition > nBound)
471 {
472 nFoundIndex = nIndex; // first index whose nPosition is greater than nBound
473 nPosition = nNearestPosition;
474 break;
475 }
476 }
477 if (nFoundIndex == -2)
478 {
479 nFoundIndex = MAX_INDEX;
480 nPosition = nNearestPosition;
481 }
482 else if (bTowards)
483 {
484 nPosition -= GetSize(nFoundIndex);
485 nFoundIndex -= 1;
486 }
487}
488
490 eZoomType( SvxZoomType::PERCENT ),
491 aZoomX( 1,1 ),
492 aZoomY( 1,1 ),
493 aPageZoomX( 3,5 ), // Page-Default: 60%
494 aPageZoomY( 3,5 ),
495 nHSplitPos( 0 ),
496 nVSplitPos( 0 ),
497 eHSplitMode( SC_SPLIT_NONE ),
498 eVSplitMode( SC_SPLIT_NONE ),
499 eWhichActive( SC_SPLIT_BOTTOMLEFT ),
500 nFixPosX( 0 ),
501 nFixPosY( 0 ),
502 nCurX( 0 ),
503 nCurY( 0 ),
504 nOldCurX( 0 ),
505 nOldCurY( 0 ),
506 aWidthHelper(pDoc, true),
507 aHeightHelper(pDoc, false),
508 nMaxTiledCol( 20 ),
509 nMaxTiledRow( 50 ),
510 bShowGrid( true ),
511 mbOldCursorValid( false )
512{
513 nPosX[0]=nPosX[1]=0;
514 nPosY[0]=nPosY[1]=0;
515 nTPosX[0]=nTPosX[1]=0;
516 nTPosY[0]=nTPosY[1]=0;
517 nMPosX[0]=nMPosX[1]=0;
518 nMPosY[0]=nMPosY[1]=0;
519 nPixPosX[0]=nPixPosX[1]=0;
520 nPixPosY[0]=nPixPosY[1]=0;
521}
522
524{
525 aWidthHelper.setDocument(rDoc, true);
526 aHeightHelper.setDocument(rDoc, false);
527}
528
529void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& rViewData, SCTAB nTab) const
530{
531 rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
532 beans::PropertyValue* pSettings = rSettings.getArray();
533
534 ScSplitMode eExHSplitMode = eHSplitMode;
535 ScSplitMode eExVSplitMode = eVSplitMode;
536 SCCOL nExFixPosX = nFixPosX;
537 SCROW nExFixPosY = nFixPosY;
538 tools::Long nExHSplitPos = nHSplitPos;
539 tools::Long nExVSplitPos = nVSplitPos;
540
542 {
543 rViewData.OverrideWithLOKFreeze(eExHSplitMode, eExVSplitMode,
544 nExFixPosX, nExFixPosY,
545 nExHSplitPos, nExVSplitPos, nTab);
546 }
547
548 pSettings[SC_CURSOR_X].Name = SC_CURSORPOSITIONX;
549 pSettings[SC_CURSOR_X].Value <<= sal_Int32(nCurX);
550 pSettings[SC_CURSOR_Y].Name = SC_CURSORPOSITIONY;
551 pSettings[SC_CURSOR_Y].Value <<= sal_Int32(nCurY);
552
553 // Write freezepan data only when freeze pans are set
554 if(nExFixPosX != 0 || nExFixPosY != 0 || nExHSplitPos != 0 || nExVSplitPos != 0)
555 {
557 pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eExHSplitMode);
559 pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eExVSplitMode);
561 if (eExHSplitMode == SC_SPLIT_FIX)
562 pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nExFixPosX);
563 else
564 pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nExHSplitPos);
566 if (eExVSplitMode == SC_SPLIT_FIX)
567 pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nExFixPosY);
568 else
569 pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nExVSplitPos);
570 }
571
572 // Prevent writing odd settings that would make crash versions that
573 // don't apply SanitizeWhichActive() when reading the settings.
574 // See tdf#117093
575 const ScSplitPos eActiveSplitRange = SanitizeWhichActive();
576 // And point out to give us a chance to inspect weird things (if anyone
577 // remembers what s/he did).
578 assert(eWhichActive == eActiveSplitRange);
580 pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eActiveSplitRange);
581 pSettings[SC_POSITION_LEFT].Name = SC_POSITIONLEFT;
582 pSettings[SC_POSITION_LEFT].Value <<= sal_Int32(nPosX[SC_SPLIT_LEFT]);
583 pSettings[SC_POSITION_RIGHT].Name = SC_POSITIONRIGHT;
584 pSettings[SC_POSITION_RIGHT].Value <<= sal_Int32(nPosX[SC_SPLIT_RIGHT]);
585 pSettings[SC_POSITION_TOP].Name = SC_POSITIONTOP;
586 pSettings[SC_POSITION_TOP].Value <<= sal_Int32(nPosY[SC_SPLIT_TOP]);
587 pSettings[SC_POSITION_BOTTOM].Name = SC_POSITIONBOTTOM;
588 pSettings[SC_POSITION_BOTTOM].Value <<= sal_Int32(nPosY[SC_SPLIT_BOTTOM]);
589
590 sal_Int32 nZoomValue = tools::Long(aZoomY * 100);
591 sal_Int32 nPageZoomValue = tools::Long(aPageZoomY * 100);
592 pSettings[SC_TABLE_ZOOM_TYPE].Name = SC_ZOOMTYPE;
593 pSettings[SC_TABLE_ZOOM_TYPE].Value <<= sal_Int16(eZoomType);
594 pSettings[SC_TABLE_ZOOM_VALUE].Name = SC_ZOOMVALUE;
595 pSettings[SC_TABLE_ZOOM_VALUE].Value <<= nZoomValue;
597 pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
598
599 pSettings[SC_TABLE_SHOWGRID].Name = SC_UNO_SHOWGRID;
600 pSettings[SC_TABLE_SHOWGRID].Value <<= bShowGrid;
601
602 // Common SdrModel processing
603 rViewData.GetDocument().GetDrawLayer()->WriteUserDataSequence(rSettings);
604}
605
606void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& aSettings, ScViewData& rViewData, SCTAB nTab, bool& rHasZoom )
607{
608 rHasZoom = false;
609
610 sal_Int32 nTemp32(0);
611 sal_Int16 nTemp16(0);
612 sal_Int32 nTempPosV(0);
613 sal_Int32 nTempPosH(0);
614 sal_Int32 nTempPosVTw(0);
615 sal_Int32 nTempPosHTw(0);
616 bool bHasVSplitInTwips = false;
617 bool bHasHSplitInTwips = false;
618 for (const auto& rSetting : aSettings)
619 {
620 OUString sName(rSetting.Name);
622 {
623 rSetting.Value >>= nTemp32;
624 nCurX = rViewData.GetDocument().SanitizeCol( static_cast<SCCOL>(nTemp32));
625 }
626 else if (sName == SC_CURSORPOSITIONY)
627 {
628 rSetting.Value >>= nTemp32;
629 nCurY = rViewData.GetDocument().SanitizeRow( static_cast<SCROW>(nTemp32));
630 }
631 else if (sName == SC_HORIZONTALSPLITMODE)
632 {
633 if ((rSetting.Value >>= nTemp16) && nTemp16 <= ScSplitMode::SC_SPLIT_MODE_MAX_ENUM)
634 eHSplitMode = static_cast<ScSplitMode>(nTemp16);
635 }
636 else if (sName == SC_VERTICALSPLITMODE)
637 {
638 if ((rSetting.Value >>= nTemp16) && nTemp16 <= ScSplitMode::SC_SPLIT_MODE_MAX_ENUM)
639 eVSplitMode = static_cast<ScSplitMode>(nTemp16);
640 }
642 {
643 rSetting.Value >>= nTempPosH;
644 bHasHSplitInTwips = false;
645 }
647 {
648 rSetting.Value >>= nTempPosV;
649 bHasVSplitInTwips = false;
650 }
652 {
653 rSetting.Value >>= nTempPosHTw;
654 bHasHSplitInTwips = true;
655 }
657 {
658 rSetting.Value >>= nTempPosVTw;
659 bHasVSplitInTwips = true;
660 }
661 else if (sName == SC_ACTIVESPLITRANGE)
662 {
663 if ((rSetting.Value >>= nTemp16) && nTemp16 <= ScSplitPos::SC_SPLIT_POS_MAX_ENUM)
664 eWhichActive = static_cast<ScSplitPos>(nTemp16);
665 }
666 else if (sName == SC_POSITIONLEFT)
667 {
668 rSetting.Value >>= nTemp32;
669 nPosX[SC_SPLIT_LEFT] = rViewData.GetDocument().SanitizeCol( static_cast<SCCOL>(nTemp32));
670 }
671 else if (sName == SC_POSITIONRIGHT)
672 {
673 rSetting.Value >>= nTemp32;
674 nPosX[SC_SPLIT_RIGHT] = rViewData.GetDocument().SanitizeCol( static_cast<SCCOL>(nTemp32));
675 }
676 else if (sName == SC_POSITIONTOP)
677 {
678 rSetting.Value >>= nTemp32;
679 nPosY[SC_SPLIT_TOP] = rViewData.GetDocument().SanitizeRow( static_cast<SCROW>(nTemp32));
680 }
681 else if (sName == SC_POSITIONBOTTOM)
682 {
683 rSetting.Value >>= nTemp32;
684 nPosY[SC_SPLIT_BOTTOM] = rViewData.GetDocument().SanitizeRow( static_cast<SCROW>(nTemp32));
685 }
686 else if (sName == SC_ZOOMTYPE)
687 {
688 rSetting.Value >>= nTemp16;
689 eZoomType = SvxZoomType(nTemp16);
690 rHasZoom = true; // set if there is any zoom information
691 }
692 else if (sName == SC_ZOOMVALUE)
693 {
694 rSetting.Value >>= nTemp32;
695 Fraction aZoom(nTemp32, 100);
696 aZoomX = aZoomY = aZoom;
697 rHasZoom = true;
698 }
699 else if (sName == SC_PAGEVIEWZOOMVALUE)
700 {
701 rSetting.Value >>= nTemp32;
702 Fraction aZoom(nTemp32, 100);
703 aPageZoomX = aPageZoomY = aZoom;
704 rHasZoom = true;
705 }
706 else if (sName == SC_UNO_SHOWGRID)
707 {
708 rSetting.Value >>= bShowGrid;
709 }
710 else if (sName == SC_TABLESELECTED)
711 {
712 bool bSelected = false;
713 rSetting.Value >>= bSelected;
714 rViewData.GetMarkData().SelectTable( nTab, bSelected );
715 }
716 else if (sName == SC_UNONAME_TABCOLOR)
717 {
718 // There are documents out there that have their tab color defined as a view setting.
719 Color aColor = COL_AUTO;
720 rSetting.Value >>= aColor;
721 if (aColor != COL_AUTO)
722 {
723 ScDocument& rDoc = rViewData.GetDocument();
724 rDoc.SetTabBgColor(nTab, aColor);
725 }
726 }
727 // Fallback to common SdrModel processing
728 else rViewData.GetDocument().GetDrawLayer()->ReadUserDataSequenceValue(&rSetting);
729 }
730
732 nFixPosX = rViewData.GetDocument().SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
733 else
734 nHSplitPos = bHasHSplitInTwips ? static_cast< tools::Long >( nTempPosHTw * rViewData.GetPPTX() ) : nTempPosH;
735
737 nFixPosY = rViewData.GetDocument().SanitizeRow( static_cast<SCROW>( bHasVSplitInTwips ? nTempPosVTw : nTempPosV ));
738 else
739 nVSplitPos = bHasVSplitInTwips ? static_cast< tools::Long >( nTempPosVTw * rViewData.GetPPTY() ) : nTempPosV;
740
742}
743
745{
748 {
749 SAL_WARN("sc.ui","ScViewDataTable::SanitizeWhichActive - bad eWhichActive " << eWhichActive);
750 // The default always initialized grid window is SC_SPLIT_BOTTOMLEFT.
751 return SC_SPLIT_BOTTOMLEFT;
752 }
753 return eWhichActive;
754}
755
757 : ScViewData(nullptr, &rDocSh, pViewSh)
758{
759}
760
762 : ScViewData(&rDoc, nullptr, nullptr)
763{
764}
765
767{
768 ScViewOptions aOptions;
769 aOptions.SetOption(VOPT_GRID, true);
770 aOptions.SetOption(VOPT_SYNTAX, false);
771 aOptions.SetOption(VOPT_HEADER, true);
772 aOptions.SetOption(VOPT_TABCONTROLS, true);
773 aOptions.SetOption(VOPT_VSCROLL, true);
774 aOptions.SetOption(VOPT_HSCROLL, true);
775 aOptions.SetOption(VOPT_OUTLINER, true);
776 return aOptions;
777}
778
779// Either pDoc or pDocSh must be valid
781 nPPTX(0.0),
782 nPPTY(0.0),
783 maMarkData (pDocSh ? pDocSh->GetDocument().GetSheetLimits() : pDoc->GetSheetLimits()),
784 pDocShell ( pDocSh ),
785 mrDoc (pDocSh ? pDocSh->GetDocument() : *pDoc),
786 pView ( pViewSh ),
787 maOptions (pDocSh ? pDocSh->GetDocument().GetViewOptions() : DefaultOptions()),
788 pSpellingView ( nullptr ),
789 aLogicMode ( MapUnit::Map100thMM ),
790 eDefZoomType( SvxZoomType::PERCENT ),
791 aDefZoomX ( 1,1 ),
792 aDefZoomY ( 1,1 ),
793 aDefPageZoomX( 3,5 ),
794 aDefPageZoomY( 3,5 ),
795 eRefType ( SC_REFTYPE_NONE ),
796 nTabNo ( 0 ),
797 nRefTabNo ( 0 ),
798 nRefStartX(0),
799 nRefStartY(0),
800 nRefStartZ(0),
801 nRefEndX(0),
802 nRefEndY(0),
803 nRefEndZ(0),
804 nFillStartX(0),
805 nFillStartY(0),
806 nFillEndX(0),
807 nFillEndY(0),
808 nPasteFlags ( ScPasteFlags::NONE ),
809 eEditActivePart( SC_SPLIT_BOTTOMLEFT ),
810 nFillMode ( ScFillMode::NONE ),
811 eEditAdjust ( SvxAdjust::Left ),
812 bActive ( true ), // how to initialize?
813 bIsRefMode ( false ),
814 bDelMarkValid( false ),
815 bPagebreak ( false ),
816 bSelCtrlMouseClick( false ),
817 bMoveArea ( false ),
818 bGrowing (false),
819 nFormulaBarLines(1),
820 m_nLOKPageUpDownOffset( 0 )
821{
822 assert(bool(pDoc) != bool(pDocSh)); // either one or the other, not both
823 maMarkData.SelectOneTable(0); // Sync with nTabNo
824
828 maTabData.emplace_back( new ScViewDataTable(nullptr) );
829 pThisTab = maTabData[nTabNo].get();
830
832 nEditEndRow = nEditRow = 0;
834
835 // don't show hidden tables
836 if (!mrDoc.IsVisible(nTabNo))
837 {
838 while (!mrDoc.IsVisible(nTabNo) && mrDoc.HasTable(nTabNo + 1))
839 {
840 ++nTabNo;
841 maTabData.emplace_back(nullptr);
842 }
843 maTabData[nTabNo].reset( new ScViewDataTable(nullptr) );
844 pThisTab = maTabData[nTabNo].get();
845 }
846
847 SCTAB nTableCount = mrDoc.GetTableCount();
848 EnsureTabDataSize(nTableCount);
849
850 for (auto& xTabData : maTabData)
851 {
852 if (xTabData)
853 xTabData->InitData(mrDoc);
854 }
855
856 CalcPPT();
857}
858
859ScViewData::~ScViewData() COVERITY_NOEXCEPT_FALSE
860{
861 KillEditView();
862}
863
865
867{
868 assert(0 <= nTabNo && o3tl::make_unsigned(nTabNo) < maTabData.size());
869 pThisTab = maTabData[nTabNo].get();
870 while (!pThisTab)
871 {
872 if (nTabNo > 0)
873 pThisTab = maTabData[--nTabNo].get();
874 else
875 {
876 maTabData[0].reset(new ScViewDataTable(&mrDoc));
877 pThisTab = maTabData[0].get();
878 }
879 }
880}
881
883{
884 if( nTab >= static_cast<SCTAB>(maTabData.size()))
885 maTabData.resize(nTab+1);
886 else
887 maTabData.insert( maTabData.begin() + nTab, nullptr );
888 CreateTabData( nTab );
889
891 maMarkData.InsertTab(nTab);
892
893 collectUIInformation({{}}, "InsertTab");
894}
895
896void ScViewData::InsertTabs( SCTAB nTab, SCTAB nNewSheets )
897{
898 if (nTab >= static_cast<SCTAB>(maTabData.size()))
899 maTabData.resize(nTab+nNewSheets);
900 else
901 {
902 // insert nNewSheets new tables at position nTab
903 auto prevSize = maTabData.size();
904 maTabData.resize(prevSize + nNewSheets);
905 std::move_backward(maTabData.begin() + nTab, maTabData.begin() + prevSize, maTabData.end());
906 }
907 for (SCTAB i = nTab; i < nTab + nNewSheets; ++i)
908 {
909 CreateTabData( i );
911 }
913}
914
916{
917 assert(nTab < static_cast<SCTAB>(maTabData.size()));
918 maTabData.erase(maTabData.begin() + nTab);
919
920 if (o3tl::make_unsigned(nTabNo) >= maTabData.size())
921 {
923 nTabNo = maTabData.size() - 1;
924 }
926 maMarkData.DeleteTab(nTab);
927}
928
929void ScViewData::DeleteTabs( SCTAB nTab, SCTAB nSheets )
930{
931 for (SCTAB i = 0; i < nSheets; ++i)
932 {
933 maMarkData.DeleteTab(nTab + i);
934 }
935 maTabData.erase(maTabData.begin() + nTab, maTabData.begin()+ nTab+nSheets);
936 if (o3tl::make_unsigned(nTabNo) >= maTabData.size())
937 {
939 nTabNo = maTabData.size() - 1;
940 }
942}
943
944void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
945{
946 if (nDestTab==SC_TAB_APPEND)
947 nDestTab = mrDoc.GetTableCount() - 1; // something had to have been copied
948
949 if (nDestTab > MAXTAB)
950 {
951 OSL_FAIL("too many sheets");
952 return;
953 }
954
955 if (nSrcTab >= static_cast<SCTAB>(maTabData.size()))
956 OSL_FAIL("pTabData out of bounds, FIX IT");
957
958 EnsureTabDataSize(nDestTab + 1);
959
960 if ( maTabData[nSrcTab] )
961 maTabData.emplace(maTabData.begin() + nDestTab, new ScViewDataTable( *maTabData[nSrcTab] ));
962 else
963 maTabData.insert(maTabData.begin() + nDestTab, nullptr);
964
966 maMarkData.InsertTab(nDestTab);
967}
968
969void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab )
970{
971 if (nDestTab==SC_TAB_APPEND)
972 nDestTab = mrDoc.GetTableCount() - 1;
973 std::unique_ptr<ScViewDataTable> pTab;
974 if (nSrcTab < static_cast<SCTAB>(maTabData.size()))
975 {
976 pTab = std::move(maTabData[nSrcTab]);
977 maTabData.erase( maTabData.begin() + nSrcTab );
978 }
979
980 if (nDestTab < static_cast<SCTAB>(maTabData.size()))
981 maTabData.insert( maTabData.begin() + nDestTab, std::move(pTab) );
982 else
983 {
984 EnsureTabDataSize(nDestTab + 1);
985 maTabData[nDestTab] = std::move(pTab);
986 }
987
989 maMarkData.DeleteTab(nSrcTab);
990 maMarkData.InsertTab(nDestTab); // adapted if needed
991}
992
993void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs )
994{
995 for ( const auto& rTab : rvTabs )
996 CreateTabData(rTab);
997}
998
999void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs )
1000{
1001 bool bAll = tabs.empty();
1002
1003 if ( !bAll ) // create associated table data
1004 CreateTabData( tabs );
1005
1006 if ( bAll )
1007 {
1008 for ( auto & i: maTabData )
1009 {
1010 if ( i )
1011 i->eZoomType = eNew;
1012 }
1013 eDefZoomType = eNew;
1014 }
1015 else
1016 {
1017 for ( const SCTAB& i : tabs )
1018 {
1019 if ( i < static_cast<SCTAB>(maTabData.size()) && maTabData[i] )
1020 maTabData[i]->eZoomType = eNew;
1021 }
1022 }
1023}
1024
1026{
1027 std::vector< SCTAB > vTabs; // Empty for all tabs
1028 if ( !bAll ) // get selected tabs
1029 {
1031 vTabs.insert(vTabs.begin(), itr, itrEnd);
1032 }
1033 SetZoomType( eNew, vTabs );
1034}
1035
1036void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs )
1037{
1038 bool bAll = tabs.empty();
1039 if ( !bAll ) // create associated table data
1040 CreateTabData( tabs );
1041
1042 // sanity check - we shouldn't need something this low / big
1043 SAL_WARN_IF(rNewX < Fraction(1, 100) || rNewX > Fraction(100, 1), "sc.viewdata",
1044 "fraction rNewX not sensible: " << static_cast<double>(rNewX));
1045 SAL_WARN_IF(rNewY < Fraction(1, 100) || rNewY > Fraction(100, 1), "sc.viewdata",
1046 "fraction rNewY not sensible: " << static_cast<double>(rNewY));
1047
1048 if ( bAll )
1049 {
1050 for ( auto & i: maTabData )
1051 {
1052 if ( i )
1053 {
1054 if ( bPagebreak )
1055 {
1056 i->aPageZoomX = rNewX;
1057 i->aPageZoomY = rNewY;
1058 }
1059 else
1060 {
1061 i->aZoomX = rNewX;
1062 i->aZoomY = rNewY;
1063 }
1064 }
1065 }
1066 if ( bPagebreak )
1067 {
1068 aDefPageZoomX = rNewX;
1069 aDefPageZoomY = rNewY;
1070 }
1071 else
1072 {
1073 aDefZoomX = rNewX;
1074 aDefZoomY = rNewY;
1075 }
1076 }
1077 else
1078 {
1079 for ( const SCTAB& i : tabs )
1080 {
1081 if ( i < static_cast<SCTAB>(maTabData.size()) && maTabData[i] )
1082 {
1083 if ( bPagebreak )
1084 {
1085 maTabData[i]->aPageZoomX = rNewX;
1086 maTabData[i]->aPageZoomY = rNewY;
1087 }
1088 else
1089 {
1090 maTabData[i]->aZoomX = rNewX;
1091 maTabData[i]->aZoomY = rNewY;
1092 }
1093 }
1094 }
1095 }
1096 RefreshZoom();
1097}
1098
1099void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll )
1100{
1101 std::vector< SCTAB > vTabs;
1102 if ( !bAll ) // get selected tabs
1103 {
1105 vTabs.insert(vTabs.begin(), itr, itrEnd);
1106 }
1107 SetZoom( rNewX, rNewY, vTabs );
1108}
1109
1110void ScViewData::SetShowGrid( bool bShow )
1111{
1113 maTabData[nTabNo]->bShowGrid = bShow;
1114}
1115
1117{
1118 // recalculate zoom-dependent values (only for current sheet)
1119
1120 CalcPPT();
1121 RecalcPixPos();
1122 aScenButSize = Size(0,0);
1125}
1126
1128{
1129 bPagebreak = bSet;
1130
1131 RefreshZoom();
1132}
1133
1135{
1136 ScMarkType eMarkType = SC_MARK_NONE;
1137
1138 if ( rNewMark.IsMarked() || rNewMark.IsMultiMarked() )
1139 {
1140 if ( rNewMark.IsMultiMarked() )
1141 rNewMark.MarkToSimple();
1142
1143 if ( rNewMark.IsMarked() && !rNewMark.IsMultiMarked() )
1144 {
1145 rRange = rNewMark.GetMarkArea();
1146 if (ScViewUtil::HasFiltered(rRange, GetDocument()))
1147 eMarkType = SC_MARK_SIMPLE_FILTERED;
1148 else
1149 eMarkType = SC_MARK_SIMPLE;
1150 }
1151 else
1152 eMarkType = SC_MARK_MULTI;
1153 }
1154 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1155 {
1156 if (eMarkType == SC_MARK_NONE)
1157 eMarkType = SC_MARK_SIMPLE;
1158 const ScPatternAttr* pMarkPattern = mrDoc.GetPattern(GetCurX(), GetCurY(), GetTabNo());
1159 if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false) == SfxItemState::SET)
1160 {
1161 SCROW nRow = pMarkPattern->GetItem(ATTR_MERGE).GetRowMerge();
1162 SCCOL nCol = pMarkPattern->GetItem(ATTR_MERGE).GetColMerge();
1163 if ( nRow < 1 || nCol < 1 )
1164 {
1165 // This kind of cells do exist. Not sure if that is intended or a bug.
1166 rRange = ScRange(GetCurX(), GetCurY(), GetTabNo());
1167 }
1168 else
1169 {
1170 rRange = ScRange(GetCurX(), GetCurY(), GetTabNo(),
1171 GetCurX() + nCol - 1, GetCurY() + nRow - 1, GetTabNo());
1172 if ( ScViewUtil::HasFiltered(rRange, GetDocument()) )
1173 eMarkType = SC_MARK_SIMPLE_FILTERED;
1174 }
1175 }
1176 else
1177 rRange = ScRange(GetCurX(), GetCurY(), GetTabNo());
1178 }
1179 return eMarkType;
1180}
1181
1182ScMarkType ScViewData::GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
1183 SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const
1184{
1185 // parameter bMergeMark is no longer needed: The view's selection is never modified
1186 // (a local copy is used), and a multi selection that adds to a single range can always
1187 // be treated like a single selection (GetSimpleArea isn't used in selection
1188 // handling itself)
1189
1190 ScRange aRange;
1191 ScMarkData aNewMark(maMarkData); // use a local copy for MarkToSimple
1192 ScMarkType eMarkType = GetSimpleArea( aRange, aNewMark);
1193 aRange.GetVars( rStartCol, rStartRow, rStartTab, rEndCol, rEndRow, rEndTab);
1194 return eMarkType;
1195}
1196
1198{
1199 // parameter bMergeMark is no longer needed, see above
1200
1201 ScMarkData aNewMark(maMarkData); // use a local copy for MarkToSimple
1202 return GetSimpleArea( rRange, aNewMark);
1203}
1204
1206{
1207 // parameter bMergeMark is no longer needed, see GetSimpleArea
1208
1209 ScMarkData aNewMark(maMarkData); // use a local copy for MarkToSimple
1210
1211 bool bMulti = aNewMark.IsMultiMarked();
1212 if (bMulti)
1213 {
1214 aNewMark.MarkToSimple();
1215 bMulti = aNewMark.IsMultiMarked();
1216 }
1217 if (bMulti)
1218 {
1219 rRange = new ScRangeList;
1220 aNewMark.FillRangeListWithMarks( rRange.get(), false );
1221 }
1222 else
1223 {
1224 ScRange aSimple;
1225 GetSimpleArea(aSimple);
1226 rRange = new ScRangeList(aSimple);
1227 }
1228}
1229
1231{
1232 SCCOL nStartCol;
1233 SCROW nStartRow;
1234 SCTAB nStartTab;
1235 SCCOL nEndCol;
1236 SCROW nEndRow;
1237 SCTAB nEndTab;
1238 if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
1239 if (nStartRow == 0 && nEndRow == mrDoc.MaxRow())
1240 return true;
1241
1242 return false;
1243}
1244
1246{
1247 SCCOL nStartCol;
1248 SCROW nStartRow;
1249 SCTAB nStartTab;
1250 SCCOL nEndCol;
1251 SCROW nEndRow;
1252 SCTAB nEndTab;
1253 if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
1254 if (nStartCol == 0 && nEndCol == mrDoc.MaxCol())
1255 return true;
1256
1257 return false;
1258}
1259
1261{
1262 // Test for "real" multi selection, calling MarkToSimple on a local copy,
1263 // and taking filtered in simple area marks into account.
1264
1265 ScRange aDummy;
1266 ScMarkType eType = GetSimpleArea(aDummy);
1267 return (eType & SC_MARK_SIMPLE) != SC_MARK_SIMPLE;
1268}
1269
1271{
1272 if (!pClipDoc)
1273 {
1274 // Same as checkDestRanges() in sc/source/ui/view/cellsh.cxx but
1275 // different return details.
1276
1277 vcl::Window* pWin = GetActiveWin();
1278 if (!pWin)
1279 // No window doesn't mean paste would be forbidden.
1280 return false;
1281
1283 if (!pOwnClip)
1284 // Foreign content does not get repeatedly replicated.
1285 return false;
1286
1287 pClipDoc = pOwnClip->GetDocument();
1288 if (!pClipDoc)
1289 // No clipdoc doesn't mean paste would be forbidden.
1290 return false;
1291 }
1292
1293 const ScRange aSrcRange = pClipDoc->GetClipParam().getWholeRange();
1294 const SCROW nRowSize = aSrcRange.aEnd.Row() - aSrcRange.aStart.Row() + 1;
1295 const SCCOL nColSize = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1;
1296
1297 return SelectionForbidsPaste( nColSize, nRowSize);
1298}
1299
1301{
1302 ScRange aSelRange( ScAddress::UNINITIALIZED );
1303 ScMarkType eMarkType = GetSimpleArea( aSelRange);
1304
1305 if (eMarkType == SC_MARK_MULTI)
1306 // Not because of DOOM.
1307 return false;
1308
1309 if (aSelRange.aEnd.Row() - aSelRange.aStart.Row() + 1 == nSrcRows)
1310 // This also covers entire col(s) copied to be pasted on entire cols.
1311 return false;
1312
1313 if (aSelRange.aEnd.Col() - aSelRange.aStart.Col() + 1 == nSrcCols)
1314 // This also covers entire row(s) copied to be pasted on entire rows.
1315 return false;
1316
1317 return SelectionFillDOOM( aSelRange);
1318}
1319
1321{
1322 ScRange aSelRange( ScAddress::UNINITIALIZED );
1323 ScMarkType eMarkType = GetSimpleArea( aSelRange);
1324 return eMarkType != SC_MARK_MULTI && SelectionFillDOOM( aSelRange);
1325}
1326
1327// static
1329{
1330 // Assume that more than 23 full columns (23M cells) will not be
1331 // successful... Even with only 10 bytes per cell that would already be
1332 // 230MB, formula cells would be 100 bytes and more per cell.
1333 // rows * columns > 23m => rows > 23m / columns
1334 // to not overflow in case number of available columns or rows would be
1335 // arbitrarily increased.
1336 // We could refine this and take some actual cell size into account,
1337 // evaluate available memory and what not, but...
1338 const sal_Int32 kMax = 23 * 1024 * 1024; // current MAXROWCOUNT1 is 1024*1024=1048576
1339 return (rRange.aEnd.Row() - rRange.aStart.Row() + 1) > (kMax / (rRange.aEnd.Col() - rRange.aStart.Col() + 1));
1340}
1341
1342void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
1343{
1345 nFillStartX = nStartCol;
1346 nFillStartY = nStartRow;
1347 nFillEndX = nEndCol;
1348 nFillEndY = nEndRow;
1349}
1350
1351void ScViewData::SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1352 ScFillMode nMode )
1353{
1354 nFillMode = nMode;
1355 nFillStartX = nStartCol;
1356 nFillStartY = nStartRow;
1357 nFillEndX = nEndCol;
1358 nFillEndY = nEndRow;
1359}
1360
1362{
1364}
1365
1366void ScViewData::GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
1367 SCCOL& rEndCol, SCROW& rEndRow )
1368{
1369 rStartCol = nFillStartX;
1370 rStartRow = nFillStartY;
1371 rEndCol = nFillEndX;
1372 rEndRow = nFillEndY;
1373}
1374
1376{
1378 return pThisTab->nOldCurX;
1379 else
1380 return pThisTab->nCurX;
1381}
1382
1384{
1386 return pThisTab->nOldCurY;
1387 else
1388 return pThisTab->nCurY;
1389}
1390
1392{
1393 pThisTab->nOldCurX = nNewX;
1394 pThisTab->nOldCurY = nNewY;
1395 pThisTab->mbOldCursorValid = true;
1396}
1397
1399{
1400 pThisTab->mbOldCursorValid = false;
1401}
1402
1404{
1406 return 0;
1407
1408 if (nForTab == -1)
1409 return pThisTab->nPosX[eWhich];
1410
1411 if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))
1412 return -1;
1413
1414 return maTabData[nForTab]->nPosX[eWhich];
1415}
1416
1418{
1420 return 0;
1421
1422 if (nForTab == -1)
1423 return pThisTab->nPosY[eWhich];
1424
1425 if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))
1426 return -1;
1427
1428 return maTabData[nForTab]->nPosY[eWhich];
1429}
1430
1432{
1433 if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) || !maTabData[nTabIndex])
1434 return -1;
1435
1436 return maTabData[nTabIndex]->nCurX;
1437}
1438
1440{
1441 if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
1442 return -1;
1443
1444 return maTabData[nTabIndex]->nCurY;
1445}
1446
1447void ScViewData::SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex )
1448{
1449 if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
1450 return;
1451
1452 maTabData[nTabIndex]->nCurX = nNewCurX;
1453}
1454
1455void ScViewData::SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex )
1456{
1457 if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
1458 return;
1459
1460 maTabData[nTabIndex]->nCurY = nNewCurY;
1461}
1462
1464{
1465 nNewMaxCol = std::clamp(nNewMaxCol, SCCOL(0), mrDoc.MaxCol());
1466
1467 const SCTAB nTab = GetTabNo();
1468 auto GetColWidthPx = [this, nTab](SCCOL nCol) {
1469 const sal_uInt16 nSize = this->mrDoc.GetColWidth(nCol, nTab);
1470 const tools::Long nSizePx = ScViewData::ToPixel(nSize, nPPTX);
1471 return nSizePx;
1472 };
1473
1474 tools::Long nTotalPixels = GetLOKWidthHelper().computePosition(nNewMaxCol, GetColWidthPx);
1475
1476 SAL_INFO("sc.lok.docsize", "ScViewData::SetMaxTiledCol: nNewMaxCol: "
1477 << nNewMaxCol << ", nTotalPixels: " << nTotalPixels);
1478
1480 GetLOKWidthHelper().insert(nNewMaxCol, nTotalPixels);
1481
1482 pThisTab->nMaxTiledCol = nNewMaxCol;
1483}
1484
1486{
1487 if (nNewMaxRow < 0)
1488 nNewMaxRow = 0;
1489 if (nNewMaxRow > MAXTILEDROW)
1490 nNewMaxRow = MAXTILEDROW;
1491
1492 const SCTAB nTab = GetTabNo();
1493 auto GetRowHeightPx = [this, nTab](SCROW nRow) {
1494 const sal_uInt16 nSize = this->mrDoc.GetRowHeight(nRow, nTab);
1495 const tools::Long nSizePx = ScViewData::ToPixel(nSize, nPPTY);
1496 return nSizePx;
1497 };
1498
1499 tools::Long nTotalPixels = GetLOKHeightHelper().computePosition(nNewMaxRow, GetRowHeightPx);
1500
1501 SAL_INFO("sc.lok.docsize", "ScViewData::SetMaxTiledRow: nNewMaxRow: "
1502 << nNewMaxRow << ", nTotalPixels: " << nTotalPixels);
1503
1505 GetLOKHeightHelper().insert(nNewMaxRow, nTotalPixels);
1506
1507 pThisTab->nMaxTiledRow = nNewMaxRow;
1508}
1509
1511 vcl::Window* pWin, const ScPatternAttr* pPattern,
1512 bool bForceToTop, bool bInPrintTwips )
1513{
1514 Point aCellTopLeft = bInPrintTwips ?
1515 GetPrintTwipsPos(nPosX, nPosY) : GetScrPos(nPosX, nPosY, eWhich, true);
1516 return ScEditUtil(&mrDoc, nPosX, nPosY, nTabNo, aCellTopLeft,
1517 pWin->GetOutDev(), nPPTX, nPPTY, GetZoomX(), GetZoomY(), bInPrintTwips ).
1518 GetEditArea( pPattern, bForceToTop );
1519}
1520
1522 ScEditEngineDefaulter* pNewEngine,
1523 vcl::Window* pWin, SCCOL nNewX, SCROW nNewY )
1524{
1525 bool bLayoutRTL = mrDoc.IsLayoutRTL(nTabNo);
1526 ScHSplitPos eHWhich = WhichH(eWhich);
1527 ScVSplitPos eVWhich = WhichV(eWhich);
1528 bool bLOKActive = comphelper::LibreOfficeKit::isActive();
1529 bool bLOKPrintTwips = bLOKActive && comphelper::LibreOfficeKit::isCompatFlagSet(
1530 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
1531 bool bLOKLayoutRTL = bLOKActive && bLayoutRTL;
1532
1533 bool bWasThere = false;
1534 if (pEditView[eWhich])
1535 {
1536 // if the view is already there don't call anything that changes the cursor position
1537 if (bEditActive[eWhich])
1538 {
1539 bWasThere = true;
1540 }
1541 else
1542 {
1543 lcl_LOKRemoveWindow(GetViewShell(), eWhich);
1544 pEditView[eWhich]->SetEditEngine(pNewEngine);
1545 }
1546
1547 if (pEditView[eWhich]->GetWindow() != pWin)
1548 {
1549 lcl_LOKRemoveWindow(GetViewShell(), eWhich);
1550 pEditView[eWhich]->SetWindow(pWin);
1551 OSL_FAIL("EditView Window has changed");
1552 }
1553 }
1554 else
1555 {
1556 pEditView[eWhich].reset(new EditView( pNewEngine, pWin ));
1557
1558 if (bLOKActive)
1559 {
1560 // We can broadcast the view-cursor message in print-twips for all views.
1561 pEditView[eWhich]->SetBroadcastLOKViewCursor(bLOKPrintTwips);
1562 pEditView[eWhich]->RegisterViewShell(pView);
1563 }
1564 }
1565
1566 // add windows from other views
1567 if (!bWasThere && bLOKActive)
1568 {
1569 ScTabViewShell* pThisViewShell = GetViewShell();
1570 SCTAB nThisTabNo = GetTabNo();
1571 auto lAddWindows =
1572 [pThisViewShell, nThisTabNo, eWhich] (ScTabViewShell* pOtherViewShell)
1573 {
1574 ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
1575 SCTAB nOtherTabNo = rOtherViewData.GetTabNo();
1576 if (nThisTabNo == nOtherTabNo)
1577 pOtherViewShell->AddWindowToForeignEditView(pThisViewShell, eWhich);
1578 };
1579
1580 SfxLokHelper::forEachOtherView(pThisViewShell, lAddWindows);
1581 }
1582
1583 // if view is gone then during IdleFormat sometimes a cursor is drawn
1584
1585 EEControlBits nEC = pNewEngine->GetControlWord();
1586 pNewEngine->SetControlWord(nEC & ~EEControlBits::DOIDLEFORMAT);
1587
1588 EVControlBits nVC = pEditView[eWhich]->GetControlWord();
1589 pEditView[eWhich]->SetControlWord(nVC & ~EVControlBits::AUTOSCROLL);
1590
1591 bEditActive[eWhich] = true;
1592
1593 const ScPatternAttr* pPattern = mrDoc.GetPattern(nNewX, nNewY, nTabNo);
1594 SvxCellHorJustify eJust = pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue();
1595
1596 bool bBreak = ( eJust == SvxCellHorJustify::Block ) ||
1597 pPattern->GetItem(ATTR_LINEBREAK).GetValue();
1598
1599 bool bAsianVertical = pNewEngine->IsEffectivelyVertical(); // set by InputHandler
1600
1601 tools::Rectangle aPixRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, GetScrPos(nNewX, nNewY, eWhich),
1602 pWin->GetOutDev(), nPPTX,nPPTY,GetZoomX(),GetZoomY() ).
1603 GetEditArea( pPattern, true );
1604
1605 tools::Rectangle aPTwipsRect;
1606 if (bLOKPrintTwips)
1607 {
1608 aPTwipsRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, GetPrintTwipsPos(nNewX, nNewY),
1609 pWin->GetOutDev(), nPPTX, nPPTY, GetZoomX(), GetZoomY(), true /* bInPrintTwips */).
1610 GetEditArea(pPattern, true);
1611 }
1612
1613 // when right-aligned, leave space for the cursor
1614 // in vertical mode, editing is always right-aligned
1615 if ( GetEditAdjust() == SvxAdjust::Right || bAsianVertical )
1616 {
1617 aPixRect.AdjustRight(1 );
1618 if (bLOKPrintTwips)
1620 }
1621
1622 if (bLOKPrintTwips)
1623 {
1624 if (!pEditView[eWhich]->HasLOKSpecialPositioning())
1625 pEditView[eWhich]->InitLOKSpecialPositioning(MapUnit::MapTwip, aPTwipsRect, Point());
1626 else
1627 pEditView[eWhich]->SetLOKSpecialOutputArea(aPTwipsRect);
1628 }
1629
1630 if (bLOKActive && pEditView[eWhich]->HasLOKSpecialPositioning())
1631 pEditView[eWhich]->SetLOKSpecialFlags(bLOKLayoutRTL ? LOKSpecialFlags::LayoutRTL : LOKSpecialFlags::NONE);
1632
1633 tools::Rectangle aOutputArea = pWin->PixelToLogic( aPixRect, GetLogicMode() );
1634 pEditView[eWhich]->SetOutputArea( aOutputArea );
1635
1636 if ( bActive && eWhich == GetActivePart() )
1637 {
1638 // keep the part that has the active edit view available after
1639 // switching sheets or reference input on a different part
1640 eEditActivePart = eWhich;
1641
1642 // modify members nEditCol etc. only if also extending for needed area
1643 nEditCol = nNewX;
1644 nEditRow = nNewY;
1645 const ScMergeAttr* pMergeAttr = &pPattern->GetItem(ATTR_MERGE);
1647 if (pMergeAttr->GetColMerge() > 1)
1648 nEditEndCol += pMergeAttr->GetColMerge() - 1;
1650 if (pMergeAttr->GetRowMerge() > 1)
1651 nEditEndRow += pMergeAttr->GetRowMerge() - 1;
1653
1654 // For growing use only the alignment value from the attribute, numbers
1655 // (existing or started) with default alignment extend to the right.
1656 bool bGrowCentered = ( eJust == SvxCellHorJustify::Center );
1657 bool bGrowToLeft = ( eJust == SvxCellHorJustify::Right ); // visual left
1658 bool bLOKRTLInvert = (bLOKActive && bLayoutRTL);
1659 if ( bAsianVertical )
1660 bGrowCentered = bGrowToLeft = false; // keep old behavior for asian mode
1661
1662 tools::Long nSizeXPix, nSizeXPTwips = 0;
1663
1664 const tools::Long nGridWidthPx = pView->GetGridWidth(eHWhich);
1665 const tools::Long nGridHeightPx = pView->GetGridHeight(eVWhich);
1666 tools::Long nGridWidthTwips = 0, nGridHeightTwips = 0;
1667 if (bLOKPrintTwips)
1668 {
1669 Size aGridSize(nGridWidthPx, nGridHeightPx);
1670 const MapMode& rWinMapMode = GetLogicMode();
1671 aGridSize = OutputDevice::LogicToLogic(
1672 pWin->PixelToLogic(aGridSize, rWinMapMode),
1673 rWinMapMode, MapMode(MapUnit::MapTwip));
1674 nGridWidthTwips = aGridSize.Width();
1675 nGridHeightTwips = aGridSize.Height();
1676 }
1677
1678 if (bBreak && !bAsianVertical)
1679 {
1680 nSizeXPix = aPixRect.GetWidth(); // papersize -> no horizontal scrolling
1681 if (bLOKPrintTwips)
1682 nSizeXPTwips = aPTwipsRect.GetWidth();
1683 }
1684 else
1685 {
1686 OSL_ENSURE(pView,"no View for EditView");
1687
1688 if ( bGrowCentered )
1689 {
1690 // growing into both directions until one edge is reached
1692 tools::Long nLeft = aPixRect.Left();
1693 tools::Long nRight = nGridWidthPx - aPixRect.Right();
1694 nSizeXPix = aPixRect.GetWidth() + 2 * std::min( nLeft, nRight );
1695 if (bLOKPrintTwips)
1696 {
1697 tools::Long nLeftPTwips = aPTwipsRect.Left();
1698 tools::Long nRightPTwips = nGridWidthTwips - aPTwipsRect.Right();
1699 nSizeXPTwips = aPTwipsRect.GetWidth() + 2 * std::min(nLeftPTwips, nRightPTwips);
1700 }
1701 }
1702 else if ( (bGrowToLeft && !bLOKRTLInvert) || (!bGrowToLeft && bLOKRTLInvert) )
1703 {
1704 nSizeXPix = aPixRect.Right(); // space that's available in the window when growing to the left
1705 if (bLOKPrintTwips)
1706 nSizeXPTwips = aPTwipsRect.Right();
1707 }
1708 else
1709 {
1710 nSizeXPix = nGridWidthPx - aPixRect.Left();
1711 if (bLOKPrintTwips)
1712 nSizeXPTwips = nGridWidthTwips - aPTwipsRect.Left();
1713 }
1714
1715 if ( nSizeXPix <= 0 )
1716 {
1717 nSizeXPix = aPixRect.GetWidth(); // editing outside to the right of the window -> keep cell width
1718 if (bLOKPrintTwips)
1719 nSizeXPTwips = aPTwipsRect.GetWidth();
1720 }
1721 }
1722 OSL_ENSURE(pView,"no View for EditView");
1723 tools::Long nSizeYPix = nGridHeightPx - aPixRect.Top();
1724 tools::Long nSizeYPTwips = bLOKPrintTwips ? (nGridHeightTwips - aPTwipsRect.Top()) : 0;
1725
1726 if ( nSizeYPix <= 0 )
1727 {
1728 nSizeYPix = aPixRect.GetHeight(); // editing outside below the window -> keep cell height
1729 if (bLOKPrintTwips)
1730 nSizeYPTwips = aPTwipsRect.GetHeight();
1731 }
1732
1733 Size aPaperSize = pView->GetActiveWin()->PixelToLogic( Size( nSizeXPix, nSizeYPix ), GetLogicMode() );
1734 Size aPaperSizePTwips(nSizeXPTwips, nSizeYPTwips);
1735 if ( bBreak && !bAsianVertical && SC_MOD()->GetInputOptions().GetTextWysiwyg() )
1736 {
1737 // if text is formatted for printer, use the exact same paper width
1738 // (and same line breaks) as for output.
1739
1740 Fraction aFract(1,1);
1742 tools::Rectangle aUtilRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, Point(0, 0), pWin->GetOutDev(),
1743 HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, false );
1744 aPaperSize.setWidth( aUtilRect.GetWidth() );
1745 if (bLOKPrintTwips)
1746 {
1747 aPaperSizePTwips.setWidth(o3tl::convert(aUtilRect.GetWidth(), o3tl::Length::mm100, o3tl::Length::twip));
1748 }
1749 }
1750
1751 pNewEngine->SetPaperSize( aPaperSize );
1752 if (bLOKPrintTwips)
1753 pNewEngine->SetLOKSpecialPaperSize(aPaperSizePTwips);
1754
1755 // sichtbarer Ausschnitt
1756 Size aPaper = pNewEngine->GetPaperSize();
1757 tools::Rectangle aVis = pEditView[eWhich]->GetVisArea();
1758 tools::Rectangle aVisPTwips;
1759 if (bLOKPrintTwips)
1760 aVisPTwips = pEditView[eWhich]->GetLOKSpecialVisArea();
1761
1762 tools::Long nDiff = aVis.Right() - aVis.Left();
1763 tools::Long nDiffPTwips = bLOKPrintTwips ? (aVisPTwips.Right() - aVisPTwips.Left()) : 0;
1764 if ( GetEditAdjust() == SvxAdjust::Right )
1765 {
1766 aVis.SetRight( aPaper.Width() - 1 );
1767 if (bLOKPrintTwips)
1768 aVisPTwips.SetRight( aPaperSizePTwips.Width() - 1 );
1769 bMoveArea = !bLayoutRTL;
1770 }
1771 else if ( GetEditAdjust() == SvxAdjust::Center )
1772 {
1773 aVis.SetRight( ( aPaper.Width() - 1 + nDiff ) / 2 );
1774 if (bLOKPrintTwips)
1775 aVisPTwips.SetRight( ( aPaperSizePTwips.Width() - 1 + nDiffPTwips ) / 2 );
1776 bMoveArea = true; // always
1777 }
1778 else
1779 {
1780 aVis.SetRight( nDiff );
1781 if (bLOKPrintTwips)
1782 aVisPTwips.SetRight(nDiffPTwips);
1783 bMoveArea = bLayoutRTL;
1784 }
1785 aVis.SetLeft( aVis.Right() - nDiff );
1786 if (bLOKPrintTwips)
1787 aVisPTwips.SetLeft(aVisPTwips.Right() - nDiffPTwips);
1788 // #i49561# Important note:
1789 // The set offset of the visible area of the EditView for centered and
1790 // right alignment in horizontal layout is consider by instances of
1791 // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
1792 // and <PixelToLogic(..)>. This is needed for the correct visibility
1793 // of paragraphs in edit mode at the accessibility API.
1794 pEditView[eWhich]->SetVisArea(aVis);
1795 if (bLOKPrintTwips)
1796 pEditView[eWhich]->SetLOKSpecialVisArea(aVisPTwips);
1797 // UpdateMode has been disabled in ScInputHandler::StartTable
1798 // must be enabled before EditGrowY (GetTextHeight)
1799 pNewEngine->SetUpdateLayout( true );
1800
1801 pNewEngine->SetStatusEventHdl( LINK( this, ScViewData, EditEngineHdl ) );
1802
1803 EditGrowY( true ); // adjust to existing text content
1804 EditGrowX();
1805
1806 Point aDocPos = pEditView[eWhich]->GetWindowPosTopLeft(0);
1807 if (aDocPos.Y() < aOutputArea.Top())
1808 pEditView[eWhich]->Scroll( 0, aOutputArea.Top() - aDocPos.Y() );
1809 }
1810
1811 // here bEditActive needs to be set already
1812 // (due to Map-Mode during Paint)
1813 if (!bWasThere)
1814 pNewEngine->InsertView(pEditView[eWhich].get());
1815
1816 // background color of the cell
1817 Color aBackCol = pPattern->GetItem(ATTR_BACKGROUND).GetColor();
1818
1819 ScModule* pScMod = SC_MOD();
1820 if ( aBackCol.IsTransparent() )
1821 {
1823 }
1824 pEditView[eWhich]->SetBackgroundColor( aBackCol );
1825
1826 pEditView[eWhich]->Invalidate(); // needed?
1827 // needed, if position changed
1828}
1829
1830IMPL_LINK( ScViewData, EditEngineHdl, EditStatus&, rStatus, void )
1831{
1832 EditStatusFlags nStatus = rStatus.GetStatusWord();
1833 if (nStatus & (EditStatusFlags::HSCROLL | EditStatusFlags::TextHeightChanged | EditStatusFlags::TEXTWIDTHCHANGED | EditStatusFlags::CURSOROUT))
1834 {
1835 EditGrowY();
1836 EditGrowX();
1837
1838 if (nStatus & EditStatusFlags::CURSOROUT)
1839 {
1840 ScSplitPos eWhich = GetActivePart();
1841 if (pEditView[eWhich])
1842 pEditView[eWhich]->ShowCursor(false);
1843 }
1844 }
1845}
1846
1848{
1849 // It is insane to call EditGrowX while the output area is already growing.
1850 // That could occur because of the call to SetDefaultItem later.
1851 // We end up with wrong start/end edit columns and the changes
1852 // to the output area performed by the inner call to this method are
1853 // useless since they are discarded by the outer call.
1854 if (bGrowing)
1855 return;
1856
1858
1859 bool bLOKActive = comphelper::LibreOfficeKit::isActive();
1860 bool bLOKPrintTwips = bLOKActive && comphelper::LibreOfficeKit::isCompatFlagSet(
1861 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
1862
1863 ScDocument& rLocalDoc = GetDocument();
1864
1865 ScSplitPos eWhich = GetActivePart();
1866 ScHSplitPos eHWhich = WhichH(eWhich);
1867 EditView* pCurView = pEditView[eWhich].get();
1868
1869 if ( !pCurView || !bEditActive[eWhich])
1870 return;
1871
1872 bool bLayoutRTL = rLocalDoc.IsLayoutRTL( nTabNo );
1873
1874 ScEditEngineDefaulter* pEngine =
1875 static_cast<ScEditEngineDefaulter*>( pCurView->GetEditEngine() );
1876 vcl::Window* pWin = pCurView->GetWindow();
1877
1878 // Get the left- and right-most column positions.
1879 SCCOL nLeft = GetPosX(eHWhich);
1880 SCCOL nRight = nLeft + VisibleCellsX(eHWhich);
1881
1882 Size aSize = pEngine->GetPaperSize();
1883 Size aSizePTwips;
1884 if (bLOKPrintTwips)
1885 aSizePTwips = pEngine->GetLOKSpecialPaperSize();
1886
1887 tools::Rectangle aArea = pCurView->GetOutputArea();
1888 tools::Rectangle aAreaPTwips;
1889 if (bLOKPrintTwips)
1890 aAreaPTwips = pCurView->GetLOKSpecialOutputArea();
1891
1892 tools::Long nOldRight = aArea.Right();
1893
1894 // Margin is already included in the original width.
1895 tools::Long nTextWidth = pEngine->CalcTextWidth();
1896
1897 bool bChanged = false;
1898 bool bAsianVertical = pEngine->IsEffectivelyVertical();
1899
1900 // get bGrow... variables the same way as in SetEditEngine
1901 const ScPatternAttr* pPattern = rLocalDoc.GetPattern( nEditCol, nEditRow, nTabNo );
1902 SvxCellHorJustify eJust = pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue();
1903 bool bGrowCentered = ( eJust == SvxCellHorJustify::Center );
1904 bool bGrowToLeft = ( eJust == SvxCellHorJustify::Right ); // visual left
1905 bool bGrowBackwards = bGrowToLeft; // logical left
1906 if ( bLayoutRTL )
1907 bGrowBackwards = !bGrowBackwards; // invert on RTL sheet
1908 if ( bAsianVertical )
1909 bGrowCentered = bGrowToLeft = bGrowBackwards = false; // keep old behavior for asian mode
1910
1911 bool bUnevenGrow = false;
1912 if ( bGrowCentered )
1913 {
1914 while (aArea.GetWidth() + 0 < nTextWidth && ( nEditStartCol > nLeft || nEditEndCol < nRight ) )
1915 {
1916 tools::Long nLogicLeft = 0;
1917 tools::Long nLogicLeftPTwips = 0;
1918 if ( nEditStartCol > nLeft )
1919 {
1920 --nEditStartCol;
1921 tools::Long nColWidth = rLocalDoc.GetColWidth( nEditStartCol, nTabNo );
1922 tools::Long nLeftPix = ToPixel( nColWidth, nPPTX );
1923 nLogicLeft = pWin->PixelToLogic(Size(nLeftPix,0)).Width();
1924 if (bLOKPrintTwips)
1925 nLogicLeftPTwips = nColWidth;
1926 }
1927 tools::Long nLogicRight = 0;
1928 tools::Long nLogicRightPTwips = 0;
1929 if ( nEditEndCol < nRight )
1930 {
1931 ++nEditEndCol;
1932 tools::Long nColWidth = rLocalDoc.GetColWidth( nEditEndCol, nTabNo );
1933 tools::Long nRightPix = ToPixel( nColWidth, nPPTX );
1934 nLogicRight = pWin->PixelToLogic(Size(nRightPix,0)).Width();
1935 if (bLOKPrintTwips)
1936 nLogicRightPTwips = nColWidth;
1937 }
1938
1939 aArea.AdjustLeft( -((bLayoutRTL && !bLOKActive) ? nLogicRight : nLogicLeft) );
1940 aArea.AdjustRight((bLayoutRTL && !bLOKActive) ? nLogicLeft : nLogicRight );
1941 if (bLOKPrintTwips)
1942 {
1943 aAreaPTwips.AdjustLeft(-nLogicLeftPTwips);
1944 aAreaPTwips.AdjustRight(nLogicRightPTwips);
1945 }
1946
1947 if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1948 {
1949 tools::Long nCenter = ( aArea.Left() + aArea.Right() ) / 2;
1950 tools::Long nHalf = aSize.Width() / 2;
1951 aArea.SetLeft( nCenter - nHalf + 1 );
1952 aArea.SetRight( nCenter + aSize.Width() - nHalf - 1 );
1953
1954 if (bLOKPrintTwips)
1955 {
1956 tools::Long nCenterPTwips = ( aAreaPTwips.Left() + aAreaPTwips.Right() ) / 2;
1957 tools::Long nHalfPTwips = aSizePTwips.Width() / 2;
1958 aAreaPTwips.SetLeft( nCenterPTwips - nHalfPTwips + 1 );
1959 aAreaPTwips.SetRight( nCenterPTwips + aSizePTwips.Width() - nHalfPTwips - 1 );
1960 }
1961 }
1962
1963 bChanged = true;
1964 if ( nLogicLeft != nLogicRight )
1965 bUnevenGrow = true;
1966 }
1967 }
1968 else if ( bGrowBackwards )
1969 {
1970 while (aArea.GetWidth() + 0 < nTextWidth && nEditStartCol > nLeft)
1971 {
1972 --nEditStartCol;
1973 tools::Long nColWidth = rLocalDoc.GetColWidth( nEditStartCol, nTabNo );
1974 tools::Long nPix = ToPixel( nColWidth, nPPTX );
1975 tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
1976 tools::Long& nLogicWidthPTwips = nColWidth;
1977
1978 if ( !bLayoutRTL || bLOKActive )
1979 {
1980 aArea.AdjustLeft( -nLogicWidth );
1981 if (bLOKPrintTwips)
1982 aAreaPTwips.AdjustLeft( -nLogicWidthPTwips );
1983 }
1984 else
1985 {
1986 aArea.AdjustRight(nLogicWidth );
1987 if (bLOKPrintTwips)
1988 aAreaPTwips.AdjustRight(nLogicWidthPTwips);
1989 }
1990
1991 if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1992 {
1993 if ( !bLayoutRTL || bLOKActive )
1994 {
1995 aArea.SetLeft( aArea.Right() - aSize.Width() + 1 );
1996 if (bLOKPrintTwips)
1997 aAreaPTwips.SetLeft( aAreaPTwips.Right() - aSizePTwips.Width() + 1 );
1998 }
1999 else
2000 {
2001 aArea.SetRight( aArea.Left() + aSize.Width() - 1 );
2002 if (bLOKPrintTwips)
2003 aAreaPTwips.SetRight( aAreaPTwips.Left() + aSizePTwips.Width() - 1 );
2004 }
2005 }
2006
2007 bChanged = true;
2008 }
2009 }
2010 else
2011 {
2012 while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight)
2013 {
2014 ++nEditEndCol;
2015 tools::Long nColWidth = rLocalDoc.GetColWidth( nEditEndCol, nTabNo );
2016 tools::Long nPix = ToPixel( nColWidth, nPPTX );
2017 tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
2018 tools::Long& nLogicWidthPTwips = nColWidth;
2019 if ( bLayoutRTL && !bLOKActive )
2020 {
2021 aArea.AdjustLeft( -nLogicWidth );
2022 }
2023 else
2024 {
2025 aArea.AdjustRight(nLogicWidth );
2026 if (bLOKPrintTwips)
2027 aAreaPTwips.AdjustRight(nLogicWidthPTwips);
2028 }
2029
2030 if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
2031 {
2032 if ( bLayoutRTL && !bLOKActive )
2033 {
2034 aArea.SetLeft( aArea.Right() - aSize.Width() + 1 );
2035 }
2036 else
2037 {
2038 aArea.SetRight( aArea.Left() + aSize.Width() - 1 );
2039 if (bLOKPrintTwips)
2040 aAreaPTwips.SetRight( aAreaPTwips.Left() + aSizePTwips.Width() - 1 );
2041 }
2042 }
2043
2044 bChanged = true;
2045 }
2046 }
2047
2048 if (!bChanged)
2049 return;
2050
2051 if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL )
2052 {
2053 tools::Rectangle aVis = pCurView->GetVisArea();
2054 tools::Rectangle aVisPTwips;
2055 if (bLOKPrintTwips)
2056 aVisPTwips = pCurView->GetLOKSpecialVisArea();
2057
2058 if ( bGrowCentered )
2059 {
2060 // switch to center-aligned (undo?) and reset VisArea to center
2061
2062 pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
2063
2064 tools::Long nCenter = aSize.Width() / 2;
2065 tools::Long nVisSize = aArea.GetWidth();
2066 aVis.SetLeft( nCenter - nVisSize / 2 );
2067 aVis.SetRight( aVis.Left() + nVisSize - 1 );
2068
2069 if (bLOKPrintTwips)
2070 {
2071 tools::Long nCenterPTwips = aSizePTwips.Width() / 2;
2072 tools::Long nVisSizePTwips = aAreaPTwips.GetWidth();
2073 aVisPTwips.SetLeft( nCenterPTwips - nVisSizePTwips / 2 );
2074 aVisPTwips.SetRight( aVisPTwips.Left() + nVisSizePTwips - 1 );
2075 }
2076 }
2077 else if ( bGrowToLeft )
2078 {
2079 // switch to right-aligned (undo?) and reset VisArea to the right
2080
2081 pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
2082
2083 aVis.SetRight( aSize.Width() - 1 );
2084 aVis.SetLeft( aSize.Width() - aArea.GetWidth() ); // with the new, increased area
2085
2086 if (bLOKPrintTwips)
2087 {
2088 aVisPTwips.SetRight( aSizePTwips.Width() - 1 );
2089 aVisPTwips.SetLeft( aSizePTwips.Width() - aAreaPTwips.GetWidth() ); // with the new, increased area
2090 }
2091 }
2092 else
2093 {
2094 // switch to left-aligned (undo?) and reset VisArea to the left
2095
2096 pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
2097
2098 tools::Long nMove = aVis.Left();
2099 aVis.SetLeft( 0 );
2100 aVis.AdjustRight( -nMove );
2101
2102 if (bLOKPrintTwips)
2103 {
2104 tools::Long nMovePTwips = aVisPTwips.Left();
2105 aVisPTwips.SetLeft( 0 );
2106 aVisPTwips.AdjustRight( -nMovePTwips );
2107 }
2108 }
2109
2110 pCurView->SetVisArea( aVis );
2111 if (bLOKPrintTwips)
2112 pCurView->SetLOKSpecialVisArea( aVisPTwips );
2113
2114 bMoveArea = false;
2115 }
2116
2117 if (bLOKPrintTwips)
2118 pCurView->SetLOKSpecialOutputArea(aAreaPTwips);
2119
2120 pCurView->SetOutputArea(aArea);
2121
2122 // In vertical mode, the whole text is moved to the next cell (right-aligned),
2123 // so everything must be repainted. Otherwise, paint only the new area.
2124 // If growing in centered alignment, if the cells left and right have different sizes,
2125 // the whole text will move, and may not even obscure all of the original display.
2126 if ( bUnevenGrow )
2127 {
2128 aArea.SetLeft( pWin->PixelToLogic( Point(0,0) ).X() );
2129 aArea.SetRight( pWin->PixelToLogic( aScrSize ).Width() );
2130 }
2131 else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered )
2132 aArea.SetLeft( nOldRight );
2133 pWin->Invalidate(aArea);
2134
2135 // invalidate other views
2136 pCurView->InvalidateOtherViewWindows(aArea);
2137}
2138
2139void ScViewData::EditGrowY( bool bInitial )
2140{
2141 if (bGrowing)
2142 return;
2143
2145
2146 bool bLOKActive = comphelper::LibreOfficeKit::isActive();
2147 bool bLOKPrintTwips = bLOKActive && comphelper::LibreOfficeKit::isCompatFlagSet(
2148 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
2149
2150 ScSplitPos eWhich = GetActivePart();
2151 ScVSplitPos eVWhich = WhichV(eWhich);
2152 EditView* pCurView = pEditView[eWhich].get();
2153
2154 if ( !pCurView || !bEditActive[eWhich])
2155 return;
2156
2157 EVControlBits nControl = pEditView[eWhich]->GetControlWord();
2158 if ( nControl & EVControlBits::AUTOSCROLL )
2159 {
2160 // if end of screen had already been reached and scrolling enabled,
2161 // don't further try to grow the edit area
2162
2163 pCurView->SetOutputArea( pCurView->GetOutputArea() ); // re-align to pixels
2164 return;
2165 }
2166
2167 EditEngine* pEngine = pCurView->GetEditEngine();
2168 vcl::Window* pWin = pCurView->GetWindow();
2169
2170 SCROW nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich);
2171
2172 Size aSize = pEngine->GetPaperSize();
2173 Size aSizePTwips;
2174 tools::Rectangle aArea = pCurView->GetOutputArea();
2175 tools::Rectangle aAreaPTwips;
2176
2177 if (bLOKPrintTwips)
2178 {
2179 aSizePTwips = pEngine->GetLOKSpecialPaperSize();
2180 aAreaPTwips = pCurView->GetLOKSpecialOutputArea();
2181 }
2182
2183 tools::Long nOldBottom = aArea.Bottom();
2184 tools::Long nTextHeight = pEngine->GetTextHeight();
2185
2186 // When editing a formula in a cell with optimal height, allow a larger portion
2187 // to be clipped before extending to following rows, to avoid obscuring cells for
2188 // reference input (next row is likely to be useful in formulas).
2189 tools::Long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
2191 pEngine->GetParagraphCount() <= 1 )
2192 {
2193 // If the (only) paragraph starts with a '=', it's a formula.
2194 // If this is the initial call and the text is empty, allow the larger value, too,
2195 // because this occurs in the normal progress of editing a formula.
2196 // Subsequent calls with empty text might involve changed attributes (including
2197 // font height), so they are treated like normal text.
2198 OUString aText = pEngine->GetText( 0 );
2199 if ( ( aText.isEmpty() && bInitial ) || aText.startsWith("=") )
2200 nAllowedExtra = SC_GROWY_BIG_EXTRA;
2201 }
2202
2203 bool bChanged = false;
2204 bool bMaxReached = false;
2205 while (aArea.GetHeight() + nAllowedExtra < nTextHeight && nEditEndRow < nBottom && !bMaxReached)
2206 {
2207 ++nEditEndRow;
2208 ScDocument& rLocalDoc = GetDocument();
2209 tools::Long nRowHeight = rLocalDoc.GetRowHeight( nEditEndRow, nTabNo );
2210 tools::Long nPix = ToPixel( nRowHeight, nPPTY );
2211 aArea.AdjustBottom(pWin->PixelToLogic(Size(0,nPix)).Height() );
2212 if (bLOKPrintTwips)
2213 aAreaPTwips.AdjustBottom(nRowHeight);
2214
2215 if ( aArea.Bottom() > aArea.Top() + aSize.Height() - 1 )
2216 {
2217 aArea.SetBottom( aArea.Top() + aSize.Height() - 1 );
2218 if (bLOKPrintTwips)
2219 aAreaPTwips.SetBottom( aAreaPTwips.Top() + aSizePTwips.Height() - 1 );
2220 bMaxReached = true; // don't occupy more cells beyond paper size
2221 }
2222
2223 bChanged = true;
2224 nAllowedExtra = SC_GROWY_SMALL_EXTRA; // larger value is only for first row
2225 }
2226
2227 if (!bChanged)
2228 return;
2229
2230 if (bLOKPrintTwips)
2231 pCurView->SetLOKSpecialOutputArea(aAreaPTwips);
2232
2233 pCurView->SetOutputArea(aArea);
2234
2235 if (nEditEndRow >= nBottom || bMaxReached)
2236 {
2237 if (!(nControl & EVControlBits::AUTOSCROLL))
2238 pCurView->SetControlWord( nControl | EVControlBits::AUTOSCROLL );
2239 }
2240
2241 aArea.SetTop( nOldBottom );
2242 pWin->Invalidate(aArea);
2243
2244 // invalidate other views
2245 pCurView->InvalidateOtherViewWindows(aArea);
2246}
2247
2249{
2250 EditEngine* pEngine = nullptr;
2251 for (sal_uInt16 i=0; i<4; i++)
2252 if (pEditView[i])
2253 {
2254 if (bEditActive[i])
2255 {
2256 lcl_LOKRemoveWindow(GetViewShell(), static_cast<ScSplitPos>(i));
2257 pEngine = pEditView[i]->GetEditEngine();
2258 pEngine->RemoveView(pEditView[i].get());
2259 pEditView[i]->SetOutputArea( tools::Rectangle() );
2260 }
2261 bEditActive[i] = false;
2262 }
2263
2264 if (pEngine)
2266}
2267
2269{
2270 EditEngine* pEngine = nullptr;
2271 for (sal_uInt16 i=0; i<4; i++)
2272 if (pEditView[i])
2273 {
2274 if (bEditActive[i])
2275 {
2276 pEngine = pEditView[i]->GetEditEngine();
2277 if (pEngine)
2278 pEngine->RemoveView(pEditView[i].get());
2279 }
2280 pEditView[i].reset();
2281 }
2282}
2283
2284void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow )
2285{
2286 rViewPtr = pEditView[eWhich].get();
2287 rCol = nEditCol;
2288 rRow = nEditRow;
2289}
2290
2292{
2293 EnsureTabDataSize(nNewTab + 1);
2294
2295 if (!maTabData[nNewTab])
2296 {
2297 maTabData[nNewTab].reset(new ScViewDataTable(&mrDoc));
2298
2299 maTabData[nNewTab]->eZoomType = eDefZoomType;
2300 maTabData[nNewTab]->aZoomX = aDefZoomX;
2301 maTabData[nNewTab]->aZoomY = aDefZoomY;
2302 maTabData[nNewTab]->aPageZoomX = aDefPageZoomX;
2303 maTabData[nNewTab]->aPageZoomY = aDefPageZoomY;
2304 }
2305}
2306
2308{
2309 for (const auto& rTab : maMarkData)
2310 CreateTabData(rTab);
2311}
2312
2314{
2315 if (nSize > maTabData.size())
2316 maTabData.resize(nSize);
2317}
2318
2320{
2321 if (!ValidTab(nNewTab))
2322 {
2323 OSL_FAIL("wrong sheet number");
2324 return;
2325 }
2326
2327 nTabNo = nNewTab;
2329 pThisTab = maTabData[nTabNo].get();
2330
2331 CalcPPT(); // for common column width correction
2332 RecalcPixPos();
2333}
2334
2336{
2337 if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) ||
2338 !maTabData[nTabIndex])
2339 {
2340 return nullptr;
2341 }
2342 return &(maTabData[nTabIndex]->aWidthHelper);
2343}
2344
2346{
2347 if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) ||
2348 !maTabData[nTabIndex])
2349 {
2350 return nullptr;
2351 }
2352 return &(maTabData[nTabIndex]->aHeightHelper);
2353}
2354
2356{
2357 pThisTab->eWhichActive = eNewActive;
2358
2359 // Let's hope we find the culprit for tdf#117093
2360 // Don't sanitize the real value (yet?) because this function might be
2361 // called before setting the then corresponding split modes. For which in
2362 // fact then the order should be changed.
2363 assert(eNewActive == pThisTab->SanitizeWhichActive());
2364}
2365
2366Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const
2367{
2368 OSL_ENSURE( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "wrong position" );
2370 return GetScrPos( nWhereX, nWhereY, ePos );
2371}
2372
2373Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const
2374{
2375 OSL_ENSURE( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "wrong position" );
2377 return GetScrPos( nWhereX, nWhereY, ePos );
2378}
2379
2381 bool bAllowNeg, SCTAB nForTab ) const
2382{
2383 ScHSplitPos eWhichX = SC_SPLIT_LEFT;
2384 ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
2385 switch( eWhich )
2386 {
2387 case SC_SPLIT_TOPLEFT:
2388 eWhichX = SC_SPLIT_LEFT;
2389 eWhichY = SC_SPLIT_TOP;
2390 break;
2391 case SC_SPLIT_TOPRIGHT:
2392 eWhichX = SC_SPLIT_RIGHT;
2393 eWhichY = SC_SPLIT_TOP;
2394 break;
2396 eWhichX = SC_SPLIT_LEFT;
2397 eWhichY = SC_SPLIT_BOTTOM;
2398 break;
2400 eWhichX = SC_SPLIT_RIGHT;
2401 eWhichY = SC_SPLIT_BOTTOM;
2402 break;
2403 }
2404
2405 if (nForTab == -1)
2406 nForTab = nTabNo;
2407 bool bForCurTab = (nForTab == nTabNo);
2408 if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))))
2409 {
2410 SAL_WARN("sc.viewdata", "ScViewData::GetScrPos : invalid nForTab = " << nForTab);
2411 nForTab = nTabNo;
2412 bForCurTab = true;
2413 }
2414
2415 ScViewDataTable* pViewTable = bForCurTab ? pThisTab : maTabData[nForTab].get();
2416
2417 if (pView)
2418 {
2419 const_cast<ScViewData*>(this)->aScrSize.setWidth( pView->GetGridWidth(eWhichX) );
2420 const_cast<ScViewData*>(this)->aScrSize.setHeight( pView->GetGridHeight(eWhichY) );
2421 }
2422
2423 sal_uInt16 nTSize;
2424 bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
2425
2426 SCCOL nPosX = GetPosX(eWhichX, nForTab);
2427 tools::Long nScrPosX = 0;
2428
2429 if (bAllowNeg || nWhereX >= nPosX)
2430 {
2431 SCROW nStartPosX = nPosX;
2432 if (bIsTiledRendering)
2433 {
2434 OSL_ENSURE(nPosX == 0, "Unsupported case.");
2435 const auto& rNearest = pViewTable->aWidthHelper.getNearestByIndex(nWhereX - 1);
2436 nStartPosX = rNearest.first + 1;
2437 nScrPosX = rNearest.second;
2438 }
2439
2440 if (nWhereX >= nStartPosX)
2441 {
2442 for (SCCOL nX = nStartPosX; nX < nWhereX && (bAllowNeg || bIsTiledRendering || nScrPosX <= aScrSize.Width()); nX++)
2443 {
2444 if (nX > mrDoc.MaxCol())
2445 nScrPosX = 0x7FFFFFFF;
2446 else
2447 {
2448 nTSize = mrDoc.GetColWidth(nX, nForTab);
2449 if (nTSize)
2450 {
2451 tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
2452 nScrPosX += nSizeXPix;
2453 }
2454 else
2455 { // If the width is zero, the column is possibly hidden, skips groups of such columns.
2456 SCCOL lastHidden = -1;
2457 if(mrDoc.ColHidden(nX, nForTab, nullptr, &lastHidden) && lastHidden > nX)
2458 nX = lastHidden - 1;
2459 }
2460 }
2461 }
2462 }
2463 else
2464 {
2465 for (SCCOL nX = nStartPosX; nX > nWhereX;)
2466 {
2467 --nX;
2468 nTSize = mrDoc.GetColWidth(nX, nForTab);
2469 if (nTSize)
2470 {
2471 tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
2472 nScrPosX -= nSizeXPix;
2473 }
2474 else
2475 { // If the width is zero, the column is possibly hidden, skips groups of such columns.
2476 SCCOL firstHidden = -1;
2477 if(mrDoc.ColHidden(nX, nForTab, &firstHidden, nullptr) && firstHidden >= 0)
2478 nX = firstHidden;
2479 }
2480 }
2481 }
2482
2483 }
2484
2485
2486 SCROW nPosY = GetPosY(eWhichY, nForTab);
2487 tools::Long nScrPosY = 0;
2488
2489 if (bAllowNeg || nWhereY >= nPosY)
2490 {
2491 SCROW nStartPosY = nPosY;
2492 if (bIsTiledRendering)
2493 {
2494 OSL_ENSURE(nPosY == 0, "Unsupported case.");
2495 const auto& rNearest = pViewTable->aHeightHelper.getNearestByIndex(nWhereY - 1);
2496 nStartPosY = rNearest.first + 1;
2497 nScrPosY = rNearest.second;
2498 }
2499
2500 if (nWhereY >= nStartPosY)
2501 {
2502 for (SCROW nY = nStartPosY; nY < nWhereY && (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height()); nY++)
2503 {
2504 if ( nY > mrDoc.MaxRow() )
2505 nScrPosY = 0x7FFFFFFF;
2506 else
2507 {
2508 nTSize = mrDoc.GetRowHeight( nY, nTabNo );
2509 if (nTSize)
2510 {
2511 tools::Long nSizeYPix = ToPixel( nTSize, nPPTY );
2512 nScrPosY += nSizeYPix;
2513 }
2514 else if ( nY < mrDoc.MaxRow() )
2515 {
2516 // skip multiple hidden rows (forward only for now)
2517 SCROW nNext = mrDoc.FirstVisibleRow(nY + 1, mrDoc.MaxRow(), nTabNo);
2518 if ( nNext > mrDoc.MaxRow() )
2519 nY = mrDoc.MaxRow();
2520 else
2521 nY = nNext - 1; // +=nDir advances to next visible row
2522 }
2523 }
2524 }
2525 }
2526 else
2527 {
2528 for (SCROW nY = nStartPosY; nY > nWhereY;)
2529 {
2530 --nY;
2531 nTSize = mrDoc.GetRowHeight(nY, nForTab);
2532 if (nTSize)
2533 {
2534 tools::Long nSizeYPix = ToPixel( nTSize, nPPTY );
2535 nScrPosY -= nSizeYPix;
2536 }
2537 else
2538 { // If the height is zero, the row is possibly hidden, skips groups of such rows.
2539 SCROW firstHidden = -1;
2540 if(mrDoc.RowHidden(nY, nForTab, &firstHidden, nullptr) && firstHidden >= 0)
2541 nY = firstHidden;
2542 }
2543 }
2544 }
2545 }
2546
2547 if (mrDoc.IsLayoutRTL(nForTab) && !bIsTiledRendering)
2548 {
2549 // mirror horizontal position
2550 nScrPosX = aScrSize.Width() - 1 - nScrPosX;
2551 }
2552
2553 return Point( nScrPosX, nScrPosY );
2554}
2555
2557{
2558 // hidden ones are given 0 sizes by these by default.
2559 // TODO: rewrite this to loop over spans (matters for jumbosheets).
2560 tools::Long nPosX = nCol ? mrDoc.GetColWidth(0, nCol - 1, nTabNo) : 0;
2561 // This is now fast as it loops over spans.
2562 tools::Long nPosY = nRow ? mrDoc.GetRowHeight(0, nRow - 1, nTabNo) : 0;
2563 // TODO: adjust for RTL layout case.
2564
2565 return Point(nPosX, nPosY);
2566}
2567
2569{
2570 const tools::Long nPixelX = static_cast<tools::Long>(rTileTwipsPos.X() * nPPTX);
2571 const tools::Long nPixelY = static_cast<tools::Long>(rTileTwipsPos.Y() * nPPTY);
2572 SCCOL nCol = 0;
2573 SCROW nRow = 0;
2574
2575 // The following call (with bTestMerge = false) will not modify any members.
2576 const_cast<ScViewData*>(this)->GetPosFromPixel(nPixelX, nPixelY, SC_SPLIT_TOPLEFT, nCol, nRow, false /* bTestMerge */);
2577 const Point aPixCellPos = GetScrPos(nCol, nRow, SC_SPLIT_TOPLEFT, true /* bAllowNeg */);
2578 const Point aTileTwipsCellPos(aPixCellPos.X() / nPPTX, aPixCellPos.Y() / nPPTY);
2579 const Point aPrintTwipsCellPos = GetPrintTwipsPos(nCol, nRow);
2580 return aPrintTwipsCellPos + (rTileTwipsPos - aTileTwipsCellPos);
2581}
2582
2583OString ScViewData::describeCellCursorAt(SCCOL nX, SCROW nY, bool bPixelAligned) const
2584{
2585 const bool bPosSizeInPixels = bPixelAligned;
2586 Point aCellPos = bPosSizeInPixels ? GetScrPos( nX, nY, SC_SPLIT_BOTTOMRIGHT, true ) :
2587 GetPrintTwipsPos(nX, nY);
2588
2589 tools::Long nSizeX;
2590 tools::Long nSizeY;
2591 if (bPosSizeInPixels)
2592 GetMergeSizePixel( nX, nY, nSizeX, nSizeY );
2593 else
2594 GetMergeSizePrintTwips(nX, nY, nSizeX, nSizeY);
2595
2597 if (bPosSizeInPixels)
2598 {
2599 double fPPTX = GetPPTX();
2600 double fPPTY = GetPPTY();
2601
2602 // make it a slim cell cursor, but not empty
2603 if (nSizeX == 0)
2604 nSizeX = 1;
2605
2606 if (nSizeY == 0)
2607 nSizeY = 1;
2608
2609 tools::Long nPosXTw = rtl::math::round(aCellPos.getX() / fPPTX);
2610 tools::Long nPosYTw = rtl::math::round(aCellPos.getY() / fPPTY);
2611 // look at Rectangle( const Point& rLT, const Size& rSize ) for the '- 1'
2612 tools::Long nSizeXTw = rtl::math::round(nSizeX / fPPTX) - 1;
2613 tools::Long nSizeYTw = rtl::math::round(nSizeY / fPPTY) - 1;
2614
2615 ss << nPosXTw << ", " << nPosYTw << ", " << nSizeXTw << ", " << nSizeYTw << ", "
2616 << nX << ", " << nY;
2617 }
2618 else
2619 {
2620 // look at Rectangle( const Point& rLT, const Size& rSize ) for the decrement.
2621 if (nSizeX)
2622 --nSizeX;
2623 if (nSizeY)
2624 --nSizeY;
2625 ss << aCellPos.getX() << ", " << aCellPos.getY()
2626 << ", " << nSizeX << ", " << nSizeY << ", "
2627 << nX << ", " << nY;
2628 }
2629
2630 return OString(ss.str());
2631}
2632
2633// Number of cells on a screen
2634SCCOL ScViewData::CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeX ) const
2635{
2636 OSL_ENSURE( nDir==1 || nDir==-1, "wrong CellsAt call" );
2637
2638 if (pView)
2639 const_cast<ScViewData*>(this)->aScrSize.setWidth( pView->GetGridWidth(eWhichX) );
2640
2641 SCCOL nX;
2642 sal_uInt16 nScrPosX = 0;
2643 if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = static_cast<sal_uInt16>(aScrSize.Width());
2644
2645 if (nDir==1)
2646 nX = nPosX; // forwards
2647 else
2648 nX = nPosX-1; // backwards
2649
2650 bool bOut = false;
2651 for ( ; nScrPosX<=nScrSizeX && !bOut; nX = sal::static_int_cast<SCCOL>(nX + nDir) )
2652 {
2653 SCCOL nColNo = nX;
2654 if (nColNo < 0 || nColNo > mrDoc.MaxCol())
2655 bOut = true;
2656 else
2657 {
2658 sal_uInt16 nTSize = mrDoc.GetColWidth(nColNo, nTabNo);
2659 if (nTSize)
2660 {
2661 tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
2662 nScrPosX = sal::static_int_cast<sal_uInt16>( nScrPosX + static_cast<sal_uInt16>(nSizeXPix) );
2663 }
2664 }
2665 }
2666
2667 if (nDir==1)
2668 nX = sal::static_int_cast<SCCOL>( nX - nPosX );
2669 else
2670 nX = (nPosX-1)-nX;
2671
2672 if (nX>0) --nX;
2673 return nX;
2674}
2675
2676SCROW ScViewData::CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeY ) const
2677{
2678 OSL_ENSURE( nDir==1 || nDir==-1, "wrong CellsAt call" );
2679
2680 if (pView)
2681 const_cast<ScViewData*>(this)->aScrSize.setHeight( pView->GetGridHeight(eWhichY) );
2682
2683 if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = static_cast<sal_uInt16>(aScrSize.Height());
2684
2685 SCROW nY;
2686
2687 if (nDir==1)
2688 {
2689 // forward
2690 nY = nPosY;
2691 tools::Long nScrPosY = 0;
2692 AddPixelsWhile(nScrPosY, nScrSizeY, nY, mrDoc.MaxRow(), nPPTY, &mrDoc, nTabNo);
2693 // Original loop ended on last evaluated +1 or if that was MaxRow even on MaxRow+2.
2694 nY += (nY == mrDoc.MaxRow() ? 2 : 1);
2695 nY -= nPosY;
2696 }
2697 else
2698 {
2699 // backward
2700 nY = nPosY-1;
2701 tools::Long nScrPosY = 0;
2702 AddPixelsWhileBackward(nScrPosY, nScrSizeY, nY, 0, nPPTY, &mrDoc, nTabNo);
2703 // Original loop ended on last evaluated -1 or if that was 0 even on -2.
2704 nY -= (nY == 0 ? 2 : 1);
2705 nY = (nPosY-1)-nY;
2706 }
2707
2708 if (nY>0) --nY;
2709 return nY;
2710}
2711
2713{
2714 return CellsAtX( GetPosX( eWhichX ), 1, eWhichX );
2715}
2716
2718{
2719 return CellsAtY( GetPosY( eWhichY ), 1, eWhichY );
2720}
2721
2723{
2724 return CellsAtX( GetPosX( eWhichX ), -1, eWhichX );
2725}
2726
2728{
2729 return CellsAtY( GetPosY( eWhichY ), -1, eWhichY );
2730}
2731
2732bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, tools::Long& rSizeXPix, tools::Long& rSizeYPix ) const
2733{
2734 const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nTabNo, ATTR_MERGE);
2735 if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
2736 {
2737 tools::Long nOutWidth = 0;
2738 tools::Long nOutHeight = 0;
2739 SCCOL nCountX = pMerge->GetColMerge();
2740 for (SCCOL i=0; i<nCountX; i++)
2741 nOutWidth += ToPixel(mrDoc.GetColWidth(nX + i, nTabNo), nPPTX);
2742 SCROW nCountY = pMerge->GetRowMerge();
2743
2744 for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
2745 {
2746 SCROW nLastRow = nRow;
2747 if (mrDoc.RowHidden(nRow, nTabNo, nullptr, &nLastRow))
2748 {
2749 nRow = nLastRow;
2750 continue;
2751 }
2752
2753 sal_uInt16 nHeight = mrDoc.GetRowHeight(nRow, nTabNo);
2754 nOutHeight += ToPixel(nHeight, nPPTY);
2755 }
2756
2757 rSizeXPix = nOutWidth;
2758 rSizeYPix = nOutHeight;
2759 return true;
2760 }
2761 else
2762 {
2763 rSizeXPix = ToPixel(mrDoc.GetColWidth(nX, nTabNo), nPPTX);
2764 rSizeYPix = ToPixel(mrDoc.GetRowHeight(nY, nTabNo), nPPTY);
2765 return false;
2766 }
2767}
2768
2769bool ScViewData::GetMergeSizePrintTwips(SCCOL nX, SCROW nY, tools::Long& rSizeXTwips, tools::Long& rSizeYTwips) const
2770{
2771 const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nTabNo, ATTR_MERGE);
2772 SCCOL nCountX = pMerge->GetColMerge();
2773 if (!nCountX)
2774 nCountX = 1;
2775 rSizeXTwips = mrDoc.GetColWidth(nX, nX + nCountX - 1, nTabNo);
2776
2777 SCROW nCountY = pMerge->GetRowMerge();
2778 if (!nCountY)
2779 nCountY = 1;
2780 rSizeYTwips = mrDoc.GetRowHeight(nY, nY + nCountY - 1, nTabNo);
2781
2782 return (nCountX > 1 || nCountY > 1);
2783}
2784
2786 SCCOL& rPosX, SCROW& rPosY,
2787 bool bTestMerge, bool bRepair, SCTAB nForTab )
2788{
2789 // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
2790
2791 if (nForTab == -1)
2792 nForTab = nTabNo;
2793 bool bForCurTab = (nForTab == nTabNo);
2794 if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))))
2795 {
2796 SAL_WARN("sc.viewdata", "ScViewData::GetPosFromPixel : invalid nForTab = " << nForTab);
2797 nForTab = nTabNo;
2798 bForCurTab = true;
2799 }
2800
2801 ScHSplitPos eHWhich = WhichH(eWhich);
2802 ScVSplitPos eVWhich = WhichV(eWhich);
2803
2804 if (mrDoc.IsLayoutRTL(nForTab))
2805 {
2807 {
2808 // mirror horizontal position
2809 if (pView)
2810 aScrSize.setWidth( pView->GetGridWidth(eHWhich) );
2811 nClickX = aScrSize.Width() - 1 - nClickX;
2812 }
2813 }
2814
2815 SCCOL nStartPosX = GetPosX(eHWhich, nForTab);
2816 SCROW nStartPosY = GetPosY(eVWhich, nForTab);
2817 rPosX = nStartPosX;
2818 rPosY = nStartPosY;
2819 tools::Long nScrX = 0;
2820 tools::Long nScrY = 0;
2821
2822 if (nClickX > 0)
2823 {
2824 while (rPosX <= mrDoc.MaxCol() && nClickX >= nScrX)
2825 {
2826 nScrX += ToPixel(mrDoc.GetColWidth(rPosX, nForTab), nPPTX);
2827 ++rPosX;
2828 }
2829 --rPosX;
2830 }
2831 else
2832 {
2833 while ( rPosX>0 && nClickX < nScrX )
2834 {
2835 --rPosX;
2836 nScrX -= ToPixel(mrDoc.GetColWidth(rPosX, nForTab), nPPTX);
2837 }
2838 }
2839
2840 if (nClickY > 0)
2841 AddPixelsWhile(nScrY, nClickY, rPosY, mrDoc.MaxRow(), nPPTY, &mrDoc, nForTab);
2842 else
2843 {
2844 /* TODO: could need some "SubPixelsWhileBackward" method */
2845 while ( rPosY>0 && nClickY < nScrY )
2846 {
2847 --rPosY;
2848 nScrY -= ToPixel(mrDoc.GetRowHeight(rPosY, nForTab), nPPTY);
2849 }
2850 }
2851
2852 // cells too big?
2853 if ( rPosX == nStartPosX && nClickX > 0 )
2854 {
2855 if (pView)
2856 aScrSize.setWidth( pView->GetGridWidth(eHWhich) );
2857 if ( nClickX > aScrSize.Width() )
2858 ++rPosX;
2859 }
2860 if ( rPosY == nStartPosY && nClickY > 0 )
2861 {
2862 if (pView)
2864 if ( nClickY > aScrSize.Height() )
2865 ++rPosY;
2866 }
2867
2868 rPosX = std::clamp(rPosX, SCCOL(0), mrDoc.MaxCol());
2869 rPosY = std::clamp(rPosY, SCROW(0), mrDoc.MaxRow());
2870
2871 if (!(bTestMerge && bForCurTab))
2872 return;
2873
2874 // public method to adapt position
2875 SCCOL nOrigX = rPosX;
2876 SCROW nOrigY = rPosY;
2877 mrDoc.SkipOverlapped(rPosX, rPosY, nTabNo);
2878 bool bHOver = (nOrigX != rPosX);
2879 bool bVOver = (nOrigY != rPosY);
2880
2881 if ( !(bRepair && ( bHOver || bVOver )) )
2882 return;
2883
2884 const ScMergeAttr* pMerge = mrDoc.GetAttr(rPosX, rPosY, nTabNo, ATTR_MERGE);
2885 if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
2886 ( bVOver && pMerge->GetRowMerge() <= 1 ) )
2887 {
2888 OSL_FAIL("merge error found");
2889
2891 SCCOL nEndCol = mrDoc.MaxCol();
2892 SCROW nEndRow = mrDoc.MaxRow();
2893 mrDoc.ExtendMerge(0, 0, nEndCol, nEndRow, nTabNo, true);
2894 if (pDocShell)
2897 }
2898}
2899
2900void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
2901 SCCOL nPosX, SCROW nPosY, bool& rLeft, bool& rTop )
2902{
2903 bool bLayoutRTL = mrDoc.IsLayoutRTL(nTabNo);
2904 tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
2905
2906 Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, true );
2907 tools::Long nSizeX;
2908 tools::Long nSizeY;
2909 GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
2910 rLeft = ( rClickPos.X() - aCellStart.X() ) * nLayoutSign <= nSizeX / 2;
2911 rTop = rClickPos.Y() - aCellStart.Y() <= nSizeY / 2;
2912}
2913
2914void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX )
2915{
2916 // in the tiled rendering case, nPosX [the leftmost visible column] must be 0
2917 bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
2918 if (nNewPosX != 0 && !bIsTiledRendering)
2919 {
2920 SCCOL nOldPosX = pThisTab->nPosX[eWhich];
2921 tools::Long nTPosX = pThisTab->nTPosX[eWhich];
2922 tools::Long nPixPosX = pThisTab->nPixPosX[eWhich];
2923 SCCOL i;
2924 if ( nNewPosX > nOldPosX )
2925 for ( i=nOldPosX; i<nNewPosX; i++ )
2926 {
2928 nTPosX -= nThis;
2929 nPixPosX -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
2930 }
2931 else
2932 for ( i=nNewPosX; i<nOldPosX; i++ )
2933 {
2935 nTPosX += nThis;
2936 nPixPosX += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
2937 }
2938
2939 pThisTab->nPosX[eWhich] = nNewPosX;
2940 pThisTab->nTPosX[eWhich] = nTPosX;
2942 pThisTab->nPixPosX[eWhich] = nPixPosX;
2943 }
2944 else
2945 {
2946 pThisTab->nPixPosX[eWhich] =
2947 pThisTab->nTPosX[eWhich] =
2948 pThisTab->nMPosX[eWhich] =
2949 pThisTab->nPosX[eWhich] = 0;
2950 }
2951}
2952
2953void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY )
2954{
2955 // in the tiled rendering case, nPosY [the topmost visible row] must be 0
2956 bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
2957 if (nNewPosY != 0 && !bIsTiledRendering)
2958 {
2959 SCROW nOldPosY = pThisTab->nPosY[eWhich];
2960 tools::Long nTPosY = pThisTab->nTPosY[eWhich];
2961 tools::Long nPixPosY = pThisTab->nPixPosY[eWhich];
2962 SCROW i, nHeightEndRow;
2963 if ( nNewPosY > nOldPosY )
2964 for ( i=nOldPosY; i<nNewPosY; i++ )
2965 {
2966 tools::Long nThis = mrDoc.GetRowHeight(i, nTabNo, nullptr, &nHeightEndRow);
2967 SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i;
2968 i = nHeightEndRow;
2969 nTPosY -= nThis * nRows;
2970 nPixPosY -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
2971 }
2972 else
2973 for ( i=nNewPosY; i<nOldPosY; i++ )
2974 {
2975 tools::Long nThis = mrDoc.GetRowHeight(i, nTabNo, nullptr, &nHeightEndRow);
2976 SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i;
2977 i = nHeightEndRow;
2978 nTPosY += nThis * nRows;
2979 nPixPosY += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
2980 }
2981
2982 pThisTab->nPosY[eWhich] = nNewPosY;
2983 pThisTab->nTPosY[eWhich] = nTPosY;
2985 pThisTab->nPixPosY[eWhich] = nPixPosY;
2986 }
2987 else
2988 {
2989 pThisTab->nPixPosY[eWhich] =
2990 pThisTab->nTPosY[eWhich] =
2991 pThisTab->nMPosY[eWhich] =
2992 pThisTab->nPosY[eWhich] = 0;
2993 }
2994}
2995
2996void ScViewData::RecalcPixPos() // after zoom changes
2997{
2998 for (sal_uInt16 eWhich=0; eWhich<2; eWhich++)
2999 {
3000 tools::Long nPixPosX = 0;
3001 SCCOL nPosX = pThisTab->nPosX[eWhich];
3002 for (SCCOL i=0; i<nPosX; i++)
3003 nPixPosX -= ToPixel(mrDoc.GetColWidth(i, nTabNo), nPPTX);
3004 pThisTab->nPixPosX[eWhich] = nPixPosX;
3005
3006 tools::Long nPixPosY = 0;
3007 SCROW nPosY = pThisTab->nPosY[eWhich];
3008 tools::Long nRowHeight = -1;
3009 SCROW nLastSameHeightRow = -1;
3010 for (SCROW j=0; j<nPosY; j++)
3011 {
3012 if(nLastSameHeightRow < j)
3013 nRowHeight = ToPixel(mrDoc.GetRowHeight(j, nTabNo, nullptr, &nLastSameHeightRow), nPPTY);
3014 nPixPosY -= nRowHeight;
3015 }
3016 pThisTab->nPixPosY[eWhich] = nPixPosY;
3017 }
3018}
3019
3021{
3023 pThisTab->nMPosY[WhichV(eWhich)] ) );
3024 return aLogicMode;
3025}
3026
3028{
3030 return aLogicMode;
3031}
3032
3033void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
3034{
3035 SCCOL nCol;
3036 SCROW nRow;
3037 sal_uInt16 nTSize;
3038 tools::Long nSizePix;
3039 tools::Long nScrPosX = 0;
3040 tools::Long nScrPosY = 0;
3041
3043 SetPosX( SC_SPLIT_LEFT, nCol1 );
3044 SetPosY( SC_SPLIT_BOTTOM, nRow1 );
3045
3046 for (nCol=nCol1; nCol<=nCol2; nCol++)
3047 {
3048 nTSize = mrDoc.GetColWidth(nCol, nTabNo);
3049 if (nTSize)
3050 {
3051 nSizePix = ToPixel( nTSize, nPPTX );
3052 nScrPosX += static_cast<sal_uInt16>(nSizePix);
3053 }
3054 }
3055
3056 for (nRow=nRow1; nRow<=nRow2; nRow++)
3057 {
3058 nTSize = mrDoc.GetRowHeight(nRow, nTabNo);
3059 if (nTSize)
3060 {
3061 nSizePix = ToPixel( nTSize, nPPTY );
3062 nScrPosY += static_cast<sal_uInt16>(nSizePix);
3063 }
3064 }
3065
3066 aScrSize = Size( nScrPosX, nScrPosY );
3067}
3068
3069void ScViewData::SetScreenPos( const Point& rVisAreaStart )
3070{
3071 tools::Long nSize;
3072 tools::Long nTwips;
3073 tools::Long nAdd;
3074 bool bEnd;
3075
3076 nSize = 0;
3077 nTwips = o3tl::convert(rVisAreaStart.X(), o3tl::Length::mm100, o3tl::Length::twip);
3079 nTwips = -nTwips;
3080 SCCOL nX1 = 0;
3081 bEnd = false;
3082 while (!bEnd)
3083 {
3084 nAdd = static_cast<tools::Long>(mrDoc.GetColWidth(nX1, nTabNo));
3085 if (nSize + nAdd <= nTwips + 1 && nX1 < mrDoc.MaxCol())
3086 {
3087 nSize += nAdd;
3088 ++nX1;
3089 }
3090 else
3091 bEnd = true;
3092 }
3093
3094 nSize = 0;
3095 nTwips = o3tl::convert(rVisAreaStart.Y(), o3tl::Length::mm100, o3tl::Length::twip);
3096 SCROW nY1 = 0;
3097 bEnd = false;
3098 while (!bEnd)
3099 {
3100 nAdd = static_cast<tools::Long>(mrDoc.GetRowHeight(nY1, nTabNo));
3101 if (nSize + nAdd <= nTwips + 1 && nY1 < mrDoc.MaxRow())
3102 {
3103 nSize += nAdd;
3104 ++nY1;
3105 }
3106 else
3107 bEnd = true;
3108 }
3109
3111 SetPosX( SC_SPLIT_LEFT, nX1 );
3112 SetPosY( SC_SPLIT_BOTTOM, nY1 );
3113
3114 SetCurX( nX1 );
3115 SetCurY( nY1 );
3116}
3117
3119{
3120 SetScreenPos( rVisArea.TopLeft() );
3121
3122 // here without GetOutputFactor(), since it's for the output into a Metafile
3123
3124 aScrSize = rVisArea.GetSize();
3127}
3128
3130{
3131 return pDocShell->GetDocFunc();
3132}
3133
3135{
3136 assert(pView && "GetBindings() without ViewShell");
3137 return pView->GetViewFrame().GetBindings();
3138}
3139
3141{
3142 assert(pView && "GetDispatcher() without ViewShell");
3143 return *pView->GetViewFrame().GetDispatcher();
3144}
3145
3147{
3148 return maMarkData;
3149}
3150
3152{
3153 return maMarkData;
3154}
3155
3157{
3158 assert(pView && "GetDialogParent() without ViewShell");
3159 return pView->GetDialogParent();
3160}
3161
3163{
3164 assert(pView && "GetActiveWin() without View");
3165 return pView->GetActiveWin();
3166}
3167
3169{
3170 assert(pView && "GetActiveWin() without View");
3171 return pView->GetActiveWin();
3172}
3173
3175{
3176 assert(pView && "GetScDrawView() without View");
3177 return pView->GetScDrawView();
3178}
3179
3181{
3182 assert(pView && "IsMinimized() without View");
3183 return pView->IsMinimized();
3184}
3185
3186void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY )
3187{
3188 Fraction aOldX = GetZoomX();
3189 Fraction aOldY = GetZoomY();
3190
3191 SetZoom( rNewX, rNewY, false );
3192
3193 Fraction aWidth = GetZoomX();
3194 aWidth *= Fraction( aScrSize.Width(),1 );
3195 aWidth /= aOldX;
3196
3197 Fraction aHeight = GetZoomY();
3198 aHeight *= Fraction( aScrSize.Height(),1 );
3199 aHeight /= aOldY;
3200
3201 aScrSize.setWidth( static_cast<tools::Long>(aWidth) );
3202 aScrSize.setHeight( static_cast<tools::Long>(aHeight) );
3203}
3204
3206{
3207 double nOldPPTX = nPPTX;
3208 double nOldPPTY = nPPTY;
3209 nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(GetZoomX());
3210 if (pDocShell)
3211 nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Factor is printer to screen
3212 nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(GetZoomY());
3213
3214 // if detective objects are present,
3215 // try to adjust horizontal scale so the most common column width has minimal rounding errors,
3216 // to avoid differences between cell and drawing layer output
3217
3219 {
3220 SCCOL nEndCol = 0;
3221 SCROW nDummy = 0;
3222 mrDoc.GetTableArea(nTabNo, nEndCol, nDummy);
3223 if (nEndCol<20)
3224 nEndCol = 20; // same end position as when determining draw scale
3225
3226 sal_uInt16 nTwips = mrDoc.GetCommonWidth(nEndCol, nTabNo);
3227 if ( nTwips )
3228 {
3229 double fOriginal = nTwips * nPPTX;
3230 if ( fOriginal < static_cast<double>(nEndCol) )
3231 {
3232 // if one column is smaller than the column count,
3233 // rounding errors are likely to add up to a whole column.
3234
3235 double fRounded = ::rtl::math::approxFloor( fOriginal + 0.5 );
3236 if ( fRounded > 0.0 )
3237 {
3238 double fScale = fRounded / fOriginal + 1E-6;
3239 if ( fScale >= 0.9 && fScale <= 1.1 )
3240 nPPTX *= fScale;
3241 }
3242 }
3243 }
3244 }
3245
3247 return;
3248
3249 SCTAB nTabCount = maTabData.size();
3250 bool bResetWidths = (nPPTX != nOldPPTX);
3251 bool bResetHeights = (nPPTY != nOldPPTY);
3252 for (SCTAB nTabIdx = 0; nTabIdx < nTabCount; ++nTabIdx)
3253 {
3254 if (!maTabData[nTabIdx])
3255 continue;
3256
3257 if (bResetWidths)
3258 if (auto* pWHelper = GetLOKWidthHelper(nTabIdx))
3259 pWHelper->invalidateByPosition(0L);
3260
3261 if (bResetHeights)
3262 if (auto* pHHelper = GetLOKHeightHelper(nTabIdx))
3263 pHHelper->invalidateByPosition(0L);
3264 }
3265}
3266
3267#define SC_OLD_TABSEP '/'
3268#define SC_NEW_TABSEP '+'
3269
3270void ScViewData::WriteUserData(OUString& rData)
3271{
3272 // nZoom (until 364v) or nZoom/nPageZoom/bPageMode (from 364w)
3273 // nTab
3274 // Tab control width
3275 // per sheet:
3276 // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
3277 // PosX[left]/PosX[right]/PosY[top]/PosY[bottom]
3278 // when rows bigger than 8192, "+" instead of "/"
3279
3280 sal_uInt16 nZoom = static_cast<sal_uInt16>(tools::Long(pThisTab->aZoomY * 100));
3281 rData = OUString::number( nZoom ) + "/";
3282 nZoom = static_cast<sal_uInt16>(tools::Long(pThisTab->aPageZoomY * 100));
3283 rData += OUString::number( nZoom ) + "/";
3284 if (bPagebreak)
3285 rData += "1";
3286 else
3287 rData += "0";
3288
3289 rData += ";" + OUString::number( nTabNo ) + ";" + TAG_TABBARWIDTH +
3290 OUString::number( pView->GetTabBarWidth() );
3291
3292 SCTAB nTabCount = mrDoc.GetTableCount();
3293 for (SCTAB i=0; i<nTabCount; i++)
3294 {
3295 rData += ";"; // Numbering must not get mixed up under any circumstances
3296 if (i < static_cast<SCTAB>(maTabData.size()) && maTabData[i])
3297 {
3298 OUString cTabSep(SC_OLD_TABSEP); // like 3.1
3299 if ( maTabData[i]->nCurY > MAXROW_30 ||
3300 maTabData[i]->nPosY[0] > MAXROW_30 || maTabData[i]->nPosY[1] > MAXROW_30 ||
3301 ( maTabData[i]->eVSplitMode == SC_SPLIT_FIX &&
3302 maTabData[i]->nFixPosY > MAXROW_30 ) )
3303 {
3304 cTabSep = OUStringChar(SC_NEW_TABSEP); // in order to not kill a 3.1-version
3305 }
3306
3307 rData += OUString::number( maTabData[i]->nCurX ) + cTabSep +
3308 OUString::number( maTabData[i]->nCurY ) + cTabSep +
3309 OUString::number( maTabData[i]->eHSplitMode ) + cTabSep +
3310 OUString::number( maTabData[i]->eVSplitMode ) + cTabSep;
3311 if ( maTabData[i]->eHSplitMode == SC_SPLIT_FIX )
3312 rData += OUString::number( maTabData[i]->nFixPosX );
3313 else
3314 rData += OUString::number( maTabData[i]->nHSplitPos );
3315 rData += cTabSep;
3316 if ( maTabData[i]->eVSplitMode == SC_SPLIT_FIX )
3317 rData += OUString::number( maTabData[i]->nFixPosY );
3318 else
3319 rData += OUString::number( maTabData[i]->nVSplitPos );
3320 rData += cTabSep +
3321 OUString::number( maTabData[i]->eWhichActive ) + cTabSep +
3322 OUString::number( maTabData[i]->nPosX[0] ) + cTabSep +
3323 OUString::number( maTabData[i]->nPosX[1] ) + cTabSep +
3324 OUString::number( maTabData[i]->nPosY[0] ) + cTabSep +
3325 OUString::number( maTabData[i]->nPosY[1] );
3326 }
3327 }
3328}
3329
3330void ScViewData::ReadUserData(std::u16string_view rData)
3331{
3332 if (rData.empty()) // empty string on "reload"
3333 return; // then exit without assertion
3334
3335 if ( comphelper::string::getTokenCount(rData, ';') <= 2 )
3336 {
3337 // when reload, in page preview, the preview UserData may have been left intact.
3338 // we don't want the zoom from the page preview here.
3339 OSL_FAIL("ReadUserData: This is not my data");
3340 return;
3341 }
3342
3343 sal_Int32 nMainIdx {0};
3344 sal_Int32 nIdx {0};
3345
3346 std::u16string_view aZoomStr = o3tl::getToken(rData, 0, ';', nMainIdx); // Zoom/PageZoom/Mode
3347 sal_Unicode cMode = o3tl::getToken(aZoomStr, 2, '/', nIdx)[0]; // 0 or "0"/"1"
3348 SetPagebreakMode( cMode == '1' );
3349 // SetPagebreakMode must always be called due to CalcPPT / RecalcPixPos()
3350
3351 // sheet may have become invalid (for instance last version):
3352 SCTAB nNewTab = static_cast<SCTAB>(o3tl::toUInt32(o3tl::getToken(rData, 0, ';', nMainIdx)));
3353 if (mrDoc.HasTable(nNewTab))
3354 SetTabNo(nNewTab);
3355
3356 // if available, get tab bar width:
3357 const sal_Int32 nMainIdxRef {nMainIdx};
3358 std::u16string_view aTabOpt = o3tl::getToken(rData, 0, ';', nMainIdx);
3359
3360 std::u16string_view aRest;
3361 if (o3tl::starts_with(aTabOpt, TAG_TABBARWIDTH, &aRest))
3362 {
3364 }
3365 else
3366 {
3367 // Tab bar width not specified, token to be processed again
3368 nMainIdx = nMainIdxRef;
3369 }
3370
3371 // per sheet
3372 SCTAB nPos = 0;
3373 while ( nMainIdx>0 )
3374 {
3375 aTabOpt = o3tl::getToken(rData, 0, ';', nMainIdx);
3377 if (!maTabData[nPos])
3378 maTabData[nPos].reset(new ScViewDataTable(&mrDoc));
3379
3380 sal_Unicode cTabSep = 0;
3382 cTabSep = SC_OLD_TABSEP;
3383 else if (comphelper::string::getTokenCount(aTabOpt, SC_NEW_TABSEP) >= 11)
3384 cTabSep = SC_NEW_TABSEP;
3385 // '+' is only allowed, if we can deal with rows > 8192
3386
3387 if (cTabSep)
3388 {
3389 nIdx = 0;
3390 maTabData[nPos]->nCurX = mrDoc.SanitizeCol(static_cast<SCCOL>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))));
3391 maTabData[nPos]->nCurY = mrDoc.SanitizeRow(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)));
3392 maTabData[nPos]->eHSplitMode = static_cast<ScSplitMode>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)));
3393 maTabData[nPos]->eVSplitMode = static_cast<ScSplitMode>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)));
3394
3395 sal_Int32 nTmp = o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx));
3396 if ( maTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
3397 {
3398 maTabData[nPos]->nFixPosX = mrDoc.SanitizeCol(static_cast<SCCOL>(nTmp));
3400 }
3401 else
3402 maTabData[nPos]->nHSplitPos = nTmp;
3403
3404 nTmp = o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx));
3405 if ( maTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
3406 {
3407 maTabData[nPos]->nFixPosY = mrDoc.SanitizeRow(nTmp);
3409 }
3410 else
3411 maTabData[nPos]->nVSplitPos = nTmp;
3412
3413 maTabData[nPos]->eWhichActive = static_cast<ScSplitPos>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)));
3414 maTabData[nPos]->nPosX[0] = mrDoc.SanitizeCol(static_cast<SCCOL>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))));
3415 maTabData[nPos]->nPosX[1] = mrDoc.SanitizeCol(static_cast<SCCOL>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))));
3416 maTabData[nPos]->nPosY[0] = mrDoc.SanitizeRow(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)));
3417 maTabData[nPos]->nPosY[1] = mrDoc.SanitizeRow(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)));
3418
3419 maTabData[nPos]->eWhichActive = maTabData[nPos]->SanitizeWhichActive();
3420 }
3421 ++nPos;
3422 }
3423
3424 RecalcPixPos();
3425}
3426
3428{
3429 // *** Fill extended document data for export filters ***
3430
3431 // document settings
3432 ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
3433
3434 // displayed sheet
3435 rDocSett.mnDisplTab = GetTabNo();
3436
3437 // width of the tabbar, relative to frame window width
3439 if( rDocSett.mfTabBarWidth < 0.0 )
3441
3442 bool bLOKActive = comphelper::LibreOfficeKit::isActive();
3443
3444 // sheet settings
3445 for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab )
3446 {
3447 if( const ScViewDataTable* pViewTab = maTabData[ nTab ].get() )
3448 {
3449 ScExtTabSettings& rTabSett = rDocOpt.GetOrCreateTabSettings( nTab );
3450
3451 // split mode
3452 ScSplitMode eExHSplit = pViewTab->eHSplitMode;
3453 ScSplitMode eExVSplit = pViewTab->eVSplitMode;
3454 SCCOL nExFixPosX = pViewTab->nFixPosX;
3455 SCROW nExFixPosY = pViewTab->nFixPosY;
3456 tools::Long nExHSplitPos = pViewTab->nHSplitPos;
3457 tools::Long nExVSplitPos = pViewTab->nVSplitPos;
3458
3459 if (bLOKActive)
3460 {
3461 OverrideWithLOKFreeze(eExHSplit, eExVSplit,
3462 nExFixPosX, nExFixPosY,
3463 nExHSplitPos, nExVSplitPos, nTab);
3464 }
3465
3466 bool bHSplit = eExHSplit != SC_SPLIT_NONE;
3467 bool bVSplit = eExVSplit != SC_SPLIT_NONE;
3468 bool bRealSplit = (eExHSplit == SC_SPLIT_NORMAL) || (eExVSplit == SC_SPLIT_NORMAL);
3469 bool bFrozen = (eExHSplit == SC_SPLIT_FIX) || (eExVSplit == SC_SPLIT_FIX);
3470 OSL_ENSURE( !bRealSplit || !bFrozen, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
3471 rTabSett.mbFrozenPanes = !bRealSplit && bFrozen;
3472
3473 // split and freeze position
3474 rTabSett.maSplitPos = Point( 0, 0 );
3475 rTabSett.maFreezePos.Set( 0, 0, nTab );
3476 if( bRealSplit )
3477 {
3478 Point& rSplitPos = rTabSett.maSplitPos;
3479 rSplitPos = Point( bHSplit ? nExHSplitPos : 0, bVSplit ? nExVSplitPos : 0 );
3480 rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MapUnit::MapTwip ) );
3481 if( pDocShell )
3482 rSplitPos.setX( static_cast<tools::Long>(static_cast<double>(rSplitPos.X()) / pDocShell->GetOutputFactor()) );
3483 }
3484 else if( bFrozen )
3485 {
3486 if( bHSplit ) rTabSett.maFreezePos.SetCol( nExFixPosX );
3487 if( bVSplit ) rTabSett.maFreezePos.SetRow( nExFixPosY );
3488 }
3489
3490 // first visible cell in top-left and additional panes
3491 rTabSett.maFirstVis.Set( pViewTab->nPosX[ SC_SPLIT_LEFT ], pViewTab->nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ], nTab );
3492 rTabSett.maSecondVis.Set( pViewTab->nPosX[ SC_SPLIT_RIGHT ], pViewTab->nPosY[ SC_SPLIT_BOTTOM ], nTab );
3493
3494 // active pane
3495 switch( pViewTab->eWhichActive )
3496 {
3497 // no horizontal split -> always use left panes
3498 // no vertical split -> always use top panes
3499 case SC_SPLIT_TOPLEFT:
3501 break;
3502 case SC_SPLIT_TOPRIGHT:
3504 break;
3507 break;
3509 rTabSett.meActivePane = bHSplit ?
3512 break;
3513 }
3514
3515 // cursor position
3516 rTabSett.maCursor.Set( pViewTab->nCurX, pViewTab->nCurY, nTab );
3517
3518 // sheet selection and selected ranges
3519 const ScMarkData& rMarkData = GetMarkData();
3520 rTabSett.mbSelected = rMarkData.GetTableSelect( nTab );
3521 rMarkData.FillRangeListWithMarks( &rTabSett.maSelection, true );
3522 rTabSett.mbShowGrid = pViewTab->bShowGrid;
3523
3524 // view mode and zoom
3525 rTabSett.mbPageMode = bPagebreak;
3526 rTabSett.mnNormalZoom = static_cast< tools::Long >( pViewTab->aZoomY * Fraction( 100.0 ) );
3527 rTabSett.mnPageZoom = static_cast< tools::Long >( pViewTab->aPageZoomY * Fraction( 100.0 ) );
3528 }
3529 }
3530}
3531
3533{
3534 // *** Get extended document data from import filters ***
3535
3536 if( !rDocOpt.IsChanged() ) return;
3537
3538 // document settings
3539 const ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
3540
3541 // displayed sheet
3542 SetTabNo( rDocSett.mnDisplTab );
3543
3544 /* Width of the tabbar, relative to frame window width. We do not have the
3545 correct width of the frame window here -> store in ScTabView, which sets
3546 the size in the next resize. */
3548
3549 // sheet settings
3550 SCTAB nLastTab = rDocOpt.GetLastTab();
3551 if (static_cast<SCTAB>(maTabData.size()) <= nLastTab)
3552 maTabData.resize(nLastTab+1);
3553
3554 for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab )
3555 {
3556 if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) )
3557 {
3558 if( !maTabData[ nTab ] )
3559 maTabData[nTab].reset(new ScViewDataTable(&mrDoc));
3560
3561 const ScExtTabSettings& rTabSett = *pTabSett;
3562 ScViewDataTable& rViewTab = *maTabData[ nTab ];
3563
3564 // split mode initialization
3565 bool bFrozen = rTabSett.mbFrozenPanes;
3566 bool bHSplit = bFrozen ? (rTabSett.maFreezePos.Col() > 0) : (rTabSett.maSplitPos.X() > 0);
3567 bool bVSplit = bFrozen ? (rTabSett.maFreezePos.Row() > 0) : (rTabSett.maSplitPos.Y() > 0);
3568
3569 // first visible cell of top-left pane and additional panes
3570 if (rTabSett.maFirstVis.IsValid())
3571 {
3572 rViewTab.nPosX[ SC_SPLIT_LEFT ] = rTabSett.maFirstVis.Col();
3573 rViewTab.nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ] = rTabSett.maFirstVis.Row();
3574 }
3575
3576 if (rTabSett.maSecondVis.IsValid())
3577 {
3578 if (bHSplit)
3579 rViewTab.nPosX[ SC_SPLIT_RIGHT ] = rTabSett.maSecondVis.Col();
3580 if (bVSplit)
3581 rViewTab.nPosY[ SC_SPLIT_BOTTOM ] = rTabSett.maSecondVis.Row();
3582 }
3583
3584 // split mode, split and freeze position
3585 rViewTab.eHSplitMode = rViewTab.eVSplitMode = SC_SPLIT_NONE;
3586 rViewTab.nHSplitPos = rViewTab.nVSplitPos = 0;
3587 rViewTab.nFixPosX = 0;
3588 rViewTab.nFixPosY = 0;
3589 if( bFrozen )
3590 {
3591 if( bHSplit )
3592 {
3593 rViewTab.eHSplitMode = SC_SPLIT_FIX;
3594 rViewTab.nFixPosX = rTabSett.maFreezePos.Col();
3595 UpdateFixX( nTab );
3596 }
3597 if( bVSplit )
3598 {
3599 rViewTab.eVSplitMode = SC_SPLIT_FIX;
3600 rViewTab.nFixPosY = rTabSett.maFreezePos.Row();
3601 UpdateFixY( nTab );
3602 }
3603 }
3604 else
3605 {
3607 rTabSett.maSplitPos, MapMode( MapUnit::MapTwip ) );
3608 // the test for use of printer metrics for text formatting here
3609 // effectively results in the nFactor = 1.0 regardless of the Option setting.
3610 if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg())
3611 {
3612 double nFactor = pDocShell->GetOutputFactor();
3613 aPixel.setX( static_cast<tools::Long>( aPixel.X() * nFactor + 0.5 ) );
3614 }
3615
3616 bHSplit = bHSplit && aPixel.X() > 0;
3617 bVSplit = bVSplit && aPixel.Y() > 0;
3618 if( bHSplit )
3619 {
3620 rViewTab.eHSplitMode = SC_SPLIT_NORMAL;
3621 rViewTab.nHSplitPos = aPixel.X();
3622 }
3623 if( bVSplit )
3624 {
3625 rViewTab.eVSplitMode = SC_SPLIT_NORMAL;
3626 rViewTab.nVSplitPos = aPixel.Y();
3627 }
3628 }
3629
3630 // active pane
3632 switch( rTabSett.meActivePane )
3633 {
3634 // no horizontal split -> always use left panes
3635 // no vertical split -> always use *bottom* panes
3636 case SCEXT_PANE_TOPLEFT:
3638 break;
3640 ePos = bHSplit ?
3643 break;
3646 break;
3649 break;
3650 }
3651 rViewTab.eWhichActive = ePos;
3652
3653 // cursor position
3654 const ScAddress& rCursor = rTabSett.maCursor;
3655 if( rCursor.IsValid() )
3656 {
3657 rViewTab.nCurX = rCursor.Col();
3658 rViewTab.nCurY = rCursor.Row();
3659 }
3660
3661 // sheet selection and selected ranges
3662 ScMarkData& rMarkData = GetMarkData();
3663 rMarkData.SelectTable( nTab, rTabSett.mbSelected );
3664
3665 // zoom for each sheet
3666 if( rTabSett.mnNormalZoom )
3667 rViewTab.aZoomX = rViewTab.aZoomY = Fraction( rTabSett.mnNormalZoom, 100 );
3668 if( rTabSett.mnPageZoom )
3669 rViewTab.aPageZoomX = rViewTab.aPageZoomY = Fraction( rTabSett.mnPageZoom, 100 );
3670
3671 rViewTab.bShowGrid = rTabSett.mbShowGrid;
3672
3673 // get some settings from displayed Excel sheet, set at Calc document
3674 if( nTab == GetTabNo() )
3675 {
3676 // view mode and default zoom (for new sheets) from current sheet
3677 if( rTabSett.mnNormalZoom )
3678 aDefZoomX = aDefZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
3679 if( rTabSett.mnPageZoom )
3680 aDefPageZoomX = aDefPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
3681 /* #i46820# set pagebreak mode via SetPagebreakMode(), this will
3682 update map modes that are needed to draw text correctly. */
3683 SetPagebreakMode( rTabSett.mbPageMode );
3684 }
3685 }
3686 }
3687
3690
3691 // RecalcPixPos or so - also nMPos - also for ReadUserData ??!?!
3692}
3693
3694void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings) const
3695{
3696 rSettings.realloc(SC_VIEWSETTINGS_COUNT);
3697 // + 1, because we have to put the view id in the sequence
3698 beans::PropertyValue* pSettings = rSettings.getArray();
3699
3700 sal_uInt16 nViewID(pView->GetViewFrame().GetCurViewId());
3701 pSettings[SC_VIEW_ID].Name = SC_VIEWID;
3702 pSettings[SC_VIEW_ID].Value <<= SC_VIEW + OUString::number(nViewID);
3703
3704 uno::Reference<container::XNameContainer> xNameContainer =
3705 document::NamedPropertyValues::create( comphelper::getProcessComponentContext() );
3706 for (SCTAB nTab=0; nTab<static_cast<SCTAB>(maTabData.size()); nTab++)
3707 {
3708 if (maTabData[nTab])
3709 {
3710 uno::Sequence <beans::PropertyValue> aTableViewSettings;
3711 maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab);
3712 OUString sTabName;
3713 GetDocument().GetName( nTab, sTabName );
3714 try
3715 {
3716 xNameContainer->insertByName(sTabName, uno::Any(aTableViewSettings));
3717 }
3718 //#101739#; two tables with the same name are possible
3719 catch ( container::ElementExistException& )
3720 {
3721 OSL_FAIL("seems there are two tables with the same name");
3722 }
3723 catch ( uno::RuntimeException& )
3724 {
3725 OSL_FAIL("something went wrong");
3726 }
3727 }
3728 }
3729 pSettings[SC_TABLE_VIEWSETTINGS].Name = SC_TABLES;
3730 pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
3731
3732 OUString sName;
3734 pSettings[SC_ACTIVE_TABLE].Name = SC_ACTIVETABLE;
3735 pSettings[SC_ACTIVE_TABLE].Value <<= sName;
3737 pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32(pView->GetTabBarWidth());
3738 sal_Int32 nZoomValue = tools::Long(pThisTab->aZoomY * 100);
3739 sal_Int32 nPageZoomValue = tools::Long(pThisTab->aPageZoomY * 100);
3740 pSettings[SC_ZOOM_TYPE].Name = SC_ZOOMTYPE;
3741 pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16(pThisTab->eZoomType);
3742 pSettings[SC_ZOOM_VALUE].Name = SC_ZOOMVALUE;
3743 pSettings[SC_ZOOM_VALUE].Value <<= nZoomValue;
3745 pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
3747 pSettings[SC_PAGE_BREAK_PREVIEW].Value <<= bPagebreak;
3748
3749 pSettings[SC_SHOWZERO].Name = SC_UNO_SHOWZERO;
3750 pSettings[SC_SHOWZERO].Value <<= maOptions.GetOption(VOPT_NULLVALS);
3751 pSettings[SC_SHOWNOTES].Name = SC_UNO_SHOWNOTES;
3752 pSettings[SC_SHOWNOTES].Value <<= maOptions.GetOption(VOPT_NOTES);
3755 pSettings[SC_SHOWGRID].Name = SC_UNO_SHOWGRID;
3756 pSettings[SC_SHOWGRID].Value <<= maOptions.GetOption(VOPT_GRID);
3757 pSettings[SC_GRIDCOLOR].Name = SC_UNO_GRIDCOLOR;
3758 OUString aColorName;
3759 Color aColor = maOptions.GetGridColor(&aColorName);
3760 pSettings[SC_GRIDCOLOR].Value <<= aColor;
3761 pSettings[SC_SHOWPAGEBR].Name = SC_UNO_SHOWPAGEBR;
3762 pSettings[SC_SHOWPAGEBR].Value <<= maOptions.GetOption(VOPT_PAGEBREAKS);
3763 pSettings[SC_COLROWHDR].Name = SC_UNO_COLROWHDR;
3764 pSettings[SC_COLROWHDR].Value <<= maOptions.GetOption(VOPT_HEADER);
3765 pSettings[SC_SHEETTABS].Name = SC_UNO_SHEETTABS;
3766 pSettings[SC_SHEETTABS].Value <<= maOptions.GetOption(VOPT_TABCONTROLS);
3767 pSettings[SC_OUTLSYMB].Name = SC_UNO_OUTLSYMB;
3768 pSettings[SC_OUTLSYMB].Value <<= maOptions.GetOption(VOPT_OUTLINER);
3769 pSettings[SC_VALUE_HIGHLIGHTING].Name = SC_UNO_VALUEHIGH;
3772 pSettings[SC_FORMULA_BAR_HEIGHT_VALUE].Value <<= GetFormulaBarLines();;
3773
3774 const ScGridOptions& aGridOpt = maOptions.GetGridOptions();
3775 pSettings[SC_SNAPTORASTER].Name = SC_UNO_SNAPTORASTER;
3776 pSettings[SC_SNAPTORASTER].Value <<= aGridOpt.GetUseGridSnap();
3777 pSettings[SC_RASTERVIS].Name = SC_UNO_RASTERVIS;
3778 pSettings[SC_RASTERVIS].Value <<= aGridOpt.GetGridVisible();
3779 pSettings[SC_RASTERRESX].Name = SC_UNO_RASTERRESX;
3780 pSettings[SC_RASTERRESX].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDrawX());
3781 pSettings[SC_RASTERRESY].Name = SC_UNO_RASTERRESY;
3782 pSettings[SC_RASTERRESY].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDrawY());
3783 pSettings[SC_RASTERSUBX].Name = SC_UNO_RASTERSUBX;
3784 pSettings[SC_RASTERSUBX].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDivisionX());
3785 pSettings[SC_RASTERSUBY].Name = SC_UNO_RASTERSUBY;
3786 pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDivisionY());
3787 pSettings[SC_RASTERSYNC].Name = SC_UNO_RASTERSYNC;
3788 pSettings[SC_RASTERSYNC].Value <<= aGridOpt.GetSynchronize();
3789
3790 // Common SdrModel processing
3792}
3793
3794void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
3795{
3796 std::vector<bool> aHasZoomVect( GetDocument().GetTableCount(), false );
3797
3798 sal_Int32 nTemp32(0);
3799 sal_Int16 nTemp16(0);
3800 sal_Int16 nFormulaBarLineCount(0);
3801 bool bPageMode(false);
3802
3803 EnsureTabDataSize(GetDocument().GetTableCount());
3804
3805 for (const auto& rSetting : rSettings)
3806 {
3807 // SC_VIEWID has to parse and use by mba
3808 OUString sName(rSetting.Name);
3809 if (sName == SC_TABLES)
3810 {
3811 uno::Reference<container::XNameContainer> xNameContainer;
3812 if ((rSetting.Value >>= xNameContainer) && xNameContainer->hasElements())
3813 {
3814 const uno::Sequence< OUString > aNames(xNameContainer->getElementNames());
3815 for (const OUString& sTabName : aNames)
3816 {
3817 SCTAB nTab(0);
3818 if (GetDocument().GetTable(sTabName, nTab))
3819 {
3820 uno::Any aAny = xNameContainer->getByName(sTabName);
3821 uno::Sequence<beans::PropertyValue> aTabSettings;
3822 if (aAny >>= aTabSettings)
3823 {
3824 EnsureTabDataSize(nTab + 1);
3825 if (!maTabData[nTab])
3826 maTabData[nTab].reset(new ScViewDataTable(&mrDoc));
3827
3828 bool bHasZoom = false;
3829 maTabData[nTab]->ReadUserDataSequence(aTabSettings, *this, nTab, bHasZoom);
3830 aHasZoomVect[nTab] = bHasZoom;
3831 }
3832 }
3833 }
3834 }
3835 }
3836 else if (sName == SC_ACTIVETABLE)
3837 {
3838 OUString sTabName;
3839 if(rSetting.Value >>= sTabName)
3840 {
3841 SCTAB nTab(0);
3842 if (GetDocument().GetTable(sTabName, nTab))
3843 nTabNo = nTab;
3844 }
3845 }
3847 {
3848 if (rSetting.Value >>= nTemp32)
3849 pView->SetTabBarWidth(nTemp32);
3850 }
3852 {
3853 double fWidth = 0.0;
3854 if (rSetting.Value >>= fWidth)
3856 }
3857 else if (sName == SC_ZOOMTYPE)
3858 {
3859 if (rSetting.Value >>= nTemp16)
3860 eDefZoomType = SvxZoomType(nTemp16);
3861 }
3862 else if (sName == SC_ZOOMVALUE)
3863 {
3864 if (rSetting.Value >>= nTemp32)
3865 {
3866 Fraction aZoom(nTemp32, 100);
3867 aDefZoomX = aDefZoomY = aZoom;
3868 }
3869 }
3870 else if (sName == SC_PAGEVIEWZOOMVALUE)
3871 {
3872 if (rSetting.Value >>= nTemp32)
3873 {
3874 Fraction aZoom(nTemp32, 100);
3875 aDefPageZoomX = aDefPageZoomY = aZoom;
3876 }
3877 }
3878 else if (sName == SC_FORMULABARHEIGHT)
3879 {
3880 if (rSetting.Value >>= nFormulaBarLineCount)
3881 {
3882 SetFormulaBarLines(nFormulaBarLineCount);
3883 // Notify formula bar about changed lines
3884 ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
3885 if (pInputHdl)
3886 {
3887 ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
3888 if (pInputWin)
3889 pInputWin->NumLinesChanged();
3890 }
3891 }
3892 }
3893 else if (sName == SC_SHOWPAGEBREAKPREVIEW)
3894 bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value );
3895 else if ( sName == SC_UNO_SHOWZERO )
3897 else if ( sName == SC_UNO_SHOWNOTES )
3899 else if ( sName == SC_UNO_SHOWFORMULASMARKS )
3901 else if ( sName == SC_UNO_SHOWGRID )
3903 else if ( sName == SC_UNO_GRIDCOLOR )
3904 {
3905 Color aColor;
3906 if (rSetting.Value >>= aColor)
3907 maOptions.SetGridColor(aColor, OUString());
3908 }
3909 else if ( sName == SC_UNO_SHOWPAGEBR )
3911 else if ( sName == SC_UNO_COLROWHDR )
3913 else if ( sName == SC_UNO_SHEETTABS )
3915 else if ( sName == SC_UNO_OUTLSYMB )
3917 else if ( sName == SC_UNO_SHOWOBJ )
3918 {
3919 // #i80528# placeholders not supported anymore
3920 if ( rSetting.Value >>= nTemp16 )
3922 }
3923 else if ( sName == SC_UNO_SHOWCHARTS )
3924 {
3925 // #i80528# placeholders not supported anymore
3926 if ( rSetting.Value >>= nTemp16 )
3928 }
3929 else if ( sName == SC_UNO_SHOWDRAW )
3930 {
3931 // #i80528# placeholders not supported anymore
3932 if ( rSetting.Value >>= nTemp16 )
3934 }
3937 else
3938 {
3940 if ( sName == SC_UNO_SNAPTORASTER )
3941 aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value ) );
3942 else if ( sName == SC_UNO_RASTERVIS )
3943 aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value ) );
3944 else if ( sName == SC_UNO_RASTERRESX )
3945 aGridOpt.SetFieldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3946 else if ( sName == SC_UNO_RASTERRESY )
3947 aGridOpt.SetFieldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3948 else if ( sName == SC_UNO_RASTERSUBX )
3949 aGridOpt.SetFieldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3950 else if ( sName == SC_UNO_RASTERSUBY )
3951 aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3952 else if ( sName == SC_UNO_RASTERSYNC )
3953 aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value ) );
3954 // Fallback to common SdrModel processing
3956
3957 maOptions.SetGridOptions(aGridOpt);
3958 }
3959 }
3960
3961 // copy default zoom to sheets where a different one wasn't specified
3962 for (SCTAB nZoomTab=0; nZoomTab< static_cast<SCTAB>(maTabData.size()); ++nZoomTab)
3963 if (maTabData[nZoomTab] && ( nZoomTab >= static_cast<SCTAB>(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] ))
3964 {
3965 maTabData[nZoomTab]->eZoomType = eDefZoomType;
3966 maTabData[nZoomTab]->aZoomX = aDefZoomX;
3967 maTabData[nZoomTab]->aZoomY = aDefZoomY;
3968 maTabData[nZoomTab]->aPageZoomX = aDefPageZoomX;
3969 maTabData[nZoomTab]->aPageZoomY = aDefPageZoomY;
3970 }
3971
3972 if (rSettings.hasElements())
3973 SetPagebreakMode( bPageMode );
3974
3975 // #i47426# write view options to document, needed e.g. for Excel export
3977
3980}
3981
3983{
3984 // if visibility of horizontal ScrollBar is changed, TabBar may have to be resized...
3985 bool bHScrollChanged = (rOpt.GetOption(VOPT_HSCROLL) != maOptions.GetOption(VOPT_HSCROLL));
3986
3987 // if graphics are turned on or off, animation has to be started or stopped
3988 // graphics are controlled by VOBJ_TYPE_OLE
3989 bool bGraphicsChanged = (maOptions.GetObjMode(VOBJ_TYPE_OLE) !=
3990 rOpt.GetObjMode(VOBJ_TYPE_OLE) );
3991
3992 maOptions = rOpt;
3993 OSL_ENSURE( pView, "No View" );
3994
3995 if( pView )
3996 {
3997 pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged );
3998 }
3999}
4000
4002{
4003 OSL_ENSURE( pView, "GetMousePosPixel() without View" );
4004 return pView->GetMousePosPixel();
4005}
4006
4008{
4009 if (pView)
4010 pView->UpdateInputHandler(bForce);
4011}
4012
4014{
4015 return pDocShell && pDocShell->IsOle();
4016}
4017
4018bool ScViewData::UpdateFixX( SCTAB nTab ) // true = value changed
4019{
4020 if (!ValidTab(nTab)) // Default
4021 nTab=nTabNo; // current table
4022
4023 if (!pView || maTabData[nTab]->eHSplitMode != SC_SPLIT_FIX)
4024 return false;
4025
4026 ScDocument& rLocalDoc = GetDocument();
4027 if (!rLocalDoc.HasTable(nTab)) // if called from reload, the sheet may not exist
4028 return false;
4029
4030 SCCOL nFix = maTabData[nTab]->nFixPosX;
4031 tools::Long nNewPos = 0;
4032 for (SCCOL nX=maTabData[nTab]->nPosX[SC_SPLIT_LEFT]; nX<nFix; nX++)
4033 {
4034 sal_uInt16 nTSize = rLocalDoc.GetColWidth( nX, nTab );
4035 if (nTSize)
4036 {
4037 tools::Long nPix = ToPixel( nTSize, nPPTX );
4038 nNewPos += nPix;
4039 }
4040 }
4041 nNewPos += pView->GetGridOffset().X();
4042 if (nNewPos != maTabData[nTab]->nHSplitPos)
4043 {
4044 maTabData[nTab]->nHSplitPos = nNewPos;
4045 if (nTab == nTabNo)
4046 RecalcPixPos(); // should not be needed
4047 return true;
4048 }
4049
4050 return false;
4051}
4052
4053bool ScViewData::UpdateFixY( SCTAB nTab ) // true = value changed
4054{
4055 if (!ValidTab(nTab)) // Default
4056 nTab=nTabNo; // current table
4057
4058 if (!pView || maTabData[nTab]->eVSplitMode != SC_SPLIT_FIX)
4059 return false;
4060
4061 ScDocument& rLocalDoc = GetDocument();
4062 if (!rLocalDoc.HasTable(nTab)) // if called from reload, the sheet may not exist
4063 return false;
4064
4065 SCROW nFix = maTabData[nTab]->nFixPosY;
4066 tools::Long nNewPos = 0;
4067 for (SCROW nY=maTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++)
4068 {
4069 sal_uInt16 nTSize = rLocalDoc.GetRowHeight( nY, nTab );
4070 if (nTSize)
4071 {
4072 tools::Long nPix = ToPixel( nTSize, nPPTY );
4073 nNewPos += nPix;
4074 }
4075 }
4076 nNewPos += pView->GetGridOffset().Y();
4077 if (nNewPos != maTabData[nTab]->nVSplitPos)
4078 {
4079 maTabData[nTab]->nVSplitPos = nNewPos;
4080 if (nTab == nTabNo)
4081 RecalcPixPos(); // should not be needed
4082 return true;
4083 }
4084
4085 return false;
4086}
4087
4089{
4090 ScDocument& rLocalDoc = GetDocument();
4091 bool bOnlineSpell = rLocalDoc.GetDocOptions().IsAutoSpell();
4092
4093 EEControlBits nCntrl = rOutl.GetControlWord();
4094 nCntrl |= EEControlBits::MARKNONURLFIELDS;
4095 nCntrl &= ~EEControlBits::MARKURLFIELDS; // URLs not shaded for output
4096 nCntrl |= EEControlBits::AUTOCORRECT;
4097 if( bOnlineSpell )
4098 nCntrl |= EEControlBits::ONLINESPELLING;
4099 else
4100 nCntrl &= ~EEControlBits::ONLINESPELLING;
4101 rOutl.SetControlWord(nCntrl);
4102
4103 rOutl.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule, CalcFieldValueHdl ) );
4104
4105 // don't call GetSpellChecker if online spelling isn't enabled.
4106 // The language for AutoCorrect etc. is taken from the pool defaults
4107 // (set in ScDocument::UpdateDrawLanguages)
4108
4109 if ( bOnlineSpell )
4110 {
4111 css::uno::Reference<css::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
4112 rOutl.SetSpeller( xXSpellChecker1 );
4113 }
4114
4116 rLocalDoc.GetEditTextDirection( nTabNo ) );
4117}
4118
4120{
4121 return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
4122}
4123
4124void ScViewData::SetRefStart( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
4125{
4126 nRefStartX = nNewX; nRefStartY = nNewY; nRefStartZ = nNewZ;
4127}
4128
4129void ScViewData::SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
4130{
4131 nRefEndX = nNewX; nRefEndY = nNewY; nRefEndZ = nNewZ;
4132}
4133
4134void ScViewData::AddPixelsWhile( tools::Long & rScrY, tools::Long nEndPixels, SCROW & rPosY,
4135 SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
4136{
4137 SCROW nRow = rPosY;
4138 while (rScrY <= nEndPixels && nRow <= nEndRow)
4139 {
4140 SCROW nHeightEndRow;
4141 sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, nullptr, &nHeightEndRow);
4142 if (nHeightEndRow > nEndRow)
4143 nHeightEndRow = nEndRow;
4144 if (!nHeight)
4145 {
4146 if (ValidTab(nTabNo) && nTabNo <= pDoc->GetMaxTableNumber())
4147 nRow = nHeightEndRow + 1;
4148 else
4149 break;
4150 }
4151 else
4152 {
4153 SCROW nRows = nHeightEndRow - nRow + 1;
4154 sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
4155 sal_Int64 nAdd = nPixel * nRows;
4156 if (nAdd + rScrY > nEndPixels)
4157 {
4158 sal_Int64 nDiff = rScrY + nAdd - nEndPixels;
4159 nRows -= static_cast<SCROW>(nDiff / nPixel);
4160 nAdd = nPixel * nRows;
4161 // We're looking for a value that satisfies loop condition.
4162 if (nAdd + rScrY <= nEndPixels)
4163 {
4164 ++nRows;
4165 nAdd += nPixel;
4166 }
4167 }
4168 rScrY += static_cast<tools::Long>(nAdd);
4169 nRow += nRows;
4170 }
4171 }
4172 if (nRow > rPosY)
4173 --nRow;
4174 rPosY = nRow;
4175}
4176
4178 SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
4179 SCTAB nTabNo )
4180{
4181 SCROW nRow = rPosY;
4182 while (rScrY <= nEndPixels && nRow >= nStartRow)
4183 {
4184 SCROW nHeightStartRow;
4185 sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, nullptr);
4186 if (nHeightStartRow < nStartRow)
4187 nHeightStartRow = nStartRow;
4188 if (!nHeight)
4189 nRow = nHeightStartRow - 1;
4190 else
4191 {
4192 SCROW nRows = nRow - nHeightStartRow + 1;
4193 sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
4194 sal_Int64 nAdd = nPixel * nRows;
4195 if (nAdd + rScrY > nEndPixels)
4196 {
4197 sal_Int64 nDiff = nAdd + rScrY - nEndPixels;
4198 nRows -= static_cast<SCROW>(nDiff / nPixel);
4199 nAdd = nPixel * nRows;
4200 // We're looking for a value that satisfies loop condition.
4201 if (nAdd + rScrY <= nEndPixels)
4202 {
4203 ++nRows;
4204 nAdd += nPixel;
4205 }
4206 }
4207 rScrY += static_cast<tools::Long>(nAdd);
4208 nRow -= nRows;
4209 }
4210 }
4211 if (nRow < rPosY)
4212 ++nRow;
4213 rPosY = nRow;
4214}
4215
4217{
4218 SCCOLROW nFreezeIndex = bIsCol ? mrDoc.GetLOKFreezeCol(nTabNo) : mrDoc.GetLOKFreezeRow(nTabNo);
4219 return nFreezeIndex >= 0 ? nFreezeIndex : 0;
4220}
4221
4222bool ScViewData::SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab)
4223{
4224 if (nForTab == -1)
4225 {
4226 nForTab = nTabNo;
4227 }
4228 else if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))
4229 {
4230 SAL_WARN("sc.viewdata", "ScViewData::SetLOKSheetFreezeIndex : invalid nForTab = " << nForTab);
4231 return false;
4232 }
4233
4234 return bIsCol ? mrDoc.SetLOKFreezeCol(static_cast<SCCOL>(nFreezeIndex), nForTab)
4235 : mrDoc.SetLOKFreezeRow(static_cast<SCROW>(nFreezeIndex), nForTab);
4236}
4237
4239{
4240 bool colUnfreezed = SetLOKSheetFreezeIndex(0, true);
4241 bool rowUnfreezed = SetLOKSheetFreezeIndex(0, false);
4242 return colUnfreezed || rowUnfreezed;
4243}
4244
4246{
4247 SCTAB nMaxTab = static_cast<SCTAB>(maTabData.size()) - 1;
4248 for (SCTAB nTab = 0; nTab <= nMaxTab; ++nTab)
4250}
4251
4253{
4254 if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))
4255 {
4256 SAL_WARN("sc.viewdata", "ScViewData::DeriveLOKFreezeIfNeeded : invalid nForTab = " << nForTab);
4257 return;
4258 }
4259
4260 ScViewDataTable* pViewTable = maTabData[nForTab].get();
4261 if (!pViewTable)
4262 return;
4263
4264 bool bConvertToFreezeX = false;
4265 bool bConvertToFreezeY = false;
4266 SCCOL nFreezeCol = mrDoc.GetLOKFreezeCol(nForTab);
4267 SCROW nFreezeRow = mrDoc.GetLOKFreezeRow(nForTab);
4268
4269 if (nFreezeCol == -1)
4270 {
4271 ScSplitMode eSplitMode = pViewTable->eHSplitMode;
4272 if (eSplitMode == SC_SPLIT_FIX)
4273 nFreezeCol = pViewTable->nFixPosX;
4274 else if (eSplitMode == SC_SPLIT_NORMAL)
4275 bConvertToFreezeX = true;
4276 else
4277 nFreezeCol = 0;
4278 }
4279
4280 if (nFreezeRow == -1)
4281 {
4282 ScSplitMode eSplitMode = pViewTable->eVSplitMode;
4283 if (eSplitMode == SC_SPLIT_FIX)
4284 nFreezeRow = pViewTable->nFixPosY;
4285 else if (eSplitMode == SC_SPLIT_NORMAL)
4286 bConvertToFreezeY = true;
4287 else
4288 nFreezeRow = 0;
4289 }
4290
4291 if (bConvertToFreezeX || bConvertToFreezeY)
4292 {
4293 SCCOL nCol;
4294 SCROW nRow;
4295 GetPosFromPixel(bConvertToFreezeX ? pViewTable->nHSplitPos : 0,
4296 bConvertToFreezeY ? pViewTable->nVSplitPos : 0,
4297 SC_SPLIT_BOTTOMLEFT, nCol, nRow,
4298 false /* bTestMerge */, false /* bRepair */,
4299 nForTab);
4300 if (bConvertToFreezeX)
4301 nFreezeCol = nCol;
4302 if (bConvertToFreezeY)
4303 nFreezeRow = nRow;
4304 }
4305
4306 mrDoc.SetLOKFreezeCol(nFreezeCol, nForTab);
4307 mrDoc.SetLOKFreezeRow(nFreezeRow, nForTab);
4308}
4309
4311 SCCOL& nExFixPosX, SCROW& nExFixPosY,
4312 tools::Long& nExHSplitPos, tools::Long& nExVSplitPos, SCTAB nForTab) const
4313{
4314 SCCOL nFreezeCol = mrDoc.GetLOKFreezeCol(nForTab);
4315 SCROW nFreezeRow = mrDoc.GetLOKFreezeRow(nForTab);
4316
4317 bool bConvertToScrPosX = false;
4318 bool bConvertToScrPosY = false;
4319
4320 if (nFreezeCol >= 0)
4321 {
4322 if (eExHSplitMode == SC_SPLIT_NONE)
4323 eExHSplitMode = SC_SPLIT_FIX;
4324
4325 if (eExHSplitMode == SC_SPLIT_FIX)
4326 {
4327 nExFixPosX = nFreezeCol;
4328 pThisTab->nPosX[SC_SPLIT_RIGHT] = nFreezeCol;
4329 }
4330 else
4331 bConvertToScrPosX = true;
4332 }
4333
4334 if (nFreezeRow >= 0)
4335 {
4336 if (eExVSplitMode == SC_SPLIT_NONE)
4337 eExVSplitMode = SC_SPLIT_FIX;
4338
4339 if (eExVSplitMode == SC_SPLIT_FIX)
4340 {
4341 nExFixPosY = nFreezeRow;
4342 pThisTab->nPosY[SC_SPLIT_BOTTOM] = nFreezeRow;
4343 }
4344 else
4345 bConvertToScrPosY = true;
4346 }
4347
4348 if (bConvertToScrPosX || bConvertToScrPosY)
4349 {
4350 Point aExSplitPos = GetScrPos(nFreezeCol, nFreezeRow, SC_SPLIT_BOTTOMLEFT, true, nForTab);
4351 if (bConvertToScrPosX)
4352 nExHSplitPos = aExSplitPos.X();
4353 if (bConvertToScrPosY)
4354 nExVSplitPos = aExSplitPos.Y();
4355 }
4356}
4357
4358/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::chart::ChartAxisLabelPosition ePos
#define SC_HORIZONTAL_SPLIT_POSITION
#define SC_RASTERRESY
#define SC_TABLESELECTED
#define SC_VERTICALSPLITPOSITION_TWIPS
#define SC_SHOWGRID
#define SC_TABLE_VIEWSETTINGS
#define SC_TABLE_ZOOM_VALUE
#define SC_VERTICAL_SPLIT_MODE
#define SC_VIEWSETTINGS_COUNT
#define SC_HORIZONTAL_SPLIT_MODE
#define SC_GRIDCOLOR
#define SC_OUTLSYMB
#define SC_RASTERVIS
#define SC_POSITION_RIGHT
constexpr OUStringLiteral SC_ACTIVESPLITRANGE
constexpr OUStringLiteral SC_SHOWPAGEBREAKPREVIEW
constexpr OUStringLiteral SC_HORIZONTALSCROLLBARWIDTH
constexpr OUStringLiteral SC_TABLES
#define SC_ACTIVE_TABLE
#define SC_VERTICAL_SPLIT_POSITION
constexpr OUStringLiteral SC_POSITIONRIGHT
#define SC_VIEW_ID
#define SC_FORMULA_BAR_HEIGHT_VALUE
#define SC_RELHORIZONTALTABBARWIDTH
constexpr OUStringLiteral SC_ZOOMVALUE
constexpr OUStringLiteral SC_CURSORPOSITIONY
#define SC_RASTERSUBY
#define SC_SHOWNOTES
constexpr OUStringLiteral SC_VERTICALSPLITMODE
#define SC_CURSOR_Y
#define SC_ZOOM_TYPE
#define SC_TABLE_SHOWGRID
#define SC_VALUE_HIGHLIGHTING
constexpr OUStringLiteral SC_POSITIONBOTTOM
constexpr OUStringLiteral SC_VERTICALSPLITPOSITION
constexpr OUStringLiteral SC_POSITIONLEFT
constexpr OUStringLiteral SC_VIEWID
#define SC_SHOWZERO
constexpr OUStringLiteral SC_ZOOMTYPE
constexpr OUStringLiteral SC_HORIZONTALSPLITPOSITION
#define SC_POSITION_TOP
#define SC_RASTERSYNC
#define SC_ACTIVE_SPLIT_RANGE
#define SC_ZOOM_VALUE
#define SC_PAGE_VIEW_ZOOM_VALUE
constexpr OUStringLiteral SC_CURSORPOSITIONX
#define SC_HORIZONTAL_SCROLL_BAR_WIDTH
#define SC_SHOWFORMULASMARKS
#define SC_SNAPTORASTER
#define SC_COLROWHDR
constexpr OUStringLiteral SC_PAGEVIEWZOOMVALUE
constexpr OUStringLiteral SC_FORMULABARHEIGHT
constexpr OUStringLiteral SC_ACTIVETABLE
#define SC_RASTERSUBX
#define SC_CURSOR_X
#define SC_POSITION_LEFT
#define SC_TABLE_PAGE_VIEW_ZOOM_VALUE
#define SC_HORIZONTALSPLITPOSITION_TWIPS
#define SC_TABLE_ZOOM_TYPE
#define SC_TABLE_VIEWSETTINGS_COUNT
#define SC_PAGE_BREAK_PREVIEW
constexpr OUStringLiteral SC_POSITIONTOP
#define SC_SHOWPAGEBR
constexpr OUStringLiteral SC_HORIZONTALSPLITMODE
#define SC_SHEETTABS
#define SC_RASTERRESX
#define SC_POSITION_BOTTOM
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
const SCROW MAXTILEDROW
Definition: address.hxx:77
const SCTAB MAXTAB
Definition: address.hxx:70
const SCROW MAXROW_30
Definition: address.hxx:97
const SCCOL SC_TABSTART_NONE
Definition: address.hxx:95
const SCTAB SC_TAB_APPEND
Definition: address.hxx:90
static OutputDevice * GetDefaultDevice()
bool IsTransparent() const
OUString GetText(LineEnd eEnd=LINEEND_LF) const
bool SetUpdateLayout(bool bUpdate, bool bRestoring=false)
EEControlBits GetControlWord() const
sal_Int32 GetParagraphCount() const
const Size & GetPaperSize() const
EditView * RemoveView(EditView *pEditView)
sal_uInt32 GetTextHeight() const
bool IsEffectivelyVertical() const
sal_uInt32 CalcTextWidth()
void SetControlWord(EEControlBits nWord)
void SetStatusEventHdl(const Link< EditStatus &, void > &rLink)
void SetPaperSize(const Size &rSize)
void SetLOKSpecialPaperSize(const Size &rSize)
void InsertView(EditView *pEditView, size_t nIndex=EE_APPEND)
const Size & GetLOKSpecialPaperSize() const
void SetLOKSpecialVisArea(const tools::Rectangle &rVisArea)
void SetControlWord(EVControlBits nWord)
void InvalidateOtherViewWindows(const tools::Rectangle &rInvRect)
void SetOutputArea(const tools::Rectangle &rRect)
tools::Rectangle GetVisArea() const
tools::Rectangle GetLOKSpecialVisArea() const
vcl::Window * GetWindow() const
EditEngine * GetEditEngine() const
const tools::Rectangle & GetOutputArea() const
void SetLOKSpecialOutputArea(const tools::Rectangle &rOutputArea)
const tools::Rectangle & GetLOKSpecialOutputArea() const
void SetVisArea(const tools::Rectangle &rRect)
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
void SetOrigin(const Point &rOrigin)
void SetScaleY(const Fraction &rScaleY)
void SetScaleX(const Fraction &rScaleX)
EEControlBits GetControlWord() const
void SetSpeller(css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller)
void SetControlWord(EEControlBits nWord)
void SetCalcFieldValueHdl(const Link< EditFieldInfo *, void > &rLink)
void SetDefaultHorizontalTextDirection(EEHorizontalTextDirection eHTextDir)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
constexpr tools::Long Y() const
void setX(tools::Long nX)
constexpr tools::Long X() const
constexpr tools::Long getX() const
constexpr tools::Long getY() const
@ UNINITIALIZED
Definition: address.hxx:220
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:403
void SetCol(SCCOL nColP)
Definition: address.hxx:291
bool IsValid() const
Definition: address.hxx:305
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
SCCOL Col() const
Definition: address.hxx:279
void GetIndexAndPos(index_type nNearestIndex, tools::Long nNearestPosition, tools::Long nBound, index_type &nFoundIndex, tools::Long &nPosition, bool bTowards, tools::Long nDiff)
Definition: viewdata.cxx:336
void GetIndexTowards(index_type nNearestIndex, tools::Long nNearestPosition, tools::Long nBound, index_type &nFoundIndex, tools::Long &nPosition, bool bTowards)
Definition: viewdata.cxx:460
const SCTAB nTab
Definition: viewdata.hxx:158
ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader)
Definition: viewdata.cxx:289
const bool bColumnHeader
Definition: viewdata.hxx:159
ScPositionHelper::value_type value_type
Definition: viewdata.hxx:154
tools::Long nSecondPositionPx
Definition: viewdata.hxx:167
void EnlargeStartBy(tools::Long nOffset)
Definition: viewdata.cxx:408
void GetEndIndexAndPosition(SCCOL &nIndex, tools::Long &nPosition) const
Definition: viewdata.cxx:309
const index_type MAX_INDEX
Definition: viewdata.hxx:160
index_type nFirstIndex
Definition: viewdata.hxx:164
SCCOLROW index_type
Definition: viewdata.hxx:155
tools::Long nFirstPositionPx
Definition: viewdata.hxx:166
index_type nSecondIndex
Definition: viewdata.hxx:165
tools::Long GetSize(index_type nIndex) const
Definition: viewdata.cxx:330
void GeIndexBackwards(index_type nNearestIndex, tools::Long nNearestPosition, tools::Long nBound, index_type &nFoundIndex, tools::Long &nPosition, bool bTowards)
Definition: viewdata.cxx:436
void Compute(value_type aFirstNearest, value_type aSecondNearest, tools::Long nFirstBound, tools::Long nSecondBound)
Definition: viewdata.cxx:348
void EnlargeEndBy(tools::Long nOffset)
Definition: viewdata.cxx:423
void GetStartIndexAndPosition(SCCOL &nIndex, tools::Long &nPosition) const
Definition: viewdata.cxx:302
ScDocument & rDoc
Definition: viewdata.hxx:157
bool IsAutoSpell() const
Definition: docoptio.hxx:53
bool IsOle() const
Definition: docsh6.cxx:147
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
double GetOutputFactor() const
Definition: docsh.hxx:358
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:221
SCROW SanitizeRow(SCROW nRow) const
Definition: document.hxx:906
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:4980
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4161
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4122
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5556
bool SetLOKFreezeCol(SCCOL nFreezeCol, SCTAB nTab)
ScClipParam & GetClipParam()
Definition: document.cxx:2564
EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const
Definition: documen8.cxx:355
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const
Definition: document.cxx:928
bool HasDetectiveObjects(SCTAB nTab) const
Definition: documen9.cxx:504
bool SetLOKFreezeRow(SCROW nFreezeRow, SCTAB nTab)
SCCOL GetLOKFreezeCol(SCTAB nTab) const
sal_uInt16 GetCommonWidth(SCCOL nEndCol, SCTAB nTab) const
Definition: document.cxx:4145
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1957
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4416
SC_DLLPUBLIC CRFlags GetRowFlags(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4335
SC_DLLPUBLIC bool GetTableArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bCalcHiddens=false) const
Definition: document.cxx:1008
SCROW GetLOKFreezeRow(SCTAB nTab) const
SCCOL SanitizeCol(SCCOL nCol) const
Definition: document.hxx:905
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4430
void SkipOverlapped(SCCOL &rCol, SCROW &rRow, SCTAB nTab) const
Definition: document.cxx:5709
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:890
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:974
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:2502
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:204
SC_DLLPUBLIC void SetTabBgColor(SCTAB nTab, const Color &rColor)
Definition: documen3.cxx:456
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4684
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1936
SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:4454
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
void SetDefaultItem(const SfxPoolItem &rItem)
Set the item in the default ItemSet which is created if it doesn't exist yet.
Definition: editutil.cxx:598
tools::Rectangle GetEditArea(const ScPatternAttr *pPattern, bool bForceToTop)
Definition: editutil.cxx:338
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:77
const ScExtDocSettings & GetDocSettings() const
Definition: scextopt.cxx:170
SCTAB GetLastTab() const
Definition: scextopt.cxx:185
ScExtTabSettings & GetOrCreateTabSettings(SCTAB nTab)
Definition: scextopt.cxx:190
bool IsChanged() const
Definition: scextopt.cxx:160
const ScExtTabSettings * GetTabSettings(SCTAB nTab) const
Definition: scextopt.cxx:180
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
Definition: global.hxx:589
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
Definition: global.hxx:591
ScInputWindow * GetInputWindow()
Definition: inputhdl.hxx:264
void NumLinesChanged()
Update Input bar after the number of lines was changed externally.
Definition: inputwin.cxx:735
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
const_iterator end() const
Definition: markdata.hxx:164
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:157
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
void SelectOneTable(SCTAB nTab)
Definition: markdata.cxx:174
bool IsMultiMarked() const
Definition: markdata.hxx:81
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:372
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:169
bool IsMarked() const
Definition: markdata.hxx:80
void InsertTab(SCTAB nTab)
Definition: markdata.cxx:633
const_iterator begin() const
Definition: markdata.hxx:163
std::set< SCTAB >::const_iterator const_iterator
Definition: markdata.hxx:161
void DeleteTab(SCTAB nTab)
Definition: markdata.cxx:646
void MarkToSimple()
Definition: markdata.cxx:222
SCCOL GetColMerge() const
Definition: attrib.hxx:71
SCROW GetRowMerge() const
Definition: attrib.hxx:72
svtools::ColorConfig & GetColorConfig()
Definition: scmod.cxx:887
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:73
bool operator()(const value_type &rValue1, const value_type &rValue2) const
Definition: viewdata.cxx:115
void removeByIndex(index_type nIndex)
Definition: viewdata.cxx:150
const value_type & getNearestByPosition(tools::Long nPos) const
Definition: viewdata.cxx:224
tools::Long computePosition(index_type nIndex, const std::function< long(index_type)> &getSizePx)
Definition: viewdata.cxx:262
std::set< value_type, Comp > mData
Definition: viewdata.hxx:136
const value_type & getNearestByIndex(index_type nIndex) const
Definition: viewdata.cxx:194
tools::Long getPosition(index_type nIndex) const
Definition: viewdata.cxx:255
std::pair< index_type, tools::Long > value_type
Definition: viewdata.hxx:123
ScPositionHelper(const ScDocument *pDoc, bool bColumn)
Definition: viewdata.cxx:127
void invalidateByPosition(tools::Long nPos)
Definition: viewdata.cxx:178
static const index_type null
Definition: viewdata.hxx:127
void setDocument(const ScDocument &rDoc, bool bColumn)
Definition: viewdata.cxx:133
void invalidateByIndex(index_type nIndex)
Definition: viewdata.cxx:163
void insert(index_type nIndex, tools::Long nPos)
Definition: viewdata.cxx:138
SCCOLROW index_type
Definition: viewdata.hxx:122
index_type MAX_INDEX
Definition: viewdata.hxx:135
void GetVars(SCCOL &nCol1, SCROW &nRow1, SCTAB &nTab1, SCCOL &nCol2, SCROW &nRow2, SCTAB &nTab2) const
Definition: address.hxx:690
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
Definition: tabvwshc.cxx:519
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:690
weld::Window * GetDialogParent()
parent window for dialogs Problem: OLE Server!
Definition: tabvwshd.cxx:31
static SC_DLLPUBLIC double GetRelTabBarWidth()
Returns the current tab bar width relative to the frame window width (0.0 ... 1.0).
Definition: tabview.cxx:873
void ViewOptionsHasChanged(bool bHScrollChanged, bool bGraphicsChanged)
Definition: tabview5.cxx:454
Point GetGridOffset() const
Definition: tabview.cxx:909
tools::Long GetGridWidth(ScHSplitPos eWhich)
Definition: tabview3.cxx:3017
tools::Long GetGridHeight(ScVSplitPos eWhich)
Definition: tabview3.cxx:3039
void SetTabBarWidth(tools::Long nNewWidth)
Sets an absolute tab bar width (in pixels).
Definition: tabview.cxx:844
ScGridWindow * GetActiveWin()
Definition: tabview.cxx:878
Point GetMousePosPixel()
Definition: tabview.cxx:1979
ScDrawView * GetScDrawView()
Definition: tabview.hxx:352
tools::Long GetTabBarWidth() const
Returns the current tab bar width in pixels.
Definition: tabview.cxx:868
bool IsMinimized() const
Definition: tabview.hxx:354
double GetPendingRelTabBarWidth() const
Returns the pending tab bar width relative to the frame window width (0.0 ... 1.0).
Definition: tabview.hxx:320
void SetPendingRelTabBarWidth(double fRelTabBarWidth)
Sets a relative tab bar width.
Definition: tabview.cxx:862
ScDocument * GetDocument() const
Definition: transobj.hxx:82
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: transobj.cxx:199
static sal_Int32 GetInt32FromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:153
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:139
void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &rSettings, ScViewData &rViewData, SCTAB nTab, bool &rHasZoom)
Definition: viewdata.cxx:606
tools::Long nTPosY[2]
Definition: viewdata.hxx:217
SCROW nPosY[2]
Y position of the top left cell of the visible area.
Definition: viewdata.hxx:241
ScPositionHelper aWidthHelper
Definition: viewdata.hxx:237
ScSplitPos eWhichActive
Definition: viewdata.hxx:227
tools::Long nPixPosX[2]
Definition: viewdata.hxx:220
tools::Long nPixPosY[2]
Definition: viewdata.hxx:221
SvxZoomType eZoomType
Definition: viewdata.hxx:210
SCCOL nPosX[2]
X position of the top left cell of the visible area.
Definition: viewdata.hxx:240
tools::Long nHSplitPos
Definition: viewdata.hxx:222
ScSplitPos SanitizeWhichActive() const
Sanitize the active split range value to not point into a grid window that would never be initialized...
Definition: viewdata.cxx:744
Fraction aPageZoomY
Definition: viewdata.hxx:214
void InitData(const ScDocument &rDoc)
Definition: viewdata.cxx:523
void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &rSettings, const ScViewData &rViewData, SCTAB nTab) const
Definition: viewdata.cxx:529
tools::Long nMPosX[2]
Definition: viewdata.hxx:218
SCCOL nMaxTiledCol
Definition: viewdata.hxx:242
tools::Long nTPosX[2]
Definition: viewdata.hxx:216
Fraction aZoomX
Definition: viewdata.hxx:211
tools::Long nMPosY[2]
Definition: viewdata.hxx:219
tools::Long nVSplitPos
Definition: viewdata.hxx:223
bool mbOldCursorValid
Definition: viewdata.hxx:246
ScViewDataTable(const ScDocument *pDoc=nullptr)
Definition: viewdata.cxx:489
Fraction aZoomY
Definition: viewdata.hxx:212
ScSplitMode eVSplitMode
Definition: viewdata.hxx:226
ScSplitMode eHSplitMode
Definition: viewdata.hxx:225
Fraction aPageZoomX
Definition: viewdata.hxx:213
ScPositionHelper aHeightHelper
Definition: viewdata.hxx:238
SCROW nMaxTiledRow
Definition: viewdata.hxx:243
void RefreshZoom()
Definition: viewdata.cxx:1116
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1205
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3140
SCROW GetOldCurY() const
Definition: viewdata.cxx:1383
void SetFillMode(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow)
Definition: viewdata.cxx:1342
bool RemoveLOKFreeze()
Definition: viewdata.cxx:4238
Point GetPrintTwipsPos(SCCOL nCol, SCROW nRow) const
returns the position (top-left corner) of the requested cell in print twips coordinates.
Definition: viewdata.cxx:2556
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: viewdata.cxx:3033
bool IsMinimized() const
Definition: viewdata.cxx:3180
Fraction aDefZoomX
Definition: viewdata.hxx:291
void OverrideWithLOKFreeze(ScSplitMode &eExHSplitMode, ScSplitMode &eExVSplitMode, SCCOL &nExFixPosX, SCROW &nExFixPosY, tools::Long &nExHSplitPos, tools::Long &nExVSplitPos, SCTAB nForTab) const
Definition: viewdata.cxx:4310
void SetPagebreakMode(bool bSet)
Definition: viewdata.cxx:1127
Point GetMousePosPixel()
Definition: viewdata.cxx:4001
ScViewData(ScDocument *pDoc, ScDocShell *pDocSh, ScTabViewShell *pViewSh)
Definition: viewdata.cxx:780
void DeleteTabs(SCTAB nTab, SCTAB nSheets)
Definition: viewdata.cxx:929
SCTAB nTabNo
Definition: viewdata.hxx:298
bool SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab=-1)
Definition: viewdata.cxx:4222
SCCOL CellsAtX(SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeY=SC_SIZE_NONE) const
Definition: viewdata.cxx:2634
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3982
static void AddPixelsWhile(tools::Long &rScrY, tools::Long nEndPixels, SCROW &rPosY, SCROW nEndRow, double nPPTY, const ScDocument *pDoc, SCTAB nTabNo)
while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row heights converted with nPPTY to rSc...
Definition: viewdata.cxx:4134
void DeriveLOKFreezeAllSheets()
Definition: viewdata.cxx:4245
SCTAB nRefEndZ
Definition: viewdata.hxx:305
ScTabViewShell * pView
Definition: viewdata.hxx:280
bool GetMergeSizePixel(SCCOL nX, SCROW nY, tools::Long &rSizeXPix, tools::Long &rSizeYPix) const
Definition: viewdata.cxx:2732
SCCOL nEditEndCol
Definition: viewdata.hxx:313
bool UpdateFixX(SCTAB nTab=MAXTAB+1)
Definition: viewdata.cxx:4018
SAL_DLLPRIVATE void EnsureTabDataSize(size_t nSize)
Definition: viewdata.cxx:2313
void DeleteTab(SCTAB nTab)
Definition: viewdata.cxx:915
void SetFormulaBarLines(sal_Int16 nLines)
Definition: viewdata.hxx:471
Fraction aDefZoomY
Definition: viewdata.hxx:292
std::unique_ptr< EditView > pEditView[4]
Definition: viewdata.hxx:281
void EditGrowX()
Extend the output area for the edit engine view in a horizontal direction as needed.
Definition: viewdata.cxx:1847
SAL_DLLPRIVATE void UpdateCurrentTab()
Definition: viewdata.cxx:866
bool SimpleColMarked()
Definition: viewdata.cxx:1230
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: viewdata.cxx:1025
ScDocFunc & GetDocFunc() const
Definition: viewdata.cxx:3129
SCCOL nEditStartCol
Definition: viewdata.hxx:312
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3146
SCROW GetCurYForTab(SCTAB nTabIndex) const
Definition: viewdata.cxx:1439
bool SimpleRowMarked()
Definition: viewdata.cxx:1245
void KillEditView()
Definition: viewdata.cxx:2268
void GetMouseQuadrant(const Point &rClickPos, ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, bool &rLeft, bool &rTop)
Definition: viewdata.cxx:2900
SCROW nRefStartY
Definition: viewdata.hxx:301
SCCOL GetCurXForTab(SCTAB nTabIndex) const
Definition: viewdata.cxx:1431
SCTAB nRefStartZ
Definition: viewdata.hxx:302
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
void RecalcPixPos()
Definition: viewdata.cxx:2996
SvxZoomType eDefZoomType
Definition: viewdata.hxx:290
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
void SetTabNo(SCTAB nNewTab)
Definition: viewdata.cxx:2319
void SetCurYForTab(SCCOL nNewCurY, SCTAB nTabIndex)
Definition: viewdata.cxx:1455
ScSplitPos eEditActivePart
Definition: viewdata.hxx:320
bool SelectionForbidsPaste(ScDocument *pClipDoc=nullptr)
Disallow Paste on Ctrl+A all selected or another high amount of selected cells that is not the same s...
Definition: viewdata.cxx:1270
void InsertTab(SCTAB nTab)
Definition: viewdata.cxx:882
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScPositionHelper & GetLOKHeightHelper()
Definition: viewdata.hxx:411
SAL_DLLPRIVATE void CalcPPT()
Definition: viewdata.cxx:3205
SCROW GetPosY(ScVSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1417
SCCOLROW GetLOKSheetFreezeIndex(bool bIsCol) const
Definition: viewdata.cxx:4216
bool bGrowing
Definition: viewdata.hxx:331
SCCOL nFillEndX
Definition: viewdata.hxx:308
bool bEditActive[4]
Definition: viewdata.hxx:323
SCCOL nRefStartX
Definition: viewdata.hxx:300
void SetScreenPos(const Point &rVisAreaStart)
Definition: viewdata.cxx:3069
void SetPosY(ScVSplitPos eWhich, SCROW nNewPosY)
Definition: viewdata.cxx:2953
void EditGrowY(bool bInitial=false)
Extend the output area for the edit engine view in a vertical direction as needed.
Definition: viewdata.cxx:2139
SCCOL nFillStartX
Definition: viewdata.hxx:306
MapMode aLogicMode
Definition: viewdata.hxx:288
SAL_DLLPRIVATE void CreateSelectedTabData()
Definition: viewdata.cxx:2307
Size aScenButSize
Definition: viewdata.hxx:285
SCROW nFillEndY
Definition: viewdata.hxx:309
double GetPPTY() const
Definition: viewdata.hxx:469
void UpdateInputHandler(bool bForce=false)
Definition: viewdata.cxx:4007
ScDocument & mrDoc
Definition: viewdata.hxx:279
void SetCurXForTab(SCCOL nNewCurX, SCTAB nTabIndex)
Definition: viewdata.cxx:1447
SCCOL GetOldCurX() const
Definition: viewdata.cxx:1375
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3162
bool UpdateFixY(SCTAB nTab=MAXTAB+1)
Definition: viewdata.cxx:4053
OString describeCellCursorAt(SCCOL nCol, SCROW nRow, bool bPixelAligned=true) const
Definition: viewdata.cxx:2583
void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &rSettings) const
Definition: viewdata.cxx:3694
static bool SelectionFillDOOM(const ScRange &rRange)
Determine DOOM condition, i.e. from selected range.
Definition: viewdata.cxx:1328
void GetPosFromPixel(tools::Long nClickX, tools::Long nClickY, ScSplitPos eWhich, SCCOL &rPosX, SCROW &rPosY, bool bTestMerge=true, bool bRepair=false, SCTAB nForTab=-1)
Definition: viewdata.cxx:2785
void SetRefEnd(SCCOL nNewX, SCROW nNewY, SCTAB nNewZ)
Definition: viewdata.cxx:4129
ScDocShell * pDocShell
Definition: viewdata.hxx:278
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
void SetShowGrid(bool bShow)
Definition: viewdata.cxx:1110
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1182
static tools::Long ToPixel(sal_uInt16 nTwips, double nFactor)
Definition: viewdata.hxx:700
void InsertTabs(SCTAB nTab, SCTAB nNewSheets)
Definition: viewdata.cxx:896
ScDBFunc * GetView() const
Definition: viewdata.cxx:864
~ScViewData() COVERITY_NOEXCEPT_FALSE
Definition: viewdata.cxx:859
SCROW nEditRow
Definition: viewdata.hxx:311
void UpdateOutlinerFlags(Outliner &rOutl) const
Definition: viewdata.cxx:4088
void UpdateScreenZoom(const Fraction &rNewX, const Fraction &rNewY)
Definition: viewdata.cxx:3186
void GetFillData(SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow)
Definition: viewdata.cxx:1366
ScMarkData maMarkData
Definition: viewdata.hxx:276
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2717
const MapMode & GetLogicMode()
Definition: viewdata.cxx:3027
SCCOL nRefEndX
Definition: viewdata.hxx:303
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
void SetMaxTiledCol(SCCOL nCol)
Definition: viewdata.cxx:1463
void ResetOldCursor()
Definition: viewdata.cxx:1398
void ResetFillMode()
Definition: viewdata.cxx:1361
void GetEditView(ScSplitPos eWhich, EditView *&rViewPtr, SCCOL &rCol, SCROW &rRow)
Definition: viewdata.cxx:2284
weld::Window * GetDialogParent()
Definition: viewdata.cxx:3156
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
Definition: viewdata.cxx:2380
SCCOL nEditCol
Definition: viewdata.hxx:310
ScViewDataTable * pThisTab
Definition: viewdata.hxx:277
void SetActivePart(ScSplitPos eNewActive)
Definition: viewdata.cxx:2355
::std::vector< std::unique_ptr< ScViewDataTable > > maTabData
Definition: viewdata.hxx:275
void ResetEditView()
Definition: viewdata.cxx:2248
ScPositionHelper & GetLOKWidthHelper()
Definition: viewdata.hxx:410
void SetDragMode(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScFillMode nMode)
Definition: viewdata.cxx:1351
SCROW CellsAtY(SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeX=SC_SIZE_NONE) const
Definition: viewdata.cxx:2676
void ReadUserData(std::u16string_view rData)
Definition: viewdata.cxx:3330
void CopyTab(SCTAB nSrcTab, SCTAB nDestTab)
Definition: viewdata.cxx:944
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, std::vector< SCTAB > &tabs)
Definition: viewdata.cxx:1036
static void AddPixelsWhileBackward(tools::Long &rScrY, tools::Long nEndPixels, SCROW &rPosY, SCROW nStartRow, double nPPTY, const ScDocument *pDoc, SCTAB nTabNo)
while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row heights converted with nPPTY to r...
Definition: viewdata.cxx:4177
bool IsMultiMarked() const
Definition: viewdata.cxx:1260
void WriteUserData(OUString &rData)
Definition: viewdata.cxx:3270
SCCOL PrevCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2722
SCCOL nTabStartCol
Definition: viewdata.hxx:315
void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &rSettings)
Definition: viewdata.cxx:3794
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2712
void SetMaxTiledRow(SCROW nRow)
Definition: viewdata.cxx:1485
void SetOldCursor(SCCOL nNewX, SCROW nNewY)
Definition: viewdata.cxx:1391
const Fraction & GetZoomX() const
Definition: viewdata.hxx:459
void DeriveLOKFreezeIfNeeded(SCTAB nForTab)
Definition: viewdata.cxx:4252
tools::Rectangle GetEditArea(ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, vcl::Window *pWin, const ScPatternAttr *pPattern, bool bForceToTop, bool bInPrintTwips=false)
Definition: viewdata.cxx:1510
SCROW nEditEndRow
Definition: viewdata.hxx:314
SCROW PrevCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2727
Point GetPrintTwipsPosFromTileTwips(const Point &rTileTwipsPos) const
Definition: viewdata.cxx:2568
ScAddress GetCurPos() const
Definition: viewdata.cxx:4119
double nPPTY
Definition: viewdata.hxx:273
SvxAdjust GetEditAdjust() const
Definition: viewdata.hxx:518
double nPPTX
Definition: viewdata.hxx:273
Fraction aDefPageZoomX
Definition: viewdata.hxx:293
void SetPosX(ScHSplitPos eWhich, SCCOL nNewPosX)
Definition: viewdata.cxx:2914
double GetPPTX() const
Definition: viewdata.hxx:468
void SetEditEngine(ScSplitPos eWhich, ScEditEngineDefaulter *pNewEngine, vcl::Window *pWin, SCCOL nNewX, SCROW nNewY)
Definition: viewdata.cxx:1521
ScViewOptions maOptions
Definition: viewdata.hxx:282
bool GetMergeSizePrintTwips(SCCOL nX, SCROW nY, tools::Long &rSizeXTwips, tools::Long &rSizeYTwips) const
Definition: viewdata.cxx:2769
bool bActive
Definition: viewdata.hxx:324
bool IsOle() const
Definition: viewdata.cxx:4013
SfxBindings & GetBindings()
Definition: viewdata.cxx:3134
bool bPagebreak
Definition: viewdata.hxx:327
void MoveTab(SCTAB nSrcTab, SCTAB nDestTab)
Definition: viewdata.cxx:969
SCROW GetCurY() const
Definition: viewdata.hxx:402
Size aScrSize
Definition: viewdata.hxx:287
SCROW nFillStartY
Definition: viewdata.hxx:307
Fraction aDefPageZoomY
Definition: viewdata.hxx:294
bool bMoveArea
Definition: viewdata.hxx:329
void WriteExtOptions(ScExtDocOptions &rOpt) const
Definition: viewdata.cxx:3427
void SetCurX(SCCOL nNewCurX)
Definition: viewdata.hxx:431
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3174
SCCOL GetCurX() const
Definition: viewdata.hxx:401
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1403
SAL_DLLPRIVATE void CreateTabData(SCTAB nNewTab)
Definition: viewdata.cxx:2291
SCROW nRefEndY
Definition: viewdata.hxx:304
bool SelectionForbidsCellFill()
Disallow cell fill (Fill,Enter,...) on Ctrl+A all selected or another high amount of selected cells.
Definition: viewdata.cxx:1320
void ReadExtOptions(const ScExtDocOptions &rOpt)
Definition: viewdata.cxx:3532
ScFillMode nFillMode
Definition: viewdata.hxx:321
void SetCurY(SCROW nNewCurY)
Definition: viewdata.hxx:432
void SetRefStart(SCCOL nNewX, SCROW nNewY, SCTAB nNewZ)
Definition: viewdata.cxx:4124
sal_Int16 GetFormulaBarLines() const
Definition: viewdata.hxx:478
void SetGridColor(const Color &rCol, const OUString &rName)
Definition: viewopti.hxx:91
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:85
void SetObjMode(ScVObjType eObj, ScVObjMode eMode)
Definition: viewopti.hxx:88
const ScGridOptions & GetGridOptions() const
Definition: viewopti.hxx:94
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:86
Color const & GetGridColor(OUString *pStrName=nullptr) const
Definition: viewopti.cxx:123
ScVObjMode GetObjMode(ScVObjType eObj) const
Definition: viewopti.hxx:89
void SetGridOptions(const ScGridOptions &rNew)
Definition: viewopti.hxx:95
static bool HasFiltered(const ScRange &rRange, const ScDocument &rDoc)
Definition: viewutil.cxx:271
void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue)
void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &rValues)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
static void forEachOtherView(ViewShellType *pThisViewShell, FunctionType f)
SfxBindings & GetBindings()
SfxInterfaceId GetCurViewId() const
SfxDispatcher * GetDispatcher()
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
bool GetGridVisible() const
bool GetUseGridSnap() const
void SetFieldDrawX(sal_uInt32 nSet)
void SetUseGridSnap(bool bSet)
void SetFieldDrawY(sal_uInt32 nSet)
sal_uInt32 GetFieldDivisionY() const
bool GetSynchronize() const
void SetSynchronize(bool bSet)
sal_uInt32 GetFieldDrawY() const
void SetGridVisible(bool bSet)
void SetFieldDivisionY(sal_uInt32 nSet)
void SetFieldDivisionX(sal_uInt32 nSet)
sal_uInt32 GetFieldDrawX() const
sal_uInt32 GetFieldDivisionX() const
static UITestLogger & getInstance()
void logEvent(const EventDescription &rDescription)
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
constexpr tools::Long GetWidth() const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr void SetRight(tools::Long v)
constexpr Size GetSize() const
constexpr tools::Long Right() const
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
T * get() const
::OutputDevice const * GetOutDev() const
Point PixelToLogic(const Point &rDevicePt) const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr double nPPTX
constexpr double nPPTY
float u
EEControlBits
EditStatusFlags
EVControlBits
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
DocumentType eType
OUString sName
#define MAX_INDEX
@ VOBJ_MODE_SHOW
Definition: global.hxx:369
@ VOBJ_MODE_HIDE
Definition: global.hxx:370
#define OLE_STD_CELLS_X
Definition: global.hxx:104
#define OLE_STD_CELLS_Y
Definition: global.hxx:105
constexpr sal_Int32 STD_COL_WIDTH
Definition: global.hxx:87
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
MapUnit
bool isCompatFlagSet(Compat flag)
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
Reference< XComponentContext > getProcessComponentContext()
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix=10)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
constexpr auto HMM_PER_TWIPS
Definition: output2.cxx:97
@ SCEXT_PANE_BOTTOMLEFT
Bottom, or bottom-left pane.
Definition: scextopt.hxx:42
@ SCEXT_PANE_BOTTOMRIGHT
Bottom-right pane.
Definition: scextopt.hxx:43
@ SCEXT_PANE_TOPLEFT
Single, top, left, or top-left pane.
Definition: scextopt.hxx:40
@ SCEXT_PANE_TOPRIGHT
Right, or top-right pane.
Definition: scextopt.hxx:41
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
#define SC_MOD()
Definition: scmod.hxx:247
#define nPixel
std::map< OUString, OUString > aParameters
ScRange getWholeRange() const
Return a single range that encompasses all individual ranges.
Definition: clipparam.cxx:109
Extended settings for the document, used in import/export filters.
Definition: scextopt.hxx:28
double mfTabBarWidth
Width of the tabbar, relative to frame window width (0.0 ... 1.0).
Definition: scextopt.hxx:30
SCTAB mnDisplTab
Index of displayed sheet.
Definition: scextopt.hxx:32
Extended settings for a sheet, used in import/export filters.
Definition: scextopt.hxx:48
Point maSplitPos
Position of split.
Definition: scextopt.hxx:55
bool mbFrozenPanes
true = Frozen panes; false = Normal splits.
Definition: scextopt.hxx:61
ScAddress maSecondVis
Top-left visible cell in add. panes (column/row only).
Definition: scextopt.hxx:53
ScAddress maCursor
The cursor position (column/row only).
Definition: scextopt.hxx:51
bool mbShowGrid
Whether or not to display gridlines.
Definition: scextopt.hxx:63
ScExtPanePos meActivePane
Active (focused) pane.
Definition: scextopt.hxx:56
ScRangeList maSelection
Selected cell ranges (columns/rows only).
Definition: scextopt.hxx:50
ScAddress maFirstVis
Top-left visible cell (column/row only).
Definition: scextopt.hxx:52
tools::Long mnPageZoom
Zoom in percent for pagebreak preview.
Definition: scextopt.hxx:59
bool mbSelected
true = Sheet is selected.
Definition: scextopt.hxx:60
bool mbPageMode
true = Pagebreak mode; false = Normal view mode.
Definition: scextopt.hxx:62
ScAddress maFreezePos
Position of frozen panes (column/row only).
Definition: scextopt.hxx:54
tools::Long mnNormalZoom
Zoom in percent for normal view.
Definition: scextopt.hxx:58
SvxCellHorJustify
SvxAdjust
@ Left
Definition: tphfedit.hxx:40
sal_uInt16 sal_Unicode
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
constexpr OUStringLiteral SC_UNO_SHOWGRID
Definition: unonames.hxx:558
constexpr OUStringLiteral SC_UNO_OUTLSYMB
Definition: unonames.hxx:552
constexpr OUStringLiteral SC_UNO_RASTERVIS
Definition: unonames.hxx:568
constexpr OUStringLiteral SC_UNO_SHOWFORMULASMARKS
Definition: unonames.hxx:561
constexpr OUStringLiteral SC_UNO_SHOWNOTES
Definition: unonames.hxx:560
constexpr OUStringLiteral SC_UNO_SHOWOBJ
Definition: unonames.hxx:562
constexpr OUStringLiteral SC_UNO_SHOWDRAW
Definition: unonames.hxx:556
constexpr OUStringLiteral SC_UNO_SHOWPAGEBR
Definition: unonames.hxx:563
constexpr OUStringLiteral SC_UNO_SHEETTABS
Definition: unonames.hxx:553
constexpr OUStringLiteral SC_UNO_RASTERSUBX
Definition: unonames.hxx:571
constexpr OUStringLiteral SC_UNO_COLROWHDR
Definition: unonames.hxx:548
constexpr OUStringLiteral SC_UNONAME_TABCOLOR
Definition: unonames.hxx:191
constexpr OUStringLiteral SC_UNO_RASTERSUBY
Definition: unonames.hxx:572
constexpr OUStringLiteral SC_UNO_RASTERSYNC
Definition: unonames.hxx:573
constexpr OUStringLiteral SC_UNO_RASTERRESX
Definition: unonames.hxx:569
constexpr OUStringLiteral SC_UNO_SHOWCHARTS
Definition: unonames.hxx:555
constexpr OUStringLiteral SC_UNO_GRIDCOLOR
Definition: unonames.hxx:549
constexpr OUStringLiteral SC_UNO_SHOWZERO
Definition: unonames.hxx:564
constexpr OUStringLiteral SC_UNO_RASTERRESY
Definition: unonames.hxx:570
constexpr OUStringLiteral SC_UNO_SNAPTORASTER
Definition: unonames.hxx:567
constexpr OUStringLiteral SC_UNO_VALUEHIGH
Definition: unonames.hxx:565
#define stringstream
Definition: utils.hxx:45
constexpr OUStringLiteral PERCENT(u"Percent")
#define SC_GROWY_SMALL_EXTRA
Definition: viewdata.cxx:77
#define SC_GROWY_BIG_EXTRA
Definition: viewdata.cxx:78
#define SC_OLD_TABSEP
Definition: viewdata.cxx:3267
IMPL_LINK(ScViewData, EditEngineHdl, EditStatus &, rStatus, void)
Definition: viewdata.cxx:1830
constexpr OUStringLiteral TAG_TABBARWIDTH
Definition: viewdata.cxx:80
#define SC_NEW_TABSEP
Definition: viewdata.cxx:3268
static ScViewOptions DefaultOptions()
Definition: viewdata.cxx:766
ScSplitPos
Definition: viewdata.hxx:44
@ SC_SPLIT_BOTTOMRIGHT
Definition: viewdata.hxx:44
@ SC_SPLIT_TOPLEFT
Definition: viewdata.hxx:44
@ SC_SPLIT_BOTTOMLEFT
Definition: viewdata.hxx:44
@ SC_SPLIT_POS_MAX_ENUM
Definition: viewdata.hxx:44
@ SC_SPLIT_TOPRIGHT
Definition: viewdata.hxx:44
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:722
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:61
@ SC_MARK_MULTI
Definition: viewdata.hxx:70
@ SC_MARK_NONE
Definition: viewdata.hxx:62
@ SC_MARK_SIMPLE
Definition: viewdata.hxx:65
@ SC_MARK_SIMPLE_FILTERED
Definition: viewdata.hxx:67
ScSplitMode
Definition: viewdata.hxx:42
@ SC_SPLIT_FIX
Definition: viewdata.hxx:42
@ SC_SPLIT_MODE_MAX_ENUM
Definition: viewdata.hxx:42
@ SC_SPLIT_NORMAL
Definition: viewdata.hxx:42
@ SC_SPLIT_NONE
Definition: viewdata.hxx:42
@ SC_REFTYPE_NONE
Definition: viewdata.hxx:55
ScHSplitPos
Definition: viewdata.hxx:45
@ SC_SPLIT_LEFT
Definition: viewdata.hxx:45
@ SC_SPLIT_RIGHT
Definition: viewdata.hxx:45
ScPasteFlags
Definition: viewdata.hxx:81
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:728
#define SC_SIZE_NONE
Definition: viewdata.hxx:31
ScFillMode
Definition: viewdata.hxx:34
ScVSplitPos
Definition: viewdata.hxx:46
@ SC_SPLIT_TOP
Definition: viewdata.hxx:46
@ SC_SPLIT_BOTTOM
Definition: viewdata.hxx:46
@ VOBJ_TYPE_CHART
Definition: viewopti.hxx:54
@ VOBJ_TYPE_OLE
Definition: viewopti.hxx:53
@ VOBJ_TYPE_DRAW
Definition: viewopti.hxx:55
@ VOPT_TABCONTROLS
Definition: viewopti.hxx:39
@ VOPT_NULLVALS
Definition: viewopti.hxx:33
@ VOPT_HSCROLL
Definition: viewopti.hxx:38
@ VOPT_OUTLINER
Definition: viewopti.hxx:40
@ VOPT_FORMULAS_MARKS
Definition: viewopti.hxx:36
@ VOPT_GRID
Definition: viewopti.hxx:42
@ VOPT_NOTES
Definition: viewopti.hxx:35
@ VOPT_HEADER
Definition: viewopti.hxx:41
@ VOPT_PAGEBREAKS
Definition: viewopti.hxx:46
@ VOPT_SYNTAX
Definition: viewopti.hxx:34
@ VOPT_VSCROLL
Definition: viewopti.hxx:37
SvxZoomType