Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / qa / unit / ucalc_copypaste.cxx
blobb6062cb04c724c2e1251fd94ded5aad706757065
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "helper/debughelper.hxx"
11 #include "helper/qahelper.hxx"
13 #include <attrib.hxx>
14 #include <bcaslot.hxx>
15 #include <clipparam.hxx>
16 #include <dbdata.hxx>
17 #include <docfunc.hxx>
18 #include <docpool.hxx>
19 #include <editeng/borderline.hxx>
20 #include <editeng/brushitem.hxx>
21 #include <editutil.hxx>
22 #include <formulacell.hxx>
23 #include <iostream>
24 #include <patattr.hxx>
25 #include <postit.hxx>
26 #include <queryparam.hxx>
27 #include <refundo.hxx>
28 #include <scitems.hxx>
29 #include <scopetools.hxx>
31 #include <sfx2/docfile.hxx>
33 #include <memory>
35 class TestCopyPaste : public ScUcalcTestBase
37 public:
38 void testCopyPaste();
39 void testCopyPasteAsLink();
40 void testCopyPasteTranspose();
41 void testCopyPasteSpecialAsLinkTranspose();
42 void testCopyPasteSpecialAsLinkFilteredTranspose();
43 void testCopyPasteSpecialMultiRangeColAsLinkTranspose();
44 void testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose();
45 void testCopyPasteSpecialMultiRangeRowAsLinkTranspose();
46 void testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose();
47 void testCopyPasteSpecialAllAsLinkTranspose();
48 void testCopyPasteSpecialAllAsLinkFilteredTranspose();
49 void testCopyPasteSpecial();
50 void testCopyPasteSpecialFiltered();
51 void testCopyPasteSpecialIncludeFiltered();
52 void testCopyPasteSpecialFilteredIncludeFiltered();
53 void testCopyPasteSpecialTranspose();
54 void testCopyPasteSpecialTransposeIncludeFiltered();
55 void testCopyPasteSpecialFilteredTranspose();
56 void testCopyPasteSpecialMergedCellsTranspose();
57 void testCopyPasteSpecialMergedCellsFilteredTranspose();
58 void testCopyPasteSpecialMultiRangeCol();
59 void testCopyPasteSpecialMultiRangeColFiltered();
60 void testCopyPasteSpecialMultiRangeColIncludeFiltered();
61 void testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered();
62 void testCopyPasteSpecialMultiRangeColTranspose();
63 void testCopyPasteSpecialMultiRangeColFilteredTranspose();
64 void testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose();
65 void testCopyPasteSpecialMultiRangeRow();
66 void testCopyPasteSpecialMultiRangeRowFiltered();
67 void testCopyPasteSpecialMultiRangeRowIncludeFiltered();
68 void testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered();
69 void testCopyPasteSpecialMultiRangeRowTranspose();
70 void testCopyPasteSpecialMultiRangeRowFilteredTranspose();
71 void testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose();
72 void testCopyPasteSpecialSkipEmpty();
73 void testCopyPasteSpecialSkipEmptyFiltered();
74 void testCopyPasteSpecialSkipEmptyIncludeFiltered();
75 void testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered();
76 void testCopyPasteSpecialSkipEmptyTranspose();
77 void testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered();
78 void testCopyPasteSpecialSkipEmptyFilteredTranspose();
79 void testCopyPasteSpecialSkipEmptyMultiRangeCol();
80 void testCopyPasteSpecialSkipEmptyMultiRangeColFiltered();
81 void testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered();
82 void testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered();
83 void testCopyPasteSpecialSkipEmptyMultiRangeColTranspose();
84 void testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose();
85 void testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose();
86 void testCopyPasteSpecialSkipEmptyMultiRangeRow();
87 void testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered();
88 void testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered();
89 void testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered();
90 void testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose();
91 void testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose();
92 void testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose();
93 void testCopyPasteMultiRange();
94 void testCopyPasteSkipEmpty();
95 void testCopyPasteSkipEmpty2();
96 void testCutPasteRefUndo();
97 void testCutPasteGroupRefUndo();
98 void testMoveRefBetweenSheets();
99 void testUndoCut();
100 void testMoveBlock();
101 void testCopyPasteRelativeFormula();
102 void testCopyPasteRepeatOneFormula();
103 void testCopyPasteMixedReferenceFormula();
104 void testCopyPasteFormulas();
105 void testCopyPasteFormulasExternalDoc();
106 void testCopyPasteReferencesExternalDoc(); // tdf#106456
107 void testTdf68976();
108 void testTdf71058();
109 void testTdf149554();
111 void testCutPasteSpecial();
112 void testCutPasteSpecialTranspose();
113 void testCutPasteSpecialSkipEmpty();
114 void testCutPasteSpecialSkipEmptyTranspose();
115 void testTdf142201Row();
116 void testTdf142201ColRel();
117 void testTdf142201ColAbs();
118 void testTdf142065();
119 void testCutTransposedFormulas();
120 void testCutTransposedFormulasSquare();
121 void testReferencedCutRangesRow();
122 void testReferencedCutTransposedRangesRowTab0To0();
123 void testReferencedCutTransposedRangesRowTab0To1();
124 void testReferencedCutTransposedRangesRowTab1To3();
125 void testReferencedCutTransposedRangesRowTab3To1();
126 void testReferencedCutRangesCol();
127 void testReferencedCutTransposedRangesColTab0To0();
128 void testReferencedCutTransposedRangesColTab0To1();
129 void testReferencedCutTransposedRangesColTab1To3();
130 void testReferencedCutTransposedRangesColTab3To1();
132 void testMixData();
133 void testMixDataAsLinkTdf116413();
134 void testMixDataWithFormulaTdf116413();
136 // tdf#80137
137 void testCopyPasteMatrixFormula();
139 CPPUNIT_TEST_SUITE(TestCopyPaste);
141 CPPUNIT_TEST(testCopyPaste);
142 CPPUNIT_TEST(testCopyPasteAsLink);
143 CPPUNIT_TEST(testCopyPasteTranspose);
144 CPPUNIT_TEST(testCopyPasteSpecialAsLinkTranspose);
145 CPPUNIT_TEST(testCopyPasteSpecialAllAsLinkTranspose);
146 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColAsLinkTranspose);
147 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose);
148 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowAsLinkTranspose);
149 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose);
150 CPPUNIT_TEST(testCopyPasteSpecialAsLinkFilteredTranspose);
151 CPPUNIT_TEST(testCopyPasteSpecialAllAsLinkFilteredTranspose);
152 CPPUNIT_TEST(testCopyPasteSpecialMergedCellsTranspose);
153 CPPUNIT_TEST(testCopyPasteSpecialMergedCellsFilteredTranspose);
154 CPPUNIT_TEST(testCopyPasteSpecial);
155 CPPUNIT_TEST(testCopyPasteSpecialFiltered);
156 CPPUNIT_TEST(testCopyPasteSpecialIncludeFiltered);
157 CPPUNIT_TEST(testCopyPasteSpecialFilteredIncludeFiltered);
158 CPPUNIT_TEST(testCopyPasteSpecialTranspose);
159 CPPUNIT_TEST(testCopyPasteSpecialTransposeIncludeFiltered);
160 CPPUNIT_TEST(testCopyPasteSpecialFilteredTranspose);
161 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeCol);
162 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFiltered);
163 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColIncludeFiltered);
164 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered);
165 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColTranspose);
166 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFilteredTranspose);
167 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose);
168 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRow);
169 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFiltered);
170 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowIncludeFiltered);
171 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered);
172 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowTranspose);
173 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFilteredTranspose);
174 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose);
175 CPPUNIT_TEST(testCopyPasteSpecialSkipEmpty);
176 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyFiltered);
177 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyIncludeFiltered);
178 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered);
179 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyTranspose);
180 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered);
181 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyFilteredTranspose);
182 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeCol);
183 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFiltered);
184 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered);
185 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered);
186 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColTranspose);
187 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose);
188 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose);
189 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRow);
190 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered);
191 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered);
192 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered);
193 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose);
194 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose);
195 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose);
196 CPPUNIT_TEST(testCopyPasteMultiRange);
197 CPPUNIT_TEST(testCopyPasteSkipEmpty);
198 CPPUNIT_TEST(testCopyPasteSkipEmpty2);
199 CPPUNIT_TEST(testCutPasteRefUndo);
200 CPPUNIT_TEST(testCutPasteGroupRefUndo);
201 CPPUNIT_TEST(testMoveRefBetweenSheets);
202 CPPUNIT_TEST(testUndoCut);
203 CPPUNIT_TEST(testMoveBlock);
204 CPPUNIT_TEST(testCopyPasteRelativeFormula);
205 CPPUNIT_TEST(testCopyPasteRepeatOneFormula);
206 CPPUNIT_TEST(testCopyPasteMixedReferenceFormula);
208 CPPUNIT_TEST(testCopyPasteFormulas);
209 CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
210 CPPUNIT_TEST(testCopyPasteReferencesExternalDoc);
212 CPPUNIT_TEST(testTdf68976);
213 CPPUNIT_TEST(testTdf71058);
214 CPPUNIT_TEST(testTdf149554);
216 CPPUNIT_TEST(testCutPasteSpecial);
217 CPPUNIT_TEST(testCutPasteSpecialTranspose);
218 CPPUNIT_TEST(testCutPasteSpecialSkipEmpty);
219 CPPUNIT_TEST(testCutPasteSpecialSkipEmptyTranspose);
220 CPPUNIT_TEST(testTdf142201Row);
221 CPPUNIT_TEST(testTdf142201ColRel);
222 CPPUNIT_TEST(testTdf142201ColAbs);
223 CPPUNIT_TEST(testTdf142065);
224 CPPUNIT_TEST(testCutTransposedFormulas);
225 CPPUNIT_TEST(testCutTransposedFormulasSquare);
226 CPPUNIT_TEST(testReferencedCutRangesRow);
227 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab0To0);
228 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab0To1);
229 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab1To3);
230 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab3To1);
231 CPPUNIT_TEST(testReferencedCutRangesCol);
232 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab0To0);
233 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab0To1);
234 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab1To3);
235 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab3To1);
237 CPPUNIT_TEST(testMixData);
238 CPPUNIT_TEST(testMixDataAsLinkTdf116413);
239 CPPUNIT_TEST(testMixDataWithFormulaTdf116413);
241 CPPUNIT_TEST(testCopyPasteMatrixFormula);
243 CPPUNIT_TEST_SUITE_END();
245 private:
246 enum CalcMode
248 NoCalc,
249 AutoCalc,
250 RecalcAtEnd,
251 HardRecalcAtEnd
254 void executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
255 bool bTranspose, bool bMultiRangeSelection, bool bSkipEmpty,
256 bool bCut = false,
257 ScClipParam::Direction eDirection = ScClipParam::Column,
258 CalcMode eCalcMode = CalcMode::AutoCalc,
259 InsertDeleteFlags aFlags
260 = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB);
261 void executeCopyPasteSpecial(const SCTAB srcSheet, const SCTAB destSheet, bool bApplyFilter,
262 bool bIncludedFiltered, bool bAsLink, bool bTranspose,
263 bool bMultiRangeSelection, bool bSkipEmpty,
264 std::unique_ptr<ScUndoCut>& pUndoCut,
265 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bCut = false,
266 ScClipParam::Direction eDirection = ScClipParam::Column,
267 CalcMode eCalcMode = CalcMode::AutoCalc,
268 InsertDeleteFlags aFlags
269 = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB);
270 void checkCopyPasteSpecialInitial(const SCTAB srcSheet);
271 void checkCopyPasteSpecial(bool bSkipEmpty, bool bCut = false);
272 void checkCopyPasteSpecialFiltered(bool bSkipEmpty);
273 void checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut = false);
274 void checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty);
275 void checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty);
276 void checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty);
277 void checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty);
278 void checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty);
279 void checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty);
280 void checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty);
281 void checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty);
282 void checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty);
283 void checkReferencedCutTransposedRangesRowUndo(const SCTAB nSrcTab, const SCTAB nDestTab);
284 void executeReferencedCutRangesRow(const bool bTransposed, const SCTAB nSrcTab,
285 const SCTAB nDestTab, const bool bUndo,
286 std::unique_ptr<ScUndoCut>& pUndoCut,
287 std::unique_ptr<ScUndoPaste>& pUndoPaste);
288 void checkReferencedCutRangesRowIntitial(const SCTAB nSrcTab, const OUString& rDesc);
289 void checkReferencedCutRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab);
290 void checkReferencedCutTransposedRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab);
291 void executeReferencedCutRangesCol(const bool bTransposed, const SCTAB nSrcTab,
292 const SCTAB nDestTab, const bool bUndo,
293 std::unique_ptr<ScUndoCut>& pUndoCut,
294 std::unique_ptr<ScUndoPaste>& pUndoPaste);
295 void checkReferencedCutRangesColIntitial(const SCTAB nSrcTab, const SCTAB nDestTab,
296 const OUString& rDesc);
297 void checkReferencedCutRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab);
298 void checkReferencedCutTransposedRangesColUndo(const SCTAB nSrcTab, const SCTAB nDestTab);
299 void checkReferencedCutTransposedRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab);
300 void prepareUndoBeforePaste(bool bCut, ScDocumentUniquePtr& pPasteUndoDoc,
301 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
302 const ScMarkData& rDestMark, const ScRange& rDestRange,
303 std::unique_ptr<ScRefUndoData>& pUndoData);
304 void prepareUndoAfterPaste(ScDocumentUniquePtr& pPasteUndoDoc,
305 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
306 const ScMarkData& rDestMark, const ScRange& rDestRange,
307 std::unique_ptr<ScRefUndoData>& pUndoData,
308 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bTranspose = false,
309 bool bAsLink = false, bool bSkipEmpty = false,
310 ScPasteFunc nFunction = ScPasteFunc::NONE,
311 InsCellCmd eMoveMode = InsCellCmd::INS_NONE);
313 void printValuesAndFormulasInRange(ScDocument* pDoc, const ScRange& rRange,
314 const OString& rCaption);
315 OUString getRangeByName(const OUString& aRangeName);
316 ScAddress setNote(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString noteText);
317 OUString getNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
320 static ScMF lcl_getMergeFlagOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
322 const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE_FLAG);
323 const ScMergeFlagAttr& rMergeFlag = static_cast<const ScMergeFlagAttr&>(rPoolItem);
324 return rMergeFlag.GetValue();
327 static ScAddress lcl_getMergeSizeOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
329 const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE);
330 const ScMergeAttr& rMerge = static_cast<const ScMergeAttr&>(rPoolItem);
331 return ScAddress(rMerge.GetColMerge(), rMerge.GetRowMerge(), nTab);
334 void TestCopyPaste::printValuesAndFormulasInRange(ScDocument* pDoc, const ScRange& rRange,
335 const OString& rCaption)
337 printRange(pDoc, rRange, rCaption, false);
338 printRange(pDoc, rRange, rCaption, true);
341 OUString TestCopyPaste::getRangeByName(const OUString& aRangeName)
343 return ScUcalcTestBase::getRangeByName(m_pDoc, aRangeName);
346 ScAddress TestCopyPaste::setNote(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString noteText)
348 ScAddress aAdr(nCol, nRow, nTab);
349 ScPostIt* pNote = m_pDoc->GetOrCreateNote(aAdr);
350 pNote->SetText(aAdr, noteText);
351 return aAdr;
354 OUString TestCopyPaste::getNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
356 ScPostIt* pNote = m_pDoc->GetNote(nCol, nRow, nTab);
357 CPPUNIT_ASSERT_MESSAGE("Note expected", pNote);
358 return pNote->GetText();
361 // Cannot be moved to qahelper since ScDocument::CopyToDocument() is not SC_DLLPUBLIC
362 /** Executes the same steps for undo as ScViewFunc::PasteFromClip(). */
363 void TestCopyPaste::prepareUndoBeforePaste(bool bCut, ScDocumentUniquePtr& pPasteUndoDoc,
364 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
365 const ScMarkData& rDestMark, const ScRange& rDestRange,
366 std::unique_ptr<ScRefUndoData>& pUndoData)
368 InsertDeleteFlags nUndoFlags = InsertDeleteFlags::CONTENTS;
369 SCTAB nTabCount = m_pDoc->GetTableCount();
371 pPasteUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
372 pPasteUndoDoc->InitUndoSelected(*m_pDoc, rDestMark, false, false);
373 // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
374 m_pDoc->CopyToDocument(rDestRange.aStart.Col(), rDestRange.aStart.Row(), 0,
375 rDestRange.aEnd.Col(), rDestRange.aEnd.Row(), nTabCount - 1, nUndoFlags,
376 false, *pPasteUndoDoc);
378 if (bCut)
380 // save changed references
381 pPasteRefUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
382 pPasteRefUndoDoc->InitUndo(*m_pDoc, 0, nTabCount - 1);
384 pUndoData.reset(new ScRefUndoData(m_pDoc));
388 // Cannot be moved to qahelper since ScDocument::CopyToDocument() is not SC_DLLPUBLIC
389 /** Executes the same steps for undo as ScViewFunc::PasteFromClip(). */
390 void TestCopyPaste::prepareUndoAfterPaste(ScDocumentUniquePtr& pPasteUndoDoc,
391 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
392 const ScMarkData& rDestMark, const ScRange& rDestRange,
393 std::unique_ptr<ScRefUndoData>& pUndoData,
394 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bTranspose,
395 bool bAsLink, bool bSkipEmpty, ScPasteFunc nFunction,
396 InsCellCmd eMoveMode)
398 InsertDeleteFlags nUndoFlags = InsertDeleteFlags::CONTENTS;
399 SCTAB nTabCount = m_pDoc->GetTableCount();
401 ScDocumentUniquePtr pPasteRedoDoc;
402 // copy redo data after appearance of the first undo
403 // don't create Redo-Doc without RefUndoDoc
405 if (pPasteRefUndoDoc)
407 pPasteRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
408 pPasteRedoDoc->InitUndo(*m_pDoc, rDestRange.aStart.Tab(), rDestRange.aEnd.Tab(), false,
409 false);
411 // move adapted refs to Redo-Doc
413 pPasteRedoDoc->AddUndoTab(0, nTabCount - 1);
414 m_pDoc->CopyUpdated(pPasteRefUndoDoc.get(), pPasteRedoDoc.get());
416 pPasteUndoDoc->AddUndoTab(0, nTabCount - 1);
417 pPasteRefUndoDoc->DeleteArea(rDestRange.aStart.Col(), rDestRange.aStart.Row(),
418 rDestRange.aEnd.Col(), rDestRange.aEnd.Row(), rDestMark,
419 InsertDeleteFlags::ALL);
420 pPasteRefUndoDoc->CopyToDocument(0, 0, 0, pPasteUndoDoc->MaxCol(), pPasteUndoDoc->MaxRow(),
421 nTabCount - 1, InsertDeleteFlags::FORMULA, false,
422 *pPasteUndoDoc);
423 pPasteRefUndoDoc.reset();
426 ScUndoPasteOptions aOptions; // store options for repeat
427 aOptions.nFunction = nFunction;
428 aOptions.bSkipEmptyCells = bSkipEmpty;
429 aOptions.bTranspose = bTranspose;
430 aOptions.bAsLink = bAsLink;
431 aOptions.eMoveMode = eMoveMode;
433 pUndoPaste.reset(new ScUndoPaste(&*m_xDocShell, rDestRange, rDestMark, std::move(pPasteUndoDoc),
434 std::move(pPasteRedoDoc), nUndoFlags, std::move(pUndoData),
435 false,
436 &aOptions)); // false = Redo data not yet copied
439 void TestCopyPaste::testCopyPaste()
441 m_pDoc->InsertTab(0, "Sheet1");
442 m_pDoc->InsertTab(1, "Sheet2");
444 // We need a drawing layer in order to create caption objects.
445 m_pDoc->InitDrawLayer(m_xDocShell.get());
447 //test copy&paste + ScUndoPaste
448 //copy local and global range names in formulas
449 //string cells and value cells
450 m_pDoc->SetValue(0, 0, 0, 1);
451 m_pDoc->SetValue(3, 0, 0, 0);
452 m_pDoc->SetValue(3, 1, 0, 1);
453 m_pDoc->SetValue(3, 2, 0, 2);
454 m_pDoc->SetValue(3, 3, 0, 3);
455 m_pDoc->SetString(2, 0, 0, "test");
456 ScAddress aAdr(0, 0, 0);
458 //create some range names, local and global
459 ScRangeData* pLocal1 = new ScRangeData(*m_pDoc, "local1", aAdr);
460 ScRangeData* pLocal2 = new ScRangeData(*m_pDoc, "local2", aAdr);
461 ScRangeData* pLocal3 = new ScRangeData(*m_pDoc, "local3", "$Sheet1.$A$1");
462 ScRangeData* pLocal4 = new ScRangeData(*m_pDoc, "local4", "Sheet1.$A$1");
463 ScRangeData* pLocal5
464 = new ScRangeData(*m_pDoc, "local5", "$A$1"); // implicit relative sheet reference
465 ScRangeData* pGlobal = new ScRangeData(*m_pDoc, "global", aAdr);
466 const OUString aGlobal2Symbol("$Sheet1.$A$1:$A$23");
467 ScRangeData* pGlobal2 = new ScRangeData(*m_pDoc, "global2", aGlobal2Symbol);
468 std::unique_ptr<ScRangeName> pGlobalRangeName(new ScRangeName());
469 pGlobalRangeName->insert(pGlobal);
470 pGlobalRangeName->insert(pGlobal2);
471 std::unique_ptr<ScRangeName> pLocalRangeName1(new ScRangeName());
472 pLocalRangeName1->insert(pLocal1);
473 pLocalRangeName1->insert(pLocal2);
474 pLocalRangeName1->insert(pLocal3);
475 pLocalRangeName1->insert(pLocal4);
476 pLocalRangeName1->insert(pLocal5);
477 m_pDoc->SetRangeName(std::move(pGlobalRangeName));
478 m_pDoc->SetRangeName(0, std::move(pLocalRangeName1));
480 // Add formula to B1.
481 OUString aFormulaString("=local1+global+SUM($C$1:$D$4)+local3+local4+local5");
482 m_pDoc->SetString(1, 0, 0, aFormulaString);
484 double fValue = m_pDoc->GetValue(ScAddress(1, 0, 0));
485 ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 11", fValue, 11);
487 // add notes to A1:C1
488 setNote(0, 0, 0, "Hello world in A1"); // empty cell content
489 setNote(1, 0, 0, "Hello world in B1"); // formula cell content
490 setNote(2, 0, 0, "Hello world in C1"); // string cell content
492 //copy Sheet1.A1:C1 to Sheet2.A2:C2
493 ScRange aRange(0, 0, 0, 2, 0, 0);
494 ScDocument aClipDoc(SCDOCMODE_CLIP);
495 copyToClip(m_pDoc, aRange, &aClipDoc);
497 aRange = ScRange(0, 1, 1, 2, 1, 1); //target: Sheet2.A2:C2
498 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
499 pUndoDoc->InitUndo(*m_pDoc, 1, 1, true, true);
500 std::unique_ptr<ScUndoPaste> pUndo(createUndoPaste(*m_xDocShell, aRange, std::move(pUndoDoc)));
501 ScMarkData aMark(m_pDoc->GetSheetLimits());
502 aMark.SetMarkArea(aRange);
503 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
505 //check values after copying
506 OUString aString = m_pDoc->GetFormula(1, 1, 1);
507 CPPUNIT_ASSERT_EQUAL_MESSAGE("formula string was not copied correctly", aString,
508 aFormulaString);
509 // Only the global range points to Sheet1.A1, all copied sheet-local ranges
510 // to Sheet2.A1 that is empty, hence the result is 1, not 2.
511 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
512 ASSERT_DOUBLES_EQUAL_MESSAGE("copied formula should return 1", 1.0, fValue);
513 fValue = m_pDoc->GetValue(ScAddress(0, 1, 1));
514 ASSERT_DOUBLES_EQUAL_MESSAGE("copied value should be 1", 1.0, fValue);
516 ScRange aSheet2A1(0, 0, 1, 0, 0, 1);
518 //check local range name after copying
519 pLocal1 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL1"));
520 CPPUNIT_ASSERT_MESSAGE("local range name 1 should be copied", pLocal1);
521 ScRange aRangeLocal1;
522 bool bIsValidRef1 = pLocal1->IsValidReference(aRangeLocal1);
523 CPPUNIT_ASSERT_MESSAGE("local range name 1 should be valid", bIsValidRef1);
524 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 1 should now point to Sheet2.A1", aSheet2A1,
525 aRangeLocal1);
527 pLocal2 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL2"));
528 CPPUNIT_ASSERT_MESSAGE("local2 should not be copied", !pLocal2);
530 pLocal3 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL3"));
531 CPPUNIT_ASSERT_MESSAGE("local range name 3 should be copied", pLocal3);
532 ScRange aRangeLocal3;
533 bool bIsValidRef3 = pLocal3->IsValidReference(aRangeLocal3);
534 CPPUNIT_ASSERT_MESSAGE("local range name 3 should be valid", bIsValidRef3);
535 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 3 should now point to Sheet2.A1", aSheet2A1,
536 aRangeLocal3);
538 pLocal4 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL4"));
539 CPPUNIT_ASSERT_MESSAGE("local range name 4 should be copied", pLocal4);
540 ScRange aRangeLocal4;
541 bool bIsValidRef4 = pLocal4->IsValidReference(aRangeLocal4);
542 CPPUNIT_ASSERT_MESSAGE("local range name 4 should be valid", bIsValidRef4);
543 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 4 should now point to Sheet2.A1", aSheet2A1,
544 aRangeLocal4);
546 pLocal5 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL5"));
547 CPPUNIT_ASSERT_MESSAGE("local range name 5 should be copied", pLocal5);
548 ScRange aRangeLocal5;
549 bool bIsValidRef5 = pLocal5->IsValidReference(aRangeLocal5);
550 CPPUNIT_ASSERT_MESSAGE("local range name 5 should be valid", bIsValidRef5);
551 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 5 should now point to Sheet2.A1", aSheet2A1,
552 aRangeLocal5);
554 // check notes after copying
555 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.A2", m_pDoc->HasNote(0, 1, 1));
556 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.B2", m_pDoc->HasNote(1, 1, 1));
557 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.C2", m_pDoc->HasNote(2, 1, 1));
558 CPPUNIT_ASSERT_EQUAL_MESSAGE(
559 "Note content on Sheet1.A1 not copied to Sheet2.A2, empty cell content",
560 m_pDoc->GetNote(0, 0, 0)->GetText(), m_pDoc->GetNote(0, 1, 1)->GetText());
561 CPPUNIT_ASSERT_EQUAL_MESSAGE(
562 "Note content on Sheet1.B1 not copied to Sheet2.B2, formula cell content",
563 m_pDoc->GetNote(1, 0, 0)->GetText(), m_pDoc->GetNote(1, 1, 1)->GetText());
564 CPPUNIT_ASSERT_EQUAL_MESSAGE(
565 "Note content on Sheet1.C1 not copied to Sheet2.C2, string cell content",
566 m_pDoc->GetNote(2, 0, 0)->GetText(), m_pDoc->GetNote(2, 1, 1)->GetText());
568 //check undo and redo
569 pUndo->Undo();
570 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
571 ASSERT_DOUBLES_EQUAL_MESSAGE("after undo formula should return nothing", fValue, 0);
572 aString = m_pDoc->GetString(2, 1, 1);
573 CPPUNIT_ASSERT_MESSAGE("after undo, string should be removed", aString.isEmpty());
574 CPPUNIT_ASSERT_MESSAGE("after undo, note on A2 should be removed", !m_pDoc->HasNote(0, 1, 1));
575 CPPUNIT_ASSERT_MESSAGE("after undo, note on B2 should be removed", !m_pDoc->HasNote(1, 1, 1));
576 CPPUNIT_ASSERT_MESSAGE("after undo, note on C2 should be removed", !m_pDoc->HasNote(2, 1, 1));
578 pUndo->Redo();
579 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
580 ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 1 after redo", 1.0, fValue);
581 aString = m_pDoc->GetString(2, 1, 1);
582 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.C2 should contain: test", OUString("test"), aString);
583 aString = m_pDoc->GetFormula(1, 1, 1);
584 CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula should be correct again", aFormulaString, aString);
586 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.A2",
587 m_pDoc->HasNote(0, 1, 1));
588 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.B2",
589 m_pDoc->HasNote(1, 1, 1));
590 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.C2",
591 m_pDoc->HasNote(2, 1, 1));
592 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.A2, empty cell content",
593 getNote(0, 0, 0), getNote(0, 1, 1));
594 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.B2, formula cell content",
595 getNote(1, 0, 0), getNote(1, 1, 1));
596 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.C2, string cell content",
597 getNote(2, 0, 0), getNote(2, 1, 1));
599 // Copy Sheet1.A11:A13 to Sheet1.A7:A9, both within global2 range.
600 aRange = ScRange(0, 10, 0, 0, 12, 0);
601 ScDocument aClipDoc2(SCDOCMODE_CLIP);
602 copyToClip(m_pDoc, aRange, &aClipDoc2);
604 aRange = ScRange(0, 6, 0, 0, 8, 0);
605 aMark.SetMarkArea(aRange);
606 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc2);
608 // The global2 range must not have changed.
609 pGlobal2 = m_pDoc->GetRangeName()->findByUpperName("GLOBAL2");
610 CPPUNIT_ASSERT_MESSAGE("GLOBAL2 name not found", pGlobal2);
611 OUString aSymbol = pGlobal2->GetSymbol();
612 CPPUNIT_ASSERT_EQUAL_MESSAGE("GLOBAL2 named range changed", aGlobal2Symbol, aSymbol);
614 m_pDoc->DeleteTab(1);
615 m_pDoc->DeleteTab(0);
618 void TestCopyPaste::testCopyPasteAsLink()
620 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
622 m_pDoc->InsertTab(0, "Sheet1");
623 m_pDoc->InsertTab(1, "Sheet2");
625 m_pDoc->SetValue(ScAddress(0, 0, 0), 1); // A1
626 m_pDoc->SetValue(ScAddress(0, 1, 0), 2); // A2
627 m_pDoc->SetValue(ScAddress(0, 2, 0), 3); // A3
629 ScRange aRange(0, 0, 0, 0, 2, 0); // Copy A1:A3 to clip.
630 ScDocument aClipDoc(SCDOCMODE_CLIP);
631 copyToClip(m_pDoc, aRange, &aClipDoc);
633 aRange = ScRange(1, 1, 1, 1, 3, 1); // Paste to B2:B4 on Sheet2.
634 ScMarkData aMark(m_pDoc->GetSheetLimits());
635 aMark.SetMarkArea(aRange);
636 // Paste range as link.
637 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &aClipDoc, true,
638 true);
640 // Check pasted content to make sure they reference the correct cells.
641 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, 1));
642 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
643 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
645 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, 1));
646 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
647 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
649 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, 1));
650 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
651 CPPUNIT_ASSERT_EQUAL(3.0, pFC->GetValue());
653 m_pDoc->DeleteTab(1);
654 m_pDoc->DeleteTab(0);
657 void TestCopyPaste::testCopyPasteTranspose()
659 m_pDoc->InsertTab(0, "Sheet1");
661 // We need a drawing layer in order to create caption objects.
662 m_pDoc->InitDrawLayer(m_xDocShell.get());
664 m_pDoc->SetValue(0, 0, 0, 1);
665 m_pDoc->SetString(1, 0, 0, "=A1+1");
666 m_pDoc->SetString(2, 0, 0, "test");
668 // add notes to A1:C1
669 setNote(0, 0, 0, "Hello world in A1"); // numerical cell content
670 setNote(1, 0, 0, "Hello world in B1"); // formula cell content
671 setNote(2, 0, 0, "Hello world in C1"); // string cell content
673 // transpose clipboard, paste and check on Sheet2
674 m_pDoc->InsertTab(1, "Sheet2");
676 ScRange aSrcRange(0, 0, 0, 2, 0, 0);
677 ScDocument aNewClipDoc(SCDOCMODE_CLIP);
678 copyToClip(m_pDoc, aSrcRange, &aNewClipDoc);
680 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
681 aNewClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, false);
683 ScRange aDestRange(3, 1, 1, 3, 3, 1); //target: Sheet2.D2:D4
684 ScMarkData aMark(m_pDoc->GetSheetLimits());
685 aMark.SetMarkArea(aDestRange);
686 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get());
687 pTransClip.reset();
689 //check cell content after transposed copy/paste
690 OUString aString = m_pDoc->GetString(3, 3, 1);
691 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.D4 should contain: test", OUString("test"), aString);
692 double fValue = m_pDoc->GetValue(ScAddress(3, 1, 1));
693 ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied cell should return 1", 1, fValue);
694 fValue = m_pDoc->GetValue(ScAddress(3, 2, 1));
695 ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied formula should return 2", 2, fValue);
696 aString = m_pDoc->GetFormula(3, 2, 1);
697 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed formula should point on Sheet2.D2", OUString("=D2+1"),
698 aString);
700 // check notes after transposed copy/paste
701 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D2", m_pDoc->HasNote(3, 1, 1));
702 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D3", m_pDoc->HasNote(3, 2, 1));
703 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D4", m_pDoc->HasNote(3, 3, 1));
704 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D2", getNote(0, 0, 0),
705 getNote(3, 1, 1));
706 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D3", getNote(1, 0, 0),
707 getNote(3, 2, 1));
708 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D4", getNote(2, 0, 0),
709 getNote(3, 3, 1));
711 m_pDoc->DeleteTab(1);
712 m_pDoc->DeleteTab(0);
715 void TestCopyPaste::testCopyPasteSpecialMergedCellsTranspose()
717 const SCTAB srcSheet = 0;
718 const SCTAB destSheet = 1;
720 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
722 m_pDoc->InsertTab(srcSheet, "Sheet1");
723 m_pDoc->InsertTab(destSheet, "Sheet2");
725 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
726 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
727 m_pDoc->SetValue(0, 2, srcSheet, 3); // A3
728 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
730 m_pDoc->DoMerge(0, 1, 1, 1, srcSheet, false); // Merge A2 and B2
731 m_pDoc->DoMerge(0, 2, 1, 2, srcSheet, false); // Merge A3 and B3
733 // Test precondition
734 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
735 lcl_getMergeSizeOfCell(*m_pDoc, 0, 0, srcSheet));
736 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 0, srcSheet));
737 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
738 lcl_getMergeSizeOfCell(*m_pDoc, 0, 1, srcSheet));
739 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
740 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, srcSheet));
741 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 1, srcSheet));
742 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
743 lcl_getMergeSizeOfCell(*m_pDoc, 0, 2, srcSheet));
744 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
745 lcl_getMergeSizeOfCell(*m_pDoc, 1, 2, srcSheet));
746 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, srcSheet));
747 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
748 lcl_getMergeSizeOfCell(*m_pDoc, 0, 3, srcSheet));
749 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 3, srcSheet));
751 ScRange aSrcRange(0, 0, srcSheet, 1, 3, srcSheet); // Copy A1:B4 to clip.
752 ScDocument aClipDoc(SCDOCMODE_CLIP);
753 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
755 // transpose
756 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
757 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
759 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
760 ScMarkData aMark(m_pDoc->GetSheetLimits());
761 aMark.SetMarkArea(aDestRange);
762 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
763 false);
764 pTransClip.reset();
766 // Check transpose of merged cells
767 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
768 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, destSheet));
769 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, destSheet));
770 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
771 lcl_getMergeSizeOfCell(*m_pDoc, 2, 1, destSheet));
772 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 1, destSheet));
773 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
774 lcl_getMergeSizeOfCell(*m_pDoc, 3, 1, destSheet));
775 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 1, destSheet));
776 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
777 lcl_getMergeSizeOfCell(*m_pDoc, 4, 1, destSheet));
778 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 4, 2, destSheet));
780 m_pDoc->DeleteTab(destSheet);
781 m_pDoc->DeleteTab(srcSheet);
784 void TestCopyPaste::testCopyPasteSpecialMergedCellsFilteredTranspose()
786 const SCTAB srcSheet = 0;
787 const SCTAB destSheet = 1;
789 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
791 m_pDoc->InsertTab(srcSheet, "Sheet1");
792 m_pDoc->InsertTab(destSheet, "Sheet2");
794 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
795 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
796 m_pDoc->SetValue(0, 2, srcSheet, 3); // A3
797 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
799 m_pDoc->DoMerge(0, 1, 1, 1, srcSheet, false); // Merge A2 and B2
800 m_pDoc->DoMerge(0, 2, 1, 2, srcSheet, false); // Merge A3 and B3
802 // Filter row 1
803 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
804 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
806 pDBData->SetAutoFilter(true);
807 ScRange aRange;
808 pDBData->GetArea(aRange);
809 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
810 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
812 //create the query param
813 ScQueryParam aParam;
814 pDBData->GetQueryParam(aParam);
815 ScQueryEntry& rEntry = aParam.GetEntry(0);
816 rEntry.bDoQuery = true;
817 rEntry.nField = 0;
818 rEntry.eOp = SC_NOT_EQUAL;
819 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
820 // add queryParam to database range.
821 pDBData->SetQueryParam(aParam);
823 // perform the query.
824 m_pDoc->Query(srcSheet, aParam, true);
826 // Test precondition
827 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
828 lcl_getMergeSizeOfCell(*m_pDoc, 0, 0, srcSheet));
829 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 0, srcSheet));
830 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
831 lcl_getMergeSizeOfCell(*m_pDoc, 0, 1, srcSheet));
832 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
833 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, srcSheet));
834 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 1, srcSheet));
835 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
836 lcl_getMergeSizeOfCell(*m_pDoc, 0, 2, srcSheet));
837 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
838 lcl_getMergeSizeOfCell(*m_pDoc, 1, 2, srcSheet));
839 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, srcSheet));
840 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
841 lcl_getMergeSizeOfCell(*m_pDoc, 0, 3, srcSheet));
842 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 3, srcSheet));
844 ScRange aSrcRange(0, 0, srcSheet, 1, 3, srcSheet); // Copy A1:B4 to clip.
845 ScDocument aClipDoc(SCDOCMODE_CLIP);
846 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
848 // transpose
849 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
850 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
852 ScRange aDestRange(1, 1, destSheet, 3, 2, destSheet); // Paste to B2:D3 on Sheet2.
853 ScMarkData aMark(m_pDoc->GetSheetLimits());
854 aMark.SetMarkArea(aDestRange);
855 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
856 false);
857 pTransClip.reset();
859 // Check transpose of merged cells
860 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
861 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, destSheet));
862 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, destSheet));
863 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
864 lcl_getMergeSizeOfCell(*m_pDoc, 2, 1, destSheet));
865 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 1, destSheet));
866 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
867 lcl_getMergeSizeOfCell(*m_pDoc, 3, 1, destSheet));
868 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 3, 2, destSheet));
870 m_pDoc->DeleteTab(destSheet);
871 m_pDoc->DeleteTab(srcSheet);
874 // InsertDeleteFlags::CONTENTS
875 void TestCopyPaste::testCopyPasteSpecialAsLinkTranspose()
877 const SCTAB srcSheet = 0;
878 const SCTAB destSheet = 1;
880 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
882 m_pDoc->InsertTab(srcSheet, "Sheet1");
883 m_pDoc->InsertTab(destSheet, "Sheet2");
885 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
886 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
887 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
889 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet); // Copy A1:A4 to clip.
890 ScDocument aClipDoc(SCDOCMODE_CLIP);
891 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
893 // transpose
894 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
895 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::CONTENTS, true, false);
897 ScRange aDestRange(1, 1, destSheet, 4, 1, destSheet); // Paste to B2:E2 on Sheet2.
898 ScMarkData aMark(m_pDoc->GetSheetLimits());
899 aMark.SetMarkArea(aDestRange);
900 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, pTransClip.get(),
901 true, false);
902 pTransClip.reset();
904 // Check pasted content to make sure they reference the correct cells.
905 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
906 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
907 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
908 m_pDoc->GetFormula(1, 1, destSheet));
909 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
911 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
912 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
913 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"),
914 m_pDoc->GetFormula(2, 1, destSheet));
915 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
917 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
918 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D2.", !pFC);
920 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
921 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
922 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"),
923 m_pDoc->GetFormula(4, 1, destSheet));
924 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
926 m_pDoc->DeleteTab(destSheet);
927 m_pDoc->DeleteTab(srcSheet);
930 // InsertDeleteFlags::CONTENTS
931 void TestCopyPaste::testCopyPasteSpecialAsLinkFilteredTranspose()
933 const SCTAB srcSheet = 0;
934 const SCTAB destSheet = 1;
936 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
938 m_pDoc->InsertTab(srcSheet, "Sheet1");
939 m_pDoc->InsertTab(destSheet, "Sheet2");
941 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
942 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
943 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
945 // Filter row 1
946 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
947 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
949 pDBData->SetAutoFilter(true);
950 ScRange aRange;
951 pDBData->GetArea(aRange);
952 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
953 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
955 //create the query param
956 ScQueryParam aParam;
957 pDBData->GetQueryParam(aParam);
958 ScQueryEntry& rEntry = aParam.GetEntry(0);
959 rEntry.bDoQuery = true;
960 rEntry.nField = 0;
961 rEntry.eOp = SC_NOT_EQUAL;
962 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
963 // add queryParam to database range.
964 pDBData->SetQueryParam(aParam);
966 // perform the query.
967 m_pDoc->Query(srcSheet, aParam, true);
969 // Check precondition for test: row 1 is hidden/filtered
970 SCROW nRow1, nRow2;
971 SCROW nFilteredRow1, nFilteredRow2;
972 bool bHidden = m_pDoc->RowHidden(SCROW(1), srcSheet, &nRow1, &nRow2);
973 CPPUNIT_ASSERT_MESSAGE("row 1 should be hidden", bHidden);
974 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow1);
975 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow2);
976 bool bFiltered = m_pDoc->RowFiltered(SCROW(1), srcSheet, &nFilteredRow1, &nFilteredRow2);
977 CPPUNIT_ASSERT_MESSAGE("row 1 should be filtered", bFiltered);
978 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow1);
979 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow2);
981 // Copy A1:A4 to clip.
982 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet);
983 ScDocument aClipDoc(SCDOCMODE_CLIP);
984 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
986 // transpose
987 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
988 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::CONTENTS, true, false);
990 ScRange aDestRange(1, 1, destSheet, 3, 1, destSheet); // Paste to B2:D2 on Sheet2.
991 ScMarkData aMark(m_pDoc->GetSheetLimits());
992 aMark.SetMarkArea(aDestRange);
993 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, pTransClip.get(),
994 true, false, false);
995 pTransClip.reset();
997 // Check pasted content to make sure they reference the correct cells.
998 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
999 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1000 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1001 m_pDoc->GetFormula(1, 1, destSheet));
1002 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1004 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1005 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C2.", !pFC);
1007 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1008 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1009 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"),
1010 m_pDoc->GetFormula(3, 1, destSheet));
1011 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1013 m_pDoc->DeleteTab(destSheet);
1014 m_pDoc->DeleteTab(srcSheet);
1017 // tdf#141683
1018 // InsertDeleteFlags::VALUE
1019 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowAsLinkTranspose()
1021 const SCTAB srcSheet = 0;
1022 const SCTAB destSheet = 1;
1024 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1026 m_pDoc->InsertTab(srcSheet, "Sheet1");
1027 m_pDoc->InsertTab(destSheet, "Sheet2");
1029 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1030 m_pDoc->SetValue(1, 0, srcSheet, 2); // B1
1031 m_pDoc->SetValue(3, 0, srcSheet, 4); // D1
1033 m_pDoc->SetValue(0, 2, srcSheet, 11); // A3
1034 m_pDoc->SetValue(1, 2, srcSheet, 12); // B3
1035 m_pDoc->SetValue(3, 2, srcSheet, 14); // D3
1037 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1038 aSrcMark.SelectOneTable(0);
1039 ScClipParam aClipParam;
1040 aClipParam.meDirection = ScClipParam::Row;
1041 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 3, 0, srcSheet)); // A1:D1
1042 aClipParam.maRanges.push_back(ScRange(0, 2, srcSheet, 3, 2, srcSheet)); // A3:D3
1044 ScDocument aClipDoc(SCDOCMODE_CLIP);
1045 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1047 // transpose
1048 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1049 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1051 ScRange aDestRange(1, 1, destSheet, 2, 4, destSheet); // Paste to B2:C5 on Sheet2.
1052 ScMarkData aMark(m_pDoc->GetSheetLimits());
1053 aMark.SetMarkArea(aDestRange);
1054 m_pDoc->CopyMultiRangeFromClip(
1055 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1056 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1057 pTransClip.reset();
1059 // Check pasted content to make sure they reference the correct cells.
1060 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1061 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1062 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1063 m_pDoc->GetFormula(1, 1, destSheet));
1064 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1066 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1067 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1068 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$B$1"),
1069 m_pDoc->GetFormula(1, 2, destSheet));
1070 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1072 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, destSheet));
1073 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell B4.", !pFC);
1075 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 4, destSheet));
1076 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1077 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B5", OUString("=$Sheet1.$D$1"),
1078 m_pDoc->GetFormula(1, 4, destSheet));
1079 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1081 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1082 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1083 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"),
1084 m_pDoc->GetFormula(2, 1, destSheet));
1085 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1087 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1088 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1089 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$B$3"),
1090 m_pDoc->GetFormula(2, 2, destSheet));
1091 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1093 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 3, destSheet));
1094 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C4.", !pFC);
1096 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 4, destSheet));
1097 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1098 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C5", OUString("=$Sheet1.$D$3"),
1099 m_pDoc->GetFormula(2, 4, destSheet));
1100 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1102 m_pDoc->DeleteTab(destSheet);
1103 m_pDoc->DeleteTab(srcSheet);
1106 // tdf#141683
1107 // InsertDeleteFlags::VALUE
1108 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose()
1110 const SCTAB srcSheet = 0;
1111 const SCTAB destSheet = 1;
1113 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1115 m_pDoc->InsertTab(srcSheet, "Sheet1");
1116 m_pDoc->InsertTab(destSheet, "Sheet2");
1118 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1119 m_pDoc->SetValue(1, 0, srcSheet, 2); // B1
1120 m_pDoc->SetValue(3, 0, srcSheet, 4); // D1
1122 m_pDoc->SetValue(0, 1, srcSheet, -1); // A2, filtered and selected
1123 m_pDoc->SetValue(1, 1, srcSheet, -2); // B2, filtered and selected
1124 m_pDoc->SetValue(3, 1, srcSheet, -4); // D2, filtered and selected
1126 m_pDoc->SetValue(0, 2, srcSheet, 11); // A3
1127 m_pDoc->SetValue(1, 2, srcSheet, 12); // B3
1128 m_pDoc->SetValue(3, 2, srcSheet, 14); // D3
1130 m_pDoc->SetValue(0, 3, srcSheet, -11); // A4, filtered and not selected
1131 m_pDoc->SetValue(1, 3, srcSheet, -12); // B4, filtered and not selected
1132 m_pDoc->SetValue(3, 3, srcSheet, -14); // D4, filtered and not selected
1134 m_pDoc->SetValue(0, 5, srcSheet, 111); // A6
1135 m_pDoc->SetValue(1, 5, srcSheet, 112); // B6
1136 m_pDoc->SetValue(3, 5, srcSheet, 114); // D6
1138 // Filter row 1
1139 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 3, 3);
1140 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1142 pDBData->SetAutoFilter(true);
1143 ScRange aRange;
1144 pDBData->GetArea(aRange);
1145 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1146 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1148 //create the query param
1149 ScQueryParam aParam;
1150 pDBData->GetQueryParam(aParam);
1151 ScQueryEntry& rEntry = aParam.GetEntry(0);
1152 rEntry.bDoQuery = true;
1153 rEntry.nField = 0;
1154 rEntry.eOp = SC_GREATER_EQUAL;
1155 rEntry.GetQueryItem().mfVal = 0; // filtering negative values -> filtering row 1 and 2
1156 // add queryParam to database range.
1157 pDBData->SetQueryParam(aParam);
1159 // perform the query.
1160 m_pDoc->Query(srcSheet, aParam, true);
1162 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1163 aSrcMark.SelectOneTable(0);
1164 ScClipParam aClipParam;
1165 aClipParam.meDirection = ScClipParam::Row;
1166 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 3, 2, srcSheet)); // A1:C3
1167 aClipParam.maRanges.push_back(ScRange(0, 5, srcSheet, 3, 5, srcSheet)); // A6:C6
1169 ScDocument aClipDoc(SCDOCMODE_CLIP);
1170 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1172 printRange(m_pDoc, aClipParam.getWholeRange(), "Src range");
1173 // transpose
1174 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1175 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1177 printRange(&aClipDoc, ScRange(0, 0, 0, 4, 5, 0), "Base doc (&aClipDoc)");
1178 printRange(pTransClip.get(), ScRange(0, 0, 0, 3, 3, 0),
1179 "Transposed filtered clipdoc (pTransClip.get())");
1180 ScRange aDestRange(1, 1, destSheet, 3, 4, destSheet); // Paste to B2:D5 on Sheet2.
1181 ScMarkData aMark(m_pDoc->GetSheetLimits());
1182 aMark.SetMarkArea(aDestRange);
1183 m_pDoc->CopyMultiRangeFromClip(
1184 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1185 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1186 pTransClip.reset();
1187 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
1189 // Check pasted content to make sure they reference the correct cells.
1190 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1191 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1192 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1193 m_pDoc->GetFormula(1, 1, destSheet));
1194 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1196 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1197 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1198 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$B$1"),
1199 m_pDoc->GetFormula(1, 2, destSheet));
1200 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1202 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, destSheet));
1203 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell B4.", !pFC);
1205 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 4, destSheet));
1206 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1207 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B5", OUString("=$Sheet1.$D$1"),
1208 m_pDoc->GetFormula(1, 4, destSheet));
1209 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1211 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1212 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1213 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"),
1214 m_pDoc->GetFormula(2, 1, destSheet));
1215 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1217 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1218 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1219 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$B$3"),
1220 m_pDoc->GetFormula(2, 2, destSheet));
1221 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1223 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 3, destSheet));
1224 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C4.", !pFC);
1226 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 4, destSheet));
1227 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1228 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C5", OUString("=$Sheet1.$D$3"),
1229 m_pDoc->GetFormula(2, 4, destSheet));
1230 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1232 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1233 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell D2.", pFC);
1234 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$6"),
1235 m_pDoc->GetFormula(3, 1, destSheet));
1236 CPPUNIT_ASSERT_EQUAL(111.0, pFC->GetValue());
1238 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1239 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell D3.", pFC);
1240 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("=$Sheet1.$B$6"),
1241 m_pDoc->GetFormula(3, 2, destSheet));
1242 CPPUNIT_ASSERT_EQUAL(112.0, pFC->GetValue());
1244 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 3, destSheet));
1245 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D4.", !pFC);
1247 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 4, destSheet));
1248 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1249 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("=$Sheet1.$D$6"),
1250 m_pDoc->GetFormula(3, 4, destSheet));
1251 CPPUNIT_ASSERT_EQUAL(114.0, pFC->GetValue());
1253 m_pDoc->DeleteTab(destSheet);
1254 m_pDoc->DeleteTab(srcSheet);
1257 // tdf#141683
1258 // InsertDeleteFlags::VALUE
1259 void TestCopyPaste::testCopyPasteSpecialMultiRangeColAsLinkTranspose()
1261 const SCTAB srcSheet = 0;
1262 const SCTAB destSheet = 1;
1264 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1266 m_pDoc->InsertTab(srcSheet, "Sheet1");
1267 m_pDoc->InsertTab(destSheet, "Sheet2");
1269 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1270 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1271 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1273 m_pDoc->SetValue(2, 0, srcSheet, 11); // C1
1274 m_pDoc->SetValue(2, 1, srcSheet, 12); // C2
1275 m_pDoc->SetValue(2, 3, srcSheet, 14); // C4
1277 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1278 aSrcMark.SelectOneTable(0);
1279 ScClipParam aClipParam;
1280 aClipParam.meDirection = ScClipParam::Column;
1281 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 0, 3, srcSheet)); // A1:A4
1282 aClipParam.maRanges.push_back(ScRange(2, 0, srcSheet, 2, 3, srcSheet)); // C1:C4
1284 ScDocument aClipDoc(SCDOCMODE_CLIP);
1285 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1287 // transpose
1288 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1289 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1291 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
1292 ScMarkData aMark(m_pDoc->GetSheetLimits());
1293 aMark.SetMarkArea(aDestRange);
1294 m_pDoc->CopyMultiRangeFromClip(
1295 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1296 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1297 pTransClip.reset();
1299 // Check pasted content to make sure they reference the correct cells.
1300 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1301 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1302 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1303 m_pDoc->GetFormula(1, 1, destSheet));
1304 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1306 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1307 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1308 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"),
1309 m_pDoc->GetFormula(2, 1, destSheet));
1310 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1312 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1313 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D2.", !pFC);
1315 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
1316 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1317 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"),
1318 m_pDoc->GetFormula(4, 1, destSheet));
1319 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1321 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1322 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1323 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$C$1"),
1324 m_pDoc->GetFormula(1, 2, destSheet));
1325 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1327 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1328 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1329 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$C$2"),
1330 m_pDoc->GetFormula(2, 2, destSheet));
1331 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1333 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1334 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D3.", !pFC);
1336 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 2, destSheet));
1337 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1338 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("=$Sheet1.$C$4"),
1339 m_pDoc->GetFormula(4, 2, destSheet));
1340 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1342 m_pDoc->DeleteTab(destSheet);
1343 m_pDoc->DeleteTab(srcSheet);
1346 // tdf#141683
1347 // InsertDeleteFlags::VALUE
1348 void TestCopyPaste::testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose()
1350 const SCTAB srcSheet = 0;
1351 const SCTAB destSheet = 1;
1353 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1355 m_pDoc->InsertTab(srcSheet, "Sheet1");
1356 m_pDoc->InsertTab(destSheet, "Sheet2");
1358 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1359 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1360 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1362 m_pDoc->SetValue(2, 0, srcSheet, 11); // C1
1363 m_pDoc->SetValue(2, 1, srcSheet, 12); // C2
1364 m_pDoc->SetValue(2, 3, srcSheet, 14); // C4
1366 // Filter row 1
1367 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
1368 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1370 pDBData->SetAutoFilter(true);
1371 ScRange aRange;
1372 pDBData->GetArea(aRange);
1373 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1374 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1376 //create the query param
1377 ScQueryParam aParam;
1378 pDBData->GetQueryParam(aParam);
1379 ScQueryEntry& rEntry = aParam.GetEntry(0);
1380 rEntry.bDoQuery = true;
1381 rEntry.nField = 0;
1382 rEntry.eOp = SC_NOT_EQUAL;
1383 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1384 // add queryParam to database range.
1385 pDBData->SetQueryParam(aParam);
1387 // perform the query.
1388 m_pDoc->Query(srcSheet, aParam, true);
1390 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1391 aSrcMark.SelectOneTable(0);
1392 ScClipParam aClipParam;
1393 aClipParam.meDirection = ScClipParam::Column;
1394 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 0, 3, srcSheet)); // A1:A4
1395 aClipParam.maRanges.push_back(ScRange(2, 0, srcSheet, 2, 3, srcSheet)); // C1:C4
1397 ScDocument aClipDoc(SCDOCMODE_CLIP);
1398 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1400 // transpose
1401 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1402 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1404 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
1405 ScMarkData aMark(m_pDoc->GetSheetLimits());
1406 aMark.SetMarkArea(aDestRange);
1407 m_pDoc->CopyMultiRangeFromClip(
1408 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1409 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1410 pTransClip.reset();
1412 // Check pasted content to make sure they reference the correct cells.
1413 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1414 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1415 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1416 m_pDoc->GetFormula(1, 1, destSheet));
1417 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1419 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1420 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C2.", !pFC);
1422 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1423 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1424 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"),
1425 m_pDoc->GetFormula(3, 1, destSheet));
1426 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1428 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1429 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1430 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$C$1"),
1431 m_pDoc->GetFormula(1, 2, destSheet));
1432 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1434 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1435 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C3.", !pFC);
1437 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1438 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1439 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("=$Sheet1.$C$4"),
1440 m_pDoc->GetFormula(3, 2, destSheet));
1441 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1443 m_pDoc->DeleteTab(destSheet);
1444 m_pDoc->DeleteTab(srcSheet);
1447 // InsertDeleteFlags::ALL
1448 void TestCopyPaste::testCopyPasteSpecialAllAsLinkTranspose()
1450 const SCTAB srcSheet = 0;
1451 const SCTAB destSheet = 1;
1453 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1455 m_pDoc->InsertTab(srcSheet, "Sheet1");
1456 m_pDoc->InsertTab(destSheet, "Sheet2");
1458 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1459 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1460 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1462 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet); // Copy A1:A4 to clip.
1463 ScDocument aClipDoc(SCDOCMODE_CLIP);
1464 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1466 // transpose
1467 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1468 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
1470 ScRange aDestRange(1, 1, destSheet, 4, 1, destSheet); // Paste to B2:E2 on Sheet2.
1471 ScMarkData aMark(m_pDoc->GetSheetLimits());
1472 aMark.SetMarkArea(aDestRange);
1473 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
1474 false);
1475 pTransClip.reset();
1477 // Check pasted content to make sure they reference the correct cells.
1478 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1479 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1480 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1481 m_pDoc->GetFormula(1, 1, destSheet));
1482 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1484 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1485 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1486 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"),
1487 m_pDoc->GetFormula(2, 1, destSheet));
1488 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1490 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1491 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1492 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$3"),
1493 m_pDoc->GetFormula(3, 1, destSheet));
1494 CPPUNIT_ASSERT_EQUAL(0.0, pFC->GetValue());
1496 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
1497 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1498 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"),
1499 m_pDoc->GetFormula(4, 1, destSheet));
1500 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1502 m_pDoc->DeleteTab(destSheet);
1503 m_pDoc->DeleteTab(srcSheet);
1506 // InsertDeleteFlags::ALL
1507 void TestCopyPaste::testCopyPasteSpecialAllAsLinkFilteredTranspose()
1509 const SCTAB srcSheet = 0;
1510 const SCTAB destSheet = 1;
1512 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1514 m_pDoc->InsertTab(srcSheet, "Sheet1");
1515 m_pDoc->InsertTab(destSheet, "Sheet2");
1517 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1518 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1519 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1521 // Filter row 1
1522 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
1523 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1525 pDBData->SetAutoFilter(true);
1526 ScRange aRange;
1527 pDBData->GetArea(aRange);
1528 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1529 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1531 //create the query param
1532 ScQueryParam aParam;
1533 pDBData->GetQueryParam(aParam);
1534 ScQueryEntry& rEntry = aParam.GetEntry(0);
1535 rEntry.bDoQuery = true;
1536 rEntry.nField = 0;
1537 rEntry.eOp = SC_NOT_EQUAL;
1538 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1539 // add queryParam to database range.
1540 pDBData->SetQueryParam(aParam);
1542 // perform the query.
1543 m_pDoc->Query(srcSheet, aParam, true);
1545 // Check precondition for test: row 1 is hidden/filtered
1546 SCROW nRow1, nRow2;
1547 SCROW nFilteredRow1, nFilteredRow2;
1548 bool bHidden = m_pDoc->RowHidden(SCROW(1), srcSheet, &nRow1, &nRow2);
1549 CPPUNIT_ASSERT_MESSAGE("row 1 should be hidden", bHidden);
1550 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow1);
1551 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow2);
1552 bool bFiltered = m_pDoc->RowFiltered(SCROW(1), srcSheet, &nFilteredRow1, &nFilteredRow2);
1553 CPPUNIT_ASSERT_MESSAGE("row 1 should be filtered", bFiltered);
1554 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow1);
1555 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow2);
1557 // Copy A1:A4 to clip.
1558 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet);
1559 ScDocument aClipDoc(SCDOCMODE_CLIP);
1560 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1562 // transpose
1563 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1564 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
1566 ScRange aDestRange(1, 1, destSheet, 3, 1, destSheet); // Paste to B2:D2 on Sheet2.
1567 ScMarkData aMark(m_pDoc->GetSheetLimits());
1568 aMark.SetMarkArea(aDestRange);
1569 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
1570 false, false);
1571 pTransClip.reset();
1573 // Check pasted content to make sure they reference the correct cells.
1574 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1575 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1576 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1577 m_pDoc->GetFormula(1, 1, destSheet));
1578 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1580 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1581 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1582 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"),
1583 m_pDoc->GetFormula(2, 1, destSheet));
1584 CPPUNIT_ASSERT_EQUAL(0.0, pFC->GetValue());
1586 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1587 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1588 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"),
1589 m_pDoc->GetFormula(3, 1, destSheet));
1590 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1592 m_pDoc->DeleteTab(destSheet);
1593 m_pDoc->DeleteTab(srcSheet);
1596 // Compatibility method since normal copy/paste tests do not test undo
1597 void TestCopyPaste::executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
1598 bool bTranspose, bool bMultiRangeSelection,
1599 bool bSkipEmpty, bool bCut,
1600 ScClipParam::Direction eDirection, CalcMode eCalcMode,
1601 InsertDeleteFlags aFlags)
1603 std::unique_ptr<ScUndoCut> pUndoCut;
1604 std::unique_ptr<ScUndoPaste> pUndoPaste;
1605 executeCopyPasteSpecial(0, 1, bApplyFilter, bIncludedFiltered, bAsLink, bTranspose,
1606 bMultiRangeSelection, bSkipEmpty, pUndoCut, pUndoPaste, bCut,
1607 eDirection, eCalcMode, aFlags);
1610 // This method is used to create the different copy/paste special test cases.
1611 // Principle: Creation of test cases is parameterized, whereas checking uses a minimum of logic
1612 void TestCopyPaste::executeCopyPasteSpecial(const SCTAB srcSheet, const SCTAB destSheet,
1613 bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
1614 bool bTranspose, bool bMultiRangeSelection,
1615 bool bSkipEmpty, std::unique_ptr<ScUndoCut>& pUndoCut,
1616 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bCut,
1617 ScClipParam::Direction eDirection, CalcMode eCalcMode,
1618 InsertDeleteFlags aFlags)
1620 // turn on/off auto calc
1621 sc::AutoCalcSwitch aACSwitch(*m_pDoc, eCalcMode == AutoCalc);
1623 for (int i = 0; i < srcSheet; ++i)
1624 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
1626 m_pDoc->InsertTab(srcSheet, "SrcSheet");
1628 // We need a drawing layer in order to create caption objects.
1629 m_pDoc->InitDrawLayer(m_xDocShell.get());
1630 ScFieldEditEngine& rEditEngine = m_pDoc->GetEditEngine();
1633 | B | C | D | E | F | G |
1635 3r | 1 B*| =B3+10 *| a | R1 *| =B3+B5+60 | =SUMIF(B3:B6;"<4") |
1636 4r | 2 B*| =B4+20 b | b *| R2 *| | *| <- filtered row
1637 5r | 3 B*| =E5+30 b*| c *| 5 *| B*| |
1638 6 | 4 | =B4+40 b*| d *| R4 *| =B3+B5+70 *| =C$3+$B$5+80 *|
1639 (7r | 6 | q | r bB*| s bB| t | u |) optional, for row range
1640 (8 | -1 | -2 | -3 | -4 | -5 | -6 |) optional, for row range
1641 (9r | -11 | -12 | -13 | -14 | -15 | -16 |) optional, for row range
1642 (10 | -21 | -22 | -23 | -24 | -25 | -26 |) optional, for row range
1644 \______________/ \________________________________________/
1645 col range 1 col range 2
1647 refs to cells (used for cut/paste tests)
1648 15 | =C5 | =$C$5 | =$C5 | =C$5| =SUM(C5:C5) | =SUM($C5:$C5) | =SUM($C5:$C5) | =SUM(C$5:C$5) | =SUM($B$3:$B$6) | =SUM($B$3:$B$10) |
1649 16 | =Range_C5 | =Range_aCa5 | =Range_aC5 | =Range_Ca5| =SUM(Range_C5_C5) | =SUM(Range_aCa5_aCa5) | =SUM(Range_aC5_aC5) | =SUM(Range_Ca5_Ca5) | =SUM(Range_aCa5_aCa8) | =SUM(Range_aCa5_aCa10) |
1651 * means note attached
1652 B means background
1653 b means border
1654 r means row selected for row range in multi range selection
1656 The following test scenarios can be created:
1658 * Filtered row
1659 * Transpose
1660 * All cell types: numbers, strings, formulas, rich text, empty cell
1661 * Notes at different position
1662 * Formula references to rows before and after filtered row
1663 * Double reference (e.g. B3:B5)
1664 * Relative and absolute references
1665 * absolute references are not changed by transposing
1666 * Formatting patterns (e.g. cell backgrounds and borders)
1667 * Multi range selection with direction column and row
1670 SCCOL nSrcCols = 6;
1671 SCROW nSrcRows = 4;
1672 // Add additional row for MultiRange test cases
1673 if (bMultiRangeSelection)
1675 nSrcRows = eDirection == ScClipParam::Row ? nSrcRows + 2 : nSrcRows;
1676 nSrcCols = eDirection == ScClipParam::Column ? nSrcCols + 1 : nSrcCols;
1679 const SCCOL nStartCol = 1;
1680 const SCROW nStartRow = 2;
1682 // col B
1683 m_pDoc->SetValue(1, 2, srcSheet, 1);
1684 m_pDoc->SetValue(1, 3, srcSheet, 2);
1685 m_pDoc->SetValue(1, 4, srcSheet, 3);
1686 m_pDoc->SetValue(1, 5, srcSheet, 4);
1687 // col C
1688 m_pDoc->SetString(2, 2, srcSheet, "=B3+10");
1689 m_pDoc->SetString(2, 3, srcSheet, "=B4+20");
1690 m_pDoc->SetString(2, 4, srcSheet, "=E5+30");
1691 m_pDoc->SetString(2, 5, srcSheet, "=B4+40");
1692 // col D
1693 m_pDoc->SetString(3, 2, srcSheet, "a");
1694 m_pDoc->SetString(3, 3, srcSheet, "b");
1695 m_pDoc->SetString(3, 4, srcSheet, "c");
1696 m_pDoc->SetString(3, 5, srcSheet, "d");
1697 // col E
1698 rEditEngine.SetTextCurrentDefaults("R1");
1699 m_pDoc->SetEditText(ScAddress(4, 2, srcSheet), rEditEngine.CreateTextObject());
1700 rEditEngine.SetTextCurrentDefaults("R2");
1701 m_pDoc->SetEditText(ScAddress(4, 3, srcSheet), rEditEngine.CreateTextObject());
1702 m_pDoc->SetValue(4, 4, srcSheet, 5);
1703 rEditEngine.SetTextCurrentDefaults("R4");
1704 m_pDoc->SetEditText(ScAddress(4, 5, srcSheet), rEditEngine.CreateTextObject());
1705 // col F
1706 m_pDoc->SetValue(5, 2, srcSheet, 9);
1707 m_pDoc->SetString(5, 2, srcSheet, "=B3+B5+60");
1708 m_pDoc->SetEmptyCell(ScAddress(5, 3, srcSheet));
1709 m_pDoc->SetEmptyCell(ScAddress(5, 4, srcSheet));
1710 m_pDoc->SetString(5, 5, srcSheet, "=B3+B5+70");
1711 // col G
1712 m_pDoc->SetValue(6, 2, srcSheet, 9);
1713 m_pDoc->SetString(6, 2, srcSheet, "=SUMIF(B3:B6;\"<4\")");
1714 m_pDoc->SetEmptyCell(ScAddress(6, 3, srcSheet));
1715 m_pDoc->SetEmptyCell(ScAddress(6, 4, srcSheet));
1716 m_pDoc->SetString(6, 5, srcSheet, "=C$3+$B$5+80");
1718 const SfxPoolItem* pItem = nullptr;
1720 // row 6, additional row for MultiRange test case, otherwise not selected
1721 m_pDoc->SetValue(1, 6, srcSheet, 6);
1722 m_pDoc->SetString(2, 6, srcSheet, "q");
1723 m_pDoc->SetString(3, 6, srcSheet, "r");
1724 m_pDoc->SetString(4, 6, srcSheet, "s");
1725 m_pDoc->SetString(5, 6, srcSheet, "t");
1726 m_pDoc->SetString(6, 6, srcSheet, "u");
1728 // row 7, not selected
1729 m_pDoc->SetValue(1, 7, srcSheet, -1);
1730 m_pDoc->SetValue(2, 7, srcSheet, -2);
1731 m_pDoc->SetValue(3, 7, srcSheet, -3);
1732 m_pDoc->SetValue(4, 7, srcSheet, -4);
1733 m_pDoc->SetValue(5, 7, srcSheet, -5);
1734 m_pDoc->SetValue(6, 7, srcSheet, -6);
1736 // row 8, additional row for MultiRange test case, otherwise not selected
1737 m_pDoc->SetValue(1, 8, srcSheet, -11);
1738 m_pDoc->SetValue(2, 8, srcSheet, -12);
1739 m_pDoc->SetValue(3, 8, srcSheet, -13);
1740 m_pDoc->SetValue(4, 8, srcSheet, -14);
1741 m_pDoc->SetValue(5, 8, srcSheet, -15);
1742 m_pDoc->SetValue(6, 8, srcSheet, -16);
1744 // row 9, additional row for MultiRange test case, otherwise not selected
1745 m_pDoc->SetValue(1, 9, srcSheet, -21);
1746 m_pDoc->SetValue(2, 9, srcSheet, -22);
1747 m_pDoc->SetValue(3, 9, srcSheet, -23);
1748 m_pDoc->SetValue(4, 9, srcSheet, -24);
1749 m_pDoc->SetValue(5, 9, srcSheet, -25);
1750 m_pDoc->SetValue(6, 9, srcSheet, -26);
1752 // Col H, not selected
1753 m_pDoc->SetValue(7, 2, srcSheet, 111);
1754 m_pDoc->SetValue(7, 3, srcSheet, 112);
1755 m_pDoc->SetValue(7, 4, srcSheet, 113);
1756 m_pDoc->SetValue(7, 5, srcSheet, 114);
1757 m_pDoc->SetValue(7, 6, srcSheet, 115);
1758 m_pDoc->SetValue(7, 7, srcSheet, 116);
1760 // Col I, additional col for MultiRange test case, otherwise not selected
1761 m_pDoc->SetValue(8, 2, srcSheet, 121);
1762 m_pDoc->SetValue(8, 3, srcSheet, 122);
1763 m_pDoc->SetValue(8, 4, srcSheet, 123);
1764 m_pDoc->SetValue(8, 5, srcSheet, 124);
1765 m_pDoc->SetValue(8, 6, srcSheet, 125);
1766 m_pDoc->SetValue(8, 7, srcSheet, 126);
1768 // Col J, not selected
1769 m_pDoc->SetValue(9, 2, srcSheet, 131);
1770 m_pDoc->SetValue(9, 3, srcSheet, 132);
1771 m_pDoc->SetValue(9, 4, srcSheet, 133);
1772 m_pDoc->SetValue(9, 5, srcSheet, 134);
1773 m_pDoc->SetValue(9, 6, srcSheet, 135);
1774 m_pDoc->SetValue(9, 7, srcSheet, 136);
1776 // row 16, refs to copied/cut range
1777 m_pDoc->SetString(1, 16, srcSheet, "=C5");
1778 m_pDoc->SetString(2, 16, srcSheet, "=$C$5");
1779 m_pDoc->SetString(3, 16, srcSheet, "=$C5");
1780 m_pDoc->SetString(4, 16, srcSheet, "=C$5");
1781 m_pDoc->SetString(5, 16, srcSheet, "=SUM(C5:C5)");
1782 m_pDoc->SetString(6, 16, srcSheet, "=SUM($C$5:$C$5)");
1783 m_pDoc->SetString(7, 16, srcSheet, "=SUM($C5:$C5)");
1784 m_pDoc->SetString(8, 16, srcSheet, "=SUM(C$5:C$5)");
1785 m_pDoc->SetString(9, 16, srcSheet, "=SUM($B$3:$B$6)");
1786 m_pDoc->SetString(10, 16, srcSheet, "=SUM($B$3:$B$10)");
1788 // Cell position is used for ranges relative to current position
1789 ScAddress cellC6(2, 5, srcSheet);
1790 ScAddress cellA1(0, 0, srcSheet);
1791 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C5", cellC6, "$SrcSheet.C5"));
1792 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5", cellA1, "$SrcSheet.$C$5"));
1793 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5", cellC6, "$SrcSheet.$C5"));
1794 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_Ca5", cellC6, "$SrcSheet.C$5"));
1795 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C5_C5", cellC6, "$SrcSheet.C5:C5"));
1796 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa5", cellA1, "$SrcSheet.$C$5:$C$5"));
1797 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5_aC5", cellC6, "$SrcSheet.$C5:$C5"));
1798 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5_aC5", cellC6, "$SrcSheet.$C5:$C5"));
1799 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_Ca5_Ca5", cellC6, "$SrcSheet.C$5:C$5"));
1800 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa8", cellA1, "$SrcSheet.$B$3:$B$6"));
1801 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa10", cellA1, "$SrcSheet.$B$3:$B$10"));
1803 // row 17, refs to copied/cut range using range
1804 m_pDoc->SetString(1, 17, srcSheet, "=Range_C5");
1805 m_pDoc->SetString(2, 17, srcSheet, "=Range_aCa5");
1806 m_pDoc->SetString(3, 17, srcSheet, "=Range_aC5");
1807 m_pDoc->SetString(4, 17, srcSheet, "=Range_Ca5");
1808 m_pDoc->SetString(5, 17, srcSheet, "=SUM(Range_C5_C5)");
1809 m_pDoc->SetString(6, 17, srcSheet, "=SUM(Range_aCa5_aCa5)");
1810 m_pDoc->SetString(7, 17, srcSheet, "=SUM(Range_aC5_aC5)");
1811 m_pDoc->SetString(8, 17, srcSheet, "=SUM(Range_Ca5_Ca5)");
1812 m_pDoc->SetString(9, 17, srcSheet, "=SUM(Range_aCa5_aCa8)");
1813 m_pDoc->SetString(10, 17, srcSheet, "=SUM(Range_aCa5_aCa10)");
1815 // add patterns
1816 ScPatternAttr aCellBlueColor(m_pDoc->GetPool());
1817 aCellBlueColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
1818 m_pDoc->ApplyPatternAreaTab(1, 2, 1, 4, srcSheet, aCellBlueColor);
1820 // Check pattern precondition
1821 m_pDoc->GetPattern(ScAddress(1, 2, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1822 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B3 has a pattern", pItem);
1823 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
1824 m_pDoc->GetPattern(ScAddress(1, 3, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1825 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B4 has a pattern", pItem);
1826 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
1827 m_pDoc->GetPattern(ScAddress(1, 5, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1828 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B6 has no pattern", !pItem);
1830 // row 2 on empty cell
1831 ScPatternAttr aCellGreenColor(m_pDoc->GetPool());
1832 aCellGreenColor.GetItemSet().Put(SvxBrushItem(COL_GREEN, ATTR_BACKGROUND));
1833 m_pDoc->ApplyPatternAreaTab(5, 4, 5, 4, srcSheet, aCellGreenColor);
1835 // row 4 for multi range row selection
1836 ScPatternAttr aCellRedColor(m_pDoc->GetPool());
1837 aCellRedColor.GetItemSet().Put(SvxBrushItem(COL_RED, ATTR_BACKGROUND));
1838 m_pDoc->ApplyPatternAreaTab(3, 6, 4, 6, srcSheet, aCellRedColor);
1840 // add borders
1841 ::editeng::SvxBorderLine aLine(nullptr, 50, SvxBorderLineStyle::SOLID);
1842 SvxBoxItem aBorderItem(ATTR_BORDER);
1843 aBorderItem.SetLine(&aLine, SvxBoxItemLine::LEFT);
1844 aBorderItem.SetLine(&aLine, SvxBoxItemLine::RIGHT);
1845 m_pDoc->ApplyAttr(2, 3, srcSheet, aBorderItem);
1846 m_pDoc->ApplyAttr(2, 4, srcSheet, aBorderItem);
1847 m_pDoc->ApplyAttr(2, 5, srcSheet, aBorderItem);
1848 // Check border precondition
1849 pItem = m_pDoc->GetAttr(ScAddress(2, 2, srcSheet), ATTR_BORDER);
1850 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B1 has a border", pItem);
1851 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1852 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
1853 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1854 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1855 pItem = m_pDoc->GetAttr(ScAddress(2, 3, srcSheet), ATTR_BORDER);
1856 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B2 has a border", pItem);
1857 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1858 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
1859 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1860 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1861 // Check border precondition 2
1862 m_pDoc->GetPattern(ScAddress(2, 3, srcSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
1863 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B2 has a border", pItem);
1864 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1865 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
1866 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1867 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1868 // row 4 for multi range row selection
1869 ::editeng::SvxBorderLine aDoubleLine(nullptr, 50, SvxBorderLineStyle::DOUBLE);
1870 SvxBoxItem aDoubleBorderItem(ATTR_BORDER);
1871 aDoubleBorderItem.SetLine(&aDoubleLine, SvxBoxItemLine::TOP);
1872 aDoubleBorderItem.SetLine(&aDoubleLine, SvxBoxItemLine::BOTTOM);
1873 m_pDoc->ApplyAttr(3, 6, srcSheet, aDoubleBorderItem);
1874 m_pDoc->ApplyAttr(4, 6, srcSheet, aDoubleBorderItem);
1876 // add notes to B3:F4
1878 // add notes row 2
1879 setNote(1, 2, srcSheet, "Note A1");
1880 setNote(2, 2, srcSheet, "Note B1");
1881 // No note on D3
1882 setNote(4, 2, srcSheet, "Note D1");
1883 // No note on F3
1884 // No note on G3
1886 // add notes row 3
1887 setNote(1, 3, srcSheet, "Note A2");
1888 // No note on C4
1889 setNote(3, 3, srcSheet, "Note C2");
1890 setNote(4, 3, srcSheet, "Note D2");
1891 setNote(5, 4, srcSheet, "Note E2");
1892 setNote(6, 3, srcSheet, "Note F2");
1894 // add notes row 4
1895 setNote(1, 4, srcSheet, "Note A3");
1896 setNote(2, 4, srcSheet, "Note B3");
1897 setNote(3, 4, srcSheet, "Note C3");
1898 setNote(4, 4, srcSheet, "Note D3");
1899 // No note on F5
1900 // No note on G5
1902 // add notes row 5
1903 // No note on B6
1904 setNote(2, 5, srcSheet, "Note B4");
1905 setNote(3, 5, srcSheet, "Note C4");
1906 setNote(4, 5, srcSheet, "Note D4");
1907 setNote(5, 5, srcSheet, "Note E4");
1908 setNote(6, 5, srcSheet, "Note F4");
1910 // row 6 for multi range row selection
1911 setNote(3, 6, srcSheet, "Note C5");
1913 // Recalc if needed
1914 if (bMultiRangeSelection && bTranspose && eDirection == ScClipParam::Row
1915 && eCalcMode == RecalcAtEnd)
1916 m_pDoc->CalcFormulaTree();
1917 else if (bMultiRangeSelection && bTranspose && eDirection == ScClipParam::Row
1918 && eCalcMode == HardRecalcAtEnd)
1919 m_pDoc->CalcAll();
1921 // Filter out row 3
1922 if (bApplyFilter)
1924 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, nStartCol, nStartRow,
1925 nStartCol + nSrcCols - 1, nStartRow + nSrcRows - 1);
1926 m_pDoc->SetAnonymousDBData(srcSheet, std::unique_ptr<ScDBData>(pDBData));
1928 pDBData->SetAutoFilter(true);
1929 ScRange aRange;
1930 pDBData->GetArea(aRange);
1931 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1932 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1934 //create the query param
1935 ScQueryParam aParam;
1936 pDBData->GetQueryParam(aParam);
1937 ScQueryEntry& rEntry = aParam.GetEntry(0);
1938 rEntry.bDoQuery = true;
1939 rEntry.nField = nStartCol;
1940 rEntry.eOp = SC_NOT_EQUAL;
1941 rEntry.GetQueryItem().mfVal = 2; // value of row B4 -> filtering row 3
1942 // add queryParam to database range.
1943 pDBData->SetQueryParam(aParam);
1945 // perform the query.
1946 m_pDoc->Query(srcSheet, aParam, true);
1948 // Check precondition for test: row 3 is hidden/filtered
1949 SCROW nRow1, nRow2;
1950 SCROW nFilteredRow1, nFilteredRow2;
1951 bool bHidden = m_pDoc->RowHidden(SCROW(3), srcSheet, &nRow1, &nRow2);
1952 CPPUNIT_ASSERT_MESSAGE("row 3 should be hidden", bHidden);
1953 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be hidden", SCROW(3), nRow1);
1954 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be hidden", SCROW(3), nRow2);
1955 bool bFiltered = m_pDoc->RowFiltered(SCROW(3), srcSheet, &nFilteredRow1, &nFilteredRow2);
1956 CPPUNIT_ASSERT_MESSAGE("row 3 should be filtered", bFiltered);
1957 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be filtered", SCROW(3), nFilteredRow1);
1958 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be filtered", SCROW(3), nFilteredRow2);
1961 // create destination sheet
1962 // const SCTAB destSheet = 1;
1963 for (int i = srcSheet + 1; i < destSheet; ++i)
1964 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
1966 if (srcSheet != destSheet)
1967 m_pDoc->InsertTab(destSheet, "DestSheet");
1969 m_pDoc->SetString(3, 101, srcSheet, "=DestSheet.D1");
1970 m_pDoc->SetString(3, 102, srcSheet, "=DestSheet.D2");
1971 m_pDoc->SetString(3, 103, srcSheet, "=DestSheet.D3");
1972 m_pDoc->SetString(3, 104, srcSheet, "=DestSheet.D4");
1973 m_pDoc->SetString(3, 105, srcSheet, "=DestSheet.D5");
1974 m_pDoc->SetString(3, 106, srcSheet, "=DestSheet.D6");
1975 m_pDoc->SetString(3, 107, srcSheet, "=DestSheet.D7");
1976 m_pDoc->SetString(4, 101, srcSheet, "=DestSheet.E1");
1977 m_pDoc->SetString(4, 102, srcSheet, "=DestSheet.E2");
1978 m_pDoc->SetString(4, 103, srcSheet, "=DestSheet.E3");
1979 m_pDoc->SetString(4, 104, srcSheet, "=DestSheet.E4");
1980 m_pDoc->SetString(4, 105, srcSheet, "=DestSheet.E5");
1981 m_pDoc->SetString(4, 106, srcSheet, "=DestSheet.E6");
1982 m_pDoc->SetString(4, 107, srcSheet, "=DestSheet.E7");
1983 m_pDoc->SetString(5, 101, srcSheet, "=DestSheet.F1");
1984 m_pDoc->SetString(5, 102, srcSheet, "=DestSheet.F2");
1985 m_pDoc->SetString(5, 103, srcSheet, "=DestSheet.F3");
1986 m_pDoc->SetString(5, 104, srcSheet, "=DestSheet.F4");
1987 m_pDoc->SetString(5, 105, srcSheet, "=DestSheet.F5");
1988 m_pDoc->SetString(5, 106, srcSheet, "=DestSheet.F6");
1989 m_pDoc->SetString(5, 107, srcSheet, "=DestSheet.F7");
1990 m_pDoc->SetString(6, 101, srcSheet, "=DestSheet.G1");
1991 m_pDoc->SetString(6, 102, srcSheet, "=DestSheet.G2");
1992 m_pDoc->SetString(6, 103, srcSheet, "=DestSheet.G3");
1993 m_pDoc->SetString(6, 104, srcSheet, "=DestSheet.G4");
1994 m_pDoc->SetString(6, 105, srcSheet, "=DestSheet.G5");
1995 m_pDoc->SetString(6, 106, srcSheet, "=DestSheet.G6");
1996 m_pDoc->SetString(6, 107, srcSheet, "=DestSheet.G7");
1997 m_pDoc->SetString(7, 101, srcSheet, "=DestSheet.H1");
1998 m_pDoc->SetString(7, 102, srcSheet, "=DestSheet.H2");
1999 m_pDoc->SetString(7, 103, srcSheet, "=DestSheet.H3");
2000 m_pDoc->SetString(7, 104, srcSheet, "=DestSheet.H4");
2001 m_pDoc->SetString(7, 105, srcSheet, "=DestSheet.H5");
2002 m_pDoc->SetString(7, 106, srcSheet, "=DestSheet.H6");
2003 m_pDoc->SetString(7, 107, srcSheet, "=DestSheet.H7");
2004 m_pDoc->SetString(8, 101, srcSheet, "=DestSheet.I1");
2005 m_pDoc->SetString(8, 102, srcSheet, "=DestSheet.I2");
2006 m_pDoc->SetString(8, 103, srcSheet, "=DestSheet.I3");
2007 m_pDoc->SetString(8, 104, srcSheet, "=DestSheet.I4");
2008 m_pDoc->SetString(8, 105, srcSheet, "=DestSheet.I5");
2009 m_pDoc->SetString(8, 106, srcSheet, "=DestSheet.I6");
2010 m_pDoc->SetString(8, 107, srcSheet, "=DestSheet.I7");
2011 m_pDoc->SetString(9, 101, srcSheet, "=DestSheet.J1");
2012 m_pDoc->SetString(9, 102, srcSheet, "=DestSheet.J2");
2013 m_pDoc->SetString(9, 103, srcSheet, "=DestSheet.J3");
2014 m_pDoc->SetString(9, 104, srcSheet, "=DestSheet.J4");
2015 m_pDoc->SetString(9, 105, srcSheet, "=DestSheet.J5");
2016 m_pDoc->SetString(9, 106, srcSheet, "=DestSheet.J6");
2017 m_pDoc->SetString(9, 107, srcSheet, "=DestSheet.J7");
2019 // Check precondition
2020 checkCopyPasteSpecialInitial(srcSheet);
2022 // set cells to 1000 to check empty cell behaviour and to detect destination range problems
2023 for (int i = 0; i < 10; ++i)
2024 for (int j = 0; j < 10; ++j)
2025 m_pDoc->SetValue(i, j, destSheet, 1000);
2027 // transpose clipboard, paste on DestSheet
2028 ScDocument aClipDoc(SCDOCMODE_CLIP);
2029 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
2030 ScRange aDestRange;
2032 ScDocumentUniquePtr pPasteUndoDoc;
2033 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
2034 std::unique_ptr<ScRefUndoData> pUndoData;
2036 if (!bMultiRangeSelection)
2038 ScRange aSrcRange(nStartCol, nStartRow, srcSheet, nStartCol + nSrcCols - 1,
2039 nStartRow + nSrcRows - 1, srcSheet);
2040 printRange(m_pDoc, aSrcRange, "Src range");
2041 if (!bCut)
2042 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
2043 else
2045 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, true));
2048 printRange(&aClipDoc,
2049 ScRange(nStartCol, nStartRow, srcSheet, nStartCol + nSrcCols,
2050 nStartRow + nSrcRows, srcSheet),
2051 "Base doc (&aClipDoc)");
2053 // ScDocument::TransposeClip() and ScDocument::CopyFromClip() calls
2054 // analog to ScViewFunc::PasteFromClip()
2055 if (bTranspose)
2057 ScDocument* pOrigClipDoc = &aClipDoc;
2058 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
2059 aClipDoc.TransposeClip(pTransClip.get(), aFlags, bAsLink, bIncludedFiltered);
2060 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcRows - 1, 1 + nSrcCols - 1,
2061 destSheet); //target: D2:F6
2062 aDestMark.SetMarkArea(aDestRange);
2063 printRange(pTransClip.get(), ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
2064 "Transposed clipdoc (pTransClip.get())");
2066 if (bCut)
2067 prepareUndoBeforePaste(bCut, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
2068 pUndoData);
2070 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
2071 pTransClip.get(), true, bAsLink, bIncludedFiltered, bSkipEmpty);
2072 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
2073 if (bCut)
2075 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark,
2076 pPasteRefUndoDoc.get());
2077 printRange(m_pDoc, aDestRange, "Transposed dest sheet after UpdateTranspose()");
2079 pTransClip.reset();
2081 else
2083 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcCols - 1, 1 + nSrcRows - 1,
2084 destSheet); //target: D2:I5
2085 aDestMark.SetMarkArea(aDestRange);
2086 if (bCut)
2087 prepareUndoBeforePaste(bCut, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
2088 pUndoData);
2090 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc,
2091 true, bAsLink, bIncludedFiltered, bSkipEmpty);
2092 printValuesAndFormulasInRange(m_pDoc, aDestRange, "Dest sheet");
2095 if (bCut)
2096 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
2097 pUndoPaste, bTranspose, bAsLink, bSkipEmpty);
2099 else // multi range selection
2101 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
2102 aSrcMark.SelectOneTable(0);
2103 ScClipParam aClipParam;
2104 aClipParam.meDirection = eDirection;
2105 if (eDirection == ScClipParam::Column)
2107 aClipParam.maRanges.push_back(ScRange(1, 2, srcSheet, 2, 5, srcSheet)); // B3:C6
2108 aClipParam.maRanges.push_back(ScRange(4, 2, srcSheet, 6, 5, srcSheet)); // E3:G6
2109 aClipParam.maRanges.push_back(ScRange(8, 2, srcSheet, 8, 5, srcSheet)); // I3:I6
2111 else if (eDirection == ScClipParam::Row)
2113 aClipParam.maRanges.push_back(ScRange(1, 2, srcSheet, 6, 4, srcSheet)); // B3:G5
2114 aClipParam.maRanges.push_back(ScRange(1, 6, srcSheet, 6, 6, srcSheet)); // B7:G7
2115 aClipParam.maRanges.push_back(ScRange(1, 8, srcSheet, 6, 8, srcSheet)); // A9:G9
2117 CPPUNIT_ASSERT(aClipParam.isMultiRange());
2118 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
2120 // ScDocument::TransposeClip() and ScDocument::CopyMultiRangeFromClip() calls
2121 // analog to ScViewFunc::PasteFromClipToMultiRanges()
2122 if (bTranspose)
2124 printRange(m_pDoc, aClipParam.getWholeRange(), "Src range");
2125 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
2126 aClipDoc.TransposeClip(pTransClip.get(), aFlags, bAsLink, bIncludedFiltered);
2127 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcRows - 1, 1 + nSrcCols - 1 - 1,
2128 destSheet); //target col: D2:G6, target row: D2:H6
2129 aDestMark.SetMarkArea(aDestRange);
2130 printRange(&aClipDoc, ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
2131 "Base doc (&aClipDoc)");
2132 printRange(pTransClip.get(), ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
2133 "Transposed clipdoc (pTransClip.get())");
2134 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 1, destSheet), aDestMark, aFlags,
2135 pTransClip.get(), true, bAsLink && !bTranspose,
2136 bIncludedFiltered, bSkipEmpty);
2137 pTransClip.reset();
2138 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
2140 else
2142 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcCols - 1 - 1, 1 + nSrcRows - 1,
2143 destSheet); //target col: D2:I5, target row: D2:I6
2144 aDestMark.SetMarkArea(aDestRange);
2145 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 1, destSheet), aDestMark, aFlags, &aClipDoc,
2146 true, bAsLink && !bTranspose, bIncludedFiltered,
2147 bSkipEmpty);
2151 if (eCalcMode == RecalcAtEnd)
2152 m_pDoc->CalcFormulaTree();
2153 else if (eCalcMode == HardRecalcAtEnd)
2154 m_pDoc->CalcAll();
2157 void TestCopyPaste::testCopyPasteSpecial()
2159 executeCopyPasteSpecial(false, false, false, false, false, false);
2160 checkCopyPasteSpecial(false);
2163 void TestCopyPaste::testCopyPasteSpecialFiltered()
2165 executeCopyPasteSpecial(true, false, false, false, false, false);
2166 checkCopyPasteSpecialFiltered(false);
2169 void TestCopyPaste::testCopyPasteSpecialIncludeFiltered()
2171 // For bIncludeFiltered=true, the non-filtered outcome is expected
2172 executeCopyPasteSpecial(false, true, false, false, false, false);
2173 checkCopyPasteSpecial(false);
2176 void TestCopyPaste::testCopyPasteSpecialFilteredIncludeFiltered()
2178 // For bIncludeFiltered=true, the non-filtered outcome is expected
2179 executeCopyPasteSpecial(true, true, false, false, false, false);
2180 checkCopyPasteSpecial(false);
2183 // similar to TestCopyPaste::testCopyPasteTranspose(), but this test is more complex
2184 void TestCopyPaste::testCopyPasteSpecialTranspose()
2186 executeCopyPasteSpecial(false, false, false, true, false, false);
2187 checkCopyPasteSpecialTranspose(false);
2190 // tdf#107348
2191 void TestCopyPaste::testCopyPasteSpecialFilteredTranspose()
2193 executeCopyPasteSpecial(true, false, false, true, false, false);
2194 checkCopyPasteSpecialFilteredTranspose(false);
2197 // tdf#107348
2198 void TestCopyPaste::testCopyPasteSpecialTransposeIncludeFiltered()
2200 // For bIncludeFiltered=true, the non-filtered outcome is expected
2201 executeCopyPasteSpecial(true, true, false, true, false, false);
2202 checkCopyPasteSpecialTranspose(false);
2205 void TestCopyPaste::testCopyPasteSpecialMultiRangeCol()
2207 executeCopyPasteSpecial(false, false, false, false, true, false, false, ScClipParam::Column);
2208 checkCopyPasteSpecialMultiRangeCol(false);
2211 void TestCopyPaste::testCopyPasteSpecialMultiRangeColIncludeFiltered()
2213 // For bIncludeFiltered=true, the non-filtered outcome is expected
2214 executeCopyPasteSpecial(false, true, false, false, true, false, false, ScClipParam::Column);
2215 checkCopyPasteSpecialMultiRangeCol(false);
2218 // tdf#45958
2219 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFiltered()
2221 executeCopyPasteSpecial(true, false, false, false, true, false, false, ScClipParam::Column);
2222 checkCopyPasteSpecialMultiRangeColFiltered(false);
2225 // tdf#45958
2226 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered()
2228 // For bIncludeFiltered=true, the non-filtered outcome is expected
2229 executeCopyPasteSpecial(true, true, false, false, true, false, false, ScClipParam::Column);
2230 checkCopyPasteSpecialMultiRangeCol(false);
2233 void TestCopyPaste::testCopyPasteSpecialMultiRangeColTranspose()
2235 executeCopyPasteSpecial(false, false, false, true, true, false, false, ScClipParam::Column);
2236 checkCopyPasteSpecialMultiRangeColTranspose(false);
2239 // tdf#45958, tdf#107348
2240 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFilteredTranspose()
2242 executeCopyPasteSpecial(true, false, false, true, true, false, false, ScClipParam::Column);
2243 checkCopyPasteSpecialMultiRangeColFilteredTranspose(false);
2246 // tdf#45958, tdf#107348
2247 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose()
2249 // For bIncludeFiltered=true, the non-filtered outcome is expected
2250 executeCopyPasteSpecial(true, true, false, true, true, false, false, ScClipParam::Column);
2251 checkCopyPasteSpecialMultiRangeColTranspose(false);
2254 void TestCopyPaste::testCopyPasteSpecialMultiRangeRow()
2256 executeCopyPasteSpecial(false, false, false, false, true, false, false, ScClipParam::Row);
2257 checkCopyPasteSpecialMultiRangeRow(false);
2260 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowIncludeFiltered()
2262 // For bIncludeFiltered=true, the non-filtered outcome is expected
2263 executeCopyPasteSpecial(false, true, false, false, true, false, false, ScClipParam::Row);
2264 checkCopyPasteSpecialMultiRangeRow(false);
2267 // tdf#45958
2268 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFiltered()
2270 executeCopyPasteSpecial(true, false, false, false, true, false, false, ScClipParam::Row);
2271 checkCopyPasteSpecialMultiRangeRowFiltered(false);
2274 // tdf#45958
2275 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered()
2277 // For bIncludeFiltered=true, the non-filtered outcome is expected
2278 executeCopyPasteSpecial(true, true, false, false, true, false, false, ScClipParam::Row);
2279 checkCopyPasteSpecialMultiRangeRow(false);
2282 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowTranspose()
2284 executeCopyPasteSpecial(false, false, false, true, true, false, false, ScClipParam::Row,
2285 HardRecalcAtEnd);
2286 checkCopyPasteSpecialMultiRangeRowTranspose(false);
2289 // tdf#45958, tdf#107348
2290 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFilteredTranspose()
2292 executeCopyPasteSpecial(true, false, false, true, true, false, false, ScClipParam::Row,
2293 HardRecalcAtEnd);
2294 checkCopyPasteSpecialMultiRangeRowFilteredTranspose(false);
2297 // tdf#45958, tdf#107348
2298 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose()
2300 // For bIncludeFiltered=true, the non-filtered outcome is expected
2301 executeCopyPasteSpecial(true, true, false, true, true, false, false, ScClipParam::Row,
2302 HardRecalcAtEnd);
2303 checkCopyPasteSpecialMultiRangeRowTranspose(false);
2306 void TestCopyPaste::testCopyPasteSpecialSkipEmpty()
2308 executeCopyPasteSpecial(false, false, false, false, false, true);
2309 checkCopyPasteSpecial(true);
2312 void TestCopyPaste::testCopyPasteSpecialSkipEmptyFiltered()
2314 executeCopyPasteSpecial(true, false, false, false, false, true);
2315 checkCopyPasteSpecialFiltered(true);
2318 void TestCopyPaste::testCopyPasteSpecialSkipEmptyIncludeFiltered()
2320 // For bIncludeFiltered=true, the non-filtered outcome is expected
2321 executeCopyPasteSpecial(false, true, false, false, false, true);
2322 checkCopyPasteSpecial(true);
2325 void TestCopyPaste::testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered()
2327 // For bIncludeFiltered=true, the non-filtered outcome is expected
2328 executeCopyPasteSpecial(true, true, false, false, false, true);
2329 checkCopyPasteSpecial(true);
2332 // similar to TestCopyPaste::testCopyPasteTranspose(), but this test is more complex
2333 void TestCopyPaste::testCopyPasteSpecialSkipEmptyTranspose()
2335 executeCopyPasteSpecial(false, false, false, true, false, true);
2336 checkCopyPasteSpecialTranspose(true);
2339 // tdf#107348
2340 void TestCopyPaste::testCopyPasteSpecialSkipEmptyFilteredTranspose()
2342 executeCopyPasteSpecial(true, false, false, true, false, true);
2343 checkCopyPasteSpecialFilteredTranspose(true);
2346 // tdf#107348
2347 void TestCopyPaste::testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered()
2349 // For bIncludeFiltered=true, the non-filtered outcome is expected
2350 executeCopyPasteSpecial(true, true, false, true, false, true);
2351 checkCopyPasteSpecialTranspose(true);
2354 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeCol()
2356 executeCopyPasteSpecial(false, false, false, false, true, true, false, ScClipParam::Column);
2357 checkCopyPasteSpecialMultiRangeCol(true);
2360 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered()
2362 // For bIncludeFiltered=true, the non-filtered outcome is expected
2363 executeCopyPasteSpecial(false, true, false, false, true, true, false, ScClipParam::Column);
2364 checkCopyPasteSpecialMultiRangeCol(true);
2367 // tdf#45958
2368 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFiltered()
2370 executeCopyPasteSpecial(true, false, false, false, true, true, false, ScClipParam::Column);
2371 checkCopyPasteSpecialMultiRangeColFiltered(true);
2374 // tdf#45958
2375 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered()
2377 // For bIncludeFiltered=true, the non-filtered outcome is expected
2378 executeCopyPasteSpecial(true, true, false, false, true, true, false, ScClipParam::Column);
2379 checkCopyPasteSpecialMultiRangeCol(true);
2382 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColTranspose()
2384 executeCopyPasteSpecial(false, false, false, true, true, true, false, ScClipParam::Column);
2385 checkCopyPasteSpecialMultiRangeColTranspose(true);
2388 // tdf#45958, tdf#107348
2389 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose()
2391 // For bIncludeFiltered=true, the non-filtered outcome is expected
2392 executeCopyPasteSpecial(true, false, false, true, true, true, false, ScClipParam::Column);
2393 checkCopyPasteSpecialMultiRangeColFilteredTranspose(true);
2396 // tdf#45958, tdf#107348
2397 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose()
2399 // For bIncludeFiltered=true, the non-filtered outcome is expected
2400 executeCopyPasteSpecial(true, true, false, true, true, true, false, ScClipParam::Column);
2401 checkCopyPasteSpecialMultiRangeColTranspose(true);
2404 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRow()
2406 executeCopyPasteSpecial(false, false, false, false, true, true, false, ScClipParam::Row);
2407 checkCopyPasteSpecialMultiRangeRow(true);
2410 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered()
2412 // For bIncludeFiltered=true, the non-filtered outcome is expected
2413 executeCopyPasteSpecial(false, true, false, false, true, true, false, ScClipParam::Row);
2414 checkCopyPasteSpecialMultiRangeRow(true);
2417 // tdf#45958
2418 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered()
2420 executeCopyPasteSpecial(true, false, false, false, true, true, false, ScClipParam::Row);
2421 checkCopyPasteSpecialMultiRangeRowFiltered(true);
2424 // tdf#45958
2425 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered()
2427 // For bIncludeFiltered=true, the non-filtered outcome is expected
2428 executeCopyPasteSpecial(true, true, false, false, true, true, false, ScClipParam::Row);
2429 checkCopyPasteSpecialMultiRangeRow(true);
2432 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose()
2434 executeCopyPasteSpecial(false, false, false, true, true, true, false, ScClipParam::Row,
2435 HardRecalcAtEnd);
2436 checkCopyPasteSpecialMultiRangeRowTranspose(true);
2439 // tdf#45958, tdf#107348
2440 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose()
2442 executeCopyPasteSpecial(true, false, false, true, true, true, false, ScClipParam::Row,
2443 HardRecalcAtEnd);
2444 checkCopyPasteSpecialMultiRangeRowFilteredTranspose(true);
2447 // tdf#45958, tdf#107348
2448 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose()
2450 // For bIncludeFiltered=true, the non-filtered outcome is expected
2451 executeCopyPasteSpecial(true, true, false, true, true, true, false, ScClipParam::Row,
2452 HardRecalcAtEnd);
2453 checkCopyPasteSpecialMultiRangeRowTranspose(true);
2456 void TestCopyPaste::testCutPasteSpecial()
2458 const SCTAB srcSheet = 0;
2459 const SCTAB destSheet = 1;
2460 std::unique_ptr<ScUndoCut> pUndoCut;
2461 std::unique_ptr<ScUndoPaste> pUndoPaste;
2463 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, false, false, false, pUndoCut,
2464 pUndoPaste, true);
2465 checkCopyPasteSpecial(false, true);
2467 pUndoPaste->Undo();
2468 pUndoCut->Undo();
2469 checkCopyPasteSpecialInitial(srcSheet);
2471 pUndoCut->Redo();
2472 pUndoPaste->Redo();
2473 checkCopyPasteSpecial(false, true);
2475 pUndoPaste->Undo();
2476 pUndoCut->Undo();
2477 checkCopyPasteSpecialInitial(srcSheet);
2479 pUndoPaste.reset();
2480 pUndoCut.reset();
2482 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2483 m_pDoc->DeleteTab(i - 1);
2486 void TestCopyPaste::testCutPasteSpecialTranspose()
2488 const SCTAB srcSheet = 0;
2489 const SCTAB destSheet = 1;
2490 std::unique_ptr<ScUndoCut> pUndoCut;
2491 std::unique_ptr<ScUndoPaste> pUndoPaste;
2493 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, true, false, false, pUndoCut,
2494 pUndoPaste, true);
2495 checkCopyPasteSpecialTranspose(false, true);
2497 pUndoPaste->Undo();
2498 pUndoCut->Undo();
2499 checkCopyPasteSpecialInitial(srcSheet);
2501 pUndoCut->Redo();
2502 pUndoPaste->Redo();
2503 checkCopyPasteSpecialTranspose(false, true);
2505 pUndoPaste->Undo();
2506 pUndoCut->Undo();
2507 checkCopyPasteSpecialInitial(srcSheet);
2509 pUndoPaste.reset();
2510 pUndoCut.reset();
2512 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2513 m_pDoc->DeleteTab(i - 1);
2516 void TestCopyPaste::testCutPasteSpecialSkipEmpty()
2518 const SCTAB srcSheet = 0;
2519 const SCTAB destSheet = 1;
2520 std::unique_ptr<ScUndoCut> pUndoCut;
2521 std::unique_ptr<ScUndoPaste> pUndoPaste;
2523 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, false, false, true, pUndoCut,
2524 pUndoPaste, true);
2525 checkCopyPasteSpecial(true, true);
2527 pUndoPaste->Undo();
2528 pUndoCut->Undo();
2529 checkCopyPasteSpecialInitial(srcSheet);
2531 pUndoCut->Redo();
2532 pUndoPaste->Redo();
2533 checkCopyPasteSpecial(true, true);
2535 pUndoPaste->Undo();
2536 pUndoCut->Undo();
2537 checkCopyPasteSpecialInitial(srcSheet);
2539 pUndoPaste.reset();
2540 pUndoCut.reset();
2542 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2543 m_pDoc->DeleteTab(i - 1);
2546 void TestCopyPaste::testCutPasteSpecialSkipEmptyTranspose()
2548 const SCTAB srcSheet = 0;
2549 const SCTAB destSheet = 1;
2550 std::unique_ptr<ScUndoCut> pUndoCut;
2551 std::unique_ptr<ScUndoPaste> pUndoPaste;
2553 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, true, false, true, pUndoCut,
2554 pUndoPaste, true);
2555 checkCopyPasteSpecialTranspose(true, true);
2557 pUndoPaste->Undo();
2558 pUndoCut->Undo();
2559 checkCopyPasteSpecialInitial(srcSheet);
2561 pUndoCut->Redo();
2562 pUndoPaste->Redo();
2563 checkCopyPasteSpecialTranspose(true, true);
2565 pUndoPaste->Undo();
2566 pUndoCut->Undo();
2567 checkCopyPasteSpecialInitial(srcSheet);
2569 pUndoPaste.reset();
2570 pUndoCut.reset();
2572 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2573 m_pDoc->DeleteTab(i - 1);
2576 // check initial source
2577 void TestCopyPaste::checkCopyPasteSpecialInitial(const SCTAB srcSheet)
2579 const EditTextObject* pEditObj;
2580 // col 1
2581 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 2, srcSheet));
2582 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 3, srcSheet));
2583 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1, 4, srcSheet));
2584 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(1, 5, srcSheet));
2585 // col 2, formulas
2586 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 2, srcSheet));
2587 CPPUNIT_ASSERT_EQUAL(OUString("=B3+10"), m_pDoc->GetFormula(2, 2, srcSheet));
2588 CPPUNIT_ASSERT_EQUAL(OUString("=B4+20"), m_pDoc->GetFormula(2, 3, srcSheet));
2589 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, srcSheet));
2590 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 4, srcSheet));
2591 CPPUNIT_ASSERT_EQUAL(OUString("=E5+30"), m_pDoc->GetFormula(2, 4, srcSheet));
2592 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(2, 5, srcSheet));
2593 CPPUNIT_ASSERT_EQUAL(OUString("=B4+40"), m_pDoc->GetFormula(2, 5, srcSheet));
2594 // col 3, strings
2595 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(3, 2, srcSheet));
2596 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(3, 3, srcSheet));
2597 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(3, 4, srcSheet));
2598 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(3, 5, srcSheet));
2599 // col 4, rich text
2600 pEditObj = m_pDoc->GetEditText(ScAddress(4, 2, srcSheet));
2601 CPPUNIT_ASSERT(pEditObj);
2602 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
2603 pEditObj = m_pDoc->GetEditText(ScAddress(4, 3, srcSheet));
2604 CPPUNIT_ASSERT(pEditObj);
2605 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
2606 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 4, srcSheet));
2607 pEditObj = m_pDoc->GetEditText(ScAddress(4, 5, srcSheet));
2608 CPPUNIT_ASSERT(pEditObj);
2609 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
2610 // col 5, formulas
2611 CPPUNIT_ASSERT_EQUAL(OUString("=B3+B5+60"), m_pDoc->GetFormula(5, 2, srcSheet));
2612 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(5, 2, srcSheet));
2613 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(5, 3, srcSheet));
2614 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(5, 4, srcSheet));
2615 CPPUNIT_ASSERT_EQUAL(OUString("=B3+B5+70"), m_pDoc->GetFormula(5, 5, srcSheet));
2616 CPPUNIT_ASSERT_EQUAL(74.0, m_pDoc->GetValue(5, 5, srcSheet));
2617 // col 6, formulas
2618 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(B3:B6;\"<4\")"), m_pDoc->GetFormula(6, 2, srcSheet));
2619 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(6, 2, srcSheet));
2620 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 3, srcSheet));
2621 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 4, srcSheet));
2622 CPPUNIT_ASSERT_EQUAL(OUString("=C$3+$B$5+80"), m_pDoc->GetFormula(6, 5, srcSheet));
2623 CPPUNIT_ASSERT_EQUAL(94.0, m_pDoc->GetValue(6, 5, srcSheet));
2625 // check patterns
2626 const SfxPoolItem* pItem = nullptr;
2627 m_pDoc->GetPattern(ScAddress(1, 2, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2628 CPPUNIT_ASSERT(pItem);
2629 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2630 m_pDoc->GetPattern(ScAddress(1, 3, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2631 CPPUNIT_ASSERT(pItem);
2632 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2633 m_pDoc->GetPattern(ScAddress(1, 4, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2634 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2635 m_pDoc->GetPattern(ScAddress(1, 5, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2636 CPPUNIT_ASSERT(!pItem);
2637 m_pDoc->GetPattern(ScAddress(1, 6, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2638 CPPUNIT_ASSERT(!pItem);
2639 m_pDoc->GetPattern(ScAddress(5, 4, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2640 CPPUNIT_ASSERT(pItem);
2641 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2643 // check border, left and right borders were transformed to top and bottom borders
2644 pItem = m_pDoc->GetAttr(ScAddress(2, 2, srcSheet), ATTR_BORDER);
2645 CPPUNIT_ASSERT(pItem);
2646 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2647 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2648 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2649 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2650 pItem = m_pDoc->GetAttr(ScAddress(2, 3, srcSheet), ATTR_BORDER);
2651 CPPUNIT_ASSERT(pItem);
2652 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2653 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2654 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2655 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2656 pItem = m_pDoc->GetAttr(ScAddress(2, 4, srcSheet), ATTR_BORDER);
2657 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2658 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2659 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2660 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2661 pItem = m_pDoc->GetAttr(ScAddress(2, 5, srcSheet), ATTR_BORDER);
2662 CPPUNIT_ASSERT(pItem);
2663 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2664 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2665 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2666 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2667 pItem = m_pDoc->GetAttr(ScAddress(2, 6, srcSheet), ATTR_BORDER);
2668 CPPUNIT_ASSERT(pItem);
2669 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2670 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2671 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2672 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2674 // check notes after transposed copy/paste
2675 // check presence of notes
2676 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 2, srcSheet));
2677 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 2, srcSheet));
2678 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 2, srcSheet));
2679 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, srcSheet));
2680 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 2, srcSheet));
2681 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, srcSheet));
2682 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, srcSheet));
2683 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 3, srcSheet));
2684 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, srcSheet));
2685 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, srcSheet));
2686 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, srcSheet));
2687 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 3, srcSheet));
2688 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, srcSheet));
2689 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, srcSheet));
2690 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 4, srcSheet));
2691 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 4, srcSheet));
2692 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 4, srcSheet));
2693 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, srcSheet));
2694 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, srcSheet));
2695 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, srcSheet));
2696 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, srcSheet));
2697 CPPUNIT_ASSERT(!m_pDoc->HasNote(1, 5, srcSheet));
2698 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 5, srcSheet));
2699 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 5, srcSheet));
2700 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 5, srcSheet));
2701 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 5, srcSheet));
2702 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 5, srcSheet));
2703 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, srcSheet));
2704 CPPUNIT_ASSERT(!m_pDoc->HasNote(1, 6, srcSheet));
2705 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, srcSheet));
2706 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 6, srcSheet));
2707 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, srcSheet));
2708 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, srcSheet));
2709 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, srcSheet));
2710 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 6, srcSheet));
2712 // check values of notes
2713 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(1, 2, srcSheet));
2714 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(1, 3, srcSheet));
2715 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(1, 4, srcSheet));
2716 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(2, 2, srcSheet));
2717 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(2, 4, srcSheet));
2718 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(3, 3, srcSheet));
2719 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(3, 4, srcSheet));
2720 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(4, 2, srcSheet));
2721 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(4, 3, srcSheet));
2722 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(4, 4, srcSheet));
2723 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 4, srcSheet));
2724 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(5, 5, srcSheet));
2725 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(6, 3, srcSheet));
2726 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(6, 5, srcSheet));
2728 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
2729 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
2730 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
2731 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
2732 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
2733 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
2734 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
2735 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
2736 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
2737 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
2739 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
2740 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
2741 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
2742 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
2743 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
2744 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
2745 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
2746 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
2747 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
2748 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
2750 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
2751 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
2752 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
2753 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
2754 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
2755 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
2756 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
2757 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
2758 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
2759 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
2761 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
2762 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
2763 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
2764 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
2765 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
2766 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
2767 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
2768 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
2769 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
2770 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
2772 // Existing references to the destination range must not change
2773 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
2774 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
2775 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
2776 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
2777 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
2778 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
2779 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
2780 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
2781 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
2782 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
2783 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
2784 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
2785 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
2786 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
2787 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
2788 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
2789 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
2790 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
2791 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
2792 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
2793 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
2794 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
2795 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
2796 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
2797 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
2798 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
2799 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
2800 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
2801 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
2802 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
2803 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
2804 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
2805 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
2806 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
2807 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
2808 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
2809 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
2810 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
2811 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
2812 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
2813 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
2814 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
2815 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
2816 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
2817 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
2818 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
2819 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
2820 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
2821 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
2824 // Base check, nothing filtered, nothing transposed
2825 void TestCopyPaste::checkCopyPasteSpecial(bool bSkipEmpty, bool bCut)
2827 const SCTAB srcSheet = 0;
2828 const SCTAB destSheet = 1;
2831 | D | E | F | G | H | I |
2833 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
2834 3 | 2 B*| =D3+20 b | b *| R2 *| | *|
2835 4 | 3 B*| =G4+30 b*| c *| 5 *| B*| |
2836 5 | 4 | =D3+40 b*| d *| R4 *| =D2+D4+70 *| =E$3+$B$5+80 *|
2838 * means note attached
2839 B means background
2840 b means border
2843 const EditTextObject* pEditObj;
2844 // col 2
2845 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
2846 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
2847 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
2848 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
2849 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
2850 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
2851 // col 3, numbers
2852 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
2853 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
2854 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
2855 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
2856 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 4, destSheet));
2857 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
2858 // col 4, formulas
2859 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
2860 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
2861 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
2862 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), m_pDoc->GetFormula(4, 2, destSheet));
2863 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
2864 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 3, destSheet));
2865 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), m_pDoc->GetFormula(4, 3, destSheet));
2866 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(4, 4, destSheet));
2867 CPPUNIT_ASSERT_EQUAL(OUString("=D3+40"), m_pDoc->GetFormula(4, 4, destSheet));
2868 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
2869 // col 5, strings
2870 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
2871 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
2872 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
2873 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(5, 2, destSheet));
2874 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 3, destSheet));
2875 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(5, 4, destSheet));
2876 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
2877 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 5, destSheet));
2878 // col 6, rich text
2879 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
2880 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
2881 CPPUNIT_ASSERT(pEditObj == nullptr);
2882 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
2883 CPPUNIT_ASSERT(pEditObj);
2884 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
2885 pEditObj = m_pDoc->GetEditText(ScAddress(6, 2, destSheet));
2886 CPPUNIT_ASSERT(pEditObj);
2887 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
2888 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 3, destSheet));
2889 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
2890 CPPUNIT_ASSERT(pEditObj);
2891 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
2892 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
2893 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
2894 CPPUNIT_ASSERT(pEditObj == nullptr);
2895 // col 7, formulas
2896 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
2897 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
2898 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
2899 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(7, 1, destSheet));
2900 if (!bSkipEmpty)
2902 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
2903 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
2905 else
2907 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
2908 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
2910 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+70"), m_pDoc->GetFormula(7, 4, destSheet));
2911 CPPUNIT_ASSERT_EQUAL(74.0, m_pDoc->GetValue(7, 4, destSheet));
2912 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
2913 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
2914 // col 8, formulas
2915 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
2916 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
2917 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
2918 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
2919 if (!bSkipEmpty)
2921 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
2922 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 3, destSheet));
2924 else
2926 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
2927 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
2929 double fValue = m_pDoc->GetValue(8, 4, destSheet);
2930 OUString aStr = m_pDoc->GetFormula(8, 4, destSheet);
2931 if (!bCut)
2933 CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), aStr);
2934 CPPUNIT_ASSERT_EQUAL(1102.0, fValue);
2936 else
2938 CPPUNIT_ASSERT_EQUAL(OUString("=E$2+$D$4+80"), aStr);
2939 CPPUNIT_ASSERT_EQUAL(94.0, fValue);
2941 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
2942 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
2943 // col 9, numbers
2944 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
2945 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
2946 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
2947 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
2948 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
2949 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
2951 // check patterns
2952 const SfxPoolItem* pItem = nullptr;
2953 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2954 CPPUNIT_ASSERT(pItem);
2955 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2956 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2957 CPPUNIT_ASSERT(pItem);
2958 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2959 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2960 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2961 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2962 CPPUNIT_ASSERT(!pItem);
2963 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2964 CPPUNIT_ASSERT(!pItem);
2965 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2966 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
2967 if (!bSkipEmpty)
2968 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2970 // check border, left and right borders were transformed to top and bottom borders
2971 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
2972 CPPUNIT_ASSERT(pItem);
2973 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2974 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2975 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2976 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2977 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
2978 CPPUNIT_ASSERT(pItem);
2979 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2980 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2981 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2982 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2983 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
2984 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2985 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2986 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2987 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2988 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
2989 CPPUNIT_ASSERT(pItem);
2990 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2991 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2992 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2993 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2994 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
2995 CPPUNIT_ASSERT(pItem);
2996 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2997 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2998 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2999 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3001 // check notes after transposed copy/paste
3002 // check presence of notes
3003 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
3004 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
3005 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
3006 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
3007 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
3008 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
3009 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
3010 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
3011 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
3012 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
3013 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
3014 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
3015 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
3016 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
3017 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
3018 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
3019 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
3020 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
3021 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
3022 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
3023 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
3024 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
3025 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(8, 2, destSheet));
3026 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
3027 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
3028 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
3029 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
3030 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
3031 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
3032 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 3, destSheet));
3033 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
3034 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
3035 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
3036 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
3037 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
3038 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
3039 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
3040 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 4, destSheet));
3041 CPPUNIT_ASSERT(m_pDoc->HasNote(8, 4, destSheet));
3042 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
3043 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
3044 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
3045 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
3046 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
3047 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
3048 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
3049 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
3050 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
3052 // check values of notes
3053 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
3054 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
3055 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
3056 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
3057 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
3058 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(5, 2, destSheet));
3059 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 3, destSheet));
3060 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
3061 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(6, 2, destSheet));
3062 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 3, destSheet));
3063 if (!bSkipEmpty)
3064 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 3, destSheet));
3065 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(7, 4, destSheet));
3066 if (!bSkipEmpty)
3067 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(8, 2, destSheet));
3068 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(8, 4, destSheet));
3070 // Existing references to the destination range must not change
3071 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
3072 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
3073 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
3074 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
3075 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
3076 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
3077 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
3078 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
3079 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
3080 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
3081 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
3082 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
3083 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
3084 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
3085 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
3086 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
3087 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
3088 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
3089 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
3090 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
3091 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
3092 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
3093 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
3094 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
3095 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
3096 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
3097 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
3098 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
3099 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
3100 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
3101 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
3102 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
3103 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
3104 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
3105 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
3106 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
3107 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
3108 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
3109 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
3110 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
3111 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
3112 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
3113 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
3114 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
3115 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
3116 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
3117 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
3118 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
3119 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
3121 // row 14 on src sheet, refs to copied/cut range
3122 if (!bCut)
3124 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
3125 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
3126 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
3127 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
3128 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
3129 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
3130 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
3131 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
3132 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
3133 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
3135 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3136 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3137 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3138 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3139 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3140 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3141 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3142 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3143 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3144 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
3146 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3147 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3148 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3149 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3150 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3151 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3152 m_pDoc->GetFormula(6, 17, srcSheet));
3153 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3154 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3155 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3156 m_pDoc->GetFormula(9, 17, srcSheet));
3157 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3158 m_pDoc->GetFormula(10, 17, srcSheet));
3160 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3161 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3162 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3163 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
3164 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3165 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3166 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3167 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3168 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3169 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
3171 m_pDoc->DeleteTab(destSheet);
3172 m_pDoc->DeleteTab(srcSheet);
3174 else
3176 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(1, 16, srcSheet));
3177 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$E$4"), m_pDoc->GetFormula(2, 16, srcSheet));
3178 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$E4"), m_pDoc->GetFormula(3, 16, srcSheet));
3179 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E$4"), m_pDoc->GetFormula(4, 16, srcSheet));
3180 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.E4:E4)"),
3181 m_pDoc->GetFormula(5, 16, srcSheet));
3182 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$E$4:$E$4)"),
3183 m_pDoc->GetFormula(6, 16, srcSheet));
3184 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$E4:$E4)"),
3185 m_pDoc->GetFormula(7, 16, srcSheet));
3186 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.E$4:E$4)"),
3187 m_pDoc->GetFormula(8, 16, srcSheet));
3188 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$D$2:$D$5)"),
3189 m_pDoc->GetFormula(9, 16, srcSheet));
3190 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
3192 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3193 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3194 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3195 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3196 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3197 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3198 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3199 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3200 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3201 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 16, srcSheet));
3203 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3204 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3205 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3206 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3207 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3208 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3209 m_pDoc->GetFormula(6, 17, srcSheet));
3210 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3211 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3212 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3213 m_pDoc->GetFormula(9, 17, srcSheet));
3214 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3215 m_pDoc->GetFormula(10, 17, srcSheet));
3217 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3218 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3219 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3220 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(4, 17, srcSheet));
3221 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3222 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3223 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3224 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3225 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3226 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 17, srcSheet));
3230 void TestCopyPaste::checkCopyPasteSpecialFiltered(bool bSkipEmpty)
3232 const SCTAB srcSheet = 0;
3233 const SCTAB destSheet = 1;
3236 | D | E | F | G | H | I |
3238 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
3239 3 | 3 B*| =G3+30 b*| c *| 5 *| B*| |
3240 4 | 4 | =D2+40 b*| d *| R4 *| =D1+D3+70 *| =E$3+$B$5+80 *|
3241 5 | 1 B*| =D5+10 *| a | R1 *| =D5+D7+60 | =SUMIF(D5:D8;"<4") | <- repeated row
3243 * means note attached
3244 B means background
3245 b means border
3248 const EditTextObject* pEditObj;
3250 // col 2
3251 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3252 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3253 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3254 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3255 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3256 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3257 // col 3, numbers
3258 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3259 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
3260 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
3261 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 3, destSheet));
3262 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 4, destSheet)); // repeated row 1
3263 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
3264 // col 4, formulas
3265 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3266 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 0, destSheet));
3267 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
3268 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
3269 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), m_pDoc->GetFormula(4, 2, destSheet));
3270 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 2, destSheet));
3271 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), m_pDoc->GetFormula(4, 3, destSheet));
3272 CPPUNIT_ASSERT_EQUAL(41.0, m_pDoc->GetValue(4, 3, destSheet));
3273 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 4, destSheet)); // repeated row 1
3274 CPPUNIT_ASSERT_EQUAL(OUString("=D5+10"), m_pDoc->GetFormula(4, 4, destSheet));
3275 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 4, destSheet));
3276 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3277 // col 5, strings
3278 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3279 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
3280 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 2, destSheet));
3281 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(5, 3, destSheet));
3282 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 4, destSheet)); // repeated row 1
3283 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
3284 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 5, destSheet));
3285 // col 6, rich text
3286 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3287 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
3288 CPPUNIT_ASSERT(pEditObj == nullptr);
3289 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
3290 CPPUNIT_ASSERT(pEditObj);
3291 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
3292 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 2, destSheet));
3293 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
3294 CPPUNIT_ASSERT(pEditObj);
3295 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
3296 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet)); // repeated row 1
3297 CPPUNIT_ASSERT(pEditObj);
3298 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
3299 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
3300 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
3301 CPPUNIT_ASSERT(pEditObj == nullptr);
3302 // col 7, formulas
3303 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3304 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
3305 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
3306 // formula is not adjusted due to filter row
3307 CPPUNIT_ASSERT_EQUAL(65.0, m_pDoc->GetValue(7, 1, destSheet));
3308 if (!bSkipEmpty)
3309 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
3310 else
3311 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3312 CPPUNIT_ASSERT_EQUAL(OUString("=D1+D3+70"), m_pDoc->GetFormula(7, 3, destSheet));
3313 CPPUNIT_ASSERT_EQUAL(1073.0, m_pDoc->GetValue(7, 3, destSheet));
3314 CPPUNIT_ASSERT_EQUAL(OUString("=D5+D7+60"),
3315 m_pDoc->GetFormula(7, 4, destSheet)); // repeated row 1
3316 // formula is not adjusted due to filter row
3317 CPPUNIT_ASSERT_EQUAL(1061.0, m_pDoc->GetValue(7, 4, destSheet));
3318 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3319 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3320 // col 8, formulas
3321 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
3322 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
3323 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
3324 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(8, 1, destSheet));
3325 if (!bSkipEmpty)
3326 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
3327 else
3328 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
3329 CPPUNIT_ASSERT_EQUAL(1115.0, m_pDoc->GetValue(8, 3, destSheet));
3330 CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), m_pDoc->GetFormula(8, 3, destSheet));
3331 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D5:D8;\"<4\")"), m_pDoc->GetFormula(8, 4, destSheet));
3332 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(8, 4, destSheet));
3333 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
3334 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
3335 // col 9, numbers
3336 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
3337 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
3338 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
3339 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
3340 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
3341 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
3343 // check patterns
3344 const SfxPoolItem* pItem = nullptr;
3345 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3346 CPPUNIT_ASSERT(pItem);
3347 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3348 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3349 CPPUNIT_ASSERT(pItem);
3350 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3351 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3352 CPPUNIT_ASSERT(!pItem);
3353 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3354 CPPUNIT_ASSERT(pItem);
3355 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3356 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3357 CPPUNIT_ASSERT(!pItem);
3358 m_pDoc->GetPattern(ScAddress(7, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3359 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3360 if (!bSkipEmpty)
3361 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3363 // check border, left and right borders were transformed to top and bottom borders
3364 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
3365 CPPUNIT_ASSERT(pItem);
3366 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3367 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3368 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3369 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3370 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3371 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3372 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3373 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3374 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
3375 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
3376 CPPUNIT_ASSERT(pItem);
3377 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3378 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3379 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3380 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
3381 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
3382 CPPUNIT_ASSERT(pItem);
3383 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3384 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3385 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3386 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3388 // check notes after transposed copy/paste
3389 // check presence of notes
3390 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
3391 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
3392 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
3393 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
3394 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
3395 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
3396 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
3397 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
3398 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
3399 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
3400 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
3401 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
3402 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
3403 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
3404 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
3405 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
3406 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
3407 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
3408 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
3409 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
3410 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
3411 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
3412 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
3413 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
3414 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
3415 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
3416 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
3417 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
3418 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
3419 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 3, destSheet));
3420 CPPUNIT_ASSERT(m_pDoc->HasNote(8, 3, destSheet));
3421 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
3422 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
3423 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 4, destSheet));
3424 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
3425 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
3426 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
3427 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
3428 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
3429 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
3430 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
3431 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
3432 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
3433 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
3434 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
3435 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
3436 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
3437 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
3439 // check values of notes
3440 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
3441 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
3442 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
3443 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
3444 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 2, destSheet));
3445 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
3446 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 2, destSheet));
3447 if (!bSkipEmpty)
3448 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 2, destSheet));
3449 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(7, 3, destSheet));
3450 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(8, 3, destSheet));
3452 m_pDoc->DeleteTab(destSheet);
3453 m_pDoc->DeleteTab(srcSheet);
3456 void TestCopyPaste::checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut)
3458 const SCTAB srcSheet = 0;
3459 const SCTAB destSheet = 1;
3462 | D | E | F | G |
3464 2 | 1 B*| 2 B*| 3 B*| 4 |
3465 3 | =D2+10 *| =E2+20 b | =F5+30 b*| =E2+40 b*|
3466 4 | a | b *| c *| d *|
3467 5 | R1 *| R2 *| 5 *| R4 *|
3468 6 | =D2+F2+60 | | B*| =D2+F2+70 *|
3469 7 | =SUMIF(D2:G2;"<4") | *| | =C$3+$B$5+80 *|
3471 * means note attached
3472 B means background
3473 b means border
3476 //check cell content after transposed copy/paste of filtered data
3477 // Note: column F is a repetition of srcSheet.Column A
3478 // Col C and G are checked to be empty
3479 const EditTextObject* pEditObj;
3480 // row 0
3481 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3482 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3483 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3484 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3485 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3486 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3487 // row 1, numbers
3488 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3489 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
3490 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 2.0, m_pDoc->GetValue(4, 1, destSheet));
3491 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 3.0, m_pDoc->GetValue(5, 1, destSheet));
3492 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2", 4.0, m_pDoc->GetValue(6, 1, destSheet));
3493 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
3494 // row 2, formulas
3495 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3496 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
3497 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
3498 m_pDoc->GetFormula(3, 2, destSheet));
3499 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
3500 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E2+20"),
3501 m_pDoc->GetFormula(4, 2, destSheet));
3502 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 22.0, m_pDoc->GetValue(4, 2, destSheet));
3503 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=F5+30"),
3504 m_pDoc->GetFormula(5, 2, destSheet));
3505 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 35.0, m_pDoc->GetValue(5, 2, destSheet));
3506 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3", OUString("=E2+40"),
3507 m_pDoc->GetFormula(6, 2, destSheet));
3508 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3", 42.0, m_pDoc->GetValue(6, 2, destSheet));
3509 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3510 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
3511 // row 3, strings
3512 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3513 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
3514 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
3515 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("b"), m_pDoc->GetString(4, 3, destSheet));
3516 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("c"), m_pDoc->GetString(5, 3, destSheet));
3517 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("d"), m_pDoc->GetString(6, 3, destSheet));
3518 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
3519 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
3520 // row 4, rich text
3521 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3522 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
3523 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
3524 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
3525 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
3526 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
3527 pEditObj->GetText(0));
3528 pEditObj = m_pDoc->GetEditText(ScAddress(4, 4, destSheet));
3529 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in E5.", pEditObj);
3530 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong E5.", OUString("R2"), pEditObj->GetText(0));
3531 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F5", 5.0, m_pDoc->GetValue(5, 4, destSheet));
3532 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
3533 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in G5.", pEditObj);
3534 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong G5.", OUString("R4"), pEditObj->GetText(0));
3535 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
3536 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
3537 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
3538 // row 5, formulas
3539 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3540 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
3541 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
3542 m_pDoc->GetFormula(3, 5, destSheet));
3543 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 64.0, m_pDoc->GetValue(3, 5, destSheet));
3544 if (!bSkipEmpty)
3546 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
3547 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
3549 else
3551 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3552 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
3554 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6", OUString("=D2+F2+70"),
3555 m_pDoc->GetFormula(6, 5, destSheet));
3556 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6", 74.0, m_pDoc->GetValue(6, 5, destSheet));
3557 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3558 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3559 // row 6, formulas
3560 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
3561 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
3562 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
3563 m_pDoc->GetFormula(3, 6, destSheet));
3564 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 6.0, m_pDoc->GetValue(3, 6, destSheet));
3565 if (!bSkipEmpty)
3567 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
3568 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 6, destSheet));
3570 else
3572 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
3573 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
3575 double fValue = m_pDoc->GetValue(6, 6, destSheet); // G7
3576 OUString aStr = m_pDoc->GetFormula(6, 6, destSheet); // G7
3577 if (!bCut)
3579 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", OUString("=C$3+$B$5+80"), aStr);
3580 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", 2080.0, fValue);
3582 else
3584 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$F$2+80"), aStr);
3585 CPPUNIT_ASSERT_EQUAL(94.0, fValue);
3587 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
3588 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
3589 // row 7
3590 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
3591 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
3592 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
3593 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
3594 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
3595 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
3597 // check patterns
3598 const SfxPoolItem* pItem = nullptr;
3599 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3600 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
3601 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
3602 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3603 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3604 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
3605 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has blue background", COL_BLUE,
3606 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3607 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3608 CPPUNIT_ASSERT_MESSAGE("F2 has a pattern", pItem);
3609 CPPUNIT_ASSERT_EQUAL_MESSAGE("F2 has a pattern", COL_BLUE,
3610 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3611 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3612 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
3613 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3614 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
3615 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3616 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3617 if (!bSkipEmpty)
3618 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3620 // check border, left and right borders were transformed to top and bottom borders
3621 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
3622 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
3623 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
3624 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3625 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
3626 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3627 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
3628 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3629 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
3630 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3632 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
3633 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3634 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3636 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3637 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3638 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3640 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
3641 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3642 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
3643 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3644 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
3645 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3646 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
3647 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
3648 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3649 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
3650 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3651 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
3652 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3653 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
3654 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3655 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
3656 CPPUNIT_ASSERT_MESSAGE("G3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3657 CPPUNIT_ASSERT_MESSAGE("G3 has bottom border",
3658 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3659 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
3660 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3661 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
3662 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3663 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
3664 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
3665 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
3666 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3667 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
3668 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3669 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
3670 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3671 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
3672 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3674 // check notes after transposed copy/paste
3675 // check presence of notes
3676 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
3677 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
3678 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
3679 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
3680 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
3681 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
3682 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
3683 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
3684 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
3685 CPPUNIT_ASSERT_MESSAGE("F2: a note", m_pDoc->HasNote(5, 1, destSheet));
3686 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
3687 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
3688 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
3689 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
3690 CPPUNIT_ASSERT_MESSAGE("E3: no note", !m_pDoc->HasNote(4, 2, destSheet));
3691 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
3692 CPPUNIT_ASSERT_MESSAGE("G3: a note", m_pDoc->HasNote(6, 2, destSheet));
3693 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
3694 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
3695 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
3696 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
3697 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
3698 CPPUNIT_ASSERT_MESSAGE("G4: a note", m_pDoc->HasNote(6, 3, destSheet));
3699 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
3700 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
3701 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
3702 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
3703 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
3704 CPPUNIT_ASSERT_MESSAGE("G5: a note", m_pDoc->HasNote(6, 4, destSheet));
3705 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
3706 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
3707 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
3708 CPPUNIT_ASSERT_MESSAGE("E6: no note", !m_pDoc->HasNote(4, 5, destSheet));
3709 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 5, destSheet));
3710 CPPUNIT_ASSERT_MESSAGE("G6: a note", m_pDoc->HasNote(6, 5, destSheet));
3711 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
3712 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
3713 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
3714 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 6, destSheet));
3715 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
3716 CPPUNIT_ASSERT_MESSAGE("G7: a note", m_pDoc->HasNote(6, 6, destSheet));
3717 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
3718 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
3719 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
3720 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
3721 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
3722 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
3723 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
3725 // check values of notes
3726 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
3727 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A2"), getNote(4, 1, destSheet));
3728 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F2", OUString("Note A3"), getNote(5, 1, destSheet));
3729 // G2 has no note
3730 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
3731 // E3 has no note
3732 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B3"), getNote(5, 2, destSheet));
3733 // D4 has no note
3734 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C2"), getNote(4, 3, destSheet));
3735 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C3"), getNote(5, 3, destSheet));
3736 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
3737 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D2"), getNote(4, 4, destSheet));
3738 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D3"), getNote(5, 4, destSheet));
3739 if (!bSkipEmpty)
3740 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 5, destSheet));
3741 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G6", OUString("Note E4"), getNote(6, 5, destSheet));
3742 if (!bSkipEmpty)
3743 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString("Note F2"), getNote(4, 6, destSheet));
3744 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G7", OUString("Note F4"), getNote(6, 6, destSheet));
3746 // row 14 on src sheet, refs to copied/cut range
3747 if (!bCut)
3749 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
3750 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
3751 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
3752 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
3753 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
3754 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
3755 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
3756 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
3757 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
3758 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
3760 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3761 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3762 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3763 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3764 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3765 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3766 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3767 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3768 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3769 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
3771 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3772 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3773 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3774 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3775 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3776 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3777 m_pDoc->GetFormula(6, 17, srcSheet));
3778 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3779 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3780 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3781 m_pDoc->GetFormula(9, 17, srcSheet));
3782 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3783 m_pDoc->GetFormula(10, 17, srcSheet));
3785 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3786 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3787 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3788 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
3789 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3790 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3791 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3792 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3793 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3794 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
3796 // Existing references to the destination range must not change
3797 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
3798 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
3799 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
3800 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
3801 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
3802 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
3803 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
3804 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
3805 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
3806 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
3807 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
3808 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
3809 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
3810 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
3811 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
3812 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
3813 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
3814 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
3815 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
3816 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
3817 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
3818 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
3819 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
3820 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
3821 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
3822 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
3823 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
3824 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
3825 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
3826 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
3827 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
3828 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
3829 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
3830 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
3831 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
3832 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
3833 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
3834 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
3835 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
3836 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
3837 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
3838 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
3839 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
3840 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
3841 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
3842 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
3843 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
3844 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
3845 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
3847 m_pDoc->DeleteTab(destSheet);
3848 m_pDoc->DeleteTab(srcSheet);
3850 else
3852 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(1, 16, srcSheet));
3853 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$F$3"), m_pDoc->GetFormula(2, 16, srcSheet));
3854 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$F3"), m_pDoc->GetFormula(3, 16, srcSheet));
3855 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F$3"), m_pDoc->GetFormula(4, 16, srcSheet));
3856 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.F3:F3)"),
3857 m_pDoc->GetFormula(5, 16, srcSheet));
3858 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$F$3:$F$3)"),
3859 m_pDoc->GetFormula(6, 16, srcSheet));
3860 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$F3:$F3)"),
3861 m_pDoc->GetFormula(7, 16, srcSheet));
3862 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.F$3:F$3)"),
3863 m_pDoc->GetFormula(8, 16, srcSheet));
3864 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$D$2:$G$2)"),
3865 m_pDoc->GetFormula(9, 16, srcSheet));
3866 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
3868 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3869 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3870 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3871 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3872 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3873 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3874 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3875 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3876 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3877 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 16, srcSheet));
3879 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3880 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3881 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3882 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3883 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3884 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3885 m_pDoc->GetFormula(6, 17, srcSheet));
3886 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3887 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3888 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3889 m_pDoc->GetFormula(9, 17, srcSheet));
3890 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3891 m_pDoc->GetFormula(10, 17, srcSheet));
3893 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3894 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3895 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3896 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(4, 17, srcSheet));
3897 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3898 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3899 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3900 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3901 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3902 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 17, srcSheet));
3904 // Existing references to the destination range must not change
3905 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
3906 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
3907 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
3908 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
3909 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
3910 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
3911 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
3912 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
3913 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
3914 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
3915 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
3916 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
3917 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
3918 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
3919 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
3920 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
3921 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
3922 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
3923 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
3924 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
3925 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
3926 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
3927 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
3928 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
3929 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
3930 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
3931 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
3932 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
3933 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
3934 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
3935 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
3936 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
3937 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
3938 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
3939 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
3940 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
3941 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
3942 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
3943 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
3944 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
3945 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
3946 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
3947 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
3948 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
3949 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
3950 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
3951 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
3952 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
3953 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
3957 void TestCopyPaste::checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty)
3959 const SCTAB srcSheet = 0;
3960 const SCTAB destSheet = 1;
3963 ┌--- filtered src row 2 ┌--- repeated row
3966 | D | E | F | G |
3968 2 | 1 B*| 3 B*| 4 | 1 B*|
3969 3 | =D2+10 *| =E5+30 b*| =D2+40 b*| =G2+10 *|
3970 4 | a | c *| d *| a |
3971 5 | R1 *| 5 *| R4 *| R1 *|
3972 6 | =D2+F2+60 | B*| =C2+E2+70 *| =G2+I2+60 |
3973 7 | =SUMIF(D2:G2;"<4") | | =B$3+$B$5+80 *| =SUMIF(G2:J2;"<4") |
3975 * means note attached
3978 //check cell content after transposed copy/paste of filtered data
3979 // Note: column F is a repetition of srcSheet.Column A
3980 // Col C and G are checked to be empty
3981 const EditTextObject* pEditObj;
3982 // row 0
3983 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3984 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3985 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3986 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3987 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3988 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3989 // row 1, numbers
3990 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3991 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 1, destSheet));
3992 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
3993 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 3.0, m_pDoc->GetValue(4, 1, destSheet));
3994 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 4.0, m_pDoc->GetValue(5, 1, destSheet));
3995 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2 (repetition of D2)", 1.0,
3996 m_pDoc->GetValue(6, 1, destSheet));
3997 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
3998 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 1, destSheet));
3999 // row 2, formulas
4000 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4001 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
4002 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
4003 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
4004 m_pDoc->GetFormula(3, 2, destSheet));
4005 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E5+30"),
4006 m_pDoc->GetFormula(4, 2, destSheet));
4007 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 35.0, m_pDoc->GetValue(4, 2, destSheet));
4008 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=D2+40"),
4009 m_pDoc->GetFormula(5, 2, destSheet));
4010 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 41.0, m_pDoc->GetValue(5, 2, destSheet));
4011 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 11.0, m_pDoc->GetValue(6, 2, destSheet));
4012 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3 (repetition of D3)", OUString("=G2+10"),
4013 m_pDoc->GetFormula(6, 2, destSheet));
4014 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4015 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
4016 // row 3, strings
4017 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4018 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
4019 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
4020 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("c"), m_pDoc->GetString(4, 3, destSheet));
4021 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("d"), m_pDoc->GetString(5, 3, destSheet));
4022 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4 (repetition of D4)", OUString("a"),
4023 m_pDoc->GetString(6, 3, destSheet));
4024 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
4025 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
4026 // row 4, rich text
4027 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4028 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
4029 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
4030 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
4031 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
4032 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
4033 pEditObj->GetText(0));
4034 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E5", 5.0, m_pDoc->GetValue(4, 4, destSheet));
4035 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4036 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in F5.", pEditObj);
4037 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong F5.", OUString("R4"), pEditObj->GetText(0));
4038 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
4039 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in G5. (repetition of D5)", pEditObj);
4040 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong G5. (repetition of D5)", OUString("R1"),
4041 pEditObj->GetText(0));
4042 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
4043 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
4044 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
4045 // row 5, formulas
4046 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4047 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
4048 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
4049 m_pDoc->GetFormula(3, 5, destSheet));
4050 // formulas over filtered rows are not adjusted
4051 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 65.0,
4052 m_pDoc->GetValue(ScAddress(3, 5, destSheet)));
4053 if (!bSkipEmpty)
4054 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
4055 else
4056 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
4057 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", OUString("=C2+E2+70"),
4058 m_pDoc->GetFormula(5, 5, destSheet));
4059 // F6, formulas over filtered rows are not adjusted
4060 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", 1073.0,
4061 m_pDoc->GetValue(ScAddress(5, 5, destSheet)));
4062 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6 (repetition of D6)", OUString("=G2+I2+60"),
4063 m_pDoc->GetFormula(6, 5, destSheet));
4064 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6 (repetition of D6)", 1061.0,
4065 m_pDoc->GetValue(6, 5, destSheet));
4066 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
4067 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
4068 // row 6, formulas
4069 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
4070 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
4071 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
4072 m_pDoc->GetFormula(3, 6, destSheet));
4073 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 5.0, m_pDoc->GetValue(3, 6, destSheet));
4074 if (!bSkipEmpty)
4075 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
4076 else
4077 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
4078 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F7", OUString("=B$3+$B$5+80"),
4079 m_pDoc->GetFormula(5, 6, destSheet));
4080 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", 2080.0, m_pDoc->GetValue(5, 6, destSheet));
4081 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7 (repetition of D7)",
4082 OUString("=SUMIF(G2:J2;\"<4\")"),
4083 m_pDoc->GetFormula(6, 6, destSheet));
4084 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7 (repetition of D7)", 1061.0,
4085 m_pDoc->GetValue(6, 5, destSheet));
4086 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
4087 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
4089 // row
4090 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
4091 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
4092 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
4093 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
4094 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
4095 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
4097 // check patterns
4099 const SfxPoolItem* pItem = nullptr;
4100 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4101 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
4102 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
4103 static_cast<const SvxBrushItem*>(pItem)->GetColor());
4104 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4105 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
4106 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4107 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4108 CPPUNIT_ASSERT_MESSAGE("F2 has no pattern", !pItem);
4109 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4110 CPPUNIT_ASSERT_MESSAGE("G2 has a pattern", pItem);
4111 CPPUNIT_ASSERT_EQUAL_MESSAGE("G2 has a pattern", COL_BLUE,
4112 static_cast<const SvxBrushItem*>(pItem)->GetColor());
4113 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4114 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
4115 m_pDoc->GetPattern(ScAddress(4, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4116 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4117 if (!bSkipEmpty)
4118 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4120 // check border, left and right borders were transformed to top and bottom borders
4121 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
4122 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
4123 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
4124 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
4125 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
4126 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4127 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
4128 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4129 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
4130 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4131 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4132 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
4133 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
4134 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
4135 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4136 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
4137 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4138 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
4139 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4140 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
4141 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
4142 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
4143 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
4144 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4145 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
4146 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4147 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
4148 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4149 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
4150 CPPUNIT_ASSERT_MESSAGE("G3 has a border", pItem);
4151 CPPUNIT_ASSERT_MESSAGE("G3 has no top border",
4152 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
4153 CPPUNIT_ASSERT_MESSAGE("G3 has no bottom border",
4154 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4155 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
4156 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4157 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
4158 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4159 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
4160 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
4161 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
4162 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
4163 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
4164 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4165 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
4166 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4167 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
4168 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4170 // check notes after transposed copy/paste
4171 // check presence of notes
4172 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
4173 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
4174 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
4175 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
4176 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
4177 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
4178 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
4179 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
4180 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
4181 CPPUNIT_ASSERT_MESSAGE("F2: no note", !m_pDoc->HasNote(5, 1, destSheet));
4182 CPPUNIT_ASSERT_MESSAGE("G2: a note", m_pDoc->HasNote(6, 1, destSheet));
4183 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
4184 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
4185 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
4186 CPPUNIT_ASSERT_MESSAGE("E3: a note", m_pDoc->HasNote(4, 2, destSheet));
4187 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
4188 CPPUNIT_ASSERT_MESSAGE("G3: a note", m_pDoc->HasNote(6, 2, destSheet));
4189 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
4190 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
4191 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
4192 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
4193 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
4194 CPPUNIT_ASSERT_MESSAGE("G4: no note", !m_pDoc->HasNote(6, 3, destSheet));
4195 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
4196 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
4197 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
4198 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
4199 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
4200 CPPUNIT_ASSERT_MESSAGE("G5: a note", m_pDoc->HasNote(6, 4, destSheet));
4201 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
4202 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
4203 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
4204 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
4205 CPPUNIT_ASSERT_MESSAGE("F6: a note", m_pDoc->HasNote(5, 5, destSheet));
4206 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
4207 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
4208 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
4209 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
4210 CPPUNIT_ASSERT_MESSAGE("E7: no note", !m_pDoc->HasNote(4, 6, destSheet));
4211 CPPUNIT_ASSERT_MESSAGE("F7: a note", m_pDoc->HasNote(5, 6, destSheet));
4212 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
4213 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
4214 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
4215 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
4216 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
4217 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
4218 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
4219 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
4221 // check values of notes
4222 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
4223 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A3"), getNote(4, 1, destSheet));
4224 // F2 has no note
4225 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G2", OUString("Note A1"), getNote(6, 1, destSheet));
4226 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
4227 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("Note B3"), getNote(4, 2, destSheet));
4228 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B4"), getNote(5, 2, destSheet));
4229 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G3", OUString("Note B1"), getNote(6, 2, destSheet));
4230 // D4 has no note
4231 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C3"), getNote(4, 3, destSheet));
4232 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C4"), getNote(5, 3, destSheet));
4233 // G4 has no note
4234 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
4235 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D3"), getNote(4, 4, destSheet));
4236 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D4"), getNote(5, 4, destSheet));
4237 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G5", OUString("Note D1"), getNote(6, 4, destSheet));
4238 if (!bSkipEmpty)
4239 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 5, destSheet));
4240 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F6", OUString("Note E4"), getNote(5, 5, destSheet));
4241 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F7", OUString("Note F4"), getNote(5, 6, destSheet));
4243 // check row 16 on src sheet, refs to copied/cut range
4244 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
4245 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
4246 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
4247 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
4248 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
4249 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
4250 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
4251 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
4252 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
4253 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
4255 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4256 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4257 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4258 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4259 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4260 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4261 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4262 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4263 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4264 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4266 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
4267 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
4268 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
4269 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
4270 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
4271 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
4272 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
4273 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
4274 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
4275 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
4277 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4278 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4279 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4280 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4281 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4282 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4283 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4284 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4285 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4286 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4288 // Existing references to the destination range must not change
4289 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
4290 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
4291 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
4292 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
4293 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
4294 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
4295 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
4296 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
4297 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
4298 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
4299 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
4300 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
4301 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
4302 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
4303 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
4304 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
4305 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
4306 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
4307 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
4308 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
4309 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
4310 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
4311 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
4312 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
4313 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
4314 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
4315 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
4316 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
4317 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
4318 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
4319 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
4320 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
4321 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
4322 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
4323 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
4324 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
4325 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
4326 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
4327 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
4328 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
4329 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
4330 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
4331 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
4332 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
4333 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
4334 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
4335 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
4336 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
4337 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
4339 m_pDoc->DeleteTab(destSheet);
4340 m_pDoc->DeleteTab(srcSheet);
4343 void TestCopyPaste::checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty)
4345 const SCTAB srcSheet = 0;
4346 const SCTAB destSheet = 1;
4349 ┌--- not selected src col C
4352 | D | E | F | G | H | I |
4354 2 | 1 B*| =D2+10 *| R1 *| =C2+C4+60 | =SUMIF(C2:C5;"<4") | 121 |
4355 3 | 2 B*| =D3+20 b | R2 *| | *| 122 | <- filtered row
4356 4 | 3 B*| =G4+30 b*| 5 *| B*| | 123 |
4357 5 | 4 | =D3+40 b*| R4 *| =C2+C4+70 *| =D$3+$B$5+80 *| 124 |
4359 * means note attached
4360 B means background
4361 b means border
4364 const EditTextObject* pEditObj;
4365 // col 2
4366 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4367 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4368 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4369 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4370 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4371 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4372 // col 3, numbers
4373 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4374 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4375 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
4376 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
4377 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 4, destSheet));
4378 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
4379 // col 4, formulas
4380 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4381 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
4382 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
4383 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
4384 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), m_pDoc->GetFormula(4, 2, destSheet));
4385 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
4386 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), m_pDoc->GetFormula(4, 3, destSheet));
4387 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4388 m_pDoc->GetValue(4, 3, destSheet)); // It was 35
4389 CPPUNIT_ASSERT_EQUAL(OUString("=D3+40"), m_pDoc->GetFormula(4, 4, destSheet));
4390 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(4, 4, destSheet));
4391 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
4392 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 5, destSheet));
4393 // col 5, strings are not selected
4394 // col 5, rich text
4395 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4396 pEditObj = m_pDoc->GetEditText(ScAddress(5, 0, destSheet));
4397 CPPUNIT_ASSERT(pEditObj == nullptr);
4398 pEditObj = m_pDoc->GetEditText(ScAddress(5, 1, destSheet));
4399 CPPUNIT_ASSERT(pEditObj);
4400 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4401 pEditObj = m_pDoc->GetEditText(ScAddress(5, 2, destSheet));
4402 CPPUNIT_ASSERT(pEditObj);
4403 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
4404 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 3, destSheet));
4405 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4406 CPPUNIT_ASSERT(pEditObj);
4407 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4408 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
4409 pEditObj = m_pDoc->GetEditText(ScAddress(5, 5, destSheet));
4410 CPPUNIT_ASSERT(pEditObj == nullptr);
4411 // col 6, formulas
4412 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4413 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 0, destSheet));
4414 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+60"), m_pDoc->GetFormula(6, 1, destSheet));
4415 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(6, 1, destSheet)); // It was 64
4416 if (!bSkipEmpty)
4418 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 2, destSheet));
4419 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 3, destSheet));
4421 else
4423 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
4424 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 3, destSheet));
4426 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+70"), m_pDoc->GetFormula(6, 4, destSheet));
4427 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 4, destSheet)); // It was 74
4428 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
4429 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 5, destSheet));
4430 // col 7, formulas
4431 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4432 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
4433 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(C2:C5;\"<4\")"), m_pDoc->GetFormula(7, 1, destSheet));
4434 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(7, 1, destSheet)); // It was 6
4435 if (!bSkipEmpty)
4437 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
4438 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
4440 else
4442 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4443 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
4445 CPPUNIT_ASSERT_EQUAL(1082.0, m_pDoc->GetValue(7, 4, destSheet));
4446 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$B$5+80"), m_pDoc->GetFormula(7, 4, destSheet));
4447 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
4448 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
4449 // col 8, numbers
4450 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
4451 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(8, 1, destSheet));
4452 CPPUNIT_ASSERT_EQUAL(122.0, m_pDoc->GetValue(8, 2, destSheet));
4453 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 3, destSheet));
4454 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(8, 4, destSheet));
4455 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
4456 // col 9, col repetition is not supported for multi range copy/paste
4457 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
4458 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
4459 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
4460 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
4461 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
4462 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
4464 // check patterns
4465 const SfxPoolItem* pItem = nullptr;
4466 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4467 CPPUNIT_ASSERT(pItem);
4468 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4469 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4470 CPPUNIT_ASSERT(pItem);
4471 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4472 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4473 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4474 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4475 CPPUNIT_ASSERT(!pItem);
4476 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4477 CPPUNIT_ASSERT(!pItem);
4478 m_pDoc->GetPattern(ScAddress(6, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4479 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4480 if (!bSkipEmpty)
4481 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4483 // check border, left and right borders were transformed to top and bottom borders
4484 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
4485 CPPUNIT_ASSERT(pItem);
4486 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4487 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4488 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4489 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4490 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4491 CPPUNIT_ASSERT(pItem);
4492 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4493 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4494 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4495 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4496 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
4497 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4498 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4499 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4500 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4501 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
4502 CPPUNIT_ASSERT(pItem);
4503 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4504 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4505 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4506 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4507 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
4508 CPPUNIT_ASSERT(pItem);
4509 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4510 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4511 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4512 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4514 // check notes after transposed copy/paste
4515 // check presence of notes
4516 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4517 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4518 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4519 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4520 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4521 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4522 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
4523 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4524 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4525 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4526 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4527 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4528 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4529 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
4530 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4531 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4532 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
4533 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4534 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, destSheet));
4535 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
4536 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
4537 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4538 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
4539 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4540 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4541 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(6, 3, destSheet));
4542 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
4543 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
4544 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4545 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4546 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
4547 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
4548 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
4549 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 4, destSheet));
4550 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
4551 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
4552 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
4553 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
4554 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
4555 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
4556 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
4557 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
4559 // check values of notes
4560 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4561 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
4562 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
4563 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
4564 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
4565 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(5, 1, destSheet));
4566 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(5, 2, destSheet));
4567 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 3, destSheet));
4568 if (!bSkipEmpty)
4569 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(6, 3, destSheet));
4570 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 4, destSheet));
4571 if (!bSkipEmpty)
4572 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(7, 2, destSheet));
4573 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(7, 4, destSheet));
4575 // check row 16 on src sheet, refs to copied/cut range
4576 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
4577 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
4578 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
4579 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
4580 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
4581 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
4582 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
4583 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
4584 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
4585 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
4587 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4588 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4589 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4590 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4591 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4592 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4593 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4594 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4595 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4596 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4598 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
4599 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
4600 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
4601 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
4602 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
4603 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
4604 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
4605 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
4606 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
4607 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
4609 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4610 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4611 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4612 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4613 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4614 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4615 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4616 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4617 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4618 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4620 // Existing references to the destination range must not change
4621 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
4622 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
4623 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
4624 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
4625 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
4626 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
4627 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
4628 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
4629 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
4630 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
4631 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
4632 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
4633 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
4634 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
4635 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
4636 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
4637 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
4638 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
4639 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
4640 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
4641 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
4642 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
4643 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
4644 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
4645 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
4646 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
4647 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
4648 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
4649 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
4650 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
4651 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
4652 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
4653 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
4654 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
4655 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
4656 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
4657 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
4658 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
4659 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
4660 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
4661 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
4662 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
4663 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
4664 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
4665 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
4666 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
4667 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
4668 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
4669 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
4671 m_pDoc->DeleteTab(destSheet);
4672 m_pDoc->DeleteTab(srcSheet);
4675 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty)
4677 const SCTAB srcSheet = 0;
4678 const SCTAB destSheet = 1;
4681 ┌--- not selected src col C
4684 | D | E | F | G | H | I |
4686 2 | 1 B*| =D2+10 *| R1 *| =C2+C4+60 | =SUMIF(C2:C5;"<4") | 121 |
4687 3 | 3 B*| =G4+30 b*| 5 *| B*| | 123 |
4688 4 | 4 | =D2+40 b*| R4 *| =C1+C3+70 *| =D$3+$B$5+80 *| 124 |
4690 * means note attached
4691 B means background
4692 b means border
4695 const EditTextObject* pEditObj;
4696 // col 2
4697 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4698 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4699 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4700 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4701 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4702 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4703 // col 3, numbers
4704 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4705 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4706 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
4707 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 3, destSheet));
4708 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 4, destSheet));
4709 // col 4, formulas
4710 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4711 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 0, destSheet));
4712 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
4713 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
4714 // references over selection gaps are not adjusted
4715 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), m_pDoc->GetFormula(4, 2, destSheet));
4716 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4717 m_pDoc->GetValue(4, 2, destSheet)); // It was 35
4718 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), m_pDoc->GetFormula(4, 3, destSheet));
4719 // was originally 42, not adjusted by filtering
4720 CPPUNIT_ASSERT_EQUAL(41.0, m_pDoc->GetValue(4, 3, destSheet));
4721 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
4722 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 4, destSheet));
4723 // col 5, strings are not selected
4724 // col 5, rich text
4725 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4726 pEditObj = m_pDoc->GetEditText(ScAddress(5, 0, destSheet));
4727 CPPUNIT_ASSERT(pEditObj == nullptr);
4728 pEditObj = m_pDoc->GetEditText(ScAddress(5, 1, destSheet));
4729 CPPUNIT_ASSERT(pEditObj);
4730 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4731 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 2, destSheet));
4732 pEditObj = m_pDoc->GetEditText(ScAddress(5, 3, destSheet));
4733 CPPUNIT_ASSERT(pEditObj);
4734 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4735 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 4, destSheet));
4736 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4737 CPPUNIT_ASSERT(pEditObj == nullptr);
4738 // col 6, formulas
4739 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4740 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(6, 0, destSheet));
4741 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+60"), m_pDoc->GetFormula(6, 1, destSheet));
4742 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(6, 1, destSheet)); // It was 64
4743 if (!bSkipEmpty)
4744 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 2, destSheet));
4745 else
4746 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
4747 CPPUNIT_ASSERT_EQUAL(OUString("=C1+C3+70"), m_pDoc->GetFormula(6, 3, destSheet));
4748 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 3, destSheet)); // It was 74
4749 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 4, destSheet));
4750 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(6, 4, destSheet));
4751 // col 7, formulas
4752 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4753 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(7, 0, destSheet));
4754 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(C2:C5;\"<4\")"), m_pDoc->GetFormula(7, 1, destSheet));
4755 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(7, 1, destSheet)); // It was 6
4756 if (!bSkipEmpty)
4757 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
4758 else
4759 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4760 CPPUNIT_ASSERT_EQUAL(1083.0, m_pDoc->GetValue(7, 3, destSheet));
4761 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$B$5+80"), m_pDoc->GetFormula(7, 3, destSheet));
4762 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
4763 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(7, 4, destSheet));
4764 // col 8, numbers
4765 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
4766 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(8, 1, destSheet));
4767 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 2, destSheet));
4768 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(8, 3, destSheet));
4769 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 4, destSheet));
4770 // col 9, col repetition is not supported for multi range copy/paste
4771 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
4772 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
4773 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
4774 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
4775 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
4776 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
4778 // check patterns
4779 const SfxPoolItem* pItem = nullptr;
4780 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4781 CPPUNIT_ASSERT(pItem);
4782 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4783 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4784 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4785 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4786 CPPUNIT_ASSERT(!pItem);
4787 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4788 CPPUNIT_ASSERT(!pItem);
4789 m_pDoc->GetPattern(ScAddress(6, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4790 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4791 if (!bSkipEmpty)
4792 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4794 // check border, left and right borders were transformed to top and bottom borders
4795 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
4796 CPPUNIT_ASSERT(pItem);
4797 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4798 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4799 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4800 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4801 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4802 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4803 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4804 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4805 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4806 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
4807 CPPUNIT_ASSERT(pItem);
4808 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4809 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4810 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4811 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4812 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
4813 CPPUNIT_ASSERT(pItem);
4814 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4815 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4816 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4817 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4819 // check notes after transposed copy/paste
4820 // check presence of notes
4821 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4822 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4823 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4824 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4825 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4826 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4827 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
4828 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4829 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4830 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4831 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4832 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4833 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4834 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
4835 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4836 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4837 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
4838 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4839 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(6, 2, destSheet));
4840 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
4841 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
4842 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4843 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
4844 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4845 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4846 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
4847 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 3, destSheet));
4848 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
4849 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4850 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4851 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
4852 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
4853 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
4854 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
4855 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
4857 // check values of notes
4858 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4859 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
4860 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
4861 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
4862 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(5, 1, destSheet));
4863 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 2, destSheet));
4864 if (!bSkipEmpty)
4865 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(6, 2, destSheet));
4866 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 3, destSheet));
4867 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(7, 3, destSheet));
4869 // check row 16 on src sheet, refs to copied/cut range
4870 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
4871 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
4872 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
4873 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
4874 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
4875 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
4876 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
4877 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
4878 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
4879 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
4881 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4882 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4883 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4884 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4885 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4886 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4887 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4888 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4889 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4890 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4892 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
4893 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
4894 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
4895 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
4896 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
4897 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
4898 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
4899 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
4900 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
4901 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
4903 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4904 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4905 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4906 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4907 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4908 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4909 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4910 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4911 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4912 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4914 // Existing references to the destination range must not change
4915 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
4916 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
4917 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
4918 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
4919 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
4920 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
4921 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
4922 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
4923 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
4924 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
4925 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
4926 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
4927 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
4928 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
4929 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
4930 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
4931 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
4932 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
4933 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
4934 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
4935 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
4936 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
4937 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
4938 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
4939 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
4940 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
4941 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
4942 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
4943 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
4944 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
4945 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
4946 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
4947 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
4948 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
4949 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
4950 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
4951 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
4952 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
4953 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
4954 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
4955 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
4956 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
4957 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
4958 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
4959 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
4960 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
4961 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
4962 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
4963 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
4965 m_pDoc->DeleteTab(destSheet);
4966 m_pDoc->DeleteTab(srcSheet);
4969 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty)
4971 const SCTAB srcSheet = 0;
4972 const SCTAB destSheet = 1;
4975 | D | E | F | G |
4977 2 | 1 B*| 2 B*| 3 B*| 4 |
4978 3 | =D2+10 *| =E2+20 b | =F5+30 b*| =E2+40 b*|
4979 4 | R1 *| R2 *| 5 *| R4 *|
4980 5 | =D1+F1+60 | | B*| =D1+F1+70 *|
4981 6 | =SUMIF(D1:G1;"<4") | *| | =C$3+$B$5+80 *|
4982 7 | 121 | 122 | 123 | 124 |
4984 * means note attached
4985 B means background
4986 b means border
4989 // check cell content after transposed copy/paste of filtered data
4990 // Col C and G are checked to be empty
4991 const EditTextObject* pEditObj;
4992 // row 0
4993 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4994 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4995 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4996 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4997 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4998 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4999 // row 1, numbers
5000 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5001 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5002 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(4, 1, destSheet));
5003 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(5, 1, destSheet));
5004 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(6, 1, destSheet));
5005 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
5006 // row 2, formulas
5007 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
5008 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
5009 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 2, destSheet));
5010 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(3, 2, destSheet));
5011 CPPUNIT_ASSERT_EQUAL(OUString("=E2+20"), m_pDoc->GetFormula(4, 2, destSheet));
5012 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
5013 CPPUNIT_ASSERT_EQUAL(OUString("=F5+30"), m_pDoc->GetFormula(5, 2, destSheet));
5014 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
5015 m_pDoc->GetValue(5, 2, destSheet)); // It was 35
5016 CPPUNIT_ASSERT_EQUAL(OUString("=E2+40"), m_pDoc->GetFormula(6, 2, destSheet));
5017 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(6, 2, destSheet));
5018 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
5019 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
5020 // row 3, strings was not selected in multi range selection
5021 // row 3, rich text
5022 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5023 pEditObj = m_pDoc->GetEditText(ScAddress(2, 3, destSheet));
5024 CPPUNIT_ASSERT(pEditObj == nullptr);
5025 pEditObj = m_pDoc->GetEditText(ScAddress(3, 3, destSheet));
5026 CPPUNIT_ASSERT(pEditObj);
5027 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5028 pEditObj = m_pDoc->GetEditText(ScAddress(4, 3, destSheet));
5029 CPPUNIT_ASSERT(pEditObj);
5030 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
5031 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 3, destSheet));
5032 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
5033 CPPUNIT_ASSERT(pEditObj);
5034 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
5035 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
5036 pEditObj = m_pDoc->GetEditText(ScAddress(7, 3, destSheet));
5037 CPPUNIT_ASSERT(pEditObj == nullptr);
5038 // row 4, formulas
5039 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5040 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 4, destSheet));
5041 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+60"), m_pDoc->GetFormula(3, 4, destSheet));
5042 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(3, 4, destSheet)); // It was 64
5043 if (!bSkipEmpty)
5045 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString(), m_pDoc->GetString(4, 4, destSheet));
5046 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString(), m_pDoc->GetString(5, 4, destSheet));
5048 else
5050 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
5051 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 4, destSheet));
5053 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+70"), m_pDoc->GetFormula(6, 4, destSheet));
5054 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 4, destSheet)); // It was 74
5055 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
5056 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 4, destSheet));
5057 // row 5, formulas
5058 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5059 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5060 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D1:G1;\"<4\")"), m_pDoc->GetFormula(3, 5, destSheet));
5061 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(3, 5, destSheet)); // It was 6
5062 if (!bSkipEmpty)
5064 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
5065 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
5067 else
5069 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
5070 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
5073 CPPUNIT_ASSERT_EQUAL(OUString("=C$3+$B$5+80"), m_pDoc->GetFormula(6, 5, destSheet));
5074 CPPUNIT_ASSERT_EQUAL(2080.0, m_pDoc->GetValue(6, 5, destSheet));
5075 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
5076 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
5077 // row 6, numbers
5078 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
5079 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(3, 6, destSheet));
5080 CPPUNIT_ASSERT_EQUAL(122.0, m_pDoc->GetValue(4, 6, destSheet));
5081 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(5, 6, destSheet));
5082 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(6, 6, destSheet));
5083 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
5084 // row 7, not selected
5085 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5086 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5087 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5088 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5089 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5090 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5092 // check patterns
5093 const SfxPoolItem* pItem = nullptr;
5094 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5095 CPPUNIT_ASSERT(pItem);
5096 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5097 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5098 CPPUNIT_ASSERT(pItem);
5099 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5100 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5101 CPPUNIT_ASSERT(pItem);
5102 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5103 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5104 CPPUNIT_ASSERT(!pItem);
5105 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5106 CPPUNIT_ASSERT(!pItem);
5107 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5108 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5109 // std::cout << "bSkipEmpty: " << bSkipEmpty << ", pItem == nullptr: " << (pItem == nullptr) << std::endl;
5110 if (!bSkipEmpty)
5111 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5113 // check border, left and right borders were transformed to top and bottom borders
5114 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
5115 CPPUNIT_ASSERT(pItem);
5116 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5117 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5118 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5119 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5121 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
5122 CPPUNIT_ASSERT(pItem);
5123 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5124 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5125 CPPUNIT_ASSERT(pItem);
5126 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5127 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5128 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5129 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5130 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
5131 CPPUNIT_ASSERT(pItem);
5132 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5133 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5134 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5135 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5136 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
5137 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5138 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5139 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5140 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5141 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
5142 CPPUNIT_ASSERT(pItem);
5143 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5144 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5145 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5146 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5148 // check notes after transposed copy/paste
5149 // check presence of notes
5150 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5151 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5152 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5153 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5154 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5155 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
5156 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5157 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5158 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5159 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
5160 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
5161 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
5162 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5163 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5164 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
5165 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5166 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
5167 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
5168 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5169 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5170 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5171 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5172 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
5173 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
5174 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5175 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5176 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
5177 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 4, destSheet));
5178 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
5179 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
5180 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5181 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5182 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
5183 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
5184 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 5, destSheet));
5185 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
5186 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, destSheet));
5187 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 6, destSheet));
5188 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, destSheet));
5189 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, destSheet));
5190 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, destSheet));
5191 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 6, destSheet));
5193 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5194 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(4, 1, destSheet));
5195 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(5, 1, destSheet));
5196 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(3, 2, destSheet));
5197 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(5, 2, destSheet));
5198 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(3, 3, destSheet));
5199 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(4, 3, destSheet));
5200 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 3, destSheet));
5201 if (!bSkipEmpty)
5202 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 4, destSheet));
5203 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 4, destSheet));
5204 if (!bSkipEmpty)
5205 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(4, 5, destSheet));
5206 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(6, 5, destSheet));
5208 // check row 16 on src sheet, refs to copied/cut range
5209 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
5210 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
5211 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
5212 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
5213 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
5214 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
5215 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
5216 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
5217 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
5218 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
5220 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5221 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5222 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5223 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5224 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5225 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5226 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5227 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5228 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5229 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5231 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
5232 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
5233 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
5234 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
5235 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
5236 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
5237 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
5238 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
5239 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
5240 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
5242 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5243 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5244 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5245 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5246 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5247 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5248 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5249 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5250 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5251 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5253 // Existing references to the destination range must not change
5254 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
5255 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
5256 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
5257 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
5258 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
5259 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
5260 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
5261 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
5262 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
5263 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
5264 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
5265 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
5266 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
5267 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
5268 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
5269 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
5270 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
5271 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
5272 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
5273 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
5274 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
5275 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
5276 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
5277 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
5278 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
5279 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
5280 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
5281 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
5282 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
5283 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
5284 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
5285 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
5286 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
5287 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
5288 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
5289 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
5290 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
5291 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
5292 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
5293 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
5294 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
5295 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
5296 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
5297 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
5298 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
5299 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
5300 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
5301 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
5302 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
5304 m_pDoc->DeleteTab(destSheet);
5305 m_pDoc->DeleteTab(srcSheet);
5308 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty)
5310 const SCTAB srcSheet = 0;
5311 const SCTAB destSheet = 1;
5314 ┌--- filtered src row 2
5317 | D | E | F |
5319 2 | 1 B*| 3 B*| 4 |
5320 3 | =D2+10 *| =E5+30 b*| =D2+40 b*|
5321 <- not copied col C
5322 4 | R1 *| 5 *| R4 *|
5323 5 | =D1+F1+60 | B*| =C1+E1+70 *|
5324 6 | =SUMIF(D1:G1;"<4") | | =B$3+$B$5+80 *|
5325 7 | 121 | 123 | 124 |
5327 * means note attached
5328 B means background
5329 b means border
5332 // check cell content after transposed copy/paste of filtered data
5333 // Col C and G are checked to be empty
5334 const EditTextObject* pEditObj;
5335 // row 0
5336 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5337 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5338 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5339 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5340 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5341 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5342 // row 1, numbers
5343 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5344 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5345 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(4, 1, destSheet));
5346 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(5, 1, destSheet));
5347 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 1, destSheet));
5348 // row 2, formulas
5349 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5350 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5351 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 2, destSheet));
5352 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(3, 2, destSheet));
5353 CPPUNIT_ASSERT_EQUAL(OUString("=E5+30"), m_pDoc->GetFormula(4, 2, destSheet));
5354 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
5355 m_pDoc->GetValue(4, 2, destSheet)); // It was 35
5356 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), m_pDoc->GetFormula(5, 2, destSheet));
5357 CPPUNIT_ASSERT_EQUAL(
5358 41.0, m_pDoc->GetValue(5, 2, destSheet)); // was originally 42, not adjusted by filtering
5359 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
5360 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 2, destSheet));
5361 // row 3, strings was not selected in multi range selection
5362 // row 3, rich text
5363 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5364 pEditObj = m_pDoc->GetEditText(ScAddress(2, 3, destSheet));
5365 CPPUNIT_ASSERT(pEditObj == nullptr);
5366 pEditObj = m_pDoc->GetEditText(ScAddress(3, 3, destSheet));
5367 CPPUNIT_ASSERT(pEditObj);
5368 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5369 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 3, destSheet));
5370 pEditObj = m_pDoc->GetEditText(ScAddress(5, 3, destSheet));
5371 CPPUNIT_ASSERT(pEditObj);
5372 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
5373 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 3, destSheet));
5374 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
5375 CPPUNIT_ASSERT(pEditObj == nullptr);
5376 // row 4, formulas
5377 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5378 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 4, destSheet));
5379 // formulas over filtered rows are not adjusted
5380 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+60"), m_pDoc->GetFormula(3, 4, destSheet));
5381 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(3, 4, destSheet)); // It was 64
5382 if (!bSkipEmpty)
5383 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(4, 4, destSheet));
5384 else
5385 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
5386 CPPUNIT_ASSERT_EQUAL(OUString("=C1+E1+70"), m_pDoc->GetFormula(5, 4, destSheet));
5387 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(5, 4, destSheet)); // It was 74
5388 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 4, destSheet));
5389 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 4, destSheet));
5390 // row 5, formulas
5391 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5392 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5393 // formulas over filtered rows are not adjusted
5394 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D1:G1;\"<4\")"), m_pDoc->GetFormula(3, 5, destSheet));
5395 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(3, 5, destSheet)); // It was 6
5396 if (!bSkipEmpty)
5397 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
5398 else
5399 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
5400 CPPUNIT_ASSERT_EQUAL(OUString("=B$3+$B$5+80"), m_pDoc->GetFormula(5, 5, destSheet));
5401 CPPUNIT_ASSERT_EQUAL(2080.0, m_pDoc->GetValue(5, 5, destSheet));
5402 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
5403 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 5, destSheet));
5404 // row 6, numbers
5405 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
5406 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(3, 6, destSheet));
5407 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(4, 6, destSheet));
5408 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(5, 6, destSheet));
5409 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 6, destSheet));
5410 // row 7, not copied
5411 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5412 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5413 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5414 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5415 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5416 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5417 // row 8, not copied
5418 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5419 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5420 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5421 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5422 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5423 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5425 // check patterns
5426 const SfxPoolItem* pItem = nullptr;
5427 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5428 CPPUNIT_ASSERT(pItem);
5429 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5430 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5431 CPPUNIT_ASSERT(pItem);
5432 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5433 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5434 CPPUNIT_ASSERT(!pItem);
5435 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5436 CPPUNIT_ASSERT(!pItem);
5437 m_pDoc->GetPattern(ScAddress(4, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5438 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5439 if (!bSkipEmpty)
5440 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5442 // check border, left and right borders were transformed to top and bottom borders
5443 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
5444 CPPUNIT_ASSERT(pItem);
5445 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5446 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5447 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5448 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5450 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
5451 CPPUNIT_ASSERT(pItem);
5452 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5454 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5455 CPPUNIT_ASSERT(pItem);
5456 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5457 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5458 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5459 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5460 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
5461 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5462 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5463 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5464 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5465 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
5466 CPPUNIT_ASSERT(pItem);
5467 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5468 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5469 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5470 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5472 // check notes after transposed copy/paste
5473 // check presence of notes
5474 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5475 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5476 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5477 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5478 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5479 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5480 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5481 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5482 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
5483 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
5484 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5485 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5486 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
5487 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5488 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, destSheet));
5489 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5490 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5491 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5492 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5493 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 3, destSheet));
5494 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5495 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5496 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 4, destSheet));
5497 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
5498 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
5499 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5500 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5501 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
5502 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 5, destSheet));
5503 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
5504 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, destSheet));
5505 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 6, destSheet));
5506 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, destSheet));
5507 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, destSheet));
5508 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, destSheet));
5510 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5511 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(4, 1, destSheet));
5512 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(3, 2, destSheet));
5513 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
5514 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(3, 3, destSheet));
5515 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(4, 3, destSheet));
5516 if (!bSkipEmpty)
5517 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 4, destSheet));
5518 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(5, 4, destSheet));
5519 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(5, 5, destSheet));
5521 // check row 16 on src sheet, refs to copied/cut range
5522 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
5523 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
5524 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
5525 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
5526 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
5527 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
5528 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
5529 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
5530 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
5531 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
5533 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5534 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5535 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5536 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5537 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5538 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5539 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5540 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5541 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5542 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5544 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
5545 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
5546 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
5547 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
5548 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
5549 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
5550 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
5551 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
5552 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
5553 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
5555 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5556 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5557 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5558 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5559 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5560 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5561 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5562 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5563 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5564 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5566 // Existing references to the destination range must not change
5567 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
5568 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
5569 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
5570 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
5571 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
5572 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
5573 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
5574 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
5575 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
5576 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
5577 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
5578 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
5579 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
5580 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
5581 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
5582 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
5583 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
5584 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
5585 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
5586 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
5587 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
5588 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
5589 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
5590 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
5591 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
5592 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
5593 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
5594 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
5595 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
5596 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
5597 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
5598 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
5599 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
5600 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
5601 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
5602 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
5603 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
5604 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
5605 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
5606 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
5607 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
5608 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
5609 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
5610 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
5611 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
5612 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
5613 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
5614 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
5615 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
5617 m_pDoc->DeleteTab(destSheet);
5618 m_pDoc->DeleteTab(srcSheet);
5621 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty)
5623 const SCTAB srcSheet = 0;
5624 const SCTAB destSheet = 1;
5627 | D | E | F | G | H | I |
5629 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
5630 3 | 2 B*| =D3+20 b | b *| R2 *| | *| <- filtered row
5631 4 | 3 B*| =G4+30 b*| c *| 5 *| B*| |
5632 <- not selected row
5633 5 | 6 | q | r bB*| s bB| t | u |
5634 6 | -11 | -12 | -13 | -14 | -15 | -16 |
5636 * means note attached
5637 B means background
5638 b means border
5641 const EditTextObject* pEditObj;
5642 // col 2
5643 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5644 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5645 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
5646 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5647 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5648 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5649 // col 3, numbers
5650 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5651 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5652 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
5653 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
5654 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(3, 4, destSheet));
5655 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(3, 5, destSheet));
5656 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 6, destSheet));
5657 // col 4, formulas
5658 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5659 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
5660 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
5661 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
5662 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), m_pDoc->GetFormula(4, 2, destSheet));
5663 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
5664 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), m_pDoc->GetFormula(4, 3, destSheet));
5665 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 3, destSheet));
5666 CPPUNIT_ASSERT_EQUAL(OUString("q"), m_pDoc->GetString(4, 4, destSheet));
5667 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(4, 5, destSheet));
5668 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
5669 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 6, destSheet));
5670 // col 5, strings
5671 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5672 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
5673 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
5674 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(5, 2, destSheet));
5675 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 3, destSheet));
5676 CPPUNIT_ASSERT_EQUAL(OUString("r"), m_pDoc->GetString(5, 4, destSheet));
5677 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(5, 5, destSheet));
5678 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
5679 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 6, destSheet));
5680 // col 6, rich text
5681 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5682 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
5683 CPPUNIT_ASSERT(pEditObj == nullptr);
5684 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
5685 CPPUNIT_ASSERT(pEditObj);
5686 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5687 pEditObj = m_pDoc->GetEditText(ScAddress(6, 2, destSheet));
5688 CPPUNIT_ASSERT(pEditObj);
5689 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
5690 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 3, destSheet));
5691 CPPUNIT_ASSERT_EQUAL(OUString("s"), m_pDoc->GetString(6, 4, destSheet));
5692 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 5, destSheet));
5693 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 6, destSheet));
5694 pEditObj = m_pDoc->GetEditText(ScAddress(6, 6, destSheet));
5695 CPPUNIT_ASSERT(pEditObj == nullptr);
5696 // col 7, formulas
5697 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5698 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5699 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
5700 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(7, 1, destSheet));
5701 if (!bSkipEmpty)
5703 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
5704 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
5706 else
5708 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
5709 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
5711 CPPUNIT_ASSERT_EQUAL(OUString("t"), m_pDoc->GetString(7, 4, destSheet));
5712 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 5, destSheet));
5713 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
5714 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
5715 // col 8, formulas
5716 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
5717 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5718 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
5719 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
5720 if (!bSkipEmpty)
5722 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
5723 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 3, destSheet));
5725 else
5727 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
5728 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
5730 CPPUNIT_ASSERT_EQUAL(OUString("u"), m_pDoc->GetString(8, 4, destSheet));
5731 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(8, 5, destSheet));
5732 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 6, destSheet));
5733 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 6, destSheet));
5734 // col 9
5735 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
5736 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
5737 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
5738 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
5739 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
5740 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
5742 // check patterns
5743 const SfxPoolItem* pItem = nullptr;
5744 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5745 CPPUNIT_ASSERT(pItem);
5746 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5747 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5748 CPPUNIT_ASSERT(pItem);
5749 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5750 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5751 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5752 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5753 CPPUNIT_ASSERT(!pItem);
5754 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5755 CPPUNIT_ASSERT(!pItem);
5756 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5757 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5758 if (!bSkipEmpty)
5759 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5761 m_pDoc->GetPattern(ScAddress(4, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5762 CPPUNIT_ASSERT(!pItem);
5763 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5764 CPPUNIT_ASSERT(pItem);
5765 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5766 m_pDoc->GetPattern(ScAddress(6, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5767 CPPUNIT_ASSERT(pItem);
5768 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5769 m_pDoc->GetPattern(ScAddress(7, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5770 CPPUNIT_ASSERT(!pItem);
5772 // check border, left and right borders were transformed to top and bottom borders
5773 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
5774 CPPUNIT_ASSERT(pItem);
5775 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5776 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5777 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5778 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5779 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5780 CPPUNIT_ASSERT(pItem);
5781 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5782 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5783 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5784 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5785 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
5786 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5787 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5788 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5789 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5790 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5791 CPPUNIT_ASSERT(pItem);
5792 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5793 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5794 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5795 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5796 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
5797 CPPUNIT_ASSERT(pItem);
5798 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5799 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5800 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5801 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5803 pItem = m_pDoc->GetAttr(ScAddress(3, 4, destSheet), ATTR_BORDER);
5804 CPPUNIT_ASSERT(pItem);
5805 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5806 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5807 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5808 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5809 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5810 CPPUNIT_ASSERT(pItem);
5811 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5812 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5813 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5814 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5815 pItem = m_pDoc->GetAttr(ScAddress(5, 4, destSheet), ATTR_BORDER);
5816 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5817 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5818 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5819 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5820 pItem = m_pDoc->GetAttr(ScAddress(6, 4, destSheet), ATTR_BORDER);
5821 CPPUNIT_ASSERT(pItem);
5822 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5823 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5824 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5825 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5826 pItem = m_pDoc->GetAttr(ScAddress(7, 4, destSheet), ATTR_BORDER);
5827 CPPUNIT_ASSERT(pItem);
5828 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5829 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5830 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5831 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5833 // check notes after transposed copy/paste
5834 // check presence of notes
5835 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5836 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5837 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5838 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5839 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5840 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
5841 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
5842 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
5843 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5844 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5845 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5846 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
5847 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
5848 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
5849 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
5850 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
5851 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5852 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5853 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
5854 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5855 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
5856 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
5857 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(8, 2, destSheet));
5858 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
5859 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5860 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5861 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5862 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5863 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
5864 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 3, destSheet));
5865 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
5866 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
5867 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5868 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5869 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
5870 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
5871 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
5872 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
5873 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
5874 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
5875 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5876 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5877 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
5878 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
5879 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
5880 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
5881 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
5882 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
5884 // check values of notes
5885 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5886 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
5887 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
5888 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
5889 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
5890 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(5, 2, destSheet));
5891 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 3, destSheet));
5892 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
5893 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(6, 2, destSheet));
5894 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 3, destSheet));
5895 if (!bSkipEmpty)
5896 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 3, destSheet));
5897 if (!bSkipEmpty)
5898 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(8, 2, destSheet));
5899 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 4, destSheet));
5901 // check row 16 on src sheet, refs to copied/cut range
5902 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
5903 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
5904 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
5905 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
5906 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
5907 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
5908 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
5909 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
5910 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
5911 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
5913 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5914 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5915 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5916 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5917 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5918 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5919 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5920 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5921 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5922 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5924 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
5925 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
5926 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
5927 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
5928 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
5929 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
5930 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
5931 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
5932 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
5933 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
5935 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5936 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5937 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5938 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5939 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5940 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5941 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5942 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5943 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5944 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5946 // Existing references to the destination range must not change
5947 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
5948 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
5949 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
5950 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
5951 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
5952 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
5953 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
5954 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
5955 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
5956 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
5957 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
5958 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
5959 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
5960 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
5961 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
5962 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
5963 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
5964 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
5965 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
5966 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
5967 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
5968 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
5969 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
5970 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
5971 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
5972 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
5973 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
5974 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
5975 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
5976 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
5977 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
5978 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
5979 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
5980 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
5981 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
5982 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
5983 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
5984 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
5985 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
5986 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
5987 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
5988 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
5989 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
5990 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
5991 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
5992 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
5993 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
5994 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
5995 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
5997 m_pDoc->DeleteTab(destSheet);
5998 m_pDoc->DeleteTab(srcSheet);
6001 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty)
6003 const SCTAB srcSheet = 0;
6004 const SCTAB destSheet = 1;
6007 | D | E | F | G | H | I |
6009 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
6010 3 | 3 B*| =G3+30 b*| c *| 5 *| B*| |
6011 <- not selected
6012 4 | 6 | q | r | s | t | u |
6013 5 | -11 | -12 |-13 | -14 | -15 | -16 |
6015 * means note attached
6016 B means background
6017 b means border
6020 const EditTextObject* pEditObj;
6021 // col 2
6022 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6023 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
6024 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6025 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6026 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6027 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6028 // col 3, numbers
6029 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6030 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
6031 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
6032 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(3, 3, destSheet));
6033 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(3, 4, destSheet));
6034 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
6035 // col 4, formulas
6036 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6037 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
6038 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
6039 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
6040 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), m_pDoc->GetFormula(4, 2, destSheet));
6041 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 2, destSheet));
6042 CPPUNIT_ASSERT_EQUAL(OUString("q"), m_pDoc->GetString(4, 3, destSheet));
6043 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(4, 4, destSheet));
6044 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6045 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 5, destSheet));
6046 // col 5, strings
6047 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6048 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
6049 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
6050 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 2, destSheet));
6051 CPPUNIT_ASSERT_EQUAL(OUString("r"), m_pDoc->GetString(5, 3, destSheet));
6052 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(5, 4, destSheet));
6053 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
6054 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 5, destSheet));
6055 // col 6, rich text
6056 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6057 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
6058 CPPUNIT_ASSERT(pEditObj == nullptr);
6059 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
6060 CPPUNIT_ASSERT(pEditObj);
6061 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
6062 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 2, destSheet));
6063 CPPUNIT_ASSERT_EQUAL(OUString("s"), m_pDoc->GetString(6, 3, destSheet));
6064 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 4, destSheet));
6065 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
6066 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
6067 CPPUNIT_ASSERT(pEditObj == nullptr);
6068 // col 7, formulas
6069 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6070 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
6071 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
6072 CPPUNIT_ASSERT_EQUAL(67.0, m_pDoc->GetValue(7, 1, destSheet));
6073 if (!bSkipEmpty)
6074 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
6075 else
6076 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
6077 CPPUNIT_ASSERT_EQUAL(OUString("t"), m_pDoc->GetString(7, 3, destSheet));
6078 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 4, destSheet));
6079 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
6080 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
6081 // col 8, formulas
6082 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
6083 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
6084 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
6085 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
6086 if (!bSkipEmpty)
6087 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
6088 else
6089 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
6090 CPPUNIT_ASSERT_EQUAL(OUString("u"), m_pDoc->GetString(8, 3, destSheet));
6091 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(8, 4, destSheet));
6092 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
6093 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
6094 // col 9
6095 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
6096 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
6097 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
6098 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
6099 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
6100 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
6102 // check patterns
6103 const SfxPoolItem* pItem = nullptr;
6104 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6105 CPPUNIT_ASSERT(pItem);
6106 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6107 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6108 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6109 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6110 CPPUNIT_ASSERT(!pItem);
6111 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6112 CPPUNIT_ASSERT(!pItem);
6113 m_pDoc->GetPattern(ScAddress(7, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6114 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6115 if (!bSkipEmpty)
6116 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6118 m_pDoc->GetPattern(ScAddress(4, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6119 CPPUNIT_ASSERT(!pItem);
6120 m_pDoc->GetPattern(ScAddress(5, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6121 CPPUNIT_ASSERT(pItem);
6122 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6123 m_pDoc->GetPattern(ScAddress(6, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6124 CPPUNIT_ASSERT(pItem);
6125 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6126 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6127 CPPUNIT_ASSERT(!pItem);
6129 // check border, left and right borders were transformed to top and bottom borders
6130 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
6131 CPPUNIT_ASSERT(pItem);
6132 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6133 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6134 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6135 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6136 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6137 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6138 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6139 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6140 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6141 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
6142 CPPUNIT_ASSERT(pItem);
6143 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6144 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6145 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6146 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6147 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
6148 CPPUNIT_ASSERT(pItem);
6149 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6150 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6151 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6152 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6154 pItem = m_pDoc->GetAttr(ScAddress(3, 3, destSheet), ATTR_BORDER);
6155 CPPUNIT_ASSERT(pItem);
6156 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6157 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6158 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6159 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6160 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
6161 CPPUNIT_ASSERT(pItem);
6162 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6163 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6164 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6165 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6166 pItem = m_pDoc->GetAttr(ScAddress(5, 3, destSheet), ATTR_BORDER);
6167 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
6168 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6169 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6170 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6171 pItem = m_pDoc->GetAttr(ScAddress(6, 3, destSheet), ATTR_BORDER);
6172 CPPUNIT_ASSERT(pItem);
6173 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
6174 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6175 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6176 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6177 pItem = m_pDoc->GetAttr(ScAddress(7, 3, destSheet), ATTR_BORDER);
6178 CPPUNIT_ASSERT(pItem);
6179 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6180 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6181 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6182 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6184 // check notes after transposed copy/paste
6185 // check presence of notes
6186 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
6187 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
6188 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
6189 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
6190 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
6191 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
6192 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
6193 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
6194 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
6195 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
6196 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
6197 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
6198 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
6199 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
6200 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
6201 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
6202 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
6203 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
6204 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
6205 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
6206 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
6207 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
6208 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
6209 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
6210 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
6211 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
6212 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 3, destSheet));
6213 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
6214 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 3, destSheet));
6215 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
6216 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
6217 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
6218 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
6219 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
6220 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
6221 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
6222 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
6223 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
6224 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
6225 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
6227 // check values of notes
6228 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
6229 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
6230 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
6231 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
6232 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 2, destSheet));
6233 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
6234 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 2, destSheet));
6235 if (!bSkipEmpty)
6236 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 2, destSheet));
6237 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 3, destSheet));
6239 // check row 16 on src sheet, refs to copied/cut range
6240 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
6241 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
6242 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
6243 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
6244 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
6245 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
6246 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
6247 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
6248 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
6249 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
6251 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6252 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6253 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6254 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6255 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6256 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6257 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6258 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6259 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6260 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6262 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
6263 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
6264 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
6265 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
6266 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
6267 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
6268 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
6269 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
6270 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
6271 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
6273 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6274 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6275 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6276 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6277 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6278 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6279 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6280 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6281 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6282 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6284 // Existing references to the destination range must not change
6285 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
6286 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
6287 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
6288 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
6289 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
6290 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
6291 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
6292 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
6293 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
6294 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
6295 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
6296 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
6297 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
6298 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
6299 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
6300 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
6301 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
6302 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
6303 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
6304 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
6305 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
6306 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
6307 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
6308 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
6309 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
6310 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
6311 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
6312 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
6313 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
6314 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
6315 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
6316 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
6317 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
6318 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
6319 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
6320 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
6321 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
6322 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
6323 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
6324 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
6325 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
6326 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
6327 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
6328 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
6329 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
6330 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
6331 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
6332 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
6333 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
6335 m_pDoc->DeleteTab(destSheet);
6336 m_pDoc->DeleteTab(srcSheet);
6339 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty)
6341 const SCTAB srcSheet = 0;
6342 const SCTAB destSheet = 1;
6345 | D | E | F | G | H |
6347 2 | 1 B*| 2 B*| 3 B*| 6 | -11 |
6348 3 | =D2+10 *| =E2+20 b | =F5+30 b*| q | -12 |
6349 4 | a | b *| c *| r | -13 |
6350 5 | R1 *| R2 *| 5 *| s | -14 |
6351 6 | =D2+F2+60 | | B*| t | -15 |
6352 7 | =SUMIF(D2:G2;"<4") | *| | u | -16 |
6354 * means note attached
6355 B means background
6356 b means border
6359 //check cell content after transposed copy/paste of filtered data
6360 // Note: column F is a repetition of srcSheet.Column A
6361 // Col C and G are checked to be empty
6362 const EditTextObject* pEditObj;
6363 // row 0
6364 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6365 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6366 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6367 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6368 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6369 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6370 // row 1, numbers
6371 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell C2", 1000.0, m_pDoc->GetValue(2, 1, destSheet));
6372 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
6373 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 2.0, m_pDoc->GetValue(4, 1, destSheet));
6374 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 3.0, m_pDoc->GetValue(5, 1, destSheet));
6375 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2", 6.0, m_pDoc->GetValue(6, 1, destSheet));
6376 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(7, 1, destSheet));
6377 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell I2", 1000.0, m_pDoc->GetValue(8, 1, destSheet));
6378 // row 2, formulas
6379 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6380 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
6381 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
6382 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
6383 m_pDoc->GetFormula(3, 2, destSheet));
6384 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E2+20"),
6385 m_pDoc->GetFormula(4, 2, destSheet));
6386 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 22.0, m_pDoc->GetValue(4, 2, destSheet));
6387 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 35.0, m_pDoc->GetValue(5, 2, destSheet));
6388 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=F5+30"),
6389 m_pDoc->GetFormula(5, 2, destSheet));
6390 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("q"), m_pDoc->GetString(6, 2, destSheet));
6391 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(7, 2, destSheet));
6392 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
6393 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 2, destSheet));
6394 // row 3, strings
6395 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6396 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
6397 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
6398 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("b"), m_pDoc->GetString(4, 3, destSheet));
6399 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("c"), m_pDoc->GetString(5, 3, destSheet));
6400 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("r"), m_pDoc->GetString(6, 3, destSheet));
6401 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(7, 3, destSheet));
6402 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
6403 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 3, destSheet));
6404 // row 4, rich text
6405 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6406 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
6407 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
6408 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
6409 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
6410 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
6411 pEditObj->GetText(0));
6412 pEditObj = m_pDoc->GetEditText(ScAddress(4, 4, destSheet));
6413 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in E5.", pEditObj);
6414 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong E5.", OUString("R2"), pEditObj->GetText(0));
6415 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F5", 5.0, m_pDoc->GetValue(5, 4, destSheet));
6416 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G5", OUString("s"), m_pDoc->GetString(6, 4, destSheet));
6417 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(7, 4, destSheet));
6418 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 4, destSheet));
6419 pEditObj = m_pDoc->GetEditText(ScAddress(8, 4, destSheet));
6420 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in I5.", pEditObj == nullptr);
6421 // row 5, formulas
6422 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6423 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
6424 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
6425 m_pDoc->GetFormula(3, 5, destSheet));
6426 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 64.0, m_pDoc->GetValue(3, 5, destSheet));
6427 if (!bSkipEmpty)
6429 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
6430 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
6432 else
6434 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6435 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
6437 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G6", OUString("t"), m_pDoc->GetString(6, 5, destSheet));
6438 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 5, destSheet));
6439 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
6440 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
6441 // row 6, formulas
6442 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
6443 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
6444 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
6445 m_pDoc->GetFormula(3, 6, destSheet));
6446 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 6.0, m_pDoc->GetValue(3, 6, destSheet));
6447 if (!bSkipEmpty)
6449 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
6450 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 6, destSheet));
6452 else
6454 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
6455 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
6457 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G7", OUString("u"), m_pDoc->GetString(6, 6, destSheet));
6458 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(7, 6, destSheet));
6459 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 6, destSheet));
6460 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 6, destSheet));
6461 // row 7
6462 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
6463 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
6464 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
6465 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
6466 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
6467 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
6469 // check patterns
6470 const SfxPoolItem* pItem = nullptr;
6471 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6472 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
6473 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
6474 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6475 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6476 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
6477 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has blue background", COL_BLUE,
6478 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6479 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6480 CPPUNIT_ASSERT_MESSAGE("F2 has a pattern", pItem);
6481 CPPUNIT_ASSERT_EQUAL_MESSAGE("F2 has a pattern", COL_BLUE,
6482 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6483 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6484 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
6485 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6486 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
6487 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6488 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6489 if (!bSkipEmpty)
6490 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6492 // check border, left and right borders were transformed to top and bottom borders
6493 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
6494 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
6495 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
6496 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6497 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
6498 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6499 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
6500 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6501 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
6502 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6504 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
6505 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6506 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6508 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6509 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6510 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6511 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
6512 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6513 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
6514 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6515 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
6516 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6517 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
6518 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
6519 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6520 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
6521 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6522 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
6523 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6524 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
6525 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6526 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
6527 CPPUNIT_ASSERT_MESSAGE("G3 has top border", !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6528 CPPUNIT_ASSERT_MESSAGE("G3 has bottom border",
6529 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6530 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
6531 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6532 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
6533 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6534 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
6535 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
6536 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
6537 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6538 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
6539 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6540 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
6541 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6542 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
6543 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6545 // check notes after transposed copy/paste
6546 // check presence of notes
6547 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
6548 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
6549 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
6550 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
6551 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
6552 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
6553 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
6554 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
6555 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
6556 CPPUNIT_ASSERT_MESSAGE("F2: a note", m_pDoc->HasNote(5, 1, destSheet));
6557 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
6558 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
6559 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
6560 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
6561 CPPUNIT_ASSERT_MESSAGE("E3: no note", !m_pDoc->HasNote(4, 2, destSheet));
6562 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
6563 CPPUNIT_ASSERT_MESSAGE("G3: no note", !m_pDoc->HasNote(6, 2, destSheet));
6564 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
6565 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
6566 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
6567 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
6568 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
6569 CPPUNIT_ASSERT_MESSAGE("G4: a note", m_pDoc->HasNote(6, 3, destSheet));
6570 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
6571 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
6572 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
6573 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
6574 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
6575 CPPUNIT_ASSERT_MESSAGE("G5: no note", !m_pDoc->HasNote(6, 4, destSheet));
6576 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
6577 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
6578 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
6579 CPPUNIT_ASSERT_MESSAGE("E6: no note", !m_pDoc->HasNote(4, 5, destSheet));
6580 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 5, destSheet));
6581 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
6582 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
6583 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
6584 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
6585 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 6, destSheet));
6586 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
6587 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
6588 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
6589 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
6590 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
6591 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
6592 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
6593 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
6594 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
6596 // check values of notes
6597 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
6598 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A2"), getNote(4, 1, destSheet));
6599 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F2", OUString("Note A3"), getNote(5, 1, destSheet));
6600 // G2 has no note
6601 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
6602 // E3 has no note
6603 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B3"), getNote(5, 2, destSheet));
6604 // D4 has no note
6605 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C2"), getNote(4, 3, destSheet));
6606 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C3"), getNote(5, 3, destSheet));
6607 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
6608 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D2"), getNote(4, 4, destSheet));
6609 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D3"), getNote(5, 4, destSheet));
6610 if (!bSkipEmpty)
6611 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 5, destSheet));
6612 if (!bSkipEmpty)
6613 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString("Note F2"), getNote(4, 6, destSheet));
6614 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(6, 3, destSheet));
6616 // check row 16 on src sheet, refs to copied/cut range
6617 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
6618 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
6619 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
6620 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
6621 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
6622 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
6623 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
6624 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
6625 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
6626 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
6628 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6629 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6630 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6631 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6632 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6633 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6634 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6635 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6636 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6637 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6639 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
6640 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
6641 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
6642 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
6643 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
6644 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
6645 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
6646 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
6647 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
6648 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
6650 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6651 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6652 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6653 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6654 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6655 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6656 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6657 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6658 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6659 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6661 // Existing references to the destination range must not change
6662 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
6663 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
6664 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
6665 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
6666 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
6667 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
6668 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
6669 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
6670 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
6671 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
6672 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
6673 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
6674 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
6675 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
6676 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
6677 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
6678 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
6679 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
6680 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
6681 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
6682 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
6683 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
6684 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
6685 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
6686 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
6687 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
6688 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
6689 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
6690 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
6691 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
6692 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
6693 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
6694 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
6695 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
6696 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
6697 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
6698 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
6699 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
6700 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
6701 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
6702 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
6703 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
6704 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
6705 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
6706 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
6707 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
6708 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
6709 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
6710 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
6712 m_pDoc->DeleteTab(destSheet);
6713 m_pDoc->DeleteTab(srcSheet);
6716 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty)
6718 const SCTAB srcSheet = 0;
6719 const SCTAB destSheet = 1;
6722 | D | E | F | G |
6724 2 | 1 B*| 3 B*| 6 | -11 |
6725 3 | =D2+10 *| =F5+30 b*| q | -12 |
6726 4 | a | c *| r | -13 |
6727 5 | R1 *| 5 *| s | -14 |
6728 6 | =D2+F2+60 | B*| t | -15 |
6729 7 | =SUMIF(D2:G2;"<4") | | u | -16 |
6731 * means note attached
6732 B means background
6733 b means border
6736 //check cell content after transposed copy/paste of filtered data
6737 // Note: column F is a repetition of srcSheet.Column A
6738 // Col C and G are checked to be empty
6739 const EditTextObject* pEditObj;
6740 // row 0
6741 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6742 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6743 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6744 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6745 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6746 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6747 // row 1, numbers
6748 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell C2", 1000.0, m_pDoc->GetValue(2, 1, destSheet));
6749 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
6750 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 3.0, m_pDoc->GetValue(4, 1, destSheet));
6751 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 6.0, m_pDoc->GetValue(5, 1, destSheet));
6752 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(6, 1, destSheet));
6753 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell H2", 1000.0, m_pDoc->GetValue(7, 1, destSheet));
6754 // row 2, formulas
6755 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6756 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
6757 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
6758 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
6759 m_pDoc->GetFormula(3, 2, destSheet));
6760 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 35.0, m_pDoc->GetValue(4, 2, destSheet));
6761 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E5+30"),
6762 m_pDoc->GetFormula(4, 2, destSheet));
6763 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("q"), m_pDoc->GetString(5, 2, destSheet));
6764 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(6, 2, destSheet));
6765 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
6766 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
6767 // row 3, strings
6768 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6769 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
6770 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
6771 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("c"), m_pDoc->GetString(4, 3, destSheet));
6772 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("r"), m_pDoc->GetString(5, 3, destSheet));
6773 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(6, 3, destSheet));
6774 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
6775 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
6776 // row 4, rich text
6777 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6778 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
6779 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
6780 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
6781 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
6782 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
6783 pEditObj->GetText(0));
6784 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E5", 5.0, m_pDoc->GetValue(4, 4, destSheet));
6785 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("s"), m_pDoc->GetString(5, 4, destSheet));
6786 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 4, destSheet));
6787 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
6788 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
6789 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
6790 // row 5, formulas
6791 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6792 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
6793 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
6794 m_pDoc->GetFormula(3, 5, destSheet));
6795 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 67.0, m_pDoc->GetValue(3, 5, destSheet));
6796 if (!bSkipEmpty)
6798 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
6800 else
6801 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6802 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F6", OUString("t"), m_pDoc->GetString(5, 5, destSheet));
6803 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(6, 5, destSheet));
6804 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
6805 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
6806 // row 6, formulas
6807 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
6808 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
6809 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
6810 m_pDoc->GetFormula(3, 6, destSheet));
6811 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", -7.0, m_pDoc->GetValue(3, 6, destSheet));
6812 if (!bSkipEmpty)
6813 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString(), m_pDoc->GetString(4, 6, destSheet));
6814 else
6815 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
6816 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F7", OUString("u"), m_pDoc->GetString(5, 6, destSheet));
6817 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(6, 6, destSheet));
6818 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
6819 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
6820 // row 7
6821 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
6822 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
6823 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
6824 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
6825 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
6826 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
6828 // check patterns
6829 const SfxPoolItem* pItem = nullptr;
6830 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6831 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
6832 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
6833 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6834 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6835 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
6836 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has a pattern", COL_BLUE,
6837 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6838 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6839 CPPUNIT_ASSERT_MESSAGE("F2 has no pattern", !pItem);
6840 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6841 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
6842 m_pDoc->GetPattern(ScAddress(4, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6843 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6844 if (!bSkipEmpty)
6845 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6847 m_pDoc->GetPattern(ScAddress(5, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6848 CPPUNIT_ASSERT(!pItem);
6849 m_pDoc->GetPattern(ScAddress(5, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6850 CPPUNIT_ASSERT(pItem);
6851 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6852 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6853 CPPUNIT_ASSERT(pItem);
6854 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6855 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6856 CPPUNIT_ASSERT(!pItem);
6857 m_pDoc->GetPattern(ScAddress(5, 6, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6858 CPPUNIT_ASSERT(!pItem);
6860 // check border, left and right borders were transformed to top and bottom borders
6861 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
6862 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
6863 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
6864 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6865 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
6866 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6867 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
6868 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6869 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
6870 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6871 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
6872 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6873 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6874 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6875 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6876 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6877 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
6878 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6879 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
6880 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6881 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
6882 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6883 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
6884 CPPUNIT_ASSERT_MESSAGE("F3 has top border", !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6885 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
6886 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6887 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
6888 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6889 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
6890 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6891 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
6892 CPPUNIT_ASSERT_MESSAGE("G3 has a border", pItem);
6893 CPPUNIT_ASSERT_MESSAGE("G3 has no top border",
6894 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6895 CPPUNIT_ASSERT_MESSAGE("G3 has no bottom border",
6896 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6897 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
6898 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6899 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
6900 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6901 pItem = m_pDoc->GetAttr(ScAddress(5, 3, destSheet), ATTR_BORDER);
6902 CPPUNIT_ASSERT(pItem);
6903 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6904 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6905 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6906 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6907 pItem = m_pDoc->GetAttr(ScAddress(5, 4, destSheet), ATTR_BORDER);
6908 CPPUNIT_ASSERT(pItem);
6909 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6910 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6911 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6912 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6914 // check notes after transposed copy/paste
6915 // check presence of notes
6916 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
6917 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
6918 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
6919 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
6920 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
6921 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
6922 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
6923 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
6924 CPPUNIT_ASSERT_MESSAGE("F2: no note", !m_pDoc->HasNote(5, 1, destSheet));
6925 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
6926 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
6927 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
6928 CPPUNIT_ASSERT_MESSAGE("E3: a note", m_pDoc->HasNote(4, 2, destSheet));
6929 CPPUNIT_ASSERT_MESSAGE("F3: no note", !m_pDoc->HasNote(5, 2, destSheet));
6930 CPPUNIT_ASSERT_MESSAGE("G3: no note", !m_pDoc->HasNote(6, 2, destSheet));
6931 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
6932 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
6933 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
6934 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
6935 CPPUNIT_ASSERT_MESSAGE("G4: no note", !m_pDoc->HasNote(6, 3, destSheet));
6936 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
6937 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
6938 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
6939 CPPUNIT_ASSERT_MESSAGE("F5: no note", !m_pDoc->HasNote(5, 4, destSheet));
6940 CPPUNIT_ASSERT_MESSAGE("G5: no note", !m_pDoc->HasNote(6, 4, destSheet));
6941 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
6942 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
6943 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
6944 CPPUNIT_ASSERT_MESSAGE("F6: no note", !m_pDoc->HasNote(5, 5, destSheet));
6945 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
6946 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
6947 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
6948 CPPUNIT_ASSERT_MESSAGE("E7: no note", !m_pDoc->HasNote(4, 6, destSheet));
6949 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
6950 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
6951 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
6952 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
6953 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
6954 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
6955 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
6957 // check values of notes
6958 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
6959 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A3"), getNote(4, 1, destSheet));
6960 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
6961 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("Note B3"), getNote(4, 2, destSheet));
6962 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C3"), getNote(4, 3, destSheet));
6963 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
6964 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D3"), getNote(4, 4, destSheet));
6965 if (!bSkipEmpty)
6966 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 5, destSheet));
6967 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 3, destSheet));
6969 // check row 16 on src sheet, refs to copied/cut range
6970 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
6971 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
6972 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
6973 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
6974 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
6975 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
6976 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
6977 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
6978 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
6979 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
6981 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6982 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6983 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6984 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6985 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6986 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6987 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6988 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6989 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6990 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6992 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
6993 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
6994 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
6995 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
6996 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
6997 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
6998 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
6999 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
7000 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
7001 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
7003 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
7004 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
7005 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
7006 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
7007 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
7008 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
7009 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
7010 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
7011 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
7012 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
7014 // Existing references to the destination range must not change
7015 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
7016 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
7017 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
7018 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
7019 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
7020 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
7021 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
7022 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
7023 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
7024 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
7025 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
7026 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
7027 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
7028 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
7029 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
7030 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
7031 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
7032 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
7033 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
7034 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
7035 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
7036 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
7037 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
7038 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
7039 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
7040 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
7041 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
7042 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
7043 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
7044 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
7045 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
7046 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
7047 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
7048 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
7049 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
7050 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
7051 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
7052 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
7053 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
7054 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
7055 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
7056 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
7057 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
7058 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
7059 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
7060 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
7061 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
7062 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
7063 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
7065 m_pDoc->DeleteTab(destSheet);
7066 m_pDoc->DeleteTab(srcSheet);
7069 void TestCopyPaste::testTdf142201Row()
7071 const SCTAB nTab = 0;
7072 m_pDoc->InsertTab(nTab, "Test");
7074 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7075 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7076 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7077 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7079 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
7080 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
7081 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
7082 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
7084 // Check precondition
7085 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7086 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7087 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7088 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7090 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7091 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7092 printRange(m_pDoc, aReferencesRange, "References");
7093 printFormula(m_pDoc, 0, 3, nTab);
7094 printFormula(m_pDoc, 0, 4, nTab);
7095 printFormula(m_pDoc, 1, 3, nTab);
7096 printFormula(m_pDoc, 1, 4, nTab);
7098 // Cut A1:A2 to the clip document.
7099 ScDocument aClipDoc(SCDOCMODE_CLIP);
7100 ScRange aSrcRange(0, 0, nTab, 0, 1, nTab);
7101 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7103 // To B7:C7
7104 ScRange aDestRange(1, 6, nTab, 2, 6, nTab);
7105 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7107 // Transpose
7108 ScDocument* pOrigClipDoc = &aClipDoc;
7109 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7110 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7111 aDestMark.SetMarkArea(aDestRange);
7112 // Paste
7113 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7114 true, false, true, false);
7115 printRange(m_pDoc, aReferencesRange, "References after cut");
7116 printFormula(m_pDoc, 0, 3, nTab);
7117 printFormula(m_pDoc, 0, 4, nTab);
7118 printFormula(m_pDoc, 1, 3, nTab);
7119 printFormula(m_pDoc, 1, 4, nTab);
7120 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7121 pTransClip.reset();
7123 printRange(m_pDoc, aReferencesRange, "References after cut transposed");
7124 printFormula(m_pDoc, 0, 3, nTab);
7125 printFormula(m_pDoc, 0, 4, nTab);
7126 printFormula(m_pDoc, 1, 3, nTab);
7127 printFormula(m_pDoc, 1, 4, nTab);
7129 // Check results
7130 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7131 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7132 // Without the fix in place, this would have failed with
7133 // - Expected: 11
7134 // - Actual : 2
7135 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7136 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7138 CPPUNIT_ASSERT_EQUAL(OUString("=B7"), m_pDoc->GetFormula(0, 3, nTab));
7139 CPPUNIT_ASSERT_EQUAL(OUString("=C7"), m_pDoc->GetFormula(0, 4, nTab));
7140 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(1, 3, nTab));
7141 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(1, 4, nTab));
7144 void TestCopyPaste::testTdf142201ColRel()
7146 const SCTAB nTab = 0;
7147 m_pDoc->InsertTab(nTab, "Test");
7149 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7150 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7151 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7152 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7154 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
7155 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
7156 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
7157 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
7159 // Check precondition
7160 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7161 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7162 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7163 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7165 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7166 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7167 printRange(m_pDoc, aReferencesRange, "References");
7168 printFormula(m_pDoc, 0, 3, nTab);
7169 printFormula(m_pDoc, 0, 4, nTab);
7170 printFormula(m_pDoc, 1, 3, nTab);
7171 printFormula(m_pDoc, 1, 4, nTab);
7173 // Cut values A1:B1 to the clip document.
7174 ScDocument aClipDoc(SCDOCMODE_CLIP);
7175 ScRange aSrcRange(0, 0, nTab, 1, 0, nTab);
7176 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7178 // To B7:B8
7179 ScRange aDestRange(1, 6, nTab, 1, 7, nTab);
7180 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7182 // Transpose
7183 ScDocument* pOrigClipDoc = &aClipDoc;
7184 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7185 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7186 aDestMark.SetMarkArea(aDestRange);
7187 // Paste
7188 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7189 true, false, true, false);
7190 printRange(m_pDoc, aReferencesRange, "References after paste");
7191 printFormula(m_pDoc, 0, 3, nTab);
7192 printFormula(m_pDoc, 0, 4, nTab);
7193 printFormula(m_pDoc, 1, 3, nTab);
7194 printFormula(m_pDoc, 1, 4, nTab);
7195 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7196 pTransClip.reset();
7198 printRange(m_pDoc, aReferencesRange, "References after paste transposed");
7199 printFormula(m_pDoc, 0, 3, nTab);
7200 printFormula(m_pDoc, 0, 4, nTab);
7201 printFormula(m_pDoc, 1, 3, nTab);
7202 printFormula(m_pDoc, 1, 4, nTab);
7204 // Check results
7205 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7206 // Without the fix in place, this would have failed with
7207 // - Expected: 2
7208 // - Actual : 11
7209 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7210 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7211 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7213 CPPUNIT_ASSERT_EQUAL(OUString("=B7"), m_pDoc->GetFormula(0, 3, nTab));
7214 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(0, 4, nTab));
7215 CPPUNIT_ASSERT_EQUAL(OUString("=B8"), m_pDoc->GetFormula(1, 3, nTab));
7216 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(1, 4, nTab));
7219 void TestCopyPaste::testTdf142201ColAbs()
7221 const SCTAB nTab = 0;
7222 m_pDoc->InsertTab(nTab, "Test");
7224 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7225 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7226 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7227 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7229 m_pDoc->SetString(0, 3, nTab, "=$A$1"); // A4
7230 m_pDoc->SetString(0, 4, nTab, "=$A$2"); // A5
7231 m_pDoc->SetString(1, 3, nTab, "=$B$1"); // B4
7232 m_pDoc->SetString(1, 4, nTab, "=$B$2"); // B5
7234 // Check precondition
7235 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7236 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7237 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7238 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7240 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7241 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7242 printRange(m_pDoc, aReferencesRange, "References");
7243 printFormula(m_pDoc, 0, 3, nTab);
7244 printFormula(m_pDoc, 0, 4, nTab);
7245 printFormula(m_pDoc, 1, 3, nTab);
7246 printFormula(m_pDoc, 1, 4, nTab);
7248 // Cut values A1:B1 to the clip document.
7249 ScDocument aClipDoc(SCDOCMODE_CLIP);
7250 ScRange aSrcRange(0, 0, nTab, 1, 0, nTab);
7251 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7253 // To B7:B8
7254 ScRange aDestRange(1, 6, nTab, 1, 7, nTab);
7255 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7257 // Transpose
7258 ScDocument* pOrigClipDoc = &aClipDoc;
7259 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7260 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7261 aDestMark.SetMarkArea(aDestRange);
7262 // Paste
7263 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7264 true, false, true, false);
7265 printRange(m_pDoc, aReferencesRange, "References after paste");
7266 printFormula(m_pDoc, 0, 3, nTab);
7267 printFormula(m_pDoc, 0, 4, nTab);
7268 printFormula(m_pDoc, 1, 3, nTab);
7269 printFormula(m_pDoc, 1, 4, nTab);
7270 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7271 pTransClip.reset();
7273 printRange(m_pDoc, aReferencesRange, "References after paste transposed");
7274 printFormula(m_pDoc, 0, 3, nTab);
7275 printFormula(m_pDoc, 0, 4, nTab);
7276 printFormula(m_pDoc, 1, 3, nTab);
7277 printFormula(m_pDoc, 1, 4, nTab);
7279 // Check results
7280 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7281 // Without the fix in place, this would have failed with
7282 // - Expected: 2
7283 // - Actual : 11
7284 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7285 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7286 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7288 CPPUNIT_ASSERT_EQUAL(OUString("=$B$7"), m_pDoc->GetFormula(0, 3, nTab));
7289 CPPUNIT_ASSERT_EQUAL(OUString("=$A$2"), m_pDoc->GetFormula(0, 4, nTab));
7290 CPPUNIT_ASSERT_EQUAL(OUString("=$B$8"), m_pDoc->GetFormula(1, 3, nTab));
7291 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), m_pDoc->GetFormula(1, 4, nTab));
7294 void TestCopyPaste::checkReferencedCutRangesRowIntitial(const SCTAB nSrcTab, const OUString& rDesc)
7296 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 3, 2, nSrcTab), rDesc.toUtf8() + ": Source");
7297 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(1, 1, nSrcTab));
7298 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 1, nSrcTab));
7299 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(3, 1, nSrcTab));
7300 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7301 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7302 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7304 // Guards
7305 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7306 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7307 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7308 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7309 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7310 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7311 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7312 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7313 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7314 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7315 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7316 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7317 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7318 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7319 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7320 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7321 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7322 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7323 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7324 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7325 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7326 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7327 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7328 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7329 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7330 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7331 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7332 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7333 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
7334 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
7335 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
7336 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
7337 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), m_pDoc->GetFormula(24, 0, nSrcTab)); // Y1
7338 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
7339 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), m_pDoc->GetFormula(24, 1, nSrcTab)); // Y2
7340 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
7341 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), m_pDoc->GetFormula(24, 2, nSrcTab)); // Y3
7342 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
7343 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(21, 3, nSrcTab)); // B4
7344 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(22, 3, nSrcTab)); // W4
7345 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
7346 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), m_pDoc->GetFormula(24, 3, nSrcTab)); // Y4
7348 for (int i = 10; i < 20; ++i)
7349 for (int j = 0; j < 10; ++j)
7351 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(j, i, nSrcTab));
7352 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(j, i, nSrcTab));
7355 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7356 rDesc.toUtf8() + ": Relative references");
7357 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
7358 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
7359 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(2, 20, nSrcTab)); // C21
7360 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
7361 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
7362 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(2, 21, nSrcTab)); // C22
7363 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7364 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7365 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7366 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7367 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7368 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7370 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 30, nSrcTab, 2, 31, nSrcTab),
7371 rDesc.toUtf8() + ": Absolute references");
7372 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
7373 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
7374 CPPUNIT_ASSERT_EQUAL(OUString("=$D$2"), m_pDoc->GetFormula(2, 30, nSrcTab)); // C31
7375 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
7376 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
7377 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), m_pDoc->GetFormula(2, 31, nSrcTab)); // C32
7378 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7379 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7380 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7381 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7382 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7383 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7385 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2"), getRangeByName("Range_B2"));
7386 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
7387 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$2"), getRangeByName("Range_D2"));
7388 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3"));
7389 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
7390 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3"));
7391 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$2"), getRangeByName("Range_B2_D2"));
7392 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3"));
7393 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3"));
7394 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
7396 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 40, nSrcTab, 2, 41, nSrcTab),
7397 rDesc.toUtf8() + ": Absolute ranges");
7398 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
7399 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
7400 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), m_pDoc->GetFormula(2, 40, nSrcTab)); // C41
7401 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
7402 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
7403 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), m_pDoc->GetFormula(2, 41, nSrcTab)); // C42
7404 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7405 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7406 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7407 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7408 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7409 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7411 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 50, nSrcTab, 2, 51, nSrcTab),
7412 rDesc.toUtf8() + ": Relative ranges");
7413 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
7414 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
7415 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 50, nSrcTab)); // C51
7416 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
7417 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
7418 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 51, nSrcTab)); // C52
7419 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7420 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7421 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7422 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7423 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7424 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7426 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 60, nSrcTab, 2, 61, nSrcTab),
7427 rDesc.toUtf8() + ": Relative sum");
7428 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
7429 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
7430 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), m_pDoc->GetFormula(2, 60, nSrcTab)); // C61
7431 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
7432 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
7433 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(2, 61, nSrcTab)); // C62
7434 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7435 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7436 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7437 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7438 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7439 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7441 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 70, nSrcTab, 2, 71, nSrcTab),
7442 rDesc.toUtf8() + ": Absolute sum");
7443 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
7444 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
7445 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), m_pDoc->GetFormula(2, 70, nSrcTab)); // C71
7446 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
7447 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
7448 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(2, 71, nSrcTab)); // C72
7449 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7450 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7451 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7452 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7453 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7454 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7456 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 80, nSrcTab, 2, 81, nSrcTab),
7457 rDesc.toUtf8() + ": Relative range sum");
7458 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
7459 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
7460 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(2, 80, nSrcTab)); // C81
7461 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
7462 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
7463 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(2, 81, nSrcTab)); // C82
7464 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7465 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7466 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7467 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7468 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7469 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7471 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 90, nSrcTab, 2, 91, nSrcTab),
7472 rDesc.toUtf8() + ": Absolute sum");
7473 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
7474 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
7475 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 90, nSrcTab)); // C91
7476 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
7477 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
7478 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 91, nSrcTab)); // C92
7479 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 90, nSrcTab));
7480 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 90, nSrcTab));
7481 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 90, nSrcTab));
7482 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 91, nSrcTab));
7483 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 91, nSrcTab));
7484 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 91, nSrcTab));
7486 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 100, nSrcTab, 2, 101, nSrcTab),
7487 rDesc.toUtf8() + ": Relative range sum");
7488 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7489 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
7490 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7491 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
7492 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7493 m_pDoc->GetFormula(2, 100, nSrcTab)); // C101
7494 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7495 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
7496 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7497 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
7498 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7499 m_pDoc->GetFormula(2, 101, nSrcTab)); // C102
7500 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 100, nSrcTab));
7501 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 100, nSrcTab));
7502 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 100, nSrcTab));
7503 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 101, nSrcTab));
7504 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 101, nSrcTab));
7505 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 101, nSrcTab));
7508 void TestCopyPaste::executeReferencedCutRangesRow(const bool bTransposed, const SCTAB nSrcTab,
7509 const SCTAB nDestTab, const bool bUndo,
7510 std::unique_ptr<ScUndoCut>& pUndoCut,
7511 std::unique_ptr<ScUndoPaste>& pUndoPaste)
7513 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
7515 for (int i = 0; i < nSrcTab; ++i)
7516 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7517 m_pDoc->InsertTab(nSrcTab, "Test");
7519 m_pDoc->SetValue(1, 1, nSrcTab, 01.0); // B2 \.
7520 m_pDoc->SetValue(2, 1, nSrcTab, 11.0); // C2 | cut
7521 m_pDoc->SetValue(3, 1, nSrcTab, 21.0); // D2 /
7522 m_pDoc->SetValue(1, 2, nSrcTab, 02.0); // B3
7523 m_pDoc->SetValue(2, 2, nSrcTab, 12.0); // C3
7524 m_pDoc->SetValue(3, 2, nSrcTab, 22.0); // D3
7525 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 3, 2, nSrcTab), "Source");
7527 // Guard values
7528 m_pDoc->SetValue(0, 0, nSrcTab, 1000.0); // A1
7529 m_pDoc->SetValue(1, 0, nSrcTab, 1001.0); // B1
7530 m_pDoc->SetValue(2, 0, nSrcTab, 1002.0); // C1
7531 m_pDoc->SetValue(3, 0, nSrcTab, 1003.0); // D1
7532 m_pDoc->SetValue(4, 0, nSrcTab, 1004.0); // E1
7533 m_pDoc->SetValue(0, 1, nSrcTab, 1010.0); // A2
7534 m_pDoc->SetValue(4, 1, nSrcTab, 1014.0); // E2
7535 m_pDoc->SetValue(0, 2, nSrcTab, 1020.0); // A3
7536 m_pDoc->SetValue(4, 2, nSrcTab, 1024.0); // E3
7537 m_pDoc->SetValue(0, 3, nSrcTab, 1030.0); // A4
7538 m_pDoc->SetValue(1, 3, nSrcTab, 1031.0); // B4
7539 m_pDoc->SetValue(2, 3, nSrcTab, 1032.0); // C4
7540 m_pDoc->SetValue(3, 3, nSrcTab, 1033.0); // D4
7541 m_pDoc->SetValue(4, 3, nSrcTab, 1034.0); // E4
7543 m_pDoc->SetString(20, 0, nSrcTab, "=A1"); // U1
7544 m_pDoc->SetString(21, 0, nSrcTab, "=B1"); // V1
7545 m_pDoc->SetString(22, 0, nSrcTab, "=C1"); // W1
7546 m_pDoc->SetString(23, 0, nSrcTab, "=D1"); // X1
7547 m_pDoc->SetString(24, 0, nSrcTab, "=E1"); // Y1
7548 m_pDoc->SetString(20, 1, nSrcTab, "=A2"); // U2
7549 m_pDoc->SetString(24, 1, nSrcTab, "=E2"); // Y2
7550 m_pDoc->SetString(20, 2, nSrcTab, "=A3"); // U3
7551 m_pDoc->SetString(24, 2, nSrcTab, "=E3"); // Y3
7552 m_pDoc->SetString(20, 3, nSrcTab, "=A4"); // U4
7553 m_pDoc->SetString(21, 3, nSrcTab, "=B4"); // B4
7554 m_pDoc->SetString(22, 3, nSrcTab, "=C4"); // W4
7555 m_pDoc->SetString(23, 3, nSrcTab, "=D4"); // X4
7556 m_pDoc->SetString(24, 3, nSrcTab, "=E4"); // Y4
7558 // Cell position is used for ranges relative to current position
7559 ScAddress cellA1(0, 0, nSrcTab);
7560 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2", cellA1, "$Test.$B$2"));
7561 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2", cellA1, "$Test.$C$2"));
7562 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_D2", cellA1, "$Test.$D$2"));
7563 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3", cellA1, "$Test.$B$3"));
7564 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C3", cellA1, "$Test.$C$3"));
7565 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_D3", cellA1, "$Test.$D$3"));
7566 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_D2", cellA1, "$Test.$B$2:$D$2"));
7567 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3_D3", cellA1, "$Test.$B$3:$D$3"));
7568 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_D3", cellA1, "$Test.$B$2:$D$3"));
7569 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("RelRange_Cm20_R0", ScAddress(1, 21, nSrcTab), "B2"));
7571 m_pDoc->SetString(0, 20, nSrcTab, "=B2"); // A21
7572 m_pDoc->SetString(1, 20, nSrcTab, "=C2"); // B21
7573 m_pDoc->SetString(2, 20, nSrcTab, "=D2"); // C21
7574 m_pDoc->SetString(0, 21, nSrcTab, "=B3"); // A22
7575 m_pDoc->SetString(1, 21, nSrcTab, "=C3"); // B22
7576 m_pDoc->SetString(2, 21, nSrcTab, "=D3"); // C22
7578 m_pDoc->SetString(0, 30, nSrcTab, "=$B$2"); // A31
7579 m_pDoc->SetString(1, 30, nSrcTab, "=$C$2"); // B31
7580 m_pDoc->SetString(2, 30, nSrcTab, "=$D$2"); // C31
7581 m_pDoc->SetString(0, 31, nSrcTab, "=$B$3"); // A32
7582 m_pDoc->SetString(1, 31, nSrcTab, "=$C$3"); // B32
7583 m_pDoc->SetString(2, 31, nSrcTab, "=$D$3"); // C32
7585 m_pDoc->SetString(0, 40, nSrcTab, "=Range_B2"); // A41
7586 m_pDoc->SetString(1, 40, nSrcTab, "=Range_C2"); // B41
7587 m_pDoc->SetString(2, 40, nSrcTab, "=Range_D2"); // C41
7588 m_pDoc->SetString(0, 41, nSrcTab, "=Range_B3"); // A42
7589 m_pDoc->SetString(1, 41, nSrcTab, "=Range_C3"); // B42
7590 m_pDoc->SetString(2, 41, nSrcTab, "=Range_D3"); // C42
7592 m_pDoc->SetString(0, 50, nSrcTab, "=RelRange_Cm20_R0"); // A51
7593 m_pDoc->SetString(1, 50, nSrcTab, "=RelRange_Cm20_R0"); // B51
7594 m_pDoc->SetString(2, 50, nSrcTab, "=RelRange_Cm20_R0"); // C51
7595 m_pDoc->SetString(0, 51, nSrcTab, "=RelRange_Cm20_R0"); // A52
7596 m_pDoc->SetString(1, 51, nSrcTab, "=RelRange_Cm20_R0"); // B52
7597 m_pDoc->SetString(2, 51, nSrcTab, "=RelRange_Cm20_R0"); // C52
7599 m_pDoc->SetString(0, 60, nSrcTab, "=SUM(B2:D2)"); // A61
7600 m_pDoc->SetString(1, 60, nSrcTab, "=SUM(B2:D2)"); // B61
7601 m_pDoc->SetString(2, 60, nSrcTab, "=SUM(B2:D2)"); // C61
7602 m_pDoc->SetString(0, 61, nSrcTab, "=SUM(B3:D3)"); // A62
7603 m_pDoc->SetString(1, 61, nSrcTab, "=SUM(B3:D3)"); // B62
7604 m_pDoc->SetString(2, 61, nSrcTab, "=SUM(B3:D3)"); // C62
7606 m_pDoc->SetString(0, 70, nSrcTab, "=SUM($B$2:$D$2)"); // A71
7607 m_pDoc->SetString(1, 70, nSrcTab, "=SUM($B$2:$D$2)"); // B71
7608 m_pDoc->SetString(2, 70, nSrcTab, "=SUM($B$2:$D$2)"); // C71
7609 m_pDoc->SetString(0, 71, nSrcTab, "=SUM($B$3:$D$3)"); // A72
7610 m_pDoc->SetString(1, 71, nSrcTab, "=SUM($B$3:$D$3)"); // B72
7611 m_pDoc->SetString(2, 71, nSrcTab, "=SUM($B$3:$D$3)"); // C72
7613 m_pDoc->SetString(0, 80, nSrcTab, "=SUM(Range_B2_D2)"); // A81
7614 m_pDoc->SetString(1, 80, nSrcTab, "=SUM(Range_B2_D2)"); // B81
7615 m_pDoc->SetString(2, 80, nSrcTab, "=SUM(Range_B2_D2)"); // C81
7616 m_pDoc->SetString(0, 81, nSrcTab, "=SUM(Range_B3_D3)"); // A82
7617 m_pDoc->SetString(1, 81, nSrcTab, "=SUM(Range_B3_D3)"); // B82
7618 m_pDoc->SetString(2, 81, nSrcTab, "=SUM(Range_B3_D3)"); // C82
7620 m_pDoc->SetString(0, 90, nSrcTab, "=SUM($B$2:$D$3)"); // A91
7621 m_pDoc->SetString(1, 90, nSrcTab, "=SUM($B$2:$D$3)"); // B91
7622 m_pDoc->SetString(2, 90, nSrcTab, "=SUM($B$2:$D$3)"); // C91
7623 m_pDoc->SetString(0, 91, nSrcTab, "=SUM($B$2:$D$3)"); // A92
7624 m_pDoc->SetString(1, 91, nSrcTab, "=SUM($B$2:$D$3)"); // B92
7625 m_pDoc->SetString(2, 91, nSrcTab, "=SUM($B$2:$D$3)"); // C92
7627 m_pDoc->SetString(0, 100, nSrcTab, "=SUM(Range_B2_D3)"); // A101
7628 m_pDoc->SetString(1, 100, nSrcTab, "=SUM(Range_B2_D3)"); // B101
7629 m_pDoc->SetString(2, 100, nSrcTab, "=SUM(Range_B2_D3)"); // C101
7630 m_pDoc->SetString(0, 101, nSrcTab, "=SUM(Range_B2_D3)"); // A102
7631 m_pDoc->SetString(1, 101, nSrcTab, "=SUM(Range_B2_D3)"); // B102
7632 m_pDoc->SetString(2, 101, nSrcTab, "=SUM(Range_B2_D3)"); // C102
7634 // Check precondition
7635 checkReferencedCutRangesRowIntitial(nSrcTab, "Initial");
7637 // Cut values B2:D2 to the clip document.
7638 ScDocument aClipDoc(SCDOCMODE_CLIP);
7639 ScRange aSrcRange(1, 1, nSrcTab, 3, 1, nSrcTab);
7640 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
7641 aSrcMark.SetMarkArea(aSrcRange);
7643 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, bUndo));
7645 for (int i = nSrcTab + 1; i < nDestTab; ++i)
7646 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7648 if (nSrcTab < nDestTab)
7649 m_pDoc->InsertTab(nDestTab, "Dest");
7650 else if (nSrcTab > nDestTab)
7651 m_pDoc->RenameTab(nDestTab, "Dest");
7653 int nTabCount = m_pDoc->GetTableCount();
7654 for (int i = nTabCount; i < nTabCount + 2; ++i)
7655 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7656 nTabCount = m_pDoc->GetTableCount();
7658 InsertDeleteFlags aFlags(InsertDeleteFlags::ALL);
7660 ScDocumentUniquePtr pPasteUndoDoc;
7661 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
7662 std::unique_ptr<ScRefUndoData> pUndoData;
7664 ScRange aDestRange;
7665 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7667 if (bTransposed)
7669 // To C12:C14
7670 aDestRange = ScRange(2, 11, nDestTab, 2, 13, nDestTab);
7671 aDestMark.SetMarkArea(aDestRange);
7673 if (bUndo)
7674 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
7675 pUndoData);
7677 // Transpose
7678 ScDocument* pOrigClipDoc = &aClipDoc;
7679 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7680 aClipDoc.TransposeClip(pTransClip.get(), aFlags, false, true);
7681 // Paste
7682 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
7683 pTransClip.get(), true, false, true, false);
7684 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7685 "Relative references after copy");
7687 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, pPasteRefUndoDoc.get());
7688 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7689 "Relative references after UpdateTranspose");
7690 pTransClip.reset();
7692 else
7694 // To C12:E12
7695 aDestRange = ScRange(2, 11, nDestTab, 4, 11, nDestTab);
7697 aDestMark.SetMarkArea(aDestRange);
7699 if (bUndo)
7700 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
7701 pUndoData);
7703 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc, true,
7704 false, false, false);
7707 if (bUndo)
7708 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
7709 pUndoPaste, bTransposed);
7712 void TestCopyPaste::checkReferencedCutRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab)
7714 // Cut B2:D2 and pasted to C12:E12
7716 OUString aFBase("=");
7717 if (nSrcTab != nDestTab)
7718 aFBase += "Dest.";
7720 // Precondition
7721 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab));
7722 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 11, nDestTab));
7723 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(4, 11, nDestTab));
7724 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7725 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7726 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7728 // Guards
7729 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7730 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7731 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7732 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7733 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7734 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7735 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7736 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7737 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7738 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7739 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7740 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7741 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7742 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7743 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7744 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7745 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7746 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7747 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7748 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7749 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7750 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7751 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7752 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7753 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7754 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7755 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7756 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7757 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
7758 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
7759 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
7760 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
7761 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), m_pDoc->GetFormula(24, 0, nSrcTab)); // Y1
7762 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
7763 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), m_pDoc->GetFormula(24, 1, nSrcTab)); // Y2
7764 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
7765 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), m_pDoc->GetFormula(24, 2, nSrcTab)); // Y3
7766 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
7767 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(21, 3, nSrcTab)); // B4
7768 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(22, 3, nSrcTab)); // W4
7769 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
7770 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), m_pDoc->GetFormula(24, 3, nSrcTab)); // Y4
7772 // Note: Values (mostly) remain the same
7774 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
7775 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
7776 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 20, nSrcTab)); // C21
7777 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
7778 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
7779 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(2, 21, nSrcTab)); // C22
7780 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7781 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7782 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7783 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7784 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7785 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7787 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
7788 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$D$12"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
7789 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$E$12"), m_pDoc->GetFormula(2, 30, nSrcTab)); // C31
7790 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
7791 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
7792 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), m_pDoc->GetFormula(2, 31, nSrcTab)); // C32
7793 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7794 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7795 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7796 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7797 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7798 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7800 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
7801 getRangeByName("Range_B2"));
7802 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$D$12") : OUString("$Test.$D$12"),
7803 getRangeByName("Range_C2"));
7804 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$E$12") : OUString("$Test.$E$12"),
7805 getRangeByName("Range_D2"));
7806 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3")); // no change
7807 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3")); // no change
7808 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3")); // no change
7809 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$E$12")
7810 : OUString("$Test.$C$12:$E$12"),
7811 getRangeByName("Range_B2_D2"));
7812 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3")); // no change
7813 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3")); // no change
7814 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0")); // no change
7816 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
7817 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
7818 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), m_pDoc->GetFormula(2, 40, nSrcTab)); // C41
7819 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
7820 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
7821 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), m_pDoc->GetFormula(2, 41, nSrcTab)); // C42
7822 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7823 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7824 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7825 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7826 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7827 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7829 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
7830 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
7831 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 50, nSrcTab)); // C51
7832 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
7833 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
7834 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 51, nSrcTab)); // C52
7835 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7836 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7837 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7838 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7839 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7840 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7842 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7843 : OUString("=SUM(C12:E12)"),
7844 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
7845 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7846 : OUString("=SUM(C12:E12)"),
7847 m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
7848 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7849 : OUString("=SUM(C12:E12)"),
7850 m_pDoc->GetFormula(2, 60, nSrcTab)); // C61
7851 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
7852 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
7853 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(2, 61, nSrcTab)); // C62
7854 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7855 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7856 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7857 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7858 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7859 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7861 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7862 : OUString("=SUM($C$12:$E$12)"),
7863 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
7864 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7865 : OUString("=SUM($C$12:$E$12)"),
7866 m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
7867 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7868 : OUString("=SUM($C$12:$E$12)"),
7869 m_pDoc->GetFormula(2, 70, nSrcTab)); // C71
7870 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
7871 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
7872 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(2, 71, nSrcTab)); // C72
7873 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7874 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7875 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7876 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7877 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7878 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7880 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
7881 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
7882 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(2, 80, nSrcTab)); // C81
7883 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
7884 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
7885 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(2, 81, nSrcTab)); // C82
7886 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7887 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7888 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7889 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7890 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7891 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7893 // no change in formula after cut
7894 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
7895 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
7896 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 90, nSrcTab)); // C91
7897 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
7898 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
7899 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 91, nSrcTab)); // C92
7900 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab)); // only 2nd row
7901 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab)); // only 2nd row
7902 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 90, nSrcTab)); // only 2nd row
7903 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab)); // only 2nd row
7904 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab)); // only 2nd row
7905 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 91, nSrcTab)); // only 2nd row
7907 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7908 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
7909 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7910 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
7911 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7912 m_pDoc->GetFormula(2, 100, nSrcTab)); // C101
7913 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7914 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
7915 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7916 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
7917 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7918 m_pDoc->GetFormula(2, 101, nSrcTab)); // C102
7919 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab)); // only 2nd row
7920 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab)); // only 2nd row
7921 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 100, nSrcTab)); // only 2nd row
7922 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab)); // only 2nd row
7923 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab)); // only 2nd row
7924 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 101, nSrcTab)); // only 2nd row
7927 void TestCopyPaste::checkReferencedCutTransposedRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab)
7929 // Cut B2:D2 and pasted transposed to C12:C14
7931 OUString aFBase("=");
7932 if (nSrcTab != nDestTab)
7933 aFBase += "Dest.";
7935 // Precondition
7936 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab));
7937 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 12, nDestTab));
7938 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 13, nDestTab));
7939 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7940 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7941 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7943 // Guards
7944 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7945 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7946 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7947 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7948 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7949 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7950 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7951 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7952 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7953 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7954 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7955 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7956 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7957 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7958 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7959 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7960 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7961 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7962 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7963 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7964 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7965 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7966 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7967 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7968 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7969 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7970 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7971 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7972 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
7973 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
7974 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
7975 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
7976 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), m_pDoc->GetFormula(24, 0, nSrcTab)); // Y1
7977 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
7978 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), m_pDoc->GetFormula(24, 1, nSrcTab)); // Y2
7979 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
7980 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), m_pDoc->GetFormula(24, 2, nSrcTab)); // Y3
7981 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
7982 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(21, 3, nSrcTab)); // B4
7983 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(22, 3, nSrcTab)); // W4
7984 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
7985 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), m_pDoc->GetFormula(24, 3, nSrcTab)); // Y4
7987 // Note: Values (mostly) remain the same
7989 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7990 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7991 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7992 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7993 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7994 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7996 // ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 20, nSrcTab), "C12", "Wrong reference");
7997 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab));
7998 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(1, 20, nSrcTab));
7999 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(2, 20, nSrcTab));
8000 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab));
8001 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab));
8002 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(2, 21, nSrcTab));
8004 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8005 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
8006 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
8007 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
8008 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8009 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
8011 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab));
8012 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$13"), m_pDoc->GetFormula(1, 30, nSrcTab));
8013 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$14"), m_pDoc->GetFormula(2, 30, nSrcTab));
8014 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab));
8015 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab));
8016 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), m_pDoc->GetFormula(2, 31, nSrcTab));
8018 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8019 getRangeByName("Range_B2"));
8020 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$13") : OUString("$Test.$C$13"),
8021 getRangeByName("Range_C2"));
8022 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$14") : OUString("$Test.$C$14"),
8023 getRangeByName("Range_D2"));
8024 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3")); // no change
8025 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3")); // no change
8026 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3")); // no change
8027 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$C$14")
8028 : OUString("$Test.$C$12:$C$14"),
8029 getRangeByName("Range_B2_D2"));
8030 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3")); // no change
8031 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3")); // no change
8032 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0")); // no change
8034 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
8035 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
8036 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), m_pDoc->GetFormula(2, 40, nSrcTab)); // C41
8037 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
8038 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
8039 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), m_pDoc->GetFormula(2, 41, nSrcTab)); // C42
8040 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8041 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
8042 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
8043 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
8044 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8045 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
8047 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
8048 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
8049 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 50, nSrcTab)); // C51
8050 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
8051 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
8052 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 51, nSrcTab)); // C52
8053 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8054 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
8055 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
8056 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
8057 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8058 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
8060 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8061 : OUString("=SUM(C12:C14)"),
8062 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
8063 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8064 : OUString("=SUM(C12:C14)"),
8065 m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
8066 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8067 : OUString("=SUM(C12:C14)"),
8068 m_pDoc->GetFormula(2, 60, nSrcTab)); // C61
8069 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
8070 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
8071 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(2, 61, nSrcTab)); // C62
8072 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8073 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
8074 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
8075 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
8076 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8077 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
8079 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8080 : OUString("=SUM($C$12:$C$14)"),
8081 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
8082 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8083 : OUString("=SUM($C$12:$C$14)"),
8084 m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
8085 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8086 : OUString("=SUM($C$12:$C$14)"),
8087 m_pDoc->GetFormula(2, 70, nSrcTab)); // C71
8088 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
8089 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
8090 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(2, 71, nSrcTab)); // C72
8091 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8092 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
8093 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
8094 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
8095 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8096 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
8098 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
8099 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
8100 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(2, 80, nSrcTab)); // C81
8101 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
8102 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
8103 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(2, 81, nSrcTab)); // C82
8104 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8105 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
8106 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
8107 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
8108 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8109 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
8111 // no change in formula after cut
8112 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
8113 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
8114 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 90, nSrcTab)); // C91
8115 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
8116 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
8117 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 91, nSrcTab)); // C92
8118 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab)); // only 2nd row
8119 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab)); // only 2nd row
8120 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 90, nSrcTab)); // only 2nd row
8121 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab)); // only 2nd row
8122 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab)); // only 2nd row
8123 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 91, nSrcTab)); // only 2nd row
8125 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
8126 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
8127 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
8128 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
8129 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
8130 m_pDoc->GetFormula(2, 100, nSrcTab)); // C101
8131 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
8132 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
8133 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
8134 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
8135 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
8136 m_pDoc->GetFormula(2, 101, nSrcTab)); // C102
8137 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab)); // only 2nd row
8138 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab)); // only 2nd row
8139 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 100, nSrcTab)); // only 2nd row
8140 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab)); // only 2nd row
8141 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab)); // only 2nd row
8142 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 101, nSrcTab)); // only 2nd row
8145 void TestCopyPaste::testReferencedCutRangesRow()
8147 const SCTAB nSrcTab = 0;
8148 const SCTAB nDestTab = 2;
8149 std::unique_ptr<ScUndoCut> pUndoCut;
8150 std::unique_ptr<ScUndoPaste> pUndoPaste;
8151 executeReferencedCutRangesRow(false, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8152 checkReferencedCutRangesRow(nSrcTab, nDestTab);
8154 pUndoPaste->Undo();
8155 pUndoCut->Undo();
8156 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8158 pUndoCut->Redo();
8159 pUndoPaste->Redo();
8160 checkReferencedCutRangesRow(nSrcTab, nDestTab);
8162 pUndoPaste->Undo();
8163 pUndoCut->Undo();
8164 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8166 pUndoPaste.reset();
8167 pUndoCut.reset();
8169 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
8170 m_pDoc->DeleteTab(i - 1);
8173 // tdf#142201
8174 void TestCopyPaste::testReferencedCutTransposedRangesRowTab0To0()
8176 checkReferencedCutTransposedRangesRowUndo(0, 0);
8179 // tdf#142201
8180 void TestCopyPaste::testReferencedCutTransposedRangesRowTab0To1()
8182 checkReferencedCutTransposedRangesRowUndo(0, 1);
8185 // tdf#142201
8186 void TestCopyPaste::testReferencedCutTransposedRangesRowTab1To3()
8188 checkReferencedCutTransposedRangesRowUndo(1, 3);
8191 // tdf#142201
8192 void TestCopyPaste::testReferencedCutTransposedRangesRowTab3To1()
8194 checkReferencedCutTransposedRangesRowUndo(3, 1);
8197 // tdf#142201
8198 void TestCopyPaste::checkReferencedCutTransposedRangesRowUndo(const SCTAB nSrcTab,
8199 const SCTAB nDestTab)
8201 std::unique_ptr<ScUndoCut> pUndoCut;
8202 std::unique_ptr<ScUndoPaste> pUndoPaste;
8203 executeReferencedCutRangesRow(true, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8204 checkReferencedCutTransposedRangesRow(nSrcTab, nDestTab);
8206 pUndoPaste->Undo();
8207 pUndoCut->Undo();
8208 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8210 pUndoCut->Redo();
8211 pUndoPaste->Redo();
8212 checkReferencedCutTransposedRangesRow(nSrcTab, nDestTab);
8214 pUndoPaste->Undo();
8215 pUndoCut->Undo();
8216 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8218 pUndoPaste.reset();
8219 pUndoCut.reset();
8221 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
8222 m_pDoc->DeleteTab(i - 1);
8225 void TestCopyPaste::checkReferencedCutRangesColIntitial(const SCTAB nSrcTab, const SCTAB nDestTab,
8226 const OUString& rDesc)
8228 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 2, 3, nSrcTab), rDesc.toUtf8() + ": Source");
8229 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(1, 1, nSrcTab));
8230 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 2, nSrcTab));
8231 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(1, 3, nSrcTab));
8232 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab));
8233 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
8234 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab));
8236 // Guards
8237 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8238 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8239 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8240 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8241 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8242 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8243 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8244 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8245 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8246 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8247 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8248 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8249 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8250 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8251 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8252 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8253 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8254 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8255 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8256 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8257 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8258 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8259 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8260 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8261 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8262 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8263 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8264 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8265 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
8266 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
8267 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
8268 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
8269 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), m_pDoc->GetFormula(20, 4, nSrcTab)); // U5
8270 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
8271 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), m_pDoc->GetFormula(21, 4, nSrcTab)); // V5
8272 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
8273 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(22, 4, nSrcTab)); // W5
8274 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
8275 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(23, 1, nSrcTab)); // X2
8276 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(23, 2, nSrcTab)); // X3
8277 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
8278 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), m_pDoc->GetFormula(23, 4, nSrcTab)); // X5
8280 for (int i = 10; i < 20; ++i)
8281 for (int j = 0; j < 10; ++j)
8283 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(j, i, nSrcTab));
8284 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(j, i, nSrcTab));
8287 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 1, 22, nSrcTab),
8288 rDesc.toUtf8() + ": Relative references");
8289 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
8290 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
8291 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(0, 22, nSrcTab)); // A23
8292 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
8293 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
8294 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(1, 22, nSrcTab)); // B23
8295 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8296 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8297 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8298 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8299 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8300 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8302 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 30, nSrcTab, 1, 32, nSrcTab),
8303 rDesc.toUtf8() + ": Absolute references");
8304 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
8305 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
8306 CPPUNIT_ASSERT_EQUAL(OUString("=$B$4"), m_pDoc->GetFormula(0, 32, nSrcTab)); // A33
8307 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
8308 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
8309 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), m_pDoc->GetFormula(1, 32, nSrcTab)); // B33
8310 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8311 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8312 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8313 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8314 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8315 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8317 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2"), getRangeByName("Range_B2"));
8318 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3"));
8319 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$4"), getRangeByName("Range_B4"));
8320 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8321 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8322 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8323 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$B$4"), getRangeByName("Range_B2_B4"));
8324 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8325 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8326 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8328 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 40, nSrcTab, 1, 42, nSrcTab),
8329 rDesc.toUtf8() + ": Absolute ranges");
8330 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
8331 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
8332 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), m_pDoc->GetFormula(0, 42, nSrcTab)); // A43
8333 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
8334 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
8335 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), m_pDoc->GetFormula(1, 42, nSrcTab)); // B43
8336 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8337 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8338 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8339 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8340 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8341 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8343 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 50, nSrcTab, 1, 52, nSrcTab),
8344 rDesc.toUtf8() + ": Relative ranges");
8345 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
8346 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
8347 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 52, nSrcTab)); // A53
8348 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
8349 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
8350 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 52, nSrcTab)); // B53
8351 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8352 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8353 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8354 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8355 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8356 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8358 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 60, nSrcTab, 1, 62, nSrcTab),
8359 rDesc.toUtf8() + ": Relative sum");
8360 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
8361 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
8362 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), m_pDoc->GetFormula(0, 62, nSrcTab)); // A63
8363 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
8364 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
8365 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 62, nSrcTab)); // B63
8366 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8367 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8368 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8369 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8370 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8371 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8373 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 70, nSrcTab, 1, 72, nSrcTab),
8374 rDesc.toUtf8() + ": Absolute sum");
8375 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
8376 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
8377 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), m_pDoc->GetFormula(0, 72, nSrcTab)); // A73
8378 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
8379 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
8380 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 72, nSrcTab)); // B73
8381 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8382 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8383 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8384 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8385 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8386 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8388 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 80, nSrcTab, 1, 82, nSrcTab),
8389 rDesc.toUtf8() + ": Relative range sum");
8390 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
8391 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
8392 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 82, nSrcTab)); // A83
8393 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
8394 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
8395 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 82, nSrcTab)); // B83
8396 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8397 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8398 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8399 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8400 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8401 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8403 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 90, nSrcTab, 1, 92, nSrcTab),
8404 rDesc.toUtf8() + ": Absolute sum");
8405 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
8406 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
8407 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 92, nSrcTab)); // A93
8408 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
8409 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
8410 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 92, nSrcTab)); // B93
8411 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 90, nSrcTab));
8412 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 91, nSrcTab));
8413 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 92, nSrcTab));
8414 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 90, nSrcTab));
8415 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 91, nSrcTab));
8416 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 92, nSrcTab));
8418 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 100, nSrcTab, 1, 102, nSrcTab),
8419 rDesc.toUtf8() + ": Relative range sum");
8420 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8421 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
8422 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8423 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
8424 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8425 m_pDoc->GetFormula(0, 102, nSrcTab)); // A103
8426 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8427 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
8428 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8429 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
8430 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8431 m_pDoc->GetFormula(1, 102, nSrcTab)); // B103
8432 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 100, nSrcTab));
8433 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 101, nSrcTab));
8434 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 102, nSrcTab));
8435 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 100, nSrcTab));
8436 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 101, nSrcTab));
8437 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 102, nSrcTab));
8439 // References to the dest range
8440 OUString aFBase("=");
8441 if (nSrcTab != nDestTab)
8442 aFBase += "Dest.";
8444 // Existing references to the destination range must not change
8445 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 112, nSrcTab));
8446 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 113, nSrcTab));
8447 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 114, nSrcTab));
8448 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 112, nSrcTab));
8449 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), m_pDoc->GetFormula(1, 113, nSrcTab));
8450 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), m_pDoc->GetFormula(1, 114, nSrcTab));
8451 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 112, nSrcTab));
8452 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), m_pDoc->GetFormula(2, 113, nSrcTab));
8453 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), m_pDoc->GetFormula(2, 114, nSrcTab));
8456 void TestCopyPaste::executeReferencedCutRangesCol(const bool bTransposed, const SCTAB nSrcTab,
8457 const SCTAB nDestTab, const bool bUndo,
8458 std::unique_ptr<ScUndoCut>& pUndoCut,
8459 std::unique_ptr<ScUndoPaste>& pUndoPaste)
8461 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
8463 for (int i = 0; i < nSrcTab; ++i)
8464 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8465 m_pDoc->InsertTab(nSrcTab, "Test");
8467 m_pDoc->SetValue(1, 1, nSrcTab, 01.0); // B2 \.
8468 m_pDoc->SetValue(1, 2, nSrcTab, 11.0); // B3 | cut
8469 m_pDoc->SetValue(1, 3, nSrcTab, 21.0); // B4 /
8470 m_pDoc->SetValue(2, 1, nSrcTab, 02.0); // C2
8471 m_pDoc->SetValue(2, 2, nSrcTab, 12.0); // C3
8472 m_pDoc->SetValue(2, 3, nSrcTab, 22.0); // C4
8473 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 2, 3, nSrcTab), "Source");
8475 // Guard values
8476 m_pDoc->SetValue(0, 0, nSrcTab, 1000.0); // A1
8477 m_pDoc->SetValue(0, 1, nSrcTab, 1001.0); // A2
8478 m_pDoc->SetValue(0, 2, nSrcTab, 1002.0); // A3
8479 m_pDoc->SetValue(0, 3, nSrcTab, 1003.0); // A4
8480 m_pDoc->SetValue(0, 4, nSrcTab, 1004.0); // A5
8481 m_pDoc->SetValue(1, 0, nSrcTab, 1010.0); // B1
8482 m_pDoc->SetValue(1, 4, nSrcTab, 1014.0); // B5
8483 m_pDoc->SetValue(2, 0, nSrcTab, 1020.0); // C1
8484 m_pDoc->SetValue(2, 4, nSrcTab, 1024.0); // C5
8485 m_pDoc->SetValue(3, 0, nSrcTab, 1030.0); // D1
8486 m_pDoc->SetValue(3, 1, nSrcTab, 1031.0); // D2
8487 m_pDoc->SetValue(3, 2, nSrcTab, 1032.0); // D3
8488 m_pDoc->SetValue(3, 3, nSrcTab, 1033.0); // D4
8489 m_pDoc->SetValue(3, 4, nSrcTab, 1034.0); // D5
8491 m_pDoc->SetString(20, 0, nSrcTab, "=A1"); // U1
8492 m_pDoc->SetString(20, 1, nSrcTab, "=A2"); // U2
8493 m_pDoc->SetString(20, 2, nSrcTab, "=A3"); // U3
8494 m_pDoc->SetString(20, 3, nSrcTab, "=A4"); // U4
8495 m_pDoc->SetString(20, 4, nSrcTab, "=A5"); // U5
8496 m_pDoc->SetString(21, 0, nSrcTab, "=B1"); // V1
8497 m_pDoc->SetString(21, 4, nSrcTab, "=B5"); // V5
8498 m_pDoc->SetString(22, 0, nSrcTab, "=C1"); // W1
8499 m_pDoc->SetString(22, 4, nSrcTab, "=C5"); // W5
8500 m_pDoc->SetString(23, 0, nSrcTab, "=D1"); // X1
8501 m_pDoc->SetString(23, 1, nSrcTab, "=D2"); // X2
8502 m_pDoc->SetString(23, 2, nSrcTab, "=D3"); // X3
8503 m_pDoc->SetString(23, 3, nSrcTab, "=D4"); // X4
8504 m_pDoc->SetString(23, 4, nSrcTab, "=D5"); // X5
8506 // Cell position is used for ranges relative to current position
8507 ScAddress cellA1(0, 0, nSrcTab);
8508 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2", cellA1, "$Test.$B$2"));
8509 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3", cellA1, "$Test.$B$3"));
8510 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B4", cellA1, "$Test.$B$4"));
8511 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2", cellA1, "$Test.$C$2"));
8512 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C3", cellA1, "$Test.$C$3"));
8513 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C4", cellA1, "$Test.$C$4"));
8514 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_B4", cellA1, "$Test.$B$2:$B$4"));
8515 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2_C4", cellA1, "$Test.$C$2:$C$4"));
8516 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_C4", cellA1, "$Test.$B$2:$C$4"));
8517 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("RelRange_Cm20_R0", ScAddress(1, 21, nSrcTab), "B2"));
8519 m_pDoc->SetString(0, 20, nSrcTab, "=B2"); // A21
8520 m_pDoc->SetString(0, 21, nSrcTab, "=B3"); // A22
8521 m_pDoc->SetString(0, 22, nSrcTab, "=B4"); // A23
8522 m_pDoc->SetString(1, 20, nSrcTab, "=C2"); // B21
8523 m_pDoc->SetString(1, 21, nSrcTab, "=C3"); // B22
8524 m_pDoc->SetString(1, 22, nSrcTab, "=C4"); // B23
8526 m_pDoc->SetString(0, 30, nSrcTab, "=$B$2"); // A31
8527 m_pDoc->SetString(0, 31, nSrcTab, "=$B$3"); // A32
8528 m_pDoc->SetString(0, 32, nSrcTab, "=$B$4"); // A33
8529 m_pDoc->SetString(1, 30, nSrcTab, "=$C$2"); // B31
8530 m_pDoc->SetString(1, 31, nSrcTab, "=$C$3"); // B32
8531 m_pDoc->SetString(1, 32, nSrcTab, "=$C$4"); // B33
8533 m_pDoc->SetString(0, 40, nSrcTab, "=Range_B2"); // A41
8534 m_pDoc->SetString(0, 41, nSrcTab, "=Range_B3"); // A42
8535 m_pDoc->SetString(0, 42, nSrcTab, "=Range_B4"); // A43
8536 m_pDoc->SetString(1, 40, nSrcTab, "=Range_C2"); // B41
8537 m_pDoc->SetString(1, 41, nSrcTab, "=Range_C3"); // B42
8538 m_pDoc->SetString(1, 42, nSrcTab, "=Range_C4"); // B43
8540 m_pDoc->SetString(0, 50, nSrcTab, "=RelRange_Cm20_R0"); // A51
8541 m_pDoc->SetString(0, 51, nSrcTab, "=RelRange_Cm20_R0"); // A52
8542 m_pDoc->SetString(0, 52, nSrcTab, "=RelRange_Cm20_R0"); // A53
8543 m_pDoc->SetString(1, 50, nSrcTab, "=RelRange_Cm20_R0"); // B51
8544 m_pDoc->SetString(1, 51, nSrcTab, "=RelRange_Cm20_R0"); // B52
8545 m_pDoc->SetString(1, 52, nSrcTab, "=RelRange_Cm20_R0"); // B53
8547 m_pDoc->SetString(0, 60, nSrcTab, "=SUM(B2:B4"); // A61
8548 m_pDoc->SetString(0, 61, nSrcTab, "=SUM(B2:B4"); // A62
8549 m_pDoc->SetString(0, 62, nSrcTab, "=SUM(B2:B4"); // A63
8550 m_pDoc->SetString(1, 60, nSrcTab, "=SUM(C2:C4"); // B61
8551 m_pDoc->SetString(1, 61, nSrcTab, "=SUM(C2:C4"); // B62
8552 m_pDoc->SetString(1, 62, nSrcTab, "=SUM(C2:C4"); // B63
8554 m_pDoc->SetString(0, 70, nSrcTab, "=SUM($B$2:$B$4"); // A71
8555 m_pDoc->SetString(0, 71, nSrcTab, "=SUM($B$2:$B$4"); // A72
8556 m_pDoc->SetString(0, 72, nSrcTab, "=SUM($B$2:$B$4"); // A73
8557 m_pDoc->SetString(1, 70, nSrcTab, "=SUM($C$2:$C$4"); // B71
8558 m_pDoc->SetString(1, 71, nSrcTab, "=SUM($C$2:$C$4"); // B72
8559 m_pDoc->SetString(1, 72, nSrcTab, "=SUM($C$2:$C$4"); // B73
8561 m_pDoc->SetString(0, 80, nSrcTab, "=SUM(Range_B2_B4)"); // A81
8562 m_pDoc->SetString(0, 81, nSrcTab, "=SUM(Range_B2_B4)"); // A82
8563 m_pDoc->SetString(0, 82, nSrcTab, "=SUM(Range_B2_B4)"); // A83
8564 m_pDoc->SetString(1, 80, nSrcTab, "=SUM(Range_C2_C4)"); // B81
8565 m_pDoc->SetString(1, 81, nSrcTab, "=SUM(Range_C2_C4)"); // B82
8566 m_pDoc->SetString(1, 82, nSrcTab, "=SUM(Range_C2_C4)"); // B83
8568 m_pDoc->SetString(0, 90, nSrcTab, "=SUM($B$2:$C$4"); // A91
8569 m_pDoc->SetString(0, 91, nSrcTab, "=SUM($B$2:$C$4"); // A92
8570 m_pDoc->SetString(0, 92, nSrcTab, "=SUM($B$2:$C$4"); // A93
8571 m_pDoc->SetString(1, 90, nSrcTab, "=SUM($B$2:$C$4"); // B91
8572 m_pDoc->SetString(1, 91, nSrcTab, "=SUM($B$2:$C$4"); // B92
8573 m_pDoc->SetString(1, 92, nSrcTab, "=SUM($B$2:$C$4"); // B93
8575 m_pDoc->SetString(0, 100, nSrcTab, "=SUM(Range_B2_C4"); // A101
8576 m_pDoc->SetString(0, 101, nSrcTab, "=SUM(Range_B2_C4"); // A102
8577 m_pDoc->SetString(0, 102, nSrcTab, "=SUM(Range_B2_C4"); // A103
8578 m_pDoc->SetString(1, 100, nSrcTab, "=SUM(Range_B2_C4"); // B101
8579 m_pDoc->SetString(1, 101, nSrcTab, "=SUM(Range_B2_C4"); // B102
8580 m_pDoc->SetString(1, 102, nSrcTab, "=SUM(Range_B2_C4"); // B103
8582 for (int i = nSrcTab + 1; i < nDestTab; ++i)
8583 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8585 if (nSrcTab < nDestTab)
8586 m_pDoc->InsertTab(nDestTab, "Dest");
8587 else if (nSrcTab > nDestTab)
8588 m_pDoc->RenameTab(nDestTab, "Dest");
8590 int nTabCount = m_pDoc->GetTableCount();
8591 for (int i = nTabCount; i < nTabCount + 2; ++i)
8592 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8593 nTabCount = m_pDoc->GetTableCount();
8595 // References to the dest range
8596 OUString aFBase("=");
8597 if (nSrcTab != nDestTab)
8598 aFBase += "Dest.";
8600 m_pDoc->SetString(0, 112, nSrcTab, OUString(aFBase + "C12"));
8601 m_pDoc->SetString(0, 113, nSrcTab, OUString(aFBase + "C13"));
8602 m_pDoc->SetString(0, 114, nSrcTab, OUString(aFBase + "C14"));
8603 m_pDoc->SetString(1, 112, nSrcTab, OUString(aFBase + "D12"));
8604 m_pDoc->SetString(1, 113, nSrcTab, OUString(aFBase + "D13"));
8605 m_pDoc->SetString(1, 114, nSrcTab, OUString(aFBase + "D14"));
8606 m_pDoc->SetString(2, 112, nSrcTab, OUString(aFBase + "E12"));
8607 m_pDoc->SetString(2, 113, nSrcTab, OUString(aFBase + "E13"));
8608 m_pDoc->SetString(2, 114, nSrcTab, OUString(aFBase + "E14"));
8610 // Check precondition
8611 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "Initial");
8613 // Cut values B2:B4 to the clip document.
8614 ScDocument aClipDoc(SCDOCMODE_CLIP);
8615 ScRange aSrcRange(1, 1, nSrcTab, 1, 3, nSrcTab);
8616 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
8617 aSrcMark.SetMarkArea(aSrcRange);
8619 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, bUndo));
8621 InsertDeleteFlags aFlags(InsertDeleteFlags::ALL);
8623 ScDocumentUniquePtr pPasteUndoDoc;
8624 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
8625 std::unique_ptr<ScRefUndoData> pUndoData;
8627 ScRange aDestRange;
8628 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
8630 if (bTransposed)
8632 // To C12:E12
8633 aDestRange = ScRange(2, 11, nDestTab, 4, 11, nDestTab);
8634 aDestMark.SetMarkArea(aDestRange);
8636 if (bUndo)
8637 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
8638 pUndoData);
8640 // Transpose
8641 ScDocument* pOrigClipDoc = &aClipDoc;
8642 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
8643 aClipDoc.TransposeClip(pTransClip.get(), aFlags, false, true);
8644 // Paste
8645 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
8646 pTransClip.get(), true, false, true, false);
8647 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
8648 "Relative references after copy");
8650 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, pPasteRefUndoDoc.get());
8651 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
8652 "Relative references after UpdateTranspose");
8653 pTransClip.reset();
8655 else
8657 // To C12:C14
8658 aDestRange = ScRange(2, 11, nDestTab, 2, 13, nDestTab);
8659 // aDestMark = ScMarkData(m_pDoc->GetSheetLimits());
8661 aDestMark.SetMarkArea(aDestRange);
8663 if (bUndo)
8664 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
8665 pUndoData);
8667 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc, true,
8668 false, false, false);
8671 if (bUndo)
8672 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
8673 pUndoPaste, bTransposed);
8676 void TestCopyPaste::checkReferencedCutRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab)
8678 // Cut B2:B4 and pasted to C12:C14
8680 OUString aFBase("=");
8681 if (nSrcTab != nDestTab)
8682 aFBase += "Dest.";
8684 // Precondition
8685 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab)); // C12
8686 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 12, nDestTab)); // C13
8687 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 13, nDestTab)); // C14
8688 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab)); // C2
8689 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab)); // C3
8690 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
8692 // Guards
8693 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8694 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8695 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8696 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8697 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8698 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8699 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8700 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8701 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8702 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8703 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8704 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8705 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8706 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8707 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8708 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8709 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8710 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8711 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8712 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8713 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8714 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8715 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8716 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8717 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8718 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8719 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8720 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8721 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
8722 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
8723 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
8724 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
8725 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), m_pDoc->GetFormula(20, 4, nSrcTab)); // U5
8726 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
8727 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), m_pDoc->GetFormula(21, 4, nSrcTab)); // V5
8728 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
8729 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(22, 4, nSrcTab)); // W5
8730 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
8731 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(23, 1, nSrcTab)); // X2
8732 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(23, 2, nSrcTab)); // X3
8733 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
8734 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), m_pDoc->GetFormula(23, 4, nSrcTab)); // X5
8736 // Note: Values (mostly) remain the same
8738 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
8739 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
8740 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 22, nSrcTab)); // A23
8741 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
8742 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
8743 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(1, 22, nSrcTab)); // B23
8744 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8745 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8746 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8747 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8748 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8749 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8751 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
8752 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$13"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
8753 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$14"), m_pDoc->GetFormula(0, 32, nSrcTab)); // A33
8754 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
8755 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
8756 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), m_pDoc->GetFormula(1, 32, nSrcTab)); // B33
8757 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8758 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8759 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8760 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8761 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8762 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8764 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8765 getRangeByName("Range_B2"));
8766 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$13") : OUString("$Test.$C$13"),
8767 getRangeByName("Range_B3"));
8768 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$14") : OUString("$Test.$C$14"),
8769 getRangeByName("Range_B4"));
8770 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8771 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8772 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8773 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$C$14")
8774 : OUString("$Test.$C$12:$C$14"),
8775 getRangeByName("Range_B2_B4"));
8776 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8777 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8778 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8780 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
8781 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
8782 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), m_pDoc->GetFormula(0, 42, nSrcTab)); // A43
8783 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
8784 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
8785 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), m_pDoc->GetFormula(1, 42, nSrcTab)); // B43
8786 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8787 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8788 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8789 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8790 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8791 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8793 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
8794 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
8795 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 52, nSrcTab)); // A53
8796 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
8797 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
8798 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 52, nSrcTab)); // B53
8799 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8800 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8801 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8802 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8803 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8804 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8806 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8807 : OUString("=SUM(C12:C14)"),
8808 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
8809 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8810 : OUString("=SUM(C12:C14)"),
8811 m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
8812 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8813 : OUString("=SUM(C12:C14)"),
8814 m_pDoc->GetFormula(0, 62, nSrcTab)); // A63
8815 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
8816 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
8817 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 62, nSrcTab)); // B63
8818 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8819 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8820 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8821 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8822 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8823 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8825 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8826 : OUString("=SUM($C$12:$C$14)"),
8827 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
8828 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8829 : OUString("=SUM($C$12:$C$14)"),
8830 m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
8831 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8832 : OUString("=SUM($C$12:$C$14)"),
8833 m_pDoc->GetFormula(0, 72, nSrcTab)); // A73
8834 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
8835 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
8836 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 72, nSrcTab)); // B73
8837 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8838 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8839 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8840 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8841 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8842 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8844 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
8845 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
8846 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 82, nSrcTab)); // A83
8847 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
8848 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
8849 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 82, nSrcTab)); // B83
8850 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8851 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8852 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8853 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8854 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8855 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8857 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
8858 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
8859 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 92, nSrcTab)); // A93
8860 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
8861 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
8862 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 92, nSrcTab)); // B93
8863 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab));
8864 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab));
8865 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 92, nSrcTab));
8866 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab));
8867 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab));
8868 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 92, nSrcTab));
8870 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8871 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
8872 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8873 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
8874 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8875 m_pDoc->GetFormula(0, 102, nSrcTab)); // A103
8876 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8877 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
8878 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8879 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
8880 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8881 m_pDoc->GetFormula(1, 102, nSrcTab)); // B103
8882 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab));
8883 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab));
8884 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 102, nSrcTab));
8885 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab));
8886 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab));
8887 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 102, nSrcTab));
8889 // Existing references to the destination range must not change
8890 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 112, nSrcTab));
8891 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 113, nSrcTab));
8892 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 114, nSrcTab));
8893 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 112, nSrcTab));
8894 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), m_pDoc->GetFormula(1, 113, nSrcTab));
8895 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), m_pDoc->GetFormula(1, 114, nSrcTab));
8896 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 112, nSrcTab));
8897 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), m_pDoc->GetFormula(2, 113, nSrcTab));
8898 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), m_pDoc->GetFormula(2, 114, nSrcTab));
8901 void TestCopyPaste::checkReferencedCutTransposedRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab)
8903 // Cut B2:D2 and pasted transposed to C12:E12
8905 OUString aFBase("=");
8906 if (nSrcTab != nDestTab)
8907 aFBase += "Dest.";
8909 // Precondition
8910 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab)); // C12
8911 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 11, nDestTab)); // D12
8912 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(4, 11, nDestTab)); // E12
8913 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab)); // C2
8914 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab)); // C3
8915 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
8917 // Guards
8918 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8919 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8920 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8921 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8922 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8923 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8924 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8925 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8926 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8927 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8928 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8929 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8930 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8931 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8932 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8933 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8934 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8935 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8936 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8937 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8938 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8939 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8940 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8941 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8942 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8943 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8944 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8945 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8946 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
8947 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
8948 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
8949 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
8950 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), m_pDoc->GetFormula(20, 4, nSrcTab)); // U5
8951 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
8952 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), m_pDoc->GetFormula(21, 4, nSrcTab)); // V5
8953 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
8954 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(22, 4, nSrcTab)); // W5
8955 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
8956 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(23, 1, nSrcTab)); // X2
8957 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(23, 2, nSrcTab)); // X3
8958 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
8959 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), m_pDoc->GetFormula(23, 4, nSrcTab)); // X5
8961 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
8962 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
8963 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(0, 22, nSrcTab)); // A23
8964 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
8965 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
8966 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(1, 22, nSrcTab)); // B23
8967 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8968 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8969 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8970 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8971 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8972 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8974 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
8975 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$D$12"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
8976 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$E$12"), m_pDoc->GetFormula(0, 32, nSrcTab)); // A33
8977 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
8978 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
8979 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), m_pDoc->GetFormula(1, 32, nSrcTab)); // B33
8980 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8981 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8982 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8983 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8984 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8985 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8987 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8988 getRangeByName("Range_B2"));
8989 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$D$12") : OUString("$Test.$D$12"),
8990 getRangeByName("Range_B3"));
8991 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$E$12") : OUString("$Test.$E$12"),
8992 getRangeByName("Range_B4"));
8993 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8994 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8995 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8996 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$E$12")
8997 : OUString("$Test.$C$12:$E$12"),
8998 getRangeByName("Range_B2_B4"));
8999 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
9000 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
9001 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
9003 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
9004 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
9005 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), m_pDoc->GetFormula(0, 42, nSrcTab)); // A43
9006 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
9007 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
9008 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), m_pDoc->GetFormula(1, 42, nSrcTab)); // B43
9009 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
9010 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
9011 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
9012 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
9013 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
9014 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
9016 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
9017 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
9018 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 52, nSrcTab)); // A53
9019 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
9020 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
9021 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 52, nSrcTab)); // B53
9022 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
9023 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
9024 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
9025 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
9026 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
9027 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
9029 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
9030 : OUString("=SUM(C12:E12)"),
9031 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
9032 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
9033 : OUString("=SUM(C12:E12)"),
9034 m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
9035 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
9036 : OUString("=SUM(C12:E12)"),
9037 m_pDoc->GetFormula(0, 62, nSrcTab)); // A63
9038 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
9039 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
9040 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 62, nSrcTab)); // B63
9041 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
9042 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
9043 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
9044 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
9045 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
9046 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
9048 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
9049 : OUString("=SUM($C$12:$E$12)"),
9050 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
9051 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
9052 : OUString("=SUM($C$12:$E$12)"),
9053 m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
9054 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
9055 : OUString("=SUM($C$12:$E$12)"),
9056 m_pDoc->GetFormula(0, 72, nSrcTab)); // A73
9057 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
9058 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
9059 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 72, nSrcTab)); // B73
9060 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
9061 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
9062 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
9063 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
9064 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
9065 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
9067 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
9068 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
9069 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 82, nSrcTab)); // A83
9070 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
9071 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
9072 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 82, nSrcTab)); // B83
9073 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
9074 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
9075 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
9076 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
9077 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
9078 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
9080 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
9081 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
9082 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 92, nSrcTab)); // A93
9083 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
9084 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
9085 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 92, nSrcTab)); // B93
9086 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab));
9087 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab));
9088 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 92, nSrcTab));
9089 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab));
9090 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab));
9091 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 92, nSrcTab));
9093 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
9094 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
9095 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
9096 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
9097 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
9098 m_pDoc->GetFormula(0, 102, nSrcTab)); // A103
9099 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
9100 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
9101 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
9102 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
9103 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
9104 m_pDoc->GetFormula(1, 102, nSrcTab)); // B103
9105 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab));
9106 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab));
9107 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 102, nSrcTab));
9108 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab));
9109 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab));
9110 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 102, nSrcTab));
9112 // Existing references to the destination range must not change
9113 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 112, nSrcTab));
9114 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 113, nSrcTab));
9115 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 114, nSrcTab));
9116 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 112, nSrcTab));
9117 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), m_pDoc->GetFormula(1, 113, nSrcTab));
9118 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), m_pDoc->GetFormula(1, 114, nSrcTab));
9119 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 112, nSrcTab));
9120 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), m_pDoc->GetFormula(2, 113, nSrcTab));
9121 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), m_pDoc->GetFormula(2, 114, nSrcTab));
9124 void TestCopyPaste::testReferencedCutRangesCol()
9126 const SCTAB nSrcTab = 0;
9127 const SCTAB nDestTab = 2;
9128 std::unique_ptr<ScUndoCut> pUndoCut;
9129 std::unique_ptr<ScUndoPaste> pUndoPaste;
9130 executeReferencedCutRangesCol(false, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
9131 checkReferencedCutRangesCol(nSrcTab, nDestTab);
9133 pUndoPaste->Undo();
9134 pUndoCut->Undo();
9135 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9137 pUndoCut->Redo();
9138 pUndoPaste->Redo();
9139 checkReferencedCutRangesCol(nSrcTab, nDestTab);
9141 pUndoPaste->Undo();
9142 pUndoCut->Undo();
9143 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9145 pUndoPaste.reset();
9146 pUndoCut.reset();
9148 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
9149 m_pDoc->DeleteTab(i - 1);
9152 // tdf#142201
9153 void TestCopyPaste::testReferencedCutTransposedRangesColTab0To0()
9155 checkReferencedCutTransposedRangesColUndo(0, 0);
9158 // tdf#142201
9159 void TestCopyPaste::testReferencedCutTransposedRangesColTab0To1()
9161 checkReferencedCutTransposedRangesColUndo(0, 1);
9164 // tdf#142201
9165 void TestCopyPaste::testReferencedCutTransposedRangesColTab1To3()
9167 checkReferencedCutTransposedRangesColUndo(1, 3);
9170 // tdf#142201
9171 void TestCopyPaste::testReferencedCutTransposedRangesColTab3To1()
9173 checkReferencedCutTransposedRangesColUndo(3, 1);
9176 // tdf#142201
9177 void TestCopyPaste::checkReferencedCutTransposedRangesColUndo(const SCTAB nSrcTab,
9178 const SCTAB nDestTab)
9180 std::unique_ptr<ScUndoCut> pUndoCut;
9181 std::unique_ptr<ScUndoPaste> pUndoPaste;
9182 executeReferencedCutRangesCol(true, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
9183 checkReferencedCutTransposedRangesCol(nSrcTab, nDestTab);
9185 pUndoPaste->Undo();
9186 pUndoCut->Undo();
9187 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9189 pUndoCut->Redo();
9190 pUndoPaste->Redo();
9191 checkReferencedCutTransposedRangesCol(nSrcTab, nDestTab);
9193 pUndoPaste->Undo();
9194 pUndoCut->Undo();
9195 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9197 pUndoPaste.reset();
9198 pUndoCut.reset();
9200 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
9201 m_pDoc->DeleteTab(i - 1);
9204 void TestCopyPaste::testCutTransposedFormulas()
9206 const SCTAB nTab = 0;
9207 m_pDoc->InsertTab(nTab, "Test");
9209 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9210 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
9212 m_pDoc->SetString(1, 1, nTab, "=A1"); // B2
9213 m_pDoc->SetString(2, 1, nTab, "=B1"); // C2
9214 m_pDoc->SetString(3, 1, nTab, "=SUM(A1:B1)"); // D2
9215 m_pDoc->SetString(4, 1, nTab, "=$B$1"); // E2
9216 m_pDoc->SetString(5, 1, nTab, "=$B1"); // F2
9217 m_pDoc->SetString(6, 1, nTab, "=B$1"); // G2
9219 // Check precondition
9220 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 1, nTab));
9222 // Cut formulas B2:G2 to the clip document.
9223 ScDocument aClipDoc(SCDOCMODE_CLIP);
9224 ScRange aSrcRange(1, 1, nTab, 6, 1, nTab);
9225 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9227 // To C3:C8
9228 ScRange aDestRange(2, 2, nTab, 2, 7, nTab);
9229 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9231 // Transpose
9232 ScDocument* pOrigClipDoc = &aClipDoc;
9233 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9234 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9235 aDestMark.SetMarkArea(aDestRange);
9236 // Paste
9237 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9238 true, false, true, false);
9239 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9240 pTransClip.reset();
9242 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(2, 2, nTab));
9243 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(2, 2, nTab));
9245 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(2, 3, nTab));
9246 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 3, nTab));
9248 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A1:B1)"), m_pDoc->GetFormula(2, 4, nTab));
9249 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 4, nTab));
9251 CPPUNIT_ASSERT_EQUAL(OUString("=$B$1"), m_pDoc->GetFormula(2, 5, nTab));
9252 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 5, nTab));
9254 CPPUNIT_ASSERT_EQUAL(OUString("=$B1"), m_pDoc->GetFormula(2, 6, nTab));
9255 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 6, nTab));
9257 CPPUNIT_ASSERT_EQUAL(OUString("=B$1"), m_pDoc->GetFormula(2, 7, nTab));
9258 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 7, nTab));
9261 void TestCopyPaste::testCutTransposedFormulasSquare()
9263 const SCTAB nTab = 0;
9264 m_pDoc->InsertTab(nTab, "Test");
9266 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9267 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
9268 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
9269 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
9270 m_pDoc->SetValue(2, 0, nTab, 21.0); // C1
9271 m_pDoc->SetValue(2, 1, nTab, 22.0); // C2
9273 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
9274 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
9275 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
9276 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
9277 m_pDoc->SetString(2, 3, nTab, "=C1"); // C4
9278 m_pDoc->SetString(2, 4, nTab, "=C2"); // C5
9280 // Check precondition
9281 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
9282 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
9283 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
9284 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
9285 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 3, nTab));
9286 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 4, nTab));
9288 printRange(m_pDoc, ScRange(0, 0, nTab, 2, 1, nTab), "Values");
9289 printRange(m_pDoc, ScRange(0, 3, nTab, 2, 4, nTab), "Formulas");
9290 printFormula(m_pDoc, 0, 4, nTab);
9292 // Cut formulas A4:B5 to the clip document.
9293 ScDocument aClipDoc(SCDOCMODE_CLIP);
9294 ScRange aSrcRange(0, 3, nTab, 2, 4, nTab);
9295 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9297 // To B7:C9
9298 ScRange aDestRange(1, 6, nTab, 2, 8, nTab);
9299 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9301 // Transpose
9302 ScDocument* pOrigClipDoc = &aClipDoc;
9303 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9304 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9305 aDestMark.SetMarkArea(aDestRange);
9306 // Paste
9307 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9308 true, false, true, false);
9309 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9310 pTransClip.reset();
9312 printRange(m_pDoc, aDestRange, "Formulas after cut transposed");
9313 printFormula(m_pDoc, 2, 6, nTab);
9315 // Check results
9316 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 6, nTab));
9317 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 6, nTab));
9318 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 7, nTab));
9319 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 7, nTab));
9320 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(1, 8, nTab));
9321 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 8, nTab));
9323 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(1, 6, nTab));
9324 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(2, 6, nTab));
9325 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(1, 7, nTab));
9326 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(2, 7, nTab));
9327 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(1, 8, nTab));
9328 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(2, 8, nTab));
9331 void TestCopyPaste::testTdf142065()
9333 const SCTAB nTab = 0;
9334 m_pDoc->InsertTab(nTab, "Test");
9336 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9337 m_pDoc->SetString(1, 0, nTab, "=A1"); // B1
9338 m_pDoc->SetString(2, 0, nTab, "=SUM(A1:B1)"); // C1
9339 m_pDoc->SetString(3, 0, nTab, "=$A$1"); // D1
9340 m_pDoc->SetString(4, 0, nTab, "=$A1"); // E1
9341 m_pDoc->SetString(5, 0, nTab, "=A$1"); // F1
9343 // Check precondition
9344 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 0, nTab));
9346 // Cut A1:F1 to the clip document.
9347 ScDocument aClipDoc(SCDOCMODE_CLIP);
9348 ScRange aSrcRange(0, 0, nTab, 5, 0, nTab);
9349 printRange(m_pDoc, aSrcRange, "Src sheet");
9350 printFormula(m_pDoc, 1, 0, nTab);
9351 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9352 printRange(&aClipDoc, aSrcRange, "clip doc (&aClipDoc)");
9353 printFormula(&aClipDoc, 1, 0, nTab);
9355 // To A3:A9
9356 ScRange aDestRange(0, 2, nTab, 0, 7, nTab);
9357 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9359 // Transpose
9360 ScDocument* pOrigClipDoc = &aClipDoc;
9361 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9362 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9363 printRange(pTransClip.get(), ScRange(0, 0, nTab, 0, 1, nTab),
9364 "transposed clip doc (pTransClip.get())");
9365 printFormula(pTransClip.get(), 0, 1, nTab);
9366 printFormula(pTransClip.get(), 1, 0, nTab);
9367 aDestMark.SetMarkArea(aDestRange);
9368 // Paste
9369 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9370 true, false, true, false);
9371 printRange(m_pDoc, aDestRange, "dest doc");
9372 printFormula(m_pDoc, 0, 3, nTab);
9373 printRange(pOrigClipDoc, aSrcRange, "orig clip doc (pOrigClipDoc)");
9374 printFormula(pOrigClipDoc, 1, 0, nTab);
9375 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9376 pTransClip.reset();
9377 printRange(m_pDoc, aDestRange, "dest doc after UpdateTranspose()");
9378 printFormula(m_pDoc, 0, 3, nTab);
9380 // Check results
9381 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 2, nTab));
9382 // Without the fix in place, this would have failed with
9383 // - Expected: =A3
9384 // - Actual : =#REF!#REF!
9385 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(0, 3, nTab));
9386 // Without the fix in place, this would have failed with
9387 // - Expected: 1
9388 // - Actual : #REF!
9389 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
9390 // Without the fix in place, this would have failed with
9391 // - Expected: =SUM(A3:A4)
9392 // - Actual : =SUM(#REF!#REF!:#REF!#REF!)
9393 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A3:A4)"), m_pDoc->GetFormula(0, 4, nTab));
9394 // Without the fix in place, this would have failed with
9395 // - Expected: 2
9396 // - Actual : #REF!
9397 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
9399 CPPUNIT_ASSERT_EQUAL(OUString("=$A$3"), m_pDoc->GetFormula(0, 5, nTab));
9400 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 5, nTab));
9402 CPPUNIT_ASSERT_EQUAL(OUString("=$A3"), m_pDoc->GetFormula(0, 6, nTab));
9403 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 6, nTab));
9405 CPPUNIT_ASSERT_EQUAL(OUString("=A$3"), m_pDoc->GetFormula(0, 7, nTab));
9406 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 7, nTab));
9409 void TestCopyPaste::testCopyPasteMultiRange()
9411 m_pDoc->InsertTab(0, "Test");
9413 // Fill A2:B6 with numbers.
9414 for (SCROW nRow = 1; nRow <= 5; ++nRow)
9416 for (SCCOL nCol = 0; nCol <= 1; ++nCol)
9418 ScAddress aPos(nCol, nRow, 0);
9419 m_pDoc->SetValue(aPos, nRow + nCol);
9423 // Fill D9:E11 with numbers.
9424 for (SCROW nRow = 8; nRow <= 10; ++nRow)
9426 for (SCCOL nCol = 3; nCol <= 4; ++nCol)
9428 ScAddress aPos(nCol, nRow, 0);
9429 m_pDoc->SetValue(aPos, 10.0);
9433 ScMarkData aMark(m_pDoc->GetSheetLimits());
9434 aMark.SelectOneTable(0);
9436 // Copy A2:B2, A4:B4, and A6:B6 to clipboard.
9437 ScDocument aClipDoc(SCDOCMODE_CLIP);
9438 ScClipParam aClipParam;
9439 aClipParam.maRanges.push_back(ScRange(0, 1, 0, 1, 1, 0)); // A2:B2
9440 aClipParam.maRanges.push_back(ScRange(0, 3, 0, 1, 3, 0)); // A4:B4
9441 aClipParam.maRanges.push_back(ScRange(0, 5, 0, 1, 5, 0)); // A6:B6
9442 aClipParam.meDirection = ScClipParam::Row;
9443 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9445 // Paste to D9:E11, and make sure it won't crash (rhbz#1080196).
9446 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 8, 0), aMark, InsertDeleteFlags::CONTENTS,
9447 &aClipDoc);
9448 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(3, 8, 0)));
9449 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4, 8, 0)));
9450 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3, 9, 0)));
9451 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(4, 9, 0)));
9452 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(3, 10, 0)));
9453 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(4, 10, 0)));
9455 m_pDoc->DeleteTab(0);
9458 void TestCopyPaste::testCopyPasteSkipEmpty()
9460 struct Check
9462 const char* mpStr;
9463 Color maColor;
9464 bool mbHasNote;
9467 struct TestRange
9469 ScDocument* mpDoc;
9471 explicit TestRange(ScDocument* pDoc)
9472 : mpDoc(pDoc)
9476 bool checkRange(const ScAddress& rPos, const Check* p, const Check* pEnd)
9478 ScAddress aPos(rPos);
9479 OUString aPosStr = aPos.Format(ScRefFlags::VALID);
9480 for (; p != pEnd; ++p, aPos.IncRow())
9482 if (!mpDoc->GetString(aPos).equalsAscii(p->mpStr))
9484 cerr << aPosStr << ": incorrect string value: expected='" << p->mpStr
9485 << "' actual='" << mpDoc->GetString(aPos) << endl;
9486 return false;
9489 const SvxBrushItem* pBrush = mpDoc->GetAttr(aPos, ATTR_BACKGROUND);
9490 if (!pBrush)
9492 cerr << aPosStr << ": failed to get brush item from the cell." << endl;
9493 return false;
9496 if (pBrush->GetColor() != p->maColor)
9498 Color aExpected = p->maColor;
9499 Color aActual = pBrush->GetColor();
9500 cerr << aPosStr << ": incorrect cell background color: expected=("
9501 << static_cast<int>(aExpected.GetRed()) << ","
9502 << static_cast<int>(aExpected.GetGreen()) << ","
9503 << static_cast<int>(aExpected.GetBlue()) << "), actual=("
9504 << static_cast<int>(aActual.GetRed()) << ","
9505 << static_cast<int>(aActual.GetGreen()) << ","
9506 << static_cast<int>(aActual.GetBlue()) << ")" << endl;
9508 return false;
9511 bool bHasNote = mpDoc->HasNote(aPos);
9512 if (bHasNote != p->mbHasNote)
9514 cerr << aPosStr << ": ";
9515 if (p->mbHasNote)
9516 cerr << "this cell should have a cell note, but doesn't." << endl;
9517 else
9518 cerr << "this cell should NOT have a cell note, but one is found." << endl;
9520 return false;
9524 return true;
9527 } aTest(m_pDoc);
9529 m_pDoc->InsertTab(0, "Test");
9530 m_pDoc->InitDrawLayer(m_xDocShell.get()); // for cell note objects.
9532 ScRange aSrcRange(0, 0, 0, 0, 4, 0);
9533 ScRange aDestRange(1, 0, 0, 1, 4, 0);
9535 ScMarkData aMark(m_pDoc->GetSheetLimits());
9536 aMark.SetMarkArea(aDestRange);
9538 // Put some texts in B1:B5.
9539 m_pDoc->SetString(ScAddress(1, 0, 0), "A");
9540 m_pDoc->SetString(ScAddress(1, 1, 0), "B");
9541 m_pDoc->SetString(ScAddress(1, 2, 0), "C");
9542 m_pDoc->SetString(ScAddress(1, 3, 0), "D");
9543 m_pDoc->SetString(ScAddress(1, 4, 0), "E");
9545 // Set the background color of B1:B5 to blue.
9546 ScPatternAttr aCellBackColor(m_pDoc->GetPool());
9547 aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
9548 m_pDoc->ApplyPatternAreaTab(1, 0, 1, 4, 0, aCellBackColor);
9550 // Insert notes to B1:B5.
9551 m_pDoc->GetOrCreateNote(ScAddress(1, 0, 0));
9552 m_pDoc->GetOrCreateNote(ScAddress(1, 1, 0));
9553 m_pDoc->GetOrCreateNote(ScAddress(1, 2, 0));
9554 m_pDoc->GetOrCreateNote(ScAddress(1, 3, 0));
9555 m_pDoc->GetOrCreateNote(ScAddress(1, 4, 0));
9557 // Prepare a clipboard content interleaved with empty cells.
9558 ScDocument aClipDoc(SCDOCMODE_CLIP);
9559 aClipDoc.ResetClip(m_pDoc, &aMark);
9560 ScClipParam aParam(aSrcRange, false);
9561 aClipDoc.SetClipParam(aParam);
9562 aClipDoc.SetString(ScAddress(0, 0, 0), "Clip1");
9563 aClipDoc.SetString(ScAddress(0, 2, 0), "Clip2");
9564 aClipDoc.SetString(ScAddress(0, 4, 0), "Clip3");
9566 // Set the background color of A1:A5 to yellow.
9567 aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_YELLOW, ATTR_BACKGROUND));
9568 aClipDoc.ApplyPatternAreaTab(0, 0, 0, 4, 0, aCellBackColor);
9570 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 0, 0)));
9571 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0, 1, 0)));
9572 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 2, 0)));
9573 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0, 3, 0)));
9574 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 4, 0)));
9576 // Check the initial condition.
9578 static const Check aChecks[] = {
9579 { "A", COL_BLUE, true }, { "B", COL_BLUE, true }, { "C", COL_BLUE, true },
9580 { "D", COL_BLUE, true }, { "E", COL_BLUE, true },
9583 bool bRes
9584 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9585 CPPUNIT_ASSERT_MESSAGE("Initial check failed.", bRes);
9588 // Create undo document.
9589 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9590 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9591 m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, *pUndoDoc, &aMark);
9593 // Paste clipboard content onto A1:A5 but skip empty cells.
9594 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, pUndoDoc.get(), &aClipDoc, true,
9595 false, false, true /*bSkipEmpty*/);
9597 // Create redo document.
9598 ScDocumentUniquePtr pRedoDoc(new ScDocument(SCDOCMODE_UNDO));
9599 pRedoDoc->InitUndo(*m_pDoc, 0, 0);
9600 m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, *pRedoDoc, &aMark);
9602 // Create an undo object for this.
9603 std::unique_ptr<ScRefUndoData> pRefUndoData(new ScRefUndoData(m_pDoc));
9604 ScUndoPaste aUndo(m_xDocShell.get(), aDestRange, aMark, std::move(pUndoDoc),
9605 std::move(pRedoDoc), InsertDeleteFlags::ALL, std::move(pRefUndoData));
9607 // Check the content after the paste.
9609 static const Check aChecks[] = {
9610 { "Clip1", COL_YELLOW, false }, { "B", COL_BLUE, true },
9611 { "Clip2", COL_YELLOW, false }, { "D", COL_BLUE, true },
9612 { "Clip3", COL_YELLOW, false },
9615 bool bRes
9616 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9617 CPPUNIT_ASSERT_MESSAGE("Check after paste failed.", bRes);
9620 // Undo, and check the content.
9621 aUndo.Undo();
9623 static const Check aChecks[] = {
9624 { "A", COL_BLUE, true }, { "B", COL_BLUE, true }, { "C", COL_BLUE, true },
9625 { "D", COL_BLUE, true }, { "E", COL_BLUE, true },
9628 bool bRes
9629 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9630 CPPUNIT_ASSERT_MESSAGE("Check after undo failed.", bRes);
9633 // Redo, and check the content again.
9634 aUndo.Redo();
9636 static const Check aChecks[] = {
9637 { "Clip1", COL_YELLOW, false }, { "B", COL_BLUE, true },
9638 { "Clip2", COL_YELLOW, false }, { "D", COL_BLUE, true },
9639 { "Clip3", COL_YELLOW, false },
9642 bool bRes
9643 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9644 CPPUNIT_ASSERT_MESSAGE("Check after redo failed.", bRes);
9647 m_pDoc->DeleteTab(0);
9650 void TestCopyPaste::testCopyPasteSkipEmpty2()
9652 m_pDoc->InsertTab(0, "Test");
9654 m_pDoc->SetString(ScAddress(0, 0, 0), "A");
9655 m_pDoc->SetString(ScAddress(2, 0, 0), "C");
9657 // Copy A1:C1 to clipboard.
9658 ScDocument aClipDoc(SCDOCMODE_CLIP);
9659 aClipDoc.ResetClip(m_pDoc, static_cast<SCTAB>(0));
9660 copyToClip(m_pDoc, ScRange(0, 0, 0, 2, 0, 0), &aClipDoc);
9662 // Paste to A3 with the skip empty option set. This used to freeze. (fdo#77735)
9663 ScRange aDestRange(0, 2, 0, 2, 2, 0);
9664 ScMarkData aMark(m_pDoc->GetSheetLimits());
9665 aMark.SetMarkArea(aDestRange);
9666 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, false,
9667 false, true, true);
9669 CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(0, 2, 0)));
9670 CPPUNIT_ASSERT_EQUAL_MESSAGE("B3 should be empty.", CELLTYPE_NONE,
9671 m_pDoc->GetCellType(ScAddress(1, 2, 0)));
9672 CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(2, 2, 0)));
9674 m_pDoc->DeleteTab(0);
9677 void TestCopyPaste::testCutPasteRefUndo()
9679 // Testing scenario: A2 references B2, and B2 gets cut and pasted onto C2,
9680 // which updates A2's formula to reference C2. Then the paste action gets
9681 // undone, which should also undo A2's formula to reference back to B2.
9683 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9685 m_pDoc->InsertTab(0, "Test");
9687 // A2 references B2.
9688 m_pDoc->SetString(ScAddress(0, 1, 0), "=B2");
9690 ScMarkData aMark(m_pDoc->GetSheetLimits());
9691 aMark.SelectOneTable(0);
9693 // Set up clip document for cutting of B2.
9694 ScDocument aClipDoc(SCDOCMODE_CLIP);
9695 aClipDoc.ResetClip(m_pDoc, &aMark);
9696 ScClipParam aParam(ScAddress(1, 1, 0), true);
9697 aClipDoc.SetClipParam(aParam);
9698 aClipDoc.SetValue(ScAddress(1, 1, 0), 12.0);
9700 // Set up undo document for reference update.
9701 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9702 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9704 // Do the pasting of 12 into C2. This should update A2 to reference C2.
9705 m_pDoc->CopyFromClip(ScAddress(2, 1, 0), aMark, InsertDeleteFlags::CONTENTS, pUndoDoc.get(),
9706 &aClipDoc);
9707 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(0, 1, 0));
9709 CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 should be referencing C2.", OUString("=C2"),
9710 m_pDoc->GetFormula(0, 1, 0));
9712 // At this point, the ref undo document should contain a formula cell at A2 that references B2.
9713 CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 in the undo document should be referencing B2.",
9714 OUString("=B2"), pUndoDoc->GetFormula(0, 1, 0));
9716 ScUndoPaste aUndo(m_xDocShell.get(), ScRange(2, 1, 0), aMark, std::move(pUndoDoc), nullptr,
9717 InsertDeleteFlags::CONTENTS, nullptr, false, nullptr);
9718 aUndo.Undo();
9720 // Now A2 should be referencing B2 once again.
9721 CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 should be referencing B2 after undo.", OUString("=B2"),
9722 m_pDoc->GetFormula(0, 1, 0));
9724 m_pDoc->DeleteTab(0);
9727 void TestCopyPaste::testCutPasteGroupRefUndo()
9729 // Test that Cut&Paste part of a grouped formula adjusts references
9730 // correctly and Undo works.
9732 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9734 m_pDoc->InsertTab(0, "Test");
9736 // Formula data in A1:A9
9737 std::vector<std::vector<const char*>> aData
9738 = { { "1" }, { "=A1+A1" }, { "=A2+A1" }, { "=A3+A2" }, { "=A4+A3" },
9739 { "=A5+A4" }, { "=A6+A5" }, { "=A7+A6" }, { "=A8+A7" } };
9741 ScAddress aPos(0, 0, 0);
9742 ScRange aDataRange = insertRangeData(m_pDoc, aPos, aData);
9743 CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to insert data", aPos, aDataRange.aStart);
9745 // Check initial data.
9746 const char* aDataCheck[][2] = { { "1", "" }, { "2", "=A1+A1" }, { "3", "=A2+A1" },
9747 { "5", "=A3+A2" }, { "8", "=A4+A3" }, { "13", "=A5+A4" },
9748 { "21", "=A6+A5" }, { "34", "=A7+A6" }, { "55", "=A8+A7" } };
9749 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataCheck); ++i)
9751 OUString aString = m_pDoc->GetString(0, i, 0);
9752 CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial data failure",
9753 OUString::createFromAscii(aDataCheck[i][0]), aString);
9754 aString = m_pDoc->GetFormula(0, i, 0);
9755 CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial formula failure",
9756 OUString::createFromAscii(aDataCheck[i][1]), aString);
9759 ScMarkData aMark(m_pDoc->GetSheetLimits());
9760 aMark.SelectOneTable(0);
9762 // Set up clip document.
9763 ScDocument aClipDoc(SCDOCMODE_CLIP);
9764 aClipDoc.ResetClip(m_pDoc, &aMark);
9765 // Cut A4:A6 to clipboard with Undo.
9766 std::unique_ptr<ScUndoCut> pUndoCut(
9767 cutToClip(*m_xDocShell, ScRange(0, 3, 0, 0, 5, 0), &aClipDoc, true));
9769 // Check data after Cut.
9770 const char* aCutCheck[] = { "1", "2", "3", "", "", "", "0", "0", "0" };
9771 for (size_t i = 0; i < SAL_N_ELEMENTS(aCutCheck); ++i)
9773 OUString aString = m_pDoc->GetString(0, i, 0);
9774 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cut data failure", OUString::createFromAscii(aCutCheck[i]),
9775 aString);
9778 // Paste to B5:B7 with Undo.
9779 ScRange aPasteRange(1, 4, 0, 1, 6, 0);
9780 aMark.SetMarkArea(aPasteRange);
9781 ScDocument* pPasteUndoDoc = new ScDocument(SCDOCMODE_UNDO);
9782 pPasteUndoDoc->InitUndoSelected(*m_pDoc, aMark);
9783 std::unique_ptr<ScUndoPaste> pUndoPaste(
9784 createUndoPaste(*m_xDocShell, aPasteRange, ScDocumentUniquePtr(pPasteUndoDoc)));
9785 m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::ALL, pPasteUndoDoc, &aClipDoc);
9787 // Check data after Paste.
9788 const char* aPasteCheck[][4] = { { "1", "", "", "" },
9789 { "2", "", "=A1+A1", "" },
9790 { "3", "", "=A2+A1", "" },
9791 { "", "", "", "" },
9792 { "", "5", "", "=A3+A2" },
9793 { "", "8", "", "=B5+A3" },
9794 { "21", "13", "=B7+B6", "=B6+B5" },
9795 { "34", "", "=A7+B7", "" },
9796 { "55", "", "=A8+A7", "" } };
9797 for (size_t i = 0; i < SAL_N_ELEMENTS(aPasteCheck); ++i)
9799 for (size_t j = 0; j < 2; ++j)
9801 OUString aString = m_pDoc->GetString(j, i, 0);
9802 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste data failure",
9803 OUString::createFromAscii(aPasteCheck[i][j]), aString);
9804 aString = m_pDoc->GetFormula(j, i, 0);
9805 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste formula failure",
9806 OUString::createFromAscii(aPasteCheck[i][2 + j]), aString);
9810 // Undo Paste and check, must be same as after Cut.
9811 pUndoPaste->Undo();
9812 for (size_t i = 0; i < SAL_N_ELEMENTS(aCutCheck); ++i)
9814 OUString aString = m_pDoc->GetString(0, i, 0);
9815 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Paste data failure",
9816 OUString::createFromAscii(aCutCheck[i]), aString);
9819 // Undo Cut and check, must be initial data.
9820 pUndoCut->Undo();
9821 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataCheck); ++i)
9823 OUString aString = m_pDoc->GetString(0, i, 0);
9824 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut data failure",
9825 OUString::createFromAscii(aDataCheck[i][0]), aString);
9826 aString = m_pDoc->GetFormula(0, i, 0);
9827 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut formula failure",
9828 OUString::createFromAscii(aDataCheck[i][1]), aString);
9831 m_pDoc->DeleteTab(0);
9834 void TestCopyPaste::testMoveRefBetweenSheets()
9836 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9838 m_pDoc->InsertTab(0, "Test1");
9839 m_pDoc->InsertTab(1, "Test2");
9841 m_pDoc->SetValue(ScAddress(0, 0, 0), 12.0);
9842 m_pDoc->SetValue(ScAddress(1, 0, 0), 10.0);
9843 m_pDoc->SetValue(ScAddress(2, 0, 0), 8.0);
9844 m_pDoc->SetString(ScAddress(0, 1, 0), "=A1");
9845 m_pDoc->SetString(ScAddress(0, 2, 0), "=SUM(A1:C1)");
9847 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 0, 0)));
9848 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
9849 CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
9851 // These formulas should not display the sheet name.
9852 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=A1"), m_pDoc->GetFormula(0, 1, 0));
9853 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A1:C1)"),
9854 m_pDoc->GetFormula(0, 2, 0));
9856 // Move Test1.A2:A3 to Test2.A2:A3.
9857 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
9858 bool bMoved
9859 = rFunc.MoveBlock(ScRange(0, 1, 0, 0, 2, 0), ScAddress(0, 1, 1), true, true, false, true);
9860 CPPUNIT_ASSERT(bMoved);
9862 CPPUNIT_ASSERT_EQUAL_MESSAGE("This cell should be empty after the move.", CELLTYPE_NONE,
9863 m_pDoc->GetCellType(ScAddress(0, 1, 0)));
9864 ASSERT_DOUBLES_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 1, 1)));
9865 ASSERT_DOUBLES_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 1)));
9867 // The reference in the pasted formula should display sheet name after the move.
9868 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=Test1.A1"),
9869 m_pDoc->GetFormula(0, 1, 1));
9870 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(Test1.A1:C1)"),
9871 m_pDoc->GetFormula(0, 2, 1));
9873 m_pDoc->DeleteTab(1);
9874 m_pDoc->DeleteTab(0);
9877 void TestCopyPaste::testUndoCut()
9879 m_pDoc->InsertTab(0, "Test");
9881 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9883 // Insert values into A1:A3.
9884 m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
9885 m_pDoc->SetValue(ScAddress(0, 1, 0), 10.0);
9886 m_pDoc->SetValue(ScAddress(0, 2, 0), 100.0);
9888 // SUM in A4.
9889 m_pDoc->SetString(ScAddress(0, 3, 0), "=SUM(A1:A3)");
9890 CPPUNIT_ASSERT_EQUAL(111.0, m_pDoc->GetValue(0, 3, 0));
9892 // Select A1:A3.
9893 ScMarkData aMark(m_pDoc->GetSheetLimits());
9894 ScRange aRange(0, 0, 0, 0, 2, 0);
9895 aMark.SetMarkArea(aRange);
9896 aMark.MarkToMulti();
9898 // Set up an undo object for cutting A1:A3.
9899 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9900 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9901 m_pDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *pUndoDoc);
9902 ASSERT_DOUBLES_EQUAL(1.0, pUndoDoc->GetValue(ScAddress(0, 0, 0)));
9903 ASSERT_DOUBLES_EQUAL(10.0, pUndoDoc->GetValue(ScAddress(0, 1, 0)));
9904 ASSERT_DOUBLES_EQUAL(100.0, pUndoDoc->GetValue(ScAddress(0, 2, 0)));
9905 ScUndoCut aUndo(m_xDocShell.get(), aRange, aRange.aEnd, aMark, std::move(pUndoDoc));
9907 // "Cut" the selection.
9908 m_pDoc->DeleteSelection(InsertDeleteFlags::ALL, aMark);
9909 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 3, 0)); // The SUM should be zero after the "cut".
9911 // Undo it, and check the result.
9912 aUndo.Undo();
9913 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 0, 0)));
9914 ASSERT_DOUBLES_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
9915 ASSERT_DOUBLES_EQUAL(100.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
9916 ASSERT_DOUBLES_EQUAL(
9917 111.0, m_pDoc->GetValue(0, 3, 0)); // The SUM value should be back to the original.
9919 // Redo it and check.
9920 aUndo.Redo();
9921 ASSERT_DOUBLES_EQUAL(0.0, m_pDoc->GetValue(0, 3, 0));
9923 // Undo again.
9924 aUndo.Undo();
9925 ASSERT_DOUBLES_EQUAL(111.0, m_pDoc->GetValue(0, 3, 0));
9927 m_pDoc->DeleteTab(0);
9930 void TestCopyPaste::testMoveBlock()
9932 m_pDoc->InsertTab(0, "SheetNotes");
9934 // We need a drawing layer in order to create caption objects.
9935 m_pDoc->InitDrawLayer(m_xDocShell.get());
9937 m_pDoc->SetValue(0, 0, 0, 1);
9938 m_pDoc->SetString(1, 0, 0, "=A1+1");
9939 m_pDoc->SetString(2, 0, 0, "test");
9941 // add notes to A1:C1
9942 ScAddress aAddrA1 = setNote(0, 0, 0, "Hello world in A1");
9943 ScAddress aAddrB1 = setNote(1, 0, 0, "Hello world in B1");
9944 ScAddress aAddrC1 = setNote(2, 0, 0, "Hello world in C1");
9945 ScAddress aAddrD1(3, 0, 0);
9947 // previous tests on cell note content are ok. this one fails !!! :(
9948 //CPPUNIT_ASSERT_MESSAGE("Note content in B1 before move block", m_pDoc->GetNote(aAddrB1)->GetText() == aHelloB1);
9950 // move notes to B1:D1
9951 ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc();
9952 bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0, 0, 2, 0, 0), ScAddress(1, 0, 0),
9953 true /*bCut*/, false, false, false);
9955 CPPUNIT_ASSERT_MESSAGE("Cells not moved", bMoveDone);
9957 //check cell content
9958 OUString aString = m_pDoc->GetString(3, 0, 0);
9959 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D1 should contain: test", OUString("test"), aString);
9960 aString = m_pDoc->GetFormula(2, 0, 0);
9961 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C1 should contain an updated formula", OUString("=B1+1"),
9962 aString);
9963 double fValue = m_pDoc->GetValue(aAddrB1);
9964 ASSERT_DOUBLES_EQUAL_MESSAGE("Cell B1 should contain 1", fValue, 1);
9966 // cell notes has been moved 1 cell right (event when overlapping)
9967 CPPUNIT_ASSERT_MESSAGE("There should be NO note on A1", !m_pDoc->HasNote(aAddrA1));
9968 CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", m_pDoc->HasNote(aAddrB1));
9969 CPPUNIT_ASSERT_MESSAGE("There should be a note on C1", m_pDoc->HasNote(aAddrC1));
9970 CPPUNIT_ASSERT_MESSAGE("There should be a note on D1", m_pDoc->HasNote(aAddrD1));
9971 /* still failing, wrong content ???
9972 OUString sNoteText;
9973 sNoteText = m_pDoc->GetNote(aAddrB1)->GetText();
9974 CPPUNIT_ASSERT_MESSAGE("Note content in B1", sNoteText == aHelloA1);
9975 sNoteText = m_pDoc->GetNote(aAddrC1)->GetText();
9976 CPPUNIT_ASSERT_MESSAGE("Note content in C1", sNoteText == aHelloB1);
9977 sNoteText = m_pDoc->GetNote(aAddrD1)->GetText();
9978 CPPUNIT_ASSERT_MESSAGE("Note content in D1", sNoteText == aHelloC1);
9981 m_pDoc->DeleteTab(0);
9984 void TestCopyPaste::testCopyPasteRelativeFormula()
9986 m_pDoc->InsertTab(0, "Formula");
9988 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
9990 // Insert values to A2 and A4.
9991 m_pDoc->SetValue(ScAddress(0, 1, 0), 1);
9992 m_pDoc->SetValue(ScAddress(0, 3, 0), 2);
9994 // Insert formula to B4.
9995 m_pDoc->SetString(ScAddress(1, 3, 0), "=A4");
9996 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1, 3, 0)));
9998 // Select and copy B3:B4 to the clipboard.
9999 ScRange aRange(1, 2, 0, 1, 3, 0);
10000 ScClipParam aClipParam(aRange, false);
10001 ScMarkData aMark(m_pDoc->GetSheetLimits());
10002 aMark.SetMarkArea(aRange);
10003 ScDocument aClipDoc(SCDOCMODE_CLIP);
10004 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10006 // Paste it to B1:B2.
10007 InsertDeleteFlags nFlags = InsertDeleteFlags::ALL;
10008 ScRange aDestRange(1, 0, 0, 1, 1, 0);
10009 aMark.SetMarkArea(aDestRange);
10010 m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
10012 // B2 references A2, so the value should be 1.
10013 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1, 1, 0)));
10015 // Clear content and start over.
10016 clearSheet(m_pDoc, 0);
10017 clearSheet(&aClipDoc, 0);
10019 // Insert a single formula cell in A1.
10020 m_pDoc->SetString(ScAddress(0, 0, 0), "=ROW()");
10021 const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0, 0, 0));
10022 CPPUNIT_ASSERT(pFC);
10023 CPPUNIT_ASSERT(!pFC->IsShared()); // single formula cell is never shared.
10025 // Copy A1 to clipboard.
10026 aClipParam = ScClipParam(ScAddress(0, 0, 0), false);
10027 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10029 pFC = aClipDoc.GetFormulaCell(ScAddress(0, 0, 0));
10030 CPPUNIT_ASSERT(pFC);
10031 CPPUNIT_ASSERT(!pFC->IsShared());
10033 // Paste to A3.
10034 aDestRange = ScRange(0, 2, 0, 0, 2, 0);
10035 aMark.SetMarkArea(aDestRange);
10036 m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
10038 pFC = m_pDoc->GetFormulaCell(ScAddress(0, 2, 0));
10039 CPPUNIT_ASSERT(pFC);
10040 CPPUNIT_ASSERT(!pFC->IsShared());
10042 // Delete A3 and make sure it doesn't crash (see fdo#76132).
10043 clearRange(m_pDoc, ScAddress(0, 2, 0));
10044 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(ScAddress(0, 2, 0)));
10046 m_pDoc->DeleteTab(0);
10049 void TestCopyPaste::testCopyPasteRepeatOneFormula()
10051 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
10053 m_pDoc->InsertTab(0, "Test");
10055 ScDocument aClipDoc(SCDOCMODE_CLIP);
10056 ScMarkData aMark(m_pDoc->GetSheetLimits());
10058 // Insert values in A1:B10.
10059 for (SCROW i = 0; i < 10; ++i)
10061 m_pDoc->SetValue(ScAddress(0, i, 0), i + 1.0); // column A
10062 m_pDoc->SetValue(ScAddress(1, i, 0), (i + 1.0) * 10.0); // column B
10065 // Insert a formula in C1.
10066 ScAddress aPos(2, 0, 0); // C1
10067 m_pDoc->SetString(aPos, "=SUM(A1:B1)");
10068 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(aPos));
10070 // This check makes only sense if group listeners are activated.
10071 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10072 // At this point, there should be only one normal area listener listening
10073 // on A1:B1.
10074 ScRange aWholeSheet(0, 0, 0, m_pDoc->MaxCol(), m_pDoc->MaxRow(), 0);
10075 ScBroadcastAreaSlotMachine* pBASM = m_pDoc->GetBASM();
10076 CPPUNIT_ASSERT(pBASM);
10077 std::vector<sc::AreaListener> aListeners
10078 = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10079 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10080 const sc::AreaListener* pListener = aListeners.data();
10081 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 0, 0), pListener->maArea);
10082 CPPUNIT_ASSERT_MESSAGE("This listener shouldn't be a group listener.",
10083 !pListener->mbGroupListening);
10084 #endif
10086 // Copy C1 to clipboard.
10087 ScClipParam aClipParam(aPos, false);
10088 aMark.SetMarkArea(aPos);
10089 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10091 // Paste it to C2:C10.
10092 ScRange aDestRange(2, 1, 0, 2, 9, 0);
10093 aMark.SetMarkArea(aDestRange);
10094 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &aClipDoc);
10096 // Make sure C1:C10 are grouped.
10097 const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(aPos);
10098 CPPUNIT_ASSERT(pFC);
10099 CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength());
10101 // Check the formula results.
10102 for (SCROW i = 0; i < 10; ++i)
10104 double fExpected = (i + 1.0) * 11.0;
10105 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i, 0)));
10108 // This check makes only sense if group listeners are activated.
10109 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10110 // At this point, there should only be one area listener and it should be
10111 // a group listener listening on A1:B10.
10112 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10113 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10114 pListener = aListeners.data();
10115 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 9, 0), pListener->maArea);
10116 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
10117 pListener->mbGroupListening);
10118 #endif
10120 // Insert a new row at row 1.
10121 ScRange aRowOne(0, 0, 0, m_pDoc->MaxCol(), 0, 0);
10122 aMark.SetMarkArea(aRowOne);
10123 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
10124 rFunc.InsertCells(aRowOne, &aMark, INS_INSROWS_BEFORE, true, true);
10126 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 should be empty.", CELLTYPE_NONE,
10127 m_pDoc->GetCellType(ScAddress(2, 0, 0)));
10129 // This check makes only sense if group listeners are activated.
10130 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10131 // Make there we only have one group area listener listening on A2:B11.
10132 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10133 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10134 pListener = aListeners.data();
10135 CPPUNIT_ASSERT_EQUAL(ScRange(0, 1, 0, 1, 10, 0), pListener->maArea);
10136 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
10137 pListener->mbGroupListening);
10138 #endif
10140 // Check the formula results.
10141 for (SCROW i = 0; i < 10; ++i)
10143 double fExpected = (i + 1.0) * 11.0;
10144 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i + 1, 0)));
10147 // Delete row at row 1 to shift the cells up.
10148 rFunc.DeleteCells(aRowOne, &aMark, DelCellCmd::Rows, true);
10150 // Check the formula results again.
10151 for (SCROW i = 0; i < 10; ++i)
10153 double fExpected = (i + 1.0) * 11.0;
10154 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i, 0)));
10157 // This check makes only sense if group listeners are activated.
10158 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10159 // Check the group area listener again to make sure it's listening on A1:B10 once again.
10160 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10161 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10162 pListener = aListeners.data();
10163 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 9, 0), pListener->maArea);
10164 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
10165 pListener->mbGroupListening);
10166 #endif
10168 m_pDoc->DeleteTab(0);
10171 void TestCopyPaste::testCopyPasteMixedReferenceFormula()
10173 sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc.
10174 m_pDoc->InsertTab(0, "Test");
10176 // Insert value to C3
10177 m_pDoc->SetValue(2, 2, 0, 1.0);
10179 // Insert formula to A1 with mixed relative/absolute addressing.
10180 m_pDoc->SetString(0, 0, 0, "=SUM(B:$C)");
10181 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B:$C)"),
10182 m_pDoc->GetFormula(0, 0, 0));
10183 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, 0));
10185 // Copy formula in A1 to clipboard.
10186 ScRange aRange(ScAddress(0, 0, 0));
10187 ScDocument aClipDoc(SCDOCMODE_CLIP);
10188 copyToClip(m_pDoc, aRange, &aClipDoc);
10190 // Paste formula to B1.
10191 aRange = ScAddress(1, 0, 0);
10192 pasteFromClip(m_pDoc, aRange, &aClipDoc);
10193 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(C:$C)"),
10194 m_pDoc->GetFormula(1, 0, 0));
10195 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 0, 0));
10196 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 0, 0));
10198 // Paste formula to C1. All three results now must be circular reference.
10199 aRange = ScAddress(2, 0, 0);
10200 pasteFromClip(m_pDoc, aRange, &aClipDoc);
10201 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM($C:D)"),
10202 m_pDoc->GetFormula(2, 0, 0)); // reference put in order
10203 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(0, 0, 0));
10204 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(1, 0, 0));
10205 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(2, 0, 0));
10207 m_pDoc->DeleteTab(0);
10210 void TestCopyPaste::testCopyPasteFormulas()
10212 m_pDoc->InsertTab(0, "Sheet1");
10213 m_pDoc->InsertTab(1, "Sheet2");
10215 m_pDoc->SetString(0, 0, 0, "=COLUMN($A$1)");
10216 m_pDoc->SetString(0, 1, 0, "=$A$1+B2");
10217 m_pDoc->SetString(0, 2, 0, "=$Sheet2.A1");
10218 m_pDoc->SetString(0, 3, 0, "=$Sheet2.$A$1");
10219 m_pDoc->SetString(0, 4, 0, "=$Sheet2.A$1");
10221 // to prevent ScEditableTester in ScDocFunc::MoveBlock
10222 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(0, 0, 0), 1.0);
10223 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(0, 1, 0), 1.0);
10224 ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc();
10225 bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0, 0, 0, 4, 0), ScAddress(10, 10, 0), false,
10226 false, false, true);
10228 // check that moving was successful, mainly for editable tester
10229 CPPUNIT_ASSERT(bMoveDone);
10230 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(10, 10, 0), 1.0);
10231 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(10, 11, 0), 1.0);
10232 CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($A$1)"), m_pDoc->GetFormula(10, 10, 0));
10233 CPPUNIT_ASSERT_EQUAL(OUString("=$A$1+L12"), m_pDoc->GetFormula(10, 11, 0));
10234 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.K11"), m_pDoc->GetFormula(10, 12, 0));
10235 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.$A$1"), m_pDoc->GetFormula(10, 13, 0));
10236 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.K$1"), m_pDoc->GetFormula(10, 14, 0));
10239 void TestCopyPaste::testCopyPasteFormulasExternalDoc()
10241 SfxMedium* pMedium = new SfxMedium("file:///source.fake", StreamMode::STD_READWRITE);
10242 m_xDocShell->DoLoad(pMedium);
10244 ScDocShellRef xExtDocSh = new ScDocShell;
10245 OUString const aExtDocName("file:///extdata.fake");
10246 SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
10247 xExtDocSh->DoLoad(pMed);
10248 CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
10249 findLoadedDocShellByName(aExtDocName) != nullptr);
10251 ScDocument& rExtDoc = xExtDocSh->GetDocument();
10252 rExtDoc.InsertTab(0, "ExtSheet1");
10253 rExtDoc.InsertTab(1, "ExtSheet2");
10255 m_pDoc->InsertTab(0, "Sheet1");
10256 m_pDoc->InsertTab(1, "Sheet2");
10258 m_pDoc->SetString(0, 0, 0, "=COLUMN($A$1)");
10259 m_pDoc->SetString(0, 1, 0, "=$A$1+B2");
10260 m_pDoc->SetString(0, 2, 0, "=$Sheet2.A1");
10261 m_pDoc->SetString(0, 3, 0, "=$Sheet2.$A$1");
10262 m_pDoc->SetString(0, 4, 0, "=$Sheet2.A$1");
10263 m_pDoc->SetString(0, 5, 0, "=$Sheet1.$A$1");
10265 ScRange aRange(0, 0, 0, 0, 5, 0);
10266 ScClipParam aClipParam(aRange, false);
10267 ScMarkData aMark(m_pDoc->GetSheetLimits());
10268 aMark.SetMarkArea(aRange);
10269 ScDocument aClipDoc(SCDOCMODE_CLIP);
10270 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10272 aRange = ScRange(1, 1, 1, 1, 6, 1);
10273 ScMarkData aMarkData2(m_pDoc->GetSheetLimits());
10274 aMarkData2.SetMarkArea(aRange);
10275 rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
10277 OUString aFormula = rExtDoc.GetFormula(1, 1, 1);
10278 //adjust absolute refs pointing to the copy area
10279 CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($B$2)"), aFormula);
10280 aFormula = rExtDoc.GetFormula(1, 2, 1);
10281 //adjust absolute refs and keep relative refs
10282 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2+C3"), aFormula);
10283 aFormula = rExtDoc.GetFormula(1, 3, 1);
10284 // make absolute sheet refs external refs
10285 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B2"), aFormula);
10286 aFormula = rExtDoc.GetFormula(1, 4, 1);
10287 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.$A$1"), aFormula);
10288 aFormula = rExtDoc.GetFormula(1, 5, 1);
10289 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B$1"), aFormula);
10290 aFormula = rExtDoc.GetFormula(1, 6, 1);
10291 CPPUNIT_ASSERT_EQUAL(OUString("=$ExtSheet2.$B$2"), aFormula);
10293 xExtDocSh->DoClose();
10296 void TestCopyPaste::testCopyPasteReferencesExternalDoc()
10298 SfxMedium* pMedium = new SfxMedium("file:///source.fake", StreamMode::STD_READWRITE);
10299 m_xDocShell->DoLoad(pMedium);
10301 ScDocShellRef xExtDocSh = new ScDocShell;
10302 OUString aExtDocName("file:///extdata.fake");
10303 SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
10304 xExtDocSh->DoLoad(pMed);
10305 CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
10306 findLoadedDocShellByName(aExtDocName) != nullptr);
10308 ScDocument& rExtDoc = xExtDocSh->GetDocument();
10309 rExtDoc.InsertTab(0, "ExtSheet1");
10311 m_pDoc->InsertTab(0, "Sheet1");
10313 m_pDoc->SetString(0, 5, 0, "=SUM($Sheet1.A1:A5)");
10315 ScRange aRange(0, 2, 0, 0, 5, 0);
10316 ScClipParam aClipParam(aRange, false);
10317 ScMarkData aMark(m_pDoc->GetSheetLimits());
10318 aMark.SetMarkArea(aRange);
10319 ScDocument aClipDoc(SCDOCMODE_CLIP);
10320 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10322 aRange = ScRange(0, 0, 0, 0, 3, 0);
10323 ScMarkData aMarkData2(m_pDoc->GetSheetLimits());
10324 aMarkData2.SetMarkArea(aRange);
10325 rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
10327 OUString aFormula = rExtDoc.GetFormula(0, 3, 0);
10328 //adjust absolute refs pointing to the copy area
10329 CPPUNIT_ASSERT_EQUAL(OUString("=SUM('file:///source.fake'#$Sheet1.A#REF!:A3)"), aFormula);
10331 xExtDocSh->DoClose();
10334 void TestCopyPaste::testTdf68976()
10336 const SCTAB nTab = 0;
10337 m_pDoc->InsertTab(nTab, "Test");
10339 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10340 m_pDoc->SetString(0, 1, nTab, "=$A$1"); // A2
10341 m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3
10343 // Cut A3 to the clip document.
10344 ScDocument aClipDoc(SCDOCMODE_CLIP);
10345 ScRange aSrcRange(0, 2, nTab, 0, 2, nTab);
10346 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false); // A3
10348 ScRange aDestRange(1, 3, nTab, 1, 3, nTab); // B4
10349 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10351 // Transpose
10352 ScDocument* pOrigClipDoc = &aClipDoc;
10353 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10354 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10355 aDestMark.SetMarkArea(aDestRange);
10356 // Paste
10357 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10358 true, false, true, false);
10359 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10360 pTransClip.reset();
10362 // Check results
10363 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, nTab)); // A1
10364 // Without the fix in place, this would have failed with
10365 // - Expected: =$A$1
10366 // - Actual : =$B$4
10367 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=$A$1"),
10368 m_pDoc->GetFormula(0, 1, nTab));
10369 // Without the fix in place, this would have failed with
10370 // - Expected: 1
10371 // - Actual : 1000
10372 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10373 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10374 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(1, 3, nTab)); // B4
10377 void TestCopyPaste::testTdf71058()
10379 const SCTAB nTab = 0;
10380 m_pDoc->InsertTab(nTab, "Test");
10382 m_pDoc->SetString(2, 2, nTab, "=C4"); // C3
10383 m_pDoc->SetString(3, 2, nTab, "=D4"); // D3
10384 m_pDoc->SetValue(2, 3, nTab, 1.0); // C4
10385 m_pDoc->SetValue(3, 3, nTab, 2.0); // D4
10387 // Cut C4:C5 to the clip document.
10388 ScDocument aClipDoc(SCDOCMODE_CLIP);
10389 ScRange aSrcRange(2, 3, nTab, 3, 3, nTab);
10390 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
10392 // To E6:E7
10393 ScRange aDestRange(4, 5, nTab, 4, 6, nTab);
10394 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10396 // Transpose
10397 ScDocument* pOrigClipDoc = &aClipDoc;
10398 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10399 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10400 aDestMark.SetMarkArea(aDestRange);
10401 // Paste
10402 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10403 true, false, true, false);
10404 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10405 pTransClip.reset();
10407 // Check precondition
10408 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(4, 5, nTab));
10409 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(4, 6, nTab));
10411 // Check results
10412 // Without the fix in place, this would have failed with
10413 // - Expected: =E6
10414 // - Actual : =C4
10415 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=E6"), m_pDoc->GetFormula(2, 2, nTab));
10416 // Without the fix in place, this would have failed with
10417 // - Expected: 1
10418 // - Actual : 0
10419 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(2, 2, nTab));
10421 // Without the fix in place, this would have failed with
10422 // - Expected: =E7
10423 // - Actual : =D4
10424 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=E7"), m_pDoc->GetFormula(3, 2, nTab));
10425 // Without the fix in place, this would have failed with
10426 // - Expected: 2
10427 // - Actual : 0
10428 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, nTab));
10431 void TestCopyPaste::testTdf149554()
10433 const SCTAB nTab = 0;
10434 m_pDoc->InsertTab(nTab, "Test");
10436 // Cut C4:C5 to the clip document.
10437 ScDocument aClipDoc(SCDOCMODE_CLIP);
10438 ScRange aSrcRange(2, 3, nTab, 3, 3, nTab);
10439 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
10441 // To E6:E7
10442 ScRange aDestRange(4, 5, nTab, 4, 6, nTab);
10443 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10445 // Transpose
10446 ScDocument* pOrigClipDoc = &aClipDoc;
10447 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10448 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10449 aDestMark.SetMarkArea(aDestRange);
10450 // Paste. Without the fix in place, this test would have crashed here
10451 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10452 true, false, true, false);
10453 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10454 pTransClip.reset();
10456 m_pDoc->DeleteTab(0);
10459 void TestCopyPaste::testMixData()
10461 m_pDoc->InsertTab(0, "Test");
10463 m_pDoc->SetValue(ScAddress(1, 0, 0), 2.0); // B1
10464 m_pDoc->SetValue(ScAddress(0, 1, 0), 3.0); // A2
10466 // Copy A1:B1 to the clip document.
10467 ScDocument aClipDoc(SCDOCMODE_CLIP);
10468 copyToClip(m_pDoc, ScRange(0, 0, 0, 1, 0, 0), &aClipDoc); // A1:B1
10470 // Copy A2:B2 to the mix document (for arithmetic paste).
10471 ScDocument aMixDoc(SCDOCMODE_CLIP);
10472 copyToClip(m_pDoc, ScRange(0, 1, 0, 1, 1, 0), &aMixDoc); // A2:B2
10474 // Paste A1:B1 to A2:B2 and perform addition.
10475 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 1, 1, 0), &aClipDoc);
10476 m_pDoc->MixDocument(ScRange(0, 1, 0, 1, 1, 0), ScPasteFunc::ADD, false, aMixDoc);
10478 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0, 1, 0)); // A2
10479 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 1, 0)); // B2
10481 // Clear everything and start over.
10482 clearSheet(m_pDoc, 0);
10483 clearSheet(&aClipDoc, 0);
10484 clearSheet(&aMixDoc, 0);
10486 // Set values to A1, A2, and B1. B2 will remain empty.
10487 m_pDoc->SetValue(ScAddress(0, 0, 0), 15.0);
10488 m_pDoc->SetValue(ScAddress(0, 1, 0), 16.0);
10489 m_pDoc->SetValue(ScAddress(1, 0, 0), 12.0);
10490 CPPUNIT_ASSERT_EQUAL_MESSAGE("B2 should be empty.", CELLTYPE_NONE,
10491 m_pDoc->GetCellType(ScAddress(1, 1, 0)));
10493 // Copy A1:A2 and paste it onto B1:B2 with subtraction operation.
10494 copyToClip(m_pDoc, ScRange(0, 0, 0, 0, 1, 0), &aClipDoc);
10495 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(0, 0, 0)),
10496 aClipDoc.GetValue(ScAddress(0, 0, 0)));
10497 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(0, 1, 0)),
10498 aClipDoc.GetValue(ScAddress(0, 1, 0)));
10500 copyToClip(m_pDoc, ScRange(1, 0, 0, 1, 1, 0), &aMixDoc);
10501 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(1, 0, 0)),
10502 aMixDoc.GetValue(ScAddress(1, 0, 0)));
10503 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(1, 1, 0)),
10504 aMixDoc.GetValue(ScAddress(1, 1, 0)));
10506 pasteFromClip(m_pDoc, ScRange(1, 0, 0, 1, 1, 0), &aClipDoc);
10507 m_pDoc->MixDocument(ScRange(1, 0, 0, 1, 1, 0), ScPasteFunc::SUB, false, aMixDoc);
10509 CPPUNIT_ASSERT_EQUAL(-3.0, m_pDoc->GetValue(ScAddress(1, 0, 0))); // 12 - 15
10510 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(ScAddress(1, 1, 0))); // 0 - 16
10512 m_pDoc->DeleteTab(0);
10515 void TestCopyPaste::testMixDataAsLinkTdf116413()
10517 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
10519 const SCTAB nTab = 0;
10520 m_pDoc->InsertTab(nTab, "Test");
10522 // Scenario 1: Past "As Link" and "Add" operation (as described in tdf#116413)
10523 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10524 m_pDoc->SetValue(0, 1, nTab, 1000.0); // A2
10526 // Copy A1 to the clip document.
10527 ScDocument aClipDoc(SCDOCMODE_CLIP);
10528 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 0, nTab), &aClipDoc); // A1
10530 ScRange aDestRange(0, 1, nTab, 0, 1, nTab);
10531 // Copy A2 to the mix document (for arithmetic paste).
10532 ScDocument aMixDoc(SCDOCMODE_CLIP);
10533 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A2
10535 // Paste A1 to A2 "As Link" and perform addition.
10536 ScMarkData aMark(m_pDoc->GetSheetLimits());
10537 aMark.SetMarkArea(aDestRange);
10538 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10540 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10542 // Test precondition
10543 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10544 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10546 // Change A1 from 1.0 to 2.0 (auto calculation is triggered)
10547 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10549 // Without the fix in place, this would have failed with
10550 // - Expected: =1002
10551 // - Actual : =1001
10552 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10553 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10555 // Clear everything and start over.
10556 clearSheet(m_pDoc, nTab);
10557 clearSheet(&aClipDoc, nTab);
10558 clearSheet(&aMixDoc, nTab);
10560 // Scenario 2: Like Scenario 1, but with a range (3 columns)
10561 m_pDoc->InsertTab(nTab, "Test");
10563 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10564 m_pDoc->SetValue(0, 1, nTab, 1000.0); // A2
10565 m_pDoc->SetValue(1, 0, nTab, 1.0); // B1
10566 m_pDoc->SetValue(1, 1, nTab, 1000.0); // B2
10567 m_pDoc->SetValue(2, 0, nTab, 1.0); // C1
10568 m_pDoc->SetValue(2, 1, nTab, 1000.0); // C2
10570 // Copy A1:C1 to the clip document.
10571 copyToClip(m_pDoc, ScRange(0, 0, nTab, 2, 0, nTab), &aClipDoc); // A1:C1
10573 aDestRange = ScRange(0, 1, nTab, 2, 1, nTab);
10574 // Copy A2:C2 to the mix document (for arithmetic paste).
10575 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A2:C2
10577 // Paste A1:C1 to A2:C2 "As Link" and perform addition.
10578 aMark = ScMarkData(m_pDoc->GetSheetLimits());
10579 aMark.SetMarkArea(aDestRange);
10580 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10582 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10584 // Test precondition
10585 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10586 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10588 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10589 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$B$1)"), m_pDoc->GetFormula(1, 1, nTab));
10591 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10592 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$C$1)"), m_pDoc->GetFormula(2, 1, nTab));
10594 // Change A1:C1 from 1.0 to 2.0 (auto calculation is triggered)
10595 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10596 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
10597 m_pDoc->SetValue(2, 0, nTab, 2.0); // C1
10599 // Without the fix in place, this would have failed with
10600 // - Expected: =1002
10601 // - Actual : =1001
10602 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10603 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10605 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10606 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$B$1)"), m_pDoc->GetFormula(1, 1, nTab));
10608 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10609 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$C$1)"), m_pDoc->GetFormula(2, 1, nTab));
10611 // Scenario 3: Like Scenario 2, but transposed
10612 m_pDoc->InsertTab(nTab, "Test");
10614 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10615 m_pDoc->SetValue(1, 0, nTab, 1000.0); // B1
10616 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10617 m_pDoc->SetValue(1, 1, nTab, 1000.0); // B2
10618 m_pDoc->SetValue(0, 2, nTab, 1.0); // A3
10619 m_pDoc->SetValue(1, 2, nTab, 1000.0); // B3
10621 // Copy A1:A3 to the clip document.
10622 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 2, nTab), &aClipDoc); // A1:A3
10624 aDestRange = ScRange(1, 0, nTab, 1, 2, nTab);
10625 // Copy B1:B3 to the mix document (for arithmetic paste).
10626 copyToClip(m_pDoc, aDestRange, &aMixDoc); // B1:B3
10628 // Paste A1:A3 to B1:B3 "As Link" and perform addition.
10629 aMark = ScMarkData(m_pDoc->GetSheetLimits());
10630 aMark.SetMarkArea(aDestRange);
10631 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10633 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10635 // Test precondition
10636 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nTab)); // B1
10637 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(1, 0, nTab));
10639 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10640 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$2)"), m_pDoc->GetFormula(1, 1, nTab));
10642 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10643 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$3)"), m_pDoc->GetFormula(1, 2, nTab));
10645 // Change A1:C1 from 1.0 to 2.0 (auto calculation is triggered)
10646 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10647 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10648 m_pDoc->SetValue(0, 2, nTab, 2.0); // A3
10650 // Without the fix in place, this would have failed with
10651 // - Expected: =1002
10652 // - Actual : =1001
10653 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 0, nTab)); // B1
10654 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(1, 0, nTab));
10656 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10657 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$2)"), m_pDoc->GetFormula(1, 1, nTab));
10659 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10660 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$3)"), m_pDoc->GetFormula(1, 2, nTab));
10662 m_pDoc->DeleteTab(nTab);
10665 void TestCopyPaste::testMixDataWithFormulaTdf116413()
10667 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
10669 const SCTAB nTab = 0;
10670 m_pDoc->InsertTab(nTab, "Test");
10672 // Scenario 1: There is already a reference in destination cell
10673 m_pDoc->InsertTab(nTab, "Test");
10675 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10676 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10677 m_pDoc->SetString(0, 2, nTab, "=A2"); // A3
10679 // Copy A1 to the clip document.
10680 ScDocument aClipDoc(SCDOCMODE_CLIP);
10681 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 0, nTab), &aClipDoc); // A1
10683 ScRange aDestRange(0, 2, nTab, 0, 2, nTab);
10684 ScDocument aMixDoc(SCDOCMODE_CLIP);
10685 // Copy A3 to the mix document (for arithmetic paste).
10686 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A3
10688 // Paste A1 to A3 and perform addition.
10689 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10690 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10692 // Test precondition
10693 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10694 CPPUNIT_ASSERT_EQUAL(OUString("=(A2)+100"), m_pDoc->GetFormula(0, 2, nTab));
10696 // Change A2 from 1.0 to 2.0 (auto calculation is triggered)
10697 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10699 // Without the fix in place, this would have failed with
10700 // - Expected: =102
10701 // - Actual : =101
10702 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10703 CPPUNIT_ASSERT_EQUAL(OUString("=(A2)+100"), m_pDoc->GetFormula(0, 2, nTab));
10705 // Clear everything and start over.
10706 clearSheet(m_pDoc, nTab);
10707 clearSheet(&aClipDoc, nTab);
10708 clearSheet(&aMixDoc, nTab);
10710 // Scenario 2: Similar to scenario 1, but a range of 4 cells and 2 of them have references
10711 m_pDoc->InsertTab(nTab, "Test");
10713 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10714 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10715 m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3
10717 m_pDoc->SetValue(1, 0, nTab, 100.0); // B1
10718 m_pDoc->SetValue(1, 1, nTab, 1.0); // B2
10719 m_pDoc->SetString(1, 2, nTab, "=B2"); // B3
10721 m_pDoc->SetValue(2, 0, nTab, 100.0); // C1
10722 m_pDoc->SetValue(2, 1, nTab, 1.0); // C2
10723 m_pDoc->SetString(2, 2, nTab, "=C2"); // C3
10725 m_pDoc->SetValue(3, 0, nTab, 100.0); // D1
10726 m_pDoc->SetValue(3, 1, nTab, 1.0); // D2
10727 m_pDoc->SetValue(3, 2, nTab, 1000.0); // D3
10729 // Copy A1:D1 to the clip document.
10730 copyToClip(m_pDoc, ScRange(0, 0, nTab, 3, 0, nTab), &aClipDoc); // A1:D1
10732 aDestRange = ScRange(0, 2, nTab, 3, 2, nTab);
10733 // Copy A3:D3 to the mix document (for arithmetic paste).
10734 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A3:D3
10736 // Paste A1:D1 to A3:D3 and perform addition.
10737 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10738 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10740 // Test precondition
10741 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10742 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(0, 2, nTab));
10744 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10745 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(1, 2, nTab));
10747 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10748 CPPUNIT_ASSERT_EQUAL(OUString("=(C2)+100"), m_pDoc->GetFormula(2, 2, nTab));
10750 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(3, 2, nTab)); // D3
10751 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(3, 2, nTab));
10753 // Change A2:D2 from 1.0 to 2.0 (auto calculation is triggered)
10754 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10755 m_pDoc->SetValue(1, 1, nTab, 2.0); // B2
10756 m_pDoc->SetValue(2, 1, nTab, 2.0); // C2
10757 m_pDoc->SetValue(3, 1, nTab, 2.0); // D2
10759 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10760 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(0, 2, nTab));
10762 // Without the fix in place, this would have failed with
10763 // - Expected: =102
10764 // - Actual : =101
10765 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10766 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(1, 2, nTab));
10768 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10769 CPPUNIT_ASSERT_EQUAL(OUString("=(C2)+100"), m_pDoc->GetFormula(2, 2, nTab));
10771 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(3, 2, nTab)); // D3
10772 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(3, 2, nTab));
10774 // Scenario 3: Similar to scenario 2, but transposed
10775 m_pDoc->InsertTab(nTab, "Test");
10777 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10778 m_pDoc->SetValue(1, 0, nTab, 1.0); // B1
10779 m_pDoc->SetValue(2, 0, nTab, 1000.0); // C1
10781 m_pDoc->SetValue(0, 1, nTab, 100.0); // A2
10782 m_pDoc->SetValue(1, 1, nTab, 1.0); // B2
10783 m_pDoc->SetString(2, 1, nTab, "=B2"); // C2
10785 m_pDoc->SetValue(0, 2, nTab, 100.0); // A3
10786 m_pDoc->SetValue(1, 2, nTab, 1.0); // B3
10787 m_pDoc->SetString(2, 2, nTab, "=B3"); // C3
10789 m_pDoc->SetValue(0, 3, nTab, 100.0); // A4
10790 m_pDoc->SetValue(1, 3, nTab, 1.0); // B4
10791 m_pDoc->SetValue(2, 3, nTab, 1000.0); // C4
10793 // Copy A1:A4 to the clip document.
10794 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 3, nTab), &aClipDoc); // A1:A4
10796 aDestRange = ScRange(2, 0, nTab, 2, 3, nTab);
10797 // Copy C1:C4 to the mix document (for arithmetic paste).
10798 copyToClip(m_pDoc, aDestRange, &aMixDoc); // C1:C4
10800 // Paste A1:A4 to C1:C4 and perform addition.
10801 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10802 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10804 // Test precondition
10805 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 0, nTab)); // C1
10806 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 0, nTab));
10808 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10809 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(2, 1, nTab));
10811 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10812 CPPUNIT_ASSERT_EQUAL(OUString("=(B3)+100"), m_pDoc->GetFormula(2, 2, nTab));
10814 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 3, nTab)); // C4
10815 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 3, nTab));
10817 // Change B1:B4 from 1.0 to 2.0 (auto calculation is triggered)
10818 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
10819 m_pDoc->SetValue(1, 1, nTab, 2.0); // B2
10820 m_pDoc->SetValue(1, 2, nTab, 2.0); // B3
10821 m_pDoc->SetValue(1, 3, nTab, 2.0); // B4
10823 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 0, nTab)); // C1
10824 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 0, nTab));
10826 // Without the fix in place, this would have failed with
10827 // - Expected: =102
10828 // - Actual : =101
10829 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10830 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(2, 1, nTab));
10832 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10833 CPPUNIT_ASSERT_EQUAL(OUString("=(B3)+100"), m_pDoc->GetFormula(2, 2, nTab));
10835 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 3, nTab)); // C4
10836 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 3, nTab));
10838 m_pDoc->DeleteTab(nTab);
10841 void TestCopyPaste::testCopyPasteMatrixFormula()
10843 m_pDoc->InsertTab(0, "hcv");
10845 // Set Values to B1, C1, D1
10846 m_pDoc->SetValue(ScAddress(1, 0, 0), 2.0); // B1
10847 m_pDoc->SetValue(ScAddress(2, 0, 0), 5.0); // C1
10848 m_pDoc->SetValue(ScAddress(3, 0, 0), 3.0); // D1
10850 // Set Values to B2, C2
10851 m_pDoc->SetString(ScAddress(1, 1, 0), "B2"); // B2
10852 //m_pDoc->SetString(ScAddress(2,1,0), "C2"); // C2
10853 m_pDoc->SetString(ScAddress(3, 1, 0), "D2"); // D2
10855 // Set Values to D3
10856 //m_pDoc->SetValue(ScAddress(1,2,0), 9.0); // B3
10857 //m_pDoc->SetString(ScAddress(2,2,0), "C3"); // C3
10858 m_pDoc->SetValue(ScAddress(3, 2, 0), 11.0); // D3
10860 // Insert matrix formula to A1
10861 ScMarkData aMark(m_pDoc->GetSheetLimits());
10862 aMark.SelectOneTable(0);
10863 m_pDoc->InsertMatrixFormula(0, 0, 0, 0, aMark, "=COUNTIF(ISBLANK(B1:D1);TRUE())");
10864 m_pDoc->CalcAll();
10865 // A1 should contain 0
10866 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0, 0, 0))); // A1
10868 // Copy cell A1 to clipboard.
10869 ScAddress aPos(0, 0, 0); // A1
10870 ScDocument aClipDoc(SCDOCMODE_CLIP);
10871 ScClipParam aParam(aPos, false);
10872 m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark, false, false);
10873 // Formula string should be equal.
10874 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
10876 // First try single range.
10877 // Paste matrix formula to A2
10878 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 0, 1, 0), &aClipDoc); // A2
10879 // A2 Cell value should contain 1.0
10880 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
10882 // Paste matrix formula to A3
10883 pasteFromClip(m_pDoc, ScRange(0, 2, 0, 0, 2, 0), &aClipDoc); // A3
10884 // A3 Cell value should contain 2.0
10885 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
10887 // Paste matrix formula to A4
10888 pasteFromClip(m_pDoc, ScRange(0, 3, 0, 0, 3, 0), &aClipDoc); // A4
10889 // A4 Cell value should contain 3.0
10890 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0, 3, 0)));
10892 // Clear cell A2:A4
10893 clearRange(m_pDoc, ScRange(0, 1, 0, 0, 3, 0));
10895 // Paste matrix formula to range A2:A4
10896 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 0, 3, 0), &aClipDoc); // A2:A4
10898 // A2 Cell value should contain 1.0
10899 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
10900 // A3 Cell value should contain 2.0
10901 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
10902 // A4 Cell value should contain 3.0
10903 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0, 3, 0)));
10905 m_pDoc->DeleteTab(0);
10908 CPPUNIT_TEST_SUITE_REGISTRATION(TestCopyPaste);
10910 CPPUNIT_PLUGIN_IMPLEMENT();
10912 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */