From 8e49269f794f6eae193fa9af8846a470baab0c1b Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 3 Apr 2018 09:31:34 +0200 Subject: tdf#116510 Copy graphics too when copying cells/rows Before this worked only for columns Change-Id: I0e2c54aa85455d5fe3ec7ae78638e1b1157e4a9c Reviewed-on: https://gerrit.libreoffice.org/52380 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sc/source/core/data/table7.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx index 8ba58ccde185..aab7c47cf522 100644 --- a/sc/source/core/data/table7.cxx +++ b/sc/source/core/data/table7.cxx @@ -18,6 +18,7 @@ #include #include #include +#include bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const { @@ -140,6 +141,27 @@ void ScTable::CopyOneCellFromClip( if (nCol1 == 0 && nCol2 == MAXCOL && mpRowHeights) mpRowHeights->setValue(nRow1, nRow2, pSrcTab->GetOriginalHeight(nSrcRow)); + + // Copy graphics over too + bool bCopyGraphics + = (rCxt.getInsertFlag() & InsertDeleteFlags::OBJECTS) != InsertDeleteFlags::NONE; + if (bCopyGraphics && rCxt.getClipDoc()->mpDrawLayer) + { + ScDrawLayer* pDrawLayer = GetDoc().GetDrawLayer(); + OSL_ENSURE(pDrawLayer, "No drawing layer"); + if (pDrawLayer) + { + const ScAddress& rSrcStartPos + = rCxt.getClipDoc()->GetClipParam().getWholeRange().aStart; + const ScAddress& rSrcEndPos = rCxt.getClipDoc()->GetClipParam().getWholeRange().aEnd; + tools::Rectangle aSourceRect = rCxt.getClipDoc()->GetMMRect( + rSrcStartPos.Col(), rSrcStartPos.Row(), rSrcEndPos.Col(), rSrcEndPos.Row(), + rSrcStartPos.Tab()); + tools::Rectangle aDestRect = GetDoc().GetMMRect(nCol1, nRow1, nCol2, nRow2, nTab); + pDrawLayer->CopyFromClip(rCxt.getClipDoc()->mpDrawLayer, rSrcStartPos.Tab(), + aSourceRect, ScAddress(nCol1, nRow1, nTab), aDestRect); + } + } } void ScTable::SetValues( const SCCOL nCol, const SCROW nRow, const std::vector& rVals ) -- cgit v1.2.3