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 std::shared_ptr<ScDocument> pSysClipDoc;
233 pClipDoc = pSysClipDoc.get();
242 if ( pSysClipDoc && bIncludeObjects )
257 uno::Reference<util::XCloneable> xCloneable(pObjectShell->getDocProperties(), uno::UNO_QUERY_THROW);
259 pOptions->m_xDocumentProperties.set(xCloneable->createClone(), uno::UNO_QUERY);
263 rDoc.
CopyToClip( aClipParam, pClipDoc, &rMark,
false, bIncludeObjects );
269 for (
SCTAB nTab = 0; nTab < nTabCount; ++nTab )
271 SdrPage* pPage = pDrawLayer->GetPage(
static_cast< sal_uInt16
>( nTab ) );
298 pTransferObj->SetDrawPersist( aPersistRef );
328 bool bSuccess =
false;
336 bool bValidRanges =
true;
338 SCCOL nPrevColDelta = 0;
339 SCROW nPrevRowDelta = 0;
340 SCCOL nPrevCol =
p->aStart.Col();
341 SCROW nPrevRow =
p->aStart.Row();
342 SCCOL nPrevColSize =
p->aEnd.Col() -
p->aStart.Col() + 1;
343 SCROW nPrevRowSize =
p->aEnd.Row() -
p->aStart.Row() + 1;
348 p->aStart.Col(),
p->aStart.Row(),
p->aEnd.Col(),
p->aEnd.Row(), rMark) )
355 SCCOL nColDelta =
p->aStart.Col() - nPrevCol;
356 SCROW nRowDelta =
p->aStart.Row() - nPrevRow;
358 if ((nColDelta && nRowDelta) || (nPrevColDelta && nRowDelta) || (nPrevRowDelta && nColDelta))
360 bValidRanges =
false;
372 SCCOL nColSize =
p->aEnd.Col() -
p->aStart.Col() + 1;
373 SCROW nRowSize =
p->aEnd.Row() -
p->aStart.Row() + 1;
378 bValidRanges =
false;
385 bValidRanges =
false;
389 nPrevCol =
p->aStart.Col();
390 nPrevRow =
p->aStart.Row();
391 nPrevColDelta = nColDelta;
392 nPrevRowDelta = nRowDelta;
393 nPrevColSize = nColSize;
394 nPrevRowSize = nRowSize;
398 rDoc.
CopyToClip(aClipParam, pDocClip.get(), &rMark,
false, bIncludeObjects );
414 pTransferObj->SetDrawPersist( aPersistRef );
422 if (!bSuccess && !bApi)
449 rDoc.
CopyToClip(aClipParam, pClipDoc.get(), &rMark,
false,
true);
452 pClipDoc->ExtendMerge( aRange,
true );
458 return new ScTransferObj( std::move(pClipDoc), std::move(aObjDesc) );
478 const OUString& aSrcShellID = pDrawClip->
GetShellID();
512 uno::Reference<css::datatransfer::XTransferable> xTransferable( aDataHelper.
GetXTransferable() );
515 SotExchangeDest::SCDOC_FREE_AREA,
518 nFormat, nEventAction, SotClipboardFormatId::NONE,
545 if (aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ))
548 if( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) )
552 else if( aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) )
561 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ))
575 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ) );
578 PasteFromSystem( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT );
579 else if ( aObjDesc.
maClassName ==
SvGlobalName( 0,0,0,0,0,0,0,0,0,0,0 )
580 && aDataHelper.
HasFormat( SotClipboardFormatId::SYLK ))
585 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ))
588 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ))
595 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RTF))
597 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RICHTEXT))
599 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML))
601 else if (aDataHelper.
HasFormat(SotClipboardFormatId::BITMAP))
603 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML_SIMPLE))
605 else if (aDataHelper.
HasFormat(SotClipboardFormatId::SYLK))
607 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING_TSVC))
609 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING))
612 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ))
614 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ))
625 if (
auto pOwnClip =
dynamic_cast<ScTransferObj*
>(rxTransferable.get()))
631 else if (
auto pDrawClip =
dynamic_cast<ScDrawTransferObj*
>(rxTransferable.get()))
639 aPos, pDrawClip->GetModel(),
false,
651 if (aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ))
652 nFormatId = SotClipboardFormatId::DRAWING;
653 else if (aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ))
654 nFormatId = SotClipboardFormatId::SVXB;
655 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ))
664 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ));
667 nFormatId = aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
669 nFormatId = SotClipboardFormatId::EMBED_SOURCE;
671 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ))
672 nFormatId = SotClipboardFormatId::LINK_SOURCE;
674 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ))
675 nFormatId = SotClipboardFormatId::EMBEDDED_OBJ_OLE;
681 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RTF))
682 nFormatId = SotClipboardFormatId::RTF;
683 else if (aDataHelper.
HasFormat(SotClipboardFormatId::RICHTEXT))
684 nFormatId = SotClipboardFormatId::RICHTEXT;
685 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML))
686 nFormatId = SotClipboardFormatId::HTML;
687 else if (aDataHelper.
HasFormat(SotClipboardFormatId::HTML_SIMPLE))
688 nFormatId = SotClipboardFormatId::HTML_SIMPLE;
689 else if (aDataHelper.
HasFormat(SotClipboardFormatId::SYLK))
690 nFormatId = SotClipboardFormatId::SYLK;
691 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING_TSVC))
692 nFormatId = SotClipboardFormatId::STRING_TSVC;
693 else if (aDataHelper.
HasFormat(SotClipboardFormatId::STRING))
694 nFormatId = SotClipboardFormatId::STRING;
695 else if (aDataHelper.
HasFormat(SotClipboardFormatId::GDIMETAFILE))
696 nFormatId = SotClipboardFormatId::GDIMETAFILE;
697 else if (aDataHelper.
HasFormat(SotClipboardFormatId::BITMAP))
698 nFormatId = SotClipboardFormatId::BITMAP;
700 else if (aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ))
701 nFormatId = SotClipboardFormatId::EMBED_SOURCE_OLE;
702 else if (aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ))
703 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
720 if ( nFormatId == SotClipboardFormatId::NONE && pOwnClip )
750 nullptr,
false, !bApi );
752 if ( !bRet && !bApi )
760 true ,
false ,
false ,
false , rViewData.
GetTabNo());
769 const uno::Reference<datatransfer::XTransferable>& rxTransferable,
774 if ( aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ) )
785 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
793 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
798 if( pScDrawView && aDataHelper.
GetGDIMetaFile( SotClipboardFormatId::GDIMETAFILE, aMtf ) )
800 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
808 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BITMAP ) || aDataHelper.
HasFormat( SotClipboardFormatId::PNG ) )
813 if( pScDrawView && aDataHelper.
GetBitmapEx( SotClipboardFormatId::BITMAP, aBmpEx ) )
815 const OUString aBeginUndo(
ScResId(STR_UNDO_DRAGDROP));
830 return std::any_of(rTabSelection.
begin(), rTabSelection.
end(),
831 [&](
const SCTAB& rTab) { return rDoc.HasAttrib( nCol1, nRow1, rTab, nCol2, nRow2, rTab, nMask ); });
842 bool bIsEmpty =
true;
843 size_t nRangeSize = rDestRanges.
size();
844 for (
const auto& rTab : rMark)
846 for (
size_t i = 0;
i < nRangeSize && bIsEmpty; ++
i)
848 const ScRange& rRange = rDestRanges[
i];
860 if (aBox.run() != RET_YES)
873 bool bTranspose,
bool bAsLink,
879 OSL_FAIL(
"PasteFromClip: pClipDoc=0 not allowed");
904 bAsLink, bAllowDialogs, eMoveMode, nUndoFlags);
912 nFlags, pClipDoc, nFunction, bSkipEmptyCells, bTranspose, bAsLink, bAllowDialogs,
913 eMoveMode, nUndoFlags);
917 bool bIncludeFiltered = bCutMode;
931 if ( nY >
static_cast<sal_Int32
>(pClipDoc->
MaxCol()) )
936 pOrigClipDoc = pClipDoc;
941 aTransShellRef->DoInitNew();
946 pClipDoc->
TransposeClip(xTransClip.get(), nFlags, bAsLink, bIncludeFiltered);
947 pClipDoc = xTransClip.get();
963 pClipDoc->
GetClipArea( nClipSizeX, nClipSizeY,
true );
968 pClipDoc->
GetClipArea( nDestSizeX, nDestSizeY, bIncludeFiltered );
981 bool bNoPaste = ((eMarkType !=
SC_MARK_SIMPLE && !bMarkIsFiltered) ||
982 (bMarkIsFiltered && (eMoveMode !=
INS_NONE || bAsLink)));
993 nEndCol = nStartCol + nDestSizeX;
994 nEndRow = nStartRow + nDestSizeY;
996 aMarkRange =
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
999 bMarkIsFiltered =
true;
1029 if (bMarkIsFiltered)
1033 nUnfilteredRows = 0;
1034 size_t ListSize = aRangeList.
size();
1035 for (
size_t i = 0;
i < ListSize; ++
i )
1045 if ((nUnfilteredRows % (nDestSizeY+1)) != 0)
1055 if ( aFilteredMark.
IsMarked() || bMarkIsFiltered )
1057 aMarkRange.
GetVars( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
1058 SCCOL nBlockAddX = nEndCol-nStartCol;
1059 SCROW nBlockAddY = nEndRow-nStartRow;
1065 if ( ( nBlockAddX != 0 && nBlockAddX < nDestSizeX ) ||
1066 ( nBlockAddY != 0 && nBlockAddY < nDestSizeY ) ||
1067 ( bMarkIsFiltered && nUnfilteredRows < nDestSizeY+1 ) )
1070 OUString aMessage =
ScResId( STR_PASTE_BIGGER );
1073 VclMessageType::Question, VclButtonsType::YesNo,
1075 xQueryBox->set_default_response(
RET_NO);
1076 if (xQueryBox->run() !=
RET_YES)
1082 if (nBlockAddX <= nDestSizeX)
1083 nEndCol = nStartCol + nDestSizeX;
1085 if (nBlockAddY <= nDestSizeY)
1087 nEndRow = nStartRow + nDestSizeY;
1088 if (bMarkIsFiltered || nEndRow > aMarkRange.
aEnd.
Row())
1094 aMarkRange =
ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
1097 bMarkIsFiltered =
true;
1105 aMarkRange.
GetVars( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
1107 if (bMarkIsFiltered)
1120 nEndCol = nStartCol + nDestSizeX;
1121 nEndRow = nStartRow + nDestSizeY;
1122 nEndTab = nStartTab;
1128 ScRange aUserRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab );
1132 bool bInsertCells = ( eMoveMode !=
INS_NONE && !bOffLimits );
1151 else if (!bOffLimits)
1153 bool bAskIfNotEmpty = bAllowDialogs &&
1156 SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
1157 if ( bAskIfNotEmpty )
1160 if (!checkDestRangeForOverwrite(aTestRanges, rDoc, aFilteredMark,
GetViewData().GetDialogParent()))
1168 SCCOL nUndoEndCol = nClipStartX + nClipSizeX;
1169 SCROW nUndoEndRow = nClipStartY + nClipSizeY;
1170 bool bClipOver =
false;
1175 if ( pClipDoc->
HasTable(nClipTab) )
1176 if ( pClipDoc->
ExtendMerge( nClipStartX,nClipStartY, nUndoEndCol,nUndoEndRow, nClipTab ) )
1178 nUndoEndCol -= nClipStartX + nClipSizeX;
1179 nUndoEndRow -= nClipStartY + nClipSizeY;
1180 nUndoEndCol = sal::static_int_cast<SCCOL>( nUndoEndCol + nEndCol );
1181 nUndoEndRow = sal::static_int_cast<SCROW>( nUndoEndRow + nEndRow );
1183 if (nUndoEndCol>pClipDoc->
MaxCol() || nUndoEndRow>pClipDoc->
MaxRow())
1189 rDoc.
ExtendMergeSel( nStartCol,nStartRow, nUndoEndCol,nUndoEndRow, aFilteredMark );
1193 ScEditableTester aTester( rDoc, nStartTab, nStartCol,nStartRow, nUndoEndCol,nUndoEndRow );
1206 OUString aUndo =
ScResId( pClipDoc->
IsCutMode() ? STR_UNDO_MOVE : STR_UNDO_COPY );
1213 ScDocAttrIterator aIter( rDoc, nStartTab, nStartCol, nStartRow, nUndoEndCol, nUndoEndRow );
1218 while ( ( pPattern = aIter.
GetNext( nCol, nRow1, nRow2 ) ) !=
nullptr )
1224 ScRange aRange(nCol, nRow1, nStartTab);
1239 bool bColInfo = ( nStartRow==0 && nEndRow==rDoc.
MaxRow() );
1240 bool bRowInfo = ( nStartCol==0 && nEndCol==rDoc.
MaxCol() );
1243 std::unique_ptr<ScDocument> pRefUndoDoc;
1244 std::unique_ptr<ScRefUndoData> pUndoData;
1249 pUndoDoc->InitUndoSelected( rDoc, aFilteredMark, bColInfo, bRowInfo );
1253 rDoc.
CopyToDocument( nStartCol, nStartRow, 0, nUndoEndCol, nUndoEndRow, nTabCount-1,
1254 nUndoFlags,
false, *pUndoDoc );
1259 pRefUndoDoc->InitUndo( rDoc, 0, nTabCount-1 );
1265 sal_uInt16 nExtFlags = 0;
1266 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
1267 nEndCol, nEndRow, nEndTab );
1283 bSkipEmptyCells =
false;
1287 pMixDoc->InitUndo( rDoc, nStartTab, nEndTab );
1288 rDoc.
CopyToDocument(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
1306 rDoc.
CopyFromClip( aUserRange, aFilteredMark, nNoObjFlags,
1307 pRefUndoDoc.get(), pClipDoc,
true,
false, bIncludeFiltered,
1308 bSkipEmptyCells, (bMarkIsFiltered ? &aRangeList :
nullptr) );
1314 else if (!bTranspose)
1317 rDoc.
CopyFromClip( aUserRange, aFilteredMark, nNoObjFlags, pRefUndoDoc.get(), pClipDoc,
1318 true,
true, bIncludeFiltered, bSkipEmptyCells );
1323 rDoc.
CopyFromClip( aUserRange, aFilteredMark, nContFlags, pRefUndoDoc.get(), pClipDoc );
1330 rDoc.
ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, aFilteredMark,
true );
1335 rDoc.
MixDocument( aUserRange, nFunction, bSkipEmptyCells, *pMixDoc );
1341 ::std::vector< OUString > aExcludedChartNames;
1348 pPage = ( pModel ? pModel->
GetPage(
static_cast< sal_uInt16
>( nStartTab ) ) :
nullptr );
1357 true,
false, bIncludeFiltered );
1360 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
1361 nEndCol, nEndRow, nEndTab );
1366 nClipStartY+nClipSizeY, nStartTab ))
1369 ScRange(nClipStartX, nClipStartY, nStartTab, nClipStartX+nClipSizeX, nClipStartY, nStartTab),
1384 pRedoDoc->InitUndo( rDoc, nStartTab, nEndTab, bColInfo, bRowInfo );
1389 pRedoDoc->AddUndoTab( 0, nTabCount-1 );
1390 rDoc.
CopyUpdated( pRefUndoDoc.get(), pRedoDoc.get() );
1395 pUndoDoc->AddUndoTab( 0, nTabCount-1 );
1396 pRefUndoDoc->DeleteArea( nStartCol, nStartRow, nEndCol, nEndRow, aFilteredMark,
InsertDeleteFlags::ALL );
1397 pRefUndoDoc->CopyToDocument( 0,0,0, pUndoDoc->MaxCol(), pUndoDoc->MaxRow(), nTabCount-1,
1399 pRefUndoDoc.reset();
1412 std::unique_ptr<SfxUndoAction> pUndo(
new ScUndoPaste(
1413 pDocSh,
ScRange(nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab),
1414 aFilteredMark, std::move(pUndoDoc), std::move(pRedoDoc), nFlags | nUndoFlags, std::move(pUndoData),
1415 false, &aOptions ));
1422 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoWrapper>( std::move(pUndo) ),
true );
1433 nUndoEndCol = rDoc.
MaxCol();
1438 nUndoEndRow = rDoc.
MaxRow();
1441 ScRange(nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab),
1451 if ( pPage && pModelObj )
1456 rProtectedChartRangesVector, aExcludedChartNames, bSameDoc );
1461 collectUIInformation({{
"RANGE", aStartAddress +
":" + aEndAddress}},
"PASTE");
1467 bool bTranspose,
bool bAsLink,
1482 if (
static_cast<SCROW>(rCurPos.
Col()) + nRowSize-1 >
static_cast<SCROW>(pClipDoc->
MaxCol()))
1489 pClipDoc->
TransposeClip(pTransClip.get(), nFlags, bAsLink,
false);
1490 pClipDoc = pTransClip.release();
1491 SCCOL nTempColSize = nColSize;
1492 nColSize =
static_cast<SCCOL>(nRowSize);
1493 nRowSize =
static_cast<SCROW>(nTempColSize);
1512 rCurPos.
Col()+nColSize-1, rCurPos.
Row()+nRowSize-1, nTab2);
1522 bool bAskIfNotEmpty =
1529 if (!checkDestRangeForOverwrite(aTestRanges, rDoc, aMark,
GetViewData().GetDialogParent()))
1536 bool bInsertCells = (eMoveMode !=
INS_NONE);
1551 pUndoDoc->InitUndoSelected(rDoc, aMark,
false, bRowInfo);
1552 rDoc.
CopyToDocument(aMarkedRange, nUndoFlags,
false, *pUndoDoc, &aMark);
1561 pMixDoc->InitUndoSelected(rDoc, aMark);
1577 if (bAsLink && bTranspose)
1580 false, bSkipEmptyCells);
1583 rDoc.
MixDocument(aMarkedRange, nFunction, bSkipEmptyCells, *pMixDoc);
1591 false,
false,
true);
1608 pClipDoc->
IsCutMode() ? STR_UNDO_CUT : STR_UNDO_COPY);
1618 std::unique_ptr<ScUndoPaste> pUndo(
new ScUndoPaste(pDocSh,
1619 aMarkedRange, aMark, std::move(pUndoDoc),
nullptr, nFlags|nUndoFlags,
nullptr,
false, &aOptions));
1622 pUndoMgr->
AddUndoAction(std::make_unique<ScUndoWrapper>(std::move(pUndo)),
true);
1636 bool bSkipEmptyCells,
bool bTranspose,
bool bAsLink,
bool bAllowDialogs,
1690 bool bAskIfNotEmpty =
1696 if (!checkDestRangeForOverwrite(aRanges, rDoc, aMark,
GetViewData().GetDialogParent()))
1707 pUndoDoc->InitUndoSelected(rDoc, aMark);
1708 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1711 aRanges[
i], nUndoFlags,
false, *pUndoDoc, &aMark);
1721 pMixDoc->InitUndoSelected(rDoc, aMark);
1722 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1736 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1740 false,
false,
true, bSkipEmptyCells);
1745 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1746 rDoc.
MixDocument(aRanges[
i], nFunction, bSkipEmptyCells, *pMixDoc);
1754 for (
size_t i = 0,
n = aRanges.
size();
i <
n; ++
i)
1758 false,
false,
true, bSkipEmptyCells);
1774 pClipDoc->
IsCutMode() ? STR_UNDO_CUT : STR_UNDO_COPY);
1786 std::make_unique<ScUndoPaste>(
1787 pDocSh, aRanges, aMark, std::move(pUndoDoc),
nullptr, nFlags|nUndoFlags,
nullptr,
false, &aOptions));
1808 for (
size_t i = 0,
n = rPasteRanges.
size();
i <
n; ++
i)
1810 const ScRange& r = rPasteRanges[
i];
1811 for (
const auto& rTab : rMark)
1838 bool bSuccess =
true;
1845 OUString aUndo =
ScResId( bCut ? STR_UNDO_MOVE : STR_UNDO_COPY );
1850 ScRange aLocalSource = rSource;
1853 SCTAB nStartTab = 0;
1854 while ( nStartTab < nTabCount && bSuccess )
1856 while ( nStartTab < nTabCount && !rMark.
GetTableSelect(nStartTab) )
1858 if ( nStartTab < nTabCount )
1860 SCTAB nEndTab = nStartTab;
1861 while ( nEndTab+1 < nTabCount && rMark.
GetTableSelect(nEndTab+1) )
1866 aLocalDest.
SetTab( nStartTab );
1869 aLocalSource, aLocalDest, bCut,
true,
true,
true );
1871 nStartTab = nEndTab + 1;
1881 rSource, rDestPos, bCut,
true,
true,
true );
1893 bool bIncludeFiltered = bCut;
1894 if ( !bIncludeFiltered )
1900 if ( nPastedCount == 0 )
1902 aDestEnd.
SetRow( rDestPos.
Row() + nPastedCount - 1 );
1956 std::vector<std::unique_ptr<ScDataFormFragment>>& rEdits,
1957 sal_uInt16 aColLength )
1968 std::unique_ptr<ScRefUndoData> pUndoData;
1970 SCTAB nStartTab = nTab;
1971 SCTAB nEndTab = nTab;
1978 ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
1979 bool bColInfo = ( nStartRow==0 && nEndRow==rDoc.
MaxRow() );
1980 bool bRowInfo = ( nStartCol==0 && nEndCol==rDoc.
MaxCol() );
1981 SCCOL nUndoEndCol = nStartCol+aColLength-1;
1982 SCROW nUndoEndRow = nCurrentRow;
1987 pUndoDoc->InitUndoSelected( rDoc , rMark , bColInfo , bRowInfo );
1990 sal_uInt16 nExtFlags = 0;
1991 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab );
1994 for(sal_uInt16
i = 0;
i < aColLength;
i++)
1996 if (rEdits[
i] !=
nullptr)
1998 OUString aFieldName = rEdits[
i]->m_xEdit->get_text();
1999 rDoc.
SetString( nStartCol +
i, nCurrentRow, nTab, aFieldName );
2002 pDocSh->
UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
2003 std::unique_ptr<SfxUndoAction> pUndo(
new ScUndoDataForm( pDocSh,
2004 nStartCol, nCurrentRow, nStartTab,
2005 nUndoEndCol, nUndoEndRow, nEndTab, rMark,
2006 std::move(pUndoDoc), std::move(pRedoDoc),
2007 std::move(pUndoData) ) );
2008 pUndoMgr->
AddUndoAction( std::make_unique<ScUndoWrapper>( std::move(pUndo) ),
true );
2014 nUndoEndCol = rDoc.
MaxCol();
2019 nUndoEndRow = rDoc.
MaxRow();
2023 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, const ILibreOfficeKitNotifier *pNotifier=nullptr)
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)