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 // a single '=' character is handled as string (needed for special filters)
412 if ( rString.getLength() > 1 )
413 {
414 if ( rString[0] == '=' )
415 {
416 // handle as formula
417 bFormula = true;
418 }
419 else if ( rString[0] == '+' || rString[0] == '-' )
420 {
421 // if there is more than one leading '+' or '-' character, remove the additional ones
422 sal_Int32 nIndex = 1;
423 sal_Int32 nLen = rString.getLength();
424 while ( nIndex < nLen && ( rString[ nIndex ] == '+' || rString[ nIndex ] == '-' ) )
425 {
426 ++nIndex;
427 }
428 OUString aString = rString.replaceAt( 1, nIndex - 1, u"" );
429
430 // if the remaining part without the leading '+' or '-' character
431 // is non-empty and not a number, handle as formula
432 if ( aString.getLength() > 1 )
433 {
434 sal_uInt32 nFormat = rDoc.GetNumberFormat( nCol, nRow, nTab );
435 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
436 double fNumber = 0;
437 if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) )
438 {
439 bFormula = true;
440 }
441 }
442 }
443 }
444
445 bool bNumFmtChanged = false;
446 if ( bFormula )
447 { // formula, compile with autoCorrection
448 i = rMark.GetFirstSelected();
449 ScAddress aPos( nCol, nRow, i );
450 ScCompiler aComp( rDoc, aPos, rDoc.GetGrammar(), true, false );
451//2do: enable/disable autoCorrection via calcoptions
452 aComp.SetAutoCorrection( true );
453 if ( rString[0] == '+' || rString[0] == '-' )
454 {
456 }
457 OUString aFormula( rString );
458 std::unique_ptr< ScTokenArray > pArr;
459 bool bAgain;
460 do
461 {
462 bAgain = false;
463 bool bAddEqual = false;
464 pArr = aComp.CompileString( aFormula );
465 bool bCorrected = aComp.IsCorrected();
466 std::unique_ptr< ScTokenArray > pArrFirst;
467 if ( bCorrected )
468 { // try to parse with first parser-correction
469 pArrFirst = std::move( pArr );
470 pArr = aComp.CompileString( aComp.GetCorrectedFormula() );
471 }
472 if ( pArr->GetCodeError() == FormulaError::NONE )
473 {
474 bAddEqual = true;
475 aComp.CompileTokenArray();
476 bCorrected |= aComp.IsCorrected();
477 }
478 if ( bCorrected )
479 {
480 OUString aCorrectedFormula;
481 if ( bAddEqual )
482 {
483 aCorrectedFormula = "=" + aComp.GetCorrectedFormula();
484 }
485 else
486 aCorrectedFormula = aComp.GetCorrectedFormula();
487 short nResult;
488 if ( aCorrectedFormula.getLength() == 1 )
489 nResult = RET_NO; // empty formula, just '='
490 else
491 {
492 AutoCorrectQuery aQueryBox(GetViewData().GetDialogParent(), aCorrectedFormula);
493 nResult = aQueryBox.run();
494 }
495 if ( nResult == RET_YES )
496 {
497 aFormula = aCorrectedFormula;
498 bAgain = true;
499 }
500 else
501 {
502 if ( pArrFirst )
503 pArr = std::move( pArrFirst );
504 }
505 }
506 } while ( bAgain );
507 // to be used in multiple tabs, the formula must be compiled anew
508 // via ScFormulaCell copy-ctor because of RangeNames,
509 // the same code-array for all cells is not possible.
510 // If the array has an error, (it) must be RPN-erased in the newly generated
511 // cells and the error be set explicitly, so that
512 // via FormulaCell copy-ctor and Interpreter it will be, when possible,
513 // ironed out again, too intelligent... e.g.: =1))
514 FormulaError nError = pArr->GetCodeError();
515 if ( nError == FormulaError::NONE )
516 {
517 // update list of recent functions with all functions that
518 // are not within parentheses
519
520 ScModule* pScMod = SC_MOD();
521 ScAppOptions aAppOpt = pScMod->GetAppOptions();
522 bool bOptChanged = false;
523
524 formula::FormulaToken** ppToken = pArr->GetArray();
525 sal_uInt16 nTokens = pArr->GetLen();
526 sal_uInt16 nLevel = 0;
527 for (sal_uInt16 nTP=0; nTP<nTokens; nTP++)
528 {
529 formula::FormulaToken* pTok = ppToken[nTP];
530 OpCode eOp = pTok->GetOpCode();
531 if ( eOp == ocOpen )
532 ++nLevel;
533 else if ( eOp == ocClose && nLevel )
534 --nLevel;
535 if ( nLevel == 0 && pTok->IsFunction() &&
536 lcl_AddFunction( aAppOpt, sal::static_int_cast<sal_uInt16>( eOp ) ) )
537 bOptChanged = true;
538 }
539
540 if ( bOptChanged )
541 {
542 pScMod->SetAppOptions(aAppOpt);
543 }
544
545 if (bMatrixExpand)
546 {
547 // If the outer function/operator returns an array/matrix then
548 // enter a matrix formula. ScViewFunc::EnterMatrix() takes care
549 // of selection/mark of the result dimensions or preselected
550 // mark. If the user wanted less or a single cell then should
551 // mark such prior to entering the formula.
552 const formula::FormulaToken* pToken = pArr->LastRPNToken();
554 || pToken->IsInForceArray()))
555 {
556 // Discard this (still empty here) Undo action,
557 // EnterMatrix() will create its own.
558 if (bRecord)
559 rFunc.EndListAction();
560
561 // Use corrected formula string.
562 EnterMatrix( aFormula, rDoc.GetGrammar());
563
564 return;
565 }
566 }
567 }
568
569 ScFormulaCell aCell(rDoc, aPos, std::move( pArr ), formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE);
570
571 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
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}
836
838{
839 ScViewData& rData = GetViewData();
840 const SCCOL nCol = rData.GetCurX();
841 const SCROW nRow = rData.GetCurY();
842 const ScMarkData& rMark = rData.GetMarkData();
843 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
844 {
845 // nothing marked -> temporarily calculate block
846 // with size of result formula to get the size
847
848 ScDocument& rDoc = rData.GetDocument();
849 SCTAB nTab = rData.GetTabNo();
850 ScFormulaCell aFormCell( rDoc, ScAddress(nCol,nRow,nTab), rString, eGram, ScMatrixMode::Formula );
851
852 SCSIZE nSizeX;
853 SCSIZE nSizeY;
854 aFormCell.GetResultDimensions( nSizeX, nSizeY );
855 if ( nSizeX != 0 && nSizeY != 0 &&
856 nCol+nSizeX-1 <= sal::static_int_cast<SCSIZE>(rDoc.MaxCol()) &&
857 nRow+nSizeY-1 <= sal::static_int_cast<SCSIZE>(rDoc.MaxRow()) )
858 {
859 ScRange aResult( nCol, nRow, nTab,
860 sal::static_int_cast<SCCOL>(nCol+nSizeX-1),
861 sal::static_int_cast<SCROW>(nRow+nSizeY-1), nTab );
862 MarkRange( aResult, false );
863 }
864 }
865
866 ScRange aRange;
867 if (rData.GetSimpleArea(aRange) == SC_MARK_SIMPLE)
868 {
869 ScDocShell* pDocSh = rData.GetDocShell();
870 bool bSuccess = pDocSh->GetDocFunc().EnterMatrix(
871 aRange, &rMark, nullptr, rString, false, false, OUString(), eGram );
872 if (bSuccess)
873 pDocSh->UpdateOle(GetViewData());
874 else
875 PaintArea(nCol, nRow, nCol, nRow); // possibly the edit-engine is still painted there
876 }
877 else
878 ErrorMessage(STR_NOMULTISELECT);
879}
880
882{
883 SvtScriptType nScript = SvtScriptType::NONE;
884
886 const ScMarkData& rMark = GetViewData().GetMarkData();
887 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
888 {
889 // no selection -> cursor
890
891 nScript = rDoc.GetScriptType( GetViewData().GetCurX(),
892 GetViewData().GetCurY(), GetViewData().GetTabNo());
893 }
894 else
895 {
896 ScRangeList aRanges;
897 rMark.FillRangeListWithMarks( &aRanges, false );
898 nScript = rDoc.GetRangeScriptType(aRanges);
899 }
900
901 if (nScript == SvtScriptType::NONE)
903
904 return nScript;
905}
906
908{
909 // Don't use UnmarkFiltered in slot state functions, for performance reasons.
910 // The displayed state is always that of the whole selection including filtered rows.
911
912 const ScMarkData& rMark = GetViewData().GetMarkData();
914 if ( rMark.IsMarked() || rMark.IsMultiMarked() )
915 {
916 // MarkToMulti is no longer necessary for rDoc.GetSelectionPattern
917 const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( rMark );
918 return pAttr;
919 }
920 else
921 {
922 SCCOL nCol = GetViewData().GetCurX();
923 SCROW nRow = GetViewData().GetCurY();
924 SCTAB nTab = GetViewData().GetTabNo();
925
926 ScMarkData aTempMark( rMark ); // copy sheet selection
927 aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
928 const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aTempMark );
929 return pAttr;
930 }
931}
932
934 std::shared_ptr<SvxBoxItem>& rLineOuter,
935 std::shared_ptr<SvxBoxInfoItem>& rLineInner )
936{
938 const ScMarkData& rMark = GetViewData().GetMarkData();
939
940 if ( rMark.IsMarked() || rMark.IsMultiMarked() )
941 {
942 rDoc.GetSelectionFrame( rMark, *rLineOuter, *rLineInner );
943 }
944 else
945 {
946 const ScPatternAttr* pAttrs =
947 rDoc.GetPattern( GetViewData().GetCurX(),
948 GetViewData().GetCurY(),
949 GetViewData().GetTabNo() );
950
951 rLineOuter.reset(pAttrs->GetItem(ATTR_BORDER).Clone());
952 rLineInner.reset(pAttrs->GetItem(ATTR_BORDER_INNER).Clone());
953
954 rLineInner->SetTable(false);
955 rLineInner->SetDist(true);
956 rLineInner->SetMinDist(false);
957 }
958}
959
960// apply attribute - undo OK
961//
962// complete set ( ATTR_STARTINDEX, ATTR_ENDINDEX )
963
965 const SfxItemSet* pOldSet,
966 bool bAdjustBlockHeight)
967{
968 // not editable because of matrix only? attribute OK nonetheless
969 bool bOnlyNotBecauseOfMatrix;
970 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
971 {
972 ErrorMessage(STR_PROTECTIONERR);
973 return;
974 }
975
976 ScPatternAttr aOldAttrs(( SfxItemSet(*pOldSet) ));
977 ScPatternAttr aNewAttrs(( SfxItemSet(*pDialogSet) ));
978 aNewAttrs.DeleteUnchanged( &aOldAttrs );
979
980 if ( pDialogSet->GetItemState( ATTR_VALUE_FORMAT ) == SfxItemState::SET )
981 { // don't reset to default SYSTEM GENERAL if not intended
982 sal_uInt32 nOldFormat =
983 pOldSet->Get( ATTR_VALUE_FORMAT ).GetValue();
984 sal_uInt32 nNewFormat =
985 pDialogSet->Get( ATTR_VALUE_FORMAT ).GetValue();
986 if ( nNewFormat != nOldFormat )
987 {
988 SvNumberFormatter* pFormatter =
990 const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
991 LanguageType eOldLang =
992 pOldEntry ? pOldEntry->GetLanguage() : LANGUAGE_DONTKNOW;
993 const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
994 LanguageType eNewLang =
995 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
996 if ( eNewLang != eOldLang )
997 {
998 aNewAttrs.GetItemSet().Put(
1000
1001 // only the language has changed -> do not touch numberformat-attribute
1002 sal_uInt32 nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
1003 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
1005 aNewAttrs.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
1006 }
1007 }
1008 }
1009
1010 if (pDialogSet->HasItem(ATTR_FONT_LANGUAGE))
1011 // font language has changed. Redo the online spelling.
1013
1014 const SvxBoxItem& rOldOuter = pOldSet->Get(ATTR_BORDER);
1015 const SvxBoxItem& rNewOuter = pDialogSet->Get(ATTR_BORDER);
1016 const SvxBoxInfoItem& rOldInner = pOldSet->Get(ATTR_BORDER_INNER);
1017 const SvxBoxInfoItem& rNewInner = pDialogSet->Get(ATTR_BORDER_INNER);
1018 SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
1019 SfxItemPool* pNewPool = rNewSet.GetPool();
1020
1021 pNewPool->Put(rNewOuter); // don't delete yet
1022 pNewPool->Put(rNewInner);
1023 rNewSet.ClearItem( ATTR_BORDER );
1024 rNewSet.ClearItem( ATTR_BORDER_INNER );
1025
1026 /*
1027 * establish whether border attribute is to be set:
1028 * 1. new != old
1029 * 2. is one of the borders not-DontCare (since 238.f: IsxxValid())
1030 *
1031 */
1032
1033 bool bFrame = (pDialogSet->GetItemState( ATTR_BORDER ) != SfxItemState::DEFAULT)
1034 || (pDialogSet->GetItemState( ATTR_BORDER_INNER ) != SfxItemState::DEFAULT);
1035
1036 if (&rNewOuter == &rOldOuter && &rNewInner == &rOldInner)
1037 bFrame = false;
1038
1039 // this should be intercepted by the pool: ?!??!??
1040
1041 if (bFrame && rNewOuter == rOldOuter && rNewInner == rOldInner)
1042 bFrame = false;
1043
1044 bFrame = bFrame
1045 && ( rNewInner.IsValid(SvxBoxInfoItemValidFlags::LEFT)
1046 || rNewInner.IsValid(SvxBoxInfoItemValidFlags::RIGHT)
1047 || rNewInner.IsValid(SvxBoxInfoItemValidFlags::TOP)
1048 || rNewInner.IsValid(SvxBoxInfoItemValidFlags::BOTTOM)
1049 || rNewInner.IsValid(SvxBoxInfoItemValidFlags::HORI)
1050 || rNewInner.IsValid(SvxBoxInfoItemValidFlags::VERT) );
1051
1052 if (!bFrame)
1053 ApplySelectionPattern( aNewAttrs ); // standard only
1054 else
1055 {
1056 // if new items are default-items, overwrite the old items:
1057
1058 bool bDefNewOuter = IsStaticDefaultItem(&rNewOuter);
1059 bool bDefNewInner = IsStaticDefaultItem(&rNewInner);
1060
1061 ApplyPatternLines( aNewAttrs,
1062 bDefNewOuter ? rOldOuter : rNewOuter,
1063 bDefNewInner ? &rOldInner : &rNewInner );
1064 }
1065
1066 pNewPool->Remove(rNewOuter); // release
1067 pNewPool->Remove(rNewInner);
1068
1069 // adjust height only if needed
1070 if (bAdjustBlockHeight)
1072
1073 // CellContentChanged is called in ApplySelectionPattern / ApplyPatternLines
1074}
1075
1076void ScViewFunc::ApplyAttr( const SfxPoolItem& rAttrItem, bool bAdjustBlockHeight )
1077{
1078 // not editable because of matrix only? attribute OK nonetheless
1079 bool bOnlyNotBecauseOfMatrix;
1080 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
1081 {
1082 ErrorMessage(STR_PROTECTIONERR);
1083 return;
1084 }
1085
1086 ScPatternAttr aNewAttrs(
1088
1089 aNewAttrs.GetItemSet().Put( rAttrItem );
1090 // if justify is set (with Buttons), always indentation 0
1091 if ( rAttrItem.Which() == ATTR_HOR_JUSTIFY )
1092 aNewAttrs.GetItemSet().Put( ScIndentItem( 0 ) );
1093 ApplySelectionPattern( aNewAttrs );
1094
1095 // Prevent useless compute
1096 if (bAdjustBlockHeight)
1098
1099 // CellContentChanged is called in ApplySelectionPattern
1100}
1101
1102// patterns and borders
1103
1104void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem& rNewOuter,
1105 const SvxBoxInfoItem* pNewInner )
1106{
1108 ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
1109 ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1110 bool bRecord = true;
1111 if (!rDoc.IsUndoEnabled())
1112 bRecord = false;
1113
1114 bool bRemoveAdjCellBorder = rNewOuter.IsRemoveAdjacentCellBorder();
1115 ScRange aMarkRange, aMarkRangeWithEnvelope;
1116 aFuncMark.MarkToSimple();
1117 bool bMulti = aFuncMark.IsMultiMarked();
1118 if (bMulti)
1119 aMarkRange = aFuncMark.GetMultiMarkArea();
1120 else if (aFuncMark.IsMarked())
1121 aMarkRange = aFuncMark.GetMarkArea();
1122 else
1123 {
1124 aMarkRange = ScRange( GetViewData().GetCurX(),
1125 GetViewData().GetCurY(), GetViewData().GetTabNo() );
1126 DoneBlockMode();
1127 InitOwnBlockMode( aMarkRange );
1128 aFuncMark.SetMarkArea(aMarkRange);
1130 }
1131 if( bRemoveAdjCellBorder )
1132 aFuncMark.GetSelectionCover( aMarkRangeWithEnvelope );
1133 else
1134 aMarkRangeWithEnvelope = aMarkRange;
1135
1136 ScDocShell* pDocSh = GetViewData().GetDocShell();
1137
1138 ScDocShellModificator aModificator( *pDocSh );
1139
1140 if (bRecord)
1141 {
1143 SCTAB nStartTab = aMarkRange.aStart.Tab();
1144 SCTAB nTabCount = rDoc.GetTableCount();
1145 bool bCopyOnlyMarked = false;
1146 if( !bRemoveAdjCellBorder )
1147 bCopyOnlyMarked = bMulti;
1148 pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
1149 for (const auto& rTab : aFuncMark)
1150 if (rTab != nStartTab)
1151 pUndoDoc->AddUndoTab( rTab, rTab );
1152
1153 ScRange aCopyRange = aMarkRangeWithEnvelope;
1154 aCopyRange.aStart.SetTab(0);
1155 aCopyRange.aEnd.SetTab(nTabCount-1);
1156 rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, bCopyOnlyMarked, *pUndoDoc, &aFuncMark );
1157
1158 pDocSh->GetUndoManager()->AddUndoAction(
1159 std::make_unique<ScUndoSelectionAttr>(
1160 pDocSh, aFuncMark,
1161 aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), aMarkRange.aStart.Tab(),
1162 aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), aMarkRange.aEnd.Tab(),
1163 std::move(pUndoDoc), bCopyOnlyMarked, &rAttr, &rNewOuter, pNewInner, &aMarkRangeWithEnvelope ) );
1164 }
1165
1166 sal_uInt16 nExt = SC_PF_TESTMERGE;
1167 pDocSh->UpdatePaintExt( nExt, aMarkRangeWithEnvelope ); // content before the change
1168
1169 rDoc.ApplySelectionFrame(aFuncMark, rNewOuter, pNewInner);
1170
1171 pDocSh->UpdatePaintExt( nExt, aMarkRangeWithEnvelope ); // content after the change
1172
1173 aFuncMark.MarkToMulti();
1174 rDoc.ApplySelectionPattern( rAttr, aFuncMark );
1175
1176 pDocSh->PostPaint( aMarkRange, PaintPartFlags::Grid, nExt );
1177 pDocSh->UpdateOle(GetViewData());
1178 aModificator.SetDocumentModified();
1180
1182}
1183
1184static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc)
1185{
1186 // tdf#147842 if the marked area is the entire sheet, then shrink it to the data area.
1187 // Otherwise ctrl-A, perform-action, will take a very long time as it tries to modify
1188 // cells then we are not using.
1189 if (rFuncMark.IsMultiMarked())
1190 return;
1191 ScRange aMarkArea = rFuncMark.GetMarkArea();
1192 const ScSheetLimits& rLimits = rDoc.GetSheetLimits();
1193 if (aMarkArea.aStart.Row() != 0 || aMarkArea.aStart.Col() != 0)
1194 return;
1195 if (aMarkArea.aEnd.Row() != rLimits.MaxRow() || aMarkArea.aEnd.Col() != rLimits.MaxCol())
1196 return;
1197 if (aMarkArea.aStart.Tab() != aMarkArea.aEnd.Tab())
1198 return;
1199 SCCOL nStartCol = aMarkArea.aStart.Col();
1200 SCROW nStartRow = aMarkArea.aStart.Row();
1201 SCCOL nEndCol = aMarkArea.aEnd.Col();
1202 SCROW nEndRow = aMarkArea.aEnd.Row();
1203 rDoc.ShrinkToDataArea(aMarkArea.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow);
1204 aMarkArea.aStart.SetCol(nStartCol);
1205 aMarkArea.aStart.SetRow(nStartRow);
1206 aMarkArea.aEnd.SetCol(nEndCol);
1207 aMarkArea.aEnd.SetRow(nEndRow);
1208 rFuncMark.ResetMark();
1209 rFuncMark.SetMarkArea(aMarkArea);
1210}
1211
1212// pattern only
1213
1214void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursorOnly )
1215{
1216 ScViewData& rViewData = GetViewData();
1217 ScDocShell* pDocSh = rViewData.GetDocShell();
1218 ScDocument& rDoc = pDocSh->GetDocument();
1219 ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
1220 ShrinkToDataArea( aFuncMark, rDoc );
1221 ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1222
1223 bool bRecord = true;
1224 if (!rDoc.IsUndoEnabled())
1225 bRecord = false;
1226
1227 // State from old ItemSet doesn't matter for paint flags, as any change will be
1228 // from SfxItemState::SET in the new ItemSet (default is ignored in ApplyPattern).
1229 // New alignment is checked (check in PostPaint isn't enough) in case a right
1230 // alignment is changed to left.
1231 const SfxItemSet& rNewSet = rAttr.GetItemSet();
1232 bool bSetLines = rNewSet.GetItemState( ATTR_BORDER ) == SfxItemState::SET ||
1233 rNewSet.GetItemState( ATTR_SHADOW ) == SfxItemState::SET;
1234 bool bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY ) == SfxItemState::SET;
1235
1236 sal_uInt16 nExtFlags = 0;
1237 if ( bSetLines )
1238 nExtFlags |= SC_PF_LINES;
1239 if ( bSetAlign )
1240 nExtFlags |= SC_PF_WHOLEROWS;
1241
1242 ScDocShellModificator aModificator( *pDocSh );
1243
1244 bool bMulti = aFuncMark.IsMultiMarked();
1245 aFuncMark.MarkToMulti();
1246 bool bOnlyTab = (!aFuncMark.IsMultiMarked() && !bCursorOnly && aFuncMark.GetSelectCount() > 1);
1247 if (bOnlyTab)
1248 {
1249 SCCOL nCol = rViewData.GetCurX();
1250 SCROW nRow = rViewData.GetCurY();
1251 SCTAB nTab = rViewData.GetTabNo();
1252 aFuncMark.SetMarkArea(ScRange(nCol,nRow,nTab));
1253 aFuncMark.MarkToMulti();
1254 }
1255
1256 ScRangeList aChangeRanges;
1257
1258 if (aFuncMark.IsMultiMarked() && !bCursorOnly)
1259 {
1260 const ScRange& aMarkRange = aFuncMark.GetMultiMarkArea();
1261 SCTAB nTabCount = rDoc.GetTableCount();
1262 for (const auto& rTab : aFuncMark)
1263 {
1264 ScRange aChangeRange( aMarkRange );
1265 aChangeRange.aStart.SetTab( rTab );
1266 aChangeRange.aEnd.SetTab( rTab );
1267 aChangeRanges.push_back( aChangeRange );
1268 }
1269
1270 SCCOL nStartCol = aMarkRange.aStart.Col();
1271 SCROW nStartRow = aMarkRange.aStart.Row();
1272 SCTAB nStartTab = aMarkRange.aStart.Tab();
1273 SCCOL nEndCol = aMarkRange.aEnd.Col();
1274 SCROW nEndRow = aMarkRange.aEnd.Row();
1275 SCTAB nEndTab = aMarkRange.aEnd.Tab();
1276
1277 ScEditDataArray* pEditDataArray = nullptr;
1278 if (bRecord)
1279 {
1280 ScRange aCopyRange = aMarkRange;
1281 aCopyRange.aStart.SetTab(0);
1282 aCopyRange.aEnd.SetTab(nTabCount-1);
1283
1285 pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
1286 for (const auto& rTab : aFuncMark)
1287 if (rTab != nStartTab)
1288 pUndoDoc->AddUndoTab( rTab, rTab );
1289 rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, bMulti, *pUndoDoc, &aFuncMark );
1290
1291 aFuncMark.MarkToMulti();
1292
1294 pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
1295 nEndCol, nEndRow, nEndTab, std::move(pUndoDoc), bMulti, &rAttr );
1296 pDocSh->GetUndoManager()->AddUndoAction(std::unique_ptr<ScUndoSelectionAttr>(pUndoAttr));
1297 pEditDataArray = pUndoAttr->GetDataArray();
1298 }
1299
1300 rDoc.ApplySelectionPattern( rAttr, aFuncMark, pEditDataArray );
1301
1302 pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
1303 nEndCol, nEndRow, nEndTab,
1305 pDocSh->UpdateOle(GetViewData());
1306 aModificator.SetDocumentModified();
1308 }
1309 else // single cell - simpler undo
1310 {
1311 SCCOL nCol = rViewData.GetCurX();
1312 SCROW nRow = rViewData.GetCurY();
1313 SCTAB nTab = rViewData.GetTabNo();
1314
1315 std::unique_ptr<EditTextObject> pOldEditData;
1316 std::unique_ptr<EditTextObject> pNewEditData;
1317 ScAddress aPos(nCol, nRow, nTab);
1318 ScRefCellValue aCell(rDoc, aPos);
1319 if (aCell.getType() == CELLTYPE_EDIT)
1320 {
1321 const EditTextObject* pEditObj = aCell.getEditText();
1322 pOldEditData = pEditObj->Clone();
1323 rDoc.RemoveEditTextCharAttribs(aPos, rAttr);
1324 pEditObj = rDoc.GetEditText(aPos);
1325 pNewEditData = pEditObj->Clone();
1326 }
1327
1328 aChangeRanges.push_back(aPos);
1329 std::optional<ScPatternAttr> pOldPat(*rDoc.GetPattern( nCol, nRow, nTab ));
1330
1331 rDoc.ApplyPattern( nCol, nRow, nTab, rAttr );
1332
1333 const ScPatternAttr* pNewPat = rDoc.GetPattern( nCol, nRow, nTab );
1334
1335 if (bRecord)
1336 {
1337 std::unique_ptr<ScUndoCursorAttr> pUndo(new ScUndoCursorAttr(
1338 pDocSh, nCol, nRow, nTab, &*pOldPat, pNewPat, &rAttr ));
1339 pUndo->SetEditData(std::move(pOldEditData), std::move(pNewEditData));
1340 pDocSh->GetUndoManager()->AddUndoAction(std::move(pUndo));
1341 }
1342 pOldPat.reset(); // is copied in undo (Pool)
1343
1344 pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PaintPartFlags::Grid, nExtFlags | SC_PF_TESTMERGE );
1345 pDocSh->UpdateOle(GetViewData());
1346 aModificator.SetDocumentModified();
1348 }
1349
1350 ScModelObj* pModelObj = pDocSh->GetModel();
1351
1353 {
1354 css::uno::Sequence< css::beans::PropertyValue > aProperties;
1355 sal_Int32 nCount = 0;
1357 for ( sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; ++nWhich )
1358 {
1359 const SfxPoolItem* pItem = nullptr;
1360 if ( rNewSet.GetItemState( nWhich, true, &pItem ) == SfxItemState::SET && pItem )
1361 {
1362 for ( const auto pEntry : rMap.getPropertyEntries())
1363 {
1364 if ( pEntry->nWID == nWhich )
1365 {
1366 css::uno::Any aVal;
1367 pItem->QueryValue( aVal, pEntry->nMemberId );
1368 aProperties.realloc( nCount + 1 );
1369 auto pProperties = aProperties.getArray();
1370 pProperties[ nCount ].Name = pEntry->aName;
1371 pProperties[ nCount ].Value = aVal;
1372 ++nCount;
1373 }
1374 }
1375 }
1376 }
1377 HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "attribute", aProperties);
1378 }
1379
1381}
1382
1384{
1385 // ItemSet from UI, may have different pool
1386
1387 bool bOnlyNotBecauseOfMatrix;
1388 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
1389 {
1390 ErrorMessage(STR_PROTECTIONERR);
1391 return;
1392 }
1393
1394 ScPatternAttr aNewAttrs( GetViewData().GetDocument().GetPool() );
1395 SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
1396 rNewSet.Put( rItemSet, false );
1397 ApplySelectionPattern( aNewAttrs );
1398
1400}
1401
1403{
1404 // Don't use UnmarkFiltered in slot state functions, for performance reasons.
1405 // The displayed state is always that of the whole selection including filtered rows.
1406
1407 const ScStyleSheet* pSheet = nullptr;
1408 ScViewData& rViewData = GetViewData();
1409 ScDocument& rDoc = rViewData.GetDocument();
1410 ScMarkData& rMark = rViewData.GetMarkData();
1411
1412 if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1413 pSheet = rDoc.GetSelectionStyle( rMark ); // MarkToMulti isn't necessary
1414 else
1415 pSheet = rDoc.GetStyle( rViewData.GetCurX(),
1416 rViewData.GetCurY(),
1417 rViewData.GetTabNo() );
1418
1419 return pSheet;
1420}
1421
1423{
1424 // not editable because of matrix only? attribute OK nonetheless
1425 bool bOnlyNotBecauseOfMatrix;
1426 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
1427 {
1428 ErrorMessage(STR_PROTECTIONERR);
1429 return;
1430 }
1431
1432 if ( !pStyleSheet) return;
1433
1434 ScViewData& rViewData = GetViewData();
1435 ScDocShell* pDocSh = rViewData.GetDocShell();
1436 ScDocument& rDoc = pDocSh->GetDocument();
1437 ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
1438 ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1439 SCTAB nTabCount = rDoc.GetTableCount();
1440 bool bRecord = true;
1441 if (!rDoc.IsUndoEnabled())
1442 bRecord = false;
1443
1444 ScDocShellModificator aModificator( *pDocSh );
1445
1446 if ( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() )
1447 {
1448 aFuncMark.MarkToMulti();
1449 const ScRange& aMarkRange = aFuncMark.GetMultiMarkArea();
1450
1451 if ( bRecord )
1452 {
1453 SCTAB nTab = rViewData.GetTabNo();
1455 pUndoDoc->InitUndo( rDoc, nTab, nTab );
1456 for (const auto& rTab : aFuncMark)
1457 if (rTab != nTab)
1458 pUndoDoc->AddUndoTab( rTab, rTab );
1459
1460 ScRange aCopyRange = aMarkRange;
1461 aCopyRange.aStart.SetTab(0);
1462 aCopyRange.aEnd.SetTab(nTabCount-1);
1463 rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, true, *pUndoDoc, &aFuncMark );
1464 aFuncMark.MarkToMulti();
1465
1466 OUString aName = pStyleSheet->GetName();
1467 pDocSh->GetUndoManager()->AddUndoAction(
1468 std::make_unique<ScUndoSelectionStyle>( pDocSh, aFuncMark, aMarkRange, aName, std::move(pUndoDoc) ) );
1469 }
1470
1471 rDoc.ApplySelectionStyle( static_cast<const ScStyleSheet&>(*pStyleSheet), aFuncMark );
1472
1473 if (!AdjustBlockHeight())
1474 rViewData.GetDocShell()->PostPaint( aMarkRange, PaintPartFlags::Grid );
1475
1476 aFuncMark.MarkToSimple();
1477 }
1478 else
1479 {
1480 SCCOL nCol = rViewData.GetCurX();
1481 SCROW nRow = rViewData.GetCurY();
1482 SCTAB nTab = rViewData.GetTabNo();
1483
1484 if ( bRecord )
1485 {
1487 pUndoDoc->InitUndo( rDoc, nTab, nTab );
1488 for (const auto& rTab : aFuncMark)
1489 if (rTab != nTab)
1490 pUndoDoc->AddUndoTab( rTab, rTab );
1491
1492 ScRange aCopyRange( nCol, nRow, 0, nCol, nRow, nTabCount-1 );
1493 rDoc.CopyToDocument( aCopyRange, InsertDeleteFlags::ATTRIB, false, *pUndoDoc );
1494
1495 ScRange aMarkRange ( nCol, nRow, nTab );
1496 ScMarkData aUndoMark = aFuncMark;
1497 aUndoMark.SetMultiMarkArea( aMarkRange );
1498
1499 OUString aName = pStyleSheet->GetName();
1500 pDocSh->GetUndoManager()->AddUndoAction(
1501 std::make_unique<ScUndoSelectionStyle>( pDocSh, aUndoMark, aMarkRange, aName, std::move(pUndoDoc) ) );
1502 }
1503
1504 for (const auto& rTab : aFuncMark)
1505 rDoc.ApplyStyle( nCol, nRow, rTab, static_cast<const ScStyleSheet&>(*pStyleSheet) );
1506
1507 if (!AdjustBlockHeight())
1508 rViewData.GetDocShell()->PostPaintCell( nCol, nRow, nTab );
1509
1510 }
1511
1512 aModificator.SetDocumentModified();
1513
1515}
1516
1518{
1519 if ( !pStyleSheet) return;
1520
1521 ScViewData& rViewData = GetViewData();
1522 ScDocument& rDoc = rViewData.GetDocument();
1523 ScDocShell* pDocSh = rViewData.GetDocShell();
1524
1525 ScDocShellModificator aModificator( *pDocSh );
1526
1528 pVirtDev->SetMapMode(MapMode(MapUnit::MapPixel));
1529 rDoc.StyleSheetChanged( pStyleSheet, true, pVirtDev,
1530 rViewData.GetPPTX(),
1531 rViewData.GetPPTY(),
1532 rViewData.GetZoomX(),
1533 rViewData.GetZoomY() );
1534
1535 pDocSh->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1536 aModificator.SetDocumentModified();
1537
1538 ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
1539 if (pHdl)
1540 pHdl->ForgetLastPattern();
1541}
1542
1544{
1545 if ( !pStyleSheet) return;
1546
1547 ScViewData& rViewData = GetViewData();
1548 ScDocument& rDoc = rViewData.GetDocument();
1549 ScDocShell* pDocSh = rViewData.GetDocShell();
1550
1551 ScDocShellModificator aModificator( *pDocSh );
1552
1554 pVirtDev->SetMapMode(MapMode(MapUnit::MapPixel));
1555 rDoc.StyleSheetChanged( pStyleSheet, false, pVirtDev,
1556 rViewData.GetPPTX(),
1557 rViewData.GetPPTY(),
1558 rViewData.GetZoomX(),
1559 rViewData.GetZoomY() );
1560
1561 pDocSh->PostPaint( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1562 aModificator.SetDocumentModified();
1563
1564 ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
1565 if (pHdl)
1566 pHdl->ForgetLastPattern();
1567}
1568
1569
1571{
1572 if (!comphelper::LibreOfficeKit::isActive() || nOffset == 0)
1573 return;
1574
1575 SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
1576 SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
1577 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1578 while (pViewShell)
1579 {
1580 ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1581 if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
1582 {
1583 if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex))
1584 pPosHelper->invalidateByIndex(nStartCol);
1585
1586 // if we remove a column the cursor position and the current selection
1587 // in other views could need to be moved on the left by one column.
1588 if (pTabViewShell != this)
1589 {
1590 if (pTabViewShell->getPart() == nCurrentTabIndex)
1591 {
1592 SCCOL nX = pTabViewShell->GetViewData().GetCurX();
1593 if (nX > nStartCol || (nX == nStartCol && nOffset > 0))
1594 {
1595 ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler();
1596 SCROW nY = pTabViewShell->GetViewData().GetCurY();
1597 pTabViewShell->SetCursor(nX + nOffset, nY);
1598 if (pInputHdl && pInputHdl->IsInputMode())
1599 {
1600 pInputHdl->SetModified();
1601 }
1602 }
1603
1604 ScMarkData aMultiMark( pTabViewShell->GetViewData().GetMarkData() );
1605 aMultiMark.SetMarking( false );
1606 aMultiMark.MarkToMulti();
1607 if (aMultiMark.IsMultiMarked())
1608 {
1609 aMultiMark.ShiftCols(pTabViewShell->GetViewData().GetDocument(), nStartCol, nOffset);
1610 pTabViewShell->SetMarkData(aMultiMark);
1611 }
1612 }
1613 else
1614 {
1615 SCROW nX = pTabViewShell->GetViewData().GetCurXForTab(nCurrentTabIndex);
1616 if (nX > nStartCol || (nX == nStartCol && nOffset > 0))
1617 {
1618 pTabViewShell->GetViewData().SetCurXForTab(nX + nOffset, nCurrentTabIndex);
1619 }
1620 }
1621 }
1622 }
1623 pViewShell = SfxViewShell::GetNext(*pViewShell);
1624 }
1625}
1626
1628{
1629 if (!comphelper::LibreOfficeKit::isActive() || nOffset == 0)
1630 return;
1631
1632 SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
1633 SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
1634 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1635 while (pViewShell)
1636 {
1637 ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1638 if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
1639 {
1640 if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex))
1641 pPosHelper->invalidateByIndex(nStartRow);
1642
1643 // if we remove a row the cursor position and the current selection
1644 // in other views could need to be moved up by one row.
1645 if (pTabViewShell != this)
1646 {
1647 if (pTabViewShell->getPart() == nCurrentTabIndex)
1648 {
1649 SCROW nY = pTabViewShell->GetViewData().GetCurY();
1650 if (nY > nStartRow || (nY == nStartRow && nOffset > 0))
1651 {
1652 ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler();
1653 SCCOL nX = pTabViewShell->GetViewData().GetCurX();
1654 pTabViewShell->SetCursor(nX, nY + nOffset);
1655 if (pInputHdl && pInputHdl->IsInputMode())
1656 {
1657 pInputHdl->SetModified();
1658 }
1659 }
1660
1661 ScMarkData aMultiMark( pTabViewShell->GetViewData().GetMarkData() );
1662 aMultiMark.SetMarking( false );
1663 aMultiMark.MarkToMulti();
1664 if (aMultiMark.IsMultiMarked())
1665 {
1666 aMultiMark.ShiftRows(pTabViewShell->GetViewData().GetDocument(), nStartRow, nOffset);
1667 pTabViewShell->SetMarkData(aMultiMark);
1668 }
1669 }
1670 else
1671 {
1672 SCROW nY = pTabViewShell->GetViewData().GetCurYForTab(nCurrentTabIndex);
1673 if (nY > nStartRow || (nY == nStartRow && nOffset > 0))
1674 {
1675 pTabViewShell->GetViewData().SetCurYForTab(nY + nOffset, nCurrentTabIndex);
1676 }
1677 }
1678 }
1679 }
1680 pViewShell = SfxViewShell::GetNext(*pViewShell);
1681 }
1682}
1683
1685{
1687 return;
1688
1689 SCTAB nCurTab = GetViewData().GetTabNo();
1690 SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
1691 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1692 while (pViewShell)
1693 {
1694 ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1695 if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
1696 {
1697 if (bWidth)
1698 {
1699 if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab))
1700 pPosHelper->invalidateByIndex(nStart);
1701 }
1702 else
1703 {
1704 if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab))
1705 pPosHelper->invalidateByIndex(nStart);
1706 }
1707 }
1708 pViewShell = SfxViewShell::GetNext(*pViewShell);
1709 }
1710}
1711
1712// insert cells - undo OK
1713
1714bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste )
1715{
1716 ScRange aRange;
1717 ScMarkType eMarkType = GetViewData().GetSimpleArea(aRange);
1718 if (eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED)
1719 {
1720 ScDocShell* pDocSh = GetViewData().GetDocShell();
1721 const ScMarkData& rMark = GetViewData().GetMarkData();
1722 bool bSuccess = pDocSh->GetDocFunc().InsertCells( aRange, &rMark, eCmd, bRecord, false, bPartOfPaste );
1723 if (bSuccess)
1724 {
1726 bool bInsertCols = ( eCmd == INS_INSCOLS_BEFORE || eCmd == INS_INSCOLS_AFTER);
1727 bool bInsertRows = ( eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSROWS_AFTER );
1728
1729 pDocSh->UpdateOle(GetViewData());
1731
1732 if ( bInsertCols || bInsertRows )
1733 {
1734 OUString aOperation = bInsertRows ?
1735 OUString("insert-rows"):
1736 OUString("insert-columns");
1737 HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation);
1738 }
1739
1741 {
1742 if (bInsertCols)
1744
1745 if (bInsertRows)
1747
1749 bInsertCols, bInsertRows, true /* bSizes*/,
1750 true /* bHidden */, true /* bFiltered */,
1751 true /* bGroups */, GetViewData().GetTabNo());
1752 }
1753 }
1754 OUString aStartAddress = aRange.aStart.GetColRowString();
1755 OUString aEndAddress = aRange.aEnd.GetColRowString();
1756 collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "INSERT_CELLS");
1757 return bSuccess;
1758 }
1759 else
1760 {
1761 ErrorMessage(STR_NOMULTISELECT);
1762 return false;
1763 }
1764}
1765
1766// delete cells - undo OK
1767
1769{
1770 ScRange aRange;
1771 if ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
1772 {
1773 ScDocShell* pDocSh = GetViewData().GetDocShell();
1774 const ScMarkData& rMark = GetViewData().GetMarkData();
1775
1776#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
1777 // #i94841# [Collaboration] if deleting rows is rejected, the content is sometimes wrong
1778 if ( pDocSh->IsDocShared() && ( eCmd == DelCellCmd::Rows || eCmd == DelCellCmd::Cols ) )
1779 {
1780 ScRange aDelRange( aRange.aStart );
1781 SCCOLROW nCount = 0;
1782 if ( eCmd == DelCellCmd::Rows )
1783 {
1784 nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
1785 }
1786 else
1787 {
1788 nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Col() - aRange.aStart.Col() + 1 );
1789 }
1790 while ( nCount > 0 )
1791 {
1792 pDocSh->GetDocFunc().DeleteCells( aDelRange, &rMark, eCmd, false );
1793 --nCount;
1794 }
1795 }
1796 else
1797#endif
1798 {
1799 pDocSh->GetDocFunc().DeleteCells( aRange, &rMark, eCmd, false );
1800 }
1801
1803 pDocSh->UpdateOle(GetViewData());
1805
1806 if ( eCmd == DelCellCmd::Rows || eCmd == DelCellCmd::Cols )
1807 {
1808 OUString aOperation = ( eCmd == DelCellCmd::Rows) ?
1809 OUString("delete-rows"):
1810 OUString("delete-columns");
1811 HelperNotifyChanges::NotifyIfChangesListeners(*pDocSh, aRange, aOperation);
1812 }
1813
1814 // put cursor directly behind deleted range
1815 SCCOL nCurX = GetViewData().GetCurX();
1816 SCROW nCurY = GetViewData().GetCurY();
1817 if ( eCmd==DelCellCmd::CellsLeft || eCmd==DelCellCmd::Cols )
1818 nCurX = aRange.aStart.Col();
1819 else
1820 nCurY = aRange.aStart.Row();
1821 SetCursor( nCurX, nCurY );
1822
1824 {
1825 bool bColsDeleted = (eCmd == DelCellCmd::Cols);
1826 bool bRowsDeleted = (eCmd == DelCellCmd::Rows);
1827 if (bColsDeleted)
1829
1830 if (bRowsDeleted)
1832
1834 bColsDeleted, bRowsDeleted, true /* bSizes*/,
1835 true /* bHidden */, true /* bFiltered */,
1836 true /* bGroups */, GetViewData().GetTabNo());
1837 }
1838 }
1839 else
1840 {
1841 if (eCmd == DelCellCmd::Cols)
1842 DeleteMulti( false );
1843 else if (eCmd == DelCellCmd::Rows)
1844 DeleteMulti( true );
1845 else
1846 ErrorMessage(STR_NOMULTISELECT);
1847 }
1848
1849 OUString aStartAddress = aRange.aStart.GetColRowString();
1850 OUString aEndAddress = aRange.aEnd.GetColRowString();
1851 collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "DELETE_CELLS");
1852
1853 Unmark();
1854}
1855
1856void ScViewFunc::DeleteMulti( bool bRows )
1857{
1858 ScDocShell* pDocSh = GetViewData().GetDocShell();
1859 ScDocShellModificator aModificator( *pDocSh );
1860 SCTAB nTab = GetViewData().GetTabNo();
1861 ScDocument& rDoc = pDocSh->GetDocument();
1862 ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
1863 ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
1864
1865 bool bRecord = true;
1866 if (!rDoc.IsUndoEnabled())
1867 bRecord = false;
1868
1869 std::vector<sc::ColRowSpan> aSpans;
1870 if (bRows)
1871 aSpans = aFuncMark.GetMarkedRowSpans();
1872 else
1873 aSpans = aFuncMark.GetMarkedColSpans();
1874
1875 if (aSpans.empty())
1876 {
1877 SCCOLROW nCurPos = bRows ? GetViewData().GetCurY() : GetViewData().GetCurX();
1878 aSpans.emplace_back(nCurPos, nCurPos);
1879 }
1880
1881 // test if allowed
1882
1883 TranslateId pErrorId;
1884 bool bNeedRefresh = false;
1885 for (size_t i = 0, n = aSpans.size(); i < n && !pErrorId; ++i)
1886 {
1887 SCCOLROW nStart = aSpans[i].mnStart;
1888 SCCOLROW nEnd = aSpans[i].mnEnd;
1889
1890 SCCOL nStartCol, nEndCol;
1891 SCROW nStartRow, nEndRow;
1892 if ( bRows )
1893 {
1894 nStartCol = 0;
1895 nEndCol = rDoc.MaxCol();
1896 nStartRow = static_cast<SCROW>(nStart);
1897 nEndRow = static_cast<SCROW>(nEnd);
1898 }
1899 else
1900 {
1901 nStartCol = static_cast<SCCOL>(nStart);
1902 nEndCol = static_cast<SCCOL>(nEnd);
1903 nStartRow = 0;
1904 nEndRow = rDoc.MaxRow();
1905 }
1906
1907 // cell protection (only needed for first range, as all following cells are moved)
1908 if (i == 0)
1909 {
1910 // test to the end of the sheet
1911 ScEditableTester aTester( rDoc, nTab, nStartCol, nStartRow, rDoc.MaxCol(), rDoc.MaxRow() );
1912 if (!aTester.IsEditable())
1913 pErrorId = aTester.GetMessageId();
1914 }
1915
1916 // merged cells
1917 SCCOL nMergeStartX = nStartCol;
1918 SCROW nMergeStartY = nStartRow;
1919 SCCOL nMergeEndX = nEndCol;
1920 SCROW nMergeEndY = nEndRow;
1921 rDoc.ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
1922 rDoc.ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
1923
1924 if ( nMergeStartX != nStartCol || nMergeStartY != nStartRow )
1925 {
1926 // Disallow deleting parts of a merged cell.
1927 // Deleting the start is allowed (merge is removed), so the end doesn't have to be checked.
1928
1929 pErrorId = STR_MSSG_DELETECELLS_0;
1930 }
1931 if ( nMergeEndX != nEndCol || nMergeEndY != nEndRow )
1932 {
1933 // detect if the start of a merged cell is deleted, so the merge flags can be refreshed
1934
1935 bNeedRefresh = true;
1936 }
1937 }
1938
1939 if (pErrorId)
1940 {
1941 ErrorMessage(pErrorId);
1942 return;
1943 }
1944
1945 // proceed
1946
1947 weld::WaitObject aWait(GetViewData().GetDialogParent()); // important for TrackFormulas in UpdateReference
1948
1950
1951 ScDocumentUniquePtr pUndoDoc;
1952 std::unique_ptr<ScRefUndoData> pUndoData;
1953 if (bRecord)
1954 {
1955 pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
1956 pUndoDoc->InitUndo( rDoc, nTab, nTab, !bRows, bRows ); // row height
1957
1958 for (const sc::ColRowSpan & rSpan : aSpans)
1959 {
1960 SCCOLROW nStart = rSpan.mnStart;
1961 SCCOLROW nEnd = rSpan.mnEnd;
1962 if (bRows)
1963 rDoc.CopyToDocument( 0,nStart,nTab, rDoc.MaxCol(), nEnd,nTab, InsertDeleteFlags::ALL,false,*pUndoDoc );
1964 else
1965 rDoc.CopyToDocument( static_cast<SCCOL>(nStart),0,nTab,
1966 static_cast<SCCOL>(nEnd), rDoc.MaxRow(), nTab,
1967 InsertDeleteFlags::ALL,false,*pUndoDoc );
1968 }
1969
1970 // all Formulas because of references
1971 SCTAB nTabCount = rDoc.GetTableCount();
1972 pUndoDoc->AddUndoTab( 0, nTabCount-1 );
1973 rDoc.CopyToDocument( 0,0,0, rDoc.MaxCol(), rDoc.MaxRow(), MAXTAB, InsertDeleteFlags::FORMULA,false,*pUndoDoc );
1974
1975 pUndoData.reset(new ScRefUndoData( &rDoc ));
1976
1977 rDoc.BeginDrawUndo();
1978 }
1979
1980 std::vector<sc::ColRowSpan>::const_reverse_iterator ri = aSpans.rbegin(), riEnd = aSpans.rend();
1981 aFuncMark.SelectOneTable(nTab);
1982 for (; ri != riEnd; ++ri)
1983 {
1984 SCCOLROW nEnd = ri->mnEnd;
1985 SCCOLROW nStart = ri->mnStart;
1986
1987 if (bRows)
1988 {
1989 rDoc.DeleteObjectsInArea(0, nStart, rDoc.MaxCol(), nEnd, aFuncMark, true);
1990 rDoc.DeleteRow(0, nTab, rDoc.MaxCol(), nTab, nStart, static_cast<SCSIZE>(nEnd - nStart + 1));
1991 }
1992 else
1993 {
1994 rDoc.DeleteObjectsInArea(nStart, 0, nEnd, rDoc.MaxRow(), aFuncMark, true);
1995 rDoc.DeleteCol(0, nTab, rDoc.MaxRow(), nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd - nStart + 1));
1996 }
1997 }
1998
1999 if (bNeedRefresh)
2000 {
2001 SCCOLROW nFirstStart = aSpans[0].mnStart;
2002 SCCOL nStartCol = bRows ? 0 : static_cast<SCCOL>(nFirstStart);
2003 SCROW nStartRow = bRows ? static_cast<SCROW>(nFirstStart) : 0;
2004 SCCOL nEndCol = rDoc.MaxCol();
2005 SCROW nEndRow = rDoc.MaxRow();
2006
2007 rDoc.RemoveFlagsTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, ScMF::Hor | ScMF::Ver );
2008 rDoc.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab, true );
2009 }
2010
2011 if (bRecord)
2012 {
2013 pDocSh->GetUndoManager()->AddUndoAction(
2014 std::make_unique<ScUndoDeleteMulti>(
2015 pDocSh, bRows, bNeedRefresh, nTab, std::vector(aSpans), std::move(pUndoDoc), std::move(pUndoData)));
2016 }
2017
2018 if (!AdjustRowHeight(0, rDoc.MaxRow(), true))
2019 {
2020 if (bRows)
2021 {
2022 pDocSh->PostPaint(
2023 0, aSpans[0].mnStart, nTab,
2024 rDoc.MaxCol(), rDoc.MaxRow(), nTab, (PaintPartFlags::Grid | PaintPartFlags::Left));
2025 }
2026 else
2027 {
2028 pDocSh->PostPaint(
2029 static_cast<SCCOL>(aSpans[0].mnStart), 0, nTab,
2030 rDoc.MaxCol(), rDoc.MaxRow(), nTab, (PaintPartFlags::Grid | PaintPartFlags::Top));
2031 }
2032 }
2033
2034 aModificator.SetDocumentModified();
2035
2037
2038 // put cursor directly behind the first deleted range
2039 SCCOL nCurX = GetViewData().GetCurX();
2040 SCROW nCurY = GetViewData().GetCurY();
2041 if ( bRows )
2042 nCurY = aSpans[0].mnStart;
2043 else
2044 nCurX = static_cast<SCCOL>(aSpans[0].mnStart);
2045 SetCursor( nCurX, nCurY );
2046
2047 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
2048}
2049
2050// delete contents
2051
2053{
2054 ScViewData& rViewData = GetViewData();
2055 rViewData.SetPasteMode( ScPasteFlags::NONE );
2057
2058 // not editable because of matrix only? attribute OK nonetheless
2059 bool bOnlyNotBecauseOfMatrix;
2060 bool bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix );
2061 if ( !bEditable )
2062 {
2063 if ( !(bOnlyNotBecauseOfMatrix &&
2064 ((nFlags & (InsertDeleteFlags::ATTRIB | InsertDeleteFlags::EDITATTR)) == nFlags)) )
2065 {
2066 ErrorMessage(bOnlyNotBecauseOfMatrix ? STR_MATRIXFRAGMENTERR : STR_PROTECTIONERR);
2067 return;
2068 }
2069 }
2070
2071 ScRange aMarkRange;
2072 bool bSimple = false;
2073
2075 ScDocShell* pDocSh = GetViewData().GetDocShell();
2076 ScMarkData aFuncMark( GetViewData().GetMarkData() ); // local copy for UnmarkFiltered
2077 ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
2078
2079 bool bRecord =true;
2080 if (!rDoc.IsUndoEnabled())
2081 bRecord = false;
2082
2083 if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
2084 {
2085 aMarkRange.aStart.SetCol(GetViewData().GetCurX());
2086 aMarkRange.aStart.SetRow(GetViewData().GetCurY());
2087 aMarkRange.aStart.SetTab(GetViewData().GetTabNo());
2088 aMarkRange.aEnd = aMarkRange.aStart;
2089 if ( rDoc.HasAttrib( aMarkRange, HasAttrFlags::Merged ) )
2090 {
2091 aFuncMark.SetMarkArea( aMarkRange );
2092 }
2093 else
2094 bSimple = true;
2095 }
2096
2097 HideAllCursors(); // for if summary is cancelled
2098
2099 ScDocFunc& rDocFunc = pDocSh->GetDocFunc();
2100
2101 // Can we really be sure that we can pass the bApi parameter as false to DeleteCell() and
2102 // DeleteContents() here? (Meaning that this is interactive use.) Is this never invoked from
2103 // scripting and whatnot?
2104 if (bSimple)
2105 rDocFunc.DeleteCell(aMarkRange.aStart, aFuncMark, nFlags, bRecord, /*bApi=*/ false);
2106 else
2107 rDocFunc.DeleteContents(aFuncMark, nFlags, bRecord, /*bApi=*/ false);
2108
2109 pDocSh->UpdateOle(GetViewData());
2110
2111 if (ScModelObj* pModelObj = pDocSh->GetModel())
2112 {
2113 ScRangeList aChangeRanges;
2114 if ( bSimple )
2115 {
2116 aChangeRanges.push_back( aMarkRange );
2117 }
2118 else
2119 {
2120 aFuncMark.FillRangeListWithMarks( &aChangeRanges, false );
2121 }
2122
2124 HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "delete-content");
2125 else if (pModelObj)
2126 HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "data-area-invalidate");
2127 }
2128
2131
2132 if ( nFlags & InsertDeleteFlags::ATTRIB )
2133 {
2134 if ( nFlags & InsertDeleteFlags::CONTENTS )
2135 bFormatValid = false;
2136 else
2137 StartFormatArea(); // delete attribute is also attribute-change
2138 }
2139 OUString aStartAddress = aMarkRange.aStart.GetColRowString();
2140 OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
2141 collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "DELETE");
2142}
2143
2144// column width/row height (via header) - undo OK
2145
2147 bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, ScSizeMode eMode,
2148 sal_uInt16 nSizeTwips, bool bRecord, const ScMarkData* pMarkData )
2149{
2150 if (rRanges.empty())
2151 return;
2152
2153 // Use view's mark if none specified, but do not modify the original data,
2154 // i.e. no MarkToMulti() on that.
2155 ScMarkData aMarkData( pMarkData ? *pMarkData : GetViewData().GetMarkData());
2156
2157 ScDocShell* pDocSh = GetViewData().GetDocShell();
2158 ScDocument& rDoc = pDocSh->GetDocument();
2159 SCCOL nCurX = GetViewData().GetCurX();
2160 SCROW nCurY = GetViewData().GetCurY();
2161 SCTAB nFirstTab = aMarkData.GetFirstSelected();
2162 SCTAB nCurTab = GetViewData().GetTabNo();
2163 if (bRecord && !rDoc.IsUndoEnabled())
2164 bRecord = false;
2165
2166 ScDocShellModificator aModificator( *pDocSh );
2167
2168 bool bAllowed = true;
2169 for (const SCTAB& nTab : aMarkData)
2170 {
2171 bAllowed = std::all_of(rRanges.begin(), rRanges.end(),
2172 [&bWidth, &rDoc, &nTab](const sc::ColRowSpan& rRange) {
2173 bool bOnlyMatrix;
2174 bool bIsBlockEditable;
2175 if (bWidth)
2176 bIsBlockEditable = rDoc.IsBlockEditable(nTab, rRange.mnStart, 0, rRange.mnEnd, rDoc.MaxRow(), &bOnlyMatrix);
2177 else
2178 bIsBlockEditable = rDoc.IsBlockEditable(nTab, 0, rRange.mnStart, rDoc.MaxCol(), rRange.mnEnd, &bOnlyMatrix);
2179 return bIsBlockEditable || bOnlyMatrix;
2180 });
2181 if (!bAllowed)
2182 break;
2183 }
2184
2185 // Allow users to resize cols/rows in readonly docs despite the r/o state.
2186 // It is frustrating to be unable to see content in mis-sized cells.
2187 if( !bAllowed && !pDocSh->IsReadOnly() )
2188 {
2189 ErrorMessage(STR_PROTECTIONERR);
2190 return;
2191 }
2192
2193 SCCOLROW nStart = rRanges.front().mnStart;
2194 SCCOLROW nEnd = rRanges.back().mnEnd;
2195
2196 OnLOKSetWidthOrHeight(nStart, bWidth);
2197
2198 bool bFormula = false;
2199 if ( eMode == SC_SIZE_OPTIMAL )
2200 {
2201 const ScViewOptions& rOpts = GetViewData().GetOptions();
2202 bFormula = rOpts.GetOption( VOPT_FORMULAS );
2203 }
2204
2205 ScDocumentUniquePtr pUndoDoc;
2206 std::unique_ptr<ScOutlineTable> pUndoTab;
2207 std::vector<sc::ColRowSpan> aUndoRanges;
2208
2209 if ( bRecord )
2210 {
2211 rDoc.BeginDrawUndo(); // Drawing Updates
2212
2213 pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
2214 for (const SCTAB& nTab : aMarkData)
2215 {
2216 if (bWidth)
2217 {
2218 if ( nTab == nFirstTab )
2219 pUndoDoc->InitUndo( rDoc, nTab, nTab, true );
2220 else
2221 pUndoDoc->AddUndoTab( nTab, nTab, true );
2222 rDoc.CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
2223 static_cast<SCCOL>(nEnd), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE,
2224 false, *pUndoDoc );
2225 }
2226 else
2227 {
2228 if ( nTab == nFirstTab )
2229 pUndoDoc->InitUndo( rDoc, nTab, nTab, false, true );
2230 else
2231 pUndoDoc->AddUndoTab( nTab, nTab, false, true );
2232 rDoc.CopyToDocument( 0, nStart, nTab, rDoc.MaxCol(), nEnd, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc );
2233 }
2234 }
2235
2236 aUndoRanges = rRanges;
2237
2239 ScOutlineTable* pTable = rDoc.GetOutlineTable( nCurTab );
2240 if (pTable)
2241 pUndoTab.reset(new ScOutlineTable( *pTable ));
2242 }
2243
2245 aMarkData.MarkToMulti();
2246
2247 bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
2248 bool bOutline = false;
2249
2250 for (const SCTAB& nTab : aMarkData)
2251 {
2252 for (const sc::ColRowSpan & rRange : rRanges)
2253 {
2254 SCCOLROW nStartNo = rRange.mnStart;
2255 SCCOLROW nEndNo = rRange.mnEnd;
2256
2257 if ( !bWidth ) // height always blockwise
2258 {
2260 {
2261 bool bAll = ( eMode==SC_SIZE_OPTIMAL );
2262 bool bFiltered = false;
2263 if (!bAll)
2264 {
2265 // delete CRFlags::ManualSize for all in range,
2266 // then SetOptimalHeight with bShrink = FALSE
2267 for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow)
2268 {
2269 SCROW nLastRow = nRow;
2270 if (rDoc.RowHidden(nRow, nTab, nullptr, &nLastRow))
2271 {
2272 nRow = nLastRow;
2273 continue;
2274 }
2275
2276 CRFlags nOld = rDoc.GetRowFlags(nRow, nTab);
2277 if (nOld & CRFlags::ManualSize)
2278 rDoc.SetRowFlags(nRow, nTab, nOld & ~CRFlags::ManualSize);
2279 }
2280 }
2281 else
2282 {
2283 SCROW nLastRow = nStartNo;
2284 if (rDoc.RowFiltered(nStartNo, nTab, nullptr, &nLastRow)
2285 || nLastRow < nEndNo)
2286 bFiltered = true;
2287 }
2288
2289
2290 double nPPTX = GetViewData().GetPPTX();
2291 double nPPTY = GetViewData().GetPPTY();
2292 Fraction aZoomX = GetViewData().GetZoomX();
2293 Fraction aZoomY = GetViewData().GetZoomY();
2294
2295 ScSizeDeviceProvider aProv(pDocSh);
2296 if (aProv.IsPrinter())
2297 {
2298 nPPTX = aProv.GetPPTX();
2299 nPPTY = aProv.GetPPTY();
2300 aZoomX = aZoomY = Fraction( 1, 1 );
2301 }
2302
2303 sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice());
2304 aCxt.setForceAutoSize(bAll);
2305 aCxt.setExtraHeight(nSizeTwips);
2306 rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true);
2307
2308 if (bFiltered)
2309 ShowFilteredRows(rDoc, nTab, nStartNo, nEndNo, bShow);
2310
2311 // Manual-Flag already (re)set in SetOptimalHeight in case of bAll=sal_True
2312 // (set for Extra-Height, else reset).
2313 }
2314 else if ( eMode==SC_SIZE_DIRECT )
2315 {
2316 if (nSizeTwips)
2317 {
2318 rDoc.SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
2319 rDoc.SetManualHeight( nStartNo, nEndNo, nTab, true ); // height was set manually
2320 }
2321
2322 // tdf#36383 - Skip consecutive rows hidden by AutoFilter
2323 ShowFilteredRows(rDoc, nTab, nStartNo, nEndNo, nSizeTwips != 0);
2324
2325 if (!bShow && nStartNo <= nCurY && nCurY <= nEndNo && nTab == nCurTab)
2326 {
2327 nCurY = -1;
2328 }
2329 }
2330 else if ( eMode==SC_SIZE_SHOW )
2331 {
2332 rDoc.ShowRows( nStartNo, nEndNo, nTab, true );
2333 }
2334 }
2335 else // column width
2336 {
2337 for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
2338 {
2339 const bool bIsColHidden = rDoc.ColHidden(nCol, nTab);
2340 if ( eMode != SC_SIZE_VISOPT || !bIsColHidden )
2341 {
2342 sal_uInt16 nThisSize = nSizeTwips;
2343
2345 nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula );
2346 if ( nThisSize )
2347 rDoc.SetColWidth( nCol, nTab, nThisSize );
2348
2349 // tdf#131073 - Don't show hidden cols after setting optimal col width
2350 if (eMode == SC_SIZE_OPTIMAL)
2351 rDoc.ShowCol(nCol, nTab, !bIsColHidden);
2352 else
2353 rDoc.ShowCol( nCol, nTab, bShow );
2354
2355 if (!bShow && nCol == nCurX && nTab == nCurTab)
2356 {
2357 nCurX = -1;
2358 }
2359 }
2360 }
2361 }
2362
2363 // adjust outline
2364 if (bWidth)
2365 {
2366 if ( rDoc.UpdateOutlineCol( static_cast<SCCOL>(nStartNo),
2367 static_cast<SCCOL>(nEndNo), nTab, bShow ) )
2368 bOutline = true;
2369 }
2370 else
2371 {
2372 if ( rDoc.UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ) )
2373 bOutline = true;
2374 }
2375 }
2376 rDoc.SetDrawPageSize(nTab);
2377 }
2378
2379 if (!bOutline)
2380 pUndoTab.reset();
2381
2382 if (bRecord)
2383 {
2384 pDocSh->GetUndoManager()->AddUndoAction(
2385 std::make_unique<ScUndoWidthOrHeight>(
2386 pDocSh, aMarkData, nStart, nCurTab, nEnd, nCurTab,
2387 std::move(pUndoDoc), std::move(aUndoRanges), std::move(pUndoTab), eMode, nSizeTwips, bWidth));
2388 }
2389
2390 if (nCurX < 0)
2391 {
2392 MoveCursorRel( 1, 0, SC_FOLLOW_LINE, false );
2393 }
2394
2395 if (nCurY < 0)
2396 {
2397 MoveCursorRel( 0, 1, SC_FOLLOW_LINE, false );
2398 }
2399
2400 // fdo#36247 Ensure that the drawing layer's map mode scaling factors match
2401 // the new heights and widths.
2403
2404 for (const SCTAB& nTab : aMarkData)
2405 rDoc.UpdatePageBreaks( nTab );
2406
2407 bool bAffectsVisibility = (eMode != SC_SIZE_ORIGINAL && eMode != SC_SIZE_VISOPT);
2409 bWidth /* bColumns */, !bWidth /* bRows */,
2410 true /* bSizes*/, bAffectsVisibility /* bHidden */, bAffectsVisibility /* bFiltered */,
2411 false /* bGroups */, nCurTab);
2413
2414 {
2415 for (const SCTAB& nTab : aMarkData)
2416 {
2417 if (bWidth)
2418 {
2419 if (rDoc.HasAttrib( static_cast<SCCOL>(nStart),0,nTab,
2420 static_cast<SCCOL>(nEnd), rDoc.MaxRow(), nTab,
2422 nStart = 0;
2423 if (nStart > 0) // go upwards because of Lines and cursor
2424 --nStart;
2425 pDocSh->PostPaint( static_cast<SCCOL>(nStart), 0, nTab,
2426 rDoc.MaxCol(), rDoc.MaxRow(), nTab, PaintPartFlags::Grid | PaintPartFlags::Top );
2427 }
2428 else
2429 {
2430 if (rDoc.HasAttrib( 0,nStart,nTab, rDoc.MaxCol(), nEnd,nTab, HasAttrFlags::Merged | HasAttrFlags::Overlapped ))
2431 nStart = 0;
2432 if (nStart != 0)
2433 --nStart;
2434 pDocSh->PostPaint( 0, nStart, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab, PaintPartFlags::Grid | PaintPartFlags::Left );
2435 }
2436 }
2437
2438 pDocSh->UpdateOle(GetViewData());
2439 if( !pDocSh->IsReadOnly() )
2440 aModificator.SetDocumentModified();
2441 }
2442
2443 if ( !bWidth )
2444 return;
2445
2446 ScModelObj* pModelObj = pDocSh->GetModel();
2447
2449 return;
2450
2451 ScRangeList aChangeRanges;
2452 for (const SCTAB& nTab : aMarkData)
2453 {
2454 for (const sc::ColRowSpan & rRange : rRanges)
2455 {
2456 SCCOL nStartCol = rRange.mnStart;
2457 SCCOL nEndCol = rRange.mnEnd;
2458 for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
2459 {
2460 aChangeRanges.push_back( ScRange( nCol, 0, nTab ) );
2461 }
2462 }
2463 }
2464 HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize");
2465}
2466
2467// column width/row height (via marked range)
2468
2469void ScViewFunc::SetMarkedWidthOrHeight( bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips )
2470{
2471 ScMarkData& rMark = GetViewData().GetMarkData();
2472
2473 rMark.MarkToMulti();
2474 if (!rMark.IsMultiMarked())
2475 {
2476 SCCOL nCol = GetViewData().GetCurX();
2477 SCROW nRow = GetViewData().GetCurY();
2478 SCTAB nTab = GetViewData().GetTabNo();
2479 const ScRange aMarkRange( nCol, nRow, nTab);
2480 DoneBlockMode();
2481 InitOwnBlockMode( aMarkRange );
2482 rMark.SetMultiMarkArea( aMarkRange );
2484 }
2485
2486 std::vector<sc::ColRowSpan> aRanges =
2487 bWidth ? rMark.GetMarkedColSpans() : rMark.GetMarkedRowSpans();
2488
2489 SetWidthOrHeight(bWidth, aRanges, eMode, nSizeTwips);
2490
2491 rMark.MarkToSimple();
2492}
2493
2494void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
2495{
2497 // step size is also minimum
2498 constexpr sal_uInt16 nStepX = STD_COL_WIDTH / 5;
2499 sal_uInt16 nStepY = ScGlobal::nStdRowHeight;
2500
2501 ScModule* pScMod = SC_MOD();
2502 bool bAnyEdit = pScMod->IsInputMode();
2503 SCCOL nCol = GetViewData().GetCurX();
2504 SCROW nRow = GetViewData().GetCurY();
2505 SCTAB nTab = GetViewData().GetTabNo();
2506 ScDocShell* pDocSh = GetViewData().GetDocShell();
2507 ScDocument& rDoc = pDocSh->GetDocument();
2508
2509 bool bAllowed, bOnlyMatrix;
2510 if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
2511 bAllowed = rDoc.IsBlockEditable( nTab, nCol,0, nCol,rDoc.MaxRow(), &bOnlyMatrix );
2512 else
2513 bAllowed = rDoc.IsBlockEditable( nTab, 0,nRow, rDoc.MaxCol(), nRow, &bOnlyMatrix );
2514 if ( !bAllowed && !bOnlyMatrix )
2515 {
2516 ErrorMessage(STR_PROTECTIONERR);
2517 return;
2518 }
2519
2521
2522 sal_uInt16 nWidth = rDoc.GetColWidth( nCol, nTab );
2523 sal_uInt16 nHeight = rDoc.GetRowHeight( nRow, nTab );
2524 std::vector<sc::ColRowSpan> aRange(1, sc::ColRowSpan(0,0));
2525 if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
2526 {
2527 if (bOptimal) // width of this single cell
2528 {
2529 if ( bAnyEdit )
2530 {
2531 // when editing the actual entered width
2532 ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData().GetViewShell() );
2533 if (pHdl)
2534 {
2535 tools::Long nEdit = pHdl->GetTextSize().Width(); // in 0.01 mm
2536
2537 const ScPatternAttr* pPattern = rDoc.GetPattern( nCol, nRow, nTab );
2538 const SvxMarginItem& rMItem = pPattern->GetItem(ATTR_MARGIN);
2539 sal_uInt16 nMargin = rMItem.GetLeftMargin() + rMItem.GetRightMargin();
2540 if ( pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue() == SvxCellHorJustify::Left )
2541 nMargin = sal::static_int_cast<sal_uInt16>(
2542 nMargin + pPattern->GetItem(ATTR_INDENT).GetValue() );
2543
2544 nWidth = std::round(o3tl::convert(nEdit * pDocSh->GetOutputFactor(),
2546 + nMargin + STD_EXTRA_WIDTH;
2547 }
2548 }
2549 else
2550 {
2551 double nPPTX = GetViewData().GetPPTX();
2552 double nPPTY = GetViewData().GetPPTY();
2553 Fraction aZoomX = GetViewData().GetZoomX();
2554 Fraction aZoomY = GetViewData().GetZoomY();
2555
2556 ScSizeDeviceProvider aProv(pDocSh);
2557 if (aProv.IsPrinter())
2558 {
2559 nPPTX = aProv.GetPPTX();
2560 nPPTY = aProv.GetPPTY();
2561 aZoomX = aZoomY = Fraction( 1, 1 );
2562 }
2563
2564 tools::Long nPixel = rDoc.GetNeededSize( nCol, nRow, nTab, aProv.GetDevice(),
2565 nPPTX, nPPTY, aZoomX, aZoomY, true );
2566 sal_uInt16 nTwips = static_cast<sal_uInt16>( nPixel / nPPTX );
2567 if (nTwips != 0)
2568 nWidth = nTwips + STD_EXTRA_WIDTH;
2569 else
2570 nWidth = STD_COL_WIDTH;
2571 }
2572 }
2573 else // increment / decrement
2574 {
2575 if ( eDir == DIR_RIGHT )
2576 nWidth = sal::static_int_cast<sal_uInt16>( nWidth + nStepX );
2577 else if ( nWidth > nStepX )
2578 nWidth = sal::static_int_cast<sal_uInt16>( nWidth - nStepX );
2579 if ( nWidth < nStepX ) nWidth = nStepX;
2580 if ( nWidth > MAX_COL_WIDTH ) nWidth = MAX_COL_WIDTH;
2581 }
2582 aRange[0].mnStart = nCol;
2583 aRange[0].mnEnd = nCol;
2584 SetWidthOrHeight(true, aRange, SC_SIZE_DIRECT, nWidth);
2585
2586 // adjust height of this row if width demands/allows this
2587
2588 if (!bAnyEdit)
2589 {
2590 const ScPatternAttr* pPattern = rDoc.GetPattern( nCol, nRow, nTab );
2591 bool bNeedHeight =
2592 pPattern->GetItem( ATTR_LINEBREAK ).GetValue() ||
2593 pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue() == SvxCellHorJustify::Block;
2594 if (bNeedHeight)
2595 AdjustRowHeight( nRow, nRow, true );
2596 }
2597 }
2598 else
2599 {
2601 if (bOptimal)
2602 {
2604 nHeight = 0;
2605 }
2606 else
2607 {
2609 if ( eDir == DIR_BOTTOM )
2610 nHeight = sal::static_int_cast<sal_uInt16>( nHeight + nStepY );
2611 else if ( nHeight > nStepY )
2612 nHeight = sal::static_int_cast<sal_uInt16>( nHeight - nStepY );
2613 if ( nHeight < nStepY ) nHeight = nStepY;
2614 if ( nHeight > MAX_ROW_HEIGHT ) nHeight = MAX_ROW_HEIGHT;
2615 }
2616 aRange[0].mnStart = nRow;
2617 aRange[0].mnEnd = nRow;
2618 SetWidthOrHeight(false, aRange, eMode, nHeight);
2619 }
2620
2621 if ( bAnyEdit )
2622 {
2624 if ( rDoc.HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::NeedHeight ) )
2625 {
2626 ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData().GetViewShell() );
2627 if (pHdl)
2628 pHdl->SetModified(); // so that the height is adjusted with Enter
2629 }
2630 }
2631
2633}
2634
2636{
2637 if (nTab == TABLEID_DOC)
2638 return;
2639
2640 ScMarkData& rMark = GetViewData().GetMarkData();
2641 ScDocShell* pDocSh = GetViewData().GetDocShell();
2642 ScDocument& rDoc = pDocSh->GetDocument();
2643 ScDocFunc &rFunc = pDocSh->GetDocFunc();
2644 bool bUndo(rDoc.IsUndoEnabled());
2645
2646 // modifying several tabs is handled here
2647
2648 if (bUndo)
2649 {
2650 OUString aUndo = ScResId( STR_UNDO_PROTECT_TAB );
2651 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewData().GetViewShell()->GetViewShellId() );
2652 }
2653
2654 for (const auto& rTab : rMark)
2655 {
2656 rFunc.ProtectSheet(rTab, rProtect);
2657 }
2658
2659 if (bUndo)
2660 pDocSh->GetUndoManager()->LeaveListAction();
2661
2663}
2664
2665void ScViewFunc::ProtectDoc( const OUString& rPassword )
2666{
2667 ScDocShell* pDocSh = GetViewData().GetDocShell();
2668 ScDocFunc &rFunc = pDocSh->GetDocFunc();
2669
2670 rFunc.Protect( TABLEID_DOC, rPassword );
2671
2673}
2674
2675bool ScViewFunc::Unprotect( SCTAB nTab, const OUString& rPassword )
2676{
2677 ScMarkData& rMark = GetViewData().GetMarkData();
2678 ScDocShell* pDocSh = GetViewData().GetDocShell();
2679 ScDocument& rDoc = pDocSh->GetDocument();
2680 ScDocFunc &rFunc = pDocSh->GetDocFunc();
2681 bool bChanged = false;
2682 bool bUndo (rDoc.IsUndoEnabled());
2683
2684 if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 )
2685 {
2686 bChanged = rFunc.Unprotect( nTab, rPassword, false );
2687 if (bChanged && nTab != TABLEID_DOC)
2688 SetTabProtectionSymbol(nTab, false);
2689 }
2690 else
2691 {
2692 // modifying several tabs is handled here
2693
2694 if (bUndo)
2695 {
2696 OUString aUndo = ScResId( STR_UNDO_UNPROTECT_TAB );
2697 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewData().GetViewShell()->GetViewShellId() );
2698 }
2699
2700 for (const auto& rTab : rMark)
2701 {
2702 if ( rFunc.Unprotect( rTab, rPassword, false ) )
2703 {
2704 bChanged = true;
2705 SetTabProtectionSymbol( rTab, false);
2706 }
2707 }
2708
2709 if (bUndo)
2710 pDocSh->GetUndoManager()->LeaveListAction();
2711 }
2712
2713 if (bChanged)
2715
2716 return bChanged;
2717}
2718
2719void ScViewFunc::SetNoteText( const ScAddress& rPos, const OUString& rNoteText )
2720{
2721 GetViewData().GetDocShell()->GetDocFunc().SetNoteText( rPos, rNoteText, false );
2722}
2723
2724void ScViewFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate )
2725{
2726 GetViewData().GetDocShell()->GetDocFunc().ReplaceNote( rPos, rNoteText, pAuthor, pDate, false );
2727}
2728
2730{
2731 // not editable because of matrix only? attribute OK nonetheless
2732 bool bOnlyNotBecauseOfMatrix;
2733 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
2734 {
2735 ErrorMessage(STR_PROTECTIONERR);
2736 return;
2737 }
2738
2739 sal_uInt32 nNumberFormat = 0;
2740 ScViewData& rViewData = GetViewData();
2741 ScDocument& rDoc = rViewData.GetDocument();
2742 SvNumberFormatter* pNumberFormatter = rDoc.GetFormatTable();
2743 LanguageType eLanguage = ScGlobal::eLnge;
2744 ScPatternAttr aNewAttrs( rDoc.GetPool() );
2745
2746 // always take language from cursor position, even if there is a selection
2747
2748 sal_uInt32 nCurrentNumberFormat = rDoc.GetNumberFormat( rViewData.GetCurX(),
2749 rViewData.GetCurY(),
2750 rViewData.GetTabNo());
2751 const SvNumberformat* pEntry = pNumberFormatter->GetEntry( nCurrentNumberFormat );
2752 if (pEntry)
2753 eLanguage = pEntry->GetLanguage(); // else keep ScGlobal::eLnge
2754
2755 nNumberFormat = pNumberFormatter->GetStandardFormat( nFormatType, eLanguage ) + nAdd;
2756
2757 SfxItemSet& rSet = aNewAttrs.GetItemSet();
2758 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
2759 // ATTR_LANGUAGE_FORMAT not
2760 ApplySelectionPattern( aNewAttrs );
2761}
2762
2763void ScViewFunc::SetNumFmtByStr( const OUString& rCode )
2764{
2765 // not editable because of matrix only? attribute OK nonetheless
2766 bool bOnlyNotBecauseOfMatrix;
2767 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
2768 {
2769 ErrorMessage(STR_PROTECTIONERR);
2770 return;
2771 }
2772
2773 ScViewData& rViewData = GetViewData();
2774 ScDocument& rDoc = rViewData.GetDocument();
2775 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2776
2777 // language always from cursor position
2778
2779 sal_uInt32 nCurrentNumberFormat = rDoc.GetNumberFormat( rViewData.GetCurX(), rViewData.GetCurY(),
2780 rViewData.GetTabNo());
2781 const SvNumberformat* pEntry = pFormatter->GetEntry( nCurrentNumberFormat );
2782 LanguageType eLanguage = pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge;
2783
2784 // determine index for String
2785
2786 bool bOk = true;
2787 sal_uInt32 nNumberFormat = pFormatter->GetEntryKey( rCode, eLanguage );
2788 if ( nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
2789 {
2790 // enter new
2791
2792 OUString aFormat = rCode; // will be changed
2793 sal_Int32 nErrPos = 0;
2794 SvNumFormatType nType = SvNumFormatType::ALL;
2795 bOk = pFormatter->PutEntry( aFormat, nErrPos, nType, nNumberFormat, eLanguage );
2796 }
2797
2798 if ( bOk ) // valid format?
2799 {
2800 ScPatternAttr aNewAttrs( rDoc.GetPool() );
2801 SfxItemSet& rSet = aNewAttrs.GetItemSet();
2802 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
2804 ApplySelectionPattern( aNewAttrs );
2805 }
2806
2808}
2809
2811{
2812 // not editable because of matrix only? attribute OK nonetheless
2813 bool bOnlyNotBecauseOfMatrix;
2814 if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
2815 {
2816 ErrorMessage(STR_PROTECTIONERR);
2817 return;
2818 }
2819
2821 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2822
2823 SCCOL nCol = GetViewData().GetCurX();
2824 SCROW nRow = GetViewData().GetCurY();
2825 SCTAB nTab = GetViewData().GetTabNo();
2826
2827 sal_uInt32 nOldFormat = rDoc.GetNumberFormat( nCol, nRow, nTab );
2828 const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
2829 if (!pOldEntry)
2830 {
2831 OSL_FAIL("numberformat not found !!!");
2832 return;
2833 }
2834
2835 // what have we got here?
2836
2837 sal_uInt32 nNewFormat = nOldFormat;
2838 bool bError = false;
2839
2840 LanguageType eLanguage = pOldEntry->GetLanguage();
2841 bool bThousand, bNegRed;
2842 sal_uInt16 nPrecision, nLeading;
2843 pOldEntry->GetFormatSpecialInfo( bThousand, bNegRed, nPrecision, nLeading );
2844
2845 SvNumFormatType nOldType = pOldEntry->GetType();
2846 if ( SvNumFormatType::ALL == ( nOldType & (
2847 SvNumFormatType::NUMBER | SvNumFormatType::CURRENCY | SvNumFormatType::PERCENT | SvNumFormatType::SCIENTIFIC | SvNumFormatType::TIME ) ) )
2848 {
2849 // date, fraction, logical, text can not be changed
2850 bError = true;
2851 }
2852
2854 bool bWasStandard = ( nOldFormat == pFormatter->GetStandardIndex( eLanguage ) );
2855 OUString sExponentialStandardFormat = "";
2856 if (bWasStandard)
2857 {
2858 // with "Standard" the decimal places depend on cell content
2859 // 0 if empty or text -> no decimal places
2860 double nVal = rDoc.GetValue( ScAddress( nCol, nRow, nTab ) );
2861
2862 // the ways of the Numberformatters are unfathomable, so try:
2863 OUString aOut;
2864 const Color* pCol;
2865 const_cast<SvNumberformat*>(pOldEntry)->GetOutputString( nVal, aOut, &pCol );
2866
2867 nPrecision = 0;
2868 // 'E' for exponential is fixed in Numberformatter
2869 sal_Int32 nIndexE = aOut.indexOf('E');
2870 if ( nIndexE >= 0 )
2871 {
2872 sExponentialStandardFormat = aOut.copy( nIndexE ).replace( '-', '+' );
2873 for ( sal_Int32 i=1 ; i<sExponentialStandardFormat.getLength() ; i++ )
2874 {
2875 if ( sExponentialStandardFormat[i] >= '1' && sExponentialStandardFormat[i] <= '9' )
2876 sExponentialStandardFormat = sExponentialStandardFormat.replaceAt( i, 1, u"0" );
2877 }
2878 aOut = aOut.copy( 0, nIndexE ); // remove exponential part
2879 }
2880 OUString aDecSep( pFormatter->GetFormatDecimalSep( nOldFormat ) );
2881 sal_Int32 nPos = aOut.indexOf( aDecSep );
2882 if ( nPos >= 0 )
2883 nPrecision = aOut.getLength() - nPos - aDecSep.getLength();
2884 // else keep 0
2885 }
2886 else
2887 {
2888 if ( (nOldType & SvNumFormatType::SCIENTIFIC) && !bThousand &&
2889 (pOldEntry->GetFormatIntegerDigits()%3 == 0) && pOldEntry->GetFormatIntegerDigits() > 0 )
2890 bThousand = true;
2891 }
2892
2893 if (!bError)
2894 {
2895 if (bIncrement)
2896 {
2897 if (nPrecision<20)
2898 ++nPrecision; // increment
2899 else
2900 bError = true; // 20 is maximum
2901 }
2902 else
2903 {
2904 if (nPrecision)
2905 --nPrecision; // decrement
2906 else
2907 bError = true; // 0 is minimum
2908 }
2909 }
2910
2911 if (!bError)
2912 {
2913 OUString aNewPicture = pFormatter->GenerateFormat(nOldFormat, eLanguage,
2914 bThousand, bNegRed,
2915 nPrecision, nLeading)
2916 + sExponentialStandardFormat;
2917
2918 nNewFormat = pFormatter->GetEntryKey( aNewPicture, eLanguage );
2919 if ( nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
2920 {
2921 sal_Int32 nErrPos = 0;
2922 SvNumFormatType nNewType = SvNumFormatType::ALL;
2923 bool bOk = pFormatter->PutEntry( aNewPicture, nErrPos,
2924 nNewType, nNewFormat, eLanguage );
2925 OSL_ENSURE( bOk, "incorrect numberformat generated" );
2926 if (!bOk)
2927 bError = true;
2928 }
2929 }
2930
2931 if (!bError)
2932 {
2933 ScPatternAttr aNewAttrs( rDoc.GetPool() );
2934 SfxItemSet& rSet = aNewAttrs.GetItemSet();
2935 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2936 // ATTR_LANGUAGE_FORMAT not
2937 ApplySelectionPattern( aNewAttrs );
2938 }
2939}
2940
2941void ScViewFunc::ChangeIndent( bool bIncrement )
2942{
2943 ScViewData& rViewData = GetViewData();
2944 ScDocShell* pDocSh = rViewData.GetDocShell();
2945 ScMarkData& rMark = rViewData.GetMarkData();
2946
2947 ScMarkData aWorkMark = rMark;
2948 ScViewUtil::UnmarkFiltered( aWorkMark, pDocSh->GetDocument() );
2949 aWorkMark.MarkToMulti();
2950 if (!aWorkMark.IsMultiMarked())
2951 {
2952 SCCOL nCol = rViewData.GetCurX();
2953 SCROW nRow = rViewData.GetCurY();
2954 SCTAB nTab = rViewData.GetTabNo();
2955 aWorkMark.SetMultiMarkArea( ScRange(nCol,nRow,nTab) );
2956 }
2957
2958 bool bSuccess = pDocSh->GetDocFunc().ChangeIndent( aWorkMark, bIncrement, false );
2959 if (bSuccess)
2960 {
2961 pDocSh->UpdateOle(rViewData);
2963
2964 // stuff for sidebar panels
2965 SfxBindings& rBindings = GetViewData().GetBindings();
2966 rBindings.Invalidate( SID_H_ALIGNCELL );
2967 rBindings.Invalidate( SID_ATTR_ALIGN_INDENT );
2968 }
2969}
2970
2971bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol,
2972 const OUString& rType )
2973{
2974 // Type = P,R,C,F (and combinations)
2976
2977 bool bOk = false;
2978 ScDocShell* pDocSh = GetViewData().GetDocShell();
2979 ScDocument& rDoc = pDocSh->GetDocument();
2980 SCTAB nTab = GetViewData().GetTabNo();
2981 ScRangeName* pList = rDoc.GetRangeName();
2982
2984 auto pNewEntry = std::make_unique<ScRangeData>(
2985 rDoc, rName, rSymbol, ScAddress( GetViewData().GetCurX(),
2986 GetViewData().GetCurY(), nTab), nType );
2987 OUString aUpType = rType.toAsciiUpperCase();
2988 if ( aUpType.indexOf( 'P' ) != -1 )
2990 if ( aUpType.indexOf( 'R' ) != -1 )
2992 if ( aUpType.indexOf( 'C' ) != -1 )
2994 if ( aUpType.indexOf( 'F' ) != -1 )
2996 pNewEntry->AddType(nType);
2997
2998 if ( pNewEntry->GetErrCode() == FormulaError::NONE ) // text valid?
2999 {
3000 ScDocShellModificator aModificator( *pDocSh );
3001
3003
3004 // input available yet? Then remove beforehand (=change)
3005 ScRangeData* pData = pList->findByUpperName(ScGlobal::getCharClass().uppercase(rName));
3006 if (pData)
3007 { // take old Index
3008 pNewEntry->SetIndex(pData->GetIndex());
3009 pList->erase(*pData);
3010 }
3011
3012 // don't delete, insert took ownership, even on failure!
3013 if ( pList->insert( pNewEntry.release() ) )
3014 bOk = true;
3015
3016 rDoc.CompileHybridFormula();
3017
3018 aModificator.SetDocumentModified();
3019 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
3020 }
3021
3022 return bOk;
3023}
3024
3026{
3027 bool bDone = false;
3028 ScRange aRange;
3029 if ( GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE )
3030 bDone = GetViewData().GetDocShell()->GetDocFunc().CreateNames( aRange, nFlags, false );
3031
3032 if (!bDone)
3033 ErrorMessage(STR_CREATENAME_MARKERR);
3034}
3035
3037{
3039
3040 SCCOL nStartCol, nEndCol;
3041 SCROW nStartRow, nEndRow;
3042 SCTAB nDummy;
3043 if (GetViewData().GetSimpleArea(nStartCol,nStartRow,nDummy,nEndCol,nEndRow,nDummy) == SC_MARK_SIMPLE)
3044 {
3046 SCTAB nTab = GetViewData().GetTabNo();
3047 bool bOk;
3048 SCCOL i;
3049 SCROW j;
3050
3051 bOk = true;
3052 SCCOL nFirstCol = nStartCol;
3053 SCCOL nLastCol = nEndCol;
3054 if (nStartCol+1 < nEndCol) { ++nFirstCol; --nLastCol; }
3055 for (i=nFirstCol; i<=nLastCol && bOk; i++)
3056 if (!rDoc.HasStringData( i,nStartRow,nTab ))
3057 bOk = false;
3058 if (bOk)
3059 nFlags |= CreateNameFlags::Top;
3060 else // Bottom only if not Top
3061 {
3062 bOk = true;
3063 for (i=nFirstCol; i<=nLastCol && bOk; i++)
3064 if (!rDoc.HasStringData( i,nEndRow,nTab ))
3065 bOk = false;
3066 if (bOk)
3067 nFlags |= CreateNameFlags::Bottom;
3068 }
3069
3070 bOk = true;
3071 SCROW nFirstRow = nStartRow;
3072 SCROW nLastRow = nEndRow;
3073 if (nStartRow+1 < nEndRow) { ++nFirstRow; --nLastRow; }
3074 for (j=nFirstRow; j<=nLastRow && bOk; j++)
3075 if (!rDoc.HasStringData( nStartCol,j,nTab ))
3076 bOk = false;
3077 if (bOk)
3078 nFlags |= CreateNameFlags::Left;
3079 else // Right only if not Left
3080 {
3081 bOk = true;
3082 for (j=nFirstRow; j<=nLastRow && bOk; j++)
3083 if (!rDoc.HasStringData( nEndCol,j,nTab ))
3084 bOk = false;
3085 if (bOk)
3086 nFlags |= CreateNameFlags::Right;
3087 }
3088 }
3089
3090 if (nStartCol == nEndCol)
3092 if (nStartRow == nEndRow)
3094
3095 return nFlags;
3096}
3097
3099{
3100 ScAddress aPos( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
3101 ScDocShell* pDocSh = GetViewData().GetDocShell();
3102 if ( pDocSh->GetDocFunc().InsertNameList( aPos, false ) )
3103 pDocSh->UpdateOle(GetViewData());
3104}
3105
3107{
3108 ScDocShell* pDocShell = GetViewData().GetDocShell();
3109 ScRange aMarkRange;
3110 if (rSel.IsMultiMarked() )
3111 aMarkRange = rSel.GetMultiMarkArea();
3112 else
3113 aMarkRange = rSel.GetMarkArea();
3114
3115 bool bSetLines = false;
3116 bool bSetAlign = false;
3117 if ( pAttr )
3118 {
3119 const SfxItemSet& rNewSet = pAttr->GetItemSet();
3120 bSetLines = rNewSet.GetItemState( ATTR_BORDER ) == SfxItemState::SET ||
3121 rNewSet.GetItemState( ATTR_SHADOW ) == SfxItemState::SET;
3122 bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY ) == SfxItemState::SET;
3123 }
3124
3125 sal_uInt16 nExtFlags = 0;
3126 if ( bSetLines )
3127 nExtFlags |= SC_PF_LINES;
3128 if ( bSetAlign )
3129 nExtFlags |= SC_PF_WHOLEROWS;
3130
3131 SCCOL nStartCol = aMarkRange.aStart.Col();
3132 SCROW nStartRow = aMarkRange.aStart.Row();
3133 SCTAB nStartTab = aMarkRange.aStart.Tab();
3134 SCCOL nEndCol = aMarkRange.aEnd.Col();
3135 SCROW nEndRow = aMarkRange.aEnd.Row();
3136 SCTAB nEndTab = aMarkRange.aEnd.Tab();
3137 pDocShell->PostPaint( nStartCol, nStartRow, nStartTab,
3138 nEndCol, nEndRow, nEndTab,
3140 ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
3141 pTabViewShell->AdjustBlockHeight(false, const_cast<ScMarkData*>(&rSel));
3142}
3143
3144/* 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:2467
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:5735
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:558
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:457
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:220
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:434
double GetOutputFactor() const
Definition: docsh.hxx:358
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
Definition: docsh5.cxx:404
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2963
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:222
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:3456
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5105
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:898
const ScStyleSheet * GetSelectionStyle(const ScMarkData &rMark) const
Definition: document.cxx:4994
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4228
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3689
bool UpdateOutlineCol(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow)
Adapt Outline.
Definition: documen3.cxx:1424
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4187
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
Definition: document.cxx:6348
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5687
void BeginDrawUndo()
Definition: documen9.cxx:60
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:1044
bool IsSelectionEditable(const ScMarkData &rMark, bool *pOnlyNotBecauseOfMatrix=nullptr) const
Definition: document.cxx:5471
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:4574
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bApi)
Definition: document.cxx:4333
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6181
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
const ScStyleSheet * GetStyle(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4986
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:483
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3675
SC_DLLPUBLIC void ApplySelectionStyle(const ScStyleSheet &rStyle, const ScMarkData &rMark)
Definition: document.cxx:4948
SC_DLLPUBLIC void PreprocessRangeNameUpdate()
Definition: document10.cxx:295
SC_DLLPUBLIC void SetRowHeightRange(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4168
SC_DLLPUBLIC void ApplyPattern(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4852
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:473
SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow)
Definition: document.cxx:4365
SC_DLLPUBLIC bool HasStringData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3801
bool UpdateOutlineRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow)
Definition: documen3.cxx:1433
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:1374
void GetSelectionFrame(const ScMarkData &rMark, SvxBoxItem &rLineOuter, SvxBoxInfoItem &rLineInner)
Definition: document.cxx:5192
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:195
SC_DLLPUBLIC void ApplySelectionPattern(const ScPatternAttr &rAttr, const ScMarkData &rMark, ScEditDataArray *pDataArray=nullptr, bool *pIsChanged=nullptr)
Definition: document.cxx:5995
SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow)
Definition: document.cxx:4377
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:4307
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4496
SC_DLLPUBLIC CRFlags GetRowFlags(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4403
SC_DLLPUBLIC ScConditionalFormat * GetCondFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen4.cxx:844
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5289
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1009
bool IsBlockEditable(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool *pOnlyNotBecauseOfMatrix=nullptr, bool bNoMatrixAtAll=false) const
Definition: document.cxx:5447
void DeleteObjectsInArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData &rMark, bool bAnchored=false)
Definition: documen9.cxx:252
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:2072
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
Definition: document.cxx:3520
void ApplyStyle(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScStyleSheet &rStyle)
Definition: document.cxx:4918
void ApplySelectionFrame(const ScMarkData &rMark, const SvxBoxItem &rLineOuter, const SvxBoxInfoItem *pLineInner)
Definition: document.cxx:5874
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
Definition: documen3.cxx:745
void StyleSheetChanged(const SfxStyleSheetBase *pStyleSheet, bool bRemoved, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY)
Definition: document.cxx:5043
void RemoveEditTextCharAttribs(const ScAddress &rPos, const ScPatternAttr &rAttr)
Definition: document.cxx:3667
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:3658
SC_DLLPUBLIC void ExtendOverlapped(SCCOL &rStartCol, SCROW &rStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:5597
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:1599
SC_DLLPUBLIC void SetRowFlags(SCROW nRow, SCTAB nTab, CRFlags nNewFlags)
Definition: document.cxx:4383
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:174
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4512
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
Definition: document.cxx:4181
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4150
bool IsUndoEnabled() const
Definition: document.hxx:1594
const ScPatternAttr * GetSelectionPattern(const ScMarkData &rMark)
Definition: document.cxx:5186
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4789
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:4320
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4824
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
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:616
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:1010
sal_uInt32 GetCount() const
Definition: funcdesc.hxx:247
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
Definition: global.hxx:595
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:559
static ScFunctionList * GetStarCalcFunctionList()
Definition: global.cxx:624
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
Definition: global.cxx:898
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
bool IsInputMode() const
Definition: inputhdl.hxx:186
void ForgetLastPattern()
Definition: inputhdl.cxx:2337
Size GetTextSize()
Definition: inputhdl.cxx:4469
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:1352
bool IsInputMode()
Definition: scmod.cxx:1396
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:774
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:761
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:128
void DeleteUnchanged(const ScPatternAttr *pOldAttrs)
Definition: patattr.cxx:971
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
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:422
static void notifyAllViewsSheetGeomInvalidation(const SfxViewShell *pForViewShell, bool bColumns, bool bRows, bool bSizes, bool bHidden, bool bFiltered, bool bGroups, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY for all views whose current tab is equal to nCurrentTa...
Definition: tabvwshc.cxx:568
static void notifyAllViewsHeaderInvalidation(const SfxViewShell *pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex)
Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex.
Definition: tabvwshc.cxx:510
int getPart() const override
See SfxViewShell::getPart().
Definition: tabvwshc.cxx:447
const ScInputHandler * GetInputHandler() const
Definition: tabvwsh.hxx:237
void UpdateLayerLocks()
Definition: tabview5.cxx:351
void DoneBlockMode(bool bContinue=false)
Definition: tabview2.cxx:409
void ErrorMessage(TranslateId pGlobStrId)
Definition: tabview2.cxx:1446
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:2328
ScViewData & GetViewData()
Definition: tabview.hxx:341
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:2344
void ResetAutoSpellForContentChange()
Definition: tabview.cxx:2355
void UpdateCopySourceOverlay()
Definition: tabview2.cxx:1014
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:332
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:3124
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3141
SCROW GetCurYForTab(SCTAB nTabIndex) const
Definition: viewdata.cxx:1438
SCCOL GetCurXForTab(SCTAB nTabIndex) const
Definition: viewdata.cxx:1430
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
void SetCurYForTab(SCCOL nNewCurY, SCTAB nTabIndex)
Definition: viewdata.cxx:1454
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:1446
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:1181
ScDBFunc * GetView() const
Definition: viewdata.cxx:863
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:3129
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:2763
void DeleteCells(DelCellCmd eCmd)
Definition: viewfunc.cxx:1768
void ReplaceNote(const ScAddress &rPos, const OUString &rNoteText, const OUString *pAuthor, const OUString *pDate)
Definition: viewfunc.cxx:2724
void SetMarkedWidthOrHeight(bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips)
Definition: viewfunc.cxx:2469
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:1422
void ApplyUserItemSet(const SfxItemSet &rItemSet)
Definition: viewfunc.cxx:1383
void InsertNameList()
Definition: viewfunc.cxx:3098
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:1104
bool InsertCells(InsCellCmd eCmd, bool bRecord=true, bool bPartOfPaste=false)
Definition: viewfunc.cxx:1714
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:2146
void ProtectSheet(SCTAB nTab, const ScTableProtection &rProtect)
Definition: viewfunc.cxx:2635
void SetNumberFormat(SvNumFormatType nFormatType, sal_uLong nAdd=0)
Definition: viewfunc.cxx:2729
bool Unprotect(SCTAB nTab, const OUString &rPassword)
Definition: viewfunc.cxx:2675
const SfxStyleSheet * GetStyleSheetFromMarked()
Definition: viewfunc.cxx:1402
SvtScriptType GetSelectionScriptType()
Definition: viewfunc.cxx:881
void EnterValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rValue)
Definition: viewfunc.cxx:669
void ProtectDoc(const OUString &rPassword)
Definition: viewfunc.cxx:2665
void RemoveStyleSheetInUse(const SfxStyleSheetBase *pStyleSheet)
Definition: viewfunc.cxx:1517
bool bFormatValid
Definition: viewfunc.hxx:75
void ApplySelectionPattern(const ScPatternAttr &rAttr, bool bCursorOnly=false)
Definition: viewfunc.cxx:1214
void DeleteMulti(bool bRows)
Definition: viewfunc.cxx:1856
SC_DLLPUBLIC const ScPatternAttr * GetSelectionPattern()
Definition: viewfunc.cxx:907
void DeleteContents(InsertDeleteFlags nFlags)
Definition: viewfunc.cxx:2052
ScRange aFormatArea
Definition: viewfunc.hxx:74
void UpdateSelectionArea(const ScMarkData &rSel, ScPatternAttr *pAttr=nullptr)
Definition: viewfunc.cxx:3106
bool AdjustBlockHeight(bool bPaint=true, ScMarkData *pMarkData=nullptr)
Definition: viewfun2.cxx:115
void OnLOKInsertDeleteColumn(SCCOL nStartCol, tools::Long nOffset)
Definition: viewfunc.cxx:1570
void UpdateStyleSheetInUse(const SfxStyleSheetBase *pStyleSheet)
Definition: viewfunc.cxx:1543
void CreateNames(CreateNameFlags nFlags)
Definition: viewfunc.cxx:3025
void OnLOKInsertDeleteRow(SCROW nStartRow, tools::Long nOffset)
Definition: viewfunc.cxx:1627
void ChangeNumFmtDecimals(bool bIncrement)
Definition: viewfunc.cxx:2810
void EnterMatrix(const OUString &rString, ::formula::FormulaGrammar::Grammar eGram)
Definition: viewfunc.cxx:837
void GetSelectionFrame(std::shared_ptr< SvxBoxItem > &rLineOuter, std::shared_ptr< SvxBoxInfoItem > &rLineInner)
Definition: viewfunc.cxx:933
void ModifyCellSize(ScDirection eDir, bool bOptimal)
Definition: viewfunc.cxx:2494
void SetNoteText(const ScAddress &rPos, const OUString &rNoteText)
Definition: viewfunc.cxx:2719
void ApplyAttr(const SfxPoolItem &rAttrItem, bool bAdjustBlockHeight=true)
Definition: viewfunc.cxx:1076
void DoAutoAttributes(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bAttrChanged)
Definition: viewfunc.cxx:219
void OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth)
Definition: viewfunc.cxx:1684
bool InsertName(const OUString &rName, const OUString &rSymbol, const OUString &rType)
Definition: viewfunc.cxx:2971
void StartFormatArea()
Definition: viewfunc.cxx:132
CreateNameFlags GetCreateNameFlags()
Definition: viewfunc.cxx:3036
void ApplyAttributes(const SfxItemSet *pDialogSet, const SfxItemSet *pOldSet, bool bAdjustBlockHeight=true)
Definition: viewfunc.cxx:964
void ChangeIndent(bool bIncrement)
Definition: viewfunc.cxx:2941
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, bool bApi)
Definition: viewfun2.cxx:193
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:89
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:79
#define SC_PF_TESTMERGE
Definition: docsh.hxx:78
#define SC_PF_LINES
Definition: docsh.hxx:77
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2722
@ 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:276
DelCellCmd
Definition: global.hxx:280
InsCellCmd
Definition: global.hxx:289
@ INS_INSROWS_AFTER
Definition: global.hxx:295
@ INS_INSCOLS_AFTER
Definition: global.hxx:296
@ INS_INSCOLS_BEFORE
Definition: global.hxx:293
@ INS_INSROWS_BEFORE
Definition: global.hxx:292
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:350
@ SC_SIZE_DIRECT
Definition: global.hxx:351
@ SC_SIZE_OPTIMAL
Definition: global.hxx:352
@ SC_SIZE_VISOPT
Definition: global.hxx:354
@ SC_SIZE_ORIGINAL
Definition: global.hxx:355
@ SC_SIZE_SHOW
Definition: global.hxx:353
ScDirection
Definition: global.hxx:342
@ DIR_LEFT
Definition: global.hxx:346
@ DIR_RIGHT
Definition: global.hxx:344
@ DIR_BOTTOM
Definition: global.hxx:343
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:475
void NotifyIfChangesListeners(const ScDocShell &rDocShell, const ScRange &rRange, const OUString &rType=OUString("cell-change"))
Definition: docsh.hxx:508
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:500
bool getMustPropagateChangesModel(ScModelObj *pModelObj)
Definition: docsh.hxx:495
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:249
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:1184
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