LibreOffice Module sc (master)  1
viewfunc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <config_features.h>
21 
22 #include <scitems.hxx>
23 
24 #include <sfx2/app.hxx>
25 #include <svx/algitem.hxx>
26 #include <editeng/boxitem.hxx>
27 #include <editeng/editobj.hxx>
28 #include <editeng/langitem.hxx>
29 #include <editeng/justifyitem.hxx>
30 #include <o3tl/unit_conversion.hxx>
31 #include <sfx2/bindings.hxx>
32 #include <svl/numformat.hxx>
33 #include <svl/zforlist.hxx>
34 #include <svl/zformat.hxx>
35 #include <vcl/weld.hxx>
36 #include <vcl/virdev.hxx>
37 #include <stdlib.h>
38 #include <unotools/charclass.hxx>
39 #include <vcl/uitest/logger.hxx>
41 #include <osl/diagnose.h>
42 
43 #include <viewfunc.hxx>
44 #include <tabvwsh.hxx>
45 #include <docsh.hxx>
46 #include <attrib.hxx>
47 #include <patattr.hxx>
48 #include <docpool.hxx>
49 #include <sc.hrc>
50 #include <undocell.hxx>
51 #include <undoblk.hxx>
52 #include <refundo.hxx>
53 #include <olinetab.hxx>
54 #include <rangenam.hxx>
55 #include <globstr.hrc>
56 #include <global.hxx>
57 #include <stlsheet.hxx>
58 #include <editutil.hxx>
59 #include <formulacell.hxx>
60 #include <scresid.hxx>
61 #include <inputhdl.hxx>
62 #include <scmod.hxx>
63 #include <inputopt.hxx>
64 #include <compiler.hxx>
65 #include <docfunc.hxx>
66 #include <appoptio.hxx>
67 #include <sizedev.hxx>
68 #include <editable.hxx>
69 #include <scui_def.hxx>
70 #include <funcdesc.hxx>
71 #include <docuno.hxx>
72 #include <cellsuno.hxx>
73 #include <tokenarray.hxx>
74 #include <rowheightcontext.hxx>
75 #include <comphelper/lok.hxx>
76 #include <conditio.hxx>
77 #include <columnspanset.hxx>
78 #include <stringutil.hxx>
79 
80 #include <memory>
81 
82 static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh )
83 {
84  if( pCondFmt )
85  {
86  const ScRangeList& rRanges = pCondFmt->GetRange();
87 
88  pDocSh->PostPaint( rRanges, PaintPartFlags::All );
89  }
90 }
91 
92 ScViewFunc::ScViewFunc( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
93  ScTabView( pParent, rDocSh, pViewShell ),
94  bFormatValid( false )
95 {
96 }
97 
99 {
100 }
101 
102 namespace {
103 
104 void collectUIInformation(std::map<OUString, OUString>&& aParameters, const OUString& rAction)
105 {
106  EventDescription aDescription;
107  aDescription.aID = "grid_window";
108  aDescription.aAction = rAction;
109  aDescription.aParameters = std::move(aParameters);
110  aDescription.aParent = "MainWindow";
111  aDescription.aKeyWord = "ScGridWinUIObject";
112 
113  UITestLogger::getInstance().logEvent(aDescription);
114 }
115 
116 }
117 
119 {
120  // anything to do?
121  if ( !SC_MOD()->GetInputOptions().GetExtendFormat() )
122  return;
123 
124  // start only with single cell (marked or cursor position)
125  ScRange aMarkRange;
126  bool bOk = (GetViewData().GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
127  if ( bOk && aMarkRange.aStart != aMarkRange.aEnd )
128  bOk = false;
129 
130  if (bOk)
131  {
132  bFormatValid = true;
133  aFormatSource = aMarkRange.aStart;
135  }
136  else
137  bFormatValid = false; // discard old range
138 }
139 
140 bool ScViewFunc::TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bAttrChanged )
141 {
142  // anything to do?
143  if ( !SC_MOD()->GetInputOptions().GetExtendFormat() )
144  return false;
145 
146  // Test: treat input with numberformat (bAttrChanged) always as new Attribute
147  // (discard old Area ). If not wanted, discard if-statement
148  if ( bAttrChanged )
149  {
150  StartFormatArea();
151  return false;
152  }
153 
155 
156  bool bFound = false;
157  ScRange aNewRange = aFormatArea;
158  if ( bFormatValid && nTab == aFormatSource.Tab() )
159  {
160  if ( nRow >= aFormatArea.aStart.Row() && nRow <= aFormatArea.aEnd.Row() )
161  {
162  // within range?
163  if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() )
164  {
165  bFound = true; // do not change range
166  }
167  // left ?
168  if ( nCol+1 == aFormatArea.aStart.Col() )
169  {
170  bFound = true;
171  aNewRange.aStart.SetCol( nCol );
172  }
173  // right ?
174  if ( nCol == aFormatArea.aEnd.Col()+1 )
175  {
176  bFound = true;
177  aNewRange.aEnd.SetCol( nCol );
178  }
179  }
180  if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() )
181  {
182  // top ?
183  if ( nRow+1 == aFormatArea.aStart.Row() )
184  {
185  bFound = true;
186  aNewRange.aStart.SetRow( nRow );
187  }
188  // bottom ?
189  if ( nRow == aFormatArea.aEnd.Row()+1 )
190  {
191  bFound = true;
192  aNewRange.aEnd.SetRow( nRow );
193  }
194  }
195  }
196 
197  if (bFound)
198  aFormatArea = aNewRange; // extend
199  else
200  bFormatValid = false; // outside of range -> break
201 
202  return bFound;
203 }
204 
206  bool bAttrChanged )
207 {
208  ScDocShell* pDocSh = GetViewData().GetDocShell();
209  ScDocument& rDoc = pDocSh->GetDocument();
210 
211  const ScPatternAttr* pSource = rDoc.GetPattern(
212  aFormatSource.Col(), aFormatSource.Row(), nTab );
213  if ( !pSource->GetItem(ATTR_MERGE).IsMerged() )
214  {
215  ScRange aRange( nCol, nRow, nTab, nCol, nRow, nTab );
216  ScMarkData aMark(rDoc.GetSheetLimits());
217  aMark.SetMarkArea( aRange );
218 
219  ScDocFunc &rFunc = GetViewData().GetDocFunc();
220 
221  // pOldPattern is only valid until call to ApplyAttributes!
222  const ScPatternAttr* pOldPattern = rDoc.GetPattern( nCol, nRow, nTab );
223  const ScStyleSheet* pSrcStyle = pSource->GetStyleSheet();
224  if ( pSrcStyle && pSrcStyle != pOldPattern->GetStyleSheet() )
225  rFunc.ApplyStyle( aMark, pSrcStyle->GetName(), false );
226 
227  rFunc.ApplyAttributes( aMark, *pSource, false );
228  }
229 
230  if ( bAttrChanged ) // value entered with number format?
231  aFormatSource.Set( nCol, nRow, nTab ); // then set a new source
232 }
233 
234 // additional routines
235 
236 sal_uInt16 ScViewFunc::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, bool bFormula )
237 {
238  ScDocShell* pDocSh = GetViewData().GetDocShell();
239  ScDocument& rDoc = pDocSh->GetDocument();
240  ScMarkData& rMark = GetViewData().GetMarkData();
241 
242  double nPPTX = GetViewData().GetPPTX();
243  double nPPTY = GetViewData().GetPPTY();
244  Fraction aZoomX = GetViewData().GetZoomX();
245  Fraction aZoomY = GetViewData().GetZoomY();
246 
247  ScSizeDeviceProvider aProv(pDocSh);
248  if (aProv.IsPrinter())
249  {
250  nPPTX = aProv.GetPPTX();
251  nPPTY = aProv.GetPPTY();
252  aZoomX = aZoomY = Fraction( 1, 1 );
253  }
254 
255  sal_uInt16 nTwips = rDoc.GetOptimalColWidth( nCol, nTab, aProv.GetDevice(),
256  nPPTX, nPPTY, aZoomX, aZoomY, bFormula, &rMark );
257  return nTwips;
258 }
259 
260 bool ScViewFunc::SelectionEditable( bool* pOnlyNotBecauseOfMatrix /* = NULL */ )
261 {
262  bool bRet;
263  ScDocument& rDoc = GetViewData().GetDocument();
264  ScMarkData& rMark = GetViewData().GetMarkData();
265  if (rMark.IsMarked() || rMark.IsMultiMarked())
266  bRet = rDoc.IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix );
267  else
268  {
269  SCCOL nCol = GetViewData().GetCurX();
270  SCROW nRow = GetViewData().GetCurY();
271  SCTAB nTab = GetViewData().GetTabNo();
272  bRet = rDoc.IsBlockEditable( nTab, nCol, nRow, nCol, nRow,
273  pOnlyNotBecauseOfMatrix );
274  }
275  return bRet;
276 }
277 
278 static bool lcl_FunctionKnown( sal_uInt16 nOpCode )
279 {
281  if ( pFuncList )
282  {
283  sal_uLong nCount = pFuncList->GetCount();
284  for (sal_uLong i=0; i<nCount; i++)
285  if ( pFuncList->GetFunction(i)->nFIndex == nOpCode )
286  return true;
287  }
288  return false;
289 }
290 
291 static bool lcl_AddFunction( ScAppOptions& rAppOpt, sal_uInt16 nOpCode )
292 {
293  sal_uInt16 nOldCount = rAppOpt.GetLRUFuncListCount();
294  sal_uInt16* pOldList = rAppOpt.GetLRUFuncList();
295  sal_uInt16 nPos;
296  for (nPos=0; nPos<nOldCount; nPos++)
297  if (pOldList[nPos] == nOpCode) // is the function already in the list?
298  {
299  if ( nPos == 0 )
300  return false; // already at the top -> no change
301 
302  // count doesn't change, so the original array is modified
303 
304  for (sal_uInt16 nCopy=nPos; nCopy>0; nCopy--)
305  pOldList[nCopy] = pOldList[nCopy-1];
306  pOldList[0] = nOpCode;
307 
308  return true; // list has changed
309  }
310 
311  if ( !lcl_FunctionKnown( nOpCode ) )
312  return false; // not in function list -> no change
313 
314  sal_uInt16 nNewCount = std::min( static_cast<sal_uInt16>(nOldCount + 1), sal_uInt16(LRU_MAX) );
315  sal_uInt16 nNewList[LRU_MAX];
316  nNewList[0] = nOpCode;
317  for (nPos=1; nPos<nNewCount; nPos++)
318  nNewList[nPos] = pOldList[nPos-1];
319  rAppOpt.SetLRUFuncList( nNewList, nNewCount );
320 
321  return true; // list has changed
322 }
323 
324 namespace HelperNotifyChanges
325 {
326  static void NotifyIfChangesListeners(const ScDocShell &rDocShell, ScMarkData& rMark, SCCOL nCol, SCROW nRow)
327  {
328  if (ScModelObj *pModelObj = getMustPropagateChangesModel(rDocShell))
329  {
330  ScRangeList aChangeRanges;
331  for (const auto& rTab : rMark)
332  aChangeRanges.push_back( ScRange( nCol, nRow, rTab ) );
333 
334  HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "cell-change");
335  }
336  }
337 }
338 
339 namespace
340 {
341  class AutoCorrectQuery : public weld::MessageDialogController
342  {
343  private:
344  std::unique_ptr<weld::TextView> m_xError;
345  public:
346  AutoCorrectQuery(weld::Window* pParent, const OUString& rFormula)
347  : weld::MessageDialogController(pParent, "modules/scalc/ui/warnautocorrect.ui", "WarnAutoCorrect", "grid")
348  , m_xError(m_xBuilder->weld_text_view("error"))
349  {
350  m_xDialog->set_default_response(RET_YES);
351 
352  const int nMaxWidth = m_xError->get_approximate_digit_width() * 65;
353  const int nMaxHeight = m_xError->get_height_rows(6);
354  m_xError->set_size_request(nMaxWidth, nMaxHeight);
355 
356  m_xError->set_text(rFormula);
357  }
358  };
359 }
360 
361 // actual functions
362 
363 // input - undo OK
364 void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
365  const OUString& rString,
366  const EditTextObject* pData )
367 {
368  ScDocument& rDoc = GetViewData().GetDocument();
369  ScMarkData rMark(GetViewData().GetMarkData());
370  bool bRecord = rDoc.IsUndoEnabled();
371  SCTAB i;
372 
373  ScDocShell* pDocSh = GetViewData().GetDocShell();
374  ScDocFunc &rFunc = GetViewData().GetDocFunc();
375  ScDocShellModificator aModificator( *pDocSh );
376 
377  ScEditableTester aTester( rDoc, nCol,nRow, nCol,nRow, rMark );
378  if (!aTester.IsEditable())
379  {
380  ErrorMessage(aTester.GetMessageId());
381  PaintArea(nCol, nRow, nCol, nRow); // possibly the edit-engine is still painted there
382  return;
383  }
384 
385  if ( bRecord )
386  rFunc.EnterListAction( STR_UNDO_ENTERDATA );
387 
388  bool bFormula = false;
389 
390  // a single '=' character is handled as string (needed for special filters)
391  if ( rString.getLength() > 1 )
392  {
393  if ( rString[0] == '=' )
394  {
395  // handle as formula
396  bFormula = true;
397  }
398  else if ( rString[0] == '+' || rString[0] == '-' )
399  {
400  // if there is more than one leading '+' or '-' character, remove the additional ones
401  sal_Int32 nIndex = 1;
402  sal_Int32 nLen = rString.getLength();
403  while ( nIndex < nLen && ( rString[ nIndex ] == '+' || rString[ nIndex ] == '-' ) )
404  {
405  ++nIndex;
406  }
407  OUString aString = rString.replaceAt( 1, nIndex - 1, u"" );
408 
409  // if the remaining part without the leading '+' or '-' character
410  // is non-empty and not a number, handle as formula
411  if ( aString.getLength() > 1 )
412  {
413  sal_uInt32 nFormat = rDoc.GetNumberFormat( nCol, nRow, nTab );
414  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
415  double fNumber = 0;
416  if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) )
417  {
418  bFormula = true;
419  }
420  }
421  }
422  }
423 
424  bool bNumFmtChanged = false;
425  if ( bFormula )
426  { // formula, compile with autoCorrection
427  i = rMark.GetFirstSelected();
428  ScAddress aPos( nCol, nRow, i );
429  ScCompiler aComp( rDoc, aPos, rDoc.GetGrammar(), true, false );
430 //2do: enable/disable autoCorrection via calcoptions
431  aComp.SetAutoCorrection( true );
432  if ( rString[0] == '+' || rString[0] == '-' )
433  {
434  aComp.SetExtendedErrorDetection( ScCompiler::EXTENDED_ERROR_DETECTION_NAME_BREAK );
435  }
436  OUString aFormula( rString );
437  std::unique_ptr< ScTokenArray > pArr;
438  bool bAgain;
439  do
440  {
441  bAgain = false;
442  bool bAddEqual = false;
443  pArr = aComp.CompileString( aFormula );
444  bool bCorrected = aComp.IsCorrected();
445  std::unique_ptr< ScTokenArray > pArrFirst;
446  if ( bCorrected )
447  { // try to parse with first parser-correction
448  pArrFirst = std::move( pArr );
449  pArr = aComp.CompileString( aComp.GetCorrectedFormula() );
450  }
451  if ( pArr->GetCodeError() == FormulaError::NONE )
452  {
453  bAddEqual = true;
454  aComp.CompileTokenArray();
455  bCorrected |= aComp.IsCorrected();
456  }
457  if ( bCorrected )
458  {
459  OUString aCorrectedFormula;
460  if ( bAddEqual )
461  {
462  aCorrectedFormula = "=" + aComp.GetCorrectedFormula();
463  }
464  else
465  aCorrectedFormula = aComp.GetCorrectedFormula();
466  short nResult;
467  if ( aCorrectedFormula.getLength() == 1 )
468  nResult = RET_NO; // empty formula, just '='
469  else
470  {
471  AutoCorrectQuery aQueryBox(GetViewData().GetDialogParent(), aCorrectedFormula);
472  nResult = aQueryBox.run();
473  }
474  if ( nResult == RET_YES )
475  {
476  aFormula = aCorrectedFormula;
477  bAgain = true;
478  }
479  else
480  {
481  if ( pArrFirst )
482  pArr = std::move( pArrFirst );
483  }
484  }
485  } while ( bAgain );
486  // to be used in multiple tabs, the formula must be compiled anew
487  // via ScFormulaCell copy-ctor because of RangeNames,
488  // the same code-array for all cells is not possible.
489  // If the array has an error, (it) must be RPN-erased in the newly generated
490  // cells and the error be set explicitly, so that
491  // via FormulaCell copy-ctor and Interpreter it will be, when possible,
492  // ironed out again, too intelligent... e.g.: =1))
493  FormulaError nError = pArr->GetCodeError();
494  if ( nError == FormulaError::NONE )
495  {
496  // update list of recent functions with all functions that
497  // are not within parentheses
498 
499  ScModule* pScMod = SC_MOD();
500  ScAppOptions aAppOpt = pScMod->GetAppOptions();
501  bool bOptChanged = false;
502 
503  formula::FormulaToken** ppToken = pArr->GetArray();
504  sal_uInt16 nTokens = pArr->GetLen();
505  sal_uInt16 nLevel = 0;
506  for (sal_uInt16 nTP=0; nTP<nTokens; nTP++)
507  {
508  formula::FormulaToken* pTok = ppToken[nTP];
509  OpCode eOp = pTok->GetOpCode();
510  if ( eOp == ocOpen )
511  ++nLevel;
512  else if ( eOp == ocClose && nLevel )
513  --nLevel;
514  if ( nLevel == 0 && pTok->IsFunction() &&
515  lcl_AddFunction( aAppOpt, sal::static_int_cast<sal_uInt16>( eOp ) ) )
516  bOptChanged = true;
517  }
518 
519  if ( bOptChanged )
520  {
521  pScMod->SetAppOptions(aAppOpt);
522  }
523  }
524 
525  ScFormulaCell aCell(rDoc, aPos, std::move( pArr ), formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE);
526 
527  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
528  for (const auto& rTab : rMark)
529  {
530  i = rTab;
531  aPos.SetTab( i );
532  const sal_uInt32 nIndex = rDoc.GetAttr(
533  nCol, nRow, i, ATTR_VALUE_FORMAT )->GetValue();
534  const SvNumFormatType nType = pFormatter->GetType( nIndex);
535  if (nType == SvNumFormatType::TEXT ||
536  ((rString[0] == '+' || rString[0] == '-') && nError != FormulaError::NONE && rString == aFormula))
537  {
538  if ( pData )
539  {
540  // A clone of pData will be stored in the cell.
541  rFunc.SetEditCell(aPos, *pData, true);
542  }
543  else
544  rFunc.SetStringCell(aPos, aFormula, true);
545  }
546  else
547  {
548  ScFormulaCell* pCell = new ScFormulaCell( aCell, rDoc, aPos );
549  if ( nError != FormulaError::NONE )
550  {
551  pCell->GetCode()->DelRPN();
552  pCell->SetErrCode( nError );
553  if(pCell->GetCode()->IsHyperLink())
554  pCell->GetCode()->SetHyperLink(false);
555  }
556  if (nType == SvNumFormatType::LOGICAL)
557  {
558  // Reset to General so the actual format can be determined
559  // after the cell has been interpreted. A sticky boolean
560  // number format is highly likely unwanted... see tdf#75650.
561  // General of same locale as current number format.
562  const SvNumberformat* pEntry = pFormatter->GetEntry( nIndex);
563  const LanguageType nLang = (pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge);
564  const sal_uInt32 nFormat = pFormatter->GetStandardFormat( SvNumFormatType::NUMBER, nLang);
565  ScPatternAttr aPattern( rDoc.GetPool());
566  aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nFormat));
567  ScMarkData aMark(rDoc.GetSheetLimits());
568  aMark.SelectTable( i, true);
569  aMark.SetMarkArea( ScRange( aPos));
570  rFunc.ApplyAttributes( aMark, aPattern, false);
571  bNumFmtChanged = true;
572  }
573  rFunc.SetFormulaCell(aPos, pCell, true);
574  }
575  }
576  }
577  else
578  {
579  ScFieldEditEngine& rEngine = rDoc.GetEditEngine();
580  for (const auto& rTab : rMark)
581  {
582  bool bNumFmtSet = false;
583  const ScAddress aScAddress(nCol, nRow, rTab);
584 
585  // tdf#104902 - handle embedded newline
586  if (ScStringUtil::isMultiline(rString))
587  {
588  rEngine.SetTextCurrentDefaults(rString);
589  rDoc.SetEditText(aScAddress, rEngine.CreateTextObject());
590  pDocSh->AdjustRowHeight(nRow, nRow, rTab);
591  }
592  else
593  {
594  rFunc.SetNormalString(bNumFmtSet, aScAddress, rString, false);
595  }
596 
597  if (bNumFmtSet)
598  {
599  /* FIXME: if set on any sheet results in changed only on
600  * sheet nTab for TestFormatArea() and DoAutoAttributes() */
601  bNumFmtChanged = true;
602  }
603  }
604  }
605 
606  bool bAutoFormat = TestFormatArea(nCol, nRow, nTab, bNumFmtChanged);
607 
608  if (bAutoFormat)
609  DoAutoAttributes(nCol, nRow, nTab, bNumFmtChanged);
610 
611  pDocSh->UpdateOle(GetViewData());
612 
613  HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, rMark, nCol, nRow);
614 
615  if ( bRecord )
616  rFunc.EndListAction();
617 
618  aModificator.SetDocumentModified();
619  lcl_PostRepaintCondFormat( rDoc.GetCondFormat( nCol, nRow, nTab ), pDocSh );
620 }
621 
622 // enter value in single cell (on nTab only)
623 
624 void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue )
625 {
626  ScDocument& rDoc = GetViewData().GetDocument();
627  ScDocShell* pDocSh = GetViewData().GetDocShell();
628 
629  if (!pDocSh)
630  return;
631 
632  bool bUndo(rDoc.IsUndoEnabled());
633  ScDocShellModificator aModificator( *pDocSh );
634 
635  ScEditableTester aTester( rDoc, nTab, nCol,nRow, nCol,nRow );
636  if (aTester.IsEditable())
637  {
638  ScAddress aPos( nCol, nRow, nTab );
639  ScCellValue aUndoCell;
640  if (bUndo)
641  aUndoCell.assign(rDoc, aPos);
642 
643  rDoc.SetValue( nCol, nRow, nTab, rValue );
644 
645  // because of ChangeTrack after change in document
646  if (bUndo)
647  {
648  pDocSh->GetUndoManager()->AddUndoAction(
649  std::make_unique<ScUndoEnterValue>(pDocSh, aPos, aUndoCell, rValue));
650  }
651 
652  pDocSh->PostPaintCell( aPos );
653  pDocSh->UpdateOle(GetViewData());
654  aModificator.SetDocumentModified();
655  }
656  else
657  ErrorMessage(aTester.GetMessageId());
658 }
659 
660 void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
661  const EditTextObject& rData, bool bTestSimple )
662 {
663  ScDocShell* pDocSh = GetViewData().GetDocShell();
664  ScMarkData& rMark = GetViewData().GetMarkData();
665  ScDocument& rDoc = pDocSh->GetDocument();
666  bool bRecord = rDoc.IsUndoEnabled();
667 
668  ScDocShellModificator aModificator( *pDocSh );
669 
670  ScEditableTester aTester( rDoc, nTab, nCol,nRow, nCol,nRow );
671  if (aTester.IsEditable())
672  {
673 
674  // test for attribute
675 
676  bool bSimple = false;
677  bool bCommon = false;
678  std::unique_ptr<ScPatternAttr> pCellAttrs;
679  OUString aString;
680 
681  const ScPatternAttr* pOldPattern = rDoc.GetPattern( nCol, nRow, nTab );
682  ScTabEditEngine aEngine( *pOldPattern, rDoc.GetEnginePool(), &rDoc );
683  aEngine.SetTextCurrentDefaults(rData);
684 
685  if (bTestSimple) // test, if simple string without attribute
686  {
687  ScEditAttrTester aAttrTester( &aEngine );
688  bSimple = !aAttrTester.NeedsObject();
689  bCommon = aAttrTester.NeedsCellAttr();
690 
691  // formulas have to be recognized even if they're formatted
692  // (but common attributes are still collected)
693 
694  if (!bSimple)
695  {
696  OUString aParStr(aEngine.GetText( 0 ));
697  if ( aParStr[0] == '=' )
698  bSimple = true;
699  }
700 
701  if (bCommon) // attribute for tab
702  {
703  pCellAttrs.reset(new ScPatternAttr( *pOldPattern ));
704  pCellAttrs->GetFromEditItemSet( &aAttrTester.GetAttribs() );
706  }
707  }
708 
709  // #i97726# always get text for "repeat" of undo action
710  aString = ScEditUtil::GetMultilineString(aEngine);
711 
712  // undo
713 
714  std::unique_ptr<EditTextObject> pUndoData;
715  ScUndoEnterData::ValuesType aOldValues;
716 
717  if (bRecord && !bSimple)
718  {
719  for (const auto& rTab : rMark)
720  {
721  ScUndoEnterData::Value aOldValue;
722  aOldValue.mnTab = rTab;
723  aOldValue.maCell.assign(rDoc, ScAddress(nCol, nRow, rTab));
724  aOldValues.push_back(aOldValue);
725  }
726 
727  pUndoData = rData.Clone();
728  }
729 
730  // enter data
731 
732  if (bCommon)
733  rDoc.ApplyPattern(nCol,nRow,nTab,*pCellAttrs);
734 
735  if (bSimple)
736  {
737  if (bCommon)
738  AdjustRowHeight(nRow,nRow,true);
739 
740  EnterData(nCol,nRow,nTab,aString);
741  }
742  else
743  {
744  for (const auto& rTab : rMark)
745  {
746  ScAddress aPos(nCol, nRow, rTab);
747  rDoc.SetEditText(aPos, rData, rDoc.GetEditPool());
748  }
749 
750  if ( bRecord )
751  { // because of ChangeTrack current first
752  pDocSh->GetUndoManager()->AddUndoAction(
753  std::make_unique<ScUndoEnterData>(pDocSh, ScAddress(nCol,nRow,nTab), aOldValues, aString, std::move(pUndoData)));
754  }
755 
756  HideAllCursors();
757 
758  AdjustRowHeight(nRow,nRow,true);
759 
760  for (const auto& rTab : rMark)
761  pDocSh->PostPaintCell( nCol, nRow, rTab );
762 
763  ShowAllCursors();
764 
765  pDocSh->UpdateOle(GetViewData());
766 
767  HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, rMark, nCol, nRow);
768 
769  aModificator.SetDocumentModified();
770  }
771  lcl_PostRepaintCondFormat( rDoc.GetCondFormat( nCol, nRow, nTab ), pDocSh );
772  }
773  else
774  {
775  ErrorMessage(aTester.GetMessageId());
776  PaintArea( nCol, nRow, nCol, nRow ); // possibly the edit-engine is still painted there
777  }
778 }
779 
780 void ScViewFunc::EnterDataAtCursor( const OUString& rString )
781 {
782  SCCOL nPosX = GetViewData().GetCurX();
783  SCROW nPosY = GetViewData().GetCurY();
784  SCTAB nTab = GetViewData().GetTabNo();
785 
786  EnterData( nPosX, nPosY, nTab, rString );
787 }
788 
789 void ScViewFunc::EnterMatrix( const OUString& rString, ::formula::FormulaGrammar::Grammar eGram )
790 {
792  const SCCOL nCol = rData.GetCurX();
793  const SCROW nRow = rData.GetCurY();
794  const ScMarkData& rMark = rData.GetMarkData();
795  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
796  {
797  // nothing marked -> temporarily calculate block
798  // with size of result formula to get the size
799 
800  ScDocument& rDoc = rData.GetDocument();
801  SCTAB nTab = rData.GetTabNo();
802  ScFormulaCell aFormCell( rDoc, ScAddress(nCol,nRow,nTab), rString, eGram, ScMatrixMode::Formula );
803 
804  SCSIZE nSizeX;
805  SCSIZE nSizeY;
806  aFormCell.GetResultDimensions( nSizeX, nSizeY );
807  if ( nSizeX != 0 && nSizeY != 0 &&
808  nCol+nSizeX-1 <= sal::static_int_cast<SCSIZE>(rDoc.MaxCol()) &&
809  nRow+nSizeY-1 <= sal::static_int_cast<SCSIZE>(rDoc.MaxRow()) )
810  {
811  ScRange aResult( nCol, nRow, nTab,
812  sal::static_int_cast<SCCOL>(nCol+nSizeX-1),
813  sal::static_int_cast<SCROW>(nRow+nSizeY-1), nTab );
814  MarkRange( aResult, false );
815  }
816  }
817 
818  ScRange aRange;
819  if (rData.GetSimpleArea(aRange) == SC_MARK_SIMPLE)
820  {
821  ScDocShell* pDocSh = rData.GetDocShell();
822  bool bSuccess = pDocSh->GetDocFunc().EnterMatrix(
823  aRange, &rMark, nullptr, rString, false, false, OUString(), eGram );
824  if (bSuccess)
825  pDocSh->UpdateOle(GetViewData());
826  else
827  PaintArea(nCol, nRow, nCol, nRow); // possibly the edit-engine is still painted there
828  }
829  else
830  ErrorMessage(STR_NOMULTISELECT);
831 }
832 
834 {
835  SvtScriptType nScript = SvtScriptType::NONE;
836 
837  ScDocument& rDoc = GetViewData().GetDocument();
838  const ScMarkData& rMark = GetViewData().GetMarkData();
839  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
840  {
841  // no selection -> cursor
842 
843  nScript = rDoc.GetScriptType( GetViewData().GetCurX(),
844  GetViewData().GetCurY(), GetViewData().GetTabNo());
845  }
846  else
847  {
848  ScRangeList aRanges;
849  rMark.FillRangeListWithMarks( &aRanges, false );
850  nScript = rDoc.GetRangeScriptType(aRanges);
851  }
852 
853  if (nScript == SvtScriptType::NONE)
854  nScript = ScGlobal::GetDefaultScriptType();
855 
856  return nScript;
857 }
858 
860 {
861  // Don't use UnmarkFiltered in slot state functions, for performance reasons.
862  // The displayed state is always that of the whole selection including filtered rows.
863 
864  const ScMarkData& rMark = GetViewData().GetMarkData();
865  ScDocument& rDoc = GetViewData().GetDocument();
866  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
867  {
868  // MarkToMulti is no longer necessary for rDoc.GetSelectionPattern
869  const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( rMark );
870  return pAttr;
871  }
872  else
873  {
874  SCCOL nCol = GetViewData().GetCurX();
875  SCROW nRow = GetViewData().GetCurY();
876  SCTAB nTab = GetViewData().GetTabNo();
877 
878  ScMarkData aTempMark( rMark ); // copy sheet selection
879  aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
880  const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aTempMark );
881  return pAttr;
882  }
883 }
884 
886  std::shared_ptr<SvxBoxItem>& rLineOuter,
887  std::shared_ptr<SvxBoxInfoItem>& rLineInner )
888 {
889  ScDocument& rDoc = GetViewData().GetDocument();
890  const ScMarkData& rMark = GetViewData().GetMarkData();
891 
892  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
893  {
894  rDoc.GetSelectionFrame( rMark, *rLineOuter, *rLineInner );
895  }
896  else
897  {
898  const ScPatternAttr* pAttrs =
899  rDoc.GetPattern( GetViewData().GetCurX(),
900  GetViewData().GetCurY(),
901  GetViewData().GetTabNo() );
902 
903  rLineOuter.reset(pAttrs->GetItem(ATTR_BORDER).Clone());
904  rLineInner.reset(pAttrs->GetItem(ATTR_BORDER_INNER).Clone());
905 
906  rLineInner->SetTable(false);
907  rLineInner->SetDist(true);
908  rLineInner->SetMinDist(false);
909  }
910 }
911 
912 // apply attribute - undo OK
913 //
914 // complete set ( ATTR_STARTINDEX, ATTR_ENDINDEX )
915 
916 void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet,
917  const SfxItemSet* pOldSet,
918  bool bAdjustBlockHeight)
919 {
920  // not editable because of matrix only? attribute OK nonetheless
921  bool bOnlyNotBecauseOfMatrix;
922  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
923  {
924  ErrorMessage(STR_PROTECTIONERR);
925  return;
926  }
927 
928  ScPatternAttr aOldAttrs(( SfxItemSet(*pOldSet) ));
929  ScPatternAttr aNewAttrs(( SfxItemSet(*pDialogSet) ));
930  aNewAttrs.DeleteUnchanged( &aOldAttrs );
931 
932  if ( pDialogSet->GetItemState( ATTR_VALUE_FORMAT ) == SfxItemState::SET )
933  { // don't reset to default SYSTEM GENERAL if not intended
934  sal_uInt32 nOldFormat =
935  pOldSet->Get( ATTR_VALUE_FORMAT ).GetValue();
936  sal_uInt32 nNewFormat =
937  pDialogSet->Get( ATTR_VALUE_FORMAT ).GetValue();
938  if ( nNewFormat != nOldFormat )
939  {
940  SvNumberFormatter* pFormatter =
942  const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
943  LanguageType eOldLang =
944  pOldEntry ? pOldEntry->GetLanguage() : LANGUAGE_DONTKNOW;
945  const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
946  LanguageType eNewLang =
947  pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
948  if ( eNewLang != eOldLang )
949  {
950  aNewAttrs.GetItemSet().Put(
951  SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
952 
953  // only the language has changed -> do not touch numberformat-attribute
954  sal_uInt32 nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
955  if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
956  nNewMod <= SV_MAX_COUNT_STANDARD_FORMATS )
957  aNewAttrs.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
958  }
959  }
960  }
961 
962  if (pDialogSet->HasItem(ATTR_FONT_LANGUAGE))
963  // font language has changed. Redo the online spelling.
964  ResetAutoSpell();
965 
966  const SvxBoxItem& rOldOuter = pOldSet->Get(ATTR_BORDER);
967  const SvxBoxItem& rNewOuter = pDialogSet->Get(ATTR_BORDER);
968  const SvxBoxInfoItem& rOldInner = pOldSet->Get(ATTR_BORDER_INNER);
969  const SvxBoxInfoItem& rNewInner = pDialogSet->Get(ATTR_BORDER_INNER);
970  SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
971  SfxItemPool* pNewPool = rNewSet.GetPool();
972 
973  pNewPool->Put(rNewOuter); // don't delete yet
974  pNewPool->Put(rNewInner);
975  rNewSet.ClearItem( ATTR_BORDER );
976  rNewSet.ClearItem( ATTR_BORDER_INNER );
977 
978  /*
979  * establish whether border attribute is to be set:
980  * 1. new != old
981  * 2. is one of the borders not-DontCare (since 238.f: IsxxValid())
982  *
983  */
984 
985  bool bFrame = (pDialogSet->GetItemState( ATTR_BORDER ) != SfxItemState::DEFAULT)
986  || (pDialogSet->GetItemState( ATTR_BORDER_INNER ) != SfxItemState::DEFAULT);
987 
988  if (&rNewOuter == &rOldOuter && &rNewInner == &rOldInner)
989  bFrame = false;
990 
991  // this should be intercepted by the pool: ?!??!??
992 
993  if (bFrame && rNewOuter == rOldOuter && rNewInner == rOldInner)
994  bFrame = false;
995 
996  bFrame = bFrame
997  && ( rNewInner.IsValid(SvxBoxInfoItemValidFlags::LEFT)
998  || rNewInner.IsValid(SvxBoxInfoItemValidFlags::RIGHT)
999  || rNewInner.IsValid(SvxBoxInfoItemValidFlags::TOP)
1000  || rNewInner.IsValid(SvxBoxInfoItemValidFlags::BOTTOM)
1001  || rNewInner.IsValid(SvxBoxInfoItemValidFlags::HORI)
1002  || rNewInner.IsValid(SvxBoxInfoItemValidFlags::VERT) );
1003 
1004  if (!bFrame)
1005  ApplySelectionPattern( aNewAttrs ); // standard only
1006  else
1007  {
1008  // if new items are default-items, overwrite the old items:
1009 
1010  bool bDefNewOuter = IsStaticDefaultItem(&rNewOuter);
1011  bool bDefNewInner = IsStaticDefaultItem(&rNewInner);
1012 
1013  ApplyPatternLines( aNewAttrs,
1014  bDefNewOuter ? rOldOuter : rNewOuter,
1015  bDefNewInner ? &rOldInner : &rNewInner );
1016  }
1017 
1018  pNewPool->Remove(rNewOuter); // release
1019  pNewPool->Remove(rNewInner);
1020 
1021  // adjust height only if needed
1022  if (bAdjustBlockHeight)
1024 
1025  // CellContentChanged is called in ApplySelectionPattern / ApplyPatternLines
1026 }
1027 
1028 void ScViewFunc::ApplyAttr( const SfxPoolItem& rAttrItem, bool bAdjustBlockHeight )
1029 {
1030  // not editable because of matrix only? attribute OK nonetheless
1031  bool bOnlyNotBecauseOfMatrix;
1032  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
1033  {
1034  ErrorMessage(STR_PROTECTIONERR);
1035  return;
1036  }
1037 
1038  ScPatternAttr aNewAttrs(
1040 
1041  aNewAttrs.GetItemSet().Put( rAttrItem );
1042  // if justify is set (with Buttons), always indentation 0
1043  if ( rAttrItem.Which() == ATTR_HOR_JUSTIFY )
1044  aNewAttrs.GetItemSet().Put( ScIndentItem( 0 ) );
1045  ApplySelectionPattern( aNewAttrs );
1046 
1047  // Prevent useless compute
1048  if (bAdjustBlockHeight)
1050 
1051  // CellContentChanged is called in ApplySelectionPattern
1052 }
1053 
1054 // patterns and borders
1055 
1056 void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem& rNewOuter,
1057  const SvxBoxInfoItem* pNewInner )
1058 {
1059  ScDocument& rDoc = GetViewData().GetDocument();
1060  ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
1061  ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1062  bool bRecord = true;
1063  if (!rDoc.IsUndoEnabled())
1064  bRecord = false;
1065 
1066  bool bRemoveAdjCellBorder = rNewOuter.IsRemoveAdjacentCellBorder();
1067  ScRange aMarkRange, aMarkRangeWithEnvelope;
1068  aFuncMark.MarkToSimple();
1069  bool bMulti = aFuncMark.IsMultiMarked();
1070  if (bMulti)
1071  aMarkRange = aFuncMark.GetMultiMarkArea();
1072  else if (aFuncMark.IsMarked())
1073  aMarkRange = aFuncMark.GetMarkArea();
1074  else
1075  {
1076  aMarkRange = ScRange( GetViewData().GetCurX(),
1077  GetViewData().GetCurY(), GetViewData().GetTabNo() );
1078  DoneBlockMode();
1079  InitOwnBlockMode( aMarkRange );
1080  aFuncMark.SetMarkArea(aMarkRange);
1081  MarkDataChanged();
1082  }
1083  if( bRemoveAdjCellBorder )
1084  aFuncMark.GetSelectionCover( aMarkRangeWithEnvelope );
1085  else
1086  aMarkRangeWithEnvelope = aMarkRange;
1087 
1088  ScDocShell* pDocSh = GetViewData().GetDocShell();
1089 
1090  ScDocShellModificator aModificator( *pDocSh );
1091 
1092  if (bRecord)
1093  {
1095  SCTAB nStartTab = aMarkRange.aStart.Tab();
1096  SCTAB nTabCount = rDoc.GetTableCount();
1097  bool bCopyOnlyMarked = false;
1098  if( !bRemoveAdjCellBorder )
1099  bCopyOnlyMarked = bMulti;
1100  pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
1101  for (const auto& rTab : aFuncMark)
1102  if (rTab != nStartTab)
1103  pUndoDoc->AddUndoTab( rTab, rTab );
1104 
1105  ScRange aCopyRange = aMarkRangeWithEnvelope;
1106  aCopyRange.aStart.SetTab(0);
1107  aCopyRange.aEnd.SetTab(nTabCount-1);
1108  rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, bCopyOnlyMarked, *pUndoDoc, &aFuncMark );
1109 
1110  pDocSh->GetUndoManager()->AddUndoAction(
1111  std::make_unique<ScUndoSelectionAttr>(
1112  pDocSh, aFuncMark,
1113  aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), aMarkRange.aStart.Tab(),
1114  aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), aMarkRange.aEnd.Tab(),
1115  std::move(pUndoDoc), bCopyOnlyMarked, &rAttr, &rNewOuter, pNewInner, &aMarkRangeWithEnvelope ) );
1116  }
1117 
1118  sal_uInt16 nExt = SC_PF_TESTMERGE;
1119  pDocSh->UpdatePaintExt( nExt, aMarkRangeWithEnvelope ); // content before the change
1120 
1121  rDoc.ApplySelectionFrame(aFuncMark, rNewOuter, pNewInner);
1122 
1123  pDocSh->UpdatePaintExt( nExt, aMarkRangeWithEnvelope ); // content after the change
1124 
1125  aFuncMark.MarkToMulti();
1126  rDoc.ApplySelectionPattern( rAttr, aFuncMark );
1127 
1128  pDocSh->PostPaint( aMarkRange, PaintPartFlags::Grid, nExt );
1129  pDocSh->UpdateOle(GetViewData());
1130  aModificator.SetDocumentModified();
1132 
1133  StartFormatArea();
1134 }
1135 
1136 // pattern only
1137 
1138 void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursorOnly )
1139 {
1140  ScViewData& rViewData = GetViewData();
1141  ScDocShell* pDocSh = rViewData.GetDocShell();
1142  ScDocument& rDoc = pDocSh->GetDocument();
1143  ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
1144  ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1145 
1146  bool bRecord = true;
1147  if (!rDoc.IsUndoEnabled())
1148  bRecord = false;
1149 
1150  // State from old ItemSet doesn't matter for paint flags, as any change will be
1151  // from SfxItemState::SET in the new ItemSet (default is ignored in ApplyPattern).
1152  // New alignment is checked (check in PostPaint isn't enough) in case a right
1153  // alignment is changed to left.
1154  const SfxItemSet& rNewSet = rAttr.GetItemSet();
1155  bool bSetLines = rNewSet.GetItemState( ATTR_BORDER ) == SfxItemState::SET ||
1156  rNewSet.GetItemState( ATTR_SHADOW ) == SfxItemState::SET;
1157  bool bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY ) == SfxItemState::SET;
1158 
1159  sal_uInt16 nExtFlags = 0;
1160  if ( bSetLines )
1161  nExtFlags |= SC_PF_LINES;
1162  if ( bSetAlign )
1163  nExtFlags |= SC_PF_WHOLEROWS;
1164 
1165  ScDocShellModificator aModificator( *pDocSh );
1166 
1167  bool bMulti = aFuncMark.IsMultiMarked();
1168  aFuncMark.MarkToMulti();
1169  bool bOnlyTab = (!aFuncMark.IsMultiMarked() && !bCursorOnly && aFuncMark.GetSelectCount() > 1);
1170  if (bOnlyTab)
1171  {
1172  SCCOL nCol = rViewData.GetCurX();
1173  SCROW nRow = rViewData.GetCurY();
1174  SCTAB nTab = rViewData.GetTabNo();
1175  aFuncMark.SetMarkArea(ScRange(nCol,nRow,nTab));
1176  aFuncMark.MarkToMulti();
1177  }
1178 
1179  ScRangeList aChangeRanges;
1180 
1181  if (aFuncMark.IsMultiMarked() && !bCursorOnly)
1182  {
1183  const ScRange& aMarkRange = aFuncMark.GetMultiMarkArea();
1184  SCTAB nTabCount = rDoc.GetTableCount();
1185  for (const auto& rTab : aFuncMark)
1186  {
1187  ScRange aChangeRange( aMarkRange );
1188  aChangeRange.aStart.SetTab( rTab );
1189  aChangeRange.aEnd.SetTab( rTab );
1190  aChangeRanges.push_back( aChangeRange );
1191  }
1192 
1193  SCCOL nStartCol = aMarkRange.aStart.Col();
1194  SCROW nStartRow = aMarkRange.aStart.Row();
1195  SCTAB nStartTab = aMarkRange.aStart.Tab();
1196  SCCOL nEndCol = aMarkRange.aEnd.Col();
1197  SCROW nEndRow = aMarkRange.aEnd.Row();
1198  SCTAB nEndTab = aMarkRange.aEnd.Tab();
1199 
1200  ScEditDataArray* pEditDataArray = nullptr;
1201  if (bRecord)
1202  {
1203  ScRange aCopyRange = aMarkRange;
1204  aCopyRange.aStart.SetTab(0);
1205  aCopyRange.aEnd.SetTab(nTabCount-1);
1206 
1208  pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
1209  for (const auto& rTab : aFuncMark)
1210  if (rTab != nStartTab)
1211  pUndoDoc->AddUndoTab( rTab, rTab );
1212  rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, bMulti, *pUndoDoc, &aFuncMark );
1213 
1214  aFuncMark.MarkToMulti();
1215 
1216  ScUndoSelectionAttr* pUndoAttr = new ScUndoSelectionAttr(
1217  pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
1218  nEndCol, nEndRow, nEndTab, std::move(pUndoDoc), bMulti, &rAttr );
1219  pDocSh->GetUndoManager()->AddUndoAction(std::unique_ptr<ScUndoSelectionAttr>(pUndoAttr));
1220  pEditDataArray = pUndoAttr->GetDataArray();
1221  }
1222 
1223  rDoc.ApplySelectionPattern( rAttr, aFuncMark, pEditDataArray );
1224 
1225  pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
1226  nEndCol, nEndRow, nEndTab,
1227  PaintPartFlags::Grid, nExtFlags | SC_PF_TESTMERGE );
1228  pDocSh->UpdateOle(GetViewData());
1229  aModificator.SetDocumentModified();
1231  }
1232  else // single cell - simpler undo
1233  {
1234  SCCOL nCol = rViewData.GetCurX();
1235  SCROW nRow = rViewData.GetCurY();
1236  SCTAB nTab = rViewData.GetTabNo();
1237 
1238  std::unique_ptr<EditTextObject> pOldEditData;
1239  std::unique_ptr<EditTextObject> pNewEditData;
1240  ScAddress aPos(nCol, nRow, nTab);
1241  ScRefCellValue aCell(rDoc, aPos);
1242  if (aCell.meType == CELLTYPE_EDIT)
1243  {
1244  const EditTextObject* pEditObj = aCell.mpEditText;
1245  pOldEditData = pEditObj->Clone();
1246  rDoc.RemoveEditTextCharAttribs(aPos, rAttr);
1247  pEditObj = rDoc.GetEditText(aPos);
1248  pNewEditData = pEditObj->Clone();
1249  }
1250 
1251  aChangeRanges.push_back(aPos);
1252  std::optional<ScPatternAttr> pOldPat(*rDoc.GetPattern( nCol, nRow, nTab ));
1253 
1254  rDoc.ApplyPattern( nCol, nRow, nTab, rAttr );
1255 
1256  const ScPatternAttr* pNewPat = rDoc.GetPattern( nCol, nRow, nTab );
1257 
1258  if (bRecord)
1259  {
1260  std::unique_ptr<ScUndoCursorAttr> pUndo(new ScUndoCursorAttr(
1261  pDocSh, nCol, nRow, nTab, &*pOldPat, pNewPat, &rAttr ));
1262  pUndo->SetEditData(std::move(pOldEditData), std::move(pNewEditData));
1263  pDocSh->GetUndoManager()->AddUndoAction(std::move(pUndo));
1264  }
1265  pOldPat.reset(); // is copied in undo (Pool)
1266 
1267  pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PaintPartFlags::Grid, nExtFlags | SC_PF_TESTMERGE );
1268  pDocSh->UpdateOle(GetViewData());
1269  aModificator.SetDocumentModified();
1271  }
1272 
1274  if (pModelObj)
1275  {
1276  css::uno::Sequence< css::beans::PropertyValue > aProperties;
1277  sal_Int32 nCount = 0;
1279  for ( sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; ++nWhich )
1280  {
1281  const SfxPoolItem* pItem = nullptr;
1282  if ( rNewSet.GetItemState( nWhich, true, &pItem ) == SfxItemState::SET && pItem )
1283  {
1284  for ( const auto pEntry : rMap.getPropertyEntries())
1285  {
1286  if ( pEntry->nWID == nWhich )
1287  {
1288  css::uno::Any aVal;
1289  pItem->QueryValue( aVal, pEntry->nMemberId );
1290  aProperties.realloc( nCount + 1 );
1291  auto pProperties = aProperties.getArray();
1292  pProperties[ nCount ].Name = pEntry->aName;
1293  pProperties[ nCount ].Value = aVal;
1294  ++nCount;
1295  }
1296  }
1297  }
1298  }
1299  HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "attribute", aProperties);
1300  }
1301 
1302  StartFormatArea();
1303 }
1304 
1306 {
1307  // ItemSet from UI, may have different pool
1308 
1309  bool bOnlyNotBecauseOfMatrix;
1310  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
1311  {
1312  ErrorMessage(STR_PROTECTIONERR);
1313  return;
1314  }
1315 
1316  ScPatternAttr aNewAttrs( GetViewData().GetDocument().GetPool() );
1317  SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
1318  rNewSet.Put( rItemSet, false );
1319  ApplySelectionPattern( aNewAttrs );
1320 
1322 }
1323 
1325 {
1326  // Don't use UnmarkFiltered in slot state functions, for performance reasons.
1327  // The displayed state is always that of the whole selection including filtered rows.
1328 
1329  const ScStyleSheet* pSheet = nullptr;
1330  ScViewData& rViewData = GetViewData();
1331  ScDocument& rDoc = rViewData.GetDocument();
1332  ScMarkData& rMark = rViewData.GetMarkData();
1333 
1334  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1335  pSheet = rDoc.GetSelectionStyle( rMark ); // MarkToMulti isn't necessary
1336  else
1337  pSheet = rDoc.GetStyle( rViewData.GetCurX(),
1338  rViewData.GetCurY(),
1339  rViewData.GetTabNo() );
1340 
1341  return pSheet;
1342 }
1343 
1345 {
1346  // not editable because of matrix only? attribute OK nonetheless
1347  bool bOnlyNotBecauseOfMatrix;
1348  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
1349  {
1350  ErrorMessage(STR_PROTECTIONERR);
1351  return;
1352  }
1353 
1354  if ( !pStyleSheet) return;
1355 
1356  ScViewData& rViewData = GetViewData();
1357  ScDocShell* pDocSh = rViewData.GetDocShell();
1358  ScDocument& rDoc = pDocSh->GetDocument();
1359  ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
1360  ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1361  SCTAB nTabCount = rDoc.GetTableCount();
1362  bool bRecord = true;
1363  if (!rDoc.IsUndoEnabled())
1364  bRecord = false;
1365 
1366  ScDocShellModificator aModificator( *pDocSh );
1367 
1368  if ( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() )
1369  {
1370  aFuncMark.MarkToMulti();
1371  const ScRange& aMarkRange = aFuncMark.GetMultiMarkArea();
1372 
1373  if ( bRecord )
1374  {
1375  SCTAB nTab = rViewData.GetTabNo();
1377  pUndoDoc->InitUndo( rDoc, nTab, nTab );
1378  for (const auto& rTab : aFuncMark)
1379  if (rTab != nTab)
1380  pUndoDoc->AddUndoTab( rTab, rTab );
1381 
1382  ScRange aCopyRange = aMarkRange;
1383  aCopyRange.aStart.SetTab(0);
1384  aCopyRange.aEnd.SetTab(nTabCount-1);
1385  rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, true, *pUndoDoc, &aFuncMark );
1386  aFuncMark.MarkToMulti();
1387 
1388  OUString aName = pStyleSheet->GetName();
1389  pDocSh->GetUndoManager()->AddUndoAction(
1390  std::make_unique<ScUndoSelectionStyle>( pDocSh, aFuncMark, aMarkRange, aName, std::move(pUndoDoc) ) );
1391  }
1392 
1393  rDoc.ApplySelectionStyle( static_cast<const ScStyleSheet&>(*pStyleSheet), aFuncMark );
1394 
1395  if (!AdjustBlockHeight())
1396  rViewData.GetDocShell()->PostPaint( aMarkRange, PaintPartFlags::Grid );
1397 
1398  aFuncMark.MarkToSimple();
1399  }
1400  else
1401  {
1402  SCCOL nCol = rViewData.GetCurX();
1403  SCROW nRow = rViewData.GetCurY();
1404  SCTAB nTab = rViewData.GetTabNo();
1405 
1406  if ( bRecord )
1407  {
1409  pUndoDoc->InitUndo( rDoc, nTab, nTab );
1410  for (const auto& rTab : aFuncMark)
1411  if (rTab != nTab)
1412  pUndoDoc->AddUndoTab( rTab, rTab );
1413 
1414  ScRange aCopyRange( nCol, nRow, 0, nCol, nRow, nTabCount-1 );
1415  rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, false, *pUndoDoc );
1416 
1417  ScRange aMarkRange ( nCol, nRow, nTab );
1418  ScMarkData aUndoMark = aFuncMark;
1419  aUndoMark.SetMultiMarkArea( aMarkRange );
1420 
1421  OUString aName = pStyleSheet->GetName();
1422  pDocSh->GetUndoManager()->AddUndoAction(
1423  std::make_unique<ScUndoSelectionStyle>( pDocSh, aUndoMark, aMarkRange, aName, std::move(pUndoDoc) ) );
1424  }
1425 
1426  for (const auto& rTab : aFuncMark)
1427  rDoc.ApplyStyle( nCol, nRow, rTab, static_cast<const ScStyleSheet&>(*pStyleSheet) );
1428 
1429  if (!AdjustBlockHeight())
1430  rViewData.GetDocShell()->PostPaintCell( nCol, nRow, nTab );
1431 
1432  }
1433 
1434  aModificator.SetDocumentModified();
1435 
1436  StartFormatArea();
1437 }
1438 
1440 {
1441  if ( !pStyleSheet) return;
1442 
1443  ScViewData& rViewData = GetViewData();
1444  ScDocument& rDoc = rViewData.GetDocument();
1445  ScDocShell* pDocSh = rViewData.GetDocShell();
1446 
1447  ScDocShellModificator aModificator( *pDocSh );
1448 
1450  pVirtDev->SetMapMode(MapMode(MapUnit::MapPixel));
1451  rDoc.StyleSheetChanged( pStyleSheet, true, pVirtDev,
1452  rViewData.GetPPTX(),
1453  rViewData.GetPPTY(),
1454  rViewData.GetZoomX(),
1455  rViewData.GetZoomY() );
1456 
1457  pDocSh->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1458  aModificator.SetDocumentModified();
1459 
1460  ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
1461  if (pHdl)
1462  pHdl->ForgetLastPattern();
1463 }
1464 
1466 {
1467  if ( !pStyleSheet) return;
1468 
1469  ScViewData& rViewData = GetViewData();
1470  ScDocument& rDoc = rViewData.GetDocument();
1471  ScDocShell* pDocSh = rViewData.GetDocShell();
1472 
1473  ScDocShellModificator aModificator( *pDocSh );
1474 
1476  pVirtDev->SetMapMode(MapMode(MapUnit::MapPixel));
1477  rDoc.StyleSheetChanged( pStyleSheet, false, pVirtDev,
1478  rViewData.GetPPTX(),
1479  rViewData.GetPPTY(),
1480  rViewData.GetZoomX(),
1481  rViewData.GetZoomY() );
1482 
1483  pDocSh->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1484  aModificator.SetDocumentModified();
1485 
1486  ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
1487  if (pHdl)
1488  pHdl->ForgetLastPattern();
1489 }
1490 
1491 
1493 {
1494  if (!comphelper::LibreOfficeKit::isActive() || nOffset == 0)
1495  return;
1496 
1497  SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
1498  SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
1499  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1500  while (pViewShell)
1501  {
1502  ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1503  if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
1504  {
1505  if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex))
1506  pPosHelper->invalidateByIndex(nStartCol);
1507 
1508  // if we remove a column the cursor position and the current selection
1509  // in other views could need to be moved on the left by one column.
1510  if (pTabViewShell != this)
1511  {
1512  if (pTabViewShell->getPart() == nCurrentTabIndex)
1513  {
1514  SCCOL nX = pTabViewShell->GetViewData().GetCurX();
1515  if (nX > nStartCol || (nX == nStartCol && nOffset > 0))
1516  {
1517  ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler();
1518  SCROW nY = pTabViewShell->GetViewData().GetCurY();
1519  pTabViewShell->SetCursor(nX + nOffset, nY);
1520  if (pInputHdl && pInputHdl->IsInputMode())
1521  {
1522  pInputHdl->SetModified();
1523  }
1524  }
1525 
1526  ScMarkData aMultiMark( pTabViewShell->GetViewData().GetMarkData() );
1527  aMultiMark.SetMarking( false );
1528  aMultiMark.MarkToMulti();
1529  if (aMultiMark.IsMultiMarked())
1530  {
1531  aMultiMark.ShiftCols(pTabViewShell->GetViewData().GetDocument(), nStartCol, nOffset);
1532  pTabViewShell->SetMarkData(aMultiMark);
1533  }
1534  }
1535  else
1536  {
1537  SCROW nX = pTabViewShell->GetViewData().GetCurXForTab(nCurrentTabIndex);
1538  if (nX > nStartCol || (nX == nStartCol && nOffset > 0))
1539  {
1540  pTabViewShell->GetViewData().SetCurXForTab(nX + nOffset, nCurrentTabIndex);
1541  }
1542  }
1543  }
1544  }
1545  pViewShell = SfxViewShell::GetNext(*pViewShell);
1546  }
1547 }
1548 
1550 {
1551  if (!comphelper::LibreOfficeKit::isActive() || nOffset == 0)
1552  return;
1553 
1554  SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
1555  SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
1556  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1557  while (pViewShell)
1558  {
1559  ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1560  if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
1561  {
1562  if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex))
1563  pPosHelper->invalidateByIndex(nStartRow);
1564 
1565  // if we remove a row the cursor position and the current selection
1566  // in other views could need to be moved up by one row.
1567  if (pTabViewShell != this)
1568  {
1569  if (pTabViewShell->getPart() == nCurrentTabIndex)
1570  {
1571  SCROW nY = pTabViewShell->GetViewData().GetCurY();
1572  if (nY > nStartRow || (nY == nStartRow && nOffset > 0))
1573  {
1574  ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler();
1575  SCCOL nX = pTabViewShell->GetViewData().GetCurX();
1576  pTabViewShell->SetCursor(nX, nY + nOffset);
1577  if (pInputHdl && pInputHdl->IsInputMode())
1578  {
1579  pInputHdl->SetModified();
1580  }
1581  }
1582 
1583  ScMarkData aMultiMark( pTabViewShell->GetViewData().GetMarkData() );
1584  aMultiMark.SetMarking( false );
1585  aMultiMark.MarkToMulti();
1586  if (aMultiMark.IsMultiMarked())
1587  {
1588  aMultiMark.ShiftRows(pTabViewShell->GetViewData().GetDocument(), nStartRow, nOffset);
1589  pTabViewShell->SetMarkData(aMultiMark);
1590  }
1591  }
1592  else
1593  {
1594  SCROW nY = pTabViewShell->GetViewData().GetCurYForTab(nCurrentTabIndex);
1595  if (nY > nStartRow || (nY == nStartRow && nOffset > 0))
1596  {
1597  pTabViewShell->GetViewData().SetCurYForTab(nY + nOffset, nCurrentTabIndex);
1598  }
1599  }
1600  }
1601  }
1602  pViewShell = SfxViewShell::GetNext(*pViewShell);
1603  }
1604 }
1605 
1607 {
1609  return;
1610 
1611  SCTAB nCurTab = GetViewData().GetTabNo();
1612  SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
1613  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1614  while (pViewShell)
1615  {
1616  ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1617  if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
1618  {
1619  if (bWidth)
1620  {
1621  if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab))
1622  pPosHelper->invalidateByIndex(nStart);
1623  }
1624  else
1625  {
1626  if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab))
1627  pPosHelper->invalidateByIndex(nStart);
1628  }
1629  }
1630  pViewShell = SfxViewShell::GetNext(*pViewShell);
1631  }
1632 }
1633 
1634 // insert cells - undo OK
1635 
1636 bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste )
1637 {
1638  ScRange aRange;
1639  ScMarkType eMarkType = GetViewData().GetSimpleArea(aRange);
1640  if (eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED)
1641  {
1642  ScDocShell* pDocSh = GetViewData().GetDocShell();
1643  const ScMarkData& rMark = GetViewData().GetMarkData();
1644  bool bSuccess = pDocSh->GetDocFunc().InsertCells( aRange, &rMark, eCmd, bRecord, false, bPartOfPaste );
1645  if (bSuccess)
1646  {
1648  bool bInsertCols = ( eCmd == INS_INSCOLS_BEFORE || eCmd == INS_INSCOLS_AFTER);
1649  bool bInsertRows = ( eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSROWS_AFTER );
1650 
1651  pDocSh->UpdateOle(GetViewData());
1653 
1654  if ( bInsertCols || bInsertRows )
1655  {
1656  OUString aOperation = bInsertRows ?
1657  OUString("insert-rows"):
1658  OUString("insert-columns");
1659  HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation);
1660  }
1661 
1663  {
1664  if (bInsertCols)
1666 
1667  if (bInsertRows)
1669 
1671  bInsertCols, bInsertRows, true /* bSizes*/,
1672  true /* bHidden */, true /* bFiltered */,
1673  true /* bGroups */, GetViewData().GetTabNo());
1674  }
1675  }
1676  OUString aStartAddress = aRange.aStart.GetColRowString();
1677  OUString aEndAddress = aRange.aEnd.GetColRowString();
1678  collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "INSERT_CELLS");
1679  return bSuccess;
1680  }
1681  else
1682  {
1683  ErrorMessage(STR_NOMULTISELECT);
1684  return false;
1685  }
1686 }
1687 
1688 // delete cells - undo OK
1689 
1691 {
1692  ScRange aRange;
1693  if ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
1694  {
1695  ScDocShell* pDocSh = GetViewData().GetDocShell();
1696  const ScMarkData& rMark = GetViewData().GetMarkData();
1697 
1698 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
1699  // #i94841# [Collaboration] if deleting rows is rejected, the content is sometimes wrong
1700  if ( pDocSh->IsDocShared() && ( eCmd == DelCellCmd::Rows || eCmd == DelCellCmd::Cols ) )
1701  {
1702  ScRange aDelRange( aRange.aStart );
1703  SCCOLROW nCount = 0;
1704  if ( eCmd == DelCellCmd::Rows )
1705  {
1706  nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
1707  }
1708  else
1709  {
1710  nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Col() - aRange.aStart.Col() + 1 );
1711  }
1712  while ( nCount > 0 )
1713  {
1714  pDocSh->GetDocFunc().DeleteCells( aDelRange, &rMark, eCmd, false );
1715  --nCount;
1716  }
1717  }
1718  else
1719 #endif
1720  {
1721  pDocSh->GetDocFunc().DeleteCells( aRange, &rMark, eCmd, false );
1722  }
1723 
1725  pDocSh->UpdateOle(GetViewData());
1727 
1728  if ( eCmd == DelCellCmd::Rows || eCmd == DelCellCmd::Cols )
1729  {
1730  OUString aOperation = ( eCmd == DelCellCmd::Rows) ?
1731  OUString("delete-rows"):
1732  OUString("delete-columns");
1733  HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation);
1734  }
1735 
1736  // put cursor directly behind deleted range
1737  SCCOL nCurX = GetViewData().GetCurX();
1738  SCROW nCurY = GetViewData().GetCurY();
1739  if ( eCmd==DelCellCmd::CellsLeft || eCmd==DelCellCmd::Cols )
1740  nCurX = aRange.aStart.Col();
1741  else
1742  nCurY = aRange.aStart.Row();
1743  SetCursor( nCurX, nCurY );
1744 
1746  {
1747  bool bColsDeleted = (eCmd == DelCellCmd::Cols);
1748  bool bRowsDeleted = (eCmd == DelCellCmd::Rows);
1749  if (bColsDeleted)
1751 
1752  if (bRowsDeleted)
1754 
1756  bColsDeleted, bRowsDeleted, true /* bSizes*/,
1757  true /* bHidden */, true /* bFiltered */,
1758  true /* bGroups */, GetViewData().GetTabNo());
1759  }
1760  }
1761  else
1762  {
1763  if (eCmd == DelCellCmd::Cols)
1764  DeleteMulti( false );
1765  else if (eCmd == DelCellCmd::Rows)
1766  DeleteMulti( true );
1767  else
1768  ErrorMessage(STR_NOMULTISELECT);
1769  }
1770 
1771  OUString aStartAddress = aRange.aStart.GetColRowString();
1772  OUString aEndAddress = aRange.aEnd.GetColRowString();
1773  collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "DELETE_CELLS");
1774 
1775  Unmark();
1776 }
1777 
1778 void ScViewFunc::DeleteMulti( bool bRows )
1779 {
1780  ScDocShell* pDocSh = GetViewData().GetDocShell();
1781  ScDocShellModificator aModificator( *pDocSh );
1782  SCTAB nTab = GetViewData().GetTabNo();
1783  ScDocument& rDoc = pDocSh->GetDocument();
1784  ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
1785  ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1786 
1787  bool bRecord = true;
1788  if (!rDoc.IsUndoEnabled())
1789  bRecord = false;
1790 
1791  std::vector<sc::ColRowSpan> aSpans;
1792  if (bRows)
1793  aSpans = aFuncMark.GetMarkedRowSpans();
1794  else
1795  aSpans = aFuncMark.GetMarkedColSpans();
1796 
1797  if (aSpans.empty())
1798  {
1799  SCCOLROW nCurPos = bRows ? GetViewData().GetCurY() : GetViewData().GetCurX();
1800  aSpans.emplace_back(nCurPos, nCurPos);
1801  }
1802 
1803  // test if allowed
1804 
1805  TranslateId pErrorId;
1806  bool bNeedRefresh = false;
1807  for (size_t i = 0, n = aSpans.size(); i < n && !pErrorId; ++i)
1808  {
1809  SCCOLROW nStart = aSpans[i].mnStart;
1810  SCCOLROW nEnd = aSpans[i].mnEnd;
1811 
1812  SCCOL nStartCol, nEndCol;
1813  SCROW nStartRow, nEndRow;
1814  if ( bRows )
1815  {
1816  nStartCol = 0;
1817  nEndCol = rDoc.MaxCol();
1818  nStartRow = static_cast<SCROW>(nStart);
1819  nEndRow = static_cast<SCROW>(nEnd);
1820  }
1821  else
1822  {
1823  nStartCol = static_cast<SCCOL>(nStart);
1824  nEndCol = static_cast<SCCOL>(nEnd);
1825  nStartRow = 0;
1826  nEndRow = rDoc.MaxRow();
1827  }
1828 
1829  // cell protection (only needed for first range, as all following cells are moved)
1830  if (i == 0)
1831  {
1832  // test to the end of the sheet
1833  ScEditableTester aTester( rDoc, nTab, nStartCol, nStartRow, rDoc.MaxCol(), rDoc.MaxRow() );
1834  if (!aTester.IsEditable())
1835  pErrorId = aTester.GetMessageId();
1836  }
1837 
1838  // merged cells
1839  SCCOL nMergeStartX = nStartCol;
1840  SCROW nMergeStartY = nStartRow;
1841  SCCOL nMergeEndX = nEndCol;
1842  SCROW nMergeEndY = nEndRow;
1843  rDoc.ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
1844  rDoc.ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
1845 
1846  if ( nMergeStartX != nStartCol || nMergeStartY != nStartRow )
1847  {
1848  // Disallow deleting parts of a merged cell.
1849  // Deleting the start is allowed (merge is removed), so the end doesn't have to be checked.
1850 
1851  pErrorId = STR_MSSG_DELETECELLS_0;
1852  }
1853  if ( nMergeEndX != nEndCol || nMergeEndY != nEndRow )
1854  {
1855  // detect if the start of a merged cell is deleted, so the merge flags can be refreshed
1856 
1857  bNeedRefresh = true;
1858  }
1859  }
1860 
1861  if (pErrorId)
1862  {
1863  ErrorMessage(pErrorId);
1864  return;
1865  }
1866 
1867  // proceed
1868 
1869  weld::WaitObject aWait(GetViewData().GetDialogParent()); // important for TrackFormulas in UpdateReference
1870 
1872 
1873  ScDocumentUniquePtr pUndoDoc;
1874  std::unique_ptr<ScRefUndoData> pUndoData;
1875  if (bRecord)
1876  {
1877  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
1878  pUndoDoc->InitUndo( rDoc, nTab, nTab, !bRows, bRows ); // row height
1879 
1880  for (const sc::ColRowSpan & rSpan : aSpans)
1881  {
1882  SCCOLROW nStart = rSpan.mnStart;
1883  SCCOLROW nEnd = rSpan.mnEnd;
1884  if (bRows)
1885  rDoc.CopyToDocument( 0,nStart,nTab, rDoc.MaxCol(), nEnd,nTab, InsertDeleteFlags::ALL,false,*pUndoDoc );
1886  else
1887  rDoc.CopyToDocument( static_cast<SCCOL>(nStart),0,nTab,
1888  static_cast<SCCOL>(nEnd), rDoc.MaxRow(), nTab,
1889  InsertDeleteFlags::ALL,false,*pUndoDoc );
1890  }
1891 
1892  // all Formulas because of references
1893  SCTAB nTabCount = rDoc.GetTableCount();
1894  pUndoDoc->AddUndoTab( 0, nTabCount-1 );
1895  rDoc.CopyToDocument( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB, InsertDeleteFlags::FORMULA,false,*pUndoDoc );
1896 
1897  pUndoData.reset(new ScRefUndoData( &rDoc ));
1898 
1899  rDoc.BeginDrawUndo();
1900  }
1901 
1902  std::vector<sc::ColRowSpan>::const_reverse_iterator ri = aSpans.rbegin(), riEnd = aSpans.rend();
1903  aFuncMark.SelectOneTable(nTab);
1904  for (; ri != riEnd; ++ri)
1905  {
1906  SCCOLROW nEnd = ri->mnEnd;
1907  SCCOLROW nStart = ri->mnStart;
1908 
1909  if (bRows)
1910  {
1911  rDoc.DeleteObjectsInArea(0, nStart, rDoc.MaxCol(), nEnd, aFuncMark, true);
1912  rDoc.DeleteRow(0, nTab, rDoc.MaxCol(), nTab, nStart, static_cast<SCSIZE>(nEnd - nStart + 1));
1913  }
1914  else
1915  {
1916  rDoc.DeleteObjectsInArea(nStart, 0, nEnd, rDoc.MaxRow(), aFuncMark, true);
1917  rDoc.DeleteCol(0, nTab, rDoc.MaxRow(), nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd - nStart + 1));
1918  }
1919  }
1920 
1921  if (bNeedRefresh)
1922  {
1923  SCCOLROW nFirstStart = aSpans[0].mnStart;
1924  SCCOL nStartCol = bRows ? 0 : static_cast<SCCOL>(nFirstStart);
1925  SCROW nStartRow = bRows ? static_cast<SCROW>(nFirstStart) : 0;
1926  SCCOL nEndCol = rDoc.MaxCol();
1927  SCROW nEndRow = rDoc.MaxRow();
1928 
1929  rDoc.RemoveFlagsTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, ScMF::Hor | ScMF::Ver );
1930  rDoc.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab, true );
1931  }
1932 
1933  if (bRecord)
1934  {
1935  pDocSh->GetUndoManager()->AddUndoAction(
1936  std::make_unique<ScUndoDeleteMulti>(
1937  pDocSh, bRows, bNeedRefresh, nTab, std::vector(aSpans), std::move(pUndoDoc), std::move(pUndoData)));
1938  }
1939 
1940  if (!AdjustRowHeight(0, rDoc.MaxRow(), true))
1941  {
1942  if (bRows)
1943  {
1944  pDocSh->PostPaint(
1945  0, aSpans[0].mnStart, nTab,
1946  rDoc.MaxCol(), rDoc.MaxRow(), nTab, (PaintPartFlags::Grid | PaintPartFlags::Left));
1947  }
1948  else
1949  {
1950  pDocSh->PostPaint(
1951  static_cast<SCCOL>(aSpans[0].mnStart), 0, nTab,
1952  rDoc.MaxCol(), rDoc.MaxRow(), nTab, (PaintPartFlags::Grid | PaintPartFlags::Top));
1953  }
1954  }
1955 
1956  aModificator.SetDocumentModified();
1957 
1959 
1960  // put cursor directly behind the first deleted range
1961  SCCOL nCurX = GetViewData().GetCurX();
1962  SCROW nCurY = GetViewData().GetCurY();
1963  if ( bRows )
1964  nCurY = aSpans[0].mnStart;
1965  else
1966  nCurX = static_cast<SCCOL>(aSpans[0].mnStart);
1967  SetCursor( nCurX, nCurY );
1968 
1969  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
1970 }
1971 
1972 // delete contents
1973 
1975 {
1976  ScViewData& rViewData = GetViewData();
1977  rViewData.SetPasteMode( ScPasteFlags::NONE );
1978  rViewData.GetViewShell()->UpdateCopySourceOverlay();
1979 
1980  // not editable because of matrix only? attribute OK nonetheless
1981  bool bOnlyNotBecauseOfMatrix;
1982  bool bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix );
1983  if ( !bEditable )
1984  {
1985  if ( !(bOnlyNotBecauseOfMatrix &&
1986  ((nFlags & (InsertDeleteFlags::ATTRIB | InsertDeleteFlags::EDITATTR)) == nFlags)) )
1987  {
1988  ErrorMessage(bOnlyNotBecauseOfMatrix ? STR_MATRIXFRAGMENTERR : STR_PROTECTIONERR);
1989  return;
1990  }
1991  }
1992 
1993  ScRange aMarkRange;
1994  bool bSimple = false;
1995 
1996  ScDocument& rDoc = GetViewData().GetDocument();
1997  ScDocShell* pDocSh = GetViewData().GetDocShell();
1998  ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
1999  ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
2000 
2001  bool bRecord =true;
2002  if (!rDoc.IsUndoEnabled())
2003  bRecord = false;
2004 
2005  if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
2006  {
2007  aMarkRange.aStart.SetCol(GetViewData().GetCurX());
2008  aMarkRange.aStart.SetRow(GetViewData().GetCurY());
2009  aMarkRange.aStart.SetTab(GetViewData().GetTabNo());
2010  aMarkRange.aEnd = aMarkRange.aStart;
2011  if ( rDoc.HasAttrib( aMarkRange, HasAttrFlags::Merged ) )
2012  {
2013  aFuncMark.SetMarkArea( aMarkRange );
2014  }
2015  else
2016  bSimple = true;
2017  }
2018 
2019  HideAllCursors(); // for if summary is cancelled
2020 
2021  ScDocFunc& rDocFunc = pDocSh->GetDocFunc();
2022 
2023  // Can we really be sure that we can pass the bApi parameter as false to DeleteCell() and
2024  // DeleteContents() here? (Meaning that this is interactive use.) Is this never invoked from
2025  // scripting and whatnot?
2026  if (bSimple)
2027  rDocFunc.DeleteCell(aMarkRange.aStart, aFuncMark, nFlags, bRecord, /*bApi=*/ false);
2028  else
2029  rDocFunc.DeleteContents(aFuncMark, nFlags, bRecord, /*bApi=*/ false);
2030 
2031  pDocSh->UpdateOle(GetViewData());
2032 
2034  {
2035  ScRangeList aChangeRanges;
2036  if ( bSimple )
2037  {
2038  aChangeRanges.push_back( aMarkRange );
2039  }
2040  else
2041  {
2042  aFuncMark.FillRangeListWithMarks( &aChangeRanges, false );
2043  }
2044  HelperNotifyChanges::Notify(*pModelObj, aChangeRanges);
2045  }
2046 
2048  ShowAllCursors();
2049 
2050  if ( nFlags & InsertDeleteFlags::ATTRIB )
2051  {
2052  if ( nFlags & InsertDeleteFlags::CONTENTS )
2053  bFormatValid = false;
2054  else
2055  StartFormatArea(); // delete attribute is also attribute-change
2056  }
2057  OUString aStartAddress = aMarkRange.aStart.GetColRowString();
2058  OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
2059  collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "DELETE");
2060 }
2061 
2062 // column width/row height (via header) - undo OK
2063 
2065  bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, ScSizeMode eMode,
2066  sal_uInt16 nSizeTwips, bool bRecord, const ScMarkData* pMarkData )
2067 {
2068  if (rRanges.empty())
2069  return;
2070 
2071  // Use view's mark if none specified, but do not modify the original data,
2072  // i.e. no MarkToMulti() on that.
2073  ScMarkData aMarkData( pMarkData ? *pMarkData : GetViewData().GetMarkData());
2074 
2075  ScDocShell* pDocSh = GetViewData().GetDocShell();
2076  ScDocument& rDoc = pDocSh->GetDocument();
2077  SCCOL nCurX = GetViewData().GetCurX();
2078  SCROW nCurY = GetViewData().GetCurY();
2079  SCTAB nFirstTab = aMarkData.GetFirstSelected();
2080  SCTAB nCurTab = GetViewData().GetTabNo();
2081  if (bRecord && !rDoc.IsUndoEnabled())
2082  bRecord = false;
2083 
2084  ScDocShellModificator aModificator( *pDocSh );
2085 
2086  bool bAllowed = true;
2087  for (const SCTAB& nTab : aMarkData)
2088  {
2089  bAllowed = std::all_of(rRanges.begin(), rRanges.end(),
2090  [&bWidth, &rDoc, &nTab](const sc::ColRowSpan& rRange) {
2091  bool bOnlyMatrix;
2092  bool bIsBlockEditable;
2093  if (bWidth)
2094  bIsBlockEditable = rDoc.IsBlockEditable(nTab, rRange.mnStart, 0, rRange.mnEnd, rDoc.MaxRow(), &bOnlyMatrix);
2095  else
2096  bIsBlockEditable = rDoc.IsBlockEditable(nTab, 0, rRange.mnStart, rDoc.MaxCol(), rRange.mnEnd, &bOnlyMatrix);
2097  return bIsBlockEditable || bOnlyMatrix;
2098  });
2099  if (!bAllowed)
2100  break;
2101  }
2102 
2103  // Allow users to resize cols/rows in readonly docs despite the r/o state.
2104  // It is frustrating to be unable to see content in mis-sized cells.
2105  if( !bAllowed && !pDocSh->IsReadOnly() )
2106  {
2107  ErrorMessage(STR_PROTECTIONERR);
2108  return;
2109  }
2110 
2111  SCCOLROW nStart = rRanges.front().mnStart;
2112  SCCOLROW nEnd = rRanges.back().mnEnd;
2113 
2114  OnLOKSetWidthOrHeight(nStart, bWidth);
2115 
2116  bool bFormula = false;
2117  if ( eMode == SC_SIZE_OPTIMAL )
2118  {
2119  const ScViewOptions& rOpts = GetViewData().GetOptions();
2120  bFormula = rOpts.GetOption( VOPT_FORMULAS );
2121  }
2122 
2123  ScDocumentUniquePtr pUndoDoc;
2124  std::unique_ptr<ScOutlineTable> pUndoTab;
2125  std::vector<sc::ColRowSpan> aUndoRanges;
2126 
2127  if ( bRecord )
2128  {
2129  rDoc.BeginDrawUndo(); // Drawing Updates
2130 
2131  pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
2132  for (const SCTAB& nTab : aMarkData)
2133  {
2134  if (bWidth)
2135  {
2136  if ( nTab == nFirstTab )
2137  pUndoDoc->InitUndo( rDoc, nTab, nTab, true );
2138  else
2139  pUndoDoc->AddUndoTab( nTab, nTab, true );
2140  rDoc.CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
2141  static_cast<SCCOL>(nEnd), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE,
2142  false, *pUndoDoc );
2143  }
2144  else
2145  {
2146  if ( nTab == nFirstTab )
2147  pUndoDoc->InitUndo( rDoc, nTab, nTab, false, true );
2148  else
2149  pUndoDoc->AddUndoTab( nTab, nTab, false, true );
2150  rDoc.CopyToDocument( 0, nStart, nTab, rDoc.MaxCol(), nEnd, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc );
2151  }
2152  }
2153 
2154  aUndoRanges = rRanges;
2155 
2157  ScOutlineTable* pTable = rDoc.GetOutlineTable( nCurTab );
2158  if (pTable)
2159  pUndoTab.reset(new ScOutlineTable( *pTable ));
2160  }
2161 
2162  if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
2163  aMarkData.MarkToMulti();
2164 
2165  bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
2166  bool bOutline = false;
2167 
2168  for (const SCTAB& nTab : aMarkData)
2169  {
2170  for (const sc::ColRowSpan & rRange : rRanges)
2171  {
2172  SCCOLROW nStartNo = rRange.mnStart;
2173  SCCOLROW nEndNo = rRange.mnEnd;
2174 
2175  if ( !bWidth ) // height always blockwise
2176  {
2177  if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
2178  {
2179  bool bAll = ( eMode==SC_SIZE_OPTIMAL );
2180  if (!bAll)
2181  {
2182  // delete CRFlags::ManualSize for all in range,
2183  // then SetOptimalHeight with bShrink = FALSE
2184  for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow)
2185  {
2186  SCROW nLastRow = nRow;
2187  if (rDoc.RowHidden(nRow, nTab, nullptr, &nLastRow))
2188  {
2189  nRow = nLastRow;
2190  continue;
2191  }
2192 
2193  CRFlags nOld = rDoc.GetRowFlags(nRow, nTab);
2194  if (nOld & CRFlags::ManualSize)
2195  rDoc.SetRowFlags(nRow, nTab, nOld & ~CRFlags::ManualSize);
2196  }
2197  }
2198 
2199  double nPPTX = GetViewData().GetPPTX();
2200  double nPPTY = GetViewData().GetPPTY();
2201  Fraction aZoomX = GetViewData().GetZoomX();
2202  Fraction aZoomY = GetViewData().GetZoomY();
2203 
2204  ScSizeDeviceProvider aProv(pDocSh);
2205  if (aProv.IsPrinter())
2206  {
2207  nPPTX = aProv.GetPPTX();
2208  nPPTY = aProv.GetPPTY();
2209  aZoomX = aZoomY = Fraction( 1, 1 );
2210  }
2211 
2212  sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
2213  aCxt.setForceAutoSize(bAll);
2214  aCxt.setExtraHeight(nSizeTwips);
2215  rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true);
2216  if (bAll)
2217  rDoc.ShowRows( nStartNo, nEndNo, nTab, true );
2218 
2219  // Manual-Flag already (re)set in SetOptimalHeight in case of bAll=sal_True
2220  // (set for Extra-Height, else reset).
2221  }
2222  else if ( eMode==SC_SIZE_DIRECT )
2223  {
2224  if (nSizeTwips)
2225  {
2226  rDoc.SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
2227  rDoc.SetManualHeight( nStartNo, nEndNo, nTab, true ); // height was set manually
2228  }
2229 
2230  rDoc.ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
2231 
2232  if (!bShow && nStartNo <= nCurY && nCurY <= nEndNo && nTab == nCurTab)
2233  {
2234  nCurY = -1;
2235  }
2236  }
2237  else if ( eMode==SC_SIZE_SHOW )
2238  {
2239  rDoc.ShowRows( nStartNo, nEndNo, nTab, true );
2240  }
2241  }
2242  else // column width
2243  {
2244  for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
2245  {
2246  if ( eMode != SC_SIZE_VISOPT || !rDoc.ColHidden(nCol, nTab) )
2247  {
2248  sal_uInt16 nThisSize = nSizeTwips;
2249 
2250  if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
2251  nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula );
2252  if ( nThisSize )
2253  rDoc.SetColWidth( nCol, nTab, nThisSize );
2254 
2255  rDoc.ShowCol( nCol, nTab, bShow );
2256 
2257  if (!bShow && nCol == nCurX && nTab == nCurTab)
2258  {
2259  nCurX = -1;
2260  }
2261  }
2262  }
2263  }
2264 
2265  // adjust outline
2266  if (bWidth)
2267  {
2268  if ( rDoc.UpdateOutlineCol( static_cast<SCCOL>(nStartNo),
2269  static_cast<SCCOL>(nEndNo), nTab, bShow ) )
2270  bOutline = true;
2271  }
2272  else
2273  {
2274  if ( rDoc.UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ) )
2275  bOutline = true;
2276  }
2277  }
2278  rDoc.SetDrawPageSize(nTab);
2279  }
2280 
2281  if (!bOutline)
2282  pUndoTab.reset();
2283 
2284  if (bRecord)
2285  {
2286  pDocSh->GetUndoManager()->AddUndoAction(
2287  std::make_unique<ScUndoWidthOrHeight>(
2288  pDocSh, aMarkData, nStart, nCurTab, nEnd, nCurTab,
2289  std::move(pUndoDoc), std::move(aUndoRanges), std::move(pUndoTab), eMode, nSizeTwips, bWidth));
2290  }
2291 
2292  if (nCurX < 0)
2293  {
2294  MoveCursorRel( 1, 0, SC_FOLLOW_LINE, false );
2295  }
2296 
2297  if (nCurY < 0)
2298  {
2299  MoveCursorRel( 0, 1, SC_FOLLOW_LINE, false );
2300  }
2301 
2302  // fdo#36247 Ensure that the drawing layer's map mode scaling factors match
2303  // the new heights and widths.
2305 
2306  for (const SCTAB& nTab : aMarkData)
2307  rDoc.UpdatePageBreaks( nTab );
2308 
2309  bool bAffectsVisibility = (eMode != SC_SIZE_ORIGINAL && eMode != SC_SIZE_VISOPT);
2311  bWidth /* bColumns */, !bWidth /* bRows */,
2312  true /* bSizes*/, bAffectsVisibility /* bHidden */, bAffectsVisibility /* bFiltered */,
2313  false /* bGroups */, nCurTab);
2315 
2316  {
2317  for (const SCTAB& nTab : aMarkData)
2318  {
2319  if (bWidth)
2320  {
2321  if (rDoc.HasAttrib( static_cast<SCCOL>(nStart),0,nTab,
2322  static_cast<SCCOL>(nEnd), rDoc.MaxRow(), nTab,
2324  nStart = 0;
2325  if (nStart > 0) // go upwards because of Lines and cursor
2326  --nStart;
2327  pDocSh->PostPaint( static_cast<SCCOL>(nStart), 0, nTab,
2328  rDoc.MaxCol(), rDoc.MaxRow(), nTab, PaintPartFlags::Grid | PaintPartFlags::Top );
2329  }
2330  else
2331  {
2332  if (rDoc.HasAttrib( 0,nStart,nTab, rDoc.MaxCol(), nEnd,nTab, HasAttrFlags::Merged | HasAttrFlags::Overlapped ))
2333  nStart = 0;
2334  if (nStart != 0)
2335  --nStart;
2336  pDocSh->PostPaint( 0, nStart, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, PaintPartFlags::Grid | PaintPartFlags::Left );
2337  }
2338  }
2339 
2340  pDocSh->UpdateOle(GetViewData());
2341  if( !pDocSh->IsReadOnly() )
2342  aModificator.SetDocumentModified();
2343  }
2344 
2345  if ( !bWidth )
2346  return;
2347 
2349  if (!pModelObj)
2350  return;
2351 
2352  ScRangeList aChangeRanges;
2353  for (const SCTAB& nTab : aMarkData)
2354  {
2355  for (const sc::ColRowSpan & rRange : rRanges)
2356  {
2357  SCCOL nStartCol = rRange.mnStart;
2358  SCCOL nEndCol = rRange.mnEnd;
2359  for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
2360  {
2361  aChangeRanges.push_back( ScRange( nCol, 0, nTab ) );
2362  }
2363  }
2364  }
2365  HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize");
2366 }
2367 
2368 // column width/row height (via marked range)
2369 
2370 void ScViewFunc::SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips )
2371 {
2372  ScMarkData& rMark = GetViewData().GetMarkData();
2373 
2374  rMark.MarkToMulti();
2375  if (!rMark.IsMultiMarked())
2376  {
2377  SCCOL nCol = GetViewData().GetCurX();
2378  SCROW nRow = GetViewData().GetCurY();
2379  SCTAB nTab = GetViewData().GetTabNo();
2380  const ScRange aMarkRange( nCol, nRow, nTab);
2381  DoneBlockMode();
2382  InitOwnBlockMode( aMarkRange );
2383  rMark.SetMultiMarkArea( aMarkRange );
2384  MarkDataChanged();
2385  }
2386 
2387  std::vector<sc::ColRowSpan> aRanges =
2388  bWidth ? rMark.GetMarkedColSpans() : rMark.GetMarkedRowSpans();
2389 
2390  SetWidthOrHeight(bWidth, aRanges, eMode, nSizeTwips);
2391 
2392  rMark.MarkToSimple();
2393 }
2394 
2395 void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
2396 {
2398  // step size is also minimum
2399  constexpr sal_uInt16 nStepX = STD_COL_WIDTH / 5;
2400  sal_uInt16 nStepY = ScGlobal::nStdRowHeight;
2401 
2402  ScModule* pScMod = SC_MOD();
2403  bool bAnyEdit = pScMod->IsInputMode();
2404  SCCOL nCol = GetViewData().GetCurX();
2405  SCROW nRow = GetViewData().GetCurY();
2406  SCTAB nTab = GetViewData().GetTabNo();
2407  ScDocShell* pDocSh = GetViewData().GetDocShell();
2408  ScDocument& rDoc = pDocSh->GetDocument();
2409 
2410  bool bAllowed, bOnlyMatrix;
2411  if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
2412  bAllowed = rDoc.IsBlockEditable( nTab, nCol,0, nCol,rDoc.MaxRow(), &bOnlyMatrix );
2413  else
2414  bAllowed = rDoc.IsBlockEditable( nTab, 0,nRow, rDoc.MaxCol(), nRow, &bOnlyMatrix );
2415  if ( !bAllowed && !bOnlyMatrix )
2416  {
2417  ErrorMessage(STR_PROTECTIONERR);
2418  return;
2419  }
2420 
2421  HideAllCursors();
2422 
2423  sal_uInt16 nWidth = rDoc.GetColWidth( nCol, nTab );
2424  sal_uInt16 nHeight = rDoc.GetRowHeight( nRow, nTab );
2425  std::vector<sc::ColRowSpan> aRange(1, sc::ColRowSpan(0,0));
2426  if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
2427  {
2428  if (bOptimal) // width of this single cell
2429  {
2430  if ( bAnyEdit )
2431  {
2432  // when editing the actual entered width
2433  ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData().GetViewShell() );
2434  if (pHdl)
2435  {
2436  tools::Long nEdit = pHdl->GetTextSize().Width(); // in 0.01 mm
2437 
2438  const ScPatternAttr* pPattern = rDoc.GetPattern( nCol, nRow, nTab );
2439  const SvxMarginItem& rMItem = pPattern->GetItem(ATTR_MARGIN);
2440  sal_uInt16 nMargin = rMItem.GetLeftMargin() + rMItem.GetRightMargin();
2441  if ( pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue() == SvxCellHorJustify::Left )
2442  nMargin = sal::static_int_cast<sal_uInt16>(
2443  nMargin + pPattern->GetItem(ATTR_INDENT).GetValue() );
2444 
2445  nWidth = std::round(o3tl::convert(nEdit * pDocSh->GetOutputFactor(),
2447  + nMargin + STD_EXTRA_WIDTH;
2448  }
2449  }
2450  else
2451  {
2452  double nPPTX = GetViewData().GetPPTX();
2453  double nPPTY = GetViewData().GetPPTY();
2454  Fraction aZoomX = GetViewData().GetZoomX();
2455  Fraction aZoomY = GetViewData().GetZoomY();
2456 
2457  ScSizeDeviceProvider aProv(pDocSh);
2458  if (aProv.IsPrinter())
2459  {
2460  nPPTX = aProv.GetPPTX();
2461  nPPTY = aProv.GetPPTY();
2462  aZoomX = aZoomY = Fraction( 1, 1 );
2463  }
2464 
2465  tools::Long nPixel = rDoc.GetNeededSize( nCol, nRow, nTab, aProv.GetDevice(),
2466  nPPTX, nPPTY, aZoomX, aZoomY, true );
2467  sal_uInt16 nTwips = static_cast<sal_uInt16>( nPixel / nPPTX );
2468  if (nTwips != 0)
2469  nWidth = nTwips + STD_EXTRA_WIDTH;
2470  else
2471  nWidth = STD_COL_WIDTH;
2472  }
2473  }
2474  else // increment / decrement
2475  {
2476  if ( eDir == DIR_RIGHT )
2477  nWidth = sal::static_int_cast<sal_uInt16>( nWidth + nStepX );
2478  else if ( nWidth > nStepX )
2479  nWidth = sal::static_int_cast<sal_uInt16>( nWidth - nStepX );
2480  if ( nWidth < nStepX ) nWidth = nStepX;
2481  if ( nWidth > MAX_COL_WIDTH ) nWidth = MAX_COL_WIDTH;
2482  }
2483  aRange[0].mnStart = nCol;
2484  aRange[0].mnEnd = nCol;
2485  SetWidthOrHeight(true, aRange, SC_SIZE_DIRECT, nWidth);
2486 
2487  // adjust height of this row if width demands/allows this
2488 
2489  if (!bAnyEdit)
2490  {
2491  const ScPatternAttr* pPattern = rDoc.GetPattern( nCol, nRow, nTab );
2492  bool bNeedHeight =
2493  pPattern->GetItem( ATTR_LINEBREAK ).GetValue() ||
2494  pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue() == SvxCellHorJustify::Block;
2495  if (bNeedHeight)
2496  AdjustRowHeight( nRow, nRow, true );
2497  }
2498  }
2499  else
2500  {
2501  ScSizeMode eMode;
2502  if (bOptimal)
2503  {
2504  eMode = SC_SIZE_OPTIMAL;
2505  nHeight = 0;
2506  }
2507  else
2508  {
2509  eMode = SC_SIZE_DIRECT;
2510  if ( eDir == DIR_BOTTOM )
2511  nHeight = sal::static_int_cast<sal_uInt16>( nHeight + nStepY );
2512  else if ( nHeight > nStepY )
2513  nHeight = sal::static_int_cast<sal_uInt16>( nHeight - nStepY );
2514  if ( nHeight < nStepY ) nHeight = nStepY;
2515  if ( nHeight > MAX_ROW_HEIGHT ) nHeight = MAX_ROW_HEIGHT;
2516  }
2517  aRange[0].mnStart = nRow;
2518  aRange[0].mnEnd = nRow;
2519  SetWidthOrHeight(false, aRange, eMode, nHeight);
2520  }
2521 
2522  if ( bAnyEdit )
2523  {
2524  UpdateEditView();
2525  if ( rDoc.HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::NeedHeight ) )
2526  {
2527  ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData().GetViewShell() );
2528  if (pHdl)
2529  pHdl->SetModified(); // so that the height is adjusted with Enter
2530  }
2531  }
2532 
2533  ShowAllCursors();
2534 }
2535 
2536 void ScViewFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
2537 {
2538  if (nTab == TABLEID_DOC)
2539  return;
2540 
2541  ScMarkData& rMark = GetViewData().GetMarkData();
2542  ScDocShell* pDocSh = GetViewData().GetDocShell();
2543  ScDocument& rDoc = pDocSh->GetDocument();
2544  ScDocFunc &rFunc = pDocSh->GetDocFunc();
2545  bool bUndo(rDoc.IsUndoEnabled());
2546 
2547  // modifying several tabs is handled here
2548 
2549  if (bUndo)
2550  {
2551  OUString aUndo = ScResId( STR_UNDO_PROTECT_TAB );
2552  pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewData().GetViewShell()->GetViewShellId() );
2553  }
2554 
2555  for (const auto& rTab : rMark)
2556  {
2557  rFunc.ProtectSheet(rTab, rProtect);
2558  }
2559 
2560  if (bUndo)
2561  pDocSh->GetUndoManager()->LeaveListAction();
2562 
2563  UpdateLayerLocks();
2564 }
2565 
2566 void ScViewFunc::ProtectDoc( const OUString& rPassword )
2567 {
2568  ScDocShell* pDocSh = GetViewData().GetDocShell();
2569  ScDocFunc &rFunc = pDocSh->GetDocFunc();
2570 
2571  rFunc.Protect( TABLEID_DOC, rPassword );
2572 
2573  UpdateLayerLocks();
2574 }
2575 
2576 bool ScViewFunc::Unprotect( SCTAB nTab, const OUString& rPassword )
2577 {
2578  ScMarkData& rMark = GetViewData().GetMarkData();
2579  ScDocShell* pDocSh = GetViewData().GetDocShell();
2580  ScDocument& rDoc = pDocSh->GetDocument();
2581  ScDocFunc &rFunc = pDocSh->GetDocFunc();
2582  bool bChanged = false;
2583  bool bUndo (rDoc.IsUndoEnabled());
2584 
2585  if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 )
2586  {
2587  bChanged = rFunc.Unprotect( nTab, rPassword, false );
2588  if (bChanged && nTab != TABLEID_DOC)
2589  SetTabProtectionSymbol(nTab, false);
2590  }
2591  else
2592  {
2593  // modifying several tabs is handled here
2594 
2595  if (bUndo)
2596  {
2597  OUString aUndo = ScResId( STR_UNDO_UNPROTECT_TAB );
2598  pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewData().GetViewShell()->GetViewShellId() );
2599  }
2600 
2601  for (const auto& rTab : rMark)
2602  {
2603  if ( rFunc.Unprotect( rTab, rPassword, false ) )
2604  {
2605  bChanged = true;
2606  SetTabProtectionSymbol( rTab, false);
2607  }
2608  }
2609 
2610  if (bUndo)
2611  pDocSh->GetUndoManager()->LeaveListAction();
2612  }
2613 
2614  if (bChanged)
2615  UpdateLayerLocks();
2616 
2617  return bChanged;
2618 }
2619 
2620 void ScViewFunc::SetNoteText( const ScAddress& rPos, const OUString& rNoteText )
2621 {
2622  GetViewData().GetDocShell()->GetDocFunc().SetNoteText( rPos, rNoteText, false );
2623 }
2624 
2625 void ScViewFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate )
2626 {
2627  GetViewData().GetDocShell()->GetDocFunc().ReplaceNote( rPos, rNoteText, pAuthor, pDate, false );
2628 }
2629 
2631 {
2632  // not editable because of matrix only? attribute OK nonetheless
2633  bool bOnlyNotBecauseOfMatrix;
2634  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
2635  {
2636  ErrorMessage(STR_PROTECTIONERR);
2637  return;
2638  }
2639 
2640  sal_uInt32 nNumberFormat = 0;
2641  ScViewData& rViewData = GetViewData();
2642  ScDocument& rDoc = rViewData.GetDocument();
2643  SvNumberFormatter* pNumberFormatter = rDoc.GetFormatTable();
2644  LanguageType eLanguage = ScGlobal::eLnge;
2645  ScPatternAttr aNewAttrs( rDoc.GetPool() );
2646 
2647  // always take language from cursor position, even if there is a selection
2648 
2649  sal_uInt32 nCurrentNumberFormat = rDoc.GetNumberFormat( rViewData.GetCurX(),
2650  rViewData.GetCurY(),
2651  rViewData.GetTabNo());
2652  const SvNumberformat* pEntry = pNumberFormatter->GetEntry( nCurrentNumberFormat );
2653  if (pEntry)
2654  eLanguage = pEntry->GetLanguage(); // else keep ScGlobal::eLnge
2655 
2656  nNumberFormat = pNumberFormatter->GetStandardFormat( nFormatType, eLanguage ) + nAdd;
2657 
2658  SfxItemSet& rSet = aNewAttrs.GetItemSet();
2659  rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
2660  // ATTR_LANGUAGE_FORMAT not
2661  ApplySelectionPattern( aNewAttrs );
2662 }
2663 
2664 void ScViewFunc::SetNumFmtByStr( const OUString& rCode )
2665 {
2666  // not editable because of matrix only? attribute OK nonetheless
2667  bool bOnlyNotBecauseOfMatrix;
2668  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
2669  {
2670  ErrorMessage(STR_PROTECTIONERR);
2671  return;
2672  }
2673 
2674  ScViewData& rViewData = GetViewData();
2675  ScDocument& rDoc = rViewData.GetDocument();
2676  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2677 
2678  // language always from cursor position
2679 
2680  sal_uInt32 nCurrentNumberFormat = rDoc.GetNumberFormat( rViewData.GetCurX(), rViewData.GetCurY(),
2681  rViewData.GetTabNo());
2682  const SvNumberformat* pEntry = pFormatter->GetEntry( nCurrentNumberFormat );
2683  LanguageType eLanguage = pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge;
2684 
2685  // determine index for String
2686 
2687  bool bOk = true;
2688  sal_uInt32 nNumberFormat = pFormatter->GetEntryKey( rCode, eLanguage );
2689  if ( nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
2690  {
2691  // enter new
2692 
2693  OUString aFormat = rCode; // will be changed
2694  sal_Int32 nErrPos = 0;
2695  SvNumFormatType nType = SvNumFormatType::ALL;
2696  bOk = pFormatter->PutEntry( aFormat, nErrPos, nType, nNumberFormat, eLanguage );
2697  }
2698 
2699  if ( bOk ) // valid format?
2700  {
2701  ScPatternAttr aNewAttrs( rDoc.GetPool() );
2702  SfxItemSet& rSet = aNewAttrs.GetItemSet();
2703  rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
2704  rSet.Put( SvxLanguageItem( eLanguage, ATTR_LANGUAGE_FORMAT ) );
2705  ApplySelectionPattern( aNewAttrs );
2706  }
2707 
2709 }
2710 
2711 void ScViewFunc::ChangeNumFmtDecimals( bool bIncrement )
2712 {
2713  // not editable because of matrix only? attribute OK nonetheless
2714  bool bOnlyNotBecauseOfMatrix;
2715  if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
2716  {
2717  ErrorMessage(STR_PROTECTIONERR);
2718  return;
2719  }
2720 
2721  ScDocument& rDoc = GetViewData().GetDocument();
2722  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2723 
2724  SCCOL nCol = GetViewData().GetCurX();
2725  SCROW nRow = GetViewData().GetCurY();
2726  SCTAB nTab = GetViewData().GetTabNo();
2727 
2728  sal_uInt32 nOldFormat = rDoc.GetNumberFormat( nCol, nRow, nTab );
2729  const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
2730  if (!pOldEntry)
2731  {
2732  OSL_FAIL("numberformat not found !!!");
2733  return;
2734  }
2735 
2736  // what have we got here?
2737 
2738  sal_uInt32 nNewFormat = nOldFormat;
2739  bool bError = false;
2740 
2741  LanguageType eLanguage = pOldEntry->GetLanguage();
2742  bool bThousand, bNegRed;
2743  sal_uInt16 nPrecision, nLeading;
2744  pOldEntry->GetFormatSpecialInfo( bThousand, bNegRed, nPrecision, nLeading );
2745 
2746  SvNumFormatType nOldType = pOldEntry->GetType();
2747  if ( SvNumFormatType::ALL == ( nOldType & (
2748  SvNumFormatType::NUMBER | SvNumFormatType::CURRENCY | SvNumFormatType::PERCENT | SvNumFormatType::SCIENTIFIC | SvNumFormatType::TIME ) ) )
2749  {
2750  // date, fraction, logical, text can not be changed
2751  bError = true;
2752  }
2753 
2755  bool bWasStandard = ( nOldFormat == pFormatter->GetStandardIndex( eLanguage ) );
2756  OUString sExponentialStandardFormat = "";
2757  if (bWasStandard)
2758  {
2759  // with "Standard" the decimal places depend on cell content
2760  // 0 if empty or text -> no decimal places
2761  double nVal = rDoc.GetValue( ScAddress( nCol, nRow, nTab ) );
2762 
2763  // the ways of the Numberformatters are unfathomable, so try:
2764  OUString aOut;
2765  const Color* pCol;
2766  const_cast<SvNumberformat*>(pOldEntry)->GetOutputString( nVal, aOut, &pCol );
2767 
2768  nPrecision = 0;
2769  // 'E' for exponential is fixed in Numberformatter
2770  sal_Int32 nIndexE = aOut.indexOf('E');
2771  if ( nIndexE >= 0 )
2772  {
2773  sExponentialStandardFormat = aOut.copy( nIndexE ).replace( '-', '+' );
2774  for ( sal_Int32 i=1 ; i<sExponentialStandardFormat.getLength() ; i++ )
2775  {
2776  if ( sExponentialStandardFormat[i] >= '1' && sExponentialStandardFormat[i] <= '9' )
2777  sExponentialStandardFormat = sExponentialStandardFormat.replaceAt( i, 1, u"0" );
2778  }
2779  aOut = aOut.copy( 0, nIndexE ); // remove exponential part
2780  }
2781  OUString aDecSep( pFormatter->GetFormatDecimalSep( nOldFormat ) );
2782  sal_Int32 nPos = aOut.indexOf( aDecSep );
2783  if ( nPos >= 0 )
2784  nPrecision = aOut.getLength() - nPos - aDecSep.getLength();
2785  // else keep 0
2786  }
2787  else
2788  {
2789  if ( (nOldType & SvNumFormatType::SCIENTIFIC) && !bThousand &&
2790  (pOldEntry->GetFormatIntegerDigits()%3 == 0) && pOldEntry->GetFormatIntegerDigits() > 0 )
2791  bThousand = true;
2792  }
2793 
2794  if (!bError)
2795  {
2796  if (bIncrement)
2797  {
2798  if (nPrecision<20)
2799  ++nPrecision; // increment
2800  else
2801  bError = true; // 20 is maximum
2802  }
2803  else
2804  {
2805  if (nPrecision)
2806  --nPrecision; // decrement
2807  else
2808  bError = true; // 0 is minimum
2809  }
2810  }
2811 
2812  if (!bError)
2813  {
2814  OUString aNewPicture = pFormatter->GenerateFormat(nOldFormat, eLanguage,
2815  bThousand, bNegRed,
2816  nPrecision, nLeading)
2817  + sExponentialStandardFormat;
2818 
2819  nNewFormat = pFormatter->GetEntryKey( aNewPicture, eLanguage );
2820  if ( nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
2821  {
2822  sal_Int32 nErrPos = 0;
2823  SvNumFormatType nNewType = SvNumFormatType::ALL;
2824  bool bOk = pFormatter->PutEntry( aNewPicture, nErrPos,
2825  nNewType, nNewFormat, eLanguage );
2826  OSL_ENSURE( bOk, "incorrect numberformat generated" );
2827  if (!bOk)
2828  bError = true;
2829  }
2830  }
2831 
2832  if (!bError)
2833  {
2834  ScPatternAttr aNewAttrs( rDoc.GetPool() );
2835  SfxItemSet& rSet = aNewAttrs.GetItemSet();
2836  rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2837  // ATTR_LANGUAGE_FORMAT not
2838  ApplySelectionPattern( aNewAttrs );
2839  }
2840 }
2841 
2842 void ScViewFunc::ChangeIndent( bool bIncrement )
2843 {
2844  ScViewData& rViewData = GetViewData();
2845  ScDocShell* pDocSh = rViewData.GetDocShell();
2846  ScMarkData& rMark = rViewData.GetMarkData();
2847 
2848  ScMarkData aWorkMark = rMark;
2849  ScViewUtil::UnmarkFiltered( aWorkMark, pDocSh->GetDocument() );
2850  aWorkMark.MarkToMulti();
2851  if (!aWorkMark.IsMultiMarked())
2852  {
2853  SCCOL nCol = rViewData.GetCurX();
2854  SCROW nRow = rViewData.GetCurY();
2855  SCTAB nTab = rViewData.GetTabNo();
2856  aWorkMark.SetMultiMarkArea( ScRange(nCol,nRow,nTab) );
2857  }
2858 
2859  bool bSuccess = pDocSh->GetDocFunc().ChangeIndent( aWorkMark, bIncrement, false );
2860  if (bSuccess)
2861  {
2862  pDocSh->UpdateOle(rViewData);
2863  StartFormatArea();
2864 
2865  // stuff for sidebar panels
2866  SfxBindings& rBindings = GetViewData().GetBindings();
2867  rBindings.Invalidate( SID_H_ALIGNCELL );
2868  rBindings.Invalidate( SID_ATTR_ALIGN_INDENT );
2869  }
2870 }
2871 
2872 bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol,
2873  const OUString& rType )
2874 {
2875  // Type = P,R,C,F (and combinations)
2877 
2878  bool bOk = false;
2879  ScDocShell* pDocSh = GetViewData().GetDocShell();
2880  ScDocument& rDoc = pDocSh->GetDocument();
2881  SCTAB nTab = GetViewData().GetTabNo();
2882  ScRangeName* pList = rDoc.GetRangeName();
2883 
2885  auto pNewEntry = std::make_unique<ScRangeData>(
2886  rDoc, rName, rSymbol, ScAddress( GetViewData().GetCurX(),
2887  GetViewData().GetCurY(), nTab), nType );
2888  OUString aUpType = rType.toAsciiUpperCase();
2889  if ( aUpType.indexOf( 'P' ) != -1 )
2891  if ( aUpType.indexOf( 'R' ) != -1 )
2893  if ( aUpType.indexOf( 'C' ) != -1 )
2895  if ( aUpType.indexOf( 'F' ) != -1 )
2896  nType |= ScRangeData::Type::Criteria;
2897  pNewEntry->AddType(nType);
2898 
2899  if ( pNewEntry->GetErrCode() == FormulaError::NONE ) // text valid?
2900  {
2901  ScDocShellModificator aModificator( *pDocSh );
2902 
2903  rDoc.PreprocessRangeNameUpdate();
2904 
2905  // input available yet? Then remove beforehand (=change)
2906  ScRangeData* pData = pList->findByUpperName(ScGlobal::getCharClass().uppercase(rName));
2907  if (pData)
2908  { // take old Index
2909  pNewEntry->SetIndex(pData->GetIndex());
2910  pList->erase(*pData);
2911  }
2912 
2913  // don't delete, insert took ownership, even on failure!
2914  if ( pList->insert( pNewEntry.release() ) )
2915  bOk = true;
2916 
2917  rDoc.CompileHybridFormula();
2918 
2919  aModificator.SetDocumentModified();
2920  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
2921  }
2922 
2923  return bOk;
2924 }
2925 
2927 {
2928  bool bDone = false;
2929  ScRange aRange;
2930  if ( GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE )
2931  bDone = GetViewData().GetDocShell()->GetDocFunc().CreateNames( aRange, nFlags, false );
2932 
2933  if (!bDone)
2934  ErrorMessage(STR_CREATENAME_MARKERR);
2935 }
2936 
2938 {
2940 
2941  SCCOL nStartCol, nEndCol;
2942  SCROW nStartRow, nEndRow;
2943  SCTAB nDummy;
2944  if (GetViewData().GetSimpleArea(nStartCol,nStartRow,nDummy,nEndCol,nEndRow,nDummy) == SC_MARK_SIMPLE)
2945  {
2946  ScDocument& rDoc = GetViewData().GetDocument();
2947  SCTAB nTab = GetViewData().GetTabNo();
2948  bool bOk;
2949  SCCOL i;
2950  SCROW j;
2951 
2952  bOk = true;
2953  SCCOL nFirstCol = nStartCol;
2954  SCCOL nLastCol = nEndCol;
2955  if (nStartCol+1 < nEndCol) { ++nFirstCol; --nLastCol; }
2956  for (i=nFirstCol; i<=nLastCol && bOk; i++)
2957  if (!rDoc.HasStringData( i,nStartRow,nTab ))
2958  bOk = false;
2959  if (bOk)
2960  nFlags |= CreateNameFlags::Top;
2961  else // Bottom only if not Top
2962  {
2963  bOk = true;
2964  for (i=nFirstCol; i<=nLastCol && bOk; i++)
2965  if (!rDoc.HasStringData( i,nEndRow,nTab ))
2966  bOk = false;
2967  if (bOk)
2968  nFlags |= CreateNameFlags::Bottom;
2969  }
2970 
2971  bOk = true;
2972  SCROW nFirstRow = nStartRow;
2973  SCROW nLastRow = nEndRow;
2974  if (nStartRow+1 < nEndRow) { ++nFirstRow; --nLastRow; }
2975  for (j=nFirstRow; j<=nLastRow && bOk; j++)
2976  if (!rDoc.HasStringData( nStartCol,j,nTab ))
2977  bOk = false;
2978  if (bOk)
2979  nFlags |= CreateNameFlags::Left;
2980  else // Right only if not Left
2981  {
2982  bOk = true;
2983  for (j=nFirstRow; j<=nLastRow && bOk; j++)
2984  if (!rDoc.HasStringData( nEndCol,j,nTab ))
2985  bOk = false;
2986  if (bOk)
2987  nFlags |= CreateNameFlags::Right;
2988  }
2989  }
2990 
2991  if (nStartCol == nEndCol)
2993  if (nStartRow == nEndRow)
2995 
2996  return nFlags;
2997 }
2998 
3000 {
3001  ScAddress aPos( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
3002  ScDocShell* pDocSh = GetViewData().GetDocShell();
3003  if ( pDocSh->GetDocFunc().InsertNameList( aPos, false ) )
3004  pDocSh->UpdateOle(GetViewData());
3005 }
3006 
3008 {
3009  ScDocShell* pDocShell = GetViewData().GetDocShell();
3010  ScRange aMarkRange;
3011  if (rSel.IsMultiMarked() )
3012  aMarkRange = rSel.GetMultiMarkArea();
3013  else
3014  aMarkRange = rSel.GetMarkArea();
3015 
3016  bool bSetLines = false;
3017  bool bSetAlign = false;
3018  if ( pAttr )
3019  {
3020  const SfxItemSet& rNewSet = pAttr->GetItemSet();
3021  bSetLines = rNewSet.GetItemState( ATTR_BORDER ) == SfxItemState::SET ||
3022  rNewSet.GetItemState( ATTR_SHADOW ) == SfxItemState::SET;
3023  bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY ) == SfxItemState::SET;
3024  }
3025 
3026  sal_uInt16 nExtFlags = 0;
3027  if ( bSetLines )
3028  nExtFlags |= SC_PF_LINES;
3029  if ( bSetAlign )
3030  nExtFlags |= SC_PF_WHOLEROWS;
3031 
3032  SCCOL nStartCol = aMarkRange.aStart.Col();
3033  SCROW nStartRow = aMarkRange.aStart.Row();
3034  SCTAB nStartTab = aMarkRange.aStart.Tab();
3035  SCCOL nEndCol = aMarkRange.aEnd.Col();
3036  SCROW nEndRow = aMarkRange.aEnd.Row();
3037  SCTAB nEndTab = aMarkRange.aEnd.Tab();
3038  pDocShell->PostPaint( nStartCol, nStartRow, nStartTab,
3039  nEndCol, nEndRow, nEndTab,
3040  PaintPartFlags::Grid, nExtFlags | SC_PF_TESTMERGE );
3041  ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
3042  pTabViewShell->AdjustBlockHeight(false, const_cast<ScMarkData*>(&rSel));
3043 }
3044 
3045 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_Int32 STD_COL_WIDTH
Definition: global.hxx:86
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3135
#define SC_PF_TESTMERGE
Definition: docsh.hxx:77
void BeginDrawUndo()
Definition: documen9.cxx:60
bool IsBlockEditable(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool *pOnlyNotBecauseOfMatrix=nullptr, bool bNoMatrixAtAll=false) const
Definition: document.cxx:5422
CreateNameFlags GetCreateNameFlags()
Definition: viewfunc.cxx:2937
List of spreadsheet functions.
Definition: funcdesc.hxx:241
SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow)
Definition: document.cxx:4348
constexpr sal_Int32 STD_EXTRA_WIDTH
Definition: global.hxx:87
void DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTAB nEndTab, SCCOL nStartCol, SCSIZE nSize, ScDocument *pRefUndoDoc=nullptr, bool *pUndoOutline=nullptr, const ScMarkData *pTabMark=nullptr)
Definition: document.cxx:1590
constexpr double nPPTY
void DeleteContents(InsertDeleteFlags nFlags)
Definition: viewfunc.cxx:1974
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
Definition: document.cxx:6323
SC_DLLPUBLIC void ApplySelectionStyle(const ScStyleSheet &rStyle, const ScMarkData &rMark)
Definition: document.cxx:4923
void ApplyStyle(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScStyleSheet &rStyle)
Definition: document.cxx:4893
void DeleteRow(SCCOL nStartCol, SCTAB nStartTab, SCCOL nEndCol, SCTAB nEndTab, SCROW nStartRow, SCSIZE nSize, ScDocument *pRefUndoDoc=nullptr, bool *pUndoOutline=nullptr, const ScMarkData *pTabMark=nullptr)
Definition: document.cxx:1365
OUString GetColRowString() const
Create a human-readable string representation of the cell address.
Definition: address.cxx:2467
void MarkToSimple()
Definition: markdata.cxx:222
sal_Int32 nIndex
double GetPPTY() const
Definition: sizedev.hxx:42
SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow)
Definition: document.cxx:4360
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScAddress aStart
Definition: address.hxx:497
bool AdjustBlockHeight(bool bPaint=true, ScMarkData *pMarkData=nullptr)
Definition: viewfun2.cxx:114
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
bool Unprotect(SCTAB nTab, const OUString &rPassword, bool bApi)
Definition: docfunc.cxx:4033
bool IsPrinter() const
Definition: sizedev.hxx:43
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
void ErrorMessage(TranslateId pGlobStrId)
Definition: tabview2.cxx:1446
bool CreateNames(const ScRange &rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab=-1)
Definition: docfunc.cxx:5273
void InitOwnBlockMode(const ScRange &rMarkRange)
Definition: tabview2.cxx:332
SC_DLLPUBLIC void RefreshZoom()
Definition: tabview5.cxx:435
SC_DLLPUBLIC bool DeleteContents(const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
Definition: docfunc.cxx:583
void CreateNames(CreateNameFlags nFlags)
Definition: viewfunc.cxx:2926
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
ScAddress aFormatSource
Definition: viewfunc.hxx:73
SCROW Row() const
Definition: address.hxx:274
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
Definition: docsh5.cxx:404
ScCellValue maCell
Definition: undocell.hxx:79
void MarkToMulti()
Definition: markdata.cxx:209
bool UpdateOutlineCol(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow)
Adapt Outline.
Definition: documen3.cxx:1418
constexpr sal_uInt16 ATTR_PATTERN_START(100)
void SetModified()
Definition: inputhdl.hxx:245
void GetResultDimensions(SCSIZE &rCols, SCSIZE &rRows)
const Fraction & GetZoomX() const
Definition: viewdata.hxx:459
void SetTabProtectionSymbol(SCTAB nTab, const bool bProtect)
Definition: tabview3.cxx:527
bool SetStringCell(const ScAddress &rPos, const OUString &rStr, bool bInteraction)
Definition: docfunc.cxx:936
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
void DeleteCells(DelCellCmd eCmd)
Definition: viewfunc.cxx:1690
void ApplyAttr(const SfxPoolItem &rAttrItem, bool bAdjustBlockHeight=true)
Definition: viewfunc.cxx:1028
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1689
sheet protection state container
const SfxItemSet & GetAttribs() const
Definition: editutil.hxx:104
void PostPaintCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: docsh3.cxx:188
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:195
SCCOL GetCurXForTab(SCTAB nTabIndex) const
Definition: viewdata.cxx:1430
std::unique_ptr< sal_Int32[]> pData
void SetMultiMarkArea(const ScRange &rRange, bool bMark=true, bool bSetupMulti=false)
Definition: markdata.cxx:107
bool IsInputMode() const
Definition: inputhdl.hxx:185
int getPart() const override
See SfxViewShell::getPart().
Definition: tabvwshc.cxx:447
sal_uInt16 GetIndex() const
Definition: rangenam.hxx:116
sal_uInt16 GetLRUFuncListCount() const
Definition: appoptio.hxx:47
ScTokenArray * GetCode()
void InsertNameList()
Definition: viewfunc.cxx:2999
void SetLRUFuncList(const sal_uInt16 *pList, const sal_uInt16 nCount)
Definition: appoptio.cxx:107
sal_uIntPtr sal_uLong
long Long
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
void SetPasteMode(ScPasteFlags nFlags)
Definition: viewdata.hxx:448
SCROW GetCurY() const
Definition: viewdata.hxx:402
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:168
ScDocFunc & GetDocFunc() const
Definition: viewdata.cxx:3118
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
double GetOutputFactor() const
Definition: docsh.hxx:358
ocOpen
sal_Int64 n
ViewShellDocId GetDocId() const override
std::vector< sc::ColRowSpan > GetMarkedRowSpans() const
Definition: markdata.cxx:464
SvNumFormatType GetType(sal_uInt32 nFIndex) const
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:372
ScRange aFormatArea
Definition: viewfunc.hxx:74
const ContentProperties & rData
double GetPPTX() const
Definition: viewdata.hxx:468
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
constexpr TypedWhichId< SvxBoxInfoItem > ATTR_BORDER_INNER(151)
void Unmark()
Definition: tabview3.cxx:1725
ScAddress aEnd
Definition: address.hxx:498
void EnterValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rValue)
Definition: viewfunc.cxx:624
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
OpCode GetOpCode() const
void OnLOKInsertDeleteRow(SCROW nStartRow, tools::Long nOffset)
Definition: viewfunc.cxx:1549
sal_Int16 GetRightMargin() const
void ProtectSheet(SCTAB nTab, const ScTableProtection &rProtect)
Definition: docfunc.cxx:3948
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
Definition: document.cxx:3508
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1007
void EnterDataAtCursor(const OUString &rString)
Definition: viewfunc.cxx:780
void Invalidate(sal_uInt16 nId)
void Remove(const SfxPoolItem &)
CreateNameFlags
Definition: scui_def.hxx:50
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:363
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5264
bool InsertCells(const ScRange &rRange, const ScMarkData *pTabMark, InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste=false)
Definition: docfunc.cxx:1736
static void notifyAllViewsSheetGeomInvalidation(const SfxViewShell *pForViewShell, bool bColumns, bool bRows, bool bSizes, bool bHidden, bool bFiltered, bool bGroups, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY for all views whose current tab is equal to nCurrentTa...
Definition: tabvwshc.cxx:568
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4211
void ResetAutoSpell()
Definition: tabview.cxx:2269
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
void EnterListAction(TranslateId pNameResId)
Definition: docfunc.cxx:5759
SfxApplication * SfxGetpApp()
Internal use only (d&d undo): do not delete caption objects of cell notes.
constexpr TypedWhichId< ScIndentItem > ATTR_INDENT(131)
DelCellCmd
Definition: global.hxx:278
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6156
static void lcl_PostRepaintCondFormat(const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh)
Definition: viewfunc.cxx:82
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2932
RET_NO
bool IsInputMode()
Definition: scmod.cxx:1396
constexpr tools::Long Width() const
static UITestLogger & getInstance()
void UpdateCopySourceOverlay()
Definition: tabview2.cxx:1014
SvtScriptType
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:35
void logEvent(const EventDescription &rDescription)
const ScStyleSheet * GetStyle(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4961
const ScRangeList & GetRange() const
Definition: conditio.hxx:558
const SfxStyleSheet * GetStyleSheetFromMarked()
Definition: viewfunc.cxx:1324
bool InsertName(const OUString &rName, const OUString &rSymbol, const OUString &rType)
Definition: viewfunc.cxx:2872
bool TestFormatArea(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bAttrChanged)
Definition: viewfunc.cxx:140
RET_YES
const OUString & GetName() const
bool SelectionEditable(bool *pOnlyNotBecauseOfMatrix=nullptr)
Definition: viewfunc.cxx:260
PropertiesInfo aProperties
void RemoveStyleSheetInUse(const SfxStyleSheetBase *pStyleSheet)
Definition: viewfunc.cxx:1439
const EditTextObject * mpEditText
Definition: cellvalue.hxx:109
void UpdatePaintExt(sal_uInt16 &rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab)
Definition: docsh3.cxx:228
bool PutEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge=LANGUAGE_DONTKNOW, bool bReplaceBooleanEquivalent=true)
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:891
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
constexpr TypedWhichId< SvxShadowItem > ATTR_SHADOW(152)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:315
SvtScriptType GetRangeScriptType(sc::ColumnBlockPosition &rBlockPos, const ScAddress &rPos, SCROW nLength)
Definition: documen6.cxx:183
bool Unprotect(SCTAB nTab, const OUString &rPassword)
Definition: viewfunc.cxx:2576
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4133
const ScPatternAttr * GetSelectionPattern(const ScMarkData &rMark)
Definition: document.cxx:5161
SCTAB GetSelectCount() const
Definition: markdata.cxx:180
bool IsMultiMarked() const
Definition: markdata.hxx:81
bool ChangeIndent(const ScMarkData &rMark, bool bIncrement, bool bApi)
Definition: docfunc.cxx:4135
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
OpCode
sal_uInt32 GetStandardIndex(LanguageType eLnge=LANGUAGE_DONTKNOW)
void MarkDataChanged()
Definition: tabview3.cxx:1748
int nCount
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
sal_uInt16 * GetLRUFuncList() const
Definition: appoptio.hxx:48
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
Definition: document.cxx:2063
sal_uInt16 GetOptimalColWidth(SCCOL nCol, SCTAB nTab, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bFormula, const ScMarkData *pMarkData=nullptr, const ScColWidthParam *pParam=nullptr)
Definition: document.cxx:4290
void ReplaceNote(const ScAddress &rPos, const OUString &rNoteText, const OUString *pAuthor, const OUString *pDate, bool bApi)
Definition: docfunc.cxx:1342
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1137
bool IsDocShared() const
void UpdateEditView()
Definition: tabview3.cxx:2150
Mode eMode
SCTAB Tab() const
Definition: address.hxx:283
void SetRow(SCROW nRowP)
Definition: address.hxx:287
bool DeleteCells(const ScRange &rRange, const ScMarkData *pTabMark, DelCellCmd eCmd, bool bApi)
Definition: docfunc.cxx:2271
void DeleteUnchanged(const ScPatternAttr *pOldAttrs)
Definition: patattr.cxx:971
void DoneBlockMode(bool bContinue=false)
Definition: tabview2.cxx:409
ScViewFunc(vcl::Window *pParent, ScDocShell &rDocSh, ScTabViewShell *pViewShell)
Definition: viewfunc.cxx:92
void EndListAction()
Definition: docfunc.cxx:5768
bool SetEditCell(const ScAddress &rPos, const EditTextObject &rStr, bool bInteraction)
Definition: docfunc.cxx:973
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4799
bool SetNormalString(bool &o_rbNumFmtSet, const ScAddress &rPos, const OUString &rText, bool bApi)
Definition: docfunc.cxx:799
void SetCol(SCCOL nColP)
Definition: address.hxx:291
SvtScriptType GetSelectionScriptType()
Definition: viewfunc.cxx:833
ScViewData & GetViewData()
Definition: tabview.hxx:333
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4764
bool bFormatValid
Definition: viewfunc.hxx:75
bool Protect(SCTAB nTab, const OUString &rPassword)
Definition: docfunc.cxx:4009
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3663
void PaintArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScUpdateMode eMode=ScUpdateMode::All)
Definition: tabview3.cxx:2308
constexpr sal_Int32 MAX_COL_WIDTH
Definition: global.hxx:91
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
void SetNoteText(const ScAddress &rPos, const OUString &rNoteText)
Definition: viewfunc.cxx:2620
constexpr double nPPTX
bool ApplyAttributes(const ScMarkData &rMark, const ScPatternAttr &rPattern, bool bApi)
Definition: docfunc.cxx:1426
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
Definition: document.cxx:3444
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
Definition: global.hxx:581
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:761
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:92
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:704
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:890
const ScStyleSheet * GetSelectionStyle(const ScMarkData &rMark) const
Definition: document.cxx:4969
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:459
SvNumFormatType GetType() const
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4495
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
void OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth)
Definition: viewfunc.cxx:1606
#define SV_MAX_COUNT_STANDARD_FORMATS
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:616
bool IsMarked() const
Definition: markdata.hxx:80
#define nPixel
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
bool ApplyStyle(const ScMarkData &rMark, const OUString &rStyleName, bool bApi)
Definition: docfunc.cxx:1495
void GetSelectionCover(ScRange &rRange)
Definition: markdata.cxx:703
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:157
void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, const OUString &rType=OUString("cell-change"), const css::uno::Sequence< css::beans::PropertyValue > &rProperties=css::uno::Sequence< css::beans::PropertyValue >())
Definition: docsh.hxx:483
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:403
SfxBindings & GetBindings()
Definition: viewdata.cxx:3123
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:60
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2715
sal_Int16 SCCOL
Definition: types.hxx:21
InsertDeleteFlags
Definition: global.hxx:147
#define SC_MOD()
Definition: scmod.hxx:249
void UpdateStyleSheetInUse(const SfxStyleSheetBase *pStyleSheet)
Definition: viewfunc.cxx:1465
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1024
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:896
void RemoveEditTextCharAttribs(const ScAddress &rPos, const ScPatternAttr &rAttr)
Definition: document.cxx:3655
bool IsStaticDefaultItem(const SfxPoolItem *pItem)
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:128
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:774
static const SfxItemPropertyMap & GetCellPropertyMap()
Definition: cellsuno.cxx:5745
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:470
SC_DLLPUBLIC void ApplyPattern(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4827
std::unique_ptr< EditTextObject > CreateTextObject()
void SelectOneTable(SCTAB nTab)
Definition: markdata.cxx:174
float u
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1181
void SetNumFmtByStr(const OUString &rCode)
Definition: viewfunc.cxx:2664
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
void ChangeIndent(bool bIncrement)
Definition: viewfunc.cxx:2842
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
#define LANGUAGE_DONTKNOW
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
SvNumFormatType
SC_DLLPUBLIC void SetRowHeightRange(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4151
#define LRU_MAX
Definition: funcdesc.hxx:34
void ReplaceNote(const ScAddress &rPos, const OUString &rNoteText, const OUString *pAuthor, const OUString *pDate)
Definition: viewfunc.cxx:2625
void ApplySelectionPattern(const ScPatternAttr &rAttr, bool bCursorOnly=false)
Definition: viewfunc.cxx:1138
bool IsFunction() const
SC_DLLPUBLIC const EditTextObject * GetEditText(const ScAddress &rPos) const
Definition: document.cxx:3646
sal_uInt32 GetEntryKey(std::u16string_view sStr, LanguageType eLnge=LANGUAGE_DONTKNOW)
bool IsEditable() const
Definition: editable.hxx:84
void DeleteObjectsInArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData &rMark, bool bAnchored=false)
Definition: documen9.cxx:252
#define SV_COUNTRY_LANGUAGE_OFFSET
void erase(const ScRangeData &r)
Definition: rangenam.cxx:846
void SetNumberFormat(SvNumFormatType nFormatType, sal_uLong nAdd=0)
Definition: viewfunc.cxx:2630
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument &rDoc)
Definition: viewutil.cxx:223
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:545
const SCTAB MAXTAB
Definition: address.hxx:70
void setForceAutoSize(bool b)
void StartFormatArea()
Definition: viewfunc.cxx:118
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static void notifyAllViewsHeaderInvalidation(const SfxViewShell *pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex...
Definition: tabvwshc.cxx:510
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5662
SfxItemPool * GetPool() const
Size GetTextSize()
Definition: inputhdl.cxx:4428
TranslateId GetMessageId() const
Definition: editable.cxx:152
constexpr sal_Int32 MAX_ROW_HEIGHT
Definition: global.hxx:92
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
Definition: funcdesc.cxx:1009
std::vector< Value > ValuesType
Definition: undocell.hxx:84
void UpdateScrollBars(HeaderType eHeaderType=BOTH_HEADERS)
Definition: tabview4.cxx:390
ScSizeMode
Definition: global.hxx:348
const SCTAB TABLEID_DOC
Definition: address.hxx:91
static bool SC_DLLPUBLIC isMultiline(std::u16string_view rStr)
Definition: stringutil.cxx:422
FormulaError
SCCOL Col() const
Definition: address.hxx:279
static ScFunctionList * GetStarCalcFunctionList()
Definition: global.cxx:620
OUString GetFormatDecimalSep(sal_uInt32 nFormat) const
bool IsReadOnly() const
SC_DLLPUBLIC const ScPatternAttr * GetSelectionPattern()
Definition: viewfunc.cxx:859
SC_DLLPUBLIC bool HasStringData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3789
size_t LeaveListAction()
static bool lcl_FunctionKnown(sal_uInt16 nOpCode)
Definition: viewfunc.cxx:278
ScDBFunc * GetView() const
Definition: viewdata.cxx:863
bool IsValid(SvxBoxInfoItemValidFlags nValid) const
size_t mnStart
Definition: cellvalues.cxx:23
ScModelObj * getMustPropagateChangesModel(const ScDocShell &rDocShell)
Definition: docsh.hxx:475
void SetCurYForTab(SCCOL nNewCurY, SCTAB nTabIndex)
Definition: viewdata.cxx:1454
bool DeleteCell(const ScAddress &rPos, const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
Definition: docfunc.cxx:674
void EnterMatrix(const OUString &rString,::formula::FormulaGrammar::Grammar eGram)
Definition: viewfunc.cxx:789
CellType meType
Definition: cellvalue.hxx:105
bool InsertNameList(const ScAddress &rStartPos, bool bApi)
Definition: docfunc.cxx:5362
OUString GenerateFormat(sal_uInt32 nIndex, LanguageType eLnge=LANGUAGE_DONTKNOW, bool bThousand=false, bool IsRed=false, sal_uInt16 nPrecision=0, sal_uInt16 nLeadingCnt=1)
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi)
Definition: document.cxx:4316
CRFlags
Definition: global.hxx:124
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:17
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
Definition: global.cxx:860
#define SC_PF_LINES
Definition: docsh.hxx:76
void ApplyPatternLines(const ScPatternAttr &rAttr, const SvxBoxItem &rNewOuter, const SvxBoxInfoItem *pNewInner)
Definition: viewfunc.cxx:1056
void SetIndex(sal_uInt16 nInd)
Definition: rangenam.hxx:115
void StyleSheetChanged(const SfxStyleSheetBase *pStyleSheet, bool bRemoved, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY)
Definition: document.cxx:5018
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
Definition: docsh6.cxx:152
bool SetFormulaCell(const ScAddress &rPos, ScFormulaCell *pCell, bool bInteraction)
Below two methods take ownership of the formula cell instance(s).
Definition: docfunc.cxx:1023
double GetPPTY() const
Definition: viewdata.hxx:469
void ResetAutoSpellForContentChange()
Definition: tabview.cxx:2280
void DoAutoAttributes(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bAttrChanged)
Definition: viewfunc.cxx:205
void HideAllCursors()
Definition: tabview3.cxx:220
void SetNoteText(const ScAddress &rPos, const OUString &rNoteText, bool bApi)
Definition: docfunc.cxx:1316
sal_uInt16 GetFormatIntegerDigits(sal_uInt16 nIx=0) const
void ProtectSheet(SCTAB nTab, const ScTableProtection &rProtect)
Definition: viewfunc.cxx:2536
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
SCROW GetCurYForTab(SCTAB nTabIndex) const
Definition: viewdata.cxx:1438
void assign(const ScDocument &rDoc, const ScAddress &rPos)
Take cell value from specified position in specified document.
Definition: cellvalue.cxx:330
void ChangeNumFmtDecimals(bool bIncrement)
Definition: viewfunc.cxx:2711
void MoveCursorRel(SCCOL nMovX, SCROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel=false)
Definition: tabview3.cxx:1269
OUString aName
SCTAB GetFirstSelected() const
Definition: markdata.cxx:185
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
void SetCurXForTab(SCCOL nNewCurX, SCTAB nTabIndex)
Definition: viewdata.cxx:1446
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5080
InsCellCmd
Definition: global.hxx:287
SC_DLLPUBLIC void ApplySelectionPattern(const ScPatternAttr &rAttr, const ScMarkData &rMark, ScEditDataArray *pDataArray=nullptr, bool *pIsChanged=nullptr)
Definition: document.cxx:5970
virtual std::unique_ptr< EditTextObject > Clone() const =0
SC_DLLPUBLIC bool EnterMatrix(const ScRange &rRange, const ScMarkData *pTabMark, const ScTokenArray *pTokenArray, const OUString &rString, bool bApi, bool bEnglish, const OUString &rFormulaNmsp, const formula::FormulaGrammar::Grammar)
Definition: docfunc.cxx:4316
sal_Int16 GetLeftMargin() const
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
SC_DLLPUBLIC SvtScriptType GetScriptType(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScRefCellValue *pCell=nullptr)
Definition: documen6.cxx:132
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
Definition: documen3.cxx:739
Reference< XExecutableDialog > m_xDialog
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
void SetStyleSheetToMarked(const SfxStyleSheet *pStyleSheet)
Definition: viewfunc.cxx:1344
const o3tl::sorted_vector< const SfxItemPropertyMapEntry *, SfxItemPropertyMapCompare > & getPropertyEntries() const
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:554
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
tools::Long GetNeededSize(SCCOL nCol, SCROW nRow, SCTAB nTab, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bWidth, bool bTotalSize=false, bool bInPrintTwips=false)
Definition: document.cxx:4303
void OnLOKInsertDeleteColumn(SCCOL nStartCol, tools::Long nOffset)
Definition: viewfunc.cxx:1492
bool UpdateOutlineRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow)
Definition: documen3.cxx:1427
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
Definition: document.cxx:4164
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
constexpr sal_uInt16 ATTR_PATTERN_END(155)
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:221
void SetWidthOrHeight(bool bWidth, const std::vector< sc::ColRowSpan > &rRanges, ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord=true, const ScMarkData *pMarkData=nullptr)
Definition: viewfunc.cxx:2064
sal_uInt32 GetCount() const
Definition: funcdesc.hxx:247
ScPositionHelper & GetLOKWidthHelper()
Definition: viewdata.hxx:410
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:465
void NotifyIfChangesListeners(const ScDocShell &rDocShell, const ScRange &rRange, const OUString &rType=OUString("cell-change"))
Definition: docsh.hxx:491
void SetMarking(bool bFlag)
Definition: markdata.hxx:102
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4479
void UpdateSelectionArea(const ScMarkData &rSel, ScPatternAttr *pAttr=nullptr)
Definition: viewfunc.cxx:3007
static bool lcl_AddFunction(ScAppOptions &rAppOpt, sal_uInt16 nOpCode)
Definition: viewfunc.cxx:291
void SetDocumentModified()
Definition: docsh.cxx:3284
#define SC_PF_WHOLEROWS
Definition: docsh.hxx:78
void ApplyUserItemSet(const SfxItemSet &rItemSet)
Definition: viewfunc.cxx:1305
bool IsUndoEnabled() const
Definition: document.hxx:1590
void SetMarkedWidthOrHeight(bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips)
Definition: viewfunc.cxx:2370
ScDirection
Definition: global.hxx:340
void GetSelectionFrame(const ScMarkData &rMark, SvxBoxItem &rLineOuter, SvxBoxInfoItem &rLineInner)
Definition: document.cxx:5167
void ApplyAttributes(const SfxItemSet *pDialogSet, const SfxItemSet *pOldSet, bool bAdjustBlockHeight=true)
Definition: viewfunc.cxx:916
bool NeedsCellAttr() const
Definition: editutil.hxx:103
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1352
SC_DLLPUBLIC ScConditionalFormat * GetCondFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen4.cxx:851
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:222
bool NeedsObject() const
Definition: editutil.hxx:102
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, bool bApi)
Definition: viewfun2.cxx:192
ScPositionHelper & GetLOKHeightHelper()
Definition: viewdata.hxx:411
SC_DLLPUBLIC void SetRowFlags(SCROW nRow, SCTAB nTab, CRFlags nNewFlags)
Definition: document.cxx:4366
ScEditDataArray * GetDataArray()
Definition: undoblk3.cxx:381
void ProtectDoc(const OUString &rPassword)
Definition: viewfunc.cxx:2566
std::map< OUString, OUString > aParameters
void ApplySelectionFrame(const ScMarkData &rMark, const SvxBoxItem &rLineOuter, const SvxBoxInfoItem *pLineInner)
Definition: document.cxx:5849
void UpdateLayerLocks()
Definition: tabview5.cxx:355
SC_DLLPUBLIC void ExtendOverlapped(SCCOL &rStartCol, SCROW &rStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:5572
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4170
sal_uInt16 GetOptimalColWidth(SCCOL nCol, SCTAB nTab, bool bFormula)
Definition: viewfunc.cxx:236
std::vector< sc::ColRowSpan > GetMarkedColSpans() const
Definition: markdata.cxx:481
bool IsRemoveAdjacentCellBorder() const
void SetErrCode(FormulaError n)
const ScInputHandler * GetInputHandler() const
Definition: tabvwsh.hxx:238
void SetHyperLink(bool bVal)
void ModifyCellSize(ScDirection eDir, bool bOptimal)
Definition: viewfunc.cxx:2395
void DeleteMulti(bool bRows)
Definition: viewfunc.cxx:1778
SC_DLLPUBLIC void CellContentChanged()
Definition: tabview3.cxx:513
void SetAutoCorrection(bool bVal)
When auto correction is set, the jump command reorder must be enabled.
Definition: compiler.cxx:4122
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:109
double GetPPTX() const
Definition: sizedev.hxx:41
ocClose
const ScRange & GetMultiMarkArea() const
Definition: markdata.hxx:84
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:802
void GetSelectionFrame(std::shared_ptr< SvxBoxItem > &rLineOuter, std::shared_ptr< SvxBoxInfoItem > &rLineInner)
Definition: viewfunc.cxx:885
sal_uInt16 Which() const
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:475
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:456
bool IsSelectionEditable(const ScMarkData &rMark, bool *pOnlyNotBecauseOfMatrix=nullptr) const
Definition: document.cxx:5446
LanguageType GetLanguage() const
void ForgetLastPattern()
Definition: inputhdl.cxx:2329
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
SC_DLLPUBLIC CRFlags GetRowFlags(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4386
constexpr TypedWhichId< SvxMarginItem > ATTR_MARGIN(143)
bool InsertCells(InsCellCmd eCmd, bool bRecord=true, bool bPartOfPaste=false)
Definition: viewfunc.cxx:1636
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr)
Definition: viewfunc.cxx:364
void GetFormatSpecialInfo(bool &bThousand, bool &IsRed, sal_uInt16 &nPrecision, sal_uInt16 &nLeadingCnt) const
void ShowAllCursors()
Definition: tabview3.cxx:234
SCCOL GetCurX() const
Definition: viewdata.hxx:401
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3677
bool m_bDetectedRangeSegmentation false
void SetMarkData(const ScMarkData &rNew)
Definition: tabview3.cxx:1739