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