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