Kaydet (Commit) 0a2a7436 authored tarafından Eike Rathke's avatar Eike Rathke

Resolves: tdf#103493 copying note captions needs a completed destination sheet

If a copied sheet's destination position is before its source position, the
source's ScColumn::nTab members still pointed to the original source position
when the captions were created, which led to the wrong drawing layer page being
used and at the end the drawing shapes not being correctly assigned.

Change-Id: I9c3cc97d8b4486756023b9ab02da28079a1d0627
üst 7b250d56
...@@ -454,7 +454,9 @@ public: ...@@ -454,7 +454,9 @@ public:
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true, const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true,
bool bGlobalNamesToLocal = false ); bool bGlobalNamesToLocal = false, bool bCopyCaptions = true );
void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
void UndoToTable( void UndoToTable(
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
......
...@@ -899,7 +899,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM ...@@ -899,7 +899,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
sc::CopyToDocContext aCopyDocCxt(*this); sc::CopyToDocContext aCopyDocCxt(*this);
maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MAXCOL, MAXROW, InsertDeleteFlags::ALL, maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MAXCOL, MAXROW, InsertDeleteFlags::ALL,
(pOnlyMarked != nullptr), maTabs[nNewPos], pOnlyMarked, (pOnlyMarked != nullptr), maTabs[nNewPos], pOnlyMarked,
false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal ); false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal, false /*bCopyCaptions*/ );
maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor()); maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor());
SCTAB nDz = nNewPos - nOldPos; SCTAB nDz = nNewPos - nOldPos;
...@@ -938,6 +938,12 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM ...@@ -938,6 +938,12 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
// Copy the RTL settings // Copy the RTL settings
maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL()); maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL());
maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL()); maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL());
// Finally copy the note captions, which need
// 1. the updated source ScColumn::nTab members if nNewPos <= nOldPos
// 2. row heights and column widths of the destination
// 3. RTL settings of the destination
maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MAXCOL, MAXROW, maTabs[nNewPos], true /*bCloneCaption*/);
} }
return bValid; return bValid;
......
...@@ -1089,7 +1089,7 @@ void ScTable::StartListeningFormulaCells( ...@@ -1089,7 +1089,7 @@ void ScTable::StartListeningFormulaCells(
void ScTable::CopyToTable( void ScTable::CopyToTable(
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* pMarkData, InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* pMarkData,
bool bAsLink, bool bColRowFlags, bool bGlobalNamesToLocal ) bool bAsLink, bool bColRowFlags, bool bGlobalNamesToLocal, bool bCopyCaptions )
{ {
if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2)) if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
return; return;
...@@ -1209,14 +1209,23 @@ void ScTable::CopyToTable( ...@@ -1209,14 +1209,23 @@ void ScTable::CopyToTable(
if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags
pDestTab->SetOutlineTable( pOutlineTable ); pDestTab->SetOutlineTable( pOutlineTable );
if (nFlags & (InsertDeleteFlags::NOTE|InsertDeleteFlags::ADDNOTES)) if (bCopyCaptions && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)))
{ {
bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE; bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE;
for (SCCOL i = nCol1; i <= nCol2; i++) CopyCaptionsToTable( nCol1, nRow1, nCol2, nRow2, pDestTab, bCloneCaption);
{ }
aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->aCol[i], bCloneCaption); }
pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2);
} void ScTable::CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab,
bool bCloneCaption )
{
if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
return;
for (SCCOL i = nCol1; i <= nCol2; i++)
{
aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->aCol[i], bCloneCaption);
pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment