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);
1733  tools::Rectangle aUtilRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, Point(0, 0), pWin->GetOutDev(),
1734  HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, false );
1735  aPaperSize.setWidth( aUtilRect.GetWidth() );
1736  if (bLOKPrintTwips)
1737  {
1738  aPaperSizePTwips.setWidth(o3tl::convert(aUtilRect.GetWidth(), o3tl::Length::mm100, o3tl::Length::twip));
1739  }
1740  }
1741 
1742  pNewEngine->SetPaperSize( aPaperSize );
1743  if (bLOKPrintTwips)
1744  pNewEngine->SetLOKSpecialPaperSize(aPaperSizePTwips);
1745 
1746  // sichtbarer Ausschnitt
1747  Size aPaper = pNewEngine->GetPaperSize();
1748  tools::Rectangle aVis = pEditView[eWhich]->GetVisArea();
1749  tools::Rectangle aVisPTwips;
1750  if (bLOKPrintTwips)
1751  aVisPTwips = pEditView[eWhich]->GetLOKSpecialVisArea();
1752 
1753  tools::Long nDiff = aVis.Right() - aVis.Left();
1754  tools::Long nDiffPTwips = bLOKPrintTwips ? (aVisPTwips.Right() - aVisPTwips.Left()) : 0;
1755  if ( GetEditAdjust() == SvxAdjust::Right )
1756  {
1757  aVis.SetRight( aPaper.Width() - 1 );
1758  if (bLOKPrintTwips)
1759  aVisPTwips.SetRight( aPaperSizePTwips.Width() - 1 );
1760  bMoveArea = !bLayoutRTL;
1761  }
1762  else if ( GetEditAdjust() == SvxAdjust::Center )
1763  {
1764  aVis.SetRight( ( aPaper.Width() - 1 + nDiff ) / 2 );
1765  if (bLOKPrintTwips)
1766  aVisPTwips.SetRight( ( aPaperSizePTwips.Width() - 1 + nDiffPTwips ) / 2 );
1767  bMoveArea = true; // always
1768  }
1769  else
1770  {
1771  aVis.SetRight( nDiff );
1772  if (bLOKPrintTwips)
1773  aVisPTwips.SetRight(nDiffPTwips);
1774  bMoveArea = bLayoutRTL;
1775  }
1776  aVis.SetLeft( aVis.Right() - nDiff );
1777  if (bLOKPrintTwips)
1778  aVisPTwips.SetLeft(aVisPTwips.Right() - nDiffPTwips);
1779  // #i49561# Important note:
1780  // The set offset of the visible area of the EditView for centered and
1781  // right alignment in horizontal layout is consider by instances of
1782  // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
1783  // and <PixelToLogic(..)>. This is needed for the correct visibility
1784  // of paragraphs in edit mode at the accessibility API.
1785  pEditView[eWhich]->SetVisArea(aVis);
1786  if (bLOKPrintTwips)
1787  pEditView[eWhich]->SetLOKSpecialVisArea(aVisPTwips);
1788  // UpdateMode has been disabled in ScInputHandler::StartTable
1789  // must be enabled before EditGrowY (GetTextHeight)
1790  pNewEngine->SetUpdateLayout( true );
1791 
1792  pNewEngine->SetStatusEventHdl( LINK( this, ScViewData, EditEngineHdl ) );
1793 
1794  EditGrowY( true ); // adjust to existing text content
1795  EditGrowX();
1796 
1797  Point aDocPos = pEditView[eWhich]->GetWindowPosTopLeft(0);
1798  if (aDocPos.Y() < aOutputArea.Top())
1799  pEditView[eWhich]->Scroll( 0, aOutputArea.Top() - aDocPos.Y() );
1800  }
1801 
1802  // here bEditActive needs to be set already
1803  // (due to Map-Mode during Paint)
1804  if (!bWasThere)
1805  pNewEngine->InsertView(pEditView[eWhich].get());
1806 
1807  // background color of the cell
1808  Color aBackCol = pPattern->GetItem(ATTR_BACKGROUND).GetColor();
1809 
1810  ScModule* pScMod = SC_MOD();
1811  if ( aBackCol.IsTransparent() )
1812  {
1813  aBackCol = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
1814  }
1815  pEditView[eWhich]->SetBackgroundColor( aBackCol );
1816 
1817  pEditView[eWhich]->Invalidate(); // needed?
1818  // needed, if position changed
1819 }
1820 
1821 IMPL_LINK( ScViewData, EditEngineHdl, EditStatus&, rStatus, void )
1822 {
1823  EditStatusFlags nStatus = rStatus.GetStatusWord();
1824  if (nStatus & (EditStatusFlags::HSCROLL | EditStatusFlags::TextHeightChanged | EditStatusFlags::TEXTWIDTHCHANGED | EditStatusFlags::CURSOROUT))
1825  {
1826  EditGrowY();
1827  EditGrowX();
1828 
1829  if (nStatus & EditStatusFlags::CURSOROUT)
1830  {
1831  ScSplitPos eWhich = GetActivePart();
1832  if (pEditView[eWhich])
1833  pEditView[eWhich]->ShowCursor(false);
1834  }
1835  }
1836 }
1837 
1839 {
1840  // It is insane to call EditGrowX while the output area is already growing.
1841  // That could occur because of the call to SetDefaultItem later.
1842  // We end up with wrong start/end edit columns and the changes
1843  // to the output area performed by the inner call to this method are
1844  // useless since they are discarded by the outer call.
1845  if (bGrowing)
1846  return;
1847 
1848  comphelper::FlagRestorationGuard aFlagGuard(bGrowing, true);
1849 
1850  bool bLOKActive = comphelper::LibreOfficeKit::isActive();
1851  bool bLOKPrintTwips = bLOKActive && comphelper::LibreOfficeKit::isCompatFlagSet(
1852  comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
1853 
1854  ScDocument& rLocalDoc = GetDocument();
1855 
1856  ScSplitPos eWhich = GetActivePart();
1857  ScHSplitPos eHWhich = WhichH(eWhich);
1858  EditView* pCurView = pEditView[eWhich].get();
1859 
1860  if ( !pCurView || !bEditActive[eWhich])
1861  return;
1862 
1863  bool bLayoutRTL = rLocalDoc.IsLayoutRTL( nTabNo );
1864 
1865  ScEditEngineDefaulter* pEngine =
1866  static_cast<ScEditEngineDefaulter*>( pCurView->GetEditEngine() );
1867  vcl::Window* pWin = pCurView->GetWindow();
1868 
1869  // Get the left- and right-most column positions.
1870  SCCOL nLeft = GetPosX(eHWhich);
1871  SCCOL nRight = nLeft + VisibleCellsX(eHWhich);
1872 
1873  Size aSize = pEngine->GetPaperSize();
1874  Size aSizePTwips;
1875  if (bLOKPrintTwips)
1876  aSizePTwips = pEngine->GetLOKSpecialPaperSize();
1877 
1878  tools::Rectangle aArea = pCurView->GetOutputArea();
1879  tools::Rectangle aAreaPTwips;
1880  if (bLOKPrintTwips)
1881  aAreaPTwips = pCurView->GetLOKSpecialOutputArea();
1882 
1883  tools::Long nOldRight = aArea.Right();
1884 
1885  // Margin is already included in the original width.
1886  tools::Long nTextWidth = pEngine->CalcTextWidth();
1887 
1888  bool bChanged = false;
1889  bool bAsianVertical = pEngine->IsEffectivelyVertical();
1890 
1891  // get bGrow... variables the same way as in SetEditEngine
1892  const ScPatternAttr* pPattern = rLocalDoc.GetPattern( nEditCol, nEditRow, nTabNo );
1893  SvxCellHorJustify eJust = pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue();
1894  bool bGrowCentered = ( eJust == SvxCellHorJustify::Center );
1895  bool bGrowToLeft = ( eJust == SvxCellHorJustify::Right ); // visual left
1896  bool bGrowBackwards = bGrowToLeft; // logical left
1897  if ( bLayoutRTL )
1898  bGrowBackwards = !bGrowBackwards; // invert on RTL sheet
1899  if ( bAsianVertical )
1900  bGrowCentered = bGrowToLeft = bGrowBackwards = false; // keep old behavior for asian mode
1901 
1902  bool bUnevenGrow = false;
1903  if ( bGrowCentered )
1904  {
1905  while (aArea.GetWidth() + 0 < nTextWidth && ( nEditStartCol > nLeft || nEditEndCol < nRight ) )
1906  {
1907  tools::Long nLogicLeft = 0;
1908  tools::Long nLogicLeftPTwips = 0;
1909  if ( nEditStartCol > nLeft )
1910  {
1911  --nEditStartCol;
1912  tools::Long nColWidth = rLocalDoc.GetColWidth( nEditStartCol, nTabNo );
1913  tools::Long nLeftPix = ToPixel( nColWidth, nPPTX );
1914  nLogicLeft = pWin->PixelToLogic(Size(nLeftPix,0)).Width();
1915  if (bLOKPrintTwips)
1916  nLogicLeftPTwips = nColWidth;
1917  }
1918  tools::Long nLogicRight = 0;
1919  tools::Long nLogicRightPTwips = 0;
1920  if ( nEditEndCol < nRight )
1921  {
1922  ++nEditEndCol;
1923  tools::Long nColWidth = rLocalDoc.GetColWidth( nEditEndCol, nTabNo );
1924  tools::Long nRightPix = ToPixel( nColWidth, nPPTX );
1925  nLogicRight = pWin->PixelToLogic(Size(nRightPix,0)).Width();
1926  if (bLOKPrintTwips)
1927  nLogicRightPTwips = nColWidth;
1928  }
1929 
1930  aArea.AdjustLeft( -(bLayoutRTL ? nLogicRight : nLogicLeft) );
1931  aArea.AdjustRight(bLayoutRTL ? nLogicLeft : nLogicRight );
1932  if (bLOKPrintTwips)
1933  {
1934  aAreaPTwips.AdjustLeft( -(bLayoutRTL ? nLogicRightPTwips : nLogicLeftPTwips) );
1935  aAreaPTwips.AdjustRight(bLayoutRTL ? nLogicLeftPTwips : nLogicRightPTwips );
1936  }
1937 
1938  if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1939  {
1940  tools::Long nCenter = ( aArea.Left() + aArea.Right() ) / 2;
1941  tools::Long nHalf = aSize.Width() / 2;
1942  aArea.SetLeft( nCenter - nHalf + 1 );
1943  aArea.SetRight( nCenter + aSize.Width() - nHalf - 1 );
1944 
1945  if (bLOKPrintTwips)
1946  {
1947  tools::Long nCenterPTwips = ( aAreaPTwips.Left() + aAreaPTwips.Right() ) / 2;
1948  tools::Long nHalfPTwips = aSizePTwips.Width() / 2;
1949  aAreaPTwips.SetLeft( nCenterPTwips - nHalfPTwips + 1 );
1950  aAreaPTwips.SetRight( nCenterPTwips + aSizePTwips.Width() - nHalfPTwips - 1 );
1951  }
1952  }
1953 
1954  bChanged = true;
1955  if ( nLogicLeft != nLogicRight )
1956  bUnevenGrow = true;
1957  }
1958  }
1959  else if ( bGrowBackwards )
1960  {
1961  while (aArea.GetWidth() + 0 < nTextWidth && nEditStartCol > nLeft)
1962  {
1963  --nEditStartCol;
1964  tools::Long nColWidth = rLocalDoc.GetColWidth( nEditStartCol, nTabNo );
1965  tools::Long nPix = ToPixel( nColWidth, nPPTX );
1966  tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
1967  tools::Long& nLogicWidthPTwips = nColWidth;
1968 
1969  if ( !bLayoutRTL )
1970  {
1971  aArea.AdjustLeft( -nLogicWidth );
1972  if (bLOKPrintTwips)
1973  aAreaPTwips.AdjustLeft( -nLogicWidthPTwips );
1974  }
1975  else
1976  {
1977  aArea.AdjustRight(nLogicWidth );
1978  if (bLOKPrintTwips)
1979  aAreaPTwips.AdjustRight(nLogicWidthPTwips);
1980  }
1981 
1982  if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1983  {
1984  if ( !bLayoutRTL )
1985  {
1986  aArea.SetLeft( aArea.Right() - aSize.Width() + 1 );
1987  if (bLOKPrintTwips)
1988  aAreaPTwips.SetLeft( aAreaPTwips.Right() - aSizePTwips.Width() + 1 );
1989  }
1990  else
1991  {
1992  aArea.SetRight( aArea.Left() + aSize.Width() - 1 );
1993  if (bLOKPrintTwips)
1994  aAreaPTwips.SetRight( aAreaPTwips.Left() + aSizePTwips.Width() - 1 );
1995  }
1996  }
1997 
1998  bChanged = true;
1999  }
2000  }
2001  else
2002  {
2003  while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight)
2004  {
2005  ++nEditEndCol;
2006  tools::Long nColWidth = rLocalDoc.GetColWidth( nEditEndCol, nTabNo );
2007  tools::Long nPix = ToPixel( nColWidth, nPPTX );
2008  tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
2009  tools::Long& nLogicWidthPTwips = nColWidth;
2010  if ( bLayoutRTL )
2011  {
2012  aArea.AdjustLeft( -nLogicWidth );
2013  if (bLOKPrintTwips)
2014  aAreaPTwips.AdjustLeft( -nLogicWidthPTwips );
2015  }
2016  else
2017  {
2018  aArea.AdjustRight(nLogicWidth );
2019  if (bLOKPrintTwips)
2020  aAreaPTwips.AdjustRight(nLogicWidthPTwips);
2021  }
2022 
2023  if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
2024  {
2025  if ( bLayoutRTL )
2026  {
2027  aArea.SetLeft( aArea.Right() - aSize.Width() + 1 );
2028  if (bLOKPrintTwips)
2029  aAreaPTwips.SetLeft( aAreaPTwips.Right() - aSizePTwips.Width() + 1 );
2030  }
2031  else
2032  {
2033  aArea.SetRight( aArea.Left() + aSize.Width() - 1 );
2034  if (bLOKPrintTwips)
2035  aAreaPTwips.SetRight( aAreaPTwips.Left() + aSizePTwips.Width() - 1 );
2036  }
2037  }
2038 
2039  bChanged = true;
2040  }
2041  }
2042 
2043  if (!bChanged)
2044  return;
2045 
2046  if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL )
2047  {
2048  tools::Rectangle aVis = pCurView->GetVisArea();
2049  tools::Rectangle aVisPTwips;
2050  if (bLOKPrintTwips)
2051  aVisPTwips = pCurView->GetLOKSpecialVisArea();
2052 
2053  if ( bGrowCentered )
2054  {
2055  // switch to center-aligned (undo?) and reset VisArea to center
2056 
2057  pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
2058 
2059  tools::Long nCenter = aSize.Width() / 2;
2060  tools::Long nVisSize = aArea.GetWidth();
2061  aVis.SetLeft( nCenter - nVisSize / 2 );
2062  aVis.SetRight( aVis.Left() + nVisSize - 1 );
2063 
2064  if (bLOKPrintTwips)
2065  {
2066  tools::Long nCenterPTwips = aSizePTwips.Width() / 2;
2067  tools::Long nVisSizePTwips = aAreaPTwips.GetWidth();
2068  aVisPTwips.SetLeft( nCenterPTwips - nVisSizePTwips / 2 );
2069  aVisPTwips.SetRight( aVisPTwips.Left() + nVisSizePTwips - 1 );
2070  }
2071  }
2072  else if ( bGrowToLeft )
2073  {
2074  // switch to right-aligned (undo?) and reset VisArea to the right
2075 
2076  pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
2077 
2078  aVis.SetRight( aSize.Width() - 1 );
2079  aVis.SetLeft( aSize.Width() - aArea.GetWidth() ); // with the new, increased area
2080 
2081  if (bLOKPrintTwips)
2082  {
2083  aVisPTwips.SetRight( aSizePTwips.Width() - 1 );
2084  aVisPTwips.SetLeft( aSizePTwips.Width() - aAreaPTwips.GetWidth() ); // with the new, increased area
2085  }
2086  }
2087  else
2088  {
2089  // switch to left-aligned (undo?) and reset VisArea to the left
2090 
2091  pEngine->SetDefaultItem( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
2092 
2093  tools::Long nMove = aVis.Left();
2094  aVis.SetLeft( 0 );
2095  aVis.AdjustRight( -nMove );
2096 
2097  if (bLOKPrintTwips)
2098  {
2099  tools::Long nMovePTwips = aVisPTwips.Left();
2100  aVisPTwips.SetLeft( 0 );
2101  aVisPTwips.AdjustRight( -nMovePTwips );
2102  }
2103  }
2104 
2105  pCurView->SetVisArea( aVis );
2106  if (bLOKPrintTwips)
2107  pCurView->SetLOKSpecialVisArea( aVisPTwips );
2108 
2109  bMoveArea = false;
2110  }
2111 
2112  if (bLOKPrintTwips)
2113  pCurView->SetLOKSpecialOutputArea(aAreaPTwips);
2114 
2115  pCurView->SetOutputArea(aArea);
2116 
2117  // In vertical mode, the whole text is moved to the next cell (right-aligned),
2118  // so everything must be repainted. Otherwise, paint only the new area.
2119  // If growing in centered alignment, if the cells left and right have different sizes,
2120  // the whole text will move, and may not even obscure all of the original display.
2121  if ( bUnevenGrow )
2122  {
2123  aArea.SetLeft( pWin->PixelToLogic( Point(0,0) ).X() );
2124  aArea.SetRight( pWin->PixelToLogic( aScrSize ).Width() );
2125  }
2126  else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered )
2127  aArea.SetLeft( nOldRight );
2128  pWin->Invalidate(aArea);
2129 
2130  // invalidate other views
2131  pCurView->InvalidateOtherViewWindows(aArea);
2132 }
2133 
2134 void ScViewData::EditGrowY( bool bInitial )
2135 {
2136  if (bGrowing)
2137  return;
2138 
2139  comphelper::FlagRestorationGuard aFlagGuard(bGrowing, true);
2140 
2141  bool bLOKActive = comphelper::LibreOfficeKit::isActive();
2142  bool bLOKPrintTwips = bLOKActive && comphelper::LibreOfficeKit::isCompatFlagSet(
2143  comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
2144 
2145  ScSplitPos eWhich = GetActivePart();
2146  ScVSplitPos eVWhich = WhichV(eWhich);
2147  EditView* pCurView = pEditView[eWhich].get();
2148 
2149  if ( !pCurView || !bEditActive[eWhich])
2150  return;
2151 
2152  EVControlBits nControl = pEditView[eWhich]->GetControlWord();
2153  if ( nControl & EVControlBits::AUTOSCROLL )
2154  {
2155  // if end of screen had already been reached and scrolling enabled,
2156  // don't further try to grow the edit area
2157 
2158  pCurView->SetOutputArea( pCurView->GetOutputArea() ); // re-align to pixels
2159  return;
2160  }
2161 
2162  EditEngine* pEngine = pCurView->GetEditEngine();
2163  vcl::Window* pWin = pCurView->GetWindow();
2164 
2165  SCROW nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich);
2166 
2167  Size aSize = pEngine->GetPaperSize();
2168  Size aSizePTwips;
2169  tools::Rectangle aArea = pCurView->GetOutputArea();
2170  tools::Rectangle aAreaPTwips;
2171 
2172  if (bLOKPrintTwips)
2173  {
2174  aSizePTwips = pEngine->GetLOKSpecialPaperSize();
2175  aAreaPTwips = pCurView->GetLOKSpecialOutputArea();
2176  }
2177 
2178  tools::Long nOldBottom = aArea.Bottom();
2179  tools::Long nTextHeight = pEngine->GetTextHeight();
2180 
2181  // When editing a formula in a cell with optimal height, allow a larger portion
2182  // to be clipped before extending to following rows, to avoid obscuring cells for
2183  // reference input (next row is likely to be useful in formulas).
2184  tools::Long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
2186  pEngine->GetParagraphCount() <= 1 )
2187  {
2188  // If the (only) paragraph starts with a '=', it's a formula.
2189  // If this is the initial call and the text is empty, allow the larger value, too,
2190  // because this occurs in the normal progress of editing a formula.
2191  // Subsequent calls with empty text might involve changed attributes (including
2192  // font height), so they are treated like normal text.
2193  OUString aText = pEngine->GetText( 0 );
2194  if ( ( aText.isEmpty() && bInitial ) || aText.startsWith("=") )
2195  nAllowedExtra = SC_GROWY_BIG_EXTRA;
2196  }
2197 
2198  bool bChanged = false;
2199  bool bMaxReached = false;
2200  while (aArea.GetHeight() + nAllowedExtra < nTextHeight && nEditEndRow < nBottom && !bMaxReached)
2201  {
2202  ++nEditEndRow;
2203  ScDocument& rLocalDoc = GetDocument();
2204  tools::Long nRowHeight = rLocalDoc.GetRowHeight( nEditEndRow, nTabNo );
2205  tools::Long nPix = ToPixel( nRowHeight, nPPTY );
2206  aArea.AdjustBottom(pWin->PixelToLogic(Size(0,nPix)).Height() );
2207  if (bLOKPrintTwips)
2208  aAreaPTwips.AdjustBottom(nRowHeight);
2209 
2210  if ( aArea.Bottom() > aArea.Top() + aSize.Height() - 1 )
2211  {
2212  aArea.SetBottom( aArea.Top() + aSize.Height() - 1 );
2213  if (bLOKPrintTwips)
2214  aAreaPTwips.SetBottom( aAreaPTwips.Top() + aSizePTwips.Height() - 1 );
2215  bMaxReached = true; // don't occupy more cells beyond paper size
2216  }
2217 
2218  bChanged = true;
2219  nAllowedExtra = SC_GROWY_SMALL_EXTRA; // larger value is only for first row
2220  }
2221 
2222  if (!bChanged)
2223  return;
2224 
2225  if (bLOKPrintTwips)
2226  pCurView->SetLOKSpecialOutputArea(aAreaPTwips);
2227 
2228  pCurView->SetOutputArea(aArea);
2229 
2230  if (nEditEndRow >= nBottom || bMaxReached)
2231  {
2232  if (!(nControl & EVControlBits::AUTOSCROLL))
2233  pCurView->SetControlWord( nControl | EVControlBits::AUTOSCROLL );
2234  }
2235 
2236  aArea.SetTop( nOldBottom );
2237  pWin->Invalidate(aArea);
2238 
2239  // invalidate other views
2240  pCurView->InvalidateOtherViewWindows(aArea);
2241 }
2242 
2244 {
2245  EditEngine* pEngine = nullptr;
2246  for (sal_uInt16 i=0; i<4; i++)
2247  if (pEditView[i])
2248  {
2249  if (bEditActive[i])
2250  {
2251  lcl_LOKRemoveWindow(GetViewShell(), static_cast<ScSplitPos>(i));
2252  pEngine = pEditView[i]->GetEditEngine();
2253  pEngine->RemoveView(pEditView[i].get());
2254  pEditView[i]->SetOutputArea( tools::Rectangle() );
2255  }
2256  bEditActive[i] = false;
2257  }
2258 
2259  if (pEngine)
2261 }
2262 
2264 {
2265  EditEngine* pEngine = nullptr;
2266  for (sal_uInt16 i=0; i<4; i++)
2267  if (pEditView[i])
2268  {
2269  if (bEditActive[i])
2270  {
2271  pEngine = pEditView[i]->GetEditEngine();
2272  if (pEngine)
2273  pEngine->RemoveView(pEditView[i].get());
2274  }
2275  pEditView[i].reset();
2276  }
2277 }
2278 
2279 void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow )
2280 {
2281  rViewPtr = pEditView[eWhich].get();
2282  rCol = nEditCol;
2283  rRow = nEditRow;
2284 }
2285 
2287 {
2288  EnsureTabDataSize(nNewTab + 1);
2289 
2290  if (!maTabData[nNewTab])
2291  {
2292  maTabData[nNewTab].reset(new ScViewDataTable(&mrDoc));
2293 
2294  maTabData[nNewTab]->eZoomType = eDefZoomType;
2295  maTabData[nNewTab]->aZoomX = aDefZoomX;
2296  maTabData[nNewTab]->aZoomY = aDefZoomY;
2297  maTabData[nNewTab]->aPageZoomX = aDefPageZoomX;
2298  maTabData[nNewTab]->aPageZoomY = aDefPageZoomY;
2299  }
2300 }
2301 
2303 {
2304  for (const auto& rTab : maMarkData)
2305  CreateTabData(rTab);
2306 }
2307 
2309 {
2310  if (nSize > maTabData.size())
2311  maTabData.resize(nSize);
2312 }
2313 
2315 {
2316  if (!ValidTab(nNewTab))
2317  {
2318  OSL_FAIL("wrong sheet number");
2319  return;
2320  }
2321 
2322  nTabNo = nNewTab;
2324  pThisTab = maTabData[nTabNo].get();
2325 
2326  CalcPPT(); // for common column width correction
2327  RecalcPixPos();
2328 }
2329 
2331 {
2332  if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) ||
2333  !maTabData[nTabIndex])
2334  {
2335  return nullptr;
2336  }
2337  return &(maTabData[nTabIndex]->aWidthHelper);
2338 }
2339 
2341 {
2342  if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) ||
2343  !maTabData[nTabIndex])
2344  {
2345  return nullptr;
2346  }
2347  return &(maTabData[nTabIndex]->aHeightHelper);
2348 }
2349 
2351 {
2352  pThisTab->eWhichActive = eNewActive;
2353 
2354  // Let's hope we find the culprit for tdf#117093
2355  // Don't sanitize the real value (yet?) because this function might be
2356  // called before setting the then corresponding split modes. For which in
2357  // fact then the order should be changed.
2358  assert(eNewActive == pThisTab->SanitizeWhichActive());
2359 }
2360 
2361 Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const
2362 {
2363  OSL_ENSURE( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "wrong position" );
2365  return GetScrPos( nWhereX, nWhereY, ePos );
2366 }
2367 
2368 Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const
2369 {
2370  OSL_ENSURE( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "wrong position" );
2372  return GetScrPos( nWhereX, nWhereY, ePos );
2373 }
2374 
2376  bool bAllowNeg, SCTAB nForTab ) const
2377 {
2378  ScHSplitPos eWhichX = SC_SPLIT_LEFT;
2379  ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
2380  switch( eWhich )
2381  {
2382  case SC_SPLIT_TOPLEFT:
2383  eWhichX = SC_SPLIT_LEFT;
2384  eWhichY = SC_SPLIT_TOP;
2385  break;
2386  case SC_SPLIT_TOPRIGHT:
2387  eWhichX = SC_SPLIT_RIGHT;
2388  eWhichY = SC_SPLIT_TOP;
2389  break;
2390  case SC_SPLIT_BOTTOMLEFT:
2391  eWhichX = SC_SPLIT_LEFT;
2392  eWhichY = SC_SPLIT_BOTTOM;
2393  break;
2394  case SC_SPLIT_BOTTOMRIGHT:
2395  eWhichX = SC_SPLIT_RIGHT;
2396  eWhichY = SC_SPLIT_BOTTOM;
2397  break;
2398  }
2399 
2400  if (nForTab == -1)
2401  nForTab = nTabNo;
2402  bool bForCurTab = (nForTab == nTabNo);
2403  if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))))
2404  {
2405  SAL_WARN("sc.viewdata", "ScViewData::GetScrPos : invalid nForTab = " << nForTab);
2406  nForTab = nTabNo;
2407  bForCurTab = true;
2408  }
2409 
2410  ScViewDataTable* pViewTable = bForCurTab ? pThisTab : maTabData[nForTab].get();
2411 
2412  if (pView)
2413  {
2414  const_cast<ScViewData*>(this)->aScrSize.setWidth( pView->GetGridWidth(eWhichX) );
2415  const_cast<ScViewData*>(this)->aScrSize.setHeight( pView->GetGridHeight(eWhichY) );
2416  }
2417 
2418  sal_uLong nTSize;
2419  bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
2420 
2421 
2422  SCCOL nPosX = GetPosX(eWhichX, nForTab);
2423  tools::Long nScrPosX = 0;
2424 
2425  if (bAllowNeg || nWhereX >= nPosX)
2426  {
2427  SCROW nStartPosX = nPosX;
2428  if (bIsTiledRendering)
2429  {
2430  OSL_ENSURE(nPosX == 0, "Unsupported case.");
2431  const auto& rNearest = pViewTable->aWidthHelper.getNearestByIndex(nWhereX - 1);
2432  nStartPosX = rNearest.first + 1;
2433  nScrPosX = rNearest.second;
2434  }
2435 
2436  if (nWhereX >= nStartPosX)
2437  {
2438  for (SCCOL nX = nStartPosX; nX < nWhereX && (bAllowNeg || bIsTiledRendering || nScrPosX <= aScrSize.Width()); nX++)
2439  {
2440  if (nX > mrDoc.MaxCol())
2441  nScrPosX = 0x7FFFFFFF;
2442  else
2443  {
2444  nTSize = mrDoc.GetColWidth(nX, nForTab);
2445  if (nTSize)
2446  {
2447  tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
2448  nScrPosX += nSizeXPix;
2449  }
2450  }
2451  }
2452  }
2453  else
2454  {
2455  for (SCCOL nX = nStartPosX; nX > nWhereX;)
2456  {
2457  --nX;
2458  nTSize = mrDoc.GetColWidth(nX, nForTab);
2459  if (nTSize)
2460  {
2461  tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
2462  nScrPosX -= nSizeXPix;
2463  }
2464  }
2465  }
2466 
2467  }
2468 
2469 
2470  SCROW nPosY = GetPosY(eWhichY, nForTab);
2471  tools::Long nScrPosY = 0;
2472 
2473  if (bAllowNeg || nWhereY >= nPosY)
2474  {
2475  SCROW nStartPosY = nPosY;
2476  if (bIsTiledRendering)
2477  {
2478  OSL_ENSURE(nPosY == 0, "Unsupported case.");
2479  const auto& rNearest = pViewTable->aHeightHelper.getNearestByIndex(nWhereY - 1);
2480  nStartPosY = rNearest.first + 1;
2481  nScrPosY = rNearest.second;
2482  }
2483 
2484  if (nWhereY >= nStartPosY)
2485  {
2486  if (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height())
2487  {
2488  if (nWhereY - 1 > mrDoc.MaxRow())
2489  nScrPosY = 0x7FFFFFFF;
2490  else if (bAllowNeg || bIsTiledRendering)
2491  {
2492  sal_uLong nSizeYPix = mrDoc.GetScaledRowHeight(nStartPosY, nWhereY - 1, nForTab, nPPTY);
2493  nScrPosY += nSizeYPix;
2494  }
2495  else
2496  {
2497  sal_uLong nMaxHeight = aScrSize.getHeight() - nScrPosY;
2498  sal_uLong nSizeYPix = mrDoc.GetScaledRowHeight(nStartPosY, nWhereY - 1, nForTab, nPPTY, &nMaxHeight);
2499  nScrPosY += nSizeYPix;
2500  }
2501  }
2502  }
2503  else
2504  {
2505  for (SCROW nY = nStartPosY; nY > nWhereY;)
2506  {
2507  --nY;
2508  nTSize = mrDoc.GetRowHeight(nY, nForTab);
2509  if (nTSize)
2510  {
2511  tools::Long nSizeYPix = ToPixel( nTSize, nPPTY );
2512  nScrPosY -= nSizeYPix;
2513  }
2514  }
2515  }
2516  }
2517 
2518  if (mrDoc.IsLayoutRTL(nForTab))
2519  {
2520  // mirror horizontal position
2521  nScrPosX = aScrSize.Width() - 1 - nScrPosX;
2522  }
2523 
2524  return Point( nScrPosX, nScrPosY );
2525 }
2526 
2528 {
2529  // hidden ones are given 0 sizes by these by default.
2530  // TODO: rewrite this to loop over spans (matters for jumbosheets).
2531  tools::Long nPosX = nCol ? mrDoc.GetColWidth(0, nCol - 1, nTabNo) : 0;
2532  // This is now fast as it loops over spans.
2533  tools::Long nPosY = nRow ? mrDoc.GetRowHeight(0, nRow - 1, nTabNo) : 0;
2534  // TODO: adjust for RTL layout case.
2535 
2536  return Point(nPosX, nPosY);
2537 }
2538 
2539 Point ScViewData::GetPrintTwipsPosFromTileTwips(const Point& rTileTwipsPos) const
2540 {
2541  const tools::Long nPixelX = static_cast<tools::Long>(rTileTwipsPos.X() * nPPTX);
2542  const tools::Long nPixelY = static_cast<tools::Long>(rTileTwipsPos.Y() * nPPTY);
2543  SCCOL nCol = 0;
2544  SCROW nRow = 0;
2545 
2546  // The following call (with bTestMerge = false) will not modify any members.
2547  const_cast<ScViewData*>(this)->GetPosFromPixel(nPixelX, nPixelY, SC_SPLIT_TOPLEFT, nCol, nRow, false /* bTestMerge */);
2548  const Point aPixCellPos = GetScrPos(nCol, nRow, SC_SPLIT_TOPLEFT, true /* bAllowNeg */);
2549  const Point aTileTwipsCellPos(aPixCellPos.X() / nPPTX, aPixCellPos.Y() / nPPTY);
2550  const Point aPrintTwipsCellPos = GetPrintTwipsPos(nCol, nRow);
2551  return aPrintTwipsCellPos + (rTileTwipsPos - aTileTwipsCellPos);
2552 }
2553 
2554 OString ScViewData::describeCellCursorAt(SCCOL nX, SCROW nY, bool bPixelAligned) const
2555 {
2556  const bool bPosSizeInPixels = bPixelAligned;
2557  Point aCellPos = bPosSizeInPixels ? GetScrPos( nX, nY, SC_SPLIT_BOTTOMRIGHT, true ) :
2558  GetPrintTwipsPos(nX, nY);
2559 
2560  tools::Long nSizeX;
2561  tools::Long nSizeY;
2562  if (bPosSizeInPixels)
2563  GetMergeSizePixel( nX, nY, nSizeX, nSizeY );
2564  else
2565  GetMergeSizePrintTwips(nX, nY, nSizeX, nSizeY);
2566 
2567  std::stringstream ss;
2568  if (bPosSizeInPixels)
2569  {
2570  double fPPTX = GetPPTX();
2571  double fPPTY = GetPPTY();
2572 
2573  // make it a slim cell cursor, but not empty
2574  if (nSizeX == 0)
2575  nSizeX = 1;
2576 
2577  if (nSizeY == 0)
2578  nSizeY = 1;
2579 
2580  tools::Long nPosXTw = rtl::math::round(aCellPos.getX() / fPPTX);
2581  tools::Long nPosYTw = rtl::math::round(aCellPos.getY() / fPPTY);
2582  // look at Rectangle( const Point& rLT, const Size& rSize ) for the '- 1'
2583  tools::Long nSizeXTw = rtl::math::round(nSizeX / fPPTX) - 1;
2584  tools::Long nSizeYTw = rtl::math::round(nSizeY / fPPTY) - 1;
2585 
2586  ss << nPosXTw << ", " << nPosYTw << ", " << nSizeXTw << ", " << nSizeYTw << ", "
2587  << nX << ", " << nY;
2588  }
2589  else
2590  {
2591  // look at Rectangle( const Point& rLT, const Size& rSize ) for the decrement.
2592  if (nSizeX)
2593  --nSizeX;
2594  if (nSizeY)
2595  --nSizeY;
2596  ss << aCellPos.getX() << ", " << aCellPos.getY()
2597  << ", " << nSizeX << ", " << nSizeY << ", "
2598  << nX << ", " << nY;
2599  }
2600 
2601  return ss.str().c_str();
2602 }
2603 
2604 // Number of cells on a screen
2605 SCCOL ScViewData::CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeX ) const
2606 {
2607  OSL_ENSURE( nDir==1 || nDir==-1, "wrong CellsAt call" );
2608 
2609  if (pView)
2610  const_cast<ScViewData*>(this)->aScrSize.setWidth( pView->GetGridWidth(eWhichX) );
2611 
2612  SCCOL nX;
2613  sal_uInt16 nScrPosX = 0;
2614  if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = static_cast<sal_uInt16>(aScrSize.Width());
2615 
2616  if (nDir==1)
2617  nX = nPosX; // forwards
2618  else
2619  nX = nPosX-1; // backwards
2620 
2621  bool bOut = false;
2622  for ( ; nScrPosX<=nScrSizeX && !bOut; nX = sal::static_int_cast<SCCOL>(nX + nDir) )
2623  {
2624  SCCOL nColNo = nX;
2625  if (nColNo < 0 || nColNo > mrDoc.MaxCol())
2626  bOut = true;
2627  else
2628  {
2629  sal_uInt16 nTSize = mrDoc.GetColWidth(nColNo, nTabNo);
2630  if (nTSize)
2631  {
2632  tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
2633  nScrPosX = sal::static_int_cast<sal_uInt16>( nScrPosX + static_cast<sal_uInt16>(nSizeXPix) );
2634  }
2635  }
2636  }
2637 
2638  if (nDir==1)
2639  nX = sal::static_int_cast<SCCOL>( nX - nPosX );
2640  else
2641  nX = (nPosX-1)-nX;
2642 
2643  if (nX>0) --nX;
2644  return nX;
2645 }
2646 
2647 SCROW ScViewData::CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeY ) const
2648 {
2649  OSL_ENSURE( nDir==1 || nDir==-1, "wrong CellsAt call" );
2650 
2651  if (pView)
2652  const_cast<ScViewData*>(this)->aScrSize.setHeight( pView->GetGridHeight(eWhichY) );
2653 
2654  if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = static_cast<sal_uInt16>(aScrSize.Height());
2655 
2656  SCROW nY;
2657 
2658  if (nDir==1)
2659  {
2660  // forward
2661  nY = nPosY;
2662  tools::Long nScrPosY = 0;
2663  AddPixelsWhile(nScrPosY, nScrSizeY, nY, mrDoc.MaxRow(), nPPTY, &mrDoc, nTabNo);
2664  // Original loop ended on last evaluated +1 or if that was MaxRow even on MaxRow+2.
2665  nY += (nY == mrDoc.MaxRow() ? 2 : 1);
2666  nY -= nPosY;
2667  }
2668  else
2669  {
2670  // backward
2671  nY = nPosY-1;
2672  tools::Long nScrPosY = 0;
2673  AddPixelsWhileBackward(nScrPosY, nScrSizeY, nY, 0, nPPTY, &mrDoc, nTabNo);
2674  // Original loop ended on last evaluated -1 or if that was 0 even on -2.
2675  nY -= (nY == 0 ? 2 : 1);
2676  nY = (nPosY-1)-nY;
2677  }
2678 
2679  if (nY>0) --nY;
2680  return nY;
2681 }
2682 
2684 {
2685  return CellsAtX( GetPosX( eWhichX ), 1, eWhichX );
2686 }
2687 
2689 {
2690  return CellsAtY( GetPosY( eWhichY ), 1, eWhichY );
2691 }
2692 
2694 {
2695  return CellsAtX( GetPosX( eWhichX ), -1, eWhichX );
2696 }
2697 
2699 {
2700  return CellsAtY( GetPosY( eWhichY ), -1, eWhichY );
2701 }
2702 
2703 bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, tools::Long& rSizeXPix, tools::Long& rSizeYPix ) const
2704 {
2705  const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nTabNo, ATTR_MERGE);
2706  if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
2707  {
2708  tools::Long nOutWidth = 0;
2709  tools::Long nOutHeight = 0;
2710  SCCOL nCountX = pMerge->GetColMerge();
2711  for (SCCOL i=0; i<nCountX; i++)
2712  nOutWidth += ToPixel(mrDoc.GetColWidth(nX + i, nTabNo), nPPTX);
2713  SCROW nCountY = pMerge->GetRowMerge();
2714 
2715  for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
2716  {
2717  SCROW nLastRow = nRow;
2718  if (mrDoc.RowHidden(nRow, nTabNo, nullptr, &nLastRow))
2719  {
2720  nRow = nLastRow;
2721  continue;
2722  }
2723 
2724  sal_uInt16 nHeight = mrDoc.GetRowHeight(nRow, nTabNo);
2725  nOutHeight += ToPixel(nHeight, nPPTY);
2726  }
2727 
2728  rSizeXPix = nOutWidth;
2729  rSizeYPix = nOutHeight;
2730  return true;
2731  }
2732  else
2733  {
2734  rSizeXPix = ToPixel(mrDoc.GetColWidth(nX, nTabNo), nPPTX);
2735  rSizeYPix = ToPixel(mrDoc.GetRowHeight(nY, nTabNo), nPPTY);
2736  return false;
2737  }
2738 }
2739 
2740 bool ScViewData::GetMergeSizePrintTwips(SCCOL nX, SCROW nY, tools::Long& rSizeXTwips, tools::Long& rSizeYTwips) const
2741 {
2742  const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nTabNo, ATTR_MERGE);
2743  SCCOL nCountX = pMerge->GetColMerge();
2744  if (!nCountX)
2745  nCountX = 1;
2746  rSizeXTwips = mrDoc.GetColWidth(nX, nX + nCountX - 1, nTabNo);
2747 
2748  SCROW nCountY = pMerge->GetRowMerge();
2749  if (!nCountY)
2750  nCountY = 1;
2751  rSizeYTwips = mrDoc.GetRowHeight(nY, nY + nCountY - 1, nTabNo);
2752 
2753  return (nCountX > 1 || nCountY > 1);
2754 }
2755 
2757  SCCOL& rPosX, SCROW& rPosY,
2758  bool bTestMerge, bool bRepair, SCTAB nForTab )
2759 {
2760  // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
2761 
2762  if (nForTab == -1)
2763  nForTab = nTabNo;
2764  bool bForCurTab = (nForTab == nTabNo);
2765  if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size()))))
2766  {
2767  SAL_WARN("sc.viewdata", "ScViewData::GetPosFromPixel : invalid nForTab = " << nForTab);
2768  nForTab = nTabNo;
2769  bForCurTab = true;
2770  }
2771 
2772  ScHSplitPos eHWhich = WhichH(eWhich);
2773  ScVSplitPos eVWhich = WhichV(eWhich);
2774 
2775  if (mrDoc.IsLayoutRTL(nForTab))
2776  {
2777  // mirror horizontal position
2778  if (pView)
2779  aScrSize.setWidth( pView->GetGridWidth(eHWhich) );
2780  nClickX = aScrSize.Width() - 1 - nClickX;
2781  }
2782 
2783  SCCOL nStartPosX = GetPosX(eHWhich, nForTab);
2784  SCROW nStartPosY = GetPosY(eVWhich, nForTab);
2785  rPosX = nStartPosX;
2786  rPosY = nStartPosY;
2787  tools::Long nScrX = 0;
2788  tools::Long nScrY = 0;
2789 
2790  if (nClickX > 0)
2791  {
2792  while (rPosX <= mrDoc.MaxCol() && nClickX >= nScrX)
2793  {
2794  nScrX += ToPixel(mrDoc.GetColWidth(rPosX, nForTab), nPPTX);
2795  ++rPosX;
2796  }
2797  --rPosX;
2798  }
2799  else
2800  {
2801  while ( rPosX>0 && nClickX < nScrX )
2802  {
2803  --rPosX;
2804  nScrX -= ToPixel(mrDoc.GetColWidth(rPosX, nForTab), nPPTX);
2805  }
2806  }
2807 
2808  if (nClickY > 0)
2809  AddPixelsWhile(nScrY, nClickY, rPosY, mrDoc.MaxRow(), nPPTY, &mrDoc, nForTab);
2810  else
2811  {
2812  /* TODO: could need some "SubPixelsWhileBackward" method */
2813  while ( rPosY>0 && nClickY < nScrY )
2814  {
2815  --rPosY;
2816  nScrY -= ToPixel(mrDoc.GetRowHeight(rPosY, nForTab), nPPTY);
2817  }
2818  }
2819 
2820  // cells too big?
2821  if ( rPosX == nStartPosX && nClickX > 0 )
2822  {
2823  if (pView)
2824  aScrSize.setWidth( pView->GetGridWidth(eHWhich) );
2825  if ( nClickX > aScrSize.Width() )
2826  ++rPosX;
2827  }
2828  if ( rPosY == nStartPosY && nClickY > 0 )
2829  {
2830  if (pView)
2831  aScrSize.setHeight( pView->GetGridHeight(eVWhich) );
2832  if ( nClickY > aScrSize.Height() )
2833  ++rPosY;
2834  }
2835 
2836  rPosX = std::clamp(rPosX, SCCOL(0), mrDoc.MaxCol());
2837  rPosY = std::clamp(rPosY, SCROW(0), mrDoc.MaxRow());
2838 
2839  if (!(bTestMerge && bForCurTab))
2840  return;
2841 
2842  // public method to adapt position
2843  SCCOL nOrigX = rPosX;
2844  SCROW nOrigY = rPosY;
2845  mrDoc.SkipOverlapped(rPosX, rPosY, nTabNo);
2846  bool bHOver = (nOrigX != rPosX);
2847  bool bVOver = (nOrigY != rPosY);
2848 
2849  if ( !(bRepair && ( bHOver || bVOver )) )
2850  return;
2851 
2852  const ScMergeAttr* pMerge = mrDoc.GetAttr(rPosX, rPosY, nTabNo, ATTR_MERGE);
2853  if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
2854  ( bVOver && pMerge->GetRowMerge() <= 1 ) )
2855  {
2856  OSL_FAIL("merge error found");
2857 
2858  mrDoc.RemoveFlagsTab(0, 0, mrDoc.MaxCol(), mrDoc.MaxRow(), nTabNo, ScMF::Hor | ScMF::Ver);
2859  SCCOL nEndCol = mrDoc.MaxCol();
2860  SCROW nEndRow = mrDoc.MaxRow();
2861  mrDoc.ExtendMerge(0, 0, nEndCol, nEndRow, nTabNo, true);
2862  if (pDocShell)
2863  pDocShell->PostPaint(ScRange(0, 0, nTabNo, mrDoc.MaxCol(), mrDoc.MaxRow(), nTabNo),
2865  }
2866 }
2867 
2868 void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
2869  SCCOL nPosX, SCROW nPosY, bool& rLeft, bool& rTop )
2870 {
2871  bool bLayoutRTL = mrDoc.IsLayoutRTL(nTabNo);
2872  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
2873 
2874  Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, true );
2875  tools::Long nSizeX;
2876  tools::Long nSizeY;
2877  GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
2878  rLeft = ( rClickPos.X() - aCellStart.X() ) * nLayoutSign <= nSizeX / 2;
2879  rTop = rClickPos.Y() - aCellStart.Y() <= nSizeY / 2;
2880 }
2881 
2882 void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX )
2883 {
2884  // in the tiled rendering case, nPosX [the leftmost visible column] must be 0
2885  bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
2886  if (nNewPosX != 0 && !bIsTiledRendering)
2887  {
2888  SCCOL nOldPosX = pThisTab->nPosX[eWhich];
2889  tools::Long nTPosX = pThisTab->nTPosX[eWhich];
2890  tools::Long nPixPosX = pThisTab->nPixPosX[eWhich];
2891  SCCOL i;
2892  if ( nNewPosX > nOldPosX )
2893  for ( i=nOldPosX; i<nNewPosX; i++ )
2894  {
2895  tools::Long nThis = mrDoc.GetColWidth(i, nTabNo);
2896  nTPosX -= nThis;
2897  nPixPosX -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
2898  }
2899  else
2900  for ( i=nNewPosX; i<nOldPosX; i++ )
2901  {
2902  tools::Long nThis = mrDoc.GetColWidth(i, nTabNo);
2903  nTPosX += nThis;
2904  nPixPosX += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
2905  }
2906 
2907  pThisTab->nPosX[eWhich] = nNewPosX;
2908  pThisTab->nTPosX[eWhich] = nTPosX;
2910  pThisTab->nPixPosX[eWhich] = nPixPosX;
2911  }
2912  else
2913  {
2914  pThisTab->nPixPosX[eWhich] =
2915  pThisTab->nTPosX[eWhich] =
2916  pThisTab->nMPosX[eWhich] =
2917  pThisTab->nPosX[eWhich] = 0;
2918  }
2919 }
2920 
2921 void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY )
2922 {
2923  // in the tiled rendering case, nPosY [the topmost visible row] must be 0
2924  bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
2925  if (nNewPosY != 0 && !bIsTiledRendering)
2926  {
2927  SCROW nOldPosY = pThisTab->nPosY[eWhich];
2928  tools::Long nTPosY = pThisTab->nTPosY[eWhich];
2929  tools::Long nPixPosY = pThisTab->nPixPosY[eWhich];
2930  SCROW i, nHeightEndRow;
2931  if ( nNewPosY > nOldPosY )
2932  for ( i=nOldPosY; i<nNewPosY; i++ )
2933  {
2934  tools::Long nThis = mrDoc.GetRowHeight(i, nTabNo, nullptr, &nHeightEndRow);
2935  SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i;
2936  i = nHeightEndRow;
2937  nTPosY -= nThis * nRows;
2938  nPixPosY -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
2939  }
2940  else
2941  for ( i=nNewPosY; i<nOldPosY; i++ )
2942  {
2943  tools::Long nThis = mrDoc.GetRowHeight(i, nTabNo, nullptr, &nHeightEndRow);
2944  SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i;
2945  i = nHeightEndRow;
2946  nTPosY += nThis * nRows;
2947  nPixPosY += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
2948  }
2949 
2950  pThisTab->nPosY[eWhich] = nNewPosY;
2951  pThisTab->nTPosY[eWhich] = nTPosY;
2953  pThisTab->nPixPosY[eWhich] = nPixPosY;
2954  }
2955  else
2956  {
2957  pThisTab->nPixPosY[eWhich] =
2958  pThisTab->nTPosY[eWhich] =
2959  pThisTab->nMPosY[eWhich] =
2960  pThisTab->nPosY[eWhich] = 0;
2961  }
2962 }
2963 
2964 void ScViewData::RecalcPixPos() // after zoom changes
2965 {
2966  for (sal_uInt16 eWhich=0; eWhich<2; eWhich++)
2967  {
2968  tools::Long nPixPosX = 0;
2969  SCCOL nPosX = pThisTab->nPosX[eWhich];
2970  for (SCCOL i=0; i<nPosX; i++)
2971  nPixPosX -= ToPixel(mrDoc.GetColWidth(i, nTabNo), nPPTX);
2972  pThisTab->nPixPosX[eWhich] = nPixPosX;
2973 
2974  tools::Long nPixPosY = 0;
2975  SCROW nPosY = pThisTab->nPosY[eWhich];
2976  for (SCROW j=0; j<nPosY; j++)
2977  nPixPosY -= ToPixel(mrDoc.GetRowHeight(j, nTabNo), nPPTY);
2978  pThisTab->nPixPosY[eWhich] = nPixPosY;
2979  }
2980 }
2981 
2983 {
2985  pThisTab->nMPosY[WhichV(eWhich)] ) );
2986  return aLogicMode;
2987 }
2988 
2990 {
2991  aLogicMode.SetOrigin( Point() );
2992  return aLogicMode;
2993 }
2994 
2995 void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
2996 {
2997  SCCOL nCol;
2998  SCROW nRow;
2999  sal_uInt16 nTSize;
3000  tools::Long nSizePix;
3001  tools::Long nScrPosX = 0;
3002  tools::Long nScrPosY = 0;
3003 
3005  SetPosX( SC_SPLIT_LEFT, nCol1 );
3006  SetPosY( SC_SPLIT_BOTTOM, nRow1 );
3007 
3008  for (nCol=nCol1; nCol<=nCol2; nCol++)
3009  {
3010  nTSize = mrDoc.GetColWidth(nCol, nTabNo);
3011  if (nTSize)
3012  {
3013  nSizePix = ToPixel( nTSize, nPPTX );
3014  nScrPosX += static_cast<sal_uInt16>(nSizePix);
3015  }
3016  }
3017 
3018  for (nRow=nRow1; nRow<=nRow2; nRow++)
3019  {
3020  nTSize = mrDoc.GetRowHeight(nRow, nTabNo);
3021  if (nTSize)
3022  {
3023  nSizePix = ToPixel( nTSize, nPPTY );
3024  nScrPosY += static_cast<sal_uInt16>(nSizePix);
3025  }
3026  }
3027 
3028  aScrSize = Size( nScrPosX, nScrPosY );
3029 }
3030 
3031 void ScViewData::SetScreenPos( const Point& rVisAreaStart )
3032 {
3033  tools::Long nSize;
3034  tools::Long nTwips;
3035  tools::Long nAdd;
3036  bool bEnd;
3037 
3038  nSize = 0;
3039  nTwips = o3tl::convert(rVisAreaStart.X(), o3tl::Length::mm100, o3tl::Length::twip);
3040  if (mrDoc.IsLayoutRTL(nTabNo))
3041  nTwips = -nTwips;
3042  SCCOL nX1 = 0;
3043  bEnd = false;
3044  while (!bEnd)
3045  {
3046  nAdd = static_cast<tools::Long>(mrDoc.GetColWidth(nX1, nTabNo));
3047  if (nSize + nAdd <= nTwips + 1 && nX1 < mrDoc.MaxCol())
3048  {
3049  nSize += nAdd;
3050  ++nX1;
3051  }
3052  else
3053  bEnd = true;
3054  }
3055 
3056  nSize = 0;
3057  nTwips = o3tl::convert(rVisAreaStart.Y(), o3tl::Length::mm100, o3tl::Length::twip);
3058  SCROW nY1 = 0;
3059  bEnd = false;
3060  while (!bEnd)
3061  {
3062  nAdd = static_cast<tools::Long>(mrDoc.GetRowHeight(nY1, nTabNo));
3063  if (nSize + nAdd <= nTwips + 1 && nY1 < mrDoc.MaxRow())
3064  {
3065  nSize += nAdd;
3066  ++nY1;
3067  }
3068  else
3069  bEnd = true;
3070  }
3071 
3073  SetPosX( SC_SPLIT_LEFT, nX1 );
3074  SetPosY( SC_SPLIT_BOTTOM, nY1 );
3075 
3076  SetCurX( nX1 );
3077  SetCurY( nY1 );
3078 }
3079 
3081 {
3082  SetScreenPos( rVisArea.TopLeft() );
3083 
3084  // here without GetOutputFactor(), since it's for the output into a Metafile
3085 
3086  aScrSize = rVisArea.GetSize();
3087  aScrSize.setWidth(std::round(o3tl::convert( aScrSize.Width(), o3tl::Length::mm100, o3tl::Length::twip) * ScGlobal::nScreenPPTX));
3088  aScrSize.setHeight(std::round(o3tl::convert( aScrSize.Height(), o3tl::Length::mm100, o3tl::Length::twip) * ScGlobal::nScreenPPTY));
3089 }
3090 
3092 {
3093  return pDocShell->GetDocFunc();
3094 }
3095 
3097 {
3098  assert(pView && "GetBindings() without ViewShell");
3099  return pView->GetViewFrame()->GetBindings();
3100 }
3101 
3103 {
3104  assert(pView && "GetDispatcher() without ViewShell");
3105  return *pView->GetViewFrame()->GetDispatcher();
3106 }
3107 
3109 {
3110  return maMarkData;
3111 }
3112 
3114 {
3115  return maMarkData;
3116 }
3117 
3119 {
3120  assert(pView && "GetDialogParent() without ViewShell");
3121  return pView->GetDialogParent();
3122 }
3123 
3125 {
3126  assert(pView && "GetActiveWin() without View");
3127  return pView->GetActiveWin();
3128 }
3129 
3131 {
3132  assert(pView && "GetActiveWin() without View");
3133  return pView->GetActiveWin();
3134 }
3135 
3137 {
3138  assert(pView && "GetScDrawView() without View");
3139  return pView->GetScDrawView();
3140 }
3141 
3143 {
3144  assert(pView && "IsMinimized() without View");
3145  return pView->IsMinimized();
3146 }
3147 
3148 void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY )
3149 {
3150  Fraction aOldX = GetZoomX();
3151  Fraction aOldY = GetZoomY();
3152 
3153  SetZoom( rNewX, rNewY, false );
3154 
3155  Fraction aWidth = GetZoomX();
3156  aWidth *= Fraction( aScrSize.Width(),1 );
3157  aWidth /= aOldX;
3158 
3159  Fraction aHeight = GetZoomY();
3160  aHeight *= Fraction( aScrSize.Height(),1 );
3161  aHeight /= aOldY;
3162 
3163  aScrSize.setWidth( static_cast<tools::Long>(aWidth) );
3164  aScrSize.setHeight( static_cast<tools::Long>(aHeight) );
3165 }
3166 
3168 {
3169  double nOldPPTX = nPPTX;
3170  double nOldPPTY = nPPTY;
3171  nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(GetZoomX());
3172  if (pDocShell)
3173  nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Factor is printer to screen
3174  nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(GetZoomY());
3175 
3176  // if detective objects are present,
3177  // try to adjust horizontal scale so the most common column width has minimal rounding errors,
3178  // to avoid differences between cell and drawing layer output
3179 
3181  {
3182  SCCOL nEndCol = 0;
3183  SCROW nDummy = 0;
3184  mrDoc.GetTableArea(nTabNo, nEndCol, nDummy);
3185  if (nEndCol<20)
3186  nEndCol = 20; // same end position as when determining draw scale
3187 
3188  sal_uInt16 nTwips = mrDoc.GetCommonWidth(nEndCol, nTabNo);
3189  if ( nTwips )
3190  {
3191  double fOriginal = nTwips * nPPTX;
3192  if ( fOriginal < static_cast<double>(nEndCol) )
3193  {
3194  // if one column is smaller than the column count,
3195  // rounding errors are likely to add up to a whole column.
3196 
3197  double fRounded = ::rtl::math::approxFloor( fOriginal + 0.5 );
3198  if ( fRounded > 0.0 )
3199  {
3200  double fScale = fRounded / fOriginal + 1E-6;
3201  if ( fScale >= 0.9 && fScale <= 1.1 )
3202  nPPTX *= fScale;
3203  }
3204  }
3205  }
3206  }
3207 
3209  {
3210  SCTAB nTabCount = maTabData.size();
3211  bool bResetWidths = (nPPTX != nOldPPTX);
3212  bool bResetHeights = (nPPTY != nOldPPTY);
3213  for (SCTAB nTabIdx = 0; nTabIdx < nTabCount; ++nTabIdx)
3214  {
3215  if (!maTabData[nTabIdx])
3216  continue;
3217 
3218  if (bResetWidths)
3219  if (auto* pWHelper = GetLOKWidthHelper(nTabIdx))
3220  pWHelper->invalidateByPosition(0L);
3221 
3222  if (bResetHeights)
3223  if (auto* pHHelper = GetLOKHeightHelper(nTabIdx))
3224  pHHelper->invalidateByPosition(0L);
3225  }
3226  }
3227 }
3228 
3229 #define SC_OLD_TABSEP '/'
3230 #define SC_NEW_TABSEP '+'
3231 
3232 void ScViewData::WriteUserData(OUString& rData)
3233 {
3234  // nZoom (until 364v) or nZoom/nPageZoom/bPageMode (from 364w)
3235  // nTab
3236  // Tab control width
3237  // per sheet:
3238  // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
3239  // PosX[left]/PosX[right]/PosY[top]/PosY[bottom]
3240  // when rows bigger than 8192, "+" instead of "/"
3241 
3242  sal_uInt16 nZoom = static_cast<sal_uInt16>(tools::Long(pThisTab->aZoomY * 100));
3243  rData = OUString::number( nZoom ) + "/";
3244  nZoom = static_cast<sal_uInt16>(tools::Long(pThisTab->aPageZoomY * 100));
3245  rData += OUString::number( nZoom ) + "/";
3246  if (bPagebreak)
3247  rData += "1";
3248  else
3249  rData += "0";
3250 
3251  rData += ";" + OUString::number( nTabNo ) + ";" + TAG_TABBARWIDTH +
3252  OUString::number( pView->GetTabBarWidth() );
3253 
3254  SCTAB nTabCount = mrDoc.GetTableCount();
3255  for (SCTAB i=0; i<nTabCount; i++)
3256  {
3257  rData += ";"; // Numbering must not get mixed up under any circumstances
3258  if (i < static_cast<SCTAB>(maTabData.size()) && maTabData[i])
3259  {
3260  OUString cTabSep(SC_OLD_TABSEP); // like 3.1
3261  if ( maTabData[i]->nCurY > MAXROW_30 ||
3262  maTabData[i]->nPosY[0] > MAXROW_30 || maTabData[i]->nPosY[1] > MAXROW_30 ||
3263  ( maTabData[i]->eVSplitMode == SC_SPLIT_FIX &&
3264  maTabData[i]->nFixPosY > MAXROW_30 ) )
3265  {
3266  cTabSep = OUStringChar(SC_NEW_TABSEP); // in order to not kill a 3.1-version
3267  }
3268 
3269  rData += OUString::number( maTabData[i]->nCurX ) + cTabSep +
3270  OUString::number( maTabData[i]->nCurY ) + cTabSep +
3271  OUString::number( maTabData[i]->eHSplitMode ) + cTabSep +
3272  OUString::number( maTabData[i]->eVSplitMode ) + cTabSep;
3273  if ( maTabData[i]->eHSplitMode == SC_SPLIT_FIX )
3274  rData += OUString::number( maTabData[i]->nFixPosX );
3275  else
3276  rData += OUString::number( maTabData[i]->nHSplitPos );
3277  rData += cTabSep;
3278  if ( maTabData[i]->eVSplitMode == SC_SPLIT_FIX )
3279  rData += OUString::number( maTabData[i]->nFixPosY );
3280  else
3281  rData += OUString::number( maTabData[i]->nVSplitPos );
3282  rData += cTabSep +
3283  OUString::number( maTabData[i]->eWhichActive ) + cTabSep +
3284  OUString::number( maTabData[i]->nPosX[0] ) + cTabSep +
3285  OUString::number( maTabData[i]->nPosX[1] ) + cTabSep +
3286  OUString::number( maTabData[i]->nPosY[0] ) + cTabSep +
3287  OUString::number( maTabData[i]->nPosY[1] );
3288  }
3289  }
3290 }
3291 
3292 void ScViewData::ReadUserData(const OUString& rData)
3293 {
3294  if (rData.isEmpty()) // empty string on "reload"
3295  return; // then exit without assertion
3296 
3297  if ( comphelper::string::getTokenCount(rData, ';') <= 2 )
3298  {
3299  // when reload, in page preview, the preview UserData may have been left intact.
3300  // we don't want the zoom from the page preview here.
3301  OSL_FAIL("ReadUserData: This is not my data");
3302  return;
3303  }
3304 
3305  sal_Int32 nMainIdx {0};
3306  sal_Int32 nIdx {0};
3307 
3308  OUString aZoomStr = rData.getToken(0, ';', nMainIdx); // Zoom/PageZoom/Mode
3309  sal_Unicode cMode = aZoomStr.getToken(2, '/', nIdx)[0]; // 0 or "0"/"1"
3310  SetPagebreakMode( cMode == '1' );
3311  // SetPagebreakMode must always be called due to CalcPPT / RecalcPixPos()
3312 
3313  // sheet may have become invalid (for instance last version):
3314  SCTAB nNewTab = static_cast<SCTAB>(rData.getToken(0, ';', nMainIdx).toUInt32());
3315  if (mrDoc.HasTable(nNewTab))
3316  SetTabNo(nNewTab);
3317 
3318  // if available, get tab bar width:
3319  const sal_Int32 nMainIdxRef {nMainIdx};
3320  OUString aTabOpt = rData.getToken(0, ';', nMainIdx);
3321 
3322  OUString aRest;
3323  if (aTabOpt.startsWith(TAG_TABBARWIDTH, &aRest))
3324  {
3325  pView->SetTabBarWidth(aRest.toInt32());
3326  }
3327  else
3328  {
3329  // Tab bar width not specified, token to be processed again
3330  nMainIdx = nMainIdxRef;
3331  }
3332 
3333  // per sheet
3334  SCTAB nPos = 0;
3335  while ( nMainIdx>0 )
3336  {
3337  aTabOpt = rData.getToken(0, ';', nMainIdx);
3338  EnsureTabDataSize(nPos + 1);
3339  if (!maTabData[nPos])
3340  maTabData[nPos].reset(new ScViewDataTable(&mrDoc));
3341 
3342  sal_Unicode cTabSep = 0;
3344  cTabSep = SC_OLD_TABSEP;
3345  else if (comphelper::string::getTokenCount(aTabOpt, SC_NEW_TABSEP) >= 11)
3346  cTabSep = SC_NEW_TABSEP;
3347  // '+' is only allowed, if we can deal with rows > 8192
3348 
3349  if (cTabSep)
3350  {
3351  nIdx = 0;
3352  maTabData[nPos]->nCurX = mrDoc.SanitizeCol(static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
3353  maTabData[nPos]->nCurY = mrDoc.SanitizeRow(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
3354  maTabData[nPos]->eHSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
3355  maTabData[nPos]->eVSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
3356 
3357  sal_Int32 nTmp{ aTabOpt.getToken(0, cTabSep, nIdx).toInt32() };
3358  if ( maTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
3359  {
3360  maTabData[nPos]->nFixPosX = mrDoc.SanitizeCol(static_cast<SCCOL>(nTmp));
3361  UpdateFixX(nPos);
3362  }
3363  else
3364  maTabData[nPos]->nHSplitPos = nTmp;
3365 
3366  nTmp = aTabOpt.getToken(0, cTabSep, nIdx).toInt32();
3367  if ( maTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
3368  {
3369  maTabData[nPos]->nFixPosY = mrDoc.SanitizeRow(nTmp);
3370  UpdateFixY(nPos);
3371  }
3372  else
3373  maTabData[nPos]->nVSplitPos = nTmp;
3374 
3375  maTabData[nPos]->eWhichActive = static_cast<ScSplitPos>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
3376  maTabData[nPos]->nPosX[0] = mrDoc.SanitizeCol(static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
3377  maTabData[nPos]->nPosX[1] = mrDoc.SanitizeCol(static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()));
3378  maTabData[nPos]->nPosY[0] = mrDoc.SanitizeRow(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
3379  maTabData[nPos]->nPosY[1] = mrDoc.SanitizeRow(aTabOpt.getToken(0, cTabSep, nIdx).toInt32());
3380 
3381  maTabData[nPos]->eWhichActive = maTabData[nPos]->SanitizeWhichActive();
3382  }
3383  ++nPos;
3384  }
3385 
3386  RecalcPixPos();
3387 }
3388 
3390 {
3391  // *** Fill extended document data for export filters ***
3392 
3393  // document settings
3394  ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
3395 
3396  // displayed sheet
3397  rDocSett.mnDisplTab = GetTabNo();
3398 
3399  // width of the tabbar, relative to frame window width
3401  if( rDocSett.mfTabBarWidth < 0.0 )
3403 
3404  bool bLOKActive = comphelper::LibreOfficeKit::isActive();
3405 
3406  // sheet settings
3407  for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab )
3408  {
3409  if( const ScViewDataTable* pViewTab = maTabData[ nTab ].get() )
3410  {
3411  ScExtTabSettings& rTabSett = rDocOpt.GetOrCreateTabSettings( nTab );
3412 
3413  // split mode
3414  ScSplitMode eExHSplit = pViewTab->eHSplitMode;
3415  ScSplitMode eExVSplit = pViewTab->eVSplitMode;
3416  SCCOL nExFixPosX = pViewTab->nFixPosX;
3417  SCROW nExFixPosY = pViewTab->nFixPosY;
3418  tools::Long nExHSplitPos = pViewTab->nHSplitPos;
3419  tools::Long nExVSplitPos = pViewTab->nVSplitPos;
3420 
3421  if (bLOKActive)
3422  {
3423  OverrideWithLOKFreeze(eExHSplit, eExVSplit,
3424  nExFixPosX, nExFixPosY,
3425  nExHSplitPos, nExVSplitPos, nTab);
3426  }
3427 
3428  bool bHSplit = eExHSplit != SC_SPLIT_NONE;
3429  bool bVSplit = eExVSplit != SC_SPLIT_NONE;
3430  bool bRealSplit = (eExHSplit == SC_SPLIT_NORMAL) || (eExVSplit == SC_SPLIT_NORMAL);
3431  bool bFrozen = (eExHSplit == SC_SPLIT_FIX) || (eExVSplit == SC_SPLIT_FIX);
3432  OSL_ENSURE( !bRealSplit || !bFrozen, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
3433  rTabSett.mbFrozenPanes = !bRealSplit && bFrozen;
3434 
3435  // split and freeze position
3436  rTabSett.maSplitPos = Point( 0, 0 );
3437  rTabSett.maFreezePos.Set( 0, 0, nTab );
3438  if( bRealSplit )
3439  {
3440  Point& rSplitPos = rTabSett.maSplitPos;
3441  rSplitPos = Point( bHSplit ? nExHSplitPos : 0, bVSplit ? nExVSplitPos : 0 );
3442  rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MapUnit::MapTwip ) );
3443  if( pDocShell )
3444  rSplitPos.setX( static_cast<tools::Long>(static_cast<double>(rSplitPos.X()) / pDocShell->GetOutputFactor()) );
3445  }
3446  else if( bFrozen )
3447  {
3448  if( bHSplit ) rTabSett.maFreezePos.SetCol( nExFixPosX );
3449  if( bVSplit ) rTabSett.maFreezePos.SetRow( nExFixPosY );
3450  }
3451 
3452  // first visible cell in top-left and additional panes
3453  rTabSett.maFirstVis.Set( pViewTab->nPosX[ SC_SPLIT_LEFT ], pViewTab->nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ], nTab );
3454  rTabSett.maSecondVis.Set( pViewTab->nPosX[ SC_SPLIT_RIGHT ], pViewTab->nPosY[ SC_SPLIT_BOTTOM ], nTab );
3455 
3456  // active pane
3457  switch( pViewTab->eWhichActive )
3458  {
3459  // no horizontal split -> always use left panes
3460  // no vertical split -> always use top panes
3461  case SC_SPLIT_TOPLEFT:
3462  rTabSett.meActivePane = SCEXT_PANE_TOPLEFT;
3463  break;
3464  case SC_SPLIT_TOPRIGHT:
3465  rTabSett.meActivePane = bHSplit ? SCEXT_PANE_TOPRIGHT : SCEXT_PANE_TOPLEFT;
3466  break;
3467  case SC_SPLIT_BOTTOMLEFT:
3468  rTabSett.meActivePane = bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT;
3469  break;
3470  case SC_SPLIT_BOTTOMRIGHT:
3471  rTabSett.meActivePane = bHSplit ?
3474  break;
3475  }
3476 
3477  // cursor position
3478  rTabSett.maCursor.Set( pViewTab->nCurX, pViewTab->nCurY, nTab );
3479 
3480  // sheet selection and selected ranges
3481  const ScMarkData& rMarkData = GetMarkData();
3482  rTabSett.mbSelected = rMarkData.GetTableSelect( nTab );
3483  rMarkData.FillRangeListWithMarks( &rTabSett.maSelection, true );
3484 
3485  // grid color
3486  rTabSett.maGridColor = COL_AUTO;
3487  const Color& rGridColor = maOptions.GetGridColor();
3488  if (rGridColor != SC_STD_GRIDCOLOR)
3489  rTabSett.maGridColor = rGridColor;
3490  rTabSett.mbShowGrid = pViewTab->bShowGrid;
3491 
3492  // view mode and zoom
3493  rTabSett.mbPageMode = bPagebreak;
3494  rTabSett.mnNormalZoom = static_cast< tools::Long >( pViewTab->aZoomY * Fraction( 100.0 ) );
3495  rTabSett.mnPageZoom = static_cast< tools::Long >( pViewTab->aPageZoomY * Fraction( 100.0 ) );
3496  }
3497  }
3498 }
3499 
3501 {
3502  // *** Get extended document data from import filters ***
3503 
3504  if( !rDocOpt.IsChanged() ) return;
3505 
3506  // document settings
3507  const ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
3508 
3509  // displayed sheet
3510  SetTabNo( rDocSett.mnDisplTab );
3511 
3512  /* Width of the tabbar, relative to frame window width. We do not have the
3513  correct width of the frame window here -> store in ScTabView, which sets
3514  the size in the next resize. */
3516 
3517  // sheet settings
3518  SCTAB nLastTab = rDocOpt.GetLastTab();
3519  if (static_cast<SCTAB>(maTabData.size()) <= nLastTab)
3520  maTabData.resize(nLastTab+1);
3521 
3522  for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab )
3523  {
3524  if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) )
3525  {
3526  if( !maTabData[ nTab ] )
3527  maTabData[nTab].reset(new ScViewDataTable(&mrDoc));
3528 
3529  const ScExtTabSettings& rTabSett = *pTabSett;
3530  ScViewDataTable& rViewTab = *maTabData[ nTab ];
3531 
3532  // split mode initialization
3533  bool bFrozen = rTabSett.mbFrozenPanes;
3534  bool bHSplit = bFrozen ? (rTabSett.maFreezePos.Col() > 0) : (rTabSett.maSplitPos.X() > 0);
3535  bool bVSplit = bFrozen ? (rTabSett.maFreezePos.Row() > 0) : (rTabSett.maSplitPos.Y() > 0);
3536 
3537  // first visible cell of top-left pane and additional panes
3538  if (rTabSett.maFirstVis.IsValid())
3539  {
3540  rViewTab.nPosX[ SC_SPLIT_LEFT ] = rTabSett.maFirstVis.Col();
3541  rViewTab.nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ] = rTabSett.maFirstVis.Row();
3542  }
3543 
3544  if (rTabSett.maSecondVis.IsValid())
3545  {
3546  if (bHSplit)
3547  rViewTab.nPosX[ SC_SPLIT_RIGHT ] = rTabSett.maSecondVis.Col();
3548  if (bVSplit)
3549  rViewTab.nPosY[ SC_SPLIT_BOTTOM ] = rTabSett.maSecondVis.Row();
3550  }
3551 
3552  // split mode, split and freeze position
3553  rViewTab.eHSplitMode = rViewTab.eVSplitMode = SC_SPLIT_NONE;
3554  rViewTab.nHSplitPos = rViewTab.nVSplitPos = 0;
3555  rViewTab.nFixPosX = 0;
3556  rViewTab.nFixPosY = 0;
3557  if( bFrozen )
3558  {
3559  if( bHSplit )
3560  {
3561  rViewTab.eHSplitMode = SC_SPLIT_FIX;
3562  rViewTab.nFixPosX = rTabSett.maFreezePos.Col();
3563  UpdateFixX( nTab );
3564  }
3565  if( bVSplit )
3566  {
3567  rViewTab.eVSplitMode = SC_SPLIT_FIX;
3568  rViewTab.nFixPosY = rTabSett.maFreezePos.Row();
3569  UpdateFixY( nTab );
3570  }
3571  }
3572  else
3573  {
3575  rTabSett.maSplitPos, MapMode( MapUnit::MapTwip ) );
3576  // the test for use of printer metrics for text formatting here
3577  // effectively results in the nFactor = 1.0 regardless of the Option setting.
3578  if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg())
3579  {
3580  double nFactor = pDocShell->GetOutputFactor();
3581  aPixel.setX( static_cast<tools::Long>( aPixel.X() * nFactor + 0.5 ) );
3582  }
3583 
3584  bHSplit = bHSplit && aPixel.X() > 0;
3585  bVSplit = bVSplit && aPixel.Y() > 0;
3586  if( bHSplit )
3587  {
3588  rViewTab.eHSplitMode = SC_SPLIT_NORMAL;
3589  rViewTab.nHSplitPos = aPixel.X();
3590  }
3591  if( bVSplit )
3592  {
3593  rViewTab.eVSplitMode = SC_SPLIT_NORMAL;
3594  rViewTab.nVSplitPos = aPixel.Y();
3595  }
3596  }
3597 
3598  // active pane
3600  switch( rTabSett.meActivePane )
3601  {
3602  // no horizontal split -> always use left panes
3603  // no vertical split -> always use *bottom* panes
3604  case SCEXT_PANE_TOPLEFT:
3605  ePos = bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
3606  break;
3607  case SCEXT_PANE_TOPRIGHT:
3608  ePos = bHSplit ?
3609  (bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT) :
3610  (bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT);
3611  break;
3612  case SCEXT_PANE_BOTTOMLEFT:
3613  ePos = SC_SPLIT_BOTTOMLEFT;
3614  break;
3616  ePos = bHSplit ? SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_BOTTOMLEFT;
3617  break;
3618  }
3619  rViewTab.eWhichActive = ePos;
3620 
3621  // cursor position
3622  const ScAddress& rCursor = rTabSett.maCursor;
3623  if( rCursor.IsValid() )
3624  {
3625  rViewTab.nCurX = rCursor.Col();
3626  rViewTab.nCurY = rCursor.Row();
3627  }
3628 
3629  // sheet selection and selected ranges
3630  ScMarkData& rMarkData = GetMarkData();
3631  rMarkData.SelectTable( nTab, rTabSett.mbSelected );
3632 
3633  // zoom for each sheet
3634  if( rTabSett.mnNormalZoom )
3635  rViewTab.aZoomX = rViewTab.aZoomY = Fraction( rTabSett.mnNormalZoom, 100 );
3636  if( rTabSett.mnPageZoom )
3637  rViewTab.aPageZoomX = rViewTab.aPageZoomY = Fraction( rTabSett.mnPageZoom, 100 );
3638 
3639  rViewTab.bShowGrid = rTabSett.mbShowGrid;
3640 
3641  // get some settings from displayed Excel sheet, set at Calc document
3642  if( nTab == GetTabNo() )
3643  {
3644  // grid color -- #i47435# set automatic grid color explicitly
3645  Color aGridColor(rTabSett.maGridColor);
3646  if (aGridColor == COL_AUTO)
3647  aGridColor = SC_STD_GRIDCOLOR;
3648  maOptions.SetGridColor(aGridColor, EMPTY_OUSTRING);
3649 
3650  // view mode and default zoom (for new sheets) from current sheet
3651  if( rTabSett.mnNormalZoom )
3652  aDefZoomX = aDefZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
3653  if( rTabSett.mnPageZoom )
3654  aDefPageZoomX = aDefPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
3655  /* #i46820# set pagebreak mode via SetPagebreakMode(), this will
3656  update map modes that are needed to draw text correctly. */
3657  SetPagebreakMode( rTabSett.mbPageMode );
3658  }
3659  }
3660  }
3661 
3664 
3665  // RecalcPixPos or so - also nMPos - also for ReadUserData ??!?!
3666 }
3667 
3668 void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings) const
3669 {
3670  rSettings.realloc(SC_VIEWSETTINGS_COUNT);
3671  // + 1, because we have to put the view id in the sequence
3672  beans::PropertyValue* pSettings = rSettings.getArray();
3673 
3674  sal_uInt16 nViewID(pView->GetViewFrame()->GetCurViewId());
3675  pSettings[SC_VIEW_ID].Name = SC_VIEWID;
3676  pSettings[SC_VIEW_ID].Value <<= SC_VIEW + OUString::number(nViewID);
3677 
3678  uno::Reference<container::XNameContainer> xNameContainer =
3679  document::NamedPropertyValues::create( comphelper::getProcessComponentContext() );
3680  for (SCTAB nTab=0; nTab<static_cast<SCTAB>(maTabData.size()); nTab++)
3681  {
3682  if (maTabData[nTab])
3683  {
3684  uno::Sequence <beans::PropertyValue> aTableViewSettings;
3685  maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab);
3686  OUString sTabName;
3687  GetDocument().GetName( nTab, sTabName );
3688  try
3689  {
3690  xNameContainer->insertByName(sTabName, uno::Any(aTableViewSettings));
3691  }
3692  //#101739#; two tables with the same name are possible
3693  catch ( container::ElementExistException& )
3694  {
3695  OSL_FAIL("seems there are two tables with the same name");
3696  }
3697  catch ( uno::RuntimeException& )
3698  {
3699  OSL_FAIL("something went wrong");
3700  }
3701  }
3702  }
3703  pSettings[SC_TABLE_VIEWSETTINGS].Name = SC_TABLES;
3704  pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
3705 
3706  OUString sName;
3707  GetDocument().GetName( nTabNo, sName );
3708  pSettings[SC_ACTIVE_TABLE].Name = SC_ACTIVETABLE;
3709  pSettings[SC_ACTIVE_TABLE].Value <<= sName;
3711  pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32(pView->GetTabBarWidth());
3712  sal_Int32 nZoomValue = tools::Long(pThisTab->aZoomY * 100);
3713  sal_Int32 nPageZoomValue = tools::Long(pThisTab->aPageZoomY * 100);
3714  pSettings[SC_ZOOM_TYPE].Name = SC_ZOOMTYPE;
3715  pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16(pThisTab->eZoomType);
3716  pSettings[SC_ZOOM_VALUE].Name = SC_ZOOMVALUE;
3717  pSettings[SC_ZOOM_VALUE].Value <<= nZoomValue;
3719  pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
3721  pSettings[SC_PAGE_BREAK_PREVIEW].Value <<= bPagebreak;
3722 
3723  pSettings[SC_SHOWZERO].Name = SC_UNO_SHOWZERO;
3724  pSettings[SC_SHOWZERO].Value <<= maOptions.GetOption(VOPT_NULLVALS);
3725  pSettings[SC_SHOWNOTES].Name = SC_UNO_SHOWNOTES;
3726  pSettings[SC_SHOWNOTES].Value <<= maOptions.GetOption(VOPT_NOTES);
3727  pSettings[SC_SHOWGRID].Name = SC_UNO_SHOWGRID;
3728  pSettings[SC_SHOWGRID].Value <<= maOptions.GetOption(VOPT_GRID);
3729  pSettings[SC_GRIDCOLOR].Name = SC_UNO_GRIDCOLOR;
3730  OUString aColorName;
3731  Color aColor = maOptions.GetGridColor(&aColorName);
3732  pSettings[SC_GRIDCOLOR].Value <<= aColor;
3733  pSettings[SC_SHOWPAGEBR].Name = SC_UNO_SHOWPAGEBR;
3734  pSettings[SC_SHOWPAGEBR].Value <<= maOptions.GetOption(VOPT_PAGEBREAKS);
3735  pSettings[SC_COLROWHDR].Name = SC_UNO_COLROWHDR;
3736  pSettings[SC_COLROWHDR].Value <<= maOptions.GetOption(VOPT_HEADER);
3737  pSettings[SC_SHEETTABS].Name = SC_UNO_SHEETTABS;
3738  pSettings[SC_SHEETTABS].Value <<= maOptions.GetOption(VOPT_TABCONTROLS);
3739  pSettings[SC_OUTLSYMB].Name = SC_UNO_OUTLSYMB;
3740  pSettings[SC_OUTLSYMB].Value <<= maOptions.GetOption(VOPT_OUTLINER);
3741  pSettings[SC_VALUE_HIGHLIGHTING].Name = SC_UNO_VALUEHIGH;
3742  pSettings[SC_VALUE_HIGHLIGHTING].Value <<= maOptions.GetOption(VOPT_SYNTAX);
3743 
3744  const ScGridOptions& aGridOpt = maOptions.GetGridOptions();
3745  pSettings[SC_SNAPTORASTER].Name = SC_UNO_SNAPTORASTER;
3746  pSettings[SC_SNAPTORASTER].Value <<= aGridOpt.GetUseGridSnap();
3747  pSettings[SC_RASTERVIS].Name = SC_UNO_RASTERVIS;
3748  pSettings[SC_RASTERVIS].Value <<= aGridOpt.GetGridVisible();
3749  pSettings[SC_RASTERRESX].Name = SC_UNO_RASTERRESX;
3750  pSettings[SC_RASTERRESX].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDrawX());
3751  pSettings[SC_RASTERRESY].Name = SC_UNO_RASTERRESY;
3752  pSettings[SC_RASTERRESY].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDrawY());
3753  pSettings[SC_RASTERSUBX].Name = SC_UNO_RASTERSUBX;
3754  pSettings[SC_RASTERSUBX].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDivisionX());
3755  pSettings[SC_RASTERSUBY].Name = SC_UNO_RASTERSUBY;
3756  pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32>(aGridOpt.GetFieldDivisionY());
3757  pSettings[SC_RASTERSYNC].Name = SC_UNO_RASTERSYNC;
3758  pSettings[SC_RASTERSYNC].Value <<= aGridOpt.GetSynchronize();
3759 
3760  // Common SdrModel processing
3762 }
3763 
3764 void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
3765 {
3766  std::vector<bool> aHasZoomVect( GetDocument().GetTableCount(), false );
3767 
3768  sal_Int32 nTemp32(0);
3769  sal_Int16 nTemp16(0);
3770  bool bPageMode(false);
3771 
3772  EnsureTabDataSize(GetDocument().GetTableCount());
3773 
3774  for (const auto& rSetting : rSettings)
3775  {
3776  // SC_VIEWID has to parse and use by mba
3777  OUString sName(rSetting.Name);
3778  if (sName == SC_TABLES)
3779  {
3780  uno::Reference<container::XNameContainer> xNameContainer;
3781  if ((rSetting.Value >>= xNameContainer) && xNameContainer->hasElements())
3782  {
3783  const uno::Sequence< OUString > aNames(xNameContainer->getElementNames());
3784  for (const OUString& sTabName : aNames)
3785  {
3786  SCTAB nTab(0);
3787  if (GetDocument().GetTable(sTabName, nTab))
3788  {
3789  uno::Any aAny = xNameContainer->getByName(sTabName);
3790  uno::Sequence<beans::PropertyValue> aTabSettings;
3791  if (aAny >>= aTabSettings)
3792  {
3793  EnsureTabDataSize(nTab + 1);
3794  if (!maTabData[nTab])
3795  maTabData[nTab].reset(new ScViewDataTable(&mrDoc));
3796 
3797  bool bHasZoom = false;
3798  maTabData[nTab]->ReadUserDataSequence(aTabSettings, *this, nTab, bHasZoom);
3799  aHasZoomVect[nTab] = bHasZoom;
3800  }
3801  }
3802  }
3803  }
3804  }
3805  else if (sName == SC_ACTIVETABLE)
3806  {
3807  OUString sTabName;
3808  if(rSetting.Value >>= sTabName)
3809  {
3810  SCTAB nTab(0);
3811  if (GetDocument().GetTable(sTabName, nTab))
3812  nTabNo = nTab;
3813  }
3814  }
3815  else if (sName == SC_HORIZONTALSCROLLBARWIDTH)
3816  {
3817  if (rSetting.Value >>= nTemp32)
3818  pView->SetTabBarWidth(nTemp32);
3819  }
3820  else if (sName == SC_RELHORIZONTALTABBARWIDTH)
3821  {
3822  double fWidth = 0.0;
3823  if (rSetting.Value >>= fWidth)
3824  pView->SetPendingRelTabBarWidth( fWidth );
3825  }
3826  else if (sName == SC_ZOOMTYPE)
3827  {
3828  if (rSetting.Value >>= nTemp16)
3829  eDefZoomType = SvxZoomType(nTemp16);
3830  }
3831  else if (sName == SC_ZOOMVALUE)
3832  {
3833  if (rSetting.Value >>= nTemp32)
3834  {
3835  Fraction aZoom(nTemp32, 100);
3836  aDefZoomX = aDefZoomY = aZoom;
3837  }
3838  }
3839  else if (sName == SC_PAGEVIEWZOOMVALUE)
3840  {
3841  if (rSetting.Value >>= nTemp32)
3842  {
3843  Fraction aZoom(nTemp32, 100);
3844  aDefPageZoomX = aDefPageZoomY = aZoom;
3845  }
3846  }
3847  else if (sName == SC_SHOWPAGEBREAKPREVIEW)
3848  bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value );
3849  else if ( sName == SC_UNO_SHOWZERO )
3851  else if ( sName == SC_UNO_SHOWNOTES )
3853  else if ( sName == SC_UNO_SHOWGRID )
3855  else if ( sName == SC_UNO_GRIDCOLOR )
3856  {
3857  Color aColor;
3858  if (rSetting.Value >>= aColor)
3859  {
3860  // #i47435# set automatic grid color explicitly
3861  if( aColor == COL_AUTO )
3862  aColor = SC_STD_GRIDCOLOR;
3863  maOptions.SetGridColor(aColor, OUString());
3864  }
3865  }
3866  else if ( sName == SC_UNO_SHOWPAGEBR )
3868  else if ( sName == SC_UNO_COLROWHDR )
3870  else if ( sName == SC_UNO_SHEETTABS )
3872  else if ( sName == SC_UNO_OUTLSYMB )
3874  else if ( sName == SC_UNO_SHOWOBJ )
3875  {
3876  // #i80528# placeholders not supported anymore
3877  if ( rSetting.Value >>= nTemp16 )
3879  }
3880  else if ( sName == SC_UNO_SHOWCHARTS )
3881  {
3882  // #i80528# placeholders not supported anymore
3883  if ( rSetting.Value >>= nTemp16 )
3885  }
3886  else if ( sName == SC_UNO_SHOWDRAW )
3887  {
3888  // #i80528# placeholders not supported anymore
3889  if ( rSetting.Value >>= nTemp16 )
3891  }
3892  else if ( sName.compareToAscii( SC_UNO_VALUEHIGH ) == 0 )
3894  else
3895  {
3897  if ( sName == SC_UNO_SNAPTORASTER )
3898  aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value ) );
3899  else if ( sName == SC_UNO_RASTERVIS )
3900  aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value ) );
3901  else if ( sName == SC_UNO_RASTERRESX )
3902  aGridOpt.SetFieldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3903  else if ( sName == SC_UNO_RASTERRESY )
3904  aGridOpt.SetFieldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3905  else if ( sName == SC_UNO_RASTERSUBX )
3906  aGridOpt.SetFieldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3907  else if ( sName == SC_UNO_RASTERSUBY )
3908  aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSetting.Value ) ) );
3909  else if ( sName == SC_UNO_RASTERSYNC )
3910  aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value ) );
3911  // Fallback to common SdrModel processing
3912  else GetDocument().GetDrawLayer()->ReadUserDataSequenceValue(&rSetting);
3913 
3914  maOptions.SetGridOptions(aGridOpt);
3915  }
3916  }
3917 
3918  // copy default zoom to sheets where a different one wasn't specified
3919  for (SCTAB nZoomTab=0; nZoomTab< static_cast<SCTAB>(maTabData.size()); ++nZoomTab)
3920  if (maTabData[nZoomTab] && ( nZoomTab >= static_cast<SCTAB>(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] ))
3921  {
3922  maTabData[nZoomTab]->eZoomType = eDefZoomType;
3923  maTabData[nZoomTab]->aZoomX = aDefZoomX;
3924  maTabData[nZoomTab]->aZoomY = aDefZoomY;
3925  maTabData[nZoomTab]->aPageZoomX = aDefPageZoomX;
3926  maTabData[nZoomTab]->aPageZoomY = aDefPageZoomY;
3927  }
3928 
3929  if (rSettings.hasElements())
3930  SetPagebreakMode( bPageMode );
3931 
3932  // #i47426# write view options to document, needed e.g. for Excel export
3934 
3937 }
3938 
3940 {
3941  // if visibility of horizontal ScrollBar is changed, TabBar may have to be resized...
3942  bool bHScrollChanged = (rOpt.GetOption(VOPT_HSCROLL) != maOptions.GetOption(VOPT_HSCROLL));
3943 
3944  // if graphics are turned on or off, animation has to be started or stopped
3945  // graphics are controlled by VOBJ_TYPE_OLE
3946  bool bGraphicsChanged = (maOptions.GetObjMode(VOBJ_TYPE_OLE) !=
3947  rOpt.GetObjMode(VOBJ_TYPE_OLE) );
3948 
3949  maOptions = rOpt;
3950  OSL_ENSURE( pView, "No View" );
3951 
3952  if( pView )
3953  {
3954  pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged );
3955  }
3956 }
3957 
3959 {
3960  OSL_ENSURE( pView, "GetMousePosPixel() without View" );
3961  return pView->GetMousePosPixel();
3962 }
3963 
3965 {
3966  if (pView)
3967  pView->UpdateInputHandler(bForce);
3968 }
3969 
3970 bool ScViewData::IsOle() const
3971 {
3972  return pDocShell && pDocShell->IsOle();
3973 }
3974 
3975 bool ScViewData::UpdateFixX( SCTAB nTab ) // true = value changed
3976 {
3977  if (!ValidTab(nTab)) // Default
3978  nTab=nTabNo; // current table
3979 
3980  if (!pView || maTabData[nTab]->eHSplitMode != SC_SPLIT_FIX)
3981  return false;
3982 
3983  ScDocument& rLocalDoc = GetDocument();
3984  if (!rLocalDoc.HasTable(nTab)) // if called from reload, the sheet may not exist
3985  return false;
3986 
3987  SCCOL nFix = maTabData[nTab]->nFixPosX;
3988  tools::Long nNewPos = 0;
3989  for (SCCOL nX=maTabData[nTab]->nPosX[SC_SPLIT_LEFT]; nX<nFix; nX++)
3990  {
3991  sal_uInt16 nTSize = rLocalDoc.GetColWidth( nX, nTab );
3992  if (nTSize)
3993  {
3994  tools::Long nPix = ToPixel( nTSize, nPPTX );
3995  nNewPos += nPix;
3996  }
3997  }
3998  nNewPos += pView->GetGridOffset().X();
3999  if (nNewPos != maTabData[nTab]->nHSplitPos)
4000  {
4001  maTabData[nTab]->nHSplitPos = nNewPos;
4002  if (nTab == nTabNo)
4003  RecalcPixPos(); // should not be needed
4004  return true;
4005  }
4006 
4007  return false;
4008 }
4009 
4010 bool ScViewData::UpdateFixY( SCTAB nTab ) // true = value changed
4011 {
4012  if (!ValidTab(nTab)) // Default
4013  nTab=nTabNo; // current table
4014 
4015  if (!pView || maTabData[nTab]->eVSplitMode != SC_SPLIT_FIX)
4016  return false;
4017 
4018  ScDocument& rLocalDoc = GetDocument();
4019  if (!rLocalDoc.HasTable(nTab)) // if called from reload, the sheet may not exist
4020  return false;
4021 
4022  SCROW nFix = maTabData[nTab]->nFixPosY;
4023  tools::Long nNewPos = 0;
4024  for (SCROW nY=maTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++)
4025  {
4026  sal_uInt16 nTSize = rLocalDoc.GetRowHeight( nY, nTab );
4027  if (nTSize)
4028  {
4029  tools::Long nPix = ToPixel( nTSize, nPPTY );
4030  nNewPos += nPix;
4031  }
4032  }
4033  nNewPos += pView->GetGridOffset().Y();
4034  if (nNewPos != maTabData[nTab]->nVSplitPos)
4035  {
4036  maTabData[nTab]->nVSplitPos = nNewPos;
4037  if (nTab == nTabNo)
4038  RecalcPixPos(); // should not be needed
4039  return true;
4040  }
4041 
4042  return false;
4043 }
4044 
4046 {
4047  ScDocument& rLocalDoc = GetDocument();
4048  bool bOnlineSpell = rLocalDoc.GetDocOptions().IsAutoSpell();
4049 
4050  EEControlBits nCntrl = rOutl.GetControlWord();
4051  nCntrl |= EEControlBits::MARKNONURLFIELDS;
4052  nCntrl &= ~EEControlBits::MARKURLFIELDS; // URLs not shaded for output
4053  nCntrl |= EEControlBits::AUTOCORRECT;
4054  if( bOnlineSpell )
4055  nCntrl |= EEControlBits::ONLINESPELLING;
4056  else
4057  nCntrl &= ~EEControlBits::ONLINESPELLING;
4058  rOutl.SetControlWord(nCntrl);
4059 
4060  rOutl.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule, CalcFieldValueHdl ) );
4061 
4062  // don't call GetSpellChecker if online spelling isn't enabled.
4063  // The language for AutoCorrect etc. is taken from the pool defaults
4064  // (set in ScDocument::UpdateDrawLanguages)
4065 
4066  if ( bOnlineSpell )
4067  {
4068  css::uno::Reference<css::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
4069  rOutl.SetSpeller( xXSpellChecker1 );
4070  }
4071 
4073  rLocalDoc.GetEditTextDirection( nTabNo ) );
4074 }
4075 
4077 {
4078  return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
4079 }
4080 
4081 void ScViewData::SetRefStart( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
4082 {
4083  nRefStartX = nNewX; nRefStartY = nNewY; nRefStartZ = nNewZ;
4084 }
4085 
4086 void ScViewData::SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
4087 {
4088  nRefEndX = nNewX; nRefEndY = nNewY; nRefEndZ = nNewZ;
4089 }
4090 
4091 void ScViewData::AddPixelsWhile( tools::Long & rScrY, tools::Long nEndPixels, SCROW & rPosY,
4092  SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
4093 {
4094  SCROW nRow = rPosY;
4095  while (rScrY <= nEndPixels && nRow <= nEndRow)
4096  {
4097  SCROW nHeightEndRow;
4098  sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, nullptr, &nHeightEndRow);
4099  if (nHeightEndRow > nEndRow)
4100  nHeightEndRow = nEndRow;
4101  if (!nHeight)
4102  {
4103  if (ValidTab(nTabNo) && nTabNo <= pDoc->GetMaxTableNumber())
4104  nRow = nHeightEndRow + 1;
4105  else
4106  break;
4107  }
4108  else
4109  {
4110  SCROW nRows = nHeightEndRow - nRow + 1;
4111  sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
4112  sal_Int64 nAdd = nPixel * nRows;
4113  if (nAdd + rScrY > nEndPixels)
4114  {
4115  sal_Int64 nDiff = rScrY + nAdd - nEndPixels;
4116  nRows -= static_cast<SCROW>(nDiff / nPixel);
4117  nAdd = nPixel * nRows;
4118  // We're looking for a value that satisfies loop condition.
4119  if (nAdd + rScrY <= nEndPixels)
4120  {
4121  ++nRows;
4122  nAdd += nPixel;
4123  }
4124  }
4125  rScrY += static_cast<tools::Long>(nAdd);
4126  nRow += nRows;
4127  }
4128  }
4129  if (nRow > rPosY)
4130  --nRow;
4131  rPosY = nRow;
4132 }
4133 
4135  SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
4136  SCTAB nTabNo )
4137 {
4138  SCROW nRow = rPosY;
4139  while (rScrY <= nEndPixels && nRow >= nStartRow)
4140  {
4141  SCROW nHeightStartRow;
4142  sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, nullptr);
4143  if (nHeightStartRow < nStartRow)
4144  nHeightStartRow = nStartRow;
4145  if (!nHeight)
4146  nRow = nHeightStartRow - 1;
4147  else
4148  {
4149  SCROW nRows = nRow - nHeightStartRow + 1;
4150  sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
4151  sal_Int64 nAdd = nPixel * nRows;
4152  if (nAdd + rScrY > nEndPixels)
4153  {
4154  sal_Int64 nDiff = nAdd + rScrY - nEndPixels;
4155  nRows -= static_cast<SCROW>(nDiff / nPixel);
4156  nAdd = nPixel * nRows;
4157  // We're looking for a value that satisfies loop condition.
4158  if (nAdd + rScrY <= nEndPixels)
4159  {
4160  ++nRows;
4161  nAdd += nPixel;
4162  }
4163  }
4164  rScrY += static_cast<tools::Long>(nAdd);
4165  nRow -= nRows;
4166  }
4167  }
4168  if (nRow < rPosY)
4169  ++nRow;
4170  rPosY = nRow;
4171 }
4172 
4174 {
4175  SCCOLROW nFreezeIndex = bIsCol ? mrDoc.GetLOKFreezeCol(nTabNo) : mrDoc.GetLOKFreezeRow(nTabNo);
4176  return nFreezeIndex >= 0 ? nFreezeIndex : 0;
4177 }
4178 
4179 bool ScViewData::SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab)
4180 {
4181  if (nForTab == -1)
4182  {
4183  nForTab = nTabNo;
4184  }
4185  else if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))
4186  {
4187  SAL_WARN("sc.viewdata", "ScViewData::SetLOKSheetFreezeIndex : invalid nForTab = " << nForTab);
4188  return false;
4189  }
4190 
4191  return bIsCol ? mrDoc.SetLOKFreezeCol(static_cast<SCCOL>(nFreezeIndex), nForTab)
4192  : mrDoc.SetLOKFreezeRow(static_cast<SCROW>(nFreezeIndex), nForTab);
4193 }
4194 
4196 {
4197  bool colUnfreezed = SetLOKSheetFreezeIndex(0, true);
4198  bool rowUnfreezed = SetLOKSheetFreezeIndex(0, false);
4199  return colUnfreezed || rowUnfreezed;
4200 }
4201 
4203 {
4204  SCTAB nMaxTab = static_cast<SCTAB>(maTabData.size()) - 1;
4205  for (SCTAB nTab = 0; nTab <= nMaxTab; ++nTab)
4207 }
4208 
4210 {
4211  if (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))
4212  {
4213  SAL_WARN("sc.viewdata", "ScViewData::DeriveLOKFreezeIfNeeded : invalid nForTab = " << nForTab);
4214  return;
4215  }
4216 
4217  ScViewDataTable* pViewTable = maTabData[nForTab].get();
4218  if (!pViewTable)
4219  return;
4220 
4221  bool bConvertToFreezeX = false;
4222  bool bConvertToFreezeY = false;
4223  SCCOL nFreezeCol = mrDoc.GetLOKFreezeCol(nForTab);
4224  SCROW nFreezeRow = mrDoc.GetLOKFreezeRow(nForTab);
4225 
4226  if (nFreezeCol == -1)
4227  {
4228  ScSplitMode eSplitMode = pViewTable->eHSplitMode;
4229  if (eSplitMode == SC_SPLIT_FIX)
4230  nFreezeCol = pViewTable->nFixPosX;
4231  else if (eSplitMode == SC_SPLIT_NORMAL)
4232  bConvertToFreezeX = true;
4233  else
4234  nFreezeCol = 0;
4235  }
4236 
4237  if (nFreezeRow == -1)
4238  {
4239  ScSplitMode eSplitMode = pViewTable->eVSplitMode;
4240  if (eSplitMode == SC_SPLIT_FIX)
4241  nFreezeRow = pViewTable->nFixPosY;
4242  else if (eSplitMode == SC_SPLIT_NORMAL)
4243  bConvertToFreezeY = true;
4244  else
4245  nFreezeRow = 0;
4246  }
4247 
4248  if (bConvertToFreezeX || bConvertToFreezeY)
4249  {
4250  SCCOL nCol;
4251  SCROW nRow;
4252  GetPosFromPixel(bConvertToFreezeX ? pViewTable->nHSplitPos : 0,
4253  bConvertToFreezeY ? pViewTable->nVSplitPos : 0,
4254  SC_SPLIT_BOTTOMLEFT, nCol, nRow,
4255  false /* bTestMerge */, false /* bRepair */,
4256  nForTab);
4257  if (bConvertToFreezeX)
4258  nFreezeCol = nCol;
4259  if (bConvertToFreezeY)
4260  nFreezeRow = nRow;
4261  }
4262 
4263  mrDoc.SetLOKFreezeCol(nFreezeCol, nForTab);
4264  mrDoc.SetLOKFreezeRow(nFreezeRow, nForTab);
4265 }
4266 
4267 void ScViewData::OverrideWithLOKFreeze(ScSplitMode& eExHSplitMode, ScSplitMode& eExVSplitMode,
4268  SCCOL& nExFixPosX, SCROW& nExFixPosY,
4269  tools::Long& nExHSplitPos, tools::Long& nExVSplitPos, SCTAB nForTab) const
4270 {
4271  SCCOL nFreezeCol = mrDoc.GetLOKFreezeCol(nForTab);
4272  SCROW nFreezeRow = mrDoc.GetLOKFreezeRow(nForTab);
4273 
4274  bool bConvertToScrPosX = false;
4275  bool bConvertToScrPosY = false;
4276 
4277  if (nFreezeCol >= 0)
4278  {
4279  if (eExHSplitMode == SC_SPLIT_NONE)
4280  eExHSplitMode = SC_SPLIT_FIX;
4281 
4282  if (eExHSplitMode == SC_SPLIT_FIX)
4283  {
4284  nExFixPosX = nFreezeCol;
4285  pThisTab->nPosX[SC_SPLIT_RIGHT] = nFreezeCol;
4286  }
4287  else
4288  bConvertToScrPosX = true;
4289  }
4290 
4291  if (nFreezeRow >= 0)
4292  {
4293  if (eExVSplitMode == SC_SPLIT_NONE)
4294  eExVSplitMode = SC_SPLIT_FIX;
4295 
4296  if (eExVSplitMode == SC_SPLIT_FIX)
4297  {
4298  nExFixPosY = nFreezeRow;
4299  pThisTab->nPosY[SC_SPLIT_BOTTOM] = nFreezeRow;
4300  }
4301  else
4302  bConvertToScrPosY = true;
4303  }
4304 
4305  if (bConvertToScrPosX || bConvertToScrPosY)
4306  {
4307  Point aExSplitPos = GetScrPos(nFreezeCol, nFreezeRow, SC_SPLIT_BOTTOMLEFT, true, nForTab);
4308  if (bConvertToScrPosX)
4309  nExHSplitPos = aExSplitPos.X();
4310  if (bConvertToScrPosY)
4311  nExVSplitPos = aExSplitPos.Y();
4312  }
4313 }
4314 
4315 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3108
#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:4209
#define SC_UNO_COLROWHDR
Definition: unonames.hxx:538
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:87
#define SC_TABLE_SHOWGRID
sal_uInt32 GetFieldDivisionY() const
#define SC_POSITIONLEFT
constexpr double nPPTY
#define SC_TABLE_VIEWSETTINGS
void SetControlWord(EVControlBits nWord)
#define SC_UNO_SHOWCHARTS
Definition: unonames.hxx:545
SCCOL GetColMerge() const
Definition: attrib.hxx:68
SvxCellHorJustify
OUString GetText(LineEnd eEnd=LINEEND_LF) const
ScExtPanePos meActivePane
Active (focused) pane.
Definition: scextopt.hxx:56
#define OLE_STD_CELLS_Y
Definition: global.hxx:115
void KillEditView()
Definition: viewdata.cxx:2263
EEControlBits GetControlWord() const
SCCOL GetOldCurX() const
Definition: viewdata.cxx:1372
#define SC_SHEETTABS
SCCOL SanitizeCol(SCCOL nCol) const
Definition: document.hxx:880
void MarkToSimple()
Definition: markdata.cxx:236
SvxZoomType eDefZoomType
Definition: viewdata.hxx:290
#define SC_CURSORPOSITIONX
index_type nSecondIndex
Definition: viewdata.hxx:165
ScAddress aStart
Definition: address.hxx:499
#define SC_HORIZONTAL_SPLIT_POSITION
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
void Compute(value_type aFirstNearest, value_type aSecondNearest, tools::Long nFirstBound, tools::Long nSecondBound)
Definition: viewdata.cxx:345
#define SC_ZOOMTYPE
void SetCurX(SCCOL nNewCurX)
Definition: viewdata.hxx:430
Bottom, or bottom-left pane.
Definition: scextopt.hxx:42
ScDocShell * pDocShell
Definition: viewdata.hxx:278
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:718
#define EMPTY_OUSTRING
Definition: global.hxx:214
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:3500
SAL_DLLPRIVATE void EnsureTabDataSize(size_t nSize)
Definition: viewdata.cxx:2308
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
#define SC_ACTIVETABLE
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:3167
Fraction aDefPageZoomX
Definition: viewdata.hxx:293
#define SC_UNO_RASTERRESX
Definition: unonames.hxx:558
void SetScreenPos(const Point &rVisAreaStart)
Definition: viewdata.cxx:3031
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:2527
SfxDispatcher * GetDispatcher()
::std::vector< std::unique_ptr< ScViewDataTable > > maTabData
Definition: viewdata.hxx:275
#define SC_HORIZONTALSCROLLBARWIDTH
void InsertTabs(SCTAB nTab, SCTAB nNewSheets)
Definition: viewdata.cxx: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:114
#define SC_CURSOR_Y
void SetActivePart(ScSplitPos eNewActive)
Definition: viewdata.cxx:2350
sal_uIntPtr sal_uLong
long Long
Fraction aPageZoomY
Definition: viewdata.hxx:214
ScAddress maSecondVis
Top-left visible cell in add. panes (column/row only).
Definition: scextopt.hxx:53
sal_uInt32 GetFieldDrawX() const
void invalidateByPosition(tools::Long nPos)
Definition: viewdata.cxx:175
SCROW GetCurY() const
Definition: viewdata.hxx:401
svtools::ColorConfig & GetColorConfig()
Definition: scmod.cxx:815
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:712
ScDocFunc & GetDocFunc() const
Definition: viewdata.cxx:3091
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:4173
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
void DeriveLOKFreezeAllSheets()
Definition: viewdata.cxx:4202
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
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:2134
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)
void insert(index_type nIndex, tools::Long nPos)
Definition: viewdata.cxx:135
#define SC_CURSOR_X
#define SC_CURSORPOSITIONY
tools::Long GetTabBarWidth() const
Returns the current tab bar width in pixels.
Definition: tabview.cxx:877
static void forEachOtherView(ViewShellType *pThisViewShell, FunctionType f)
ScSplitPos SanitizeWhichActive() const
Sanitize the active split range value to not point into a grid window that would never be initialized...
Definition: viewdata.cxx: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
#define SC_TABLES
SCCOL CellsAtX(SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeY=SC_SIZE_NONE) const
Definition: viewdata.cxx:2605
std::set< value_type, Comp > mData
Definition: viewdata.hxx:136
#define SC_UNO_SHOWOBJ
Definition: unonames.hxx:551
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4192
void ReadUserData(const OUString &rData)
Definition: viewdata.cxx:3292
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:4010
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:3964
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:3970
void DeleteTab(SCTAB nTab)
Definition: markdata.cxx:637
#define STD_COL_WIDTH
Definition: global.hxx:95
Fraction aPageZoomX
Definition: viewdata.hxx:213
void SetControlWord(EEControlBits nWord)