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