sc/source/ui/view/viewfun5.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
New commits: commit cd31d274c5971d6ffcc5914be684fca53c1fe257 Author: Dennis Francis <[email protected]> AuthorDate: Tue Nov 2 15:37:17 2021 +0530 Commit: Dennis Francis <[email protected]> CommitDate: Wed Nov 10 07:59:29 2021 +0100 sc: EMBED_SOURCE: extend copy to clip area... to include the draw objects in the sheet read from system clipboard. This is needed because GetCellArea() computes the "last row" and "last column" only based on the cell contents and not the drawing layer contents. So copying a "empty cells" range that has images in it and pasting it will not include any images without this fix. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124629 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Dennis Francis <[email protected]> (cherry picked from commit 789d19776ab451a6118b938830d488961b42dae5) Change-Id: I56ffb14e881a1aecc5b43590ea4fb3fc1c35ace8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124670 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Luboš Luňák <[email protected]> diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index d32ec61b38fd..588c81832ea8 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -51,6 +51,7 @@ #include <viewfunc.hxx> #include <docsh.hxx> +#include <drwlayer.hxx> #include <drawview.hxx> #include <impex.hxx> #include <dbdata.hxx> @@ -159,8 +160,26 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId, nFirstCol = nLastCol = 0; nFirstRow = nLastRow = 0; } + + bool bIncludeObjects = false; // include drawing layer objects in CopyToClip ? + + if (nFormatId == SotClipboardFormatId::EMBED_SOURCE) + { + const ScDrawLayer* pDraw = rSrcDoc.GetDrawLayer(); + SCCOL nPrintEndCol = nFirstCol; + SCROW nPrintEndRow = nFirstRow; + bool bHasObjects = pDraw && pDraw->HasObjects(); + // Extend the range to include the drawing layer objects. + if (bHasObjects && rSrcDoc.GetPrintArea(nSrcTab, nPrintEndCol, nPrintEndRow, true)) + { + nLastCol = std::max<SCCOL>(nLastCol, nPrintEndCol); + nLastRow = std::max<SCROW>(nLastRow, nPrintEndRow); + } + + bIncludeObjects = bHasObjects; + } + ScClipParam aClipParam(ScRange(nFirstCol, nFirstRow, nSrcTab, nLastCol, nLastRow, nSrcTab), false); - bool bIncludeObjects = (nFormatId == SotClipboardFormatId::EMBED_SOURCE); rSrcDoc.CopyToClip(aClipParam, pClipDoc.get(), &aSrcMark, false, bIncludeObjects); ScGlobal::SetClipDocName( xDocShRef->GetTitle( SFX_TITLE_FULLNAME ) );
