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