36#include <osl/diagnose.h>
41#include <viewfunc.hxx>
62#include <drawview.hxx>
66#include <com/sun/star/util/XCloneable.hpp>
72void collectUIInformation(std::map<OUString, OUString>&& aParameters,
const OUString& action)
75 aDescription.
aID =
"grid_window";
78 aDescription.
aParent =
"MainWindow";
79 aDescription.
aKeyWord =
"ScGridWinUIObject";
128 pUndoDoc->InitUndoSelected( rDoc, rMark );
137 sal_uInt16 nExtFlags = 0;
150 std::make_unique<ScUndoCut>( pDocSh, aRange, aOldEnd, rMark, std::move(pUndoDoc) ) );
160 collectUIInformation({{
"RANGE", aStartAddress +
":" + aEndAddress}},
"CUT");
178 bDone =
CopyToClip( pClipDoc, aRangeList, bCut, bApi, bIncludeObjects, bStopEdit );
185 bDone =
CopyToClip( pClipDoc, aRangeList, bCut, bApi, bIncludeObjects, bStopEdit );
195 collectUIInformation({{
"RANGE", aStartAddress +
":" + aEndAddress}},
"COPY");
203 if ( rRanges.
empty() )
209 if (rRanges.
size() > 1)
228 bool bSysClip =
false;
229 std::shared_ptr<ScDocument> pSysClipDoc;
234 pClipDoc = pSysClipDoc.get();
244 if ( bSysClip && bIncludeObjects )
259 uno::Reference<util::XCloneable> xCloneable(pObjectShell->getDocProperties(), uno::UNO_QUERY_THROW);
261 pOptions->m_xDocumentProperties.set(xCloneable->createClone(), uno::UNO_QUERY);
265 rDoc.
CopyToClip( aClipParam, pClipDoc, &rMark,
false, bIncludeObjects );
271 for (
SCTAB nTab = 0; nTab < nTabCount; ++nTab )
273 SdrPage* pPage = pDrawLayer->GetPage(
static_cast< sal_uInt16
>( nTab ) );
300 pTransferObj->SetDrawPersist( aPersistRef );
330 bool bSuccess =
false;
338 bool bValidRanges =
true;
340 SCCOL nPrevColDelta = 0;
341 SCROW nPrevRowDelta = 0;
342 SCCOL nPrevCol =
p->aStart.Col();
343 SCROW nPrevRow =
p->aStart.Row();
344 SCCOL nPrevColSize =
p->aEnd.Col() -
p->aStart.Col() + 1;
345 SCROW nPrevRowSize =
p->aEnd.Row() -
p->aStart.Row() + 1;
350 p->aStart.Col(),
p->aStart.Row(),
p->aEnd.Col(),
p->aEnd.Row(), rMark) )
357 SCCOL nColDelta =
p->aStart.Col() - nPrevCol;
358 SCROW nRowDelta =
p->aStart.Row() - nPrevRow;
360 if ((nColDelta && nRowDelta) || (nPrevColDelta && nRowDelta) || (nPrevRowDelta && nColDelta))
362 bValidRanges =
false;
374 SCCOL nColSize =
p->aEnd.Col() -
p->aStart.Col() + 1;
375 SCROW nRowSize =
p->aEnd.Row() -
p->aStart.Row() + 1;
380 bValidRanges =
false;
387 bValidRanges =
false;
391 nPrevCol =
p->aStart.Col();
392 nPrevRow =
p->aStart.Row();
393 nPrevColDelta = nColDelta;
394 nPrevRowDelta = nRowDelta;
395 nPrevColSize = nColSize;
396 nPrevRowSize = nRowSize;
400 rDoc.
CopyToClip(aClipParam, pDocClip.get(), &rMark,
false, bIncludeObjects );
416 pTransferObj->SetDrawPersist( aPersistRef );
424 if (!bSuccess && !bApi)
450 rDoc.
CopyToClip(aClipParam, pClipDoc.get(), &rMark,
false,
true);
453 pClipDoc->ExtendMerge( aRange,
true );
459 return new ScTransferObj( std::move(pClipDoc), std::move(aObjDesc) );
479 const OUString& aSrcShellID = pDrawClip->
GetShellID();
513 uno::Reference<css::datatransfer::XTransferable> xTransferable( aDataHelper.
GetXTransferable() );
516 SotExchangeDest::SCDOC_FREE_AREA,
519 nFormat, nEventAction, SotClipboardFormatId::NONE,
546 if (aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ))
549 if( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) )
553 else if( aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) )
562 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ))
576 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ) );
579 PasteFromSystem( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT );
580 else if ( aObjDesc.
maClassName ==
SvGlobalName( 0,0,0,0,0,0,0,0,0,0,0 )
581 && aDataHelper.
HasFormat( SotClipboardFormatId::SYLK ))
586 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ))
589 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ))
596 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RTF))
598 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RICHTEXT))
600 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML))
602 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML_SIMPLE))
604 else if (aDataHelper.
HasFormat(SotClipboardFormatId::SYLK))
606 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING_TSVC))
608 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING))
611 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ))
613 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ))
624 if (
auto pOwnClip =
dynamic_cast<ScTransferObj*
>(rxTransferable.get()))
630 else if (
auto pDrawClip =
dynamic_cast<ScDrawTransferObj*
>(rxTransferable.get()))
638 aPos, pDrawClip->GetModel(),
false,
650 if (aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ))
651 nFormatId = SotClipboardFormatId::DRAWING;
652 else if (aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ))
653 nFormatId = SotClipboardFormatId::SVXB;
654 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ))
663 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ));
666 nFormatId = aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
668 nFormatId = SotClipboardFormatId::EMBED_SOURCE;
670 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ))
671 nFormatId = SotClipboardFormatId::LINK_SOURCE;
673 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ))
674 nFormatId = SotClipboardFormatId::EMBEDDED_OBJ_OLE;
680 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RTF))
681 nFormatId = SotClipboardFormatId::RTF;
682 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RICHTEXT))
683 nFormatId = SotClipboardFormatId::RICHTEXT;
684 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML))
685 nFormatId = SotClipboardFormatId::HTML;
686 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML_SIMPLE))
687 nFormatId = SotClipboardFormatId::HTML_SIMPLE;
688 else if (aDataHelper.
HasFormat(SotClipboardFormatId::SYLK))
689 nFormatId = SotClipboardFormatId::SYLK;
690 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING_TSVC))
691 nFormatId = SotClipboardFormatId::STRING_TSVC;
692 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING))
693 nFormatId = SotClipboardFormatId::STRING;
694 else if (aDataHelper.
HasFormat(SotClipboardFormatId::GDIMETAFILE))
695 nFormatId = SotClipboardFormatId::GDIMETAFILE;
696 else if (aDataHelper.
HasFormat(SotClipboardFormatId::BITMAP))
697 nFormatId = SotClipboardFormatId::BITMAP;
699 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ))
700 nFormatId = SotClipboardFormatId::EMBED_SOURCE_OLE;
701 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ))
702 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
719 if ( nFormatId == SotClipboardFormatId::NONE && pOwnClip )
749 nullptr,
false, !bApi );
751 if ( !bRet && !bApi )
759 true ,
false ,
false ,
false , rViewData.
GetTabNo());
768 const uno::Reference<datatransfer::XTransferable>& rxTransferable,
773 if ( aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ) )
784 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
792 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
797 if( pScDrawView && aDataHelper.
GetGDIMetaFile( SotClipboardFormatId::GDIMETAFILE, aMtf ) )
799 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
807 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BITMAP ) || aDataHelper.
HasFormat( SotClipboardFormatId::PNG ) )
812 if( pScDrawView && aDataHelper.
GetBitmapEx( SotClipboardFormatId::BITMAP, aBmpEx ) )
814 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
829 return std::any_of(rTabSelection.
begin(), rTabSelection.
end(),
830 [&](
const SCTAB& rTab) { return rDoc.HasAttrib( nCol1, nRow1, rTab, nCol2, nRow2, rTab, nMask ); });
841 bool bIsEmpty =
true;
842 size_t nRangeSize = rDestRanges.
size();
843 for (
const auto& rTab : rMark)
845 for (
size_t i = 0;
i < nRangeSize && bIsEmpty; ++
i)
847 const ScRange& rRange = rDestRanges[
i];
859 if (aBox.run() != RET_YES)
872 bool bTranspose,
bool bAsLink,
878 OSL_FAIL(
"PasteFromClip: pClipDoc=0 not allowed");
903 bAsLink, bAllowDialogs, eMoveMode, nUndoFlags);
911 nFlags, pClipDoc, nFunction, bSkipEmptyCells, bTranspose, bAsLink, bAllowDialogs,
912 eMoveMode, nUndoFlags);
916 bool bIncludeFiltered = bCutMode;
930 if ( nY >
static_cast<sal_Int32
>(pClipDoc->
MaxCol()) )
935 pOrigClipDoc = pClipDoc;
940 aTransShellRef->DoInitNew();
945 pClipDoc->
TransposeClip(xTransClip.get(), nFlags, bAsLink, bIncludeFiltered);
946 pClipDoc = xTransClip.get();
962 pClipDoc->
GetClipArea( nClipSizeX, nClipSizeY,
true );
967 pClipDoc->
GetClipArea( nDestSizeX, nDestSizeY, bIncludeFiltered );
980 bool bNoPaste = ((eMarkType !=
SC_MARK_SIMPLE && !bMarkIsFiltered) ||
981 (bMarkIsFiltered && (eMoveMode !=
INS_NONE || bAsLink)));
992 nEndCol = nStartCol + nDestSizeX;
993 nEndRow = nStartRow + nDestSizeY;
995 aMarkRange =
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
998 bMarkIsFiltered =
true;
1028 if (bMarkIsFiltered)
1032 nUnfilteredRows = 0;
1033 size_t ListSize = aRangeList.
size();
1034 for (
size_t i = 0;
i < ListSize; ++
i )
1044 if ((nUnfilteredRows % (nDestSizeY+1)) != 0)
1054 if ( aFilteredMark.
IsMarked() || bMarkIsFiltered )
1056 aMarkRange.
GetVars( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
1057 SCCOL nBlockAddX = nEndCol-nStartCol;
1058 SCROW nBlockAddY = nEndRow-nStartRow;
1064 if ( ( nBlockAddX != 0 && nBlockAddX < nDestSizeX ) ||
1065 ( nBlockAddY != 0 && nBlockAddY < nDestSizeY ) ||
1066 ( bMarkIsFiltered && nUnfilteredRows < nDestSizeY+1 ) )
1069 OUString aMessage =
ScResId( STR_PASTE_BIGGER );
1072 VclMessageType::Question, VclButtonsType::YesNo,
1074 xQueryBox->set_default_response(
RET_NO);
1075 if (xQueryBox->run() !=
RET_YES)
1081 if (nBlockAddX <= nDestSizeX)
1082 nEndCol = nStartCol + nDestSizeX;
1084 if (nBlockAddY <= nDestSizeY)
1086 nEndRow = nStartRow + nDestSizeY;
1087 if (bMarkIsFiltered || nEndRow > aMarkRange.
aEnd.
Row())
1093 aMarkRange =
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
1096 bMarkIsFiltered =
true;
1104 aMarkRange.
GetVars( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
1106 if (bMarkIsFiltered)
1119 nEndCol = nStartCol + nDestSizeX;
1120 nEndRow = nStartRow + nDestSizeY;
1121 nEndTab = nStartTab;
1127 ScRange aUserRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab );
1131 bool bInsertCells = ( eMoveMode !=
INS_NONE && !bOffLimits );
1150 else if (!bOffLimits)
1152 bool bAskIfNotEmpty = bAllowDialogs &&
1155 SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
1156 if ( bAskIfNotEmpty )
1159 if (!checkDestRangeForOverwrite(aTestRanges, rDoc, aFilteredMark,
GetViewData().GetDialogParent()))
1167 SCCOL nUndoEndCol = nClipStartX + nClipSizeX;
1168 SCROW nUndoEndRow = nClipStartY + nClipSizeY;
1169 bool bClipOver =
false;
1174 if ( pClipDoc->
HasTable(nClipTab) )
1175 if ( pClipDoc->
ExtendMerge( nClipStartX,nClipStartY, nUndoEndCol,nUndoEndRow, nClipTab ) )
1177 nUndoEndCol -= nClipStartX + nClipSizeX;
1178 nUndoEndRow -= nClipStartY + nClipSizeY;
1179 nUndoEndCol = sal::static_int_cast<SCCOL>( nUndoEndCol + nEndCol );
1180 nUndoEndRow = sal::static_int_cast<SCROW>( nUndoEndRow + nEndRow );
1182 if (nUndoEndCol>pClipDoc->
MaxCol() || nUndoEndRow>pClipDoc->
MaxRow())
1188 rDoc.
ExtendMergeSel( nStartCol,nStartRow, nUndoEndCol,nUndoEndRow, aFilteredMark );
1192 ScEditableTester aTester( rDoc, nStartTab, nStartCol,nStartRow, nUndoEndCol,nUndoEndRow );
1205 OUString aUndo =
ScResId( pClipDoc->
IsCutMode() ? STR_UNDO_MOVE : STR_UNDO_COPY );
1212 ScDocAttrIterator aIter( rDoc, nStartTab, nStartCol, nStartRow, nUndoEndCol, nUndoEndRow );
1217 while ( ( pPattern = aIter.
GetNext( nCol, nRow1, nRow2 ) ) !=
nullptr )
1223 ScRange aRange(nCol, nRow1, nStartTab);
1238 bool bColInfo = ( nStartRow==0 && nEndRow==rDoc.
MaxRow() );
1239 bool bRowInfo = ( nStartCol==0 && nEndCol==rDoc.
MaxCol() );
1242 std::unique_ptr<ScDocument> pRefUndoDoc;
1243 std::unique_ptr<ScRefUndoData> pUndoData;
1248 pUndoDoc->InitUndoSelected( rDoc, aFilteredMark, bColInfo, bRowInfo );
1252 rDoc.
CopyToDocument( nStartCol, nStartRow, 0, nUndoEndCol, nUndoEndRow, nTabCount-1,
1253 nUndoFlags,
false, *pUndoDoc );
1258 pRefUndoDoc->InitUndo( rDoc, 0, nTabCount-1 );
1264 sal_uInt16 nExtFlags = 0;
1265 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
1266 nEndCol, nEndRow, nEndTab );
1282 bSkipEmptyCells =
false;
1286 pMixDoc->InitUndo( rDoc, nStartTab, nEndTab );
1287 rDoc.
CopyToDocument(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
1305 rDoc.
CopyFromClip( aUserRange, aFilteredMark, nNoObjFlags,
1306 pRefUndoDoc.get(), pClipDoc,
true,
false, bIncludeFiltered,
1307 bSkipEmptyCells, (bMarkIsFiltered ? &aRangeList :
nullptr) );
1313 else if (!bTranspose)
1316 rDoc.
CopyFromClip( aUserRange, aFilteredMark, nNoObjFlags, pRefUndoDoc.get(), pClipDoc,
1317 true,
true, bIncludeFiltered, bSkipEmptyCells );
1322 rDoc.
CopyFromClip( aUserRange, aFilteredMark, nContFlags, pRefUndoDoc.get(), pClipDoc );
1329 rDoc.
ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, aFilteredMark,
true );
1334 rDoc.
MixDocument( aUserRange, nFunction, bSkipEmptyCells, *pMixDoc );
1340 ::std::vector< OUString > aExcludedChartNames;
1347 pPage = ( pModel ? pModel->
GetPage(
static_cast< sal_uInt16
>( nStartTab ) ) :
nullptr );
1356 true,
false, bIncludeFiltered );
1359 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
1360 nEndCol, nEndRow, nEndTab );
1365 nClipStartY+nClipSizeY, nStartTab ))
1368 ScRange(nClipStartX, nClipStartY, nStartTab, nClipStartX+nClipSizeX, nClipStartY, nStartTab),
1383 pRedoDoc->InitUndo( rDoc, nStartTab, nEndTab, bColInfo, bRowInfo );
1388 pRedoDoc->AddUndoTab( 0, nTabCount-1 );
1389 rDoc.
CopyUpdated( pRefUndoDoc.get(), pRedoDoc.get() );
1394 pUndoDoc->AddUndoTab( 0, nTabCount-1 );
1395 pRefUndoDoc->DeleteArea( nStartCol, nStartRow, nEndCol, nEndRow, aFilteredMark,
InsertDeleteFlags::ALL );
1396 pRefUndoDoc->CopyToDocument( 0,0,0, pUndoDoc->MaxCol(), pUndoDoc->MaxRow(), nTabCount-1,
1398 pRefUndoDoc.reset();
1411 std::unique_ptr<SfxUndoAction> pUndo(
new ScUndoPaste(
1412 pDocSh,
ScRange(nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab),
1413 aFilteredMark, std::move(pUndoDoc), std::move(pRedoDoc), nFlags | nUndoFlags, std::move(pUndoData),
1414 false, &aOptions ));
1421 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoWrapper>( std::move(pUndo) ),
true );
1432 nUndoEndCol = rDoc.
MaxCol();
1437 nUndoEndRow = rDoc.
MaxRow();
1440 ScRange(nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab),
1450 if ( pPage && pModelObj )
1455 rProtectedChartRangesVector, aExcludedChartNames, bSameDoc );
1460 collectUIInformation({{
"RANGE", aStartAddress +
":" + aEndAddress}},
"PASTE");
1466 bool bTranspose,
bool bAsLink,
1481 if (
static_cast<SCROW>(rCurPos.
Col()) + nRowSize-1 >
static_cast<SCROW>(pClipDoc->
MaxCol()))
1488 pClipDoc->
TransposeClip(pTransClip.get(), nFlags, bAsLink,
false);
1489 pClipDoc = pTransClip.release();
1490 SCCOL nTempColSize = nColSize;
1491 nColSize =
static_cast<SCCOL>(nRowSize);
1492 nRowSize =
static_cast<SCROW>(nTempColSize);
1511 rCurPos.
Col()+nColSize-1, rCurPos.
Row()+nRowSize-1, nTab2);
1521 bool bAskIfNotEmpty =
1528 if (!checkDestRangeForOverwrite(aTestRanges, rDoc, aMark,
GetViewData().GetDialogParent()))
1535 bool bInsertCells = (eMoveMode !=
INS_NONE);
1550 pUndoDoc->InitUndoSelected(rDoc, aMark,
false, bRowInfo);
1551 rDoc.
CopyToDocument(aMarkedRange, nUndoFlags,
false, *pUndoDoc, &aMark);
1560 pMixDoc->InitUndoSelected(rDoc, aMark);
1576 if (bAsLink && bTranspose)
1579 false, bSkipEmptyCells);
1582 rDoc.
MixDocument(aMarkedRange, nFunction, bSkipEmptyCells, *pMixDoc);
1590 false,
false,
true);
1607 pClipDoc->
IsCutMode() ? STR_UNDO_CUT : STR_UNDO_COPY);
1617 std::unique_ptr<ScUndoPaste> pUndo(
new ScUndoPaste(pDocSh,
1618 aMarkedRange, aMark, std::move(pUndoDoc),
nullptr, nFlags|nUndoFlags,
nullptr,
false, &aOptions));
1621 pUndoMgr->
AddUndoAction(std::make_unique<ScUndoWrapper>(std::move(pUndo)),
true);
1635 bool bSkipEmptyCells,
bool bTranspose,
bool bAsLink,
bool bAllowDialogs,
1689 bool bAskIfNotEmpty =
1695 if (!checkDestRangeForOverwrite(aRanges, rDoc, aMark,
GetViewData().GetDialogParent()))
1706 pUndoDoc->InitUndoSelected(rDoc, aMark);
1707 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1710 aRanges[
i], nUndoFlags,
false, *pUndoDoc, &aMark);
1720 pMixDoc->InitUndoSelected(rDoc, aMark);
1721 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1735 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1739 false,
false,
true, bSkipEmptyCells);
1744 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1745 rDoc.
MixDocument(aRanges[
i], nFunction, bSkipEmptyCells, *pMixDoc);
1753 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1757 false,
false,
true, bSkipEmptyCells);
1773 pClipDoc->
IsCutMode() ? STR_UNDO_CUT : STR_UNDO_COPY);
1785 std::make_unique<ScUndoPaste>(
1786 pDocSh, aRanges, aMark, std::move(pUndoDoc),
nullptr, nFlags|nUndoFlags,
nullptr,
false, &aOptions));
1807 for (
size_t i = 0,
n = rPasteRanges.
size();
i <
n; ++
i)
1809 const ScRange& r = rPasteRanges[
i];
1810 for (
const auto& rTab : rMark)
1837 bool bSuccess =
true;
1844 OUString aUndo =
ScResId( bCut ? STR_UNDO_MOVE : STR_UNDO_COPY );
1849 ScRange aLocalSource = rSource;
1852 SCTAB nStartTab = 0;
1853 while ( nStartTab < nTabCount && bSuccess )
1855 while ( nStartTab < nTabCount && !rMark.
GetTableSelect(nStartTab) )
1857 if ( nStartTab < nTabCount )
1859 SCTAB nEndTab = nStartTab;
1860 while ( nEndTab+1 < nTabCount && rMark.
GetTableSelect(nEndTab+1) )
1865 aLocalDest.
SetTab( nStartTab );
1868 aLocalSource, aLocalDest, bCut,
true,
true,
true );
1870 nStartTab = nEndTab + 1;
1880 rSource, rDestPos, bCut,
true,
true,
true );
1892 bool bIncludeFiltered = bCut;
1893 if ( !bIncludeFiltered )
1899 if ( nPastedCount == 0 )
1901 aDestEnd.
SetRow( rDestPos.
Row() + nPastedCount - 1 );
1955 std::vector<std::unique_ptr<ScDataFormFragment>>& rEdits,
1956 sal_uInt16 aColLength )
1967 std::unique_ptr<ScRefUndoData> pUndoData;
1969 SCTAB nStartTab = nTab;
1970 SCTAB nEndTab = nTab;
1977 ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
1978 bool bColInfo = ( nStartRow==0 && nEndRow==rDoc.
MaxRow() );
1979 bool bRowInfo = ( nStartCol==0 && nEndCol==rDoc.
MaxCol() );
1980 SCCOL nUndoEndCol = nStartCol+aColLength-1;
1981 SCROW nUndoEndRow = nCurrentRow;
1986 pUndoDoc->InitUndoSelected( rDoc , rMark , bColInfo , bRowInfo );
1989 sal_uInt16 nExtFlags = 0;
1990 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab );
1993 for(sal_uInt16
i = 0;
i < aColLength;
i++)
1995 if (rEdits[
i] !=
nullptr)
1997 OUString aFieldName = rEdits[
i]->m_xEdit->get_text();
1998 rDoc.
SetString( nStartCol +
i, nCurrentRow, nTab, aFieldName );
2001 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
2002 std::unique_ptr<SfxUndoAction> pUndo(
new ScUndoDataForm( pDocSh,
2003 nStartCol, nCurrentRow, nStartTab,
2004 nUndoEndCol, nUndoEndRow, nEndTab, rMark,
2005 std::move(pUndoDoc), std::move(pRedoDoc),
2006 std::move(pUndoData) ) );
2007 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoWrapper>( std::move(pUndo) ),
true );
2013 nUndoEndCol = rDoc.
MaxCol();
2018 nUndoEndRow = rDoc.
MaxRow();
2022 ScRange(nStartCol, nCurrentRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab),
::std::vector< ScRangeList > ScRangeListVector
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetColRowString() const
Create a human-readable string representation of the cell address.
static void CreateProtectedChartListenersAndNotify(ScDocument &rDoc, const SdrPage *pPage, ScModelObj *pModelObj, SCTAB nTab, const ScRangeListVector &rRangesVector, const ::std::vector< OUString > &rExcludedChartNames, bool bSameDoc=true)
static void GetChartNames(::std::vector< OUString > &rChartNames, const SdrPage *pPage)
static void FillProtectedChartRangesVector(ScRangeListVector &rRangesVector, const ScDocument &rDocument, const SdrPage *pPage)
Stores options which are only relevant for clipboard documents.
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
bool MoveBlock(const ScRange &rSource, const ScAddress &rDestPos, bool bCut, bool bRecord, bool bPaint, bool bApi)
bool UnmergeCells(const ScRange &rRange, bool bRecord, ScUndoRemoveMerge *pUndoRemoveMerge)
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
const ScDocument & GetDocument() const
void UpdatePaintExt(sal_uInt16 &rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab)
ScDrawLayer * MakeDrawLayer()
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
ScModelObj * GetModel() const
virtual SfxUndoManager * GetUndoManager() override
SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
SC_DLLPUBLIC void CopyFromClip(const ScRange &rDestRange, const ScMarkData &rMark, InsertDeleteFlags nInsFlag, ScDocument *pRefUndoDoc, ScDocument *pClipDoc, bool bResetCut=true, bool bAsLink=false, bool bIncludeFiltered=true, bool bSkipEmptyCells=false, const ScRangeList *pDestRanges=nullptr)
Paste data from a clipboard document into this document.
bool RefreshAutoFilter(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC void CopyUpdated(ScDocument *pPosDoc, ScDocument *pDestDoc)
From this document this method copies the cells of positions at which there are also cells in pPosDoc...
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
ScClipParam & GetClipParam()
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
bool HasClipFilteredRows()
SC_DLLPUBLIC void TransposeClip(ScDocument *pTransClip, InsertDeleteFlags nFlags, bool bAsLink, bool bIncludeFiltered)
SC_DLLPUBLIC void DeleteSelection(InsertDeleteFlags nDelFlag, const ScMarkData &rMark, bool bBroadcast=true)
bool HasOLEObjectsInArea(const ScRange &rRange, const ScMarkData *pTabMark=nullptr)
SC_DLLPUBLIC void CopyToClip(const ScClipParam &rClipParam, ScDocument *pClipDoc, const ScMarkData *pMarks, bool bKeepScenarioFlags, bool bIncludeObjects)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
sal_uInt32 GetDocumentID() const
an ID unique to each document instance
void DeleteObjectsInSelection(const ScMarkData &rMark)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
void ExtendMergeSel(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, const ScMarkData &rMark, bool bRefresh=false)
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)
SfxObjectShell * GetDocumentShell() const
void GetClipArea(SCCOL &nClipX, SCROW &nClipY, bool bIncludeFiltered)
bool ValidCol(SCCOL nCol) const
SC_DLLPUBLIC void ExtendOverlapped(SCCOL &rStartCol, SCROW &rStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
void SetClipOptions(std::unique_ptr< ScClipOptions > pClipOptions)
void SetCutMode(bool bCut)
void CopyTabToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, ScDocument *pClipDoc)
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
bool IsBlockEmpty(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
bool IsUndoEnabled() const
void CopyMultiRangeFromClip(const ScAddress &rDestPos, const ScMarkData &rMark, InsertDeleteFlags nInsFlag, ScDocument *pClipDoc, bool bResetCut=true, bool bAsLink=false, bool bIncludeFiltered=true, bool bSkipAttrForEmpty=false)
bool HasSelectedBlockMatrixFragment(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScMarkData &rMark) const
void MixDocument(const ScRange &rRange, ScPasteFunc nFunction, bool bSkipEmpty, ScDocument &rSrcDoc)
SC_DLLPUBLIC void UpdateTranspose(const ScAddress &rDestPos, ScDocument *pClipDoc, const ScMarkData &rMark, ScDocument *pUndoDoc)
void GetClipStart(SCCOL &nClipX, SCROW &nClipY)
SC_DLLPUBLIC SCTAB GetTableCount() const
static void SetGlobalDrawPersist(SfxObjectShell *pPersist)
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
SdrModel * GetModel() const
const OUString & GetShellID() const
SdrObject * ApplyGraphicToObject(SdrObject &rHitObject, const Graphic &rGraphic, const OUString &rBeginUndoText, const OUString &rFile)
TranslateId GetMessageId() const
static tools::SvRef< ScDocShell > xDrawClipDocShellRef
static void SetClipDocName(const OUString &rNew)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
const_iterator end() const
const ScRange & GetMarkArea() const
SCTAB GetFirstSelected() const
bool IsMultiMarked() const
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
SCTAB GetLastSelected() const
bool GetTableSelect(SCTAB nTab) const
SCTAB GetSelectCount() const
void SetMarkArea(const ScRange &rRange)
const_iterator begin() const
bool IsOverlapped() const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
void push_back(const ScRange &rRange)
void GetVars(SCCOL &nCol1, SCROW &nRow1, SCTAB &nTab1, SCCOL &nCol2, SCROW &nRow2, SCTAB &nTab2) const
Warning box for "Replace cell contents?".
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...
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
void DoneBlockMode(bool bContinue=false)
void ErrorMessage(TranslateId pGlobStrId)
void SelectionChanged(bool bFromPaste=false)
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
vcl::Window * GetFrameWin() const
SC_DLLPUBLIC void MoveCursorAbs(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, bool bShift, bool bControl, bool bKeepOld=false, bool bKeepSel=false)
static void UpdateInputLine()
ScViewData & GetViewData()
ScGridWindow * GetActiveWin()
void ResetAutoSpellForContentChange()
SC_DLLPUBLIC void CellContentChanged()
ScDrawView * GetScDrawView()
void InitOwnBlockMode(const ScRange &rMarkRange)
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
ScDocument * GetDocument() const
static SfxObjectShell * SetDrawClipDoc(bool bAnyOle, const std::shared_ptr< ScDocument > &={})
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
ScMarkData & GetMarkData()
ScDocument & GetDocument() const
ScDocShell * GetDocShell() const
ScGridWindow * GetActiveWin()
ScTabViewShell * GetViewShell() const
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
ScSplitPos GetActivePart() const
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
ScAddress GetCurPos() const
void PasteFromTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable)
bool CopyToClipMultiRange(const ScDocument *pClipDoc, const ScRangeList &rRanges, bool bCut, bool bApi, bool bIncludeObjects)
rtl::Reference< ScTransferObj > CopyToTransferable()
bool InsertCells(InsCellCmd eCmd, bool bRecord=true, bool bPartOfPaste=false)
SC_DLLPUBLIC void CutToClip()
void PostPasteFromClip(const ScRangeList &rPasteRanges, const ScMarkData &rMark)
bool PasteFromClipToMultiRanges(InsertDeleteFlags nFlags, ScDocument *pClipDoc, ScPasteFunc nFunction, bool bSkipEmptyCells, bool bTranspose, bool bAsLink, bool bAllowDialogs, InsCellCmd eMoveMode, InsertDeleteFlags nUndoFlags)
bool PasteMultiRangesFromClip(InsertDeleteFlags nFlags, ScDocument *pClipDoc, ScPasteFunc nFunction, bool bSkipEmptyCells, bool bTranspose, bool bAsLink, bool bAllowDialogs, InsCellCmd eMoveMode, InsertDeleteFlags nUndoFlags)
SC_DLLPUBLIC void DataFormPutData(SCROW nCurrentRow, SCROW nStartRow, SCCOL nStartCol, SCROW nEndRow, SCCOL nEndCol, std::vector< std::unique_ptr< ScDataFormFragment > > &rEdits, sal_uInt16 aColLength)
bool PasteOnDrawObjectLinked(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable, SdrObject &rHitObj)
bool AdjustBlockHeight(bool bPaint=true, ScMarkData *pMarkData=nullptr)
SC_DLLPUBLIC void PasteFromSystem()
bool CopyToClipSingleRange(ScDocument *pClipDoc, const ScRangeList &rRanges, bool bCut, bool bIncludeObjects)
bool PasteDataFormat(SotClipboardFormatId nFormatId, const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable, SCCOL nPosX, SCROW nPosY, const Point *pLogicPos, bool bLink=false, bool bAllowDialogs=false)
SC_DLLPUBLIC bool CopyToClip(ScDocument *pClipDoc, bool bCut, bool bApi=false, bool bIncludeObjects=false, bool bStopEdit=true)
SC_DLLPUBLIC bool PasteFromClip(InsertDeleteFlags nFlags, ScDocument *pClipDoc, ScPasteFunc nFunction=ScPasteFunc::NONE, bool bSkipEmptyCells=false, bool bTranspose=false, bool bAsLink=false, InsCellCmd eMoveMode=INS_NONE, InsertDeleteFlags nUndoExtraFlags=InsertDeleteFlags::NONE, bool bAllowDialogs=false)
bool LinkBlock(const ScRange &rSource, const ScAddress &rDestPos)
bool MoveBlockTo(const ScRange &rSource, const ScAddress &rDestPos, bool bCut)
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, bool bApi)
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument &rDoc)
static bool FitToUnfilteredRows(ScRange &rRange, const ScDocument &rDoc, size_t nRows)
Fit a range to cover nRows number of unfiltered rows.
static bool HasFiltered(const ScRange &rRange, const ScDocument &rDoc)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrModel & GetModel() const
const INetURLObject & GetURLObject() const
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
static OUString CreateShellID(const SfxObjectShell *pShell)
SfxMedium * GetMedium() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
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)
static sal_uInt8 GetExchangeAction(const DataFlavorExVector &rDataFlavorExVector, SotExchangeDest nDestination, sal_uInt16 nSourceOptions, sal_uInt8 nUserAction, SotClipboardFormatId &rFormat, sal_uInt8 &rDefaultAction, SotClipboardFormatId nOnlyTestFormat=SotClipboardFormatId::NONE, const css::uno::Reference< css::datatransfer::XTransferable > *pxTransferable=nullptr, SotExchangeActionFlags *pActionFlags=nullptr)
static SotClipboardFormatId RegisterFormatName(const OUString &rName)
bool GetTransferableObjectDescriptor(SotClipboardFormatId nFormat, TransferableObjectDescriptor &rDesc)
const DataFlavorExVector & GetDataFlavorExVector() const
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
bool GetGDIMetaFile(SotClipboardFormatId nFormat, GDIMetaFile &rMtf, size_t nMaxActions=0) const
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool GetBitmapEx(SotClipboardFormatId nFormat, BitmapEx &rBmp) const
css::uno::Reference< css::datatransfer::XTransferable > GetXTransferable() const
void readGraphic(Graphic &rGraphic)
static UITestLogger & getInstance()
void logEvent(const EventDescription &rDescription)
#define SO3_SWWEB_CLASSID
Point PixelToLogic(const Point &rDevicePt) const
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
#define EXCHG_OUT_ACTION_INSERT_GDIMETAFILE
#define EXCHG_OUT_ACTION_INSERT_BITMAP
#define EXCHG_INOUT_ACTION_NONE
#define EXCHG_OUT_ACTION_INSERT_GRAPH
#define EXCHG_IN_ACTION_COPY
#define EXCHG_OUT_ACTION_INSERT_SVXB
#define EXCHG_IN_ACTION_DEFAULT
@ NOTE
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
@ NOCAPTIONS
Sparklines in a cell.
@ ATTRIB
Internal use only (d&d undo): do not delete caption objects of cell notes.
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 >())
bool getMustPropagateChangesModel(ScModelObj *pModelObj)
bool CheckDestRanges(const ScDocument &rDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData &rMark, const ScRangeList &rDest)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define SFX_TITLE_FULLNAME
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
std::map< OUString, OUString > aParameters
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
void setSourceDocID(sal_uInt32 nVal)
bool isMultiRange() const
SCCOL getPasteColSize()
Get the column size of a pasted range.
SCROW getPasteRowSize(const ScDocument &rSrcDoc, bool bIncludeFiltered)
Same as the above method, but returns the row size of the compressed range.
sal_uInt32 getSourceDocID() const
ScRangeListVector maProtectedChartRangesVector
ScRange getWholeRange() const
Return a single range that encompasses all individual ranges.
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
@ SC_MARK_SIMPLE_FILTERED
static bool lcl_SelHasAttrib(const ScDocument &rDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData &rTabSelection, HasAttrFlags nMask)