1 |
From 2f35fa5c95a3a6ae28ef15af88eabe8ba3e586bc Mon Sep 17 00:00:00 2001 |
2 |
Message-Id: <2f35fa5c95a3a6ae28ef15af88eabe8ba3e586bc.1480426428.git.erack@redhat.com> |
3 |
From: Eike Rathke <erack@redhat.com> |
4 |
Date: Sat, 26 Nov 2016 11:23:24 +0100 |
5 |
Subject: [PATCH] Resolves: tdf#103493 copying note captions needs a completed |
6 |
destination sheet |
7 |
MIME-Version: 1.0 |
8 |
Content-Type: multipart/mixed; boundary="------------erAck-patch-parts" |
9 |
|
10 |
This is a multi-part message in MIME format. |
11 |
--------------erAck-patch-parts |
12 |
Content-Type: text/plain; charset=UTF-8; format=fixed |
13 |
Content-Transfer-Encoding: 8bit |
14 |
|
15 |
|
16 |
If a copied sheet's destination position is before its source position, the |
17 |
source's ScColumn::nTab members still pointed to the original source position |
18 |
when the captions were created, which led to the wrong drawing layer page being |
19 |
used and at the end the drawing shapes not being correctly assigned. |
20 |
|
21 |
(cherry picked from commit 0a2a7436b4041bb34b01a183b9264af8488d1af3) |
22 |
|
23 |
Backported. |
24 |
|
25 |
Conflicts: |
26 |
sc/inc/table.hxx |
27 |
sc/source/core/data/documen2.cxx |
28 |
sc/source/core/data/table2.cxx |
29 |
|
30 |
Change-Id: I9c3cc97d8b4486756023b9ab02da28079a1d0627 |
31 |
--- |
32 |
sc/inc/table.hxx | 5 ++++- |
33 |
sc/source/core/data/documen2.cxx | 11 +++++++++-- |
34 |
sc/source/core/data/table2.cxx | 23 ++++++++++++++++------- |
35 |
3 files changed, 29 insertions(+), 10 deletions(-) |
36 |
|
37 |
|
38 |
--------------erAck-patch-parts |
39 |
Content-Type: text/x-patch; name="0001-Resolves-tdf-103493-copying-note-captions-needs-a-co.patch" |
40 |
Content-Transfer-Encoding: 8bit |
41 |
Content-Disposition: attachment; filename="0001-Resolves-tdf-103493-copying-note-captions-needs-a-co.patch" |
42 |
|
43 |
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx |
44 |
index ead8ba4..bf7c63e 100644 |
45 |
--- a/sc/inc/table.hxx |
46 |
+++ b/sc/inc/table.hxx |
47 |
@@ -444,7 +444,10 @@ public: |
48 |
void CopyToTable( |
49 |
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
50 |
InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, |
51 |
- const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true ); |
52 |
+ const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true, |
53 |
+ bool bCopyCaptions = true ); |
54 |
+ |
55 |
+ void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption ); |
56 |
|
57 |
void UndoToTable( |
58 |
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
59 |
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx |
60 |
index 57ee5f4..949cd55 100644 |
61 |
--- a/sc/source/core/data/documen2.cxx |
62 |
+++ b/sc/source/core/data/documen2.cxx |
63 |
@@ -874,8 +874,9 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM |
64 |
{ |
65 |
SetNoListening( true ); // noch nicht bei CopyToTable/Insert |
66 |
sc::CopyToDocContext aCopyDocCxt(*this); |
67 |
- maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MAXCOL, MAXROW, InsertDeleteFlags::ALL, (pOnlyMarked != nullptr), |
68 |
- maTabs[nNewPos], pOnlyMarked ); |
69 |
+ maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MAXCOL, MAXROW, InsertDeleteFlags::ALL, |
70 |
+ (pOnlyMarked != nullptr), maTabs[nNewPos], pOnlyMarked, |
71 |
+ false /*bAsLink*/, true /*bColRowFlags*/, false /*bCopyCaptions*/ ); |
72 |
maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor()); |
73 |
|
74 |
SCTAB nDz = nNewPos - nOldPos; |
75 |
@@ -913,6 +914,12 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM |
76 |
// Copy the RTL settings |
77 |
maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL()); |
78 |
maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL()); |
79 |
+ |
80 |
+ // Finally copy the note captions, which need |
81 |
+ // 1. the updated source ScColumn::nTab members if nNewPos <= nOldPos |
82 |
+ // 2. row heights and column widths of the destination |
83 |
+ // 3. RTL settings of the destination |
84 |
+ maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MAXCOL, MAXROW, maTabs[nNewPos], true /*bCloneCaption*/); |
85 |
} |
86 |
|
87 |
return bValid; |
88 |
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx |
89 |
index 5d43a37..629743c 100644 |
90 |
--- a/sc/source/core/data/table2.cxx |
91 |
+++ b/sc/source/core/data/table2.cxx |
92 |
@@ -1090,7 +1090,7 @@ void ScTable::StartListeningFormulaCells( |
93 |
void ScTable::CopyToTable( |
94 |
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
95 |
InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* pMarkData, |
96 |
- bool bAsLink, bool bColRowFlags ) |
97 |
+ bool bAsLink, bool bColRowFlags, bool bCopyCaptions ) |
98 |
{ |
99 |
if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2)) |
100 |
return; |
101 |
@@ -1210,14 +1210,23 @@ void ScTable::CopyToTable( |
102 |
if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags |
103 |
pDestTab->SetOutlineTable( pOutlineTable ); |
104 |
|
105 |
- if (nFlags & (InsertDeleteFlags::NOTE|InsertDeleteFlags::ADDNOTES)) |
106 |
+ if (bCopyCaptions && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES))) |
107 |
{ |
108 |
bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE; |
109 |
- for (SCCOL i = nCol1; i <= nCol2; i++) |
110 |
- { |
111 |
- aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->aCol[i], bCloneCaption); |
112 |
- pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2); |
113 |
- } |
114 |
+ CopyCaptionsToTable( nCol1, nRow1, nCol2, nRow2, pDestTab, bCloneCaption); |
115 |
+ } |
116 |
+} |
117 |
+ |
118 |
+void ScTable::CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, |
119 |
+ bool bCloneCaption ) |
120 |
+{ |
121 |
+ if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2)) |
122 |
+ return; |
123 |
+ |
124 |
+ for (SCCOL i = nCol1; i <= nCol2; i++) |
125 |
+ { |
126 |
+ aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->aCol[i], bCloneCaption); |
127 |
+ pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2); |
128 |
} |
129 |
} |
130 |
|
131 |
|
132 |
--------------erAck-patch-parts-- |
133 |
|
134 |
|