36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include <com/sun/star/script/ModuleType.hpp>
38 #include <com/sun/star/script/XLibraryContainer.hpp>
39 #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
41 #include <docfunc.hxx>
44 #include <strings.hrc>
58 #include <globstr.hrc>
64 #include <stlpool.hxx>
65 #include <stlsheet.hxx>
68 #include <uiitems.hxx>
77 #include <compiler.hxx>
83 #include <progress.hxx>
87 #include <tokenarray.hxx>
114 rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoDraw>( std::move(pUndoAction), &rDocShell ) );
115 rDocShell.SetDrawModified();
120 for (
SCTAB nTab=0; nTab<nTabCount; nTab++)
141 SfxViewShell* pSomeViewForThisDoc = rDocShell.GetBestViewShell(
false);
162 if (pTabViewShell && pTabViewShell->
GetDocId() == pSomeViewForThisDoc->
GetDocId())
179 if ( bPaint && bChanged )
187 pSomeViewForThisDoc,
false ,
true ,
true ,
188 false ,
false ,
false , nTab);
198 rDocShell.MakeDrawLayer();
207 pModel->BeginCalcUndo(
false);
209 std::unique_ptr<SdrUndoGroup> pUndo;
211 pUndo = pModel->GetCalcUndo();
218 rDocShell.GetUndoManager()->AddUndoAction(
219 std::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), &aOperation ) );
222 SfxBindings* pBindings = rDocShell.GetViewBindings();
224 pBindings->
Invalidate( SID_DETECTIVE_REFRESH );
246 pModel->BeginCalcUndo(
false);
248 std::unique_ptr<SdrUndoGroup> pUndo;
250 pUndo = pModel->GetCalcUndo();
257 rDocShell.GetUndoManager()->AddUndoAction(
258 std::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), &aOperation ) );
261 SfxBindings* pBindings = rDocShell.GetViewBindings();
263 pBindings->
Invalidate( SID_DETECTIVE_REFRESH );
273 rDocShell.MakeDrawLayer();
283 pModel->BeginCalcUndo(
false);
285 std::unique_ptr<SdrUndoGroup> pUndo;
287 pUndo = pModel->GetCalcUndo();
294 rDocShell.GetUndoManager()->AddUndoAction(
295 std::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), &aOperation ) );
298 SfxBindings* pBindings = rDocShell.GetViewBindings();
300 pBindings->
Invalidate( SID_DETECTIVE_REFRESH );
322 pModel->BeginCalcUndo(
false);
324 std::unique_ptr<SdrUndoGroup> pUndo;
326 pUndo = pModel->GetCalcUndo();
333 rDocShell.GetUndoManager()->AddUndoAction(
334 std::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), &aOperation ) );
337 SfxBindings* pBindings = rDocShell.GetViewBindings();
339 pBindings->
Invalidate( SID_DETECTIVE_REFRESH );
349 rDocShell.MakeDrawLayer();
359 pModel->BeginCalcUndo(
false);
361 std::unique_ptr<SdrUndoGroup> pUndo;
363 pUndo = pModel->GetCalcUndo();
370 rDocShell.GetUndoManager()->AddUndoAction(
371 std::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), &aOperation ) );
374 SfxBindings* pBindings = rDocShell.GetViewBindings();
376 pBindings->
Invalidate( SID_DETECTIVE_REFRESH );
386 rDocShell.MakeDrawLayer();
394 pModel->BeginCalcUndo(
false);
397 std::unique_ptr<SdrUndoGroup> pUndo;
399 pUndo = pModel->GetCalcUndo();
405 pUndo->SetComment(
ScResId( STR_UNDO_DETINVALID ) );
406 rDocShell.GetUndoManager()->AddUndoAction( std::move(pUndo) );
412 VclMessageType::Info, VclButtonsType::Ok,
413 ScResId(STR_DETINVALID_OVERFLOW)));
433 pModel->BeginCalcUndo(
false);
435 std::unique_ptr<SdrUndoGroup> pUndo;
437 pUndo = pModel->GetCalcUndo();
441 std::unique_ptr<ScDetOpList> pUndoList;
442 if (bUndo && pOldList)
449 rDocShell.GetUndoManager()->AddUndoAction(
450 std::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo),
nullptr, std::move(pUndoList) ) );
453 SfxBindings* pBindings = rDocShell.GetViewBindings();
455 pBindings->
Invalidate( SID_DETECTIVE_REFRESH );
467 if ( pList && pList->
Count() )
469 rDocShell.MakeDrawLayer();
478 for (
SCTAB nTab=0; nTab<nTabCount; nTab++)
484 for (
size_t i=0;
i < nCount; ++
i)
494 aFunc.ShowSucc( nCol, nRow );
497 aFunc.DeleteSucc( nCol, nRow );
500 aFunc.ShowPred( nCol, nRow );
503 aFunc.DeletePred( nCol, nRow );
506 aFunc.ShowError( nCol, nRow );
509 OSL_FAIL(
"wrong operation in DetectiveRefresh");
515 std::unique_ptr<SdrUndoGroup> pUndo = pModel->
GetCalcUndo();
518 pUndo->SetComment(
ScResId( STR_UNDO_DETREFRESH ) );
520 rDocShell.GetUndoManager()->AddUndoAction(
521 std::make_unique<ScUndoDraw>( std::move(pUndo), &rDocShell ),
525 rDocShell.SetDrawModified();
536 vector<ScTokenRef> aRefTokens;
537 if (rSrcRanges.
empty())
541 for (
size_t i = 0,
n = rSrcRanges.
size();
i <
n; ++
i)
546 aDetFunc.GetAllPreds(
551 aDetFunc.GetAllSuccs(
555 rRefTokens.
swap(aRefTokens);
575 OSL_FAIL(
"ScDocFunc::DeleteContents without markings");
601 ScRange aExtendedRange(aMarkRange);
608 sal_uInt16 nExtFlags = 0;
610 rDocShell.UpdatePaintExt( nExtFlags, aMarkRange );
619 if (bRecord && bDrawUndo)
633 std::shared_ptr<ScSimpleUndo::DataSpansType> pDataSpans;
647 rDocShell.GetUndoManager(), &rDocShell, aMultiMark, aExtendedRange,
648 std::move(pUndoDoc), nFlags, pDataSpans, bMulti, bDrawUndo);
651 if (!AdjustRowHeight( aExtendedRange ))
672 if (!aTester.IsEditable())
674 rDocShell.ErrorMessage(aTester.GetMessageId());
681 sal_uInt16 nExtFlags = 0;
683 rDocShell.UpdatePaintExt(nExtFlags, rPos);
693 if (bDrawUndo && bRecord)
700 std::shared_ptr<ScSimpleUndo::DataSpansType> pDataSpans;
714 rDocShell.GetUndoManager(), &rDocShell, rMark, rPos, std::move(pUndoDoc),
715 nFlags, pDataSpans,
false, bDrawUndo);
718 if (!AdjustRowHeight(rPos))
758 pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
759 for (
const auto& rTab : rMark)
761 if (rTab >= nTabCount)
764 if (rTab != nStartTab)
765 pUndoDoc->AddUndoTab( rTab, rTab );
768 ScRange aCopyRange = aMarkRange;
773 rDocShell.GetUndoManager()->AddUndoAction(
774 std::make_unique<ScUndoTransliterate>( &rDocShell, aMultiMark, std::move(pUndoDoc), nType ) );
779 if (!AdjustRowHeight( aMarkRange ))
794 if (!aTester.IsEditable())
797 rDocShell.ErrorMessage(aTester.GetMessageId());
822 aOldValues.push_back(aOldValue);
830 rDocShell.GetUndoManager()->AddUndoAction(
831 std::make_unique<ScUndoEnterData>(&rDocShell, rPos, aOldValues, rText,
nullptr));
835 AdjustRowHeight(
ScRange(rPos) );
837 rDocShell.PostPaintCell( rPos );
842 NotifyInputHandler( rPos );
866 aOldVal.
assign(rDoc, rPos);
874 aNewVal.
assign(rDoc, rPos);
875 pUndoMgr->
AddUndoAction(std::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
879 AdjustRowHeight(rPos);
881 rDocShell.PostPaintCell( rPos );
886 NotifyInputHandler( rPos );
896 SCROW nLastRow = rPos.
Row() + aVals.size() - 1;
897 if (nLastRow > rDoc.
MaxRow())
908 std::unique_ptr<sc::UndoSetCells> pUndoObj(
new sc::UndoSetCells(&rDocShell, rPos));
910 pUndoObj->SetNewValues(aVals);
922 NotifyInputHandler(rPos);
935 aOldVal.
assign(rDoc, rPos);
945 aNewVal.
assign(rDoc, rPos);
946 pUndoMgr->
AddUndoAction(std::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
950 AdjustRowHeight(rPos);
952 rDocShell.PostPaintCell( rPos );
957 NotifyInputHandler( rPos );
972 aOldVal.
assign(rDoc, rPos);
980 aNewVal.
assign(rDoc, rPos);
981 pUndoMgr->
AddUndoAction(std::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
985 AdjustRowHeight(rPos);
987 rDocShell.PostPaintCell( rPos );
992 NotifyInputHandler( rPos );
1006 return SetEditCell(rPos, *pEditText, bInteraction);
1009 return SetStringCell(rPos, rStr, bInteraction);
1014 std::unique_ptr<ScFormulaCell> xCell(pCell);
1024 aOldVal.
assign(rDoc, rPos);
1044 aNewVal.
assign(rDoc, rPos);
1045 pUndoMgr->
AddUndoAction(std::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
1049 AdjustRowHeight(rPos);
1051 rDocShell.PostPaintCell( rPos );
1056 NotifyInputHandler( rPos );
1065 const size_t nLength = rCells.size();
1076 std::unique_ptr<sc::UndoSetCells> pUndoObj;
1091 for (
auto* pCell : rCells)
1095 pCell->SetDirtyVar();
1102 pUndoObj->SetNewValues(rCells);
1112 NotifyInputHandler( rPos );
1138 struct ScMyRememberItem
1143 ScMyRememberItem(
const SfxItemSet& rItemSet, sal_Int32 nTempIndex) :
1144 nIndex(nTempIndex), aItemSet(rItemSet) {}
1168 std::vector<std::unique_ptr<ScMyRememberItem>> aRememberItems;
1175 for (sal_Int32
i=0;
i<nCount;
i++)
1180 if ( !bLoseContent )
1182 aRememberItems.push_back(std::make_unique<ScMyRememberItem>(rEngine.
GetParaAttribs(
i),
i));
1190 bRet = SetEditCell(rPos, *pNewData, !bApi);
1193 for (
const auto& rxItem : aRememberItems)
1199 if ( bUpdateMode && !bLoseContent )
1204 OUString aText = rEngine.
GetText();
1205 if (aText.isEmpty())
1207 bool bNumFmtSet =
false;
1208 bRet = SetNormalString( bNumFmtSet, rPos, aText, bApi );
1211 bRet = SetStringCell(rPos, aText, !bApi);
1222 if ( aPattern.GetItemSet().Count() > 0 )
1226 aMark.SetMarkArea(
ScRange( rPos ) );
1227 ApplyAttributes( aMark, aPattern, bApi );
1232 const ScAddress& rPos,
const OUString& rText,
bool bInterpret,
bool bEnglish,
bool bApi,
1242 ::std::unique_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
1255 bSet = SetValueCell(rPos, aRes.
mfValue, !bApi);
1258 bSet = SetStringOrEditCell(rPos, aRes.
maText, !bApi);
1266 else if (!rText.isEmpty())
1268 bSet = SetStringOrEditCell(rPos, rText, !bApi);
1273 bool bNumFmtSet =
false;
1274 bSet = SetNormalString( bNumFmtSet, rPos, rText, bApi );
1290 rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideNote>( rDocShell, rPos, bShow ) );
1298 if (
ScDrawView* pDrawView = pViewData->GetScDrawView())
1299 pDrawView->SyncForGrid( pNote->
GetCaption());
1302 rDocShell.SetDocumentModified();
1313 if (!aTester.IsEditable())
1316 rDocShell.ErrorMessage(aTester.GetMessageId());
1323 pNote->SetText( rPos, aNewText );
1329 rDocShell.PostPaintCell( rPos );
1338 if (aTester.IsEditable())
1344 std::unique_ptr<ScPostIt> pOldNote = rDoc.
ReleaseNote( rPos );
1345 sal_uInt32 nNoteId = 0;
1348 nNoteId = pOldNote->GetId();
1350 pOldNote->GetOrCreateCaption( rPos );
1352 aOldData = pOldNote->GetNoteData();
1360 bool hadOldNote(pOldNote);
1368 if( pAuthor ) pNewNote->
SetAuthor( *pAuthor );
1369 if( pDate ) pNewNote->
SetDate( *pDate );
1377 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoReplaceNote>( rDocShell, rPos, aOldData, aNewData, pDrawLayer->
GetCalcUndo() ) );
1380 rDocShell.PostPaintCell( rPos );
1390 &rDoc, rPos, pNewNote);
1395 rDocShell.ErrorMessage(aTester.GetMessageId());
1404 std::unique_ptr<ScPostIt> pOldNote = rDoc.
ReleaseNote( rPos );
1405 SAL_WARN_IF(pOldNote,
"sc.ui",
"imported data has >1 notes on same cell? at pos " << rPos);
1421 bool bRecord =
true;
1428 bool bOnlyNotBecauseOfMatrix;
1430 && !bOnlyNotBecauseOfMatrix )
1433 rDocShell.ErrorMessage(STR_PROTECTIONERR);
1451 pUndoDoc->InitUndo( rDoc, aMultiRange.
aStart.
Tab(), aMultiRange.
aEnd.
Tab() );
1454 rDocShell.GetUndoManager()->AddUndoAction(
1455 std::make_unique<ScUndoSelectionAttr>(
1459 std::move(pUndoDoc), bMulti, &rPattern ) );
1463 sal_uInt16 nExtFlags = 0;
1464 if ( !bImportingXML )
1465 rDocShell.UpdatePaintExt( nExtFlags, aMultiRange );
1467 bool bChanged =
false;
1472 if ( !bImportingXML )
1473 rDocShell.UpdatePaintExt( nExtFlags, aMultiRange );
1475 if (!AdjustRowHeight( aMultiRange ))
1490 bool bRecord =
true;
1497 bool bOnlyNotBecauseOfMatrix;
1499 && !bOnlyNotBecauseOfMatrix )
1502 rDocShell.ErrorMessage(STR_PROTECTIONERR);
1507 rStyleName, SfxStyleFamily::Para ));
1525 pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
1526 for (
const auto& rTab : rMark)
1528 if (rTab >= nTabCount)
1531 if (rTab != nStartTab)
1532 pUndoDoc->AddUndoTab( rTab, rTab );
1535 ScRange aCopyRange = aMultiRange;
1540 rDocShell.GetUndoManager()->AddUndoAction(
1541 std::make_unique<ScUndoSelectionStyle>(
1542 &rDocShell, rMark, aMultiRange, rStyleName, std::move(pUndoDoc) ) );
1548 if (!AdjustRowHeight( aMultiRange ))
1578 aRange.aStart.SetCol(0);
1579 aRange.aEnd.SetCol(rDoc.
MaxCol());
1584 auto bIntersects = std::any_of(rMarkData.
begin(), rMarkData.
end(), [&pDPs, &aRange](
const SCTAB& rTab) {
1591 if (aRange.aStart.Row() < 0)
1595 if (aRange.aStart.Row() == 0)
1600 aTest.aStart.IncRow(-1);
1601 aTest.aEnd.SetRow(aTest.aStart.Row());
1602 for (
const auto& rTab : rMarkData)
1604 aTest.aStart.SetTab(rTab);
1605 aTest.aEnd.SetTab(rTab);
1613 aRange.aStart.SetRow(0);
1614 aRange.aEnd.SetRow(rDoc.
MaxRow());
1619 auto bIntersects = std::any_of(rMarkData.begin(), rMarkData.end(), [&pDPs, &aRange](
const SCTAB& rTab) {
1620 return pDPs->
IntersectsTableByRows(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Row(), rTab); });
1626 if (aRange.aStart.Col() < 0)
1630 if (aRange.aStart.Col() == 0)
1635 aTest.aStart.IncCol(-1);
1636 aTest.aEnd.SetCol(aTest.aStart.Col());
1637 for (
const auto& rTab : rMarkData)
1639 aTest.aStart.SetTab(rTab);
1640 aTest.aEnd.SetTab(rTab);
1673 aRange.aStart.SetCol(0);
1674 aRange.aEnd.SetCol(rDoc.
MaxCol());
1679 auto bIntersects = std::any_of(rMarkData.
begin(), rMarkData.
end(), [&pDPs, &aRange](
const SCTAB& rTab) {
1686 for (
const auto& rTab : rMarkData)
1688 aTest.aStart.SetTab(rTab);
1689 aTest.aEnd.SetTab(rTab);
1697 aRange.aStart.SetRow(0);
1698 aRange.aEnd.SetRow(rDoc.
MaxRow());
1703 auto bIntersects = std::any_of(rMarkData.begin(), rMarkData.end(), [&pDPs, &aRange](
const SCTAB& rTab) {
1704 return pDPs->
IntersectsTableByRows(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Row(), rTab); });
1710 for (
const auto& rTab : rMarkData)
1712 aTest.aStart.SetTab(rTab);
1713 aTest.aEnd.SetTab(rTab);
1728 bool bRecord,
bool bApi,
bool bPartOfPaste )
1733 if (rDocShell.GetDocument().GetChangeTrack() &&
1739 SAL_WARN(
"sc.ui",
"ScDocFunc::InsertCells - no change-tracking of partial cell shift");
1743 ScRange aTargetRange( rRange );
1773 OSL_FAIL(
"invalid row in InsertCells");
1778 SCCOL nPaintStartCol = nStartCol;
1779 SCROW nPaintStartRow = nStartRow;
1780 SCCOL nPaintEndCol = nEndCol;
1781 SCROW nPaintEndRow = nEndRow;
1786 SCCOL nCursorCol = 0;
1787 SCROW nCursorRow = 0;
1808 if( nCount == nEndTab+1 )
1810 aMark.SelectTable(
i,
true );
1818 for (
const auto& rTab : aMark)
1820 if (rTab >= nTabCount)
1827 SCTAB nSelCount = aMark.GetSelectCount();
1831 SCCOL nMergeTestStartCol = nStartCol;
1832 SCROW nMergeTestStartRow = nStartRow;
1833 SCCOL nMergeTestEndCol = nEndCol;
1834 SCROW nMergeTestEndRow = nEndRow;
1836 ScRange aExtendMergeRange( aTargetRange );
1842 nMergeTestEndCol = aExtendMergeRange.
aEnd.
Col();
1843 nMergeTestEndRow = aExtendMergeRange.
aEnd.
Row();
1844 nPaintEndCol = nMergeTestEndCol;
1845 nPaintEndRow = nMergeTestEndRow;
1850 nMergeTestStartCol = 0;
1851 nMergeTestEndCol = rDoc.
MaxCol();
1855 nMergeTestStartRow = 0;
1856 nMergeTestEndRow = rDoc.
MaxRow();
1859 nMergeTestEndRow = rDoc.
MaxRow();
1861 nMergeTestEndCol = rDoc.
MaxCol();
1863 bool bNeedRefresh =
false;
1890 rDoc, nMergeTestStartCol, nMergeTestStartRow, nEditTestEndCol, nEditTestEndRow, aMark);
1901 if (!canInsertCellsByPivot(aTargetRange, aMark, eCmd, rDoc))
1904 rDocShell.ErrorMessage(STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE);
1911 std::unique_ptr<ScRefUndoData> pUndoData;
1915 pRefUndoDoc->InitUndo( rDoc, 0, nTabCount-1 );
1926 bool bInsertMerge =
false;
1927 std::vector<ScRange> qIncreaseRange;
1928 OUString aUndo =
ScResId( STR_UNDO_INSERTCELLS );
1934 rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo, 0, nViewShellId );
1936 std::unique_ptr<ScUndoRemoveMerge> pUndoRemoveMerge;
1938 for (
const SCTAB i : aMark)
1946 bNeedRefresh =
true;
1948 SCCOL nMergeStartCol = nMergeTestStartCol;
1949 SCROW nMergeStartRow = nMergeTestStartRow;
1950 SCCOL nMergeEndCol = nMergeTestEndCol;
1951 SCROW nMergeEndRow = nMergeTestEndRow;
1953 rDoc.
ExtendMerge( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow,
i );
1954 rDoc.
ExtendOverlapped( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow,
i );
1956 if(( eCmd ==
INS_CELLSDOWN && ( nMergeStartCol != nMergeTestStartCol || nMergeEndCol != nMergeTestEndCol )) ||
1957 (eCmd ==
INS_CELLSRIGHT && ( nMergeStartRow != nMergeTestStartRow || nMergeEndRow != nMergeTestEndRow )) )
1960 rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
1961 rDocShell.GetUndoManager()->LeaveListAction();
1965 SCCOL nTestCol = -1;
1966 SCROW nTestRow1 = -1;
1967 SCROW nTestRow2 = -1;
1969 ScDocAttrIterator aTestIter( rDoc,
i, nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow );
1970 ScRange aExtendRange( nMergeTestStartCol, nMergeTestStartRow,
i, nMergeTestEndCol, nMergeTestEndRow,
i );
1972 while ( ( pPattern = aTestIter.
GetNext( nTestCol, nTestRow1, nTestRow2 ) ) !=
nullptr )
1979 ScRange aRange( nTestCol, nTestRow1,
i );
1983 if( nTestRow1 < nTestRow2 && nNewFlags ==
ScMF::Hor )
1985 for(
SCROW nTestRow = nTestRow1; nTestRow <= nTestRow2; nTestRow++ )
1987 ScRange aTestRange( nTestCol, nTestRow,
i );
1991 if( !aExtendRange.
In( aMergeRange ) )
1993 qIncreaseRange.push_back( aTestRange );
1994 bInsertMerge =
true;
2001 if( !aExtendRange.
In( aMergeRange ) )
2003 qIncreaseRange.push_back( aRange );
2005 bInsertMerge =
true;
2014 nStartRow = aExtendMergeRange.
aStart.
Row();
2015 nEndRow = aExtendMergeRange.
aEnd.
Row();
2018 nEndCol = nMergeTestEndCol;
2028 nStartCol = aExtendMergeRange.
aStart.
Col();
2029 nEndCol = aExtendMergeRange.
aEnd.
Col();
2032 nEndRow = nMergeTestEndRow;
2041 if( !qIncreaseRange.empty() )
2043 if (bRecord && !pUndoRemoveMerge)
2046 pUndoDoc->InitUndo( rDoc, *aMark.begin(), *aMark.rbegin());
2047 pUndoRemoveMerge.reset(
new ScUndoRemoveMerge( &rDocShell, rRange, std::move(pUndoDoc) ));
2050 for(
const ScRange& aRange : qIncreaseRange )
2054 UnmergeCells( aRange, bRecord, pUndoRemoveMerge.get() );
2062 rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
2063 rDocShell.GetUndoManager()->LeaveListAction();
2069 if (bRecord && pUndoRemoveMerge)
2071 rDocShell.GetUndoManager()->AddUndoAction( std::move(pUndoRemoveMerge));
2077 bSuccess = rDoc.
InsertRow( nStartCol, 0, nEndCol,
MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc.get(), &aFullMark );
2078 nPaintEndRow = rDoc.
MaxRow();
2082 bSuccess = rDoc.
InsertRow( 0, 0, rDoc.
MaxCol(),
MAXTAB, nStartRow,
static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc.get(), &aFullMark );
2084 nPaintEndCol = rDoc.
MaxCol();
2085 nPaintEndRow = rDoc.
MaxRow();
2089 bSuccess = rDoc.
InsertCol( nStartRow, 0, nEndRow,
MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc.get(), &aFullMark );
2090 nPaintEndCol = rDoc.
MaxCol();
2094 bSuccess = rDoc.
InsertCol( 0, 0, rDoc.
MaxRow(),
MAXTAB, nStartCol,
static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc.get(), &aFullMark );
2096 nPaintEndRow = rDoc.
MaxRow();
2097 nPaintEndCol = rDoc.
MaxCol();
2101 OSL_FAIL(
"Wrong code at inserting");
2112 std::unique_ptr<SCTAB[]> pTabs(
new SCTAB[nSelCount]);
2113 std::unique_ptr<SCTAB[]> pScenarios(
new SCTAB[nSelCount]);
2115 for (
const auto& rTab : aMark)
2117 if (rTab >= nTabCount)
2124 pScenarios[nUndoPos] = nCount;
2125 pTabs[nUndoPos] = rTab;
2131 rDocShell.GetUndoManager()->LeaveListAction();
2134 rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoInsertCells>(
2135 &rDocShell,
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),
2136 nUndoPos, std::move(pTabs), std::move(pScenarios), eCmd, std::move(pRefUndoDoc), std::move(pUndoData), bPartOfPaste ) );
2141 while( !qIncreaseRange.empty() )
2143 ScRange aRange = qIncreaseRange.back();
2151 aRange.
aEnd.
IncRow(static_cast<SCCOL>(nEndRow-nStartRow+1));
2156 aRange.
aEnd.
IncCol(static_cast<SCCOL>(nEndCol-nStartCol+1));
2165 MergeCells(aMergeOption,
false,
true,
true);
2167 qIncreaseRange.pop_back();
2171 rDocShell.GetUndoManager()->LeaveListAction();
2173 for (
const SCTAB i : aMark)
2181 rDoc.
ExtendMerge( nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow,
i,
true );
2183 rDoc.
RefreshAutoFilter( nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow,
i );
2188 sal_uInt16 nExtFlags = 0;
2189 rDocShell.UpdatePaintExt( nExtFlags, nPaintStartCol, nPaintStartRow,
i, nPaintEndCol, nPaintEndRow,
i );
2191 SCTAB nScenarioCount = 0;
2197 AdjustRowHeight(
ScRange(0, nStartRow,
i, rDoc.
MaxCol(), nEndRow,
i+nScenarioCount )) :
2198 AdjustRowHeight(
ScRange(0, nPaintStartRow,
i, rDoc.
MaxCol(), nPaintEndRow,
i+nScenarioCount ));
2203 rDocShell.PostPaint( nPaintStartCol, nPaintStartRow,
i, nPaintEndCol, nPaintEndRow,
i+nScenarioCount, PaintPartFlags::Top );
2206 rDocShell.PostPaint( nPaintStartCol, nPaintStartRow,
i, nPaintEndCol, nPaintEndRow,
i+nScenarioCount, nPaintFlags, nExtFlags );
2213 while( !qIncreaseRange.empty() )
2215 ScRange aRange = qIncreaseRange.back();
2219 MergeCells(aMergeOption,
false,
true,
true);
2220 qIncreaseRange.pop_back();
2225 pViewSh->
MarkRange( aTargetRange,
false );
2226 pViewSh->
SetCursor( nCursorCol, nCursorRow );
2230 rDocShell.GetUndoManager()->LeaveListAction();
2231 rDocShell.GetUndoManager()->RemoveLastUndoAction();
2233 pRefUndoDoc.reset();
2235 rDocShell.ErrorMessage(STR_INSERT_FULL);
2268 if (rDocShell.GetDocument().GetChangeTrack() &&
2274 SAL_WARN(
"sc.ui",
"ScDocFunc::DeleteCells - no change-tracking of partial cell shift");
2287 OSL_FAIL(
"invalid row in DeleteCells");
2292 SCCOL nPaintStartCol = nStartCol;
2293 SCROW nPaintStartRow = nStartRow;
2294 SCCOL nPaintEndCol = nEndCol;
2295 SCROW nPaintEndRow = nEndRow;
2298 bool bRecord =
true;
2313 if( nCount == nEndTab+1 )
2315 aMark.SelectTable(
i,
true);
2323 for (
const auto& rTab : aMark)
2325 if (rTab >= nTabCount)
2332 SCTAB nSelCount = aMark.GetSelectCount();
2334 SCCOL nUndoStartCol = nStartCol;
2335 SCROW nUndoStartRow = nStartRow;
2336 SCCOL nUndoEndCol = nEndCol;
2337 SCROW nUndoEndRow = nEndRow;
2339 ScRange aExtendMergeRange( rRange );
2345 nUndoEndCol = aExtendMergeRange.
aEnd.
Col();
2346 nUndoEndRow = aExtendMergeRange.
aEnd.
Row();
2347 nPaintEndCol = nUndoEndCol;
2348 nPaintEndRow = nUndoEndRow;
2354 nUndoEndCol = rDoc.
MaxCol();
2359 nUndoEndRow = rDoc.
MaxRow();
2363 SCCOL nEditTestEndX = nUndoEndCol;
2365 nEditTestEndX = rDoc.
MaxCol();
2366 SCROW nEditTestEndY = nUndoEndRow;
2368 nEditTestEndY = rDoc.
MaxRow();
2384 rDoc, nUndoStartCol, nUndoStartRow, nEditTestEndX, nEditTestEndY, aMark);
2394 if (!canDeleteCellsByPivot(rRange, aMark, eCmd, rDoc))
2397 rDocShell.ErrorMessage(STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE);
2404 SCCOL nExtendStartCol = nUndoStartCol;
2405 SCROW nExtendStartRow = nUndoStartRow;
2406 bool bNeedRefresh =
false;
2410 ::std::vector<ScRange> qDecreaseRange;
2411 bool bDeletingMerge =
false;
2412 OUString aUndo =
ScResId( STR_UNDO_DELETECELLS );
2417 nViewShellId = pViewSh->GetViewShellId();
2418 rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo, 0, nViewShellId );
2420 std::unique_ptr<ScUndoRemoveMerge> pUndoRemoveMerge;
2422 for (
const SCTAB i : aMark)
2429 SCCOL nMergeStartCol = nUndoStartCol;
2430 SCROW nMergeStartRow = nUndoStartRow;
2431 SCCOL nMergeEndCol = nMergeTestEndCol;
2432 SCROW nMergeEndRow = nMergeTestEndRow;
2434 rDoc.
ExtendMerge( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow,
i );
2435 rDoc.
ExtendOverlapped( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow,
i );
2436 if( ( eCmd ==
DelCellCmd::CellsUp && ( nMergeStartCol != nUndoStartCol || nMergeEndCol != nMergeTestEndCol))||
2437 ( eCmd ==
DelCellCmd::CellsLeft && ( nMergeStartRow != nUndoStartRow || nMergeEndRow != nMergeTestEndRow)))
2440 rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
2441 rDocShell.GetUndoManager()->LeaveListAction();
2445 nExtendStartCol = nMergeStartCol;
2446 nExtendStartRow = nMergeStartRow;
2447 SCCOL nTestCol = -1;
2448 SCROW nTestRow1 = -1;
2449 SCROW nTestRow2 = -1;
2451 ScDocAttrIterator aTestIter( rDoc,
i, nUndoStartCol, nUndoStartRow, nMergeTestEndCol, nMergeTestEndRow );
2452 ScRange aExtendRange( nUndoStartCol, nUndoStartRow,
i, nMergeTestEndCol, nMergeTestEndRow,
i );
2454 while ( ( pPattern = aTestIter.
GetNext( nTestCol, nTestRow1, nTestRow2 ) ) !=
nullptr )
2461 ScRange aRange( nTestCol, nTestRow1,
i );
2465 if( nTestRow1 < nTestRow2 && nNewFlags ==
ScMF::Hor )
2467 for(
SCROW nTestRow = nTestRow1; nTestRow <= nTestRow2; nTestRow++ )
2469 ScRange aTestRange( nTestCol, nTestRow,
i );
2473 if( !aExtendRange.
In( aMergeRange ) )
2475 qDecreaseRange.push_back( aTestRange );
2476 bDeletingMerge =
true;
2483 if( !aExtendRange.
In( aMergeRange ) )
2485 qDecreaseRange.push_back( aRange );
2487 bDeletingMerge =
true;
2492 if( bDeletingMerge )
2497 nStartRow = aExtendMergeRange.
aStart.
Row();
2498 nEndRow = aExtendMergeRange.
aEnd.
Row();
2499 bNeedRefresh =
true;
2503 nEndCol = aExtendMergeRange.
aEnd.
Col();
2514 nStartCol = aExtendMergeRange.
aStart.
Col();
2515 nEndCol = aExtendMergeRange.
aEnd.
Col();
2518 nEndRow = aExtendMergeRange.
aEnd.
Row();
2519 bNeedRefresh =
true;
2528 if( !qDecreaseRange.empty() )
2530 if (bRecord && !pUndoRemoveMerge)
2533 pUndoDoc->InitUndo( rDoc, *aMark.begin(), *aMark.rbegin());
2534 pUndoRemoveMerge.reset(
new ScUndoRemoveMerge( &rDocShell, rRange, std::move(pUndoDoc) ));
2537 for(
const ScRange& aRange : qDecreaseRange )
2541 UnmergeCells( aRange, bRecord, pUndoRemoveMerge.get() );
2549 rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
2550 rDocShell.GetUndoManager()->LeaveListAction();
2556 if (bRecord && pUndoRemoveMerge)
2558 rDocShell.GetUndoManager()->AddUndoAction( std::move(pUndoRemoveMerge));
2566 std::unique_ptr<ScDocument> pRefUndoDoc;
2567 std::unique_ptr<ScRefUndoData> pUndoData;
2575 for (
const auto& rTab : aMark)
2577 if (rTab >= nTabCount)
2580 SCTAB nScenarioCount = 0;
2585 rDoc.
CopyToDocument( nUndoStartCol, nUndoStartRow, rTab, nUndoEndCol, nUndoEndRow, rTab+nScenarioCount,
2590 pRefUndoDoc->InitUndo( rDoc, 0, nTabCount-1 );
2597 sal_uInt16 nExtFlags = 0;
2598 for (
const auto& rTab : aMark)
2600 if (rTab >= nTabCount)
2603 rDocShell.UpdatePaintExt( nExtFlags, nStartCol, nStartRow, rTab, nEndCol, nEndRow, rTab );
2623 bool bUndoOutline =
false;
2627 rDoc.
DeleteRow( nStartCol, 0, nEndCol,
MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc.get(),
nullptr, &aFullMark );
2628 nPaintEndRow = rDoc.
MaxRow();
2631 rDoc.
DeleteRow( 0, 0, rDoc.
MaxCol(),
MAXTAB, nStartRow,
static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc.get(), &bUndoOutline, &aFullMark );
2633 nPaintEndCol = rDoc.
MaxCol();
2634 nPaintEndRow = rDoc.
MaxRow();
2638 rDoc.
DeleteCol( nStartRow, 0, nEndRow,
MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc.get(),
nullptr, &aFullMark );
2639 nPaintEndCol = rDoc.
MaxCol();
2642 rDoc.
DeleteCol( 0, 0, rDoc.
MaxRow(),
MAXTAB, nStartCol,
static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc.get(), &bUndoOutline, &aFullMark );
2644 nPaintEndRow = rDoc.
MaxRow();
2645 nPaintEndCol = rDoc.
MaxCol();
2649 OSL_FAIL(
"Wrong code at deleting");
2657 for (
const auto& rTab : aFullMark)
2659 if (rTab >= nTabCount)
2662 pRefUndoDoc->DeleteAreaTab(nUndoStartCol,nUndoStartRow,nUndoEndCol,nUndoEndRow, rTab,
InsertDeleteFlags::ALL);
2666 pUndoDoc->AddUndoTab( 0, nTabCount-1 );
2669 pRefUndoDoc->CopyToDocument(0,0,0,rDoc.
MaxCol(),rDoc.
MaxRow(),
MAXTAB,
InsertDeleteFlags::FORMULA,
false,*pUndoDoc,
nullptr,
false);
2670 pRefUndoDoc.reset();
2672 std::unique_ptr<SCTAB[]> pTabs(
new SCTAB[nSelCount]);
2673 std::unique_ptr<SCTAB[]> pScenarios(
new SCTAB[nSelCount]);
2676 for (
const auto& rTab : aMark)
2678 if (rTab >= nTabCount)
2685 pScenarios[nUndoPos] = nCount;
2686 pTabs[nUndoPos] = rTab;
2690 if( !bDeletingMerge )
2692 rDocShell.GetUndoManager()->LeaveListAction();
2695 rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoDeleteCells>(
2696 &rDocShell,
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),
2697 nUndoPos, std::move(pTabs), std::move(pScenarios),
2698 eCmd, std::move(pUndoDoc), std::move(pUndoData) ) );
2704 while( !qDecreaseRange.empty() )
2706 ScRange aRange = qDecreaseRange.back();
2708 sal_Int32 nDecreaseRowCount = 0;
2709 sal_Int32 nDecreaseColCount = 0;
2713 nDecreaseRowCount = nEndRow-nStartRow+1;
2715 nDecreaseRowCount = aRange.
aEnd.
Row()-nStartRow+1;
2717 nDecreaseRowCount = aRange.
aEnd.
Row()-nEndRow+1;
2722 nDecreaseColCount = nEndCol-nStartCol+1;
2724 nDecreaseColCount = aRange.
aEnd.
Col()-nStartCol+1;
2726 nDecreaseColCount = aRange.
aEnd.
Col()-nEndCol+1;
2746 MergeCells( aMergeOption,
false,
true,
true );
2748 qDecreaseRange.pop_back();
2751 if( bDeletingMerge )
2752 rDocShell.GetUndoManager()->LeaveListAction();
2755 nMergeTestEndCol = rDoc.
MaxCol();
2757 nMergeTestEndRow = rDoc.
MaxRow();
2766 rDoc.
ApplyPatternArea( nExtendStartCol, nExtendStartRow, nMergeTestEndCol, nMergeTestEndRow, aMark, aPattern );
2768 for (
const auto& rTab : aMark)
2770 if (rTab >= nTabCount)
2773 SCTAB nScenarioCount = 0;
2778 ScRange aMergedRange( nExtendStartCol, nExtendStartRow, rTab, nMergeTestEndCol, nMergeTestEndRow, rTab+nScenarioCount );
2783 for (
const auto& rTab : aMark)
2785 if (rTab >= nTabCount)
2788 rDoc.
RefreshAutoFilter( nExtendStartCol, nExtendStartRow, nMergeTestEndCol, nMergeTestEndRow, rTab );
2791 for (
const auto& rTab : aMark)
2793 if (rTab >= nTabCount)
2801 rDocShell.UpdatePaintExt( nExtFlags, nPaintStartCol, nPaintStartRow, rTab, nPaintEndCol, nPaintEndRow, rTab );
2803 SCTAB nScenarioCount = 0;
2810 rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, rTab, nPaintEndCol, nPaintEndRow, rTab+nScenarioCount, nPaintFlags, nExtFlags );
2815 lcl_PaintAbove( rDocShell,
ScRange( nPaintStartCol, nPaintStartRow, rTab, nPaintEndCol, nPaintEndRow, rTab+nScenarioCount) );
2817 rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, rTab, nPaintEndCol, nPaintEndRow, rTab+nScenarioCount, PaintPartFlags::Top );
2844 bool bCut,
bool bRecord,
bool bPaint,
bool bApi )
2861 OSL_FAIL(
"invalid row in MoveBlock");
2866 bool bScenariosAdded =
false;
2871 if ( nDestTab == nStartTab && !rDoc.
IsScenario(nEndTab) )
2872 while ( nEndTab+1 < nTabCount && rDoc.
IsScenario(nEndTab+1) )
2875 bScenariosAdded =
true;
2878 SCTAB nSrcTabCount = nEndTab-nStartTab+1;
2879 SCTAB nDestEndTab = nDestTab+nSrcTabCount-1;
2885 for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2887 aSourceMark.SetMarkArea( rSource );
2897 ScClipParam aClipParam(
ScRange(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nStartTab), bCut);
2898 rDoc.
CopyToClip(aClipParam, pClipDoc.get(), &aSourceMark, bScenariosAdded,
true);
2902 SCCOL nOldEndCol = nEndCol;
2903 SCROW nOldEndRow = nEndRow;
2904 bool bClipOver =
false;
2905 for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2907 SCCOL nTmpEndCol = nOldEndCol;
2908 SCROW nTmpEndRow = nOldEndRow;
2909 if (rDoc.
ExtendMerge( nStartCol, nStartRow, nTmpEndCol, nTmpEndRow, nTab ))
2911 if ( nTmpEndCol > nEndCol ) nEndCol = nTmpEndCol;
2912 if ( nTmpEndRow > nEndRow ) nEndRow = nTmpEndRow;
2915 SCCOL nDestEndCol = nDestCol + ( nOldEndCol-nStartCol );
2916 SCROW nDestEndRow = nDestRow + ( nOldEndRow-nStartRow );
2918 SCCOL nUndoEndCol = nDestCol + ( nEndCol-nStartCol );
2919 SCROW nUndoEndRow = nDestRow + ( nEndRow-nStartRow );
2921 bool bIncludeFiltered = bCut;
2922 if ( !bIncludeFiltered )
2928 pClipDoc->GetClipArea( nClipX, nClipY,
false );
2929 SCROW nUndoAdd = nUndoEndRow - nDestEndRow;
2930 nDestEndRow = nDestRow + nClipY;
2931 nUndoEndRow = nDestEndRow + nUndoAdd;
2937 rDocShell.ErrorMessage(STR_PASTE_FULL);
2944 for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
2945 aTester.
TestBlock( rDoc, nTab, nDestCol,nDestRow, nUndoEndCol,nUndoEndRow );
2947 for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2948 aTester.
TestBlock( rDoc, nTab, nStartCol,nStartRow, nEndCol,nEndRow );
2959 if (bClipOver && !bCut)
2960 if (rDoc.
HasAttrib( nDestCol,nDestRow,nDestTab, nUndoEndCol,nUndoEndRow,nDestEndTab,
2964 rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
2970 sal_uInt16 nSourceExt = 0;
2971 rDocShell.UpdatePaintExt( nSourceExt, nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab );
2972 sal_uInt16 nDestExt = 0;
2973 rDocShell.UpdatePaintExt( nDestExt, nDestCol,nDestRow,nDestTab, nDestEndCol,nDestEndRow,nDestEndTab );
2981 bool bWholeCols = ( nStartRow == 0 && nEndRow == rDoc.
MaxRow() );
2982 bool bWholeRows = ( nStartCol == 0 && nEndCol == rDoc.
MaxCol() );
2986 pUndoDoc->InitUndo( rDoc, nStartTab, nEndTab, bWholeCols, bWholeRows );
2990 rDoc.
CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
2991 nUndoFlags,
false, *pUndoDoc );
2994 if ( nDestTab != nStartTab )
2995 pUndoDoc->AddUndoTab( nDestTab, nDestEndTab, bWholeCols, bWholeRows );
2997 nDestEndCol, nDestEndRow, nDestEndTab,
2998 nUndoFlags,
false, *pUndoDoc );
3002 bool bSourceHeight =
false;
3006 for (nTab=nStartTab; nTab<=nEndTab; nTab++)
3009 aDelMark.SelectTable( nTab,
true );
3016 if (rDoc.
HasAttrib( nDestCol,nDestRow,nDestTab,
3017 nUndoEndCol,nUndoEndRow,nDestEndTab,
3021 for (nTab=nStartTab; nTab<=nEndTab; nTab++)
3023 SCCOL nTmpEndCol = nEndCol;
3024 SCROW nTmpEndRow = nEndRow;
3025 rDoc.
ExtendMerge( nStartCol, nStartRow, nTmpEndCol, nTmpEndRow, nTab,
true );
3030 rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
3035 bSourceHeight = AdjustRowHeight( rSource,
false );
3038 ScRange aPasteDest( nDestCol, nDestRow, nDestTab, nDestEndCol, nDestEndRow, nDestEndTab );
3041 for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
3043 aDestMark.SetMarkArea( aPasteDest );
3052 pUndoDoc.get(), pClipDoc.get(),
true,
false, bIncludeFiltered);
3055 if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
3056 UnmergeCells( aPasteDest,
false,
nullptr );
3058 bool bDestHeight = AdjustRowHeight(
3059 ScRange( 0,nDestRow,nDestTab, rDoc.
MaxCol(),nDestEndRow,nDestEndTab ),
3065 if ( pClipDoc->GetDrawLayer() )
3067 nullptr, pClipDoc.get(),
true,
false, bIncludeFiltered );
3071 ScRange aUndoRange(nStartCol, nStartRow, nStartTab, nOldEndCol, nOldEndRow, nEndTab);
3072 ScAddress aDestPos(nDestCol, nDestRow, nDestTab);
3074 rDocShell.GetUndoManager()->AddUndoAction(
3075 std::make_unique<ScUndoDragDrop>(
3076 &rDocShell, aUndoRange, aDestPos, bCut, std::move(pUndoDoc), bScenariosAdded));
3079 SCCOL nDestPaintEndCol = nDestEndCol;
3080 SCROW nDestPaintEndRow = nDestEndRow;
3081 for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
3083 SCCOL nTmpEndCol = nDestEndCol;
3084 SCROW nTmpEndRow = nDestEndRow;
3085 rDoc.
ExtendMerge( nDestCol, nDestRow, nTmpEndCol, nTmpEndRow, nTab,
true );
3086 if (nTmpEndCol > nDestPaintEndCol) nDestPaintEndCol = nTmpEndCol;
3087 if (nTmpEndRow > nDestPaintEndRow) nDestPaintEndRow = nTmpEndRow;
3091 for (nTab=nStartTab; nTab<=nEndTab; nTab++)
3098 SCCOL nPaintStartX = nDestCol;
3099 SCROW nPaintStartY = nDestRow;
3100 SCCOL nPaintEndX = nDestPaintEndCol;
3101 SCROW nPaintEndY = nDestPaintEndRow;
3104 if ( nStartRow==0 && nEndRow==rDoc.
MaxRow() )
3106 nPaintEndX = rDoc.
MaxCol();
3108 nPaintEndY = rDoc.
MaxRow();
3111 if ( bDestHeight || ( nStartCol == 0 && nEndCol == rDoc.
MaxCol() ) )
3113 nPaintEndY = rDoc.
MaxRow();
3115 nPaintEndX = rDoc.
MaxCol();
3118 if ( bScenariosAdded )
3122 nPaintEndX = rDoc.
MaxCol();
3123 nPaintEndY = rDoc.
MaxRow();
3126 rDocShell.PostPaint( nPaintStartX,nPaintStartY,nDestTab,
3127 nPaintEndX,nPaintEndY,nDestEndTab, nFlags, nSourceExt | nDestExt );
3133 nPaintStartX = nStartCol;
3134 nPaintStartY = nStartRow;
3135 nPaintEndX = nEndCol;
3136 nPaintEndY = nEndRow;
3139 if ( bSourceHeight )
3141 nPaintEndY = rDoc.
MaxRow();
3143 nPaintEndX = rDoc.
MaxCol();
3146 if ( bScenariosAdded )
3150 nPaintEndX = rDoc.
MaxCol();
3151 nPaintEndY = rDoc.
MaxRow();
3154 rDocShell.PostPaint( nPaintStartX,nPaintStartY,nStartTab,
3155 nPaintEndX,nPaintEndY,nEndTab, nFlags, nSourceExt );
3168 uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.
GetModel(), uno::UNO_QUERY);
3169 uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
3170 uno::Reference< uno::XInterface > xDocModuleApiObject;
3173 xVBACodeNamedObjectAccess.set( xSF->createInstance(
"ooo.vba.VBAObjectModuleObjectProvider"), uno::UNO_QUERY );
3174 xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY );
3176 return xDocModuleApiObject;
3182 script::ModuleInfo sModuleInfo;
3183 sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
3191 uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.
GetBasicContainer();
3192 OSL_ENSURE( xLibContainer.is(),
"No BasicContainer!" );
3194 uno::Reference< container::XNameContainer > xLib;
3195 if( xLibContainer.is() )
3197 OUString aLibName(
"Standard" );
3202 uno::Any aLibAny = xLibContainer->getByName( aLibName );
3210 OUString genModuleName =
"Sheet1";
3211 while( xLib->hasByName( genModuleName ) )
3212 genModuleName =
"Sheet" + OUString::number( ++nNum );
3215 OUString sTmpSource = sSource;
3216 if ( sTmpSource.isEmpty() )
3217 sTmpSource =
"Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n";
3218 aSourceAny <<= sTmpSource;
3219 uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
3220 if ( xVBAModuleInfo.is() )
3224 xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo );
3225 xLib->insertByName( genModuleName, aSourceAny );
3231 uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.
GetBasicContainer();
3232 OSL_ENSURE( xLibContainer.is(),
"No BasicContainer!" );
3234 uno::Reference< container::XNameContainer > xLib;
3235 if( xLibContainer.is() )
3237 OUString aLibName(
"Standard" );
3242 uno::Any aLibAny = xLibContainer->getByName( aLibName );
3247 uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
3248 if( xLib->hasByName( sModuleName ) )
3249 xLib->removeByName( sModuleName );
3250 if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(sModuleName) )
3251 xVBAModuleInfo->removeModuleInfo( sModuleName );
3258 bool bSuccess =
false;
3267 bool bInsertDocModule =
false;
3269 if( !rDocShell.GetDocument().IsImportingXML() )
3273 if ( bInsertDocModule || ( bRecord && !rDoc.
IsUndoEnabled() ) )
3280 bool bAppend = ( nTab >= nTabCount );
3287 rDocShell.GetUndoManager()->AddUndoAction(
3288 std::make_unique<ScUndoInsertTab>( &rDocShell, nTab, bAppend, rName));
3291 if( bInsertDocModule )
3297 rDocShell.PostPaintExtras();
3303 rDocShell.ErrorMessage(STR_TABINSERT_ERROR);
3314 bool bSuccess =
false;
3321 bool bWasLinked = rDoc.
IsLinked(nTab);
3323 std::unique_ptr<ScRefUndoData> pUndoData;
3329 pUndoDoc->InitUndo( rDoc, nTab, nTab,
true,
true );
3330 pUndoDoc->AddUndoTab( 0, nCount-1 );
3334 rDoc.
GetName( nTab, aOldName );
3335 pUndoDoc->RenameTab( nTab, aOldName );
3344 pUndoDoc->SetScenario( nTab,
true );
3349 pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
3351 pUndoDoc->SetActiveScenario( nTab, bActive );
3353 pUndoDoc->SetVisible( nTab, rDoc.
IsVisible( nTab ) );
3356 pUndoDoc->SetSheetEvents( nTab, std::unique_ptr<ScSheetEvents>(pSheetEvents ?
new ScSheetEvents(*pSheetEvents) :
nullptr) );
3368 vector<SCTAB> theTabs;
3369 theTabs.push_back(nTab);
3370 rDocShell.GetUndoManager()->AddUndoAction(
3371 std::make_unique<ScUndoDeleteTab>( &rDocShell, theTabs, std::move(pUndoDoc), std::move(pUndoData) ));
3386 rDocShell.UpdateLinks();
3387 SfxBindings* pBindings = rDocShell.GetViewBindings();
3392 rDocShell.PostPaintExtras();
3396 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScTablesChanged ) );
3397 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScDbAreasChanged ) );
3398 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScAreaLinksChanged ) );
3409 if ( rDoc.
IsVisible( nTab ) == bVisible )
3415 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3425 sal_uInt16 nVisCount = 0;
3427 for (
SCTAB i=0;
i<nCount && nVisCount<2;
i++)
3434 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3442 std::vector<SCTAB> undoTabs;
3443 undoTabs.push_back(nTab);
3444 rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( &rDocShell, undoTabs, bVisible ) );
3471 rDocShell.GetUndoManager()->AddUndoAction( std::make_unique<ScUndoLayoutRTL>( &rDocShell, nTab, bRTL ) );
3477 SfxBindings* pBindings = rDocShell.GetViewBindings();
3495 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3501 bool bSuccess =
false;
3508 rDocShell.GetUndoManager()->AddUndoAction(
3509 std::make_unique<ScUndoRenameTab>( &rDocShell, nTab, sOldName, rName));
3511 rDocShell.PostPaintExtras();
3529 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3535 bool bSuccess =
false;
3543 rDocShell.GetUndoManager()->AddUndoAction(
3544 std::make_unique<ScUndoTabColor>( &rDocShell, nTab, aOldTabBgColor, rColor));
3546 rDocShell.PostPaintExtras();
3560 bool bRecord =
true;
3567 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3572 Color aNewTabBgColor;
3573 bool bSuccess =
true;
3574 size_t nTabProtectCount = 0;
3575 size_t nTabListCount = rUndoTabColorList.size();
3576 for (
size_t i = 0;
i < nTabListCount; ++
i )
3597 if ( nTabProtectCount == nTabListCount )
3600 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3608 rDocShell.GetUndoManager()->AddUndoAction(
3609 std::make_unique<ScUndoTabColor>( &rDocShell, rUndoTabColorList));
3611 rDocShell.PostPaintExtras();
3632 sal_uInt16 nTwips = rDoc.
GetOptimalColWidth( nCol, nTab, pDev, nPPTX, nPPTY, aOne, aOne,
3639 bool bWidth,
const std::vector<sc::ColRowSpan>& rRanges,
SCTAB nTab,
3640 ScSizeMode eMode, sal_uInt16 nSizeTwips,
bool bRecord,
bool bApi )
3644 if (rRanges.empty())
3655 rDocShell.ErrorMessage(STR_PROTECTIONERR);
3659 SCCOLROW nStart = rRanges[0].mnStart;
3668 std::unique_ptr<ScOutlineTable> pUndoTab;
3669 std::vector<sc::ColRowSpan> aUndoRanges;
3678 pUndoDoc->InitUndo( rDoc, nTab, nTab,
true );
3683 pUndoDoc->InitUndo( rDoc, nTab, nTab,
false,
true );
3687 aUndoRanges = rRanges;
3695 bool bOutline =
false;
3699 SCCOLROW nStartNo = rRange.mnStart;
3711 for (
SCROW nRow=nStartNo; nRow<=nEndNo; nRow++)
3714 SCROW nLastRow = -1;
3715 bool bHidden = rDoc.
RowHidden(nRow, nTab,
nullptr, &nLastRow);
3717 rDoc.
SetRowFlags( nRow, nTab, nOld & ~CRFlags::ManualSize );
3728 rDoc.
ShowRows( nStartNo, nEndNo, nTab,
true );
3741 rDoc.
ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
3745 rDoc.
ShowRows( nStartNo, nEndNo, nTab,
true );
3750 for (
SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
3754 sal_uInt16 nThisSize = nSizeTwips;
3757 nThisSize = nSizeTwips +
3763 rDoc.
ShowCol( nCol, nTab, bShow );
3774 static_cast<SCCOL>(nStartNo),
3775 static_cast<SCCOL>(nEndNo), nTab, bShow );
3778 static_cast<SCROW>(nStartNo),
3779 static_cast<SCROW>(nEndNo), nTab, bShow );
3791 rDocShell.GetUndoManager()->AddUndoAction(
3792 std::make_unique<ScUndoWidthOrHeight>(
3793 &rDocShell, aMark, nStart, nTab, nEnd, nTab, std::move(pUndoDoc),
3794 aUndoRanges, std::move(pUndoTab), eMode, nSizeTwips, bWidth));
3810 bool bRecord,
bool bSetModified )
3818 SfxBindings* pBindings = rDocShell.GetViewBindings();
3821 static_cast<SCCOLROW>(rPos.
Row());
3826 rDoc.
HasColBreak(static_cast<SCCOL>(nPos), nTab) :
3832 rDocShell.GetUndoManager()->AddUndoAction(
3833 std::make_unique<ScUndoPageBreak>( &rDocShell, rPos.
Col(), rPos.
Row(), nTab, bColumn, true ) );
3836 rDoc.
SetColBreak(static_cast<SCCOL>(nPos), nTab,
false,
true);
3838 rDoc.
SetRowBreak(static_cast<SCROW>(nPos), nTab,
false,
true);
3864 pBindings->
Invalidate( FID_DEL_MANUALBREAKS );
3873 bool bRecord,
bool bSetModified )
3881 SfxBindings* pBindings = rDocShell.GetViewBindings();
3884 static_cast<SCCOLROW>(rPos.
Row());
3888 nBreak = rDoc.
HasColBreak(static_cast<SCCOL>(nPos), nTab);
3890 nBreak = rDoc.
HasRowBreak(static_cast<SCROW>(nPos), nTab);
3896 rDocShell.GetUndoManager()->AddUndoAction(
3897 std::make_unique<ScUndoPageBreak>( &rDocShell, rPos.
Col(), rPos.
Row(), nTab, bColumn, false ) );
3900 rDoc.
RemoveColBreak(static_cast<SCCOL>(nPos), nTab,
false,
true);
3902 rDoc.
RemoveRowBreak(static_cast<SCROW>(nPos), nTab,
false,
true);
3927 pBindings->
Invalidate( FID_DEL_MANUALBREAKS );
3939 std::unique_ptr<ScTableProtection>
p;
3943 p = std::make_unique<ScTableProtection>(rProtect);
3952 p = std::make_unique<ScTableProtection>(*pProtect);
3954 rDocShell.GetUndoManager()->AddUndoAction(
3955 std::make_unique<ScUndoTabProtect>(&rDocShell, nTab, std::move(p)));
3960 if (
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(fr->GetViewShell()))
3961 pTabViewShell->SetTabProtectionSymbol(nTab, rProtect.
isProtected());
3962 rDocShell.PostPaintGridAll();
3971 std::unique_ptr<ScDocProtection>
p;
3975 p = std::make_unique<ScDocProtection>(rProtect);
3984 p = std::make_unique<ScDocProtection>(*pProtect);
3986 rDocShell.GetUndoManager()->AddUndoAction(
3987 std::make_unique<ScUndoDocProtect>(&rDocShell, std::move(p)));
3991 rDocShell.PostPaintGridAll();
4004 ProtectDocument(aProtection);
4011 const ScTableProtection* pOldProtection = rDocShell.GetDocument().GetTabProtection(nTab);
4013 pNewProtection->setProtected(
true);
4014 pNewProtection->setPassword(rPassword);
4015 ProtectSheet(nTab, *pNewProtection);
4038 VclMessageType::Info, VclButtonsType::Ok,
4039 ScResId(SCSTR_WRONGPASSWORD)));
4047 ProtectDocument(aNewProtection);
4063 VclMessageType::Info, VclButtonsType::Ok,
4064 ScResId(SCSTR_WRONGPASSWORD)));
4072 ProtectSheet(nTab, aNewProtection);
4085 if (!aTester.IsEditable())
4088 rDocShell.ErrorMessage(aTester.GetMessageId());
4108 pUndoDoc->InitUndo( rDoc, nStartTab, nEndTab );
4111 rDocShell.GetUndoManager()->AddUndoAction(
4112 std::make_unique<ScUndoClearItems>( &rDocShell, aMultiMark, std::move(pUndoDoc), pWhich ) );
4130 if (!aTester.IsEditable())
4133 rDocShell.ErrorMessage(aTester.GetMessageId());
4146 pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab );
4147 for (
const auto& rTab : rMark)
4149 if (rTab >= nTabCount)
4152 if (rTab != nStartTab)
4153 pUndoDoc->AddUndoTab( rTab, rTab );
4156 ScRange aCopyRange = aMarkRange;
4161 rDocShell.GetUndoManager()->AddUndoAction(
4162 std::make_unique<ScUndoIndent>( &rDocShell, rMark, std::move(pUndoDoc), bIncrement ) );
4170 SfxBindings* pBindings = rDocShell.GetViewBindings();
4178 pBindings->
Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
4179 pBindings->
Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
4180 pBindings->
Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
4181 pBindings->
Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
4183 pBindings->
Invalidate( SID_ALIGN_ANY_HDEFAULT );
4185 pBindings->
Invalidate( SID_ALIGN_ANY_HCENTER );
4186 pBindings->
Invalidate( SID_ALIGN_ANY_RIGHT );
4187 pBindings->
Invalidate( SID_ALIGN_ANY_JUSTIFIED );
4194 sal_uInt16 nFormatNo,
bool bApi )
4206 bool bRecord =
true;
4214 for (
SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4219 ScEditableTester aTester( rDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4231 pUndoDoc->InitUndo( rDoc, nStartTab, nStartTab, bSize, bSize );
4232 for (
const auto& rTab : aMark)
4234 if (rTab >= nTabCount)
4237 if (rTab != nStartTab)
4238 pUndoDoc->AddUndoTab( rTab, rTab, bSize, bSize );
4255 rDoc.
AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo, aMark );
4259 std::vector<sc::ColRowSpan> aCols(1,
sc::ColRowSpan(nStartCol,nEndCol));
4260 std::vector<sc::ColRowSpan> aRows(1,
sc::ColRowSpan(nStartRow,nEndRow));
4262 for (
const auto& rTab : aMark)
4264 if (rTab >= nTabCount)
4268 SetWidthOrHeight(
false, aRows, rTab,
SC_SIZE_VISOPT, 0,
false,
false);
4269 rDocShell.PostPaint( 0,0,rTab, rDoc.
MaxCol(),rDoc.
MaxRow(),rTab,
4275 for (
const auto& rTab : aMark)
4277 if (rTab >= nTabCount)
4280 bool bAdj = AdjustRowHeight(
ScRange(nStartCol, nStartRow, rTab,
4281 nEndCol, nEndRow, rTab),
false );
4283 rDocShell.PostPaint( 0,nStartRow,rTab, rDoc.
MaxCol(),rDoc.
MaxRow(),rTab,
4286 rDocShell.PostPaint( nStartCol, nStartRow, rTab,
4293 rDocShell.GetUndoManager()->AddUndoAction(
4294 std::make_unique<ScUndoAutoFormat>( &rDocShell, rRange, std::move(pUndoDoc), aMark, bSize, nFormatNo ) );
4306 const ScTokenArray* pTokenArray,
const OUString& rString,
bool bApi,
bool bEnglish,
4314 bool bSuccess =
false;
4328 for (
SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4332 ScEditableTester aTester( rDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4344 pUndoDoc->InitUndo( rDoc, nStartTab, nEndTab );
4366 std::unique_ptr<ScTokenArray> pCode = aComp.
CompileString( rString );
4372 aMark, rString,
nullptr, eGrammar);
4377 rDocShell.GetUndoManager()->AddUndoAction(
4378 std::make_unique<ScUndoEnterMatrix>( &rDocShell, rRange, std::move(pUndoDoc), rString ) );
4382 rDocShell.PostPaint( nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab,
PaintPartFlags::Grid );
4398 bool bSuccess =
false;
4415 for (
SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4419 ScEditableTester aTester( rDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4428 pUndoDoc->InitUndo( rDoc, nStartTab, nEndTab );
4431 rDocShell.GetUndoManager()->AddUndoAction(
4432 std::make_unique<ScUndoTabOp>( &rDocShell,
4433 nStartCol, nStartRow, nStartTab,
4434 nEndCol, nEndRow, nEndTab, std::move(pUndoDoc),
4441 rDoc.
InsertTableOp(rParam, nStartCol, nStartRow, nEndCol, nEndRow, aMark);
4442 rDocShell.PostPaintGridAll();
4539 bool bSuccess =
false;
4541 adjustFillRangeForAdjacentCopy(rDoc, aRange, eDir);
4550 bool bRecord =
true;
4559 for (
SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4563 ScEditableTester aTester( rDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4599 pUndoDoc->InitUndo( rDoc, nDestStartTab, nDestStartTab );
4600 for (
const auto& rTab : aMark)
4602 if (rTab >= nTabCount)
4605 if (rTab != nDestStartTab)
4606 pUndoDoc->AddUndoTab( rTab, rTab );
4609 ScRange aCopyRange = aDestArea;
4620 nProgCount *= nCount;
4622 ScResId(STR_FILL_SERIES_PROGRESS), nProgCount, true );
4627 AdjustRowHeight(aRange);
4631 rDocShell.GetUndoManager()->AddUndoAction(
4632 std::make_unique<ScUndoAutoFill>( &rDocShell, aDestArea, aSourceArea, std::move(pUndoDoc), aMark,
4636 rDocShell.PostPaintGridAll();
4649 double fStart,
double fStep,
double fMax,
4654 bool bSuccess =
false;
4663 bool bRecord =
true;
4672 for (
SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4676 ScEditableTester aTester( rDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4691 static_cast<SCSIZE>( aSourceArea.
aEnd.
Row() - aSourceArea.
aStart.
Row() + 1 ) :
4692 static_cast<SCSIZE>( aSourceArea.
aEnd.
Col() - aSourceArea.
aStart.
Col() + 1 );
4693 if ( nCount >= nTotLines )
4694 nCount = nTotLines - 1;
4699 aSourceArea.
aEnd.
SetRow( sal::static_int_cast<SCROW>( aSourceArea.
aEnd.
Row() - nCount ) );
4702 aSourceArea.
aEnd.
SetCol( sal::static_int_cast<SCCOL>( aSourceArea.
aEnd.
Col() - nCount ) );
4719 pUndoDoc->InitUndo( rDoc, nDestStartTab, nDestStartTab );
4720 for (
const auto& rTab : aMark)
4722 if (rTab >= nTabCount)
4725 if (rTab != nDestStartTab)
4726 pUndoDoc->AddUndoTab( rTab, rTab );
4743 rDoc.
SetValue( nValX, nValY, nTab, fStart );
4751 nProgCount *= nCount;
4753 ScResId(STR_FILL_SERIES_PROGRESS), nProgCount, true );
4757 aMark, nCount, eDir, eCmd, eDateCmd, fStep, fMax );
4758 AdjustRowHeight(rRange);
4760 rDocShell.PostPaintGridAll();
4766 rDocShell.GetUndoManager()->AddUndoAction(
4767 std::make_unique<ScUndoAutoFill>( &rDocShell, aDestArea, aSourceArea, std::move(pUndoDoc), aMark,
4768 eDir, eCmd, eDateCmd, fStart, fStep, fMax) );
4805 for (
SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4815 aDestArea.
aEnd.
SetRow( sal::static_int_cast<SCROW>( aSourceArea.
aEnd.
Row() + nCount ) );
4818 if (nCount > sal::static_int_cast<sal_uLong>( aSourceArea.
aStart.
Row() ))
4820 OSL_FAIL(
"FillAuto: Row < 0");
4826 aDestArea.
aEnd.
SetCol( sal::static_int_cast<SCCOL>( aSourceArea.
aEnd.
Col() + nCount ) );
4829 if (nCount > sal::static_int_cast<sal_uLong>( aSourceArea.
aStart.
Col() ))
4831 OSL_FAIL(
"FillAuto: Col < 0");
4837 OSL_FAIL(
"Wrong direction with FillAuto");
4854 nEndCol, nEndRow, aMark ) )
4857 rDocShell.ErrorMessage(STR_MATRIXFRAGMENTERR);
4875 pUndoDoc->InitUndo( rDoc, nDestStartTab, nDestStartTab );
4876 for (
const auto& rTab : aMark)
4878 if (rTab >= nTabCount)
4881 if (rTab != nDestStartTab)
4882 pUndoDoc->AddUndoTab( rTab, rTab );
4897 nProgCount *= nCount;
4899 ScResId(STR_FILL_SERIES_PROGRESS), nProgCount, true );
4903 aMark, nCount, eDir, eCmd, eDateCmd, fStep, fMax );
4905 AdjustRowHeight(aDestArea);
4909 rDocShell.GetUndoManager()->AddUndoAction(
4910 std::make_unique<ScUndoAutoFill>( &rDocShell, aDestArea, aSourceArea, std::move(pUndoDoc), aMark,
4911 eDir, eCmd, eDateCmd,
MAXDOUBLE, fStep, fMax) );
4914 rDocShell.PostPaintGridAll();
4931 if ((nStartCol == nEndCol && nStartRow == nEndRow) || rOption.
maTabs.empty())
4943 for (
const auto& rTab : rOption.
maTabs)
4945 ScEditableTester aTester( rDoc, rTab, nStartCol, nStartRow, nEndCol, nEndRow );
4953 if ( rDoc.
HasAttrib( nStartCol, nStartRow, rTab, nEndCol, nEndRow, rTab,
4958 rDocShell.ErrorMessage(STR_MSSG_MERGECELLS_0);
4964 bool bNeedContentsUndo =
false;
4967 bool bIsBlockEmpty = ( nStartRow == nEndRow )
4968 ? rDoc.
IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow,
true )
4969 : rDoc.
IsBlockEmpty( nTab, nStartCol,nStartRow+1, nStartCol,nEndRow,
true ) &&
4970 rDoc.
IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow,
true );
4971 bool bNeedContents = bContents && !bIsBlockEmpty;
4972 bool bNeedEmpty = bEmptyMergedCells && !bIsBlockEmpty && !bNeedContents;
4977 bool bHasNotes =
false;
4978 for(
ScAddress aPos( nStartCol, nStartRow, nTab ); !bHasNotes && (aPos.Col() <= nEndCol); aPos.
IncCol() )
4979 for( aPos.SetRow( nStartRow ); !bHasNotes && (aPos.Row() <= nEndRow); aPos.IncRow() )
4980 bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (rDoc.
HasNote(aPos));
4985 pUndoDoc->InitUndo(rDoc, nTab1, nTab2);
4988 rDoc.
CopyToDocument( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
4996 else if ( bNeedEmpty )
4997 rDoc.
DoEmptyBlock( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
4998 rDoc.
DoMerge( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
5006 if ( !AdjustRowHeight(
ScRange( 0,nStartRow,nTab, rDoc.
MaxCol(),nEndRow,nTab ) ) )
5007 rDocShell.PostPaint( nStartCol, nStartRow, nTab,
5009 if (bNeedContents || rOption.
mbCenter)
5011 ScRange aRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab);
5017 DetectiveMarkInvalid(nTab);
5019 bNeedContentsUndo |= bNeedContents;
5025 rDocShell.GetUndoManager()->AddUndoAction(
5026 std::make_unique<ScUndoMerge>(&rDocShell, rOption, bNeedContentsUndo, std::move(pUndoDoc), std::move(pDrawUndo)) );
5031 SfxBindings* pBindings = rDocShell.GetViewBindings();
5046 for (
SCTAB i = nTab1;
i <= nTab2; ++
i)
5047 aOption.maTabs.insert(
i);
5049 return UnmergeCells(aOption, bRecord, pUndoRemoveMerge);
5056 if (rOption.
maTabs.empty())
5067 assert( pUndoDoc || !pUndoRemoveMerge );
5102 if ( !AdjustRowHeight( aExtended ) )
5107 DetectiveMarkInvalid(nTab);
5112 if (pUndoRemoveMerge)
5120 rDocShell.GetUndoManager()->AddUndoAction(
5121 std::make_unique<ScUndoRemoveMerge>( &rDocShell, rOption,
ScDocumentUniquePtr(pUndoDoc) ) );
5131 SetNewRangeNames( std::unique_ptr<ScRangeName>(
new ScRangeName(rNewRanges)),
true, nTab );
5138 OSL_ENSURE( pNewRanges,
"pNewRanges is 0" );
5153 std::unique_ptr<ScRangeName> pUndoRanges(
new ScRangeName(*pOld));
5154 std::unique_ptr<ScRangeName> pRedoRanges(
new ScRangeName(*pNewRanges));
5155 rDocShell.GetUndoManager()->AddUndoAction(
5156 std::make_unique<ScUndoRangeNames>( &rDocShell, std::move(pUndoRanges), std::move(pRedoRanges), nTab ) );
5187 std::map<OUString, ScRangeName*> aOldRangeMap;
5189 rDocShell.GetUndoManager()->AddUndoAction(
5190 std::make_unique<ScUndoAllRangeNames>(&rDocShell, aOldRangeMap, rRangeMap));
5204 bool& rCancel,
bool bApi )
5215 if (aName.isEmpty())
5218 OUString aContent(
ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).
Format(
5221 bool bInsert =
false;
5227 if (aOldStr != aContent)
5233 OUString aTemplate =
ScResId( STR_CREATENAME_REPLACE );
5234 OUString aMessage = aTemplate.getToken( 0,
'#' ) + aName + aTemplate.getToken( 1,
'#' );
5237 VclMessageType::Question, VclButtonsType::YesNo,
5240 xQueryBox->set_default_response(
RET_YES);
5242 short nResult = xQueryBox->run();
5260 if (!rList.
insert(pData))
5280 OSL_ENSURE(rRange.
aEnd.
Tab() == nTab,
"CreateNames: multiple tables not possible");
5284 if ( nStartRow == nEndRow )
5287 if ( nStartCol == nEndCol )
5308 SCCOL nContX1 = nStartCol;
5309 SCROW nContY1 = nStartRow;
5310 SCCOL nContX2 = nEndCol;
5311 SCROW nContY2 = nEndRow;
5322 bool bCancel =
false;
5327 for (i=nContX1; i<=nContX2; i++)
5328 CreateOneName( aNewRanges, i,nStartRow,nTab, i,nContY1,i,nContY2, bCancel, bApi );
5330 for (j=nContY1; j<=nContY2; j++)
5331 CreateOneName( aNewRanges, nStartCol,j,nTab, nContX1,j,nContX2,j, bCancel, bApi );
5333 for (i=nContX1; i<=nContX2; i++)
5334 CreateOneName( aNewRanges, i,nEndRow,nTab, i,nContY1,i,nContY2, bCancel, bApi );
5336 for (j=nContY1; j<=nContY2; j++)
5337 CreateOneName( aNewRanges, nEndCol,j,nTab, nContX1,j,nContX2,j, bCancel, bApi );
5339 if ( bTop && bLeft )
5340 CreateOneName( aNewRanges, nStartCol,nStartRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
5341 if ( bTop && bRight )
5342 CreateOneName( aNewRanges, nEndCol,nStartRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
5343 if ( bBottom && bLeft )
5344 CreateOneName( aNewRanges, nStartCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
5345 if ( bBottom && bRight )
5346 CreateOneName( aNewRanges, nEndCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
5348 ModifyRangeNames( aNewRanges, aTab );
5367 sal_uInt16 nValidCount = 0;
5368 for (
const auto& rEntry : *pLocalList)
5375 for (
const auto& rEntry : *pList)
5386 SCCOL nEndCol = nStartCol + 1;
5387 SCROW nEndRow = nStartRow +
static_cast<SCROW>(nValidCount) - 1;
5389 ScEditableTester aTester( rDoc, nTab, nStartCol,nStartRow, nEndCol,nEndRow );
5390 if (aTester.IsEditable())
5397 pUndoDoc->InitUndo( rDoc, nTab, nTab );
5398 rDoc.
CopyToDocument(nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
5404 std::unique_ptr<ScRangeData*[]> ppSortArray(
new ScRangeData* [ nValidCount ]);
5406 for (
const auto& rEntry : *pLocalList)
5410 ppSortArray[j++] = &r;
5412 for (
const auto& [rName, rxData] : *pList)
5416 ppSortArray[j++] = &r;
5418 qsort( static_cast<void*>(ppSortArray.get()), nValidCount,
sizeof(
ScRangeData*),
5421 OUStringBuffer aContent;
5423 SCROW nOutRow = nStartRow;
5424 for (j=0; j<nValidCount; j++)
5430 aFormula =
"=" + aContent.toString();
5438 ppSortArray.reset();
5443 pRedoDoc->InitUndo( rDoc, nTab, nTab );
5444 rDoc.
CopyToDocument(nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
5447 rDocShell.GetUndoManager()->AddUndoAction(
5448 std::make_unique<ScUndoListNames>( &rDocShell,
5449 ScRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab ),
5450 std::move(pUndoDoc), std::move(pRedoDoc) ) );
5453 if (!AdjustRowHeight(
ScRange(0,nStartRow,nTab,rDoc.
MaxCol(),nEndRow,nTab)))
5460 rDocShell.ErrorMessage(aTester.GetMessageId());
5473 rDoc.
GetFormula( nStartCol, nStartRow, nTab, aFormula );
5474 if ( !(aFormula.startsWith(
"{") && aFormula.endsWith(
"}")) )
5477 OUString aUndo =
ScResId( STR_UNDO_RESIZEMATRIX );
5483 nViewShellId = pViewSh->GetViewShellId();
5484 rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo, 0, nViewShellId );
5487 aFormula = aFormula.copy(1, aFormula.getLength()-2);
5491 aMark.SelectTable( nTab,
true );
5505 rDocShell.GetUndoManager()->LeaveListAction();
5509 const OUString& rOptions,
const OUString& rSource,
5511 bool bFitBlock,
bool bApi )
5522 sal_uInt16 nLinkCount = pLinkManager->
GetLinks().size();
5523 sal_uInt16 nRemoved = 0;
5524 sal_uInt16 nLinkPos = 0;
5525 while (nLinkPos<nLinkCount)
5536 OUString aUndo =
ScResId( STR_UNDO_INSERTAREALINK );
5539 nViewShellId = pViewSh->GetViewShellId();
5540 rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo, 0, nViewShellId );