From 7c0f6b9d0fb8d7d9e54865ccf1047bb8f8148101 Mon Sep 17 00:00:00 2001 From: Dennis Francis Date: Sat, 13 Feb 2016 02:29:12 +0530 Subject: tdf#94561 : Create notes drawing objects only once on sheet copy Skip copying notes in CopyToColumn() and then call CopyCellNotesToDocument() only after copying hidden rows and filtered rows info. Skip copying notes drawing objects in ScDocument::DrawCopyPage() when inside ScDocument::CopyTab(). Change-Id: I38296bb5d1cc062d473ea4a5a3143f6c1787fc4a Reviewed-on: https://gerrit.libreoffice.org/22331 Tested-by: Jenkins Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- sc/inc/document.hxx | 2 +- sc/inc/drwlayer.hxx | 2 +- sc/source/core/data/documen2.cxx | 4 ++-- sc/source/core/data/documen9.cxx | 4 ++-- sc/source/core/data/drwlayer.cxx | 7 ++++++- sc/source/core/data/table2.cxx | 16 +++++++++++++++- 6 files changed, 27 insertions(+), 8 deletions(-) (limited to 'sc') diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 541a0cc2e0f9..e486b04e2f21 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -2190,7 +2190,7 @@ private: void DeleteDrawLayer(); SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const; void DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); - void DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); + void DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, bool bSkipNotes = false ); void UpdateDrawPrinter(); void UpdateDrawLanguages(); diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx index 2bd6d55d72ed..6dec7b7c4a83 100644 --- a/sc/inc/drwlayer.hxx +++ b/sc/inc/drwlayer.hxx @@ -121,7 +121,7 @@ public: void ScRemovePage( SCTAB nTab ); void ScRenamePage( SCTAB nTab, const OUString& rNewName ); void ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); - void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos); + void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, bool bSkipNotes = false ); void ResetTab( SCTAB nStart, SCTAB nEnd ); ScDocument* GetDocument() const { return pDoc; } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index dc13be87861c..3745486773bf 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -896,8 +896,8 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM sc::SetFormulaDirtyContext aFormulaDirtyCxt; SetAllFormulasDirty(aFormulaDirtyCxt); - if (pDrawLayer) - DrawCopyPage( static_cast(nOldPos), static_cast(nNewPos) ); + if (pDrawLayer) // Skip cloning Note caption object + DrawCopyPage( static_cast(nOldPos), static_cast(nNewPos), true ); if (pDPCollection) pDPCollection->CopyToTab(nOldPos, nNewPos); diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index e438b1e4d4c1..3185a2d68e02 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -261,10 +261,10 @@ void ScDocument::DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ) pDrawLayer->ScMovePage(nOldPos,nNewPos); } -void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ) +void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, bool bSkipNotes ) { // page is already created in ScTable ctor - pDrawLayer->ScCopyPage( nOldPos, nNewPos ); + pDrawLayer->ScCopyPage( nOldPos, nNewPos, bSkipNotes ); } void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 898815d74b75..e90b81e55d9e 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -435,7 +435,7 @@ void ScDrawLayer::ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ) ResetTab(nMinPos, pDoc->GetTableCount()-1); } -void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos) +void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, bool bSkipNotes ) { if (bDrawIsInUndo) return; @@ -454,6 +454,11 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos) SdrObject* pOldObject = aIter.Next(); while (pOldObject) { + if ( bSkipNotes && IsNoteCaption( pOldObject ) ) + { + pOldObject = aIter.Next(); + continue; + } ScDrawObjData* pOldData = GetObjData(pOldObject); if (pOldData) { diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 419821b89b4d..9eb910f2174e 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1081,9 +1081,13 @@ void ScTable::CopyToTable( return; if (nFlags != InsertDeleteFlags::NONE) + { + InsertDeleteFlags nTempFlags( nFlags & + ~InsertDeleteFlags( InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)); for (SCCOL i = nCol1; i <= nCol2; i++) - aCol[i].CopyToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, + aCol[i].CopyToColumn(rCxt, nRow1, nRow2, nTempFlags, bMarked, pDestTab->aCol[i], pMarkData, bAsLink); + } if (!bColRowFlags) // Column widths/Row heights/Flags return; @@ -1190,6 +1194,16 @@ void ScTable::CopyToTable( if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags pDestTab->SetOutlineTable( pOutlineTable ); + + if (nFlags & (InsertDeleteFlags::NOTE|InsertDeleteFlags::ADDNOTES)) + { + bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE; + for (SCCOL i = nCol1; i <= nCol2; i++) + { + aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->aCol[i], bCloneCaption); + pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2); + } + } } void ScTable::UndoToTable( -- cgit