rtl::Static->thread-safe static in unotools
[LibreOffice.git] / sc / qa / unit / ucalc_copypaste.cxx
blobdc3a74f2ec8facfe0bf65619720c5ea80e481121
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 <memory>
11 #include <test/bootstrapfixture.hxx>
12 #include "helper/debughelper.hxx"
13 #include "helper/qahelper.hxx"
15 #include <attrib.hxx>
16 #include <bcaslot.hxx>
17 #include <clipparam.hxx>
18 #include <dbdata.hxx>
19 #include <docfunc.hxx>
20 #include <docpool.hxx>
21 #include <editeng/borderline.hxx>
22 #include <editeng/brushitem.hxx>
23 #include <editeng/editobj.hxx>
24 #include <editutil.hxx>
25 #include <formulacell.hxx>
26 #include <formulaopt.hxx>
27 #include <iostream>
28 #include <patattr.hxx>
29 #include <postit.hxx>
30 #include <queryentry.hxx>
31 #include <queryparam.hxx>
32 #include <refundo.hxx>
33 #include <scdll.hxx>
34 #include <scitems.hxx>
35 #include <scmod.hxx>
36 #include <scopetools.hxx>
38 #include <sfx2/docfile.hxx>
40 class TestCopyPaste : public test::BootstrapFixture
42 public:
43 TestCopyPaste();
45 virtual void setUp() override;
46 virtual void tearDown() override;
48 void testCopyPaste();
49 void testCopyPasteAsLink();
50 void testCopyPasteTranspose();
51 void testCopyPasteSpecialAsLinkTranspose();
52 void testCopyPasteSpecialAsLinkFilteredTranspose();
53 void testCopyPasteSpecialMultiRangeColAsLinkTranspose();
54 void testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose();
55 void testCopyPasteSpecialMultiRangeRowAsLinkTranspose();
56 void testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose();
57 void testCopyPasteSpecialAllAsLinkTranspose();
58 void testCopyPasteSpecialAllAsLinkFilteredTranspose();
59 void testCopyPasteSpecial();
60 void testCopyPasteSpecialFiltered();
61 void testCopyPasteSpecialIncludeFiltered();
62 void testCopyPasteSpecialFilteredIncludeFiltered();
63 void testCopyPasteSpecialTranspose();
64 void testCopyPasteSpecialTransposeIncludeFiltered();
65 void testCopyPasteSpecialFilteredTranspose();
66 void testCopyPasteSpecialMergedCellsTranspose();
67 void testCopyPasteSpecialMergedCellsFilteredTranspose();
68 void testCopyPasteSpecialMultiRangeCol();
69 void testCopyPasteSpecialMultiRangeColFiltered();
70 void testCopyPasteSpecialMultiRangeColIncludeFiltered();
71 void testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered();
72 void testCopyPasteSpecialMultiRangeColTranspose();
73 void testCopyPasteSpecialMultiRangeColFilteredTranspose();
74 void testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose();
75 void testCopyPasteSpecialMultiRangeRow();
76 void testCopyPasteSpecialMultiRangeRowFiltered();
77 void testCopyPasteSpecialMultiRangeRowIncludeFiltered();
78 void testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered();
79 void testCopyPasteSpecialMultiRangeRowTranspose();
80 void testCopyPasteSpecialMultiRangeRowFilteredTranspose();
81 void testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose();
82 void testCopyPasteSpecialSkipEmpty();
83 void testCopyPasteSpecialSkipEmptyFiltered();
84 void testCopyPasteSpecialSkipEmptyIncludeFiltered();
85 void testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered();
86 void testCopyPasteSpecialSkipEmptyTranspose();
87 void testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered();
88 void testCopyPasteSpecialSkipEmptyFilteredTranspose();
89 void testCopyPasteSpecialSkipEmptyMultiRangeCol();
90 void testCopyPasteSpecialSkipEmptyMultiRangeColFiltered();
91 void testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered();
92 void testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered();
93 void testCopyPasteSpecialSkipEmptyMultiRangeColTranspose();
94 void testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose();
95 void testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose();
96 void testCopyPasteSpecialSkipEmptyMultiRangeRow();
97 void testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered();
98 void testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered();
99 void testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered();
100 void testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose();
101 void testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose();
102 void testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose();
103 void testCopyPasteMultiRange();
104 void testCopyPasteSkipEmpty();
105 void testCopyPasteSkipEmpty2();
106 void testCutPasteRefUndo();
107 void testCutPasteGroupRefUndo();
108 void testMoveRefBetweenSheets();
109 void testUndoCut();
110 void testMoveBlock();
111 void testCopyPasteRelativeFormula();
112 void testCopyPasteRepeatOneFormula();
113 void testCopyPasteMixedReferenceFormula();
114 void testCopyPasteFormulas();
115 void testCopyPasteFormulasExternalDoc();
116 void testCopyPasteReferencesExternalDoc(); // tdf#106456
117 void testTdf68976();
118 void testTdf71058();
120 void testCutPasteSpecial();
121 void testCutPasteSpecialTranspose();
122 void testCutPasteSpecialSkipEmpty();
123 void testCutPasteSpecialSkipEmptyTranspose();
124 void testTdf142201Row();
125 void testTdf142201ColRel();
126 void testTdf142201ColAbs();
127 void testTdf142065();
128 void testCutTransposedFormulas();
129 void testCutTransposedFormulasSquare();
130 void testReferencedCutRangesRow();
131 void testReferencedCutTransposedRangesRowTab0To0();
132 void testReferencedCutTransposedRangesRowTab0To1();
133 void testReferencedCutTransposedRangesRowTab1To3();
134 void testReferencedCutTransposedRangesRowTab3To1();
135 void testReferencedCutRangesCol();
136 void testReferencedCutTransposedRangesColTab0To0();
137 void testReferencedCutTransposedRangesColTab0To1();
138 void testReferencedCutTransposedRangesColTab1To3();
139 void testReferencedCutTransposedRangesColTab3To1();
141 void testMixData();
142 void testMixDataAsLinkTdf116413();
143 void testMixDataWithFormulaTdf116413();
145 // tdf#80137
146 void testCopyPasteMatrixFormula();
148 CPPUNIT_TEST_SUITE(TestCopyPaste);
150 CPPUNIT_TEST(testCopyPaste);
151 CPPUNIT_TEST(testCopyPasteAsLink);
152 CPPUNIT_TEST(testCopyPasteTranspose);
153 CPPUNIT_TEST(testCopyPasteSpecialAsLinkTranspose);
154 CPPUNIT_TEST(testCopyPasteSpecialAllAsLinkTranspose);
155 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColAsLinkTranspose);
156 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose);
157 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowAsLinkTranspose);
158 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose);
159 CPPUNIT_TEST(testCopyPasteSpecialAsLinkFilteredTranspose);
160 CPPUNIT_TEST(testCopyPasteSpecialAllAsLinkFilteredTranspose);
161 CPPUNIT_TEST(testCopyPasteSpecialMergedCellsTranspose);
162 CPPUNIT_TEST(testCopyPasteSpecialMergedCellsFilteredTranspose);
163 CPPUNIT_TEST(testCopyPasteSpecial);
164 CPPUNIT_TEST(testCopyPasteSpecialFiltered);
165 CPPUNIT_TEST(testCopyPasteSpecialIncludeFiltered);
166 CPPUNIT_TEST(testCopyPasteSpecialFilteredIncludeFiltered);
167 CPPUNIT_TEST(testCopyPasteSpecialTranspose);
168 CPPUNIT_TEST(testCopyPasteSpecialTransposeIncludeFiltered);
169 CPPUNIT_TEST(testCopyPasteSpecialFilteredTranspose);
170 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeCol);
171 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFiltered);
172 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColIncludeFiltered);
173 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered);
174 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColTranspose);
175 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFilteredTranspose);
176 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose);
177 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRow);
178 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFiltered);
179 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowIncludeFiltered);
180 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered);
181 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowTranspose);
182 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFilteredTranspose);
183 CPPUNIT_TEST(testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose);
184 CPPUNIT_TEST(testCopyPasteSpecialSkipEmpty);
185 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyFiltered);
186 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyIncludeFiltered);
187 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered);
188 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyTranspose);
189 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered);
190 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyFilteredTranspose);
191 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeCol);
192 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFiltered);
193 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered);
194 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered);
195 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColTranspose);
196 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose);
197 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose);
198 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRow);
199 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered);
200 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered);
201 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered);
202 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose);
203 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose);
204 CPPUNIT_TEST(testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose);
205 CPPUNIT_TEST(testCopyPasteMultiRange);
206 CPPUNIT_TEST(testCopyPasteSkipEmpty);
207 CPPUNIT_TEST(testCopyPasteSkipEmpty2);
208 CPPUNIT_TEST(testCutPasteRefUndo);
209 CPPUNIT_TEST(testCutPasteGroupRefUndo);
210 CPPUNIT_TEST(testMoveRefBetweenSheets);
211 CPPUNIT_TEST(testUndoCut);
212 CPPUNIT_TEST(testMoveBlock);
213 CPPUNIT_TEST(testCopyPasteRelativeFormula);
214 CPPUNIT_TEST(testCopyPasteRepeatOneFormula);
215 CPPUNIT_TEST(testCopyPasteMixedReferenceFormula);
217 CPPUNIT_TEST(testCopyPasteFormulas);
218 CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
219 CPPUNIT_TEST(testCopyPasteReferencesExternalDoc);
221 CPPUNIT_TEST(testTdf68976);
222 CPPUNIT_TEST(testTdf71058);
224 CPPUNIT_TEST(testCutPasteSpecial);
225 CPPUNIT_TEST(testCutPasteSpecialTranspose);
226 CPPUNIT_TEST(testCutPasteSpecialSkipEmpty);
227 CPPUNIT_TEST(testCutPasteSpecialSkipEmptyTranspose);
228 CPPUNIT_TEST(testTdf142201Row);
229 CPPUNIT_TEST(testTdf142201ColRel);
230 CPPUNIT_TEST(testTdf142201ColAbs);
231 CPPUNIT_TEST(testTdf142065);
232 CPPUNIT_TEST(testCutTransposedFormulas);
233 CPPUNIT_TEST(testCutTransposedFormulasSquare);
234 CPPUNIT_TEST(testReferencedCutRangesRow);
235 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab0To0);
236 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab0To1);
237 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab1To3);
238 CPPUNIT_TEST(testReferencedCutTransposedRangesRowTab3To1);
239 CPPUNIT_TEST(testReferencedCutRangesCol);
240 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab0To0);
241 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab0To1);
242 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab1To3);
243 CPPUNIT_TEST(testReferencedCutTransposedRangesColTab3To1);
245 CPPUNIT_TEST(testMixData);
246 CPPUNIT_TEST(testMixDataAsLinkTdf116413);
247 CPPUNIT_TEST(testMixDataWithFormulaTdf116413);
249 CPPUNIT_TEST(testCopyPasteMatrixFormula);
251 CPPUNIT_TEST_SUITE_END();
253 private:
254 ScDocShellRef m_xDocShell;
255 ScDocument* m_pDoc;
257 enum CalcMode
259 NoCalc,
260 AutoCalc,
261 RecalcAtEnd,
262 HardRecalcAtEnd
265 void executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
266 bool bTranspose, bool bMultiRangeSelection, bool bSkipEmpty,
267 bool bCut = false,
268 ScClipParam::Direction eDirection = ScClipParam::Column,
269 CalcMode eCalcMode = CalcMode::AutoCalc,
270 InsertDeleteFlags aFlags
271 = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB);
272 void executeCopyPasteSpecial(const SCTAB srcSheet, const SCTAB destSheet, bool bApplyFilter,
273 bool bIncludedFiltered, bool bAsLink, bool bTranspose,
274 bool bMultiRangeSelection, bool bSkipEmpty,
275 std::unique_ptr<ScUndoCut>& pUndoCut,
276 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bCut = false,
277 ScClipParam::Direction eDirection = ScClipParam::Column,
278 CalcMode eCalcMode = CalcMode::AutoCalc,
279 InsertDeleteFlags aFlags
280 = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB);
281 void checkCopyPasteSpecialInitial(const SCTAB srcSheet);
282 void checkCopyPasteSpecial(bool bSkipEmpty, bool bCut = false);
283 void checkCopyPasteSpecialFiltered(bool bSkipEmpty);
284 void checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut = false);
285 void checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty);
286 void checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty);
287 void checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty);
288 void checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty);
289 void checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty);
290 void checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty);
291 void checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty);
292 void checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty);
293 void checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty);
294 void checkReferencedCutTransposedRangesRowUndo(const SCTAB nSrcTab, const SCTAB nDestTab);
295 void executeReferencedCutRangesRow(const bool bTransposed, const SCTAB nSrcTab,
296 const SCTAB nDestTab, const bool bUndo,
297 std::unique_ptr<ScUndoCut>& pUndoCut,
298 std::unique_ptr<ScUndoPaste>& pUndoPaste);
299 void checkReferencedCutRangesRowIntitial(const SCTAB nSrcTab, const OUString& rDesc);
300 void checkReferencedCutRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab);
301 void checkReferencedCutTransposedRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab);
302 void executeReferencedCutRangesCol(const bool bTransposed, const SCTAB nSrcTab,
303 const SCTAB nDestTab, const bool bUndo,
304 std::unique_ptr<ScUndoCut>& pUndoCut,
305 std::unique_ptr<ScUndoPaste>& pUndoPaste);
306 void checkReferencedCutRangesColIntitial(const SCTAB nSrcTab, const SCTAB nDestTab,
307 const OUString& rDesc);
308 void checkReferencedCutRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab);
309 void checkReferencedCutTransposedRangesColUndo(const SCTAB nSrcTab, const SCTAB nDestTab);
310 void checkReferencedCutTransposedRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab);
311 void prepareUndoBeforePaste(bool bCut, ScDocumentUniquePtr& pPasteUndoDoc,
312 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
313 const ScMarkData& rDestMark, const ScRange& rDestRange,
314 std::unique_ptr<ScRefUndoData>& pUndoData);
315 void prepareUndoAfterPaste(ScDocumentUniquePtr& pPasteUndoDoc,
316 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
317 const ScMarkData& rDestMark, const ScRange& rDestRange,
318 std::unique_ptr<ScRefUndoData>& pUndoData,
319 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bTranspose = false,
320 bool bAsLink = false, bool bSkipEmpty = false,
321 ScPasteFunc nFunction = ScPasteFunc::NONE,
322 InsCellCmd eMoveMode = InsCellCmd::INS_NONE);
324 OUString getFormula(SCCOL nCol, SCROW nRow, SCTAB nTab);
325 OUString getRangeByName(const OUString& aRangeName);
326 ScAddress setNote(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString noteText);
327 OUString getNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
330 TestCopyPaste::TestCopyPaste() {}
332 void TestCopyPaste::setUp()
334 BootstrapFixture::setUp();
336 ScDLL::Init();
338 m_xDocShell
339 = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS
340 | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
341 m_xDocShell->SetIsInUcalc();
342 m_xDocShell->DoInitUnitTest();
344 m_pDoc = &m_xDocShell->GetDocument();
347 void TestCopyPaste::tearDown()
349 m_xDocShell->DoClose();
350 m_xDocShell.clear();
352 test::BootstrapFixture::tearDown();
355 static ScMF lcl_getMergeFlagOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
357 const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE_FLAG);
358 const ScMergeFlagAttr& rMergeFlag = static_cast<const ScMergeFlagAttr&>(rPoolItem);
359 return rMergeFlag.GetValue();
362 static ScAddress lcl_getMergeSizeOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
364 const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE);
365 const ScMergeAttr& rMerge = static_cast<const ScMergeAttr&>(rPoolItem);
366 return ScAddress(rMerge.GetColMerge(), rMerge.GetRowMerge(), nTab);
369 static void lcl_printValuesAndFormulasInRange(ScDocument* pDoc, const ScRange& rRange,
370 const OString& rCaption)
372 printRange(pDoc, rRange, rCaption, false);
373 printRange(pDoc, rRange, rCaption, true);
376 OUString TestCopyPaste::getFormula(SCCOL nCol, SCROW nRow, SCTAB nTab)
378 return ::getFormula(m_pDoc, nCol, nRow, nTab);
381 OUString TestCopyPaste::getRangeByName(const OUString& aRangeName)
383 return ::getRangeByName(m_pDoc, aRangeName);
386 ScAddress TestCopyPaste::setNote(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString noteText)
388 ScAddress aAdr(nCol, nRow, nTab);
389 ScPostIt* pNote = m_pDoc->GetOrCreateNote(aAdr);
390 pNote->SetText(aAdr, noteText);
391 return aAdr;
394 OUString TestCopyPaste::getNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
396 ScPostIt* pNote = m_pDoc->GetNote(nCol, nRow, nTab);
397 CPPUNIT_ASSERT_MESSAGE("Note expected", pNote);
398 return pNote->GetText();
401 // Cannot be moved to qahelper since ScDocument::CopyToDocument() is not SC_DLLPUBLIC
402 /** Executes the same steps for undo as ScViewFunc::PasteFromClip(). */
403 void TestCopyPaste::prepareUndoBeforePaste(bool bCut, ScDocumentUniquePtr& pPasteUndoDoc,
404 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
405 const ScMarkData& rDestMark, const ScRange& rDestRange,
406 std::unique_ptr<ScRefUndoData>& pUndoData)
408 InsertDeleteFlags nUndoFlags = InsertDeleteFlags::CONTENTS;
409 SCTAB nTabCount = m_pDoc->GetTableCount();
411 pPasteUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
412 pPasteUndoDoc->InitUndoSelected(*m_pDoc, rDestMark, false, false);
413 // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
414 m_pDoc->CopyToDocument(rDestRange.aStart.Col(), rDestRange.aStart.Row(), 0,
415 rDestRange.aEnd.Col(), rDestRange.aEnd.Row(), nTabCount - 1, nUndoFlags,
416 false, *pPasteUndoDoc);
418 if (bCut)
420 // save changed references
421 pPasteRefUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
422 pPasteRefUndoDoc->InitUndo(*m_pDoc, 0, nTabCount - 1);
424 pUndoData.reset(new ScRefUndoData(m_pDoc));
428 // Cannot be moved to qahelper since ScDocument::CopyToDocument() is not SC_DLLPUBLIC
429 /** Executes the same steps for undo as ScViewFunc::PasteFromClip(). */
430 void TestCopyPaste::prepareUndoAfterPaste(ScDocumentUniquePtr& pPasteUndoDoc,
431 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
432 const ScMarkData& rDestMark, const ScRange& rDestRange,
433 std::unique_ptr<ScRefUndoData>& pUndoData,
434 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bTranspose,
435 bool bAsLink, bool bSkipEmpty, ScPasteFunc nFunction,
436 InsCellCmd eMoveMode)
438 InsertDeleteFlags nUndoFlags = InsertDeleteFlags::CONTENTS;
439 SCTAB nTabCount = m_pDoc->GetTableCount();
441 ScDocumentUniquePtr pPasteRedoDoc;
442 // copy redo data after appearance of the first undo
443 // don't create Redo-Doc without RefUndoDoc
445 if (pPasteRefUndoDoc)
447 pPasteRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
448 pPasteRedoDoc->InitUndo(*m_pDoc, rDestRange.aStart.Tab(), rDestRange.aEnd.Tab(), false,
449 false);
451 // move adapted refs to Redo-Doc
453 pPasteRedoDoc->AddUndoTab(0, nTabCount - 1);
454 m_pDoc->CopyUpdated(pPasteRefUndoDoc.get(), pPasteRedoDoc.get());
456 pPasteUndoDoc->AddUndoTab(0, nTabCount - 1);
457 pPasteRefUndoDoc->DeleteArea(rDestRange.aStart.Col(), rDestRange.aStart.Row(),
458 rDestRange.aEnd.Col(), rDestRange.aEnd.Row(), rDestMark,
459 InsertDeleteFlags::ALL);
460 pPasteRefUndoDoc->CopyToDocument(0, 0, 0, pPasteUndoDoc->MaxCol(), pPasteUndoDoc->MaxRow(),
461 nTabCount - 1, InsertDeleteFlags::FORMULA, false,
462 *pPasteUndoDoc);
463 pPasteRefUndoDoc.reset();
466 ScUndoPasteOptions aOptions; // store options for repeat
467 aOptions.nFunction = nFunction;
468 aOptions.bSkipEmpty = bSkipEmpty;
469 aOptions.bTranspose = bTranspose;
470 aOptions.bAsLink = bAsLink;
471 aOptions.eMoveMode = eMoveMode;
473 pUndoPaste.reset(new ScUndoPaste(&*m_xDocShell, rDestRange, rDestMark, std::move(pPasteUndoDoc),
474 std::move(pPasteRedoDoc), nUndoFlags, std::move(pUndoData),
475 false,
476 &aOptions)); // false = Redo data not yet copied
479 void TestCopyPaste::testCopyPaste()
481 m_pDoc->InsertTab(0, "Sheet1");
482 m_pDoc->InsertTab(1, "Sheet2");
484 // We need a drawing layer in order to create caption objects.
485 m_pDoc->InitDrawLayer(m_xDocShell.get());
487 //test copy&paste + ScUndoPaste
488 //copy local and global range names in formulas
489 //string cells and value cells
490 m_pDoc->SetValue(0, 0, 0, 1);
491 m_pDoc->SetValue(3, 0, 0, 0);
492 m_pDoc->SetValue(3, 1, 0, 1);
493 m_pDoc->SetValue(3, 2, 0, 2);
494 m_pDoc->SetValue(3, 3, 0, 3);
495 m_pDoc->SetString(2, 0, 0, "test");
496 ScAddress aAdr(0, 0, 0);
498 //create some range names, local and global
499 ScRangeData* pLocal1 = new ScRangeData(*m_pDoc, "local1", aAdr);
500 ScRangeData* pLocal2 = new ScRangeData(*m_pDoc, "local2", aAdr);
501 ScRangeData* pLocal3 = new ScRangeData(*m_pDoc, "local3", "$Sheet1.$A$1");
502 ScRangeData* pLocal4 = new ScRangeData(*m_pDoc, "local4", "Sheet1.$A$1");
503 ScRangeData* pLocal5
504 = new ScRangeData(*m_pDoc, "local5", "$A$1"); // implicit relative sheet reference
505 ScRangeData* pGlobal = new ScRangeData(*m_pDoc, "global", aAdr);
506 const OUString aGlobal2Symbol("$Sheet1.$A$1:$A$23");
507 ScRangeData* pGlobal2 = new ScRangeData(*m_pDoc, "global2", aGlobal2Symbol);
508 std::unique_ptr<ScRangeName> pGlobalRangeName(new ScRangeName());
509 pGlobalRangeName->insert(pGlobal);
510 pGlobalRangeName->insert(pGlobal2);
511 std::unique_ptr<ScRangeName> pLocalRangeName1(new ScRangeName());
512 pLocalRangeName1->insert(pLocal1);
513 pLocalRangeName1->insert(pLocal2);
514 pLocalRangeName1->insert(pLocal3);
515 pLocalRangeName1->insert(pLocal4);
516 pLocalRangeName1->insert(pLocal5);
517 m_pDoc->SetRangeName(std::move(pGlobalRangeName));
518 m_pDoc->SetRangeName(0, std::move(pLocalRangeName1));
520 // Add formula to B1.
521 OUString aFormulaString("=local1+global+SUM($C$1:$D$4)+local3+local4+local5");
522 m_pDoc->SetString(1, 0, 0, aFormulaString);
524 double fValue = m_pDoc->GetValue(ScAddress(1, 0, 0));
525 ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 11", fValue, 11);
527 // add notes to A1:C1
528 setNote(0, 0, 0, "Hello world in A1"); // empty cell content
529 setNote(1, 0, 0, "Hello world in B1"); // formula cell content
530 setNote(2, 0, 0, "Hello world in C1"); // string cell content
532 //copy Sheet1.A1:C1 to Sheet2.A2:C2
533 ScRange aRange(0, 0, 0, 2, 0, 0);
534 ScDocument aClipDoc(SCDOCMODE_CLIP);
535 copyToClip(m_pDoc, aRange, &aClipDoc);
537 aRange = ScRange(0, 1, 1, 2, 1, 1); //target: Sheet2.A2:C2
538 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
539 pUndoDoc->InitUndo(*m_pDoc, 1, 1, true, true);
540 std::unique_ptr<ScUndoPaste> pUndo(createUndoPaste(*m_xDocShell, aRange, std::move(pUndoDoc)));
541 ScMarkData aMark(m_pDoc->GetSheetLimits());
542 aMark.SetMarkArea(aRange);
543 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
545 //check values after copying
546 OUString aString = m_pDoc->GetFormula(1, 1, 1);
547 CPPUNIT_ASSERT_EQUAL_MESSAGE("formula string was not copied correctly", aString,
548 aFormulaString);
549 // Only the global range points to Sheet1.A1, all copied sheet-local ranges
550 // to Sheet2.A1 that is empty, hence the result is 1, not 2.
551 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
552 ASSERT_DOUBLES_EQUAL_MESSAGE("copied formula should return 1", 1.0, fValue);
553 fValue = m_pDoc->GetValue(ScAddress(0, 1, 1));
554 ASSERT_DOUBLES_EQUAL_MESSAGE("copied value should be 1", 1.0, fValue);
556 ScRange aSheet2A1(0, 0, 1, 0, 0, 1);
558 //check local range name after copying
559 pLocal1 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL1"));
560 CPPUNIT_ASSERT_MESSAGE("local range name 1 should be copied", pLocal1);
561 ScRange aRangeLocal1;
562 bool bIsValidRef1 = pLocal1->IsValidReference(aRangeLocal1);
563 CPPUNIT_ASSERT_MESSAGE("local range name 1 should be valid", bIsValidRef1);
564 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 1 should now point to Sheet2.A1", aSheet2A1,
565 aRangeLocal1);
567 pLocal2 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL2"));
568 CPPUNIT_ASSERT_MESSAGE("local2 should not be copied", !pLocal2);
570 pLocal3 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL3"));
571 CPPUNIT_ASSERT_MESSAGE("local range name 3 should be copied", pLocal3);
572 ScRange aRangeLocal3;
573 bool bIsValidRef3 = pLocal3->IsValidReference(aRangeLocal3);
574 CPPUNIT_ASSERT_MESSAGE("local range name 3 should be valid", bIsValidRef3);
575 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 3 should now point to Sheet2.A1", aSheet2A1,
576 aRangeLocal3);
578 pLocal4 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL4"));
579 CPPUNIT_ASSERT_MESSAGE("local range name 4 should be copied", pLocal4);
580 ScRange aRangeLocal4;
581 bool bIsValidRef4 = pLocal4->IsValidReference(aRangeLocal4);
582 CPPUNIT_ASSERT_MESSAGE("local range name 4 should be valid", bIsValidRef4);
583 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 4 should now point to Sheet2.A1", aSheet2A1,
584 aRangeLocal4);
586 pLocal5 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL5"));
587 CPPUNIT_ASSERT_MESSAGE("local range name 5 should be copied", pLocal5);
588 ScRange aRangeLocal5;
589 bool bIsValidRef5 = pLocal5->IsValidReference(aRangeLocal5);
590 CPPUNIT_ASSERT_MESSAGE("local range name 5 should be valid", bIsValidRef5);
591 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 5 should now point to Sheet2.A1", aSheet2A1,
592 aRangeLocal5);
594 // check notes after copying
595 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.A2", m_pDoc->HasNote(0, 1, 1));
596 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.B2", m_pDoc->HasNote(1, 1, 1));
597 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.C2", m_pDoc->HasNote(2, 1, 1));
598 CPPUNIT_ASSERT_EQUAL_MESSAGE(
599 "Note content on Sheet1.A1 not copied to Sheet2.A2, empty cell content",
600 m_pDoc->GetNote(0, 0, 0)->GetText(), m_pDoc->GetNote(0, 1, 1)->GetText());
601 CPPUNIT_ASSERT_EQUAL_MESSAGE(
602 "Note content on Sheet1.B1 not copied to Sheet2.B2, formula cell content",
603 m_pDoc->GetNote(1, 0, 0)->GetText(), m_pDoc->GetNote(1, 1, 1)->GetText());
604 CPPUNIT_ASSERT_EQUAL_MESSAGE(
605 "Note content on Sheet1.C1 not copied to Sheet2.C2, string cell content",
606 m_pDoc->GetNote(2, 0, 0)->GetText(), m_pDoc->GetNote(2, 1, 1)->GetText());
608 //check undo and redo
609 pUndo->Undo();
610 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
611 ASSERT_DOUBLES_EQUAL_MESSAGE("after undo formula should return nothing", fValue, 0);
612 aString = m_pDoc->GetString(2, 1, 1);
613 CPPUNIT_ASSERT_MESSAGE("after undo, string should be removed", aString.isEmpty());
614 CPPUNIT_ASSERT_MESSAGE("after undo, note on A2 should be removed", !m_pDoc->HasNote(0, 1, 1));
615 CPPUNIT_ASSERT_MESSAGE("after undo, note on B2 should be removed", !m_pDoc->HasNote(1, 1, 1));
616 CPPUNIT_ASSERT_MESSAGE("after undo, note on C2 should be removed", !m_pDoc->HasNote(2, 1, 1));
618 pUndo->Redo();
619 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
620 ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 1 after redo", 1.0, fValue);
621 aString = m_pDoc->GetString(2, 1, 1);
622 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.C2 should contain: test", OUString("test"), aString);
623 aString = m_pDoc->GetFormula(1, 1, 1);
624 CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula should be correct again", aFormulaString, aString);
626 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.A2",
627 m_pDoc->HasNote(0, 1, 1));
628 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.B2",
629 m_pDoc->HasNote(1, 1, 1));
630 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.C2",
631 m_pDoc->HasNote(2, 1, 1));
632 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.A2, empty cell content",
633 getNote(0, 0, 0), getNote(0, 1, 1));
634 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.B2, formula cell content",
635 getNote(1, 0, 0), getNote(1, 1, 1));
636 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.C2, string cell content",
637 getNote(2, 0, 0), getNote(2, 1, 1));
639 // Copy Sheet1.A11:A13 to Sheet1.A7:A9, both within global2 range.
640 aRange = ScRange(0, 10, 0, 0, 12, 0);
641 ScDocument aClipDoc2(SCDOCMODE_CLIP);
642 copyToClip(m_pDoc, aRange, &aClipDoc2);
644 aRange = ScRange(0, 6, 0, 0, 8, 0);
645 aMark.SetMarkArea(aRange);
646 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc2);
648 // The global2 range must not have changed.
649 pGlobal2 = m_pDoc->GetRangeName()->findByUpperName("GLOBAL2");
650 CPPUNIT_ASSERT_MESSAGE("GLOBAL2 name not found", pGlobal2);
651 OUString aSymbol = pGlobal2->GetSymbol();
652 CPPUNIT_ASSERT_EQUAL_MESSAGE("GLOBAL2 named range changed", aGlobal2Symbol, aSymbol);
654 m_pDoc->DeleteTab(1);
655 m_pDoc->DeleteTab(0);
658 void TestCopyPaste::testCopyPasteAsLink()
660 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
662 m_pDoc->InsertTab(0, "Sheet1");
663 m_pDoc->InsertTab(1, "Sheet2");
665 m_pDoc->SetValue(ScAddress(0, 0, 0), 1); // A1
666 m_pDoc->SetValue(ScAddress(0, 1, 0), 2); // A2
667 m_pDoc->SetValue(ScAddress(0, 2, 0), 3); // A3
669 ScRange aRange(0, 0, 0, 0, 2, 0); // Copy A1:A3 to clip.
670 ScDocument aClipDoc(SCDOCMODE_CLIP);
671 copyToClip(m_pDoc, aRange, &aClipDoc);
673 aRange = ScRange(1, 1, 1, 1, 3, 1); // Paste to B2:B4 on Sheet2.
674 ScMarkData aMark(m_pDoc->GetSheetLimits());
675 aMark.SetMarkArea(aRange);
676 // Paste range as link.
677 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &aClipDoc, true,
678 true);
680 // Check pasted content to make sure they reference the correct cells.
681 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, 1));
682 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
683 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
685 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, 1));
686 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
687 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
689 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, 1));
690 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
691 CPPUNIT_ASSERT_EQUAL(3.0, pFC->GetValue());
693 m_pDoc->DeleteTab(1);
694 m_pDoc->DeleteTab(0);
697 void TestCopyPaste::testCopyPasteTranspose()
699 m_pDoc->InsertTab(0, "Sheet1");
701 // We need a drawing layer in order to create caption objects.
702 m_pDoc->InitDrawLayer(m_xDocShell.get());
704 m_pDoc->SetValue(0, 0, 0, 1);
705 m_pDoc->SetString(1, 0, 0, "=A1+1");
706 m_pDoc->SetString(2, 0, 0, "test");
708 // add notes to A1:C1
709 setNote(0, 0, 0, "Hello world in A1"); // numerical cell content
710 setNote(1, 0, 0, "Hello world in B1"); // formula cell content
711 setNote(2, 0, 0, "Hello world in C1"); // string cell content
713 // transpose clipboard, paste and check on Sheet2
714 m_pDoc->InsertTab(1, "Sheet2");
716 ScRange aSrcRange(0, 0, 0, 2, 0, 0);
717 ScDocument aNewClipDoc(SCDOCMODE_CLIP);
718 copyToClip(m_pDoc, aSrcRange, &aNewClipDoc);
720 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
721 aNewClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, false);
723 ScRange aDestRange(3, 1, 1, 3, 3, 1); //target: Sheet2.D2:D4
724 ScMarkData aMark(m_pDoc->GetSheetLimits());
725 aMark.SetMarkArea(aDestRange);
726 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get());
727 pTransClip.reset();
729 //check cell content after transposed copy/paste
730 OUString aString = m_pDoc->GetString(3, 3, 1);
731 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.D4 should contain: test", OUString("test"), aString);
732 double fValue = m_pDoc->GetValue(ScAddress(3, 1, 1));
733 ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied cell should return 1", 1, fValue);
734 fValue = m_pDoc->GetValue(ScAddress(3, 2, 1));
735 ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied formula should return 2", 2, fValue);
736 aString = m_pDoc->GetFormula(3, 2, 1);
737 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed formula should point on Sheet2.D2", OUString("=D2+1"),
738 aString);
740 // check notes after transposed copy/paste
741 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D2", m_pDoc->HasNote(3, 1, 1));
742 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D3", m_pDoc->HasNote(3, 2, 1));
743 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D4", m_pDoc->HasNote(3, 3, 1));
744 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D2", getNote(0, 0, 0),
745 getNote(3, 1, 1));
746 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D3", getNote(1, 0, 0),
747 getNote(3, 2, 1));
748 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D4", getNote(2, 0, 0),
749 getNote(3, 3, 1));
751 m_pDoc->DeleteTab(1);
752 m_pDoc->DeleteTab(0);
755 void TestCopyPaste::testCopyPasteSpecialMergedCellsTranspose()
757 const SCTAB srcSheet = 0;
758 const SCTAB destSheet = 1;
760 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
762 m_pDoc->InsertTab(srcSheet, "Sheet1");
763 m_pDoc->InsertTab(destSheet, "Sheet2");
765 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
766 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
767 m_pDoc->SetValue(0, 2, srcSheet, 3); // A3
768 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
770 m_pDoc->DoMerge(srcSheet, 0, 1, 1, 1, false); // Merge A2 and B2
771 m_pDoc->DoMerge(srcSheet, 0, 2, 1, 2, false); // Merge A3 and B3
773 // Test precondition
774 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
775 lcl_getMergeSizeOfCell(*m_pDoc, 0, 0, srcSheet));
776 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 0, srcSheet));
777 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
778 lcl_getMergeSizeOfCell(*m_pDoc, 0, 1, srcSheet));
779 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
780 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, srcSheet));
781 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 1, srcSheet));
782 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
783 lcl_getMergeSizeOfCell(*m_pDoc, 0, 2, srcSheet));
784 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
785 lcl_getMergeSizeOfCell(*m_pDoc, 1, 2, srcSheet));
786 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, srcSheet));
787 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
788 lcl_getMergeSizeOfCell(*m_pDoc, 0, 3, srcSheet));
789 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 3, srcSheet));
791 ScRange aSrcRange(0, 0, srcSheet, 1, 3, srcSheet); // Copy A1:B4 to clip.
792 ScDocument aClipDoc(SCDOCMODE_CLIP);
793 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
795 // transpose
796 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
797 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
799 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
800 ScMarkData aMark(m_pDoc->GetSheetLimits());
801 aMark.SetMarkArea(aDestRange);
802 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
803 false);
804 pTransClip.reset();
806 // Check transpose of merged cells
807 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
808 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, destSheet));
809 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, destSheet));
810 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
811 lcl_getMergeSizeOfCell(*m_pDoc, 2, 1, destSheet));
812 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 1, destSheet));
813 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
814 lcl_getMergeSizeOfCell(*m_pDoc, 3, 1, destSheet));
815 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 1, destSheet));
816 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
817 lcl_getMergeSizeOfCell(*m_pDoc, 4, 1, destSheet));
818 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 4, 2, destSheet));
820 m_pDoc->DeleteTab(destSheet);
821 m_pDoc->DeleteTab(srcSheet);
824 void TestCopyPaste::testCopyPasteSpecialMergedCellsFilteredTranspose()
826 const SCTAB srcSheet = 0;
827 const SCTAB destSheet = 1;
829 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
831 m_pDoc->InsertTab(srcSheet, "Sheet1");
832 m_pDoc->InsertTab(destSheet, "Sheet2");
834 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
835 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
836 m_pDoc->SetValue(0, 2, srcSheet, 3); // A3
837 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
839 m_pDoc->DoMerge(srcSheet, 0, 1, 1, 1, false); // Merge A2 and B2
840 m_pDoc->DoMerge(srcSheet, 0, 2, 1, 2, false); // Merge A3 and B3
842 // Filter row 1
843 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
844 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
846 pDBData->SetAutoFilter(true);
847 ScRange aRange;
848 pDBData->GetArea(aRange);
849 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
850 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
852 //create the query param
853 ScQueryParam aParam;
854 pDBData->GetQueryParam(aParam);
855 ScQueryEntry& rEntry = aParam.GetEntry(0);
856 rEntry.bDoQuery = true;
857 rEntry.nField = 0;
858 rEntry.eOp = SC_NOT_EQUAL;
859 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
860 // add queryParam to database range.
861 pDBData->SetQueryParam(aParam);
863 // perform the query.
864 m_pDoc->Query(srcSheet, aParam, true);
866 // Test precondition
867 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
868 lcl_getMergeSizeOfCell(*m_pDoc, 0, 0, srcSheet));
869 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 0, srcSheet));
870 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
871 lcl_getMergeSizeOfCell(*m_pDoc, 0, 1, srcSheet));
872 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
873 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, srcSheet));
874 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 1, srcSheet));
875 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
876 lcl_getMergeSizeOfCell(*m_pDoc, 0, 2, srcSheet));
877 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
878 lcl_getMergeSizeOfCell(*m_pDoc, 1, 2, srcSheet));
879 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, srcSheet));
880 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
881 lcl_getMergeSizeOfCell(*m_pDoc, 0, 3, srcSheet));
882 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 3, srcSheet));
884 ScRange aSrcRange(0, 0, srcSheet, 1, 3, srcSheet); // Copy A1:B4 to clip.
885 ScDocument aClipDoc(SCDOCMODE_CLIP);
886 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
888 // transpose
889 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
890 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
892 ScRange aDestRange(1, 1, destSheet, 3, 2, destSheet); // Paste to B2:D3 on Sheet2.
893 ScMarkData aMark(m_pDoc->GetSheetLimits());
894 aMark.SetMarkArea(aDestRange);
895 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
896 false);
897 pTransClip.reset();
899 // Check transpose of merged cells
900 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
901 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, destSheet));
902 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, destSheet));
903 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
904 lcl_getMergeSizeOfCell(*m_pDoc, 2, 1, destSheet));
905 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 1, destSheet));
906 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
907 lcl_getMergeSizeOfCell(*m_pDoc, 3, 1, destSheet));
908 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 3, 2, destSheet));
910 m_pDoc->DeleteTab(destSheet);
911 m_pDoc->DeleteTab(srcSheet);
914 // InsertDeleteFlags::CONTENTS
915 void TestCopyPaste::testCopyPasteSpecialAsLinkTranspose()
917 const SCTAB srcSheet = 0;
918 const SCTAB destSheet = 1;
920 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
922 m_pDoc->InsertTab(srcSheet, "Sheet1");
923 m_pDoc->InsertTab(destSheet, "Sheet2");
925 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
926 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
927 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
929 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet); // Copy A1:A4 to clip.
930 ScDocument aClipDoc(SCDOCMODE_CLIP);
931 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
933 // transpose
934 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
935 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::CONTENTS, true, false);
937 ScRange aDestRange(1, 1, destSheet, 4, 1, destSheet); // Paste to B2:E2 on Sheet2.
938 ScMarkData aMark(m_pDoc->GetSheetLimits());
939 aMark.SetMarkArea(aDestRange);
940 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, pTransClip.get(),
941 true, false);
942 pTransClip.reset();
944 // Check pasted content to make sure they reference the correct cells.
945 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
946 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
947 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
948 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
950 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
951 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
952 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"), getFormula(2, 1, destSheet));
953 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
955 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
956 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D2.", !pFC);
958 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
959 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
960 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"), getFormula(4, 1, destSheet));
961 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
963 m_pDoc->DeleteTab(destSheet);
964 m_pDoc->DeleteTab(srcSheet);
967 // InsertDeleteFlags::CONTENTS
968 void TestCopyPaste::testCopyPasteSpecialAsLinkFilteredTranspose()
970 const SCTAB srcSheet = 0;
971 const SCTAB destSheet = 1;
973 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
975 m_pDoc->InsertTab(srcSheet, "Sheet1");
976 m_pDoc->InsertTab(destSheet, "Sheet2");
978 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
979 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
980 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
982 // Filter row 1
983 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
984 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
986 pDBData->SetAutoFilter(true);
987 ScRange aRange;
988 pDBData->GetArea(aRange);
989 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
990 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
992 //create the query param
993 ScQueryParam aParam;
994 pDBData->GetQueryParam(aParam);
995 ScQueryEntry& rEntry = aParam.GetEntry(0);
996 rEntry.bDoQuery = true;
997 rEntry.nField = 0;
998 rEntry.eOp = SC_NOT_EQUAL;
999 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1000 // add queryParam to database range.
1001 pDBData->SetQueryParam(aParam);
1003 // perform the query.
1004 m_pDoc->Query(srcSheet, aParam, true);
1006 // Check precondition for test: row 1 is hidden/filtered
1007 SCROW nRow1, nRow2;
1008 SCROW nFilteredRow1, nFilteredRow2;
1009 bool bHidden = m_pDoc->RowHidden(SCROW(1), srcSheet, &nRow1, &nRow2);
1010 CPPUNIT_ASSERT_MESSAGE("row 1 should be hidden", bHidden);
1011 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow1);
1012 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow2);
1013 bool bFiltered = m_pDoc->RowFiltered(SCROW(1), srcSheet, &nFilteredRow1, &nFilteredRow2);
1014 CPPUNIT_ASSERT_MESSAGE("row 1 should be filtered", bFiltered);
1015 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow1);
1016 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow2);
1018 // Copy A1:A4 to clip.
1019 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet);
1020 ScDocument aClipDoc(SCDOCMODE_CLIP);
1021 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1023 // transpose
1024 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1025 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::CONTENTS, true, false);
1027 ScRange aDestRange(1, 1, destSheet, 3, 1, destSheet); // Paste to B2:D2 on Sheet2.
1028 ScMarkData aMark(m_pDoc->GetSheetLimits());
1029 aMark.SetMarkArea(aDestRange);
1030 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, pTransClip.get(),
1031 true, false, false);
1032 pTransClip.reset();
1034 // Check pasted content to make sure they reference the correct cells.
1035 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1036 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1037 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1038 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1040 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1041 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C2.", !pFC);
1043 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1044 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1045 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"), getFormula(3, 1, destSheet));
1046 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1048 m_pDoc->DeleteTab(destSheet);
1049 m_pDoc->DeleteTab(srcSheet);
1052 // tdf#141683
1053 // InsertDeleteFlags::VALUE
1054 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowAsLinkTranspose()
1056 const SCTAB srcSheet = 0;
1057 const SCTAB destSheet = 1;
1059 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1061 m_pDoc->InsertTab(srcSheet, "Sheet1");
1062 m_pDoc->InsertTab(destSheet, "Sheet2");
1064 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1065 m_pDoc->SetValue(1, 0, srcSheet, 2); // B1
1066 m_pDoc->SetValue(3, 0, srcSheet, 4); // D1
1068 m_pDoc->SetValue(0, 2, srcSheet, 11); // A3
1069 m_pDoc->SetValue(1, 2, srcSheet, 12); // B3
1070 m_pDoc->SetValue(3, 2, srcSheet, 14); // D3
1072 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1073 aSrcMark.SelectOneTable(0);
1074 ScClipParam aClipParam;
1075 aClipParam.meDirection = ScClipParam::Row;
1076 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 3, 0, srcSheet)); // A1:D1
1077 aClipParam.maRanges.push_back(ScRange(0, 2, srcSheet, 3, 2, srcSheet)); // A3:D3
1079 ScDocument aClipDoc(SCDOCMODE_CLIP);
1080 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1082 // transpose
1083 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1084 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1086 ScRange aDestRange(1, 1, destSheet, 2, 4, destSheet); // Paste to B2:C5 on Sheet2.
1087 ScMarkData aMark(m_pDoc->GetSheetLimits());
1088 aMark.SetMarkArea(aDestRange);
1089 m_pDoc->CopyMultiRangeFromClip(
1090 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1091 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1092 pTransClip.reset();
1094 // Check pasted content to make sure they reference the correct cells.
1095 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1096 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1097 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1098 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1100 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1101 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1102 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$B$1"), getFormula(1, 2, destSheet));
1103 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1105 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, destSheet));
1106 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell B4.", !pFC);
1108 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 4, destSheet));
1109 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1110 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B5", OUString("=$Sheet1.$D$1"), getFormula(1, 4, destSheet));
1111 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1113 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1114 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1115 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"), getFormula(2, 1, destSheet));
1116 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1118 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1119 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1120 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$B$3"), getFormula(2, 2, destSheet));
1121 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1123 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 3, destSheet));
1124 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C4.", !pFC);
1126 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 4, destSheet));
1127 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1128 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C5", OUString("=$Sheet1.$D$3"), getFormula(2, 4, destSheet));
1129 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1131 m_pDoc->DeleteTab(destSheet);
1132 m_pDoc->DeleteTab(srcSheet);
1135 // tdf#141683
1136 // InsertDeleteFlags::VALUE
1137 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose()
1139 const SCTAB srcSheet = 0;
1140 const SCTAB destSheet = 1;
1142 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1144 m_pDoc->InsertTab(srcSheet, "Sheet1");
1145 m_pDoc->InsertTab(destSheet, "Sheet2");
1147 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1148 m_pDoc->SetValue(1, 0, srcSheet, 2); // B1
1149 m_pDoc->SetValue(3, 0, srcSheet, 4); // D1
1151 m_pDoc->SetValue(0, 1, srcSheet, -1); // A2, filtered and selected
1152 m_pDoc->SetValue(1, 1, srcSheet, -2); // B2, filtered and selected
1153 m_pDoc->SetValue(3, 1, srcSheet, -4); // D2, filtered and selected
1155 m_pDoc->SetValue(0, 2, srcSheet, 11); // A3
1156 m_pDoc->SetValue(1, 2, srcSheet, 12); // B3
1157 m_pDoc->SetValue(3, 2, srcSheet, 14); // D3
1159 m_pDoc->SetValue(0, 3, srcSheet, -11); // A4, filtered and not selected
1160 m_pDoc->SetValue(1, 3, srcSheet, -12); // B4, filtered and not selected
1161 m_pDoc->SetValue(3, 3, srcSheet, -14); // D4, filtered and not selected
1163 m_pDoc->SetValue(0, 5, srcSheet, 111); // A6
1164 m_pDoc->SetValue(1, 5, srcSheet, 112); // B6
1165 m_pDoc->SetValue(3, 5, srcSheet, 114); // D6
1167 // Filter row 1
1168 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 3, 3);
1169 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1171 pDBData->SetAutoFilter(true);
1172 ScRange aRange;
1173 pDBData->GetArea(aRange);
1174 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1175 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1177 //create the query param
1178 ScQueryParam aParam;
1179 pDBData->GetQueryParam(aParam);
1180 ScQueryEntry& rEntry = aParam.GetEntry(0);
1181 rEntry.bDoQuery = true;
1182 rEntry.nField = 0;
1183 rEntry.eOp = SC_GREATER_EQUAL;
1184 rEntry.GetQueryItem().mfVal = 0; // filtering negative values -> filtering row 1 and 2
1185 // add queryParam to database range.
1186 pDBData->SetQueryParam(aParam);
1188 // perform the query.
1189 m_pDoc->Query(srcSheet, aParam, true);
1191 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1192 aSrcMark.SelectOneTable(0);
1193 ScClipParam aClipParam;
1194 aClipParam.meDirection = ScClipParam::Row;
1195 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 3, 2, srcSheet)); // A1:C3
1196 aClipParam.maRanges.push_back(ScRange(0, 5, srcSheet, 3, 5, srcSheet)); // A6:C6
1198 ScDocument aClipDoc(SCDOCMODE_CLIP);
1199 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1201 printRange(m_pDoc, aClipParam.getWholeRange(), "Src range");
1202 // transpose
1203 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1204 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1206 printRange(&aClipDoc, ScRange(0, 0, 0, 4, 5, 0), "Base doc (&aClipDoc)");
1207 printRange(pTransClip.get(), ScRange(0, 0, 0, 3, 3, 0),
1208 "Transposed filtered clipdoc (pTransClip.get())");
1209 ScRange aDestRange(1, 1, destSheet, 3, 4, destSheet); // Paste to B2:D5 on Sheet2.
1210 ScMarkData aMark(m_pDoc->GetSheetLimits());
1211 aMark.SetMarkArea(aDestRange);
1212 m_pDoc->CopyMultiRangeFromClip(
1213 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1214 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1215 pTransClip.reset();
1216 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
1218 // Check pasted content to make sure they reference the correct cells.
1219 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1220 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1221 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1222 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1224 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1225 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1226 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$B$1"), getFormula(1, 2, destSheet));
1227 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1229 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, destSheet));
1230 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell B4.", !pFC);
1232 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 4, destSheet));
1233 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1234 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B5", OUString("=$Sheet1.$D$1"), getFormula(1, 4, destSheet));
1235 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1237 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1238 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1239 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"), getFormula(2, 1, destSheet));
1240 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1242 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1243 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1244 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$B$3"), getFormula(2, 2, destSheet));
1245 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1247 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 3, destSheet));
1248 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C4.", !pFC);
1250 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 4, destSheet));
1251 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1252 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C5", OUString("=$Sheet1.$D$3"), getFormula(2, 4, destSheet));
1253 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1255 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1256 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell D2.", pFC);
1257 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$6"), getFormula(3, 1, destSheet));
1258 CPPUNIT_ASSERT_EQUAL(111.0, pFC->GetValue());
1260 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1261 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell D3.", pFC);
1262 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("=$Sheet1.$B$6"), getFormula(3, 2, destSheet));
1263 CPPUNIT_ASSERT_EQUAL(112.0, pFC->GetValue());
1265 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 3, destSheet));
1266 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D4.", !pFC);
1268 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 4, destSheet));
1269 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1270 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("=$Sheet1.$D$6"), getFormula(3, 4, destSheet));
1271 CPPUNIT_ASSERT_EQUAL(114.0, pFC->GetValue());
1273 m_pDoc->DeleteTab(destSheet);
1274 m_pDoc->DeleteTab(srcSheet);
1277 // tdf#141683
1278 // InsertDeleteFlags::VALUE
1279 void TestCopyPaste::testCopyPasteSpecialMultiRangeColAsLinkTranspose()
1281 const SCTAB srcSheet = 0;
1282 const SCTAB destSheet = 1;
1284 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1286 m_pDoc->InsertTab(srcSheet, "Sheet1");
1287 m_pDoc->InsertTab(destSheet, "Sheet2");
1289 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1290 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1291 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1293 m_pDoc->SetValue(2, 0, srcSheet, 11); // C1
1294 m_pDoc->SetValue(2, 1, srcSheet, 12); // C2
1295 m_pDoc->SetValue(2, 3, srcSheet, 14); // C4
1297 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1298 aSrcMark.SelectOneTable(0);
1299 ScClipParam aClipParam;
1300 aClipParam.meDirection = ScClipParam::Column;
1301 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 0, 3, srcSheet)); // A1:A4
1302 aClipParam.maRanges.push_back(ScRange(2, 0, srcSheet, 2, 3, srcSheet)); // C1:C4
1304 ScDocument aClipDoc(SCDOCMODE_CLIP);
1305 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1307 // transpose
1308 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1309 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1311 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
1312 ScMarkData aMark(m_pDoc->GetSheetLimits());
1313 aMark.SetMarkArea(aDestRange);
1314 m_pDoc->CopyMultiRangeFromClip(
1315 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1316 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1317 pTransClip.reset();
1319 // Check pasted content to make sure they reference the correct cells.
1320 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1321 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1322 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1323 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1325 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1326 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1327 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"), getFormula(2, 1, destSheet));
1328 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1330 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1331 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D2.", !pFC);
1333 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
1334 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1335 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"), getFormula(4, 1, destSheet));
1336 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1338 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1339 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1340 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$C$1"), getFormula(1, 2, destSheet));
1341 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1343 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1344 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1345 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$C$2"), getFormula(2, 2, destSheet));
1346 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1348 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1349 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D3.", !pFC);
1351 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 2, destSheet));
1352 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1353 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("=$Sheet1.$C$4"), getFormula(4, 2, destSheet));
1354 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1356 m_pDoc->DeleteTab(destSheet);
1357 m_pDoc->DeleteTab(srcSheet);
1360 // tdf#141683
1361 // InsertDeleteFlags::VALUE
1362 void TestCopyPaste::testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose()
1364 const SCTAB srcSheet = 0;
1365 const SCTAB destSheet = 1;
1367 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1369 m_pDoc->InsertTab(srcSheet, "Sheet1");
1370 m_pDoc->InsertTab(destSheet, "Sheet2");
1372 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1373 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1374 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1376 m_pDoc->SetValue(2, 0, srcSheet, 11); // C1
1377 m_pDoc->SetValue(2, 1, srcSheet, 12); // C2
1378 m_pDoc->SetValue(2, 3, srcSheet, 14); // C4
1380 // Filter row 1
1381 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
1382 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1384 pDBData->SetAutoFilter(true);
1385 ScRange aRange;
1386 pDBData->GetArea(aRange);
1387 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1388 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1390 //create the query param
1391 ScQueryParam aParam;
1392 pDBData->GetQueryParam(aParam);
1393 ScQueryEntry& rEntry = aParam.GetEntry(0);
1394 rEntry.bDoQuery = true;
1395 rEntry.nField = 0;
1396 rEntry.eOp = SC_NOT_EQUAL;
1397 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1398 // add queryParam to database range.
1399 pDBData->SetQueryParam(aParam);
1401 // perform the query.
1402 m_pDoc->Query(srcSheet, aParam, true);
1404 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1405 aSrcMark.SelectOneTable(0);
1406 ScClipParam aClipParam;
1407 aClipParam.meDirection = ScClipParam::Column;
1408 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 0, 3, srcSheet)); // A1:A4
1409 aClipParam.maRanges.push_back(ScRange(2, 0, srcSheet, 2, 3, srcSheet)); // C1:C4
1411 ScDocument aClipDoc(SCDOCMODE_CLIP);
1412 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1414 // transpose
1415 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1416 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1418 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
1419 ScMarkData aMark(m_pDoc->GetSheetLimits());
1420 aMark.SetMarkArea(aDestRange);
1421 m_pDoc->CopyMultiRangeFromClip(
1422 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1423 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1424 pTransClip.reset();
1426 // Check pasted content to make sure they reference the correct cells.
1427 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1428 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1429 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1430 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1432 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1433 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C2.", !pFC);
1435 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1436 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1437 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"), getFormula(3, 1, destSheet));
1438 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1440 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1441 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1442 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$C$1"), getFormula(1, 2, destSheet));
1443 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1445 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1446 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C3.", !pFC);
1448 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1449 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1450 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("=$Sheet1.$C$4"), getFormula(3, 2, destSheet));
1451 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1453 m_pDoc->DeleteTab(destSheet);
1454 m_pDoc->DeleteTab(srcSheet);
1457 // InsertDeleteFlags::ALL
1458 void TestCopyPaste::testCopyPasteSpecialAllAsLinkTranspose()
1460 const SCTAB srcSheet = 0;
1461 const SCTAB destSheet = 1;
1463 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1465 m_pDoc->InsertTab(srcSheet, "Sheet1");
1466 m_pDoc->InsertTab(destSheet, "Sheet2");
1468 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1469 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1470 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1472 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet); // Copy A1:A4 to clip.
1473 ScDocument aClipDoc(SCDOCMODE_CLIP);
1474 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1476 // transpose
1477 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1478 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
1480 ScRange aDestRange(1, 1, destSheet, 4, 1, destSheet); // Paste to B2:E2 on Sheet2.
1481 ScMarkData aMark(m_pDoc->GetSheetLimits());
1482 aMark.SetMarkArea(aDestRange);
1483 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
1484 false);
1485 pTransClip.reset();
1487 // Check pasted content to make sure they reference the correct cells.
1488 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1489 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1490 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1491 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1493 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1494 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1495 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"), getFormula(2, 1, destSheet));
1496 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1498 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1499 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1500 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$3"), getFormula(3, 1, destSheet));
1501 CPPUNIT_ASSERT_EQUAL(0.0, pFC->GetValue());
1503 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
1504 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1505 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"), getFormula(4, 1, destSheet));
1506 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1508 m_pDoc->DeleteTab(destSheet);
1509 m_pDoc->DeleteTab(srcSheet);
1512 // InsertDeleteFlags::ALL
1513 void TestCopyPaste::testCopyPasteSpecialAllAsLinkFilteredTranspose()
1515 const SCTAB srcSheet = 0;
1516 const SCTAB destSheet = 1;
1518 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1520 m_pDoc->InsertTab(srcSheet, "Sheet1");
1521 m_pDoc->InsertTab(destSheet, "Sheet2");
1523 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1524 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1525 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1527 // Filter row 1
1528 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
1529 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1531 pDBData->SetAutoFilter(true);
1532 ScRange aRange;
1533 pDBData->GetArea(aRange);
1534 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1535 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1537 //create the query param
1538 ScQueryParam aParam;
1539 pDBData->GetQueryParam(aParam);
1540 ScQueryEntry& rEntry = aParam.GetEntry(0);
1541 rEntry.bDoQuery = true;
1542 rEntry.nField = 0;
1543 rEntry.eOp = SC_NOT_EQUAL;
1544 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1545 // add queryParam to database range.
1546 pDBData->SetQueryParam(aParam);
1548 // perform the query.
1549 m_pDoc->Query(srcSheet, aParam, true);
1551 // Check precondition for test: row 1 is hidden/filtered
1552 SCROW nRow1, nRow2;
1553 SCROW nFilteredRow1, nFilteredRow2;
1554 bool bHidden = m_pDoc->RowHidden(SCROW(1), srcSheet, &nRow1, &nRow2);
1555 CPPUNIT_ASSERT_MESSAGE("row 1 should be hidden", bHidden);
1556 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow1);
1557 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow2);
1558 bool bFiltered = m_pDoc->RowFiltered(SCROW(1), srcSheet, &nFilteredRow1, &nFilteredRow2);
1559 CPPUNIT_ASSERT_MESSAGE("row 1 should be filtered", bFiltered);
1560 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow1);
1561 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow2);
1563 // Copy A1:A4 to clip.
1564 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet);
1565 ScDocument aClipDoc(SCDOCMODE_CLIP);
1566 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1568 // transpose
1569 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1570 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
1572 ScRange aDestRange(1, 1, destSheet, 3, 1, destSheet); // Paste to B2:D2 on Sheet2.
1573 ScMarkData aMark(m_pDoc->GetSheetLimits());
1574 aMark.SetMarkArea(aDestRange);
1575 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
1576 false, false);
1577 pTransClip.reset();
1579 // Check pasted content to make sure they reference the correct cells.
1580 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1581 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1582 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"), getFormula(1, 1, destSheet));
1583 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1585 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1586 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1587 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"), getFormula(2, 1, destSheet));
1588 CPPUNIT_ASSERT_EQUAL(0.0, pFC->GetValue());
1590 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1591 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1592 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"), getFormula(3, 1, destSheet));
1593 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1595 m_pDoc->DeleteTab(destSheet);
1596 m_pDoc->DeleteTab(srcSheet);
1599 // Compatibility method since normal copy/paste tests do not test undo
1600 void TestCopyPaste::executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
1601 bool bTranspose, bool bMultiRangeSelection,
1602 bool bSkipEmpty, bool bCut,
1603 ScClipParam::Direction eDirection, CalcMode eCalcMode,
1604 InsertDeleteFlags aFlags)
1606 std::unique_ptr<ScUndoCut> pUndoCut;
1607 std::unique_ptr<ScUndoPaste> pUndoPaste;
1608 executeCopyPasteSpecial(0, 1, bApplyFilter, bIncludedFiltered, bAsLink, bTranspose,
1609 bMultiRangeSelection, bSkipEmpty, pUndoCut, pUndoPaste, bCut,
1610 eDirection, eCalcMode, aFlags);
1613 // This method is used to create the different copy/paste special test cases.
1614 // Principle: Creation of test cases is parameterized, whereas checking uses a minimum of logic
1615 void TestCopyPaste::executeCopyPasteSpecial(const SCTAB srcSheet, const SCTAB destSheet,
1616 bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
1617 bool bTranspose, bool bMultiRangeSelection,
1618 bool bSkipEmpty, std::unique_ptr<ScUndoCut>& pUndoCut,
1619 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bCut,
1620 ScClipParam::Direction eDirection, CalcMode eCalcMode,
1621 InsertDeleteFlags aFlags)
1623 // turn on/off auto calc
1624 sc::AutoCalcSwitch aACSwitch(*m_pDoc, eCalcMode == AutoCalc);
1626 for (int i = 0; i < srcSheet; ++i)
1627 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
1629 m_pDoc->InsertTab(srcSheet, "SrcSheet");
1631 // We need a drawing layer in order to create caption objects.
1632 m_pDoc->InitDrawLayer(m_xDocShell.get());
1633 ScFieldEditEngine& rEditEngine = m_pDoc->GetEditEngine();
1636 | B | C | D | E | F | G |
1638 3r | 1 B*| =B3+10 *| a | R1 *| =B3+B5+60 | =SUMIF(B3:B6;"<4") |
1639 4r | 2 B*| =B4+20 b | b *| R2 *| | *| <- filtered row
1640 5r | 3 B*| =E5+30 b*| c *| 5 *| B*| |
1641 6 | 4 | =B4+40 b*| d *| R4 *| =B3+B5+70 *| =C$3+$B$5+80 *|
1642 (7r | 6 | q | r bB*| s bB| t | u |) optional, for row range
1643 (8 | -1 | -2 | -3 | -4 | -5 | -6 |) optional, for row range
1644 (9r | -11 | -12 | -13 | -14 | -15 | -16 |) optional, for row range
1645 (10 | -21 | -22 | -23 | -24 | -25 | -26 |) optional, for row range
1647 \______________/ \________________________________________/
1648 col range 1 col range 2
1650 refs to cells (used for cut/paste tests)
1651 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) |
1652 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) |
1654 * means note attached
1655 B means background
1656 b means border
1657 r means row selected for row range in multi range selection
1659 The following test scenarios can be created:
1661 * Filtered row
1662 * Transpose
1663 * All cell types: numbers, strings, formulas, rich text, empty cell
1664 * Notes at different position
1665 * Formula references to rows before and after filtered row
1666 * Double reference (e.g. B3:B5)
1667 * Relative and absolute references
1668 * absolute references are not changed by transposing
1669 * Formatting patterns (e.g. cell backgrounds and borders)
1670 * Multi range selection with direction column and row
1673 SCCOL nSrcCols = 6;
1674 SCROW nSrcRows = 4;
1675 // Add additional row for MultiRange test cases
1676 if (bMultiRangeSelection)
1678 nSrcRows = eDirection == ScClipParam::Row ? nSrcRows + 2 : nSrcRows;
1679 nSrcCols = eDirection == ScClipParam::Column ? nSrcCols + 1 : nSrcCols;
1682 const SCCOL nStartCol = 1;
1683 const SCROW nStartRow = 2;
1685 // col B
1686 m_pDoc->SetValue(1, 2, srcSheet, 1);
1687 m_pDoc->SetValue(1, 3, srcSheet, 2);
1688 m_pDoc->SetValue(1, 4, srcSheet, 3);
1689 m_pDoc->SetValue(1, 5, srcSheet, 4);
1690 // col C
1691 m_pDoc->SetString(2, 2, srcSheet, "=B3+10");
1692 m_pDoc->SetString(2, 3, srcSheet, "=B4+20");
1693 m_pDoc->SetString(2, 4, srcSheet, "=E5+30");
1694 m_pDoc->SetString(2, 5, srcSheet, "=B4+40");
1695 // col D
1696 m_pDoc->SetString(3, 2, srcSheet, "a");
1697 m_pDoc->SetString(3, 3, srcSheet, "b");
1698 m_pDoc->SetString(3, 4, srcSheet, "c");
1699 m_pDoc->SetString(3, 5, srcSheet, "d");
1700 // col E
1701 rEditEngine.SetTextCurrentDefaults("R1");
1702 m_pDoc->SetEditText(ScAddress(4, 2, srcSheet), rEditEngine.CreateTextObject());
1703 rEditEngine.SetTextCurrentDefaults("R2");
1704 m_pDoc->SetEditText(ScAddress(4, 3, srcSheet), rEditEngine.CreateTextObject());
1705 m_pDoc->SetValue(4, 4, srcSheet, 5);
1706 rEditEngine.SetTextCurrentDefaults("R4");
1707 m_pDoc->SetEditText(ScAddress(4, 5, srcSheet), rEditEngine.CreateTextObject());
1708 // col F
1709 m_pDoc->SetValue(5, 2, srcSheet, 9);
1710 m_pDoc->SetString(5, 2, srcSheet, "=B3+B5+60");
1711 m_pDoc->SetEmptyCell(ScAddress(5, 3, srcSheet));
1712 m_pDoc->SetEmptyCell(ScAddress(5, 4, srcSheet));
1713 m_pDoc->SetString(5, 5, srcSheet, "=B3+B5+70");
1714 // col G
1715 m_pDoc->SetValue(6, 2, srcSheet, 9);
1716 m_pDoc->SetString(6, 2, srcSheet, "=SUMIF(B3:B6;\"<4\")");
1717 m_pDoc->SetEmptyCell(ScAddress(6, 3, srcSheet));
1718 m_pDoc->SetEmptyCell(ScAddress(6, 4, srcSheet));
1719 m_pDoc->SetString(6, 5, srcSheet, "=C$3+$B$5+80");
1721 const SfxPoolItem* pItem = nullptr;
1723 // row 6, additional row for MultiRange test case, otherwise not selected
1724 m_pDoc->SetValue(1, 6, srcSheet, 6);
1725 m_pDoc->SetString(2, 6, srcSheet, "q");
1726 m_pDoc->SetString(3, 6, srcSheet, "r");
1727 m_pDoc->SetString(4, 6, srcSheet, "s");
1728 m_pDoc->SetString(5, 6, srcSheet, "t");
1729 m_pDoc->SetString(6, 6, srcSheet, "u");
1731 // row 7, not selected
1732 m_pDoc->SetValue(1, 7, srcSheet, -1);
1733 m_pDoc->SetValue(2, 7, srcSheet, -2);
1734 m_pDoc->SetValue(3, 7, srcSheet, -3);
1735 m_pDoc->SetValue(4, 7, srcSheet, -4);
1736 m_pDoc->SetValue(5, 7, srcSheet, -5);
1737 m_pDoc->SetValue(6, 7, srcSheet, -6);
1739 // row 8, additional row for MultiRange test case, otherwise not selected
1740 m_pDoc->SetValue(1, 8, srcSheet, -11);
1741 m_pDoc->SetValue(2, 8, srcSheet, -12);
1742 m_pDoc->SetValue(3, 8, srcSheet, -13);
1743 m_pDoc->SetValue(4, 8, srcSheet, -14);
1744 m_pDoc->SetValue(5, 8, srcSheet, -15);
1745 m_pDoc->SetValue(6, 8, srcSheet, -16);
1747 // row 9, additional row for MultiRange test case, otherwise not selected
1748 m_pDoc->SetValue(1, 9, srcSheet, -21);
1749 m_pDoc->SetValue(2, 9, srcSheet, -22);
1750 m_pDoc->SetValue(3, 9, srcSheet, -23);
1751 m_pDoc->SetValue(4, 9, srcSheet, -24);
1752 m_pDoc->SetValue(5, 9, srcSheet, -25);
1753 m_pDoc->SetValue(6, 9, srcSheet, -26);
1755 // Col H, not selected
1756 m_pDoc->SetValue(7, 2, srcSheet, 111);
1757 m_pDoc->SetValue(7, 3, srcSheet, 112);
1758 m_pDoc->SetValue(7, 4, srcSheet, 113);
1759 m_pDoc->SetValue(7, 5, srcSheet, 114);
1760 m_pDoc->SetValue(7, 6, srcSheet, 115);
1761 m_pDoc->SetValue(7, 7, srcSheet, 116);
1763 // Col I, additional col for MultiRange test case, otherwise not selected
1764 m_pDoc->SetValue(8, 2, srcSheet, 121);
1765 m_pDoc->SetValue(8, 3, srcSheet, 122);
1766 m_pDoc->SetValue(8, 4, srcSheet, 123);
1767 m_pDoc->SetValue(8, 5, srcSheet, 124);
1768 m_pDoc->SetValue(8, 6, srcSheet, 125);
1769 m_pDoc->SetValue(8, 7, srcSheet, 126);
1771 // Col J, not selected
1772 m_pDoc->SetValue(9, 2, srcSheet, 131);
1773 m_pDoc->SetValue(9, 3, srcSheet, 132);
1774 m_pDoc->SetValue(9, 4, srcSheet, 133);
1775 m_pDoc->SetValue(9, 5, srcSheet, 134);
1776 m_pDoc->SetValue(9, 6, srcSheet, 135);
1777 m_pDoc->SetValue(9, 7, srcSheet, 136);
1779 // row 16, refs to copied/cut range
1780 m_pDoc->SetString(1, 16, srcSheet, "=C5");
1781 m_pDoc->SetString(2, 16, srcSheet, "=$C$5");
1782 m_pDoc->SetString(3, 16, srcSheet, "=$C5");
1783 m_pDoc->SetString(4, 16, srcSheet, "=C$5");
1784 m_pDoc->SetString(5, 16, srcSheet, "=SUM(C5:C5)");
1785 m_pDoc->SetString(6, 16, srcSheet, "=SUM($C$5:$C$5)");
1786 m_pDoc->SetString(7, 16, srcSheet, "=SUM($C5:$C5)");
1787 m_pDoc->SetString(8, 16, srcSheet, "=SUM(C$5:C$5)");
1788 m_pDoc->SetString(9, 16, srcSheet, "=SUM($B$3:$B$6)");
1789 m_pDoc->SetString(10, 16, srcSheet, "=SUM($B$3:$B$10)");
1791 // Cell position is used for ranges relative to current position
1792 ScAddress cellC6(2, 5, srcSheet);
1793 ScAddress cellA1(0, 0, srcSheet);
1794 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C5", cellC6, "$SrcSheet.C5"));
1795 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5", cellA1, "$SrcSheet.$C$5"));
1796 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5", cellC6, "$SrcSheet.$C5"));
1797 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_Ca5", cellC6, "$SrcSheet.C$5"));
1798 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C5_C5", cellC6, "$SrcSheet.C5:C5"));
1799 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa5", cellA1, "$SrcSheet.$C$5:$C$5"));
1800 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5_aC5", cellC6, "$SrcSheet.$C5:$C5"));
1801 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5_aC5", cellC6, "$SrcSheet.$C5:$C5"));
1802 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_Ca5_Ca5", cellC6, "$SrcSheet.C$5:C$5"));
1803 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa8", cellA1, "$SrcSheet.$B$3:$B$6"));
1804 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa10", cellA1, "$SrcSheet.$B$3:$B$10"));
1806 // row 17, refs to copied/cut range using range
1807 m_pDoc->SetString(1, 17, srcSheet, "=Range_C5");
1808 m_pDoc->SetString(2, 17, srcSheet, "=Range_aCa5");
1809 m_pDoc->SetString(3, 17, srcSheet, "=Range_aC5");
1810 m_pDoc->SetString(4, 17, srcSheet, "=Range_Ca5");
1811 m_pDoc->SetString(5, 17, srcSheet, "=SUM(Range_C5_C5)");
1812 m_pDoc->SetString(6, 17, srcSheet, "=SUM(Range_aCa5_aCa5)");
1813 m_pDoc->SetString(7, 17, srcSheet, "=SUM(Range_aC5_aC5)");
1814 m_pDoc->SetString(8, 17, srcSheet, "=SUM(Range_Ca5_Ca5)");
1815 m_pDoc->SetString(9, 17, srcSheet, "=SUM(Range_aCa5_aCa8)");
1816 m_pDoc->SetString(10, 17, srcSheet, "=SUM(Range_aCa5_aCa10)");
1818 // add patterns
1819 ScPatternAttr aCellBlueColor(m_pDoc->GetPool());
1820 aCellBlueColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
1821 m_pDoc->ApplyPatternAreaTab(1, 2, 1, 4, srcSheet, aCellBlueColor);
1823 // Check pattern precondition
1824 m_pDoc->GetPattern(ScAddress(1, 2, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1825 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B3 has a pattern", pItem);
1826 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
1827 m_pDoc->GetPattern(ScAddress(1, 3, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1828 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B4 has a pattern", pItem);
1829 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
1830 m_pDoc->GetPattern(ScAddress(1, 5, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1831 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B6 has no pattern", !pItem);
1833 // row 2 on empty cell
1834 ScPatternAttr aCellGreenColor(m_pDoc->GetPool());
1835 aCellGreenColor.GetItemSet().Put(SvxBrushItem(COL_GREEN, ATTR_BACKGROUND));
1836 m_pDoc->ApplyPatternAreaTab(5, 4, 5, 4, srcSheet, aCellGreenColor);
1838 // row 4 for multi range row selection
1839 ScPatternAttr aCellRedColor(m_pDoc->GetPool());
1840 aCellRedColor.GetItemSet().Put(SvxBrushItem(COL_RED, ATTR_BACKGROUND));
1841 m_pDoc->ApplyPatternAreaTab(3, 6, 4, 6, srcSheet, aCellRedColor);
1843 // add borders
1844 ::editeng::SvxBorderLine aLine(nullptr, 50, SvxBorderLineStyle::SOLID);
1845 SvxBoxItem aBorderItem(ATTR_BORDER);
1846 aBorderItem.SetLine(&aLine, SvxBoxItemLine::LEFT);
1847 aBorderItem.SetLine(&aLine, SvxBoxItemLine::RIGHT);
1848 m_pDoc->ApplyAttr(2, 3, srcSheet, aBorderItem);
1849 m_pDoc->ApplyAttr(2, 4, srcSheet, aBorderItem);
1850 m_pDoc->ApplyAttr(2, 5, srcSheet, aBorderItem);
1851 // Check border precondition
1852 pItem = m_pDoc->GetAttr(ScAddress(2, 2, srcSheet), ATTR_BORDER);
1853 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B1 has a border", pItem);
1854 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1855 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
1856 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1857 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1858 pItem = m_pDoc->GetAttr(ScAddress(2, 3, srcSheet), ATTR_BORDER);
1859 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B2 has a border", pItem);
1860 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1861 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
1862 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1863 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1864 // Check border precondition 2
1865 m_pDoc->GetPattern(ScAddress(2, 3, srcSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
1866 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B2 has a border", pItem);
1867 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1868 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
1869 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1870 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1871 // row 4 for multi range row selection
1872 ::editeng::SvxBorderLine aDoubleLine(nullptr, 50, SvxBorderLineStyle::DOUBLE);
1873 SvxBoxItem aDoubleBorderItem(ATTR_BORDER);
1874 aDoubleBorderItem.SetLine(&aDoubleLine, SvxBoxItemLine::TOP);
1875 aDoubleBorderItem.SetLine(&aDoubleLine, SvxBoxItemLine::BOTTOM);
1876 m_pDoc->ApplyAttr(3, 6, srcSheet, aDoubleBorderItem);
1877 m_pDoc->ApplyAttr(4, 6, srcSheet, aDoubleBorderItem);
1879 // add notes to B3:F4
1881 // add notes row 2
1882 setNote(1, 2, srcSheet, "Note A1");
1883 setNote(2, 2, srcSheet, "Note B1");
1884 // No note on D3
1885 setNote(4, 2, srcSheet, "Note D1");
1886 // No note on F3
1887 // No note on G3
1889 // add notes row 3
1890 setNote(1, 3, srcSheet, "Note A2");
1891 // No note on C4
1892 setNote(3, 3, srcSheet, "Note C2");
1893 setNote(4, 3, srcSheet, "Note D2");
1894 setNote(5, 4, srcSheet, "Note E2");
1895 setNote(6, 3, srcSheet, "Note F2");
1897 // add notes row 4
1898 setNote(1, 4, srcSheet, "Note A3");
1899 setNote(2, 4, srcSheet, "Note B3");
1900 setNote(3, 4, srcSheet, "Note C3");
1901 setNote(4, 4, srcSheet, "Note D3");
1902 // No note on F5
1903 // No note on G5
1905 // add notes row 5
1906 // No note on B6
1907 setNote(2, 5, srcSheet, "Note B4");
1908 setNote(3, 5, srcSheet, "Note C4");
1909 setNote(4, 5, srcSheet, "Note D4");
1910 setNote(5, 5, srcSheet, "Note E4");
1911 setNote(6, 5, srcSheet, "Note F4");
1913 // row 6 for multi range row selection
1914 setNote(3, 6, srcSheet, "Note C5");
1916 // Recalc if needed
1917 if (bMultiRangeSelection && bTranspose && eDirection == ScClipParam::Row
1918 && eCalcMode == RecalcAtEnd)
1919 m_pDoc->CalcFormulaTree();
1920 else if (bMultiRangeSelection && bTranspose && eDirection == ScClipParam::Row
1921 && eCalcMode == HardRecalcAtEnd)
1922 m_pDoc->CalcAll();
1924 // Filter out row 3
1925 if (bApplyFilter)
1927 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, nStartCol, nStartRow,
1928 nStartCol + nSrcCols - 1, nStartRow + nSrcRows - 1);
1929 m_pDoc->SetAnonymousDBData(srcSheet, std::unique_ptr<ScDBData>(pDBData));
1931 pDBData->SetAutoFilter(true);
1932 ScRange aRange;
1933 pDBData->GetArea(aRange);
1934 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1935 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1937 //create the query param
1938 ScQueryParam aParam;
1939 pDBData->GetQueryParam(aParam);
1940 ScQueryEntry& rEntry = aParam.GetEntry(0);
1941 rEntry.bDoQuery = true;
1942 rEntry.nField = nStartCol;
1943 rEntry.eOp = SC_NOT_EQUAL;
1944 rEntry.GetQueryItem().mfVal = 2; // value of row B4 -> filtering row 3
1945 // add queryParam to database range.
1946 pDBData->SetQueryParam(aParam);
1948 // perform the query.
1949 m_pDoc->Query(srcSheet, aParam, true);
1951 // Check precondition for test: row 3 is hidden/filtered
1952 SCROW nRow1, nRow2;
1953 SCROW nFilteredRow1, nFilteredRow2;
1954 bool bHidden = m_pDoc->RowHidden(SCROW(3), srcSheet, &nRow1, &nRow2);
1955 CPPUNIT_ASSERT_MESSAGE("row 3 should be hidden", bHidden);
1956 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be hidden", SCROW(3), nRow1);
1957 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be hidden", SCROW(3), nRow2);
1958 bool bFiltered = m_pDoc->RowFiltered(SCROW(3), srcSheet, &nFilteredRow1, &nFilteredRow2);
1959 CPPUNIT_ASSERT_MESSAGE("row 3 should be filtered", bFiltered);
1960 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be filtered", SCROW(3), nFilteredRow1);
1961 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be filtered", SCROW(3), nFilteredRow2);
1964 // create destination sheet
1965 // const SCTAB destSheet = 1;
1966 for (int i = srcSheet + 1; i < destSheet; ++i)
1967 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
1969 if (srcSheet != destSheet)
1970 m_pDoc->InsertTab(destSheet, "DestSheet");
1972 m_pDoc->SetString(3, 101, srcSheet, "=DestSheet.D1");
1973 m_pDoc->SetString(3, 102, srcSheet, "=DestSheet.D2");
1974 m_pDoc->SetString(3, 103, srcSheet, "=DestSheet.D3");
1975 m_pDoc->SetString(3, 104, srcSheet, "=DestSheet.D4");
1976 m_pDoc->SetString(3, 105, srcSheet, "=DestSheet.D5");
1977 m_pDoc->SetString(3, 106, srcSheet, "=DestSheet.D6");
1978 m_pDoc->SetString(3, 107, srcSheet, "=DestSheet.D7");
1979 m_pDoc->SetString(4, 101, srcSheet, "=DestSheet.E1");
1980 m_pDoc->SetString(4, 102, srcSheet, "=DestSheet.E2");
1981 m_pDoc->SetString(4, 103, srcSheet, "=DestSheet.E3");
1982 m_pDoc->SetString(4, 104, srcSheet, "=DestSheet.E4");
1983 m_pDoc->SetString(4, 105, srcSheet, "=DestSheet.E5");
1984 m_pDoc->SetString(4, 106, srcSheet, "=DestSheet.E6");
1985 m_pDoc->SetString(4, 107, srcSheet, "=DestSheet.E7");
1986 m_pDoc->SetString(5, 101, srcSheet, "=DestSheet.F1");
1987 m_pDoc->SetString(5, 102, srcSheet, "=DestSheet.F2");
1988 m_pDoc->SetString(5, 103, srcSheet, "=DestSheet.F3");
1989 m_pDoc->SetString(5, 104, srcSheet, "=DestSheet.F4");
1990 m_pDoc->SetString(5, 105, srcSheet, "=DestSheet.F5");
1991 m_pDoc->SetString(5, 106, srcSheet, "=DestSheet.F6");
1992 m_pDoc->SetString(5, 107, srcSheet, "=DestSheet.F7");
1993 m_pDoc->SetString(6, 101, srcSheet, "=DestSheet.G1");
1994 m_pDoc->SetString(6, 102, srcSheet, "=DestSheet.G2");
1995 m_pDoc->SetString(6, 103, srcSheet, "=DestSheet.G3");
1996 m_pDoc->SetString(6, 104, srcSheet, "=DestSheet.G4");
1997 m_pDoc->SetString(6, 105, srcSheet, "=DestSheet.G5");
1998 m_pDoc->SetString(6, 106, srcSheet, "=DestSheet.G6");
1999 m_pDoc->SetString(6, 107, srcSheet, "=DestSheet.G7");
2000 m_pDoc->SetString(7, 101, srcSheet, "=DestSheet.H1");
2001 m_pDoc->SetString(7, 102, srcSheet, "=DestSheet.H2");
2002 m_pDoc->SetString(7, 103, srcSheet, "=DestSheet.H3");
2003 m_pDoc->SetString(7, 104, srcSheet, "=DestSheet.H4");
2004 m_pDoc->SetString(7, 105, srcSheet, "=DestSheet.H5");
2005 m_pDoc->SetString(7, 106, srcSheet, "=DestSheet.H6");
2006 m_pDoc->SetString(7, 107, srcSheet, "=DestSheet.H7");
2007 m_pDoc->SetString(8, 101, srcSheet, "=DestSheet.I1");
2008 m_pDoc->SetString(8, 102, srcSheet, "=DestSheet.I2");
2009 m_pDoc->SetString(8, 103, srcSheet, "=DestSheet.I3");
2010 m_pDoc->SetString(8, 104, srcSheet, "=DestSheet.I4");
2011 m_pDoc->SetString(8, 105, srcSheet, "=DestSheet.I5");
2012 m_pDoc->SetString(8, 106, srcSheet, "=DestSheet.I6");
2013 m_pDoc->SetString(8, 107, srcSheet, "=DestSheet.I7");
2014 m_pDoc->SetString(9, 101, srcSheet, "=DestSheet.J1");
2015 m_pDoc->SetString(9, 102, srcSheet, "=DestSheet.J2");
2016 m_pDoc->SetString(9, 103, srcSheet, "=DestSheet.J3");
2017 m_pDoc->SetString(9, 104, srcSheet, "=DestSheet.J4");
2018 m_pDoc->SetString(9, 105, srcSheet, "=DestSheet.J5");
2019 m_pDoc->SetString(9, 106, srcSheet, "=DestSheet.J6");
2020 m_pDoc->SetString(9, 107, srcSheet, "=DestSheet.J7");
2022 // Check precondition
2023 checkCopyPasteSpecialInitial(srcSheet);
2025 // set cells to 1000 to check empty cell behaviour and to detect destination range problems
2026 for (int i = 0; i < 10; ++i)
2027 for (int j = 0; j < 10; ++j)
2028 m_pDoc->SetValue(i, j, destSheet, 1000);
2030 // transpose clipboard, paste on DestSheet
2031 ScDocument aClipDoc(SCDOCMODE_CLIP);
2032 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
2033 ScRange aDestRange;
2035 ScDocumentUniquePtr pPasteUndoDoc;
2036 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
2037 std::unique_ptr<ScRefUndoData> pUndoData;
2039 if (!bMultiRangeSelection)
2041 ScRange aSrcRange(nStartCol, nStartRow, srcSheet, nStartCol + nSrcCols - 1,
2042 nStartRow + nSrcRows - 1, srcSheet);
2043 printRange(m_pDoc, aSrcRange, "Src range");
2044 if (!bCut)
2045 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
2046 else
2048 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, true));
2051 printRange(&aClipDoc,
2052 ScRange(nStartCol, nStartRow, srcSheet, nStartCol + nSrcCols,
2053 nStartRow + nSrcRows, srcSheet),
2054 "Base doc (&aClipDoc)");
2056 // ScDocument::TransposeClip() and ScDocument::CopyFromClip() calls
2057 // analog to ScViewFunc::PasteFromClip()
2058 if (bTranspose)
2060 ScDocument* pOrigClipDoc = &aClipDoc;
2061 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
2062 aClipDoc.TransposeClip(pTransClip.get(), aFlags, bAsLink, bIncludedFiltered);
2063 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcRows - 1, 1 + nSrcCols - 1,
2064 destSheet); //target: D2:F6
2065 aDestMark.SetMarkArea(aDestRange);
2066 printRange(pTransClip.get(), ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
2067 "Transposed clipdoc (pTransClip.get())");
2069 if (bCut)
2070 prepareUndoBeforePaste(bCut, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
2071 pUndoData);
2073 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
2074 pTransClip.get(), true, bAsLink, bIncludedFiltered, bSkipEmpty);
2075 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
2076 if (bCut)
2078 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark,
2079 pPasteRefUndoDoc.get());
2080 printRange(m_pDoc, aDestRange, "Transposed dest sheet after UpdateTranspose()");
2082 pTransClip.reset();
2084 else
2086 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcCols - 1, 1 + nSrcRows - 1,
2087 destSheet); //target: D2:I5
2088 aDestMark.SetMarkArea(aDestRange);
2089 if (bCut)
2090 prepareUndoBeforePaste(bCut, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
2091 pUndoData);
2093 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc,
2094 true, bAsLink, bIncludedFiltered, bSkipEmpty);
2095 lcl_printValuesAndFormulasInRange(m_pDoc, aDestRange, "Dest sheet");
2098 if (bCut)
2099 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
2100 pUndoPaste, bTranspose, bAsLink, bSkipEmpty);
2102 else // multi range selection
2104 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
2105 aSrcMark.SelectOneTable(0);
2106 ScClipParam aClipParam;
2107 aClipParam.meDirection = eDirection;
2108 if (eDirection == ScClipParam::Column)
2110 aClipParam.maRanges.push_back(ScRange(1, 2, srcSheet, 2, 5, srcSheet)); // B3:C6
2111 aClipParam.maRanges.push_back(ScRange(4, 2, srcSheet, 6, 5, srcSheet)); // E3:G6
2112 aClipParam.maRanges.push_back(ScRange(8, 2, srcSheet, 8, 5, srcSheet)); // I3:I6
2114 else if (eDirection == ScClipParam::Row)
2116 aClipParam.maRanges.push_back(ScRange(1, 2, srcSheet, 6, 4, srcSheet)); // B3:G5
2117 aClipParam.maRanges.push_back(ScRange(1, 6, srcSheet, 6, 6, srcSheet)); // B7:G7
2118 aClipParam.maRanges.push_back(ScRange(1, 8, srcSheet, 6, 8, srcSheet)); // A9:G9
2120 CPPUNIT_ASSERT(aClipParam.isMultiRange());
2121 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
2123 // ScDocument::TransposeClip() and ScDocument::CopyMultiRangeFromClip() calls
2124 // analog to ScViewFunc::PasteFromClipToMultiRanges()
2125 if (bTranspose)
2127 printRange(m_pDoc, aClipParam.getWholeRange(), "Src range");
2128 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
2129 aClipDoc.TransposeClip(pTransClip.get(), aFlags, bAsLink, bIncludedFiltered);
2130 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcRows - 1, 1 + nSrcCols - 1 - 1,
2131 destSheet); //target col: D2:G6, target row: D2:H6
2132 aDestMark.SetMarkArea(aDestRange);
2133 printRange(&aClipDoc, ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
2134 "Base doc (&aClipDoc)");
2135 printRange(pTransClip.get(), ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
2136 "Transposed clipdoc (pTransClip.get())");
2137 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 1, destSheet), aDestMark, aFlags,
2138 pTransClip.get(), true, bAsLink && !bTranspose,
2139 bIncludedFiltered, bSkipEmpty);
2140 pTransClip.reset();
2141 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
2143 else
2145 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcCols - 1 - 1, 1 + nSrcRows - 1,
2146 destSheet); //target col: D2:I5, target row: D2:I6
2147 aDestMark.SetMarkArea(aDestRange);
2148 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 1, destSheet), aDestMark, aFlags, &aClipDoc,
2149 true, bAsLink && !bTranspose, bIncludedFiltered,
2150 bSkipEmpty);
2154 if (eCalcMode == RecalcAtEnd)
2155 m_pDoc->CalcFormulaTree();
2156 else if (eCalcMode == HardRecalcAtEnd)
2157 m_pDoc->CalcAll();
2160 void TestCopyPaste::testCopyPasteSpecial()
2162 executeCopyPasteSpecial(false, false, false, false, false, false);
2163 checkCopyPasteSpecial(false);
2166 void TestCopyPaste::testCopyPasteSpecialFiltered()
2168 executeCopyPasteSpecial(true, false, false, false, false, false);
2169 checkCopyPasteSpecialFiltered(false);
2172 void TestCopyPaste::testCopyPasteSpecialIncludeFiltered()
2174 // For bIncludeFiltered=true, the non-filtered outcome is expected
2175 executeCopyPasteSpecial(false, true, false, false, false, false);
2176 checkCopyPasteSpecial(false);
2179 void TestCopyPaste::testCopyPasteSpecialFilteredIncludeFiltered()
2181 // For bIncludeFiltered=true, the non-filtered outcome is expected
2182 executeCopyPasteSpecial(true, true, false, false, false, false);
2183 checkCopyPasteSpecial(false);
2186 // similar to TestCopyPaste::testCopyPasteTranspose(), but this test is more complex
2187 void TestCopyPaste::testCopyPasteSpecialTranspose()
2189 executeCopyPasteSpecial(false, false, false, true, false, false);
2190 checkCopyPasteSpecialTranspose(false);
2193 // tdf#107348
2194 void TestCopyPaste::testCopyPasteSpecialFilteredTranspose()
2196 executeCopyPasteSpecial(true, false, false, true, false, false);
2197 checkCopyPasteSpecialFilteredTranspose(false);
2200 // tdf#107348
2201 void TestCopyPaste::testCopyPasteSpecialTransposeIncludeFiltered()
2203 // For bIncludeFiltered=true, the non-filtered outcome is expected
2204 executeCopyPasteSpecial(true, true, false, true, false, false);
2205 checkCopyPasteSpecialTranspose(false);
2208 void TestCopyPaste::testCopyPasteSpecialMultiRangeCol()
2210 executeCopyPasteSpecial(false, false, false, false, true, false, false, ScClipParam::Column);
2211 checkCopyPasteSpecialMultiRangeCol(false);
2214 void TestCopyPaste::testCopyPasteSpecialMultiRangeColIncludeFiltered()
2216 // For bIncludeFiltered=true, the non-filtered outcome is expected
2217 executeCopyPasteSpecial(false, true, false, false, true, false, false, ScClipParam::Column);
2218 checkCopyPasteSpecialMultiRangeCol(false);
2221 // tdf#45958
2222 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFiltered()
2224 executeCopyPasteSpecial(true, false, false, false, true, false, false, ScClipParam::Column);
2225 checkCopyPasteSpecialMultiRangeColFiltered(false);
2228 // tdf#45958
2229 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered()
2231 // For bIncludeFiltered=true, the non-filtered outcome is expected
2232 executeCopyPasteSpecial(true, true, false, false, true, false, false, ScClipParam::Column);
2233 checkCopyPasteSpecialMultiRangeCol(false);
2236 void TestCopyPaste::testCopyPasteSpecialMultiRangeColTranspose()
2238 executeCopyPasteSpecial(false, false, false, true, true, false, false, ScClipParam::Column);
2239 checkCopyPasteSpecialMultiRangeColTranspose(false);
2242 // tdf#45958, tdf#107348
2243 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFilteredTranspose()
2245 executeCopyPasteSpecial(true, false, false, true, true, false, false, ScClipParam::Column);
2246 checkCopyPasteSpecialMultiRangeColFilteredTranspose(false);
2249 // tdf#45958, tdf#107348
2250 void TestCopyPaste::testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose()
2252 // For bIncludeFiltered=true, the non-filtered outcome is expected
2253 executeCopyPasteSpecial(true, true, false, true, true, false, false, ScClipParam::Column);
2254 checkCopyPasteSpecialMultiRangeColTranspose(false);
2257 void TestCopyPaste::testCopyPasteSpecialMultiRangeRow()
2259 executeCopyPasteSpecial(false, false, false, false, true, false, false, ScClipParam::Row);
2260 checkCopyPasteSpecialMultiRangeRow(false);
2263 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowIncludeFiltered()
2265 // For bIncludeFiltered=true, the non-filtered outcome is expected
2266 executeCopyPasteSpecial(false, true, false, false, true, false, false, ScClipParam::Row);
2267 checkCopyPasteSpecialMultiRangeRow(false);
2270 // tdf#45958
2271 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFiltered()
2273 executeCopyPasteSpecial(true, false, false, false, true, false, false, ScClipParam::Row);
2274 checkCopyPasteSpecialMultiRangeRowFiltered(false);
2277 // tdf#45958
2278 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered()
2280 // For bIncludeFiltered=true, the non-filtered outcome is expected
2281 executeCopyPasteSpecial(true, true, false, false, true, false, false, ScClipParam::Row);
2282 checkCopyPasteSpecialMultiRangeRow(false);
2285 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowTranspose()
2287 executeCopyPasteSpecial(false, false, false, true, true, false, false, ScClipParam::Row,
2288 HardRecalcAtEnd);
2289 checkCopyPasteSpecialMultiRangeRowTranspose(false);
2292 // tdf#45958, tdf#107348
2293 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFilteredTranspose()
2295 executeCopyPasteSpecial(true, false, false, true, true, false, false, ScClipParam::Row,
2296 HardRecalcAtEnd);
2297 checkCopyPasteSpecialMultiRangeRowFilteredTranspose(false);
2300 // tdf#45958, tdf#107348
2301 void TestCopyPaste::testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose()
2303 // For bIncludeFiltered=true, the non-filtered outcome is expected
2304 executeCopyPasteSpecial(true, true, false, true, true, false, false, ScClipParam::Row,
2305 HardRecalcAtEnd);
2306 checkCopyPasteSpecialMultiRangeRowTranspose(false);
2309 void TestCopyPaste::testCopyPasteSpecialSkipEmpty()
2311 executeCopyPasteSpecial(false, false, false, false, false, true);
2312 checkCopyPasteSpecial(true);
2315 void TestCopyPaste::testCopyPasteSpecialSkipEmptyFiltered()
2317 executeCopyPasteSpecial(true, false, false, false, false, true);
2318 checkCopyPasteSpecialFiltered(true);
2321 void TestCopyPaste::testCopyPasteSpecialSkipEmptyIncludeFiltered()
2323 // For bIncludeFiltered=true, the non-filtered outcome is expected
2324 executeCopyPasteSpecial(false, true, false, false, false, true);
2325 checkCopyPasteSpecial(true);
2328 void TestCopyPaste::testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered()
2330 // For bIncludeFiltered=true, the non-filtered outcome is expected
2331 executeCopyPasteSpecial(true, true, false, false, false, true);
2332 checkCopyPasteSpecial(true);
2335 // similar to TestCopyPaste::testCopyPasteTranspose(), but this test is more complex
2336 void TestCopyPaste::testCopyPasteSpecialSkipEmptyTranspose()
2338 executeCopyPasteSpecial(false, false, false, true, false, true);
2339 checkCopyPasteSpecialTranspose(true);
2342 // tdf#107348
2343 void TestCopyPaste::testCopyPasteSpecialSkipEmptyFilteredTranspose()
2345 executeCopyPasteSpecial(true, false, false, true, false, true);
2346 checkCopyPasteSpecialFilteredTranspose(true);
2349 // tdf#107348
2350 void TestCopyPaste::testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered()
2352 // For bIncludeFiltered=true, the non-filtered outcome is expected
2353 executeCopyPasteSpecial(true, true, false, true, false, true);
2354 checkCopyPasteSpecialTranspose(true);
2357 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeCol()
2359 executeCopyPasteSpecial(false, false, false, false, true, true, false, ScClipParam::Column);
2360 checkCopyPasteSpecialMultiRangeCol(true);
2363 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered()
2365 // For bIncludeFiltered=true, the non-filtered outcome is expected
2366 executeCopyPasteSpecial(false, true, false, false, true, true, false, ScClipParam::Column);
2367 checkCopyPasteSpecialMultiRangeCol(true);
2370 // tdf#45958
2371 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFiltered()
2373 executeCopyPasteSpecial(true, false, false, false, true, true, false, ScClipParam::Column);
2374 checkCopyPasteSpecialMultiRangeColFiltered(true);
2377 // tdf#45958
2378 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered()
2380 // For bIncludeFiltered=true, the non-filtered outcome is expected
2381 executeCopyPasteSpecial(true, true, false, false, true, true, false, ScClipParam::Column);
2382 checkCopyPasteSpecialMultiRangeCol(true);
2385 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColTranspose()
2387 executeCopyPasteSpecial(false, false, false, true, true, true, false, ScClipParam::Column);
2388 checkCopyPasteSpecialMultiRangeColTranspose(true);
2391 // tdf#45958, tdf#107348
2392 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose()
2394 // For bIncludeFiltered=true, the non-filtered outcome is expected
2395 executeCopyPasteSpecial(true, false, false, true, true, true, false, ScClipParam::Column);
2396 checkCopyPasteSpecialMultiRangeColFilteredTranspose(true);
2399 // tdf#45958, tdf#107348
2400 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose()
2402 // For bIncludeFiltered=true, the non-filtered outcome is expected
2403 executeCopyPasteSpecial(true, true, false, true, true, true, false, ScClipParam::Column);
2404 checkCopyPasteSpecialMultiRangeColTranspose(true);
2407 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRow()
2409 executeCopyPasteSpecial(false, false, false, false, true, true, false, ScClipParam::Row);
2410 checkCopyPasteSpecialMultiRangeRow(true);
2413 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered()
2415 // For bIncludeFiltered=true, the non-filtered outcome is expected
2416 executeCopyPasteSpecial(false, true, false, false, true, true, false, ScClipParam::Row);
2417 checkCopyPasteSpecialMultiRangeRow(true);
2420 // tdf#45958
2421 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered()
2423 executeCopyPasteSpecial(true, false, false, false, true, true, false, ScClipParam::Row);
2424 checkCopyPasteSpecialMultiRangeRowFiltered(true);
2427 // tdf#45958
2428 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered()
2430 // For bIncludeFiltered=true, the non-filtered outcome is expected
2431 executeCopyPasteSpecial(true, true, false, false, true, true, false, ScClipParam::Row);
2432 checkCopyPasteSpecialMultiRangeRow(true);
2435 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose()
2437 executeCopyPasteSpecial(false, false, false, true, true, true, false, ScClipParam::Row,
2438 HardRecalcAtEnd);
2439 checkCopyPasteSpecialMultiRangeRowTranspose(true);
2442 // tdf#45958, tdf#107348
2443 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose()
2445 executeCopyPasteSpecial(true, false, false, true, true, true, false, ScClipParam::Row,
2446 HardRecalcAtEnd);
2447 checkCopyPasteSpecialMultiRangeRowFilteredTranspose(true);
2450 // tdf#45958, tdf#107348
2451 void TestCopyPaste::testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose()
2453 // For bIncludeFiltered=true, the non-filtered outcome is expected
2454 executeCopyPasteSpecial(true, true, false, true, true, true, false, ScClipParam::Row,
2455 HardRecalcAtEnd);
2456 checkCopyPasteSpecialMultiRangeRowTranspose(true);
2459 void TestCopyPaste::testCutPasteSpecial()
2461 const SCTAB srcSheet = 0;
2462 const SCTAB destSheet = 1;
2463 std::unique_ptr<ScUndoCut> pUndoCut;
2464 std::unique_ptr<ScUndoPaste> pUndoPaste;
2466 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, false, false, false, pUndoCut,
2467 pUndoPaste, true);
2468 checkCopyPasteSpecial(false, true);
2470 pUndoPaste->Undo();
2471 pUndoCut->Undo();
2472 checkCopyPasteSpecialInitial(srcSheet);
2474 pUndoCut->Redo();
2475 pUndoPaste->Redo();
2476 checkCopyPasteSpecial(false, true);
2478 pUndoPaste->Undo();
2479 pUndoCut->Undo();
2480 checkCopyPasteSpecialInitial(srcSheet);
2482 pUndoPaste.reset();
2483 pUndoCut.reset();
2485 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2486 m_pDoc->DeleteTab(i - 1);
2489 void TestCopyPaste::testCutPasteSpecialTranspose()
2491 const SCTAB srcSheet = 0;
2492 const SCTAB destSheet = 1;
2493 std::unique_ptr<ScUndoCut> pUndoCut;
2494 std::unique_ptr<ScUndoPaste> pUndoPaste;
2496 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, true, false, false, pUndoCut,
2497 pUndoPaste, true);
2498 checkCopyPasteSpecialTranspose(false, true);
2500 pUndoPaste->Undo();
2501 pUndoCut->Undo();
2502 checkCopyPasteSpecialInitial(srcSheet);
2504 pUndoCut->Redo();
2505 pUndoPaste->Redo();
2506 checkCopyPasteSpecialTranspose(false, true);
2508 pUndoPaste->Undo();
2509 pUndoCut->Undo();
2510 checkCopyPasteSpecialInitial(srcSheet);
2512 pUndoPaste.reset();
2513 pUndoCut.reset();
2515 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2516 m_pDoc->DeleteTab(i - 1);
2519 void TestCopyPaste::testCutPasteSpecialSkipEmpty()
2521 const SCTAB srcSheet = 0;
2522 const SCTAB destSheet = 1;
2523 std::unique_ptr<ScUndoCut> pUndoCut;
2524 std::unique_ptr<ScUndoPaste> pUndoPaste;
2526 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, false, false, true, pUndoCut,
2527 pUndoPaste, true);
2528 checkCopyPasteSpecial(true, true);
2530 pUndoPaste->Undo();
2531 pUndoCut->Undo();
2532 checkCopyPasteSpecialInitial(srcSheet);
2534 pUndoCut->Redo();
2535 pUndoPaste->Redo();
2536 checkCopyPasteSpecial(true, true);
2538 pUndoPaste->Undo();
2539 pUndoCut->Undo();
2540 checkCopyPasteSpecialInitial(srcSheet);
2542 pUndoPaste.reset();
2543 pUndoCut.reset();
2545 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2546 m_pDoc->DeleteTab(i - 1);
2549 void TestCopyPaste::testCutPasteSpecialSkipEmptyTranspose()
2551 const SCTAB srcSheet = 0;
2552 const SCTAB destSheet = 1;
2553 std::unique_ptr<ScUndoCut> pUndoCut;
2554 std::unique_ptr<ScUndoPaste> pUndoPaste;
2556 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, true, false, true, pUndoCut,
2557 pUndoPaste, true);
2558 checkCopyPasteSpecialTranspose(true, true);
2560 pUndoPaste->Undo();
2561 pUndoCut->Undo();
2562 checkCopyPasteSpecialInitial(srcSheet);
2564 pUndoCut->Redo();
2565 pUndoPaste->Redo();
2566 checkCopyPasteSpecialTranspose(true, true);
2568 pUndoPaste->Undo();
2569 pUndoCut->Undo();
2570 checkCopyPasteSpecialInitial(srcSheet);
2572 pUndoPaste.reset();
2573 pUndoCut.reset();
2575 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2576 m_pDoc->DeleteTab(i - 1);
2579 // check initial source
2580 void TestCopyPaste::checkCopyPasteSpecialInitial(const SCTAB srcSheet)
2582 const EditTextObject* pEditObj;
2583 // col 1
2584 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 2, srcSheet));
2585 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 3, srcSheet));
2586 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1, 4, srcSheet));
2587 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(1, 5, srcSheet));
2588 // col 2, formulas
2589 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 2, srcSheet));
2590 CPPUNIT_ASSERT_EQUAL(OUString("=B3+10"), getFormula(2, 2, srcSheet));
2591 CPPUNIT_ASSERT_EQUAL(OUString("=B4+20"), getFormula(2, 3, srcSheet));
2592 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, srcSheet));
2593 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 4, srcSheet));
2594 CPPUNIT_ASSERT_EQUAL(OUString("=E5+30"), getFormula(2, 4, srcSheet));
2595 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(2, 5, srcSheet));
2596 CPPUNIT_ASSERT_EQUAL(OUString("=B4+40"), getFormula(2, 5, srcSheet));
2597 // col 3, strings
2598 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(3, 2, srcSheet));
2599 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(3, 3, srcSheet));
2600 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(3, 4, srcSheet));
2601 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(3, 5, srcSheet));
2602 // col 4, rich text
2603 pEditObj = m_pDoc->GetEditText(ScAddress(4, 2, srcSheet));
2604 CPPUNIT_ASSERT(pEditObj);
2605 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
2606 pEditObj = m_pDoc->GetEditText(ScAddress(4, 3, srcSheet));
2607 CPPUNIT_ASSERT(pEditObj);
2608 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
2609 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 4, srcSheet));
2610 pEditObj = m_pDoc->GetEditText(ScAddress(4, 5, srcSheet));
2611 CPPUNIT_ASSERT(pEditObj);
2612 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
2613 // col 5, formulas
2614 CPPUNIT_ASSERT_EQUAL(OUString("=B3+B5+60"), getFormula(5, 2, srcSheet));
2615 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(5, 2, srcSheet));
2616 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(5, 3, srcSheet));
2617 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(5, 4, srcSheet));
2618 CPPUNIT_ASSERT_EQUAL(OUString("=B3+B5+70"), getFormula(5, 5, srcSheet));
2619 CPPUNIT_ASSERT_EQUAL(74.0, m_pDoc->GetValue(5, 5, srcSheet));
2620 // col 6, formulas
2621 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(B3:B6;\"<4\")"), getFormula(6, 2, srcSheet));
2622 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(6, 2, srcSheet));
2623 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 3, srcSheet));
2624 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 4, srcSheet));
2625 CPPUNIT_ASSERT_EQUAL(OUString("=C$3+$B$5+80"), getFormula(6, 5, srcSheet));
2626 CPPUNIT_ASSERT_EQUAL(94.0, m_pDoc->GetValue(6, 5, srcSheet));
2628 // check patterns
2629 const SfxPoolItem* pItem = nullptr;
2630 m_pDoc->GetPattern(ScAddress(1, 2, 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, 3, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2634 CPPUNIT_ASSERT(pItem);
2635 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2636 m_pDoc->GetPattern(ScAddress(1, 4, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2637 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2638 m_pDoc->GetPattern(ScAddress(1, 5, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2639 CPPUNIT_ASSERT(!pItem);
2640 m_pDoc->GetPattern(ScAddress(1, 6, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2641 CPPUNIT_ASSERT(!pItem);
2642 m_pDoc->GetPattern(ScAddress(5, 4, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2643 CPPUNIT_ASSERT(pItem);
2644 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2646 // check border, left and right borders were transformed to top and bottom borders
2647 pItem = m_pDoc->GetAttr(ScAddress(2, 2, srcSheet), ATTR_BORDER);
2648 CPPUNIT_ASSERT(pItem);
2649 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2650 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2651 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2652 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2653 pItem = m_pDoc->GetAttr(ScAddress(2, 3, srcSheet), ATTR_BORDER);
2654 CPPUNIT_ASSERT(pItem);
2655 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2656 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2657 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2658 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2659 pItem = m_pDoc->GetAttr(ScAddress(2, 4, srcSheet), ATTR_BORDER);
2660 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2661 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2662 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2663 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2664 pItem = m_pDoc->GetAttr(ScAddress(2, 5, srcSheet), ATTR_BORDER);
2665 CPPUNIT_ASSERT(pItem);
2666 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2667 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2668 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2669 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2670 pItem = m_pDoc->GetAttr(ScAddress(2, 6, srcSheet), ATTR_BORDER);
2671 CPPUNIT_ASSERT(pItem);
2672 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2673 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2674 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2675 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2677 // check notes after transposed copy/paste
2678 // check presence of notes
2679 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 2, srcSheet));
2680 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 2, srcSheet));
2681 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 2, srcSheet));
2682 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, srcSheet));
2683 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 2, srcSheet));
2684 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, srcSheet));
2685 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, srcSheet));
2686 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 3, srcSheet));
2687 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, srcSheet));
2688 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, srcSheet));
2689 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, srcSheet));
2690 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 3, srcSheet));
2691 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, srcSheet));
2692 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, srcSheet));
2693 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 4, srcSheet));
2694 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 4, srcSheet));
2695 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 4, srcSheet));
2696 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, srcSheet));
2697 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, srcSheet));
2698 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, srcSheet));
2699 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, srcSheet));
2700 CPPUNIT_ASSERT(!m_pDoc->HasNote(1, 5, srcSheet));
2701 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 5, srcSheet));
2702 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 5, srcSheet));
2703 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 5, srcSheet));
2704 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 5, srcSheet));
2705 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 5, srcSheet));
2706 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, srcSheet));
2707 CPPUNIT_ASSERT(!m_pDoc->HasNote(1, 6, srcSheet));
2708 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, srcSheet));
2709 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 6, srcSheet));
2710 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, srcSheet));
2711 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, srcSheet));
2712 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, srcSheet));
2713 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 6, srcSheet));
2715 // check values of notes
2716 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(1, 2, srcSheet));
2717 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(1, 3, srcSheet));
2718 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(1, 4, srcSheet));
2719 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(2, 2, srcSheet));
2720 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(2, 4, srcSheet));
2721 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(3, 3, srcSheet));
2722 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(3, 4, srcSheet));
2723 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(4, 2, srcSheet));
2724 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(4, 3, srcSheet));
2725 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(4, 4, srcSheet));
2726 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 4, srcSheet));
2727 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(5, 5, srcSheet));
2728 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(6, 3, srcSheet));
2729 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(6, 5, srcSheet));
2731 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
2732 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
2733 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
2734 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
2735 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
2736 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
2737 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
2738 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
2739 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
2740 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
2742 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
2743 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
2744 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
2745 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
2746 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
2747 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
2748 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
2749 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
2750 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
2751 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
2753 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
2754 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
2755 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
2756 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
2757 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
2758 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
2759 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
2760 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
2761 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
2762 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
2764 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
2765 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
2766 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
2767 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
2768 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
2769 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
2770 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
2771 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
2772 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
2773 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
2775 // Existing references to the destination range must not change
2776 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
2777 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
2778 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
2779 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
2780 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
2781 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
2782 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
2783 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
2784 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
2785 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
2786 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
2787 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
2788 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
2789 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
2790 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
2791 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
2792 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
2793 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
2794 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
2795 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
2796 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
2797 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
2798 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
2799 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
2800 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
2801 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
2802 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
2803 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
2804 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
2805 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
2806 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
2807 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
2808 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
2809 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
2810 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
2811 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
2812 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
2813 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
2814 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
2815 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
2816 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
2817 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
2818 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
2819 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
2820 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
2821 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
2822 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
2823 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
2824 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
2827 // Base check, nothing filtered, nothing transposed
2828 void TestCopyPaste::checkCopyPasteSpecial(bool bSkipEmpty, bool bCut)
2830 const SCTAB srcSheet = 0;
2831 const SCTAB destSheet = 1;
2834 | D | E | F | G | H | I |
2836 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
2837 3 | 2 B*| =D3+20 b | b *| R2 *| | *|
2838 4 | 3 B*| =G4+30 b*| c *| 5 *| B*| |
2839 5 | 4 | =D3+40 b*| d *| R4 *| =D2+D4+70 *| =E$3+$B$5+80 *|
2841 * means note attached
2842 B means background
2843 b means border
2846 const EditTextObject* pEditObj;
2847 // col 2
2848 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
2849 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
2850 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
2851 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
2852 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
2853 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
2854 // col 3, numbers
2855 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
2856 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
2857 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
2858 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
2859 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 4, destSheet));
2860 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
2861 // col 4, formulas
2862 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
2863 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
2864 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(4, 1, destSheet));
2865 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), getFormula(4, 2, destSheet));
2866 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
2867 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 3, destSheet));
2868 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), getFormula(4, 3, destSheet));
2869 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(4, 4, destSheet));
2870 CPPUNIT_ASSERT_EQUAL(OUString("=D3+40"), getFormula(4, 4, destSheet));
2871 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
2872 // col 5, strings
2873 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
2874 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
2875 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
2876 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(5, 2, destSheet));
2877 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 3, destSheet));
2878 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(5, 4, destSheet));
2879 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
2880 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 5, destSheet));
2881 // col 6, rich text
2882 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
2883 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
2884 CPPUNIT_ASSERT(pEditObj == nullptr);
2885 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
2886 CPPUNIT_ASSERT(pEditObj);
2887 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
2888 pEditObj = m_pDoc->GetEditText(ScAddress(6, 2, destSheet));
2889 CPPUNIT_ASSERT(pEditObj);
2890 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
2891 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 3, destSheet));
2892 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
2893 CPPUNIT_ASSERT(pEditObj);
2894 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
2895 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
2896 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
2897 CPPUNIT_ASSERT(pEditObj == nullptr);
2898 // col 7, formulas
2899 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
2900 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
2901 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), getFormula(7, 1, destSheet));
2902 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(7, 1, destSheet));
2903 if (!bSkipEmpty)
2905 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
2906 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
2908 else
2910 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
2911 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
2913 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+70"), getFormula(7, 4, destSheet));
2914 CPPUNIT_ASSERT_EQUAL(74.0, m_pDoc->GetValue(7, 4, destSheet));
2915 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
2916 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
2917 // col 8, formulas
2918 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
2919 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
2920 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), getFormula(8, 1, destSheet));
2921 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
2922 if (!bSkipEmpty)
2924 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
2925 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 3, destSheet));
2927 else
2929 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
2930 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
2932 double fValue = m_pDoc->GetValue(8, 4, destSheet);
2933 OUString aStr = m_pDoc->GetFormula(8, 4, destSheet);
2934 if (!bCut)
2936 CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), aStr);
2937 CPPUNIT_ASSERT_EQUAL(1102.0, fValue);
2939 else
2941 CPPUNIT_ASSERT_EQUAL(OUString("=E$2+$D$4+80"), aStr);
2942 CPPUNIT_ASSERT_EQUAL(94.0, fValue);
2944 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
2945 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
2946 // col 9, numbers
2947 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
2948 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
2949 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
2950 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
2951 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
2952 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
2954 // check patterns
2955 const SfxPoolItem* pItem = nullptr;
2956 m_pDoc->GetPattern(ScAddress(3, 1, 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, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2960 CPPUNIT_ASSERT(pItem);
2961 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2962 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2963 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2964 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2965 CPPUNIT_ASSERT(!pItem);
2966 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2967 CPPUNIT_ASSERT(!pItem);
2968 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2969 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
2970 if (!bSkipEmpty)
2971 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2973 // check border, left and right borders were transformed to top and bottom borders
2974 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
2975 CPPUNIT_ASSERT(pItem);
2976 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2977 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2978 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2979 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2980 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
2981 CPPUNIT_ASSERT(pItem);
2982 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2983 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2984 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2985 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2986 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
2987 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2988 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2989 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2990 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2991 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
2992 CPPUNIT_ASSERT(pItem);
2993 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2994 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2995 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2996 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2997 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
2998 CPPUNIT_ASSERT(pItem);
2999 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3000 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3001 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3002 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3004 // check notes after transposed copy/paste
3005 // check presence of notes
3006 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
3007 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
3008 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
3009 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
3010 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
3011 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
3012 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
3013 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
3014 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
3015 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
3016 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
3017 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
3018 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
3019 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
3020 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
3021 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
3022 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
3023 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
3024 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
3025 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
3026 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
3027 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
3028 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(8, 2, destSheet));
3029 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
3030 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
3031 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
3032 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
3033 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
3034 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
3035 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 3, destSheet));
3036 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
3037 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
3038 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
3039 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
3040 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
3041 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
3042 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
3043 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 4, destSheet));
3044 CPPUNIT_ASSERT(m_pDoc->HasNote(8, 4, destSheet));
3045 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
3046 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
3047 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
3048 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
3049 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
3050 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
3051 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
3052 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
3053 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
3055 // check values of notes
3056 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
3057 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
3058 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
3059 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
3060 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
3061 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(5, 2, destSheet));
3062 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 3, destSheet));
3063 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
3064 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(6, 2, destSheet));
3065 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 3, destSheet));
3066 if (!bSkipEmpty)
3067 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 3, destSheet));
3068 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(7, 4, destSheet));
3069 if (!bSkipEmpty)
3070 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(8, 2, destSheet));
3071 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(8, 4, destSheet));
3073 // Existing references to the destination range must not change
3074 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
3075 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
3076 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
3077 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
3078 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
3079 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
3080 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
3081 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
3082 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
3083 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
3084 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
3085 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
3086 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
3087 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
3088 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
3089 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
3090 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
3091 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
3092 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
3093 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
3094 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
3095 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
3096 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
3097 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
3098 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
3099 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
3100 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
3101 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
3102 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
3103 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
3104 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
3105 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
3106 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
3107 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
3108 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
3109 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
3110 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
3111 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
3112 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
3113 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
3114 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
3115 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
3116 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
3117 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
3118 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
3119 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
3120 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
3121 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
3122 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
3124 // row 14 on src sheet, refs to copied/cut range
3125 if (!bCut)
3127 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
3128 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
3129 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
3130 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
3131 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
3132 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
3133 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
3134 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
3135 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
3136 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
3138 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3139 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3140 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3141 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3142 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3143 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3144 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3145 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3146 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3147 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
3149 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
3150 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
3151 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
3152 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
3153 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
3154 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
3155 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
3156 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
3157 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
3158 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), 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"), getFormula(1, 16, srcSheet));
3177 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$E$4"), getFormula(2, 16, srcSheet));
3178 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$E4"), getFormula(3, 16, srcSheet));
3179 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E$4"), getFormula(4, 16, srcSheet));
3180 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.E4:E4)"), getFormula(5, 16, srcSheet));
3181 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$E$4:$E$4)"), getFormula(6, 16, srcSheet));
3182 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$E4:$E4)"), getFormula(7, 16, srcSheet));
3183 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.E$4:E$4)"), getFormula(8, 16, srcSheet));
3184 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$D$2:$D$5)"), getFormula(9, 16, srcSheet));
3185 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
3187 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3188 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3189 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3190 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3191 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3192 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3193 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3194 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3195 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3196 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 16, srcSheet));
3198 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
3199 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
3200 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
3201 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
3202 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
3203 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
3204 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
3205 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
3206 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
3207 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
3209 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3210 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3211 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3212 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(4, 17, srcSheet));
3213 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3214 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3215 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3216 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3217 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3218 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 17, srcSheet));
3222 void TestCopyPaste::checkCopyPasteSpecialFiltered(bool bSkipEmpty)
3224 const SCTAB srcSheet = 0;
3225 const SCTAB destSheet = 1;
3228 | D | E | F | G | H | I |
3230 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
3231 3 | 3 B*| =G3+30 b*| c *| 5 *| B*| |
3232 4 | 4 | =D2+40 b*| d *| R4 *| =D1+D3+70 *| =E$3+$B$5+80 *|
3233 5 | 1 B*| =D5+10 *| a | R1 *| =D5+D7+60 | =SUMIF(D5:D8;"<4") | <- repeated row
3235 * means note attached
3236 B means background
3237 b means border
3240 const EditTextObject* pEditObj;
3242 // col 2
3243 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3244 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3245 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3246 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3247 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3248 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3249 // col 3, numbers
3250 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3251 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
3252 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
3253 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 3, destSheet));
3254 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 4, destSheet)); // repeated row 1
3255 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
3256 // col 4, formulas
3257 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3258 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(4, 0, destSheet));
3259 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
3260 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(4, 1, destSheet));
3261 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), getFormula(4, 2, destSheet));
3262 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 2, destSheet));
3263 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), getFormula(4, 3, destSheet));
3264 CPPUNIT_ASSERT_EQUAL(41.0, m_pDoc->GetValue(4, 3, destSheet));
3265 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 4, destSheet)); // repeated row 1
3266 CPPUNIT_ASSERT_EQUAL(OUString("=D5+10"), getFormula(4, 4, destSheet));
3267 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 4, destSheet));
3268 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3269 // col 5, strings
3270 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3271 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
3272 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 2, destSheet));
3273 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(5, 3, destSheet));
3274 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 4, destSheet)); // repeated row 1
3275 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
3276 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(4, 5, destSheet));
3277 // col 6, rich text
3278 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3279 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
3280 CPPUNIT_ASSERT(pEditObj == nullptr);
3281 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
3282 CPPUNIT_ASSERT(pEditObj);
3283 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
3284 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 2, destSheet));
3285 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
3286 CPPUNIT_ASSERT(pEditObj);
3287 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
3288 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet)); // repeated row 1
3289 CPPUNIT_ASSERT(pEditObj);
3290 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
3291 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
3292 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
3293 CPPUNIT_ASSERT(pEditObj == nullptr);
3294 // col 7, formulas
3295 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3296 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
3297 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), getFormula(7, 1, destSheet));
3298 // formula is not adjusted due to filter row
3299 CPPUNIT_ASSERT_EQUAL(65.0, m_pDoc->GetValue(7, 1, destSheet));
3300 if (!bSkipEmpty)
3301 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
3302 else
3303 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3304 CPPUNIT_ASSERT_EQUAL(OUString("=D1+D3+70"), getFormula(7, 3, destSheet));
3305 CPPUNIT_ASSERT_EQUAL(1073.0, m_pDoc->GetValue(7, 3, destSheet));
3306 CPPUNIT_ASSERT_EQUAL(OUString("=D5+D7+60"), getFormula(7, 4, destSheet)); // repeated row 1
3307 // formula is not adjusted due to filter row
3308 CPPUNIT_ASSERT_EQUAL(1061.0, m_pDoc->GetValue(7, 4, destSheet));
3309 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3310 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3311 // col 8, formulas
3312 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
3313 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
3314 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), getFormula(8, 1, destSheet));
3315 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(8, 1, destSheet));
3316 if (!bSkipEmpty)
3317 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
3318 else
3319 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
3320 CPPUNIT_ASSERT_EQUAL(1115.0, m_pDoc->GetValue(8, 3, destSheet));
3321 CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), getFormula(8, 3, destSheet));
3322 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D5:D8;\"<4\")"), getFormula(8, 4, destSheet));
3323 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(8, 4, destSheet));
3324 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
3325 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
3326 // col 9, numbers
3327 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
3328 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
3329 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
3330 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
3331 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
3332 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
3334 // check patterns
3335 const SfxPoolItem* pItem = nullptr;
3336 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3337 CPPUNIT_ASSERT(pItem);
3338 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3339 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3340 CPPUNIT_ASSERT(pItem);
3341 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3342 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3343 CPPUNIT_ASSERT(!pItem);
3344 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3345 CPPUNIT_ASSERT(pItem);
3346 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3347 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3348 CPPUNIT_ASSERT(!pItem);
3349 m_pDoc->GetPattern(ScAddress(7, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3350 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3351 if (!bSkipEmpty)
3352 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3354 // check border, left and right borders were transformed to top and bottom borders
3355 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
3356 CPPUNIT_ASSERT(pItem);
3357 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3358 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3359 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3360 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3361 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3362 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3363 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3364 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3365 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
3366 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
3367 CPPUNIT_ASSERT(pItem);
3368 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3369 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3370 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3371 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
3372 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
3373 CPPUNIT_ASSERT(pItem);
3374 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3375 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3376 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3377 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3379 // check notes after transposed copy/paste
3380 // check presence of notes
3381 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
3382 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
3383 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
3384 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
3385 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
3386 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
3387 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
3388 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
3389 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
3390 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
3391 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
3392 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
3393 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
3394 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
3395 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
3396 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
3397 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
3398 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
3399 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
3400 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
3401 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
3402 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
3403 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
3404 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
3405 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
3406 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
3407 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
3408 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
3409 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
3410 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 3, destSheet));
3411 CPPUNIT_ASSERT(m_pDoc->HasNote(8, 3, destSheet));
3412 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
3413 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
3414 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 4, destSheet));
3415 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
3416 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
3417 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
3418 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
3419 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
3420 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
3421 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
3422 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
3423 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
3424 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
3425 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
3426 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
3427 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
3428 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
3430 // check values of notes
3431 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
3432 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
3433 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
3434 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
3435 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 2, destSheet));
3436 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
3437 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 2, destSheet));
3438 if (!bSkipEmpty)
3439 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 2, destSheet));
3440 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(7, 3, destSheet));
3441 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(8, 3, destSheet));
3443 m_pDoc->DeleteTab(destSheet);
3444 m_pDoc->DeleteTab(srcSheet);
3447 void TestCopyPaste::checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut)
3449 const SCTAB srcSheet = 0;
3450 const SCTAB destSheet = 1;
3453 | D | E | F | G |
3455 2 | 1 B*| 2 B*| 3 B*| 4 |
3456 3 | =D2+10 *| =E2+20 b | =F5+30 b*| =E2+40 b*|
3457 4 | a | b *| c *| d *|
3458 5 | R1 *| R2 *| 5 *| R4 *|
3459 6 | =D2+F2+60 | | B*| =D2+F2+70 *|
3460 7 | =SUMIF(D2:G2;"<4") | *| | =C$3+$B$5+80 *|
3462 * means note attached
3463 B means background
3464 b means border
3467 //check cell content after transposed copy/paste of filtered data
3468 // Note: column F is a repetition of srcSheet.Column A
3469 // Col C and G are checked to be empty
3470 const EditTextObject* pEditObj;
3471 // row 0
3472 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3473 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3474 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3475 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3476 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3477 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3478 // row 1, numbers
3479 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3480 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
3481 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 2.0, m_pDoc->GetValue(4, 1, destSheet));
3482 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 3.0, m_pDoc->GetValue(5, 1, destSheet));
3483 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2", 4.0, m_pDoc->GetValue(6, 1, destSheet));
3484 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
3485 // row 2, formulas
3486 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3487 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
3488 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"), getFormula(3, 2, destSheet));
3489 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
3490 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E2+20"), getFormula(4, 2, destSheet));
3491 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 22.0, m_pDoc->GetValue(4, 2, destSheet));
3492 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=F5+30"), getFormula(5, 2, destSheet));
3493 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 35.0, m_pDoc->GetValue(5, 2, destSheet));
3494 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3", OUString("=E2+40"), getFormula(6, 2, destSheet));
3495 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3", 42.0, m_pDoc->GetValue(6, 2, destSheet));
3496 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3497 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
3498 // row 3, strings
3499 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3500 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
3501 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
3502 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("b"), m_pDoc->GetString(4, 3, destSheet));
3503 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("c"), m_pDoc->GetString(5, 3, destSheet));
3504 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("d"), m_pDoc->GetString(6, 3, destSheet));
3505 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
3506 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
3507 // row 4, rich text
3508 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3509 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
3510 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
3511 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
3512 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
3513 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
3514 pEditObj->GetText(0));
3515 pEditObj = m_pDoc->GetEditText(ScAddress(4, 4, destSheet));
3516 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in E5.", pEditObj);
3517 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong E5.", OUString("R2"), pEditObj->GetText(0));
3518 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F5", 5.0, m_pDoc->GetValue(5, 4, destSheet));
3519 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
3520 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in G5.", pEditObj);
3521 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong G5.", OUString("R4"), pEditObj->GetText(0));
3522 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
3523 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
3524 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
3525 // row 5, formulas
3526 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3527 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
3528 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
3529 getFormula(3, 5, destSheet));
3530 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 64.0, m_pDoc->GetValue(3, 5, destSheet));
3531 if (!bSkipEmpty)
3533 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
3534 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
3536 else
3538 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3539 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
3541 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6", OUString("=D2+F2+70"),
3542 getFormula(6, 5, destSheet));
3543 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6", 74.0, m_pDoc->GetValue(6, 5, destSheet));
3544 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3545 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3546 // row 6, formulas
3547 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
3548 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
3549 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
3550 getFormula(3, 6, destSheet));
3551 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 6.0, m_pDoc->GetValue(3, 6, destSheet));
3552 if (!bSkipEmpty)
3554 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
3555 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 6, destSheet));
3557 else
3559 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
3560 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
3562 double fValue = m_pDoc->GetValue(6, 6, destSheet); // G7
3563 OUString aStr = m_pDoc->GetFormula(6, 6, destSheet); // G7
3564 if (!bCut)
3566 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", OUString("=C$3+$B$5+80"), aStr);
3567 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", 2080.0, fValue);
3569 else
3571 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$F$2+80"), aStr);
3572 CPPUNIT_ASSERT_EQUAL(94.0, fValue);
3574 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
3575 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
3576 // row 7
3577 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
3578 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
3579 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
3580 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
3581 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
3582 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
3584 // check patterns
3585 const SfxPoolItem* pItem = nullptr;
3586 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3587 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
3588 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
3589 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3590 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3591 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
3592 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has blue background", COL_BLUE,
3593 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3594 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3595 CPPUNIT_ASSERT_MESSAGE("F2 has a pattern", pItem);
3596 CPPUNIT_ASSERT_EQUAL_MESSAGE("F2 has a pattern", COL_BLUE,
3597 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3598 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3599 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
3600 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3601 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
3602 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3603 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3604 if (!bSkipEmpty)
3605 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3607 // check border, left and right borders were transformed to top and bottom borders
3608 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
3609 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
3610 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
3611 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3612 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
3613 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3614 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
3615 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3616 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
3617 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3619 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
3620 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3621 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3623 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3624 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3625 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3627 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
3628 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3629 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
3630 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3631 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
3632 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3633 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
3634 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
3635 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3636 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
3637 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3638 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
3639 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3640 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
3641 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3642 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
3643 CPPUNIT_ASSERT_MESSAGE("G3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3644 CPPUNIT_ASSERT_MESSAGE("G3 has bottom border",
3645 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3646 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
3647 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3648 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
3649 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3650 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
3651 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
3652 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
3653 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3654 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
3655 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3656 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
3657 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3658 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
3659 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3661 // check notes after transposed copy/paste
3662 // check presence of notes
3663 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
3664 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
3665 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
3666 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
3667 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
3668 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
3669 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
3670 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
3671 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
3672 CPPUNIT_ASSERT_MESSAGE("F2: a note", m_pDoc->HasNote(5, 1, destSheet));
3673 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
3674 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
3675 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
3676 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
3677 CPPUNIT_ASSERT_MESSAGE("E3: no note", !m_pDoc->HasNote(4, 2, destSheet));
3678 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
3679 CPPUNIT_ASSERT_MESSAGE("G3: a note", m_pDoc->HasNote(6, 2, destSheet));
3680 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
3681 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
3682 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
3683 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
3684 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
3685 CPPUNIT_ASSERT_MESSAGE("G4: a note", m_pDoc->HasNote(6, 3, destSheet));
3686 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
3687 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
3688 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
3689 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
3690 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
3691 CPPUNIT_ASSERT_MESSAGE("G5: a note", m_pDoc->HasNote(6, 4, destSheet));
3692 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
3693 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
3694 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
3695 CPPUNIT_ASSERT_MESSAGE("E6: no note", !m_pDoc->HasNote(4, 5, destSheet));
3696 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 5, destSheet));
3697 CPPUNIT_ASSERT_MESSAGE("G6: a note", m_pDoc->HasNote(6, 5, destSheet));
3698 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
3699 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
3700 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
3701 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 6, destSheet));
3702 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
3703 CPPUNIT_ASSERT_MESSAGE("G7: a note", m_pDoc->HasNote(6, 6, destSheet));
3704 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
3705 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
3706 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
3707 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
3708 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
3709 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
3710 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
3712 // check values of notes
3713 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
3714 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A2"), getNote(4, 1, destSheet));
3715 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F2", OUString("Note A3"), getNote(5, 1, destSheet));
3716 // G2 has no note
3717 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
3718 // E3 has no note
3719 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B3"), getNote(5, 2, destSheet));
3720 // D4 has no note
3721 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C2"), getNote(4, 3, destSheet));
3722 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C3"), getNote(5, 3, destSheet));
3723 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
3724 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D2"), getNote(4, 4, destSheet));
3725 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D3"), getNote(5, 4, destSheet));
3726 if (!bSkipEmpty)
3727 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 5, destSheet));
3728 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G6", OUString("Note E4"), getNote(6, 5, destSheet));
3729 if (!bSkipEmpty)
3730 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString("Note F2"), getNote(4, 6, destSheet));
3731 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G7", OUString("Note F4"), getNote(6, 6, destSheet));
3733 // row 14 on src sheet, refs to copied/cut range
3734 if (!bCut)
3736 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
3737 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
3738 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
3739 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
3740 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
3741 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
3742 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
3743 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
3744 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
3745 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
3747 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3748 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3749 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3750 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3751 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3752 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3753 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3754 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3755 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3756 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
3758 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
3759 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
3760 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
3761 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
3762 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
3763 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
3764 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
3765 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
3766 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
3767 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
3769 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3770 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3771 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3772 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
3773 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3774 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3775 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3776 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3777 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3778 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
3780 // Existing references to the destination range must not change
3781 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
3782 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
3783 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
3784 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
3785 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
3786 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
3787 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
3788 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
3789 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
3790 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
3791 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
3792 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
3793 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
3794 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
3795 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
3796 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
3797 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
3798 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
3799 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
3800 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
3801 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
3802 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
3803 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
3804 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
3805 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
3806 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
3807 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
3808 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
3809 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
3810 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
3811 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
3812 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
3813 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
3814 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
3815 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
3816 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
3817 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
3818 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
3819 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
3820 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
3821 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
3822 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
3823 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
3824 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
3825 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
3826 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
3827 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
3828 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
3829 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
3831 m_pDoc->DeleteTab(destSheet);
3832 m_pDoc->DeleteTab(srcSheet);
3834 else
3836 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(1, 16, srcSheet));
3837 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$F$3"), getFormula(2, 16, srcSheet));
3838 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$F3"), getFormula(3, 16, srcSheet));
3839 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F$3"), getFormula(4, 16, srcSheet));
3840 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.F3:F3)"), getFormula(5, 16, srcSheet));
3841 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$F$3:$F$3)"), getFormula(6, 16, srcSheet));
3842 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$F3:$F3)"), getFormula(7, 16, srcSheet));
3843 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.F$3:F$3)"), getFormula(8, 16, srcSheet));
3844 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$D$2:$G$2)"), getFormula(9, 16, srcSheet));
3845 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
3847 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3848 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3849 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3850 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3851 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3852 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3853 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3854 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3855 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3856 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 16, srcSheet));
3858 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
3859 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
3860 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
3861 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
3862 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
3863 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
3864 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
3865 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
3866 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
3867 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
3869 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3870 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3871 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3872 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(4, 17, srcSheet));
3873 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3874 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3875 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3876 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3877 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3878 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 17, srcSheet));
3880 // Existing references to the destination range must not change
3881 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
3882 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
3883 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
3884 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
3885 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
3886 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
3887 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
3888 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
3889 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
3890 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
3891 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
3892 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
3893 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
3894 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
3895 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
3896 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
3897 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
3898 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
3899 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
3900 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
3901 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
3902 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
3903 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
3904 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
3905 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
3906 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
3907 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
3908 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
3909 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
3910 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
3911 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
3912 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
3913 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
3914 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
3915 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
3916 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
3917 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
3918 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
3919 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
3920 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
3921 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
3922 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
3923 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
3924 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
3925 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
3926 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
3927 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
3928 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
3929 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
3933 void TestCopyPaste::checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty)
3935 const SCTAB srcSheet = 0;
3936 const SCTAB destSheet = 1;
3939 ┌--- filtered src row 2 ┌--- repeated row
3942 | D | E | F | G |
3944 2 | 1 B*| 3 B*| 4 | 1 B*|
3945 3 | =D2+10 *| =E5+30 b*| =D2+40 b*| =G2+10 *|
3946 4 | a | c *| d *| a |
3947 5 | R1 *| 5 *| R4 *| R1 *|
3948 6 | =D2+F2+60 | B*| =C2+E2+70 *| =G2+I2+60 |
3949 7 | =SUMIF(D2:G2;"<4") | | =B$3+$B$5+80 *| =SUMIF(G2:J2;"<4") |
3951 * means note attached
3954 //check cell content after transposed copy/paste of filtered data
3955 // Note: column F is a repetition of srcSheet.Column A
3956 // Col C and G are checked to be empty
3957 const EditTextObject* pEditObj;
3958 // row 0
3959 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3960 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3961 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3962 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3963 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3964 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3965 // row 1, numbers
3966 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3967 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 1, destSheet));
3968 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
3969 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 3.0, m_pDoc->GetValue(4, 1, destSheet));
3970 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 4.0, m_pDoc->GetValue(5, 1, destSheet));
3971 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2 (repetition of D2)", 1.0,
3972 m_pDoc->GetValue(6, 1, destSheet));
3973 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
3974 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 1, destSheet));
3975 // row 2, formulas
3976 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3977 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
3978 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
3979 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"), getFormula(3, 2, destSheet));
3980 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E5+30"), getFormula(4, 2, destSheet));
3981 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 35.0, m_pDoc->GetValue(4, 2, destSheet));
3982 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=D2+40"), getFormula(5, 2, destSheet));
3983 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 41.0, m_pDoc->GetValue(5, 2, destSheet));
3984 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 11.0, m_pDoc->GetValue(6, 2, destSheet));
3985 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3 (repetition of D3)", OUString("=G2+10"),
3986 getFormula(6, 2, destSheet));
3987 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3988 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
3989 // row 3, strings
3990 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3991 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
3992 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
3993 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("c"), m_pDoc->GetString(4, 3, destSheet));
3994 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("d"), m_pDoc->GetString(5, 3, destSheet));
3995 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4 (repetition of D4)", OUString("a"),
3996 m_pDoc->GetString(6, 3, destSheet));
3997 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
3998 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
3999 // row 4, rich text
4000 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4001 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
4002 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
4003 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
4004 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
4005 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
4006 pEditObj->GetText(0));
4007 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E5", 5.0, m_pDoc->GetValue(4, 4, destSheet));
4008 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4009 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in F5.", pEditObj);
4010 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong F5.", OUString("R4"), pEditObj->GetText(0));
4011 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
4012 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in G5. (repetition of D5)", pEditObj);
4013 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong G5. (repetition of D5)", OUString("R1"),
4014 pEditObj->GetText(0));
4015 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
4016 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
4017 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
4018 // row 5, formulas
4019 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4020 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
4021 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
4022 getFormula(3, 5, destSheet));
4023 // formulas over filtered rows are not adjusted
4024 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 65.0,
4025 m_pDoc->GetValue(ScAddress(3, 5, destSheet)));
4026 if (!bSkipEmpty)
4027 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
4028 else
4029 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
4030 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", OUString("=C2+E2+70"),
4031 getFormula(5, 5, destSheet));
4032 // F6, formulas over filtered rows are not adjusted
4033 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", 1073.0,
4034 m_pDoc->GetValue(ScAddress(5, 5, destSheet)));
4035 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6 (repetition of D6)", OUString("=G2+I2+60"),
4036 getFormula(6, 5, destSheet));
4037 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6 (repetition of D6)", 1061.0,
4038 m_pDoc->GetValue(6, 5, destSheet));
4039 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
4040 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
4041 // row 6, formulas
4042 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
4043 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
4044 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
4045 getFormula(3, 6, destSheet));
4046 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 5.0, m_pDoc->GetValue(3, 6, destSheet));
4047 if (!bSkipEmpty)
4048 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
4049 else
4050 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
4051 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F7", OUString("=B$3+$B$5+80"),
4052 getFormula(5, 6, destSheet));
4053 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", 2080.0, m_pDoc->GetValue(5, 6, destSheet));
4054 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7 (repetition of D7)",
4055 OUString("=SUMIF(G2:J2;\"<4\")"), getFormula(6, 6, destSheet));
4056 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7 (repetition of D7)", 1061.0,
4057 m_pDoc->GetValue(6, 5, destSheet));
4058 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
4059 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
4061 // row
4062 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
4063 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
4064 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
4065 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
4066 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
4067 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
4069 // check patterns
4071 const SfxPoolItem* pItem = nullptr;
4072 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4073 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
4074 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
4075 static_cast<const SvxBrushItem*>(pItem)->GetColor());
4076 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4077 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
4078 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4079 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4080 CPPUNIT_ASSERT_MESSAGE("F2 has no pattern", !pItem);
4081 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4082 CPPUNIT_ASSERT_MESSAGE("G2 has a pattern", pItem);
4083 CPPUNIT_ASSERT_EQUAL_MESSAGE("G2 has a pattern", COL_BLUE,
4084 static_cast<const SvxBrushItem*>(pItem)->GetColor());
4085 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4086 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
4087 m_pDoc->GetPattern(ScAddress(4, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4088 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4089 if (!bSkipEmpty)
4090 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4092 // check border, left and right borders were transformed to top and bottom borders
4093 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
4094 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
4095 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
4096 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
4097 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
4098 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4099 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
4100 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4101 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
4102 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4103 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4104 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
4105 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
4106 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
4107 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4108 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
4109 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4110 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
4111 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4112 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
4113 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
4114 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
4115 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
4116 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4117 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
4118 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4119 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
4120 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4121 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
4122 CPPUNIT_ASSERT_MESSAGE("G3 has a border", pItem);
4123 CPPUNIT_ASSERT_MESSAGE("G3 has no top border",
4124 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
4125 CPPUNIT_ASSERT_MESSAGE("G3 has no bottom border",
4126 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4127 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
4128 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4129 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
4130 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4131 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
4132 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
4133 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
4134 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
4135 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
4136 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4137 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
4138 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4139 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
4140 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
4142 // check notes after transposed copy/paste
4143 // check presence of notes
4144 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
4145 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
4146 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
4147 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
4148 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
4149 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
4150 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
4151 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
4152 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
4153 CPPUNIT_ASSERT_MESSAGE("F2: no note", !m_pDoc->HasNote(5, 1, destSheet));
4154 CPPUNIT_ASSERT_MESSAGE("G2: a note", m_pDoc->HasNote(6, 1, destSheet));
4155 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
4156 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
4157 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
4158 CPPUNIT_ASSERT_MESSAGE("E3: a note", m_pDoc->HasNote(4, 2, destSheet));
4159 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
4160 CPPUNIT_ASSERT_MESSAGE("G3: a note", m_pDoc->HasNote(6, 2, destSheet));
4161 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
4162 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
4163 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
4164 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
4165 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
4166 CPPUNIT_ASSERT_MESSAGE("G4: no note", !m_pDoc->HasNote(6, 3, destSheet));
4167 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
4168 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
4169 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
4170 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
4171 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
4172 CPPUNIT_ASSERT_MESSAGE("G5: a note", m_pDoc->HasNote(6, 4, destSheet));
4173 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
4174 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
4175 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
4176 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
4177 CPPUNIT_ASSERT_MESSAGE("F6: a note", m_pDoc->HasNote(5, 5, destSheet));
4178 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
4179 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
4180 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
4181 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
4182 CPPUNIT_ASSERT_MESSAGE("E7: no note", !m_pDoc->HasNote(4, 6, destSheet));
4183 CPPUNIT_ASSERT_MESSAGE("F7: a note", m_pDoc->HasNote(5, 6, destSheet));
4184 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
4185 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
4186 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
4187 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
4188 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
4189 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
4190 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
4191 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
4193 // check values of notes
4194 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
4195 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A3"), getNote(4, 1, destSheet));
4196 // F2 has no note
4197 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G2", OUString("Note A1"), getNote(6, 1, destSheet));
4198 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
4199 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("Note B3"), getNote(4, 2, destSheet));
4200 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B4"), getNote(5, 2, destSheet));
4201 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G3", OUString("Note B1"), getNote(6, 2, destSheet));
4202 // D4 has no note
4203 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C3"), getNote(4, 3, destSheet));
4204 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C4"), getNote(5, 3, destSheet));
4205 // G4 has no note
4206 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
4207 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D3"), getNote(4, 4, destSheet));
4208 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D4"), getNote(5, 4, destSheet));
4209 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G5", OUString("Note D1"), getNote(6, 4, destSheet));
4210 if (!bSkipEmpty)
4211 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 5, destSheet));
4212 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F6", OUString("Note E4"), getNote(5, 5, destSheet));
4213 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F7", OUString("Note F4"), getNote(5, 6, destSheet));
4215 // check row 16 on src sheet, refs to copied/cut range
4216 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
4217 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
4218 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
4219 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
4220 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
4221 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
4222 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
4223 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
4224 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
4225 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
4227 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4228 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4229 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4230 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4231 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4232 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4233 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4234 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4235 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4236 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4238 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
4239 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
4240 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
4241 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
4242 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
4243 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
4244 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
4245 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
4246 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
4247 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
4249 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4250 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4251 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4252 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4253 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4254 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4255 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4256 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4257 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4258 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4260 // Existing references to the destination range must not change
4261 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
4262 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
4263 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
4264 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
4265 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
4266 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
4267 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
4268 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
4269 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
4270 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
4271 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
4272 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
4273 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
4274 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
4275 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
4276 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
4277 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
4278 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
4279 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
4280 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
4281 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
4282 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
4283 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
4284 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
4285 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
4286 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
4287 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
4288 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
4289 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
4290 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
4291 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
4292 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
4293 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
4294 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
4295 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
4296 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
4297 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
4298 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
4299 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
4300 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
4301 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
4302 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
4303 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
4304 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
4305 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
4306 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
4307 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
4308 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
4309 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
4311 m_pDoc->DeleteTab(destSheet);
4312 m_pDoc->DeleteTab(srcSheet);
4315 void TestCopyPaste::checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty)
4317 const SCTAB srcSheet = 0;
4318 const SCTAB destSheet = 1;
4321 ┌--- not selected src col C
4324 | D | E | F | G | H | I |
4326 2 | 1 B*| =D2+10 *| R1 *| =C2+C4+60 | =SUMIF(C2:C5;"<4") | 121 |
4327 3 | 2 B*| =D3+20 b | R2 *| | *| 122 | <- filtered row
4328 4 | 3 B*| =G4+30 b*| 5 *| B*| | 123 |
4329 5 | 4 | =D3+40 b*| R4 *| =C2+C4+70 *| =D$3+$B$5+80 *| 124 |
4331 * means note attached
4332 B means background
4333 b means border
4336 const EditTextObject* pEditObj;
4337 // col 2
4338 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4339 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4340 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4341 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4342 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4343 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4344 // col 3, numbers
4345 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4346 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4347 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
4348 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
4349 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 4, destSheet));
4350 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
4351 // col 4, formulas
4352 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4353 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
4354 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
4355 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(4, 1, destSheet));
4356 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), getFormula(4, 2, destSheet));
4357 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
4358 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), getFormula(4, 3, destSheet));
4359 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4360 m_pDoc->GetValue(4, 3, destSheet)); // It was 35
4361 CPPUNIT_ASSERT_EQUAL(OUString("=D3+40"), getFormula(4, 4, destSheet));
4362 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(4, 4, destSheet));
4363 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
4364 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 5, destSheet));
4365 // col 5, strings are not selected
4366 // col 5, rich text
4367 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4368 pEditObj = m_pDoc->GetEditText(ScAddress(5, 0, destSheet));
4369 CPPUNIT_ASSERT(pEditObj == nullptr);
4370 pEditObj = m_pDoc->GetEditText(ScAddress(5, 1, destSheet));
4371 CPPUNIT_ASSERT(pEditObj);
4372 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4373 pEditObj = m_pDoc->GetEditText(ScAddress(5, 2, destSheet));
4374 CPPUNIT_ASSERT(pEditObj);
4375 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
4376 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 3, destSheet));
4377 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4378 CPPUNIT_ASSERT(pEditObj);
4379 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4380 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
4381 pEditObj = m_pDoc->GetEditText(ScAddress(5, 5, destSheet));
4382 CPPUNIT_ASSERT(pEditObj == nullptr);
4383 // col 6, formulas
4384 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4385 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 0, destSheet));
4386 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+60"), getFormula(6, 1, destSheet));
4387 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(6, 1, destSheet)); // It was 64
4388 if (!bSkipEmpty)
4390 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 2, destSheet));
4391 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 3, destSheet));
4393 else
4395 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
4396 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 3, destSheet));
4398 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+70"), getFormula(6, 4, destSheet));
4399 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 4, destSheet)); // It was 74
4400 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
4401 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 5, destSheet));
4402 // col 7, formulas
4403 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4404 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
4405 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(C2:C5;\"<4\")"), getFormula(7, 1, destSheet));
4406 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(7, 1, destSheet)); // It was 6
4407 if (!bSkipEmpty)
4409 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
4410 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
4412 else
4414 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4415 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
4417 CPPUNIT_ASSERT_EQUAL(1082.0, m_pDoc->GetValue(7, 4, destSheet));
4418 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$B$5+80"), getFormula(7, 4, destSheet));
4419 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
4420 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
4421 // col 8, numbers
4422 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
4423 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(8, 1, destSheet));
4424 CPPUNIT_ASSERT_EQUAL(122.0, m_pDoc->GetValue(8, 2, destSheet));
4425 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 3, destSheet));
4426 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(8, 4, destSheet));
4427 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
4428 // col 9, col repetition is not supported for multi range copy/paste
4429 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
4430 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
4431 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
4432 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
4433 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
4434 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
4436 // check patterns
4437 const SfxPoolItem* pItem = nullptr;
4438 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4439 CPPUNIT_ASSERT(pItem);
4440 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4441 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4442 CPPUNIT_ASSERT(pItem);
4443 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4444 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4445 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4446 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4447 CPPUNIT_ASSERT(!pItem);
4448 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4449 CPPUNIT_ASSERT(!pItem);
4450 m_pDoc->GetPattern(ScAddress(6, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4451 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4452 if (!bSkipEmpty)
4453 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4455 // check border, left and right borders were transformed to top and bottom borders
4456 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
4457 CPPUNIT_ASSERT(pItem);
4458 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4459 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4460 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4461 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4462 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4463 CPPUNIT_ASSERT(pItem);
4464 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4465 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4466 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4467 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4468 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
4469 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4470 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4471 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4472 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4473 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
4474 CPPUNIT_ASSERT(pItem);
4475 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4476 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4477 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4478 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4479 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
4480 CPPUNIT_ASSERT(pItem);
4481 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4482 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4483 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4484 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4486 // check notes after transposed copy/paste
4487 // check presence of notes
4488 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4489 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4490 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4491 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4492 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4493 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4494 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
4495 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4496 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4497 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4498 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4499 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4500 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4501 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
4502 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4503 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4504 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
4505 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4506 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, destSheet));
4507 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
4508 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
4509 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4510 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
4511 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4512 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4513 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(6, 3, destSheet));
4514 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
4515 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
4516 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4517 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4518 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
4519 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
4520 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
4521 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 4, destSheet));
4522 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
4523 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
4524 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
4525 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
4526 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
4527 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
4528 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
4529 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
4531 // check values of notes
4532 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4533 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
4534 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
4535 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
4536 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
4537 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(5, 1, destSheet));
4538 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(5, 2, destSheet));
4539 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 3, destSheet));
4540 if (!bSkipEmpty)
4541 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(6, 3, destSheet));
4542 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 4, destSheet));
4543 if (!bSkipEmpty)
4544 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(7, 2, destSheet));
4545 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(7, 4, destSheet));
4547 // check row 16 on src sheet, refs to copied/cut range
4548 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
4549 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
4550 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
4551 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
4552 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
4553 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
4554 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
4555 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
4556 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
4557 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
4559 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4560 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4561 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4562 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4563 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4564 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4565 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4566 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4567 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4568 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4570 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
4571 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
4572 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
4573 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
4574 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
4575 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
4576 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
4577 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
4578 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
4579 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
4581 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4582 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4583 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4584 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4585 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4586 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4587 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4588 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4589 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4590 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4592 // Existing references to the destination range must not change
4593 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
4594 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
4595 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
4596 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
4597 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
4598 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
4599 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
4600 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
4601 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
4602 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
4603 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
4604 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
4605 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
4606 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
4607 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
4608 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
4609 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
4610 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
4611 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
4612 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
4613 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
4614 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
4615 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
4616 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
4617 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
4618 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
4619 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
4620 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
4621 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
4622 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
4623 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
4624 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
4625 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
4626 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
4627 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
4628 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
4629 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
4630 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
4631 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
4632 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
4633 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
4634 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
4635 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
4636 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
4637 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
4638 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
4639 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
4640 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
4641 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
4643 m_pDoc->DeleteTab(destSheet);
4644 m_pDoc->DeleteTab(srcSheet);
4647 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty)
4649 const SCTAB srcSheet = 0;
4650 const SCTAB destSheet = 1;
4653 ┌--- not selected src col C
4656 | D | E | F | G | H | I |
4658 2 | 1 B*| =D2+10 *| R1 *| =C2+C4+60 | =SUMIF(C2:C5;"<4") | 121 |
4659 3 | 3 B*| =G4+30 b*| 5 *| B*| | 123 |
4660 4 | 4 | =D2+40 b*| R4 *| =C1+C3+70 *| =D$3+$B$5+80 *| 124 |
4662 * means note attached
4663 B means background
4664 b means border
4667 const EditTextObject* pEditObj;
4668 // col 2
4669 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4670 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4671 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4672 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4673 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4674 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4675 // col 3, numbers
4676 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4677 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4678 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
4679 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 3, destSheet));
4680 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 4, destSheet));
4681 // col 4, formulas
4682 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4683 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(4, 0, destSheet));
4684 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
4685 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(4, 1, destSheet));
4686 // references over selection gaps are not adjusted
4687 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), getFormula(4, 2, destSheet));
4688 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4689 m_pDoc->GetValue(4, 2, destSheet)); // It was 35
4690 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), getFormula(4, 3, destSheet));
4691 // was originally 42, not adjusted by filtering
4692 CPPUNIT_ASSERT_EQUAL(41.0, m_pDoc->GetValue(4, 3, destSheet));
4693 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
4694 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(4, 4, destSheet));
4695 // col 5, strings are not selected
4696 // col 5, rich text
4697 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4698 pEditObj = m_pDoc->GetEditText(ScAddress(5, 0, destSheet));
4699 CPPUNIT_ASSERT(pEditObj == nullptr);
4700 pEditObj = m_pDoc->GetEditText(ScAddress(5, 1, destSheet));
4701 CPPUNIT_ASSERT(pEditObj);
4702 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4703 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 2, destSheet));
4704 pEditObj = m_pDoc->GetEditText(ScAddress(5, 3, destSheet));
4705 CPPUNIT_ASSERT(pEditObj);
4706 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4707 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 4, destSheet));
4708 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4709 CPPUNIT_ASSERT(pEditObj == nullptr);
4710 // col 6, formulas
4711 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4712 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(6, 0, destSheet));
4713 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+60"), getFormula(6, 1, destSheet));
4714 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(6, 1, destSheet)); // It was 64
4715 if (!bSkipEmpty)
4716 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 2, destSheet));
4717 else
4718 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
4719 CPPUNIT_ASSERT_EQUAL(OUString("=C1+C3+70"), getFormula(6, 3, destSheet));
4720 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 3, destSheet)); // It was 74
4721 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 4, destSheet));
4722 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(6, 4, destSheet));
4723 // col 7, formulas
4724 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4725 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(7, 0, destSheet));
4726 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(C2:C5;\"<4\")"), getFormula(7, 1, destSheet));
4727 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(7, 1, destSheet)); // It was 6
4728 if (!bSkipEmpty)
4729 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
4730 else
4731 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4732 CPPUNIT_ASSERT_EQUAL(1083.0, m_pDoc->GetValue(7, 3, destSheet));
4733 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$B$5+80"), getFormula(7, 3, destSheet));
4734 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
4735 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(7, 4, destSheet));
4736 // col 8, numbers
4737 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
4738 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(8, 1, destSheet));
4739 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 2, destSheet));
4740 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(8, 3, destSheet));
4741 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 4, destSheet));
4742 // col 9, col repetition is not supported for multi range copy/paste
4743 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
4744 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
4745 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
4746 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
4747 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
4748 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
4750 // check patterns
4751 const SfxPoolItem* pItem = nullptr;
4752 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4753 CPPUNIT_ASSERT(pItem);
4754 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4755 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4756 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4757 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4758 CPPUNIT_ASSERT(!pItem);
4759 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4760 CPPUNIT_ASSERT(!pItem);
4761 m_pDoc->GetPattern(ScAddress(6, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4762 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4763 if (!bSkipEmpty)
4764 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4766 // check border, left and right borders were transformed to top and bottom borders
4767 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
4768 CPPUNIT_ASSERT(pItem);
4769 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4770 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4771 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4772 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4773 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4774 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4775 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4776 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4777 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4778 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
4779 CPPUNIT_ASSERT(pItem);
4780 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4781 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4782 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4783 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4784 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
4785 CPPUNIT_ASSERT(pItem);
4786 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4787 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4788 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4789 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4791 // check notes after transposed copy/paste
4792 // check presence of notes
4793 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4794 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4795 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4796 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4797 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4798 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4799 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
4800 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4801 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4802 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4803 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4804 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4805 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4806 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
4807 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4808 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4809 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
4810 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4811 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(6, 2, destSheet));
4812 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
4813 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
4814 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4815 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
4816 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4817 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4818 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
4819 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 3, destSheet));
4820 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
4821 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4822 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4823 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
4824 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
4825 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
4826 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
4827 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
4829 // check values of notes
4830 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4831 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
4832 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
4833 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
4834 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(5, 1, destSheet));
4835 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 2, destSheet));
4836 if (!bSkipEmpty)
4837 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(6, 2, destSheet));
4838 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 3, destSheet));
4839 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(7, 3, destSheet));
4841 // check row 16 on src sheet, refs to copied/cut range
4842 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
4843 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
4844 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
4845 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
4846 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
4847 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
4848 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
4849 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
4850 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
4851 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
4853 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4854 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4855 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4856 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4857 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4858 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4859 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4860 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4861 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4862 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4864 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
4865 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
4866 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
4867 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
4868 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
4869 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
4870 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
4871 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
4872 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
4873 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
4875 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4876 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4877 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4878 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4879 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4880 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4881 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4882 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4883 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4884 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4886 // Existing references to the destination range must not change
4887 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
4888 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
4889 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
4890 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
4891 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
4892 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
4893 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
4894 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
4895 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
4896 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
4897 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
4898 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
4899 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
4900 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
4901 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
4902 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
4903 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
4904 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
4905 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
4906 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
4907 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
4908 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
4909 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
4910 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
4911 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
4912 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
4913 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
4914 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
4915 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
4916 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
4917 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
4918 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
4919 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
4920 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
4921 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
4922 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
4923 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
4924 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
4925 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
4926 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
4927 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
4928 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
4929 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
4930 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
4931 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
4932 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
4933 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
4934 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
4935 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
4937 m_pDoc->DeleteTab(destSheet);
4938 m_pDoc->DeleteTab(srcSheet);
4941 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty)
4943 const SCTAB srcSheet = 0;
4944 const SCTAB destSheet = 1;
4947 | D | E | F | G |
4949 2 | 1 B*| 2 B*| 3 B*| 4 |
4950 3 | =D2+10 *| =E2+20 b | =F5+30 b*| =E2+40 b*|
4951 4 | R1 *| R2 *| 5 *| R4 *|
4952 5 | =D1+F1+60 | | B*| =D1+F1+70 *|
4953 6 | =SUMIF(D1:G1;"<4") | *| | =C$3+$B$5+80 *|
4954 7 | 121 | 122 | 123 | 124 |
4956 * means note attached
4957 B means background
4958 b means border
4961 // check cell content after transposed copy/paste of filtered data
4962 // Col C and G are checked to be empty
4963 const EditTextObject* pEditObj;
4964 // row 0
4965 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4966 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4967 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4968 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4969 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4970 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4971 // row 1, numbers
4972 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4973 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4974 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(4, 1, destSheet));
4975 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(5, 1, destSheet));
4976 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(6, 1, destSheet));
4977 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
4978 // row 2, formulas
4979 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4980 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
4981 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 2, destSheet));
4982 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(3, 2, destSheet));
4983 CPPUNIT_ASSERT_EQUAL(OUString("=E2+20"), getFormula(4, 2, destSheet));
4984 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
4985 CPPUNIT_ASSERT_EQUAL(OUString("=F5+30"), getFormula(5, 2, destSheet));
4986 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4987 m_pDoc->GetValue(5, 2, destSheet)); // It was 35
4988 CPPUNIT_ASSERT_EQUAL(OUString("=E2+40"), getFormula(6, 2, destSheet));
4989 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(6, 2, destSheet));
4990 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4991 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
4992 // row 3, strings was not selected in multi range selection
4993 // row 3, rich text
4994 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4995 pEditObj = m_pDoc->GetEditText(ScAddress(2, 3, destSheet));
4996 CPPUNIT_ASSERT(pEditObj == nullptr);
4997 pEditObj = m_pDoc->GetEditText(ScAddress(3, 3, destSheet));
4998 CPPUNIT_ASSERT(pEditObj);
4999 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5000 pEditObj = m_pDoc->GetEditText(ScAddress(4, 3, destSheet));
5001 CPPUNIT_ASSERT(pEditObj);
5002 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
5003 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 3, destSheet));
5004 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
5005 CPPUNIT_ASSERT(pEditObj);
5006 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
5007 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
5008 pEditObj = m_pDoc->GetEditText(ScAddress(7, 3, destSheet));
5009 CPPUNIT_ASSERT(pEditObj == nullptr);
5010 // row 4, formulas
5011 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5012 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 4, destSheet));
5013 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+60"), getFormula(3, 4, destSheet));
5014 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(3, 4, destSheet)); // It was 64
5015 if (!bSkipEmpty)
5017 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString(), m_pDoc->GetString(4, 4, destSheet));
5018 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString(), m_pDoc->GetString(5, 4, destSheet));
5020 else
5022 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
5023 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 4, destSheet));
5025 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+70"), getFormula(6, 4, destSheet));
5026 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 4, destSheet)); // It was 74
5027 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
5028 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 4, destSheet));
5029 // row 5, formulas
5030 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5031 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5032 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D1:G1;\"<4\")"), getFormula(3, 5, destSheet));
5033 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(3, 5, destSheet)); // It was 6
5034 if (!bSkipEmpty)
5036 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
5037 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
5039 else
5041 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
5042 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
5045 CPPUNIT_ASSERT_EQUAL(OUString("=C$3+$B$5+80"), getFormula(6, 5, destSheet));
5046 CPPUNIT_ASSERT_EQUAL(2080.0, m_pDoc->GetValue(6, 5, destSheet));
5047 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
5048 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
5049 // row 6, numbers
5050 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
5051 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(3, 6, destSheet));
5052 CPPUNIT_ASSERT_EQUAL(122.0, m_pDoc->GetValue(4, 6, destSheet));
5053 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(5, 6, destSheet));
5054 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(6, 6, destSheet));
5055 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
5056 // row 7, not selected
5057 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5058 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5059 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5060 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5061 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5062 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5064 // check patterns
5065 const SfxPoolItem* pItem = nullptr;
5066 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5067 CPPUNIT_ASSERT(pItem);
5068 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5069 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5070 CPPUNIT_ASSERT(pItem);
5071 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5072 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5073 CPPUNIT_ASSERT(pItem);
5074 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5075 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5076 CPPUNIT_ASSERT(!pItem);
5077 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5078 CPPUNIT_ASSERT(!pItem);
5079 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5080 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5081 // std::cout << "bSkipEmpty: " << bSkipEmpty << ", pItem == nullptr: " << (pItem == nullptr) << std::endl;
5082 if (!bSkipEmpty)
5083 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5085 // check border, left and right borders were transformed to top and bottom borders
5086 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
5087 CPPUNIT_ASSERT(pItem);
5088 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5089 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5090 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5091 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5093 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
5094 CPPUNIT_ASSERT(pItem);
5095 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5096 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5097 CPPUNIT_ASSERT(pItem);
5098 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5099 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5100 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5101 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5102 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
5103 CPPUNIT_ASSERT(pItem);
5104 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5105 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5106 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5107 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5108 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
5109 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5110 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5111 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5112 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5113 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
5114 CPPUNIT_ASSERT(pItem);
5115 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5116 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5117 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5118 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5120 // check notes after transposed copy/paste
5121 // check presence of notes
5122 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5123 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5124 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5125 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5126 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5127 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
5128 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5129 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5130 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5131 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
5132 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
5133 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
5134 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5135 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5136 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
5137 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5138 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
5139 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
5140 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5141 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5142 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5143 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5144 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
5145 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
5146 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5147 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5148 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
5149 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 4, destSheet));
5150 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
5151 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
5152 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5153 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5154 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
5155 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
5156 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 5, destSheet));
5157 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
5158 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, destSheet));
5159 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 6, destSheet));
5160 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, destSheet));
5161 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, destSheet));
5162 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, destSheet));
5163 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 6, destSheet));
5165 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5166 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(4, 1, destSheet));
5167 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(5, 1, destSheet));
5168 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(3, 2, destSheet));
5169 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(5, 2, destSheet));
5170 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(3, 3, destSheet));
5171 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(4, 3, destSheet));
5172 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 3, destSheet));
5173 if (!bSkipEmpty)
5174 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 4, destSheet));
5175 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 4, destSheet));
5176 if (!bSkipEmpty)
5177 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(4, 5, destSheet));
5178 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(6, 5, destSheet));
5180 // check row 16 on src sheet, refs to copied/cut range
5181 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
5182 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
5183 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
5184 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
5185 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
5186 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
5187 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
5188 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
5189 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
5190 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
5192 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5193 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5194 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5195 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5196 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5197 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5198 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5199 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5200 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5201 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5203 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
5204 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
5205 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
5206 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
5207 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
5208 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
5209 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
5210 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
5211 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
5212 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
5214 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5215 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5216 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5217 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5218 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5219 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5220 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5221 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5222 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5223 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5225 // Existing references to the destination range must not change
5226 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
5227 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
5228 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
5229 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
5230 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
5231 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
5232 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
5233 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
5234 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
5235 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
5236 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
5237 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
5238 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
5239 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
5240 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
5241 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
5242 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
5243 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
5244 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
5245 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
5246 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
5247 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
5248 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
5249 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
5250 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
5251 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
5252 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
5253 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
5254 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
5255 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
5256 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
5257 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
5258 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
5259 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
5260 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
5261 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
5262 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
5263 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
5264 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
5265 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
5266 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
5267 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
5268 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
5269 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
5270 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
5271 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
5272 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
5273 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
5274 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
5276 m_pDoc->DeleteTab(destSheet);
5277 m_pDoc->DeleteTab(srcSheet);
5280 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty)
5282 const SCTAB srcSheet = 0;
5283 const SCTAB destSheet = 1;
5286 ┌--- filtered src row 2
5289 | D | E | F |
5291 2 | 1 B*| 3 B*| 4 |
5292 3 | =D2+10 *| =E5+30 b*| =D2+40 b*|
5293 <- not copied col C
5294 4 | R1 *| 5 *| R4 *|
5295 5 | =D1+F1+60 | B*| =C1+E1+70 *|
5296 6 | =SUMIF(D1:G1;"<4") | | =B$3+$B$5+80 *|
5297 7 | 121 | 123 | 124 |
5299 * means note attached
5300 B means background
5301 b means border
5304 // check cell content after transposed copy/paste of filtered data
5305 // Col C and G are checked to be empty
5306 const EditTextObject* pEditObj;
5307 // row 0
5308 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5309 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5310 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5311 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5312 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5313 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5314 // row 1, numbers
5315 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5316 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5317 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(4, 1, destSheet));
5318 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(5, 1, destSheet));
5319 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 1, destSheet));
5320 // row 2, formulas
5321 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5322 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5323 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 2, destSheet));
5324 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(3, 2, destSheet));
5325 CPPUNIT_ASSERT_EQUAL(OUString("=E5+30"), getFormula(4, 2, destSheet));
5326 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
5327 m_pDoc->GetValue(4, 2, destSheet)); // It was 35
5328 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), getFormula(5, 2, destSheet));
5329 CPPUNIT_ASSERT_EQUAL(
5330 41.0, m_pDoc->GetValue(5, 2, destSheet)); // was originally 42, not adjusted by filtering
5331 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
5332 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 2, destSheet));
5333 // row 3, strings was not selected in multi range selection
5334 // row 3, rich text
5335 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5336 pEditObj = m_pDoc->GetEditText(ScAddress(2, 3, destSheet));
5337 CPPUNIT_ASSERT(pEditObj == nullptr);
5338 pEditObj = m_pDoc->GetEditText(ScAddress(3, 3, destSheet));
5339 CPPUNIT_ASSERT(pEditObj);
5340 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5341 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 3, destSheet));
5342 pEditObj = m_pDoc->GetEditText(ScAddress(5, 3, destSheet));
5343 CPPUNIT_ASSERT(pEditObj);
5344 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
5345 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 3, destSheet));
5346 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
5347 CPPUNIT_ASSERT(pEditObj == nullptr);
5348 // row 4, formulas
5349 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5350 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 4, destSheet));
5351 // formulas over filtered rows are not adjusted
5352 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+60"), getFormula(3, 4, destSheet));
5353 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(3, 4, destSheet)); // It was 64
5354 if (!bSkipEmpty)
5355 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(4, 4, destSheet));
5356 else
5357 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
5358 CPPUNIT_ASSERT_EQUAL(OUString("=C1+E1+70"), getFormula(5, 4, destSheet));
5359 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(5, 4, destSheet)); // It was 74
5360 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 4, destSheet));
5361 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 4, destSheet));
5362 // row 5, formulas
5363 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5364 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5365 // formulas over filtered rows are not adjusted
5366 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D1:G1;\"<4\")"), getFormula(3, 5, destSheet));
5367 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(3, 5, destSheet)); // It was 6
5368 if (!bSkipEmpty)
5369 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
5370 else
5371 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
5372 CPPUNIT_ASSERT_EQUAL(OUString("=B$3+$B$5+80"), getFormula(5, 5, destSheet));
5373 CPPUNIT_ASSERT_EQUAL(2080.0, m_pDoc->GetValue(5, 5, destSheet));
5374 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
5375 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 5, destSheet));
5376 // row 6, numbers
5377 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
5378 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(3, 6, destSheet));
5379 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(4, 6, destSheet));
5380 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(5, 6, destSheet));
5381 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 6, destSheet));
5382 // row 7, not copied
5383 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5384 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5385 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5386 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5387 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5388 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5389 // row 8, not copied
5390 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5391 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5392 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5393 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5394 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5395 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5397 // check patterns
5398 const SfxPoolItem* pItem = nullptr;
5399 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5400 CPPUNIT_ASSERT(pItem);
5401 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5402 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5403 CPPUNIT_ASSERT(pItem);
5404 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5405 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5406 CPPUNIT_ASSERT(!pItem);
5407 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5408 CPPUNIT_ASSERT(!pItem);
5409 m_pDoc->GetPattern(ScAddress(4, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5410 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5411 if (!bSkipEmpty)
5412 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5414 // check border, left and right borders were transformed to top and bottom borders
5415 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
5416 CPPUNIT_ASSERT(pItem);
5417 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5418 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5419 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5420 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5422 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
5423 CPPUNIT_ASSERT(pItem);
5424 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5426 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5427 CPPUNIT_ASSERT(pItem);
5428 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5429 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5430 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5431 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5432 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
5433 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5434 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5435 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5436 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5437 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
5438 CPPUNIT_ASSERT(pItem);
5439 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5440 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5441 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5442 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5444 // check notes after transposed copy/paste
5445 // check presence of notes
5446 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5447 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5448 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5449 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5450 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5451 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5452 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5453 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5454 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
5455 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
5456 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5457 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5458 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
5459 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5460 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, destSheet));
5461 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5462 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5463 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5464 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5465 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 3, destSheet));
5466 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5467 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5468 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 4, destSheet));
5469 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
5470 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
5471 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5472 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5473 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
5474 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 5, destSheet));
5475 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
5476 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, destSheet));
5477 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 6, destSheet));
5478 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, destSheet));
5479 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, destSheet));
5480 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, destSheet));
5482 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5483 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(4, 1, destSheet));
5484 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(3, 2, destSheet));
5485 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
5486 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(3, 3, destSheet));
5487 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(4, 3, destSheet));
5488 if (!bSkipEmpty)
5489 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 4, destSheet));
5490 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(5, 4, destSheet));
5491 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(5, 5, destSheet));
5493 // check row 16 on src sheet, refs to copied/cut range
5494 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
5495 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
5496 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
5497 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
5498 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
5499 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
5500 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
5501 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
5502 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
5503 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
5505 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5506 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5507 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5508 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5509 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5510 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5511 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5512 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5513 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5514 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5516 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
5517 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
5518 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
5519 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
5520 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
5521 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
5522 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
5523 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
5524 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
5525 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
5527 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5528 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5529 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5530 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5531 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5532 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5533 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5534 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5535 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5536 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5538 // Existing references to the destination range must not change
5539 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
5540 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
5541 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
5542 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
5543 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
5544 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
5545 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
5546 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
5547 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
5548 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
5549 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
5550 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
5551 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
5552 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
5553 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
5554 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
5555 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
5556 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
5557 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
5558 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
5559 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
5560 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
5561 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
5562 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
5563 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
5564 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
5565 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
5566 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
5567 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
5568 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
5569 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
5570 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
5571 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
5572 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
5573 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
5574 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
5575 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
5576 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
5577 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
5578 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
5579 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
5580 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
5581 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
5582 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
5583 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
5584 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
5585 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
5586 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
5587 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
5589 m_pDoc->DeleteTab(destSheet);
5590 m_pDoc->DeleteTab(srcSheet);
5593 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty)
5595 const SCTAB srcSheet = 0;
5596 const SCTAB destSheet = 1;
5599 | D | E | F | G | H | I |
5601 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
5602 3 | 2 B*| =D3+20 b | b *| R2 *| | *| <- filtered row
5603 4 | 3 B*| =G4+30 b*| c *| 5 *| B*| |
5604 <- not selected row
5605 5 | 6 | q | r bB*| s bB| t | u |
5606 6 | -11 | -12 | -13 | -14 | -15 | -16 |
5608 * means note attached
5609 B means background
5610 b means border
5613 const EditTextObject* pEditObj;
5614 // col 2
5615 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5616 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5617 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
5618 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5619 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5620 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5621 // col 3, numbers
5622 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5623 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5624 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
5625 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
5626 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(3, 4, destSheet));
5627 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(3, 5, destSheet));
5628 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 6, destSheet));
5629 // col 4, formulas
5630 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5631 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
5632 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
5633 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(4, 1, destSheet));
5634 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), getFormula(4, 2, destSheet));
5635 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
5636 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), getFormula(4, 3, destSheet));
5637 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 3, destSheet));
5638 CPPUNIT_ASSERT_EQUAL(OUString("q"), m_pDoc->GetString(4, 4, destSheet));
5639 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(4, 5, destSheet));
5640 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
5641 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 6, destSheet));
5642 // col 5, strings
5643 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5644 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
5645 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
5646 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(5, 2, destSheet));
5647 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 3, destSheet));
5648 CPPUNIT_ASSERT_EQUAL(OUString("r"), m_pDoc->GetString(5, 4, destSheet));
5649 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(5, 5, destSheet));
5650 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
5651 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 6, destSheet));
5652 // col 6, rich text
5653 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5654 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
5655 CPPUNIT_ASSERT(pEditObj == nullptr);
5656 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
5657 CPPUNIT_ASSERT(pEditObj);
5658 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5659 pEditObj = m_pDoc->GetEditText(ScAddress(6, 2, destSheet));
5660 CPPUNIT_ASSERT(pEditObj);
5661 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
5662 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 3, destSheet));
5663 CPPUNIT_ASSERT_EQUAL(OUString("s"), m_pDoc->GetString(6, 4, destSheet));
5664 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 5, destSheet));
5665 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 6, destSheet));
5666 pEditObj = m_pDoc->GetEditText(ScAddress(6, 6, destSheet));
5667 CPPUNIT_ASSERT(pEditObj == nullptr);
5668 // col 7, formulas
5669 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5670 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5671 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), getFormula(7, 1, destSheet));
5672 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(7, 1, destSheet));
5673 if (!bSkipEmpty)
5675 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
5676 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
5678 else
5680 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
5681 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
5683 CPPUNIT_ASSERT_EQUAL(OUString("t"), m_pDoc->GetString(7, 4, destSheet));
5684 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 5, destSheet));
5685 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
5686 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
5687 // col 8, formulas
5688 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
5689 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5690 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), getFormula(8, 1, destSheet));
5691 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
5692 if (!bSkipEmpty)
5694 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
5695 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 3, destSheet));
5697 else
5699 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
5700 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
5702 CPPUNIT_ASSERT_EQUAL(OUString("u"), m_pDoc->GetString(8, 4, destSheet));
5703 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(8, 5, destSheet));
5704 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 6, destSheet));
5705 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 6, destSheet));
5706 // col 9
5707 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
5708 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
5709 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
5710 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
5711 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
5712 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
5714 // check patterns
5715 const SfxPoolItem* pItem = nullptr;
5716 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5717 CPPUNIT_ASSERT(pItem);
5718 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5719 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5720 CPPUNIT_ASSERT(pItem);
5721 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5722 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5723 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5724 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5725 CPPUNIT_ASSERT(!pItem);
5726 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5727 CPPUNIT_ASSERT(!pItem);
5728 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5729 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5730 if (!bSkipEmpty)
5731 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5733 m_pDoc->GetPattern(ScAddress(4, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5734 CPPUNIT_ASSERT(!pItem);
5735 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5736 CPPUNIT_ASSERT(pItem);
5737 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5738 m_pDoc->GetPattern(ScAddress(6, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5739 CPPUNIT_ASSERT(pItem);
5740 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5741 m_pDoc->GetPattern(ScAddress(7, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5742 CPPUNIT_ASSERT(!pItem);
5744 // check border, left and right borders were transformed to top and bottom borders
5745 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
5746 CPPUNIT_ASSERT(pItem);
5747 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5748 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5749 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5750 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5751 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5752 CPPUNIT_ASSERT(pItem);
5753 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5754 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5755 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5756 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5757 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
5758 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5759 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5760 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5761 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5762 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5763 CPPUNIT_ASSERT(pItem);
5764 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5765 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5766 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5767 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5768 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
5769 CPPUNIT_ASSERT(pItem);
5770 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5771 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5772 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5773 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5775 pItem = m_pDoc->GetAttr(ScAddress(3, 4, destSheet), ATTR_BORDER);
5776 CPPUNIT_ASSERT(pItem);
5777 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5778 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5779 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5780 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5781 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5782 CPPUNIT_ASSERT(pItem);
5783 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5784 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5785 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5786 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5787 pItem = m_pDoc->GetAttr(ScAddress(5, 4, destSheet), ATTR_BORDER);
5788 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5789 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5790 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5791 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5792 pItem = m_pDoc->GetAttr(ScAddress(6, 4, destSheet), ATTR_BORDER);
5793 CPPUNIT_ASSERT(pItem);
5794 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5795 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5796 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5797 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5798 pItem = m_pDoc->GetAttr(ScAddress(7, 4, destSheet), ATTR_BORDER);
5799 CPPUNIT_ASSERT(pItem);
5800 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5801 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5802 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5803 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5805 // check notes after transposed copy/paste
5806 // check presence of notes
5807 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5808 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5809 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5810 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5811 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5812 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
5813 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
5814 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
5815 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5816 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5817 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5818 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
5819 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
5820 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
5821 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
5822 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
5823 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5824 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5825 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
5826 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5827 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
5828 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
5829 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(8, 2, destSheet));
5830 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
5831 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5832 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5833 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5834 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5835 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
5836 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 3, destSheet));
5837 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
5838 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
5839 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5840 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5841 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
5842 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
5843 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
5844 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
5845 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
5846 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
5847 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5848 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5849 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
5850 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
5851 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
5852 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
5853 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
5854 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
5856 // check values of notes
5857 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5858 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
5859 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
5860 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
5861 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
5862 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(5, 2, destSheet));
5863 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 3, destSheet));
5864 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
5865 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(6, 2, destSheet));
5866 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 3, destSheet));
5867 if (!bSkipEmpty)
5868 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 3, destSheet));
5869 if (!bSkipEmpty)
5870 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(8, 2, destSheet));
5871 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 4, destSheet));
5873 // check row 16 on src sheet, refs to copied/cut range
5874 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
5875 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
5876 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
5877 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
5878 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
5879 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
5880 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
5881 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
5882 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
5883 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
5885 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5886 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5887 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5888 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5889 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5890 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5891 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5892 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5893 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5894 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5896 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
5897 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
5898 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
5899 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
5900 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
5901 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
5902 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
5903 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
5904 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
5905 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
5907 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5908 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5909 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5910 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5911 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5912 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5913 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5914 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5915 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5916 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5918 // Existing references to the destination range must not change
5919 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
5920 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
5921 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
5922 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
5923 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
5924 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
5925 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
5926 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
5927 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
5928 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
5929 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
5930 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
5931 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
5932 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
5933 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
5934 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
5935 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
5936 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
5937 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
5938 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
5939 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
5940 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
5941 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
5942 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
5943 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
5944 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
5945 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
5946 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
5947 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
5948 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
5949 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
5950 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
5951 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
5952 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
5953 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
5954 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
5955 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
5956 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
5957 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
5958 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
5959 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
5960 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
5961 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
5962 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
5963 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
5964 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
5965 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
5966 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
5967 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
5969 m_pDoc->DeleteTab(destSheet);
5970 m_pDoc->DeleteTab(srcSheet);
5973 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty)
5975 const SCTAB srcSheet = 0;
5976 const SCTAB destSheet = 1;
5979 | D | E | F | G | H | I |
5981 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
5982 3 | 3 B*| =G3+30 b*| c *| 5 *| B*| |
5983 <- not selected
5984 4 | 6 | q | r | s | t | u |
5985 5 | -11 | -12 |-13 | -14 | -15 | -16 |
5987 * means note attached
5988 B means background
5989 b means border
5992 const EditTextObject* pEditObj;
5993 // col 2
5994 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5995 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5996 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
5997 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5998 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5999 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6000 // col 3, numbers
6001 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6002 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
6003 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
6004 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(3, 3, destSheet));
6005 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(3, 4, destSheet));
6006 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
6007 // col 4, formulas
6008 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6009 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
6010 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
6011 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), getFormula(4, 1, destSheet));
6012 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), getFormula(4, 2, destSheet));
6013 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 2, destSheet));
6014 CPPUNIT_ASSERT_EQUAL(OUString("q"), m_pDoc->GetString(4, 3, destSheet));
6015 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(4, 4, destSheet));
6016 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6017 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 5, destSheet));
6018 // col 5, strings
6019 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6020 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
6021 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
6022 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 2, destSheet));
6023 CPPUNIT_ASSERT_EQUAL(OUString("r"), m_pDoc->GetString(5, 3, destSheet));
6024 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(5, 4, destSheet));
6025 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
6026 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 5, destSheet));
6027 // col 6, rich text
6028 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6029 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
6030 CPPUNIT_ASSERT(pEditObj == nullptr);
6031 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
6032 CPPUNIT_ASSERT(pEditObj);
6033 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
6034 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 2, destSheet));
6035 CPPUNIT_ASSERT_EQUAL(OUString("s"), m_pDoc->GetString(6, 3, destSheet));
6036 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 4, destSheet));
6037 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
6038 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
6039 CPPUNIT_ASSERT(pEditObj == nullptr);
6040 // col 7, formulas
6041 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6042 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
6043 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), getFormula(7, 1, destSheet));
6044 CPPUNIT_ASSERT_EQUAL(67.0, m_pDoc->GetValue(7, 1, destSheet));
6045 if (!bSkipEmpty)
6046 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
6047 else
6048 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
6049 CPPUNIT_ASSERT_EQUAL(OUString("t"), m_pDoc->GetString(7, 3, destSheet));
6050 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 4, destSheet));
6051 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
6052 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
6053 // col 8, formulas
6054 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
6055 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
6056 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), getFormula(8, 1, destSheet));
6057 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
6058 if (!bSkipEmpty)
6059 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
6060 else
6061 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
6062 CPPUNIT_ASSERT_EQUAL(OUString("u"), m_pDoc->GetString(8, 3, destSheet));
6063 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(8, 4, destSheet));
6064 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
6065 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
6066 // col 9
6067 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
6068 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
6069 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
6070 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
6071 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
6072 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
6074 // check patterns
6075 const SfxPoolItem* pItem = nullptr;
6076 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6077 CPPUNIT_ASSERT(pItem);
6078 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6079 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6080 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6081 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6082 CPPUNIT_ASSERT(!pItem);
6083 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6084 CPPUNIT_ASSERT(!pItem);
6085 m_pDoc->GetPattern(ScAddress(7, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6086 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6087 if (!bSkipEmpty)
6088 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6090 m_pDoc->GetPattern(ScAddress(4, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6091 CPPUNIT_ASSERT(!pItem);
6092 m_pDoc->GetPattern(ScAddress(5, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6093 CPPUNIT_ASSERT(pItem);
6094 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6095 m_pDoc->GetPattern(ScAddress(6, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6096 CPPUNIT_ASSERT(pItem);
6097 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6098 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6099 CPPUNIT_ASSERT(!pItem);
6101 // check border, left and right borders were transformed to top and bottom borders
6102 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
6103 CPPUNIT_ASSERT(pItem);
6104 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6105 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6106 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6107 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6108 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6109 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6110 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6111 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6112 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6113 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
6114 CPPUNIT_ASSERT(pItem);
6115 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6116 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6117 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6118 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6119 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
6120 CPPUNIT_ASSERT(pItem);
6121 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6122 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6123 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6124 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6126 pItem = m_pDoc->GetAttr(ScAddress(3, 3, destSheet), ATTR_BORDER);
6127 CPPUNIT_ASSERT(pItem);
6128 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6129 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6130 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6131 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6132 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
6133 CPPUNIT_ASSERT(pItem);
6134 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6135 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6136 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6137 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6138 pItem = m_pDoc->GetAttr(ScAddress(5, 3, destSheet), ATTR_BORDER);
6139 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
6140 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6141 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6142 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6143 pItem = m_pDoc->GetAttr(ScAddress(6, 3, destSheet), ATTR_BORDER);
6144 CPPUNIT_ASSERT(pItem);
6145 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
6146 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6147 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6148 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6149 pItem = m_pDoc->GetAttr(ScAddress(7, 3, destSheet), ATTR_BORDER);
6150 CPPUNIT_ASSERT(pItem);
6151 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6152 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6153 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6154 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
6156 // check notes after transposed copy/paste
6157 // check presence of notes
6158 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
6159 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
6160 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
6161 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
6162 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
6163 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
6164 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
6165 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
6166 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
6167 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
6168 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
6169 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
6170 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
6171 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
6172 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
6173 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
6174 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
6175 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
6176 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
6177 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
6178 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
6179 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
6180 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
6181 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
6182 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
6183 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
6184 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 3, destSheet));
6185 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
6186 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 3, destSheet));
6187 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
6188 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
6189 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
6190 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
6191 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
6192 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
6193 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
6194 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
6195 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
6196 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
6197 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
6199 // check values of notes
6200 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
6201 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
6202 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
6203 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
6204 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 2, destSheet));
6205 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
6206 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 2, destSheet));
6207 if (!bSkipEmpty)
6208 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 2, destSheet));
6209 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 3, destSheet));
6211 // check row 16 on src sheet, refs to copied/cut range
6212 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
6213 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
6214 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
6215 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
6216 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
6217 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
6218 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
6219 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
6220 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
6221 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
6223 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6224 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6225 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6226 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6227 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6228 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6229 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6230 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6231 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6232 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6234 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
6235 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
6236 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
6237 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
6238 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
6239 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
6240 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
6241 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
6242 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
6243 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
6245 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6246 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6247 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6248 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6249 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6250 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6251 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6252 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6253 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6254 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6256 // Existing references to the destination range must not change
6257 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
6258 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
6259 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
6260 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
6261 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
6262 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
6263 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
6264 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
6265 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
6266 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
6267 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
6268 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
6269 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
6270 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
6271 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
6272 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
6273 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
6274 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
6275 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
6276 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
6277 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
6278 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
6279 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
6280 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
6281 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
6282 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
6283 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
6284 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
6285 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
6286 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
6287 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
6288 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
6289 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
6290 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
6291 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
6292 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
6293 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
6294 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
6295 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
6296 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
6297 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
6298 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
6299 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
6300 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
6301 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
6302 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
6303 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
6304 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
6305 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
6307 m_pDoc->DeleteTab(destSheet);
6308 m_pDoc->DeleteTab(srcSheet);
6311 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty)
6313 const SCTAB srcSheet = 0;
6314 const SCTAB destSheet = 1;
6317 | D | E | F | G | H |
6319 2 | 1 B*| 2 B*| 3 B*| 6 | -11 |
6320 3 | =D2+10 *| =E2+20 b | =F5+30 b*| q | -12 |
6321 4 | a | b *| c *| r | -13 |
6322 5 | R1 *| R2 *| 5 *| s | -14 |
6323 6 | =D2+F2+60 | | B*| t | -15 |
6324 7 | =SUMIF(D2:G2;"<4") | *| | u | -16 |
6326 * means note attached
6327 B means background
6328 b means border
6331 //check cell content after transposed copy/paste of filtered data
6332 // Note: column F is a repetition of srcSheet.Column A
6333 // Col C and G are checked to be empty
6334 const EditTextObject* pEditObj;
6335 // row 0
6336 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6337 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6338 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6339 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6340 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6341 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6342 // row 1, numbers
6343 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell C2", 1000.0, m_pDoc->GetValue(2, 1, destSheet));
6344 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
6345 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 2.0, m_pDoc->GetValue(4, 1, destSheet));
6346 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 3.0, m_pDoc->GetValue(5, 1, destSheet));
6347 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2", 6.0, m_pDoc->GetValue(6, 1, destSheet));
6348 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(7, 1, destSheet));
6349 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell I2", 1000.0, m_pDoc->GetValue(8, 1, destSheet));
6350 // row 2, formulas
6351 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6352 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
6353 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
6354 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"), getFormula(3, 2, destSheet));
6355 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E2+20"), getFormula(4, 2, destSheet));
6356 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 22.0, m_pDoc->GetValue(4, 2, destSheet));
6357 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 35.0, m_pDoc->GetValue(5, 2, destSheet));
6358 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=F5+30"), getFormula(5, 2, destSheet));
6359 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("q"), m_pDoc->GetString(6, 2, destSheet));
6360 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(7, 2, destSheet));
6361 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
6362 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 2, destSheet));
6363 // row 3, strings
6364 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6365 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
6366 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
6367 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("b"), m_pDoc->GetString(4, 3, destSheet));
6368 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("c"), m_pDoc->GetString(5, 3, destSheet));
6369 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("r"), m_pDoc->GetString(6, 3, destSheet));
6370 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(7, 3, destSheet));
6371 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
6372 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 3, destSheet));
6373 // row 4, rich text
6374 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6375 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
6376 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
6377 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
6378 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
6379 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
6380 pEditObj->GetText(0));
6381 pEditObj = m_pDoc->GetEditText(ScAddress(4, 4, destSheet));
6382 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in E5.", pEditObj);
6383 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong E5.", OUString("R2"), pEditObj->GetText(0));
6384 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F5", 5.0, m_pDoc->GetValue(5, 4, destSheet));
6385 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G5", OUString("s"), m_pDoc->GetString(6, 4, destSheet));
6386 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(7, 4, destSheet));
6387 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 4, destSheet));
6388 pEditObj = m_pDoc->GetEditText(ScAddress(8, 4, destSheet));
6389 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in I5.", pEditObj == nullptr);
6390 // row 5, formulas
6391 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6392 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
6393 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
6394 getFormula(3, 5, destSheet));
6395 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 64.0, m_pDoc->GetValue(3, 5, destSheet));
6396 if (!bSkipEmpty)
6398 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
6399 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
6401 else
6403 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6404 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
6406 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G6", OUString("t"), m_pDoc->GetString(6, 5, destSheet));
6407 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 5, destSheet));
6408 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
6409 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
6410 // row 6, formulas
6411 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
6412 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
6413 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
6414 getFormula(3, 6, destSheet));
6415 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 6.0, m_pDoc->GetValue(3, 6, destSheet));
6416 if (!bSkipEmpty)
6418 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
6419 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 6, destSheet));
6421 else
6423 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
6424 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
6426 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G7", OUString("u"), m_pDoc->GetString(6, 6, destSheet));
6427 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(7, 6, destSheet));
6428 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 6, destSheet));
6429 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 6, destSheet));
6430 // row 7
6431 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
6432 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
6433 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
6434 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
6435 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
6436 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
6438 // check patterns
6439 const SfxPoolItem* pItem = nullptr;
6440 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6441 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
6442 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
6443 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6444 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6445 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
6446 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has blue background", COL_BLUE,
6447 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6448 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6449 CPPUNIT_ASSERT_MESSAGE("F2 has a pattern", pItem);
6450 CPPUNIT_ASSERT_EQUAL_MESSAGE("F2 has a pattern", COL_BLUE,
6451 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6452 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6453 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
6454 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6455 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
6456 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6457 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6458 if (!bSkipEmpty)
6459 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6461 // check border, left and right borders were transformed to top and bottom borders
6462 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
6463 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
6464 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
6465 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6466 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
6467 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6468 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
6469 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6470 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
6471 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6473 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
6474 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6475 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6477 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6478 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6479 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6480 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
6481 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6482 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
6483 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6484 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
6485 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6486 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
6487 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
6488 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6489 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
6490 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6491 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
6492 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6493 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
6494 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6495 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
6496 CPPUNIT_ASSERT_MESSAGE("G3 has top border", !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6497 CPPUNIT_ASSERT_MESSAGE("G3 has bottom border",
6498 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6499 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
6500 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6501 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
6502 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6503 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
6504 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
6505 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
6506 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6507 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
6508 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6509 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
6510 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6511 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
6512 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6514 // check notes after transposed copy/paste
6515 // check presence of notes
6516 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
6517 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
6518 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
6519 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
6520 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
6521 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
6522 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
6523 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
6524 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
6525 CPPUNIT_ASSERT_MESSAGE("F2: a note", m_pDoc->HasNote(5, 1, destSheet));
6526 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
6527 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
6528 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
6529 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
6530 CPPUNIT_ASSERT_MESSAGE("E3: no note", !m_pDoc->HasNote(4, 2, destSheet));
6531 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
6532 CPPUNIT_ASSERT_MESSAGE("G3: no note", !m_pDoc->HasNote(6, 2, destSheet));
6533 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
6534 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
6535 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
6536 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
6537 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
6538 CPPUNIT_ASSERT_MESSAGE("G4: a note", m_pDoc->HasNote(6, 3, destSheet));
6539 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
6540 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
6541 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
6542 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
6543 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
6544 CPPUNIT_ASSERT_MESSAGE("G5: no note", !m_pDoc->HasNote(6, 4, destSheet));
6545 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
6546 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
6547 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
6548 CPPUNIT_ASSERT_MESSAGE("E6: no note", !m_pDoc->HasNote(4, 5, destSheet));
6549 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 5, destSheet));
6550 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
6551 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
6552 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
6553 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
6554 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 6, destSheet));
6555 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
6556 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
6557 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
6558 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
6559 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
6560 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
6561 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
6562 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
6563 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
6565 // check values of notes
6566 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
6567 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A2"), getNote(4, 1, destSheet));
6568 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F2", OUString("Note A3"), getNote(5, 1, destSheet));
6569 // G2 has no note
6570 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
6571 // E3 has no note
6572 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B3"), getNote(5, 2, destSheet));
6573 // D4 has no note
6574 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C2"), getNote(4, 3, destSheet));
6575 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C3"), getNote(5, 3, destSheet));
6576 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
6577 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D2"), getNote(4, 4, destSheet));
6578 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D3"), getNote(5, 4, destSheet));
6579 if (!bSkipEmpty)
6580 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 5, destSheet));
6581 if (!bSkipEmpty)
6582 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString("Note F2"), getNote(4, 6, destSheet));
6583 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(6, 3, destSheet));
6585 // check row 16 on src sheet, refs to copied/cut range
6586 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
6587 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
6588 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
6589 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
6590 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
6591 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
6592 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
6593 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
6594 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
6595 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
6597 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6598 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6599 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6600 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6601 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6602 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6603 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6604 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6605 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6606 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6608 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
6609 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
6610 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
6611 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
6612 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
6613 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
6614 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
6615 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
6616 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
6617 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
6619 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6620 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6621 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6622 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6623 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6624 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6625 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6626 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6627 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6628 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6630 // Existing references to the destination range must not change
6631 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
6632 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
6633 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
6634 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
6635 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
6636 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
6637 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
6638 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
6639 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
6640 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
6641 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
6642 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
6643 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
6644 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
6645 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
6646 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
6647 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
6648 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
6649 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
6650 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
6651 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
6652 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
6653 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
6654 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
6655 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
6656 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
6657 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
6658 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
6659 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
6660 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
6661 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
6662 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
6663 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
6664 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
6665 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
6666 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
6667 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
6668 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
6669 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
6670 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
6671 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
6672 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
6673 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
6674 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
6675 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
6676 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
6677 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
6678 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
6679 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
6681 m_pDoc->DeleteTab(destSheet);
6682 m_pDoc->DeleteTab(srcSheet);
6685 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty)
6687 const SCTAB srcSheet = 0;
6688 const SCTAB destSheet = 1;
6691 | D | E | F | G |
6693 2 | 1 B*| 3 B*| 6 | -11 |
6694 3 | =D2+10 *| =F5+30 b*| q | -12 |
6695 4 | a | c *| r | -13 |
6696 5 | R1 *| 5 *| s | -14 |
6697 6 | =D2+F2+60 | B*| t | -15 |
6698 7 | =SUMIF(D2:G2;"<4") | | u | -16 |
6700 * means note attached
6701 B means background
6702 b means border
6705 //check cell content after transposed copy/paste of filtered data
6706 // Note: column F is a repetition of srcSheet.Column A
6707 // Col C and G are checked to be empty
6708 const EditTextObject* pEditObj;
6709 // row 0
6710 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6711 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6712 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6713 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6714 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6715 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6716 // row 1, numbers
6717 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell C2", 1000.0, m_pDoc->GetValue(2, 1, destSheet));
6718 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
6719 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 3.0, m_pDoc->GetValue(4, 1, destSheet));
6720 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 6.0, m_pDoc->GetValue(5, 1, destSheet));
6721 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(6, 1, destSheet));
6722 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell H2", 1000.0, m_pDoc->GetValue(7, 1, destSheet));
6723 // row 2, formulas
6724 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6725 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
6726 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
6727 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"), getFormula(3, 2, destSheet));
6728 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 35.0, m_pDoc->GetValue(4, 2, destSheet));
6729 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E5+30"), getFormula(4, 2, destSheet));
6730 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("q"), m_pDoc->GetString(5, 2, destSheet));
6731 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(6, 2, destSheet));
6732 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
6733 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
6734 // row 3, strings
6735 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6736 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
6737 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
6738 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("c"), m_pDoc->GetString(4, 3, destSheet));
6739 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("r"), m_pDoc->GetString(5, 3, destSheet));
6740 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(6, 3, destSheet));
6741 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
6742 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
6743 // row 4, rich text
6744 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6745 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
6746 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
6747 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
6748 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
6749 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
6750 pEditObj->GetText(0));
6751 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E5", 5.0, m_pDoc->GetValue(4, 4, destSheet));
6752 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("s"), m_pDoc->GetString(5, 4, destSheet));
6753 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 4, destSheet));
6754 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
6755 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
6756 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
6757 // row 5, formulas
6758 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6759 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
6760 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
6761 getFormula(3, 5, destSheet));
6762 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 67.0, m_pDoc->GetValue(3, 5, destSheet));
6763 if (!bSkipEmpty)
6765 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
6767 else
6768 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6769 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F6", OUString("t"), m_pDoc->GetString(5, 5, destSheet));
6770 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(6, 5, destSheet));
6771 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
6772 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
6773 // row 6, formulas
6774 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
6775 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
6776 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
6777 getFormula(3, 6, destSheet));
6778 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", -7.0, m_pDoc->GetValue(3, 6, destSheet));
6779 if (!bSkipEmpty)
6780 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString(), m_pDoc->GetString(4, 6, destSheet));
6781 else
6782 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
6783 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F7", OUString("u"), m_pDoc->GetString(5, 6, destSheet));
6784 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(6, 6, destSheet));
6785 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
6786 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
6787 // row 7
6788 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
6789 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
6790 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
6791 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
6792 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
6793 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
6795 // check patterns
6796 const SfxPoolItem* pItem = nullptr;
6797 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6798 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
6799 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
6800 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6801 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6802 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
6803 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has a pattern", COL_BLUE,
6804 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6805 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6806 CPPUNIT_ASSERT_MESSAGE("F2 has no pattern", !pItem);
6807 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6808 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
6809 m_pDoc->GetPattern(ScAddress(4, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6810 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6811 if (!bSkipEmpty)
6812 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6814 m_pDoc->GetPattern(ScAddress(5, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6815 CPPUNIT_ASSERT(!pItem);
6816 m_pDoc->GetPattern(ScAddress(5, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6817 CPPUNIT_ASSERT(pItem);
6818 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6819 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6820 CPPUNIT_ASSERT(pItem);
6821 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6822 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6823 CPPUNIT_ASSERT(!pItem);
6824 m_pDoc->GetPattern(ScAddress(5, 6, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6825 CPPUNIT_ASSERT(!pItem);
6827 // check border, left and right borders were transformed to top and bottom borders
6828 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
6829 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
6830 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
6831 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6832 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
6833 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6834 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
6835 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6836 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
6837 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6838 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
6839 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6840 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6841 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6842 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6843 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6844 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
6845 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6846 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
6847 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6848 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
6849 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6850 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
6851 CPPUNIT_ASSERT_MESSAGE("F3 has top border", !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6852 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
6853 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6854 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
6855 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6856 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
6857 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6858 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
6859 CPPUNIT_ASSERT_MESSAGE("G3 has a border", pItem);
6860 CPPUNIT_ASSERT_MESSAGE("G3 has no top border",
6861 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6862 CPPUNIT_ASSERT_MESSAGE("G3 has no bottom border",
6863 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6864 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
6865 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6866 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
6867 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6868 pItem = m_pDoc->GetAttr(ScAddress(5, 3, destSheet), ATTR_BORDER);
6869 CPPUNIT_ASSERT(pItem);
6870 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6871 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6872 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6873 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6874 pItem = m_pDoc->GetAttr(ScAddress(5, 4, destSheet), ATTR_BORDER);
6875 CPPUNIT_ASSERT(pItem);
6876 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6877 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6878 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6879 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6881 // check notes after transposed copy/paste
6882 // check presence of notes
6883 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
6884 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
6885 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
6886 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
6887 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
6888 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
6889 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
6890 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
6891 CPPUNIT_ASSERT_MESSAGE("F2: no note", !m_pDoc->HasNote(5, 1, destSheet));
6892 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
6893 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
6894 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
6895 CPPUNIT_ASSERT_MESSAGE("E3: a note", m_pDoc->HasNote(4, 2, destSheet));
6896 CPPUNIT_ASSERT_MESSAGE("F3: no note", !m_pDoc->HasNote(5, 2, destSheet));
6897 CPPUNIT_ASSERT_MESSAGE("G3: no note", !m_pDoc->HasNote(6, 2, destSheet));
6898 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
6899 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
6900 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
6901 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
6902 CPPUNIT_ASSERT_MESSAGE("G4: no note", !m_pDoc->HasNote(6, 3, destSheet));
6903 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
6904 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
6905 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
6906 CPPUNIT_ASSERT_MESSAGE("F5: no note", !m_pDoc->HasNote(5, 4, destSheet));
6907 CPPUNIT_ASSERT_MESSAGE("G5: no note", !m_pDoc->HasNote(6, 4, destSheet));
6908 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
6909 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
6910 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
6911 CPPUNIT_ASSERT_MESSAGE("F6: no note", !m_pDoc->HasNote(5, 5, destSheet));
6912 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
6913 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
6914 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
6915 CPPUNIT_ASSERT_MESSAGE("E7: no note", !m_pDoc->HasNote(4, 6, destSheet));
6916 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
6917 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
6918 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
6919 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
6920 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
6921 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
6922 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
6924 // check values of notes
6925 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
6926 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A3"), getNote(4, 1, destSheet));
6927 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
6928 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("Note B3"), getNote(4, 2, destSheet));
6929 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C3"), getNote(4, 3, destSheet));
6930 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
6931 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D3"), getNote(4, 4, destSheet));
6932 if (!bSkipEmpty)
6933 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 5, destSheet));
6934 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 3, destSheet));
6936 // check row 16 on src sheet, refs to copied/cut range
6937 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(1, 16, srcSheet));
6938 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), getFormula(2, 16, srcSheet));
6939 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), getFormula(3, 16, srcSheet));
6940 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), getFormula(4, 16, srcSheet));
6941 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), getFormula(5, 16, srcSheet));
6942 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), getFormula(6, 16, srcSheet));
6943 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), getFormula(7, 16, srcSheet));
6944 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), getFormula(8, 16, srcSheet));
6945 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), getFormula(9, 16, srcSheet));
6946 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), getFormula(10, 16, srcSheet));
6948 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6949 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6950 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6951 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6952 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6953 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6954 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6955 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6956 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6957 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6959 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), getFormula(1, 17, srcSheet));
6960 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), getFormula(2, 17, srcSheet));
6961 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), getFormula(3, 17, srcSheet));
6962 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), getFormula(4, 17, srcSheet));
6963 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), getFormula(5, 17, srcSheet));
6964 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), getFormula(6, 17, srcSheet));
6965 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), getFormula(7, 17, srcSheet));
6966 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), getFormula(8, 17, srcSheet));
6967 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), getFormula(9, 17, srcSheet));
6968 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), getFormula(10, 17, srcSheet));
6970 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6971 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6972 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6973 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6974 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6975 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6976 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6977 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6978 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6979 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6981 // Existing references to the destination range must not change
6982 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), getFormula(3, 101, srcSheet));
6983 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), getFormula(3, 102, srcSheet));
6984 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), getFormula(3, 103, srcSheet));
6985 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), getFormula(3, 104, srcSheet));
6986 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), getFormula(3, 105, srcSheet));
6987 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), getFormula(3, 106, srcSheet));
6988 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), getFormula(3, 107, srcSheet));
6989 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), getFormula(4, 101, srcSheet));
6990 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), getFormula(4, 102, srcSheet));
6991 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), getFormula(4, 103, srcSheet));
6992 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), getFormula(4, 104, srcSheet));
6993 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), getFormula(4, 105, srcSheet));
6994 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), getFormula(4, 106, srcSheet));
6995 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), getFormula(4, 107, srcSheet));
6996 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), getFormula(5, 101, srcSheet));
6997 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), getFormula(5, 102, srcSheet));
6998 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), getFormula(5, 103, srcSheet));
6999 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), getFormula(5, 104, srcSheet));
7000 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), getFormula(5, 105, srcSheet));
7001 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), getFormula(5, 106, srcSheet));
7002 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), getFormula(5, 107, srcSheet));
7003 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), getFormula(6, 101, srcSheet));
7004 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), getFormula(6, 102, srcSheet));
7005 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), getFormula(6, 103, srcSheet));
7006 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), getFormula(6, 104, srcSheet));
7007 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), getFormula(6, 105, srcSheet));
7008 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), getFormula(6, 106, srcSheet));
7009 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), getFormula(6, 107, srcSheet));
7010 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), getFormula(7, 101, srcSheet));
7011 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), getFormula(7, 102, srcSheet));
7012 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), getFormula(7, 103, srcSheet));
7013 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), getFormula(7, 104, srcSheet));
7014 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), getFormula(7, 105, srcSheet));
7015 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), getFormula(7, 106, srcSheet));
7016 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), getFormula(7, 107, srcSheet));
7017 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), getFormula(8, 101, srcSheet));
7018 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), getFormula(8, 102, srcSheet));
7019 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), getFormula(8, 103, srcSheet));
7020 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), getFormula(8, 104, srcSheet));
7021 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), getFormula(8, 105, srcSheet));
7022 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), getFormula(8, 106, srcSheet));
7023 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), getFormula(8, 107, srcSheet));
7024 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), getFormula(9, 101, srcSheet));
7025 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), getFormula(9, 102, srcSheet));
7026 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), getFormula(9, 103, srcSheet));
7027 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), getFormula(9, 104, srcSheet));
7028 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), getFormula(9, 105, srcSheet));
7029 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), getFormula(9, 106, srcSheet));
7030 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), getFormula(9, 107, srcSheet));
7032 m_pDoc->DeleteTab(destSheet);
7033 m_pDoc->DeleteTab(srcSheet);
7036 void TestCopyPaste::testTdf142201Row()
7038 const SCTAB nTab = 0;
7039 m_pDoc->InsertTab(nTab, "Test");
7041 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7042 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7043 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7044 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7046 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
7047 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
7048 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
7049 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
7051 // Check precondition
7052 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7053 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7054 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7055 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7057 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7058 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7059 printRange(m_pDoc, aReferencesRange, "References");
7060 printFormula(m_pDoc, 0, 3, nTab);
7061 printFormula(m_pDoc, 0, 4, nTab);
7062 printFormula(m_pDoc, 1, 3, nTab);
7063 printFormula(m_pDoc, 1, 4, nTab);
7065 // Cut A1:A2 to the clip document.
7066 ScDocument aClipDoc(SCDOCMODE_CLIP);
7067 ScRange aSrcRange(0, 0, nTab, 0, 1, nTab);
7068 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7070 // To B7:C7
7071 ScRange aDestRange(1, 6, nTab, 2, 6, nTab);
7072 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7074 // Transpose
7075 ScDocument* pOrigClipDoc = &aClipDoc;
7076 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7077 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7078 aDestMark.SetMarkArea(aDestRange);
7079 // Paste
7080 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7081 true, false, true, false);
7082 printRange(m_pDoc, aReferencesRange, "References after cut");
7083 printFormula(m_pDoc, 0, 3, nTab);
7084 printFormula(m_pDoc, 0, 4, nTab);
7085 printFormula(m_pDoc, 1, 3, nTab);
7086 printFormula(m_pDoc, 1, 4, nTab);
7087 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7088 pTransClip.reset();
7090 printRange(m_pDoc, aReferencesRange, "References after cut transposed");
7091 printFormula(m_pDoc, 0, 3, nTab);
7092 printFormula(m_pDoc, 0, 4, nTab);
7093 printFormula(m_pDoc, 1, 3, nTab);
7094 printFormula(m_pDoc, 1, 4, nTab);
7096 // Check results
7097 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7098 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7099 // Without the fix in place, this would have failed with
7100 // - Expected: 11
7101 // - Actual : 2
7102 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7103 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7105 CPPUNIT_ASSERT_EQUAL(OUString("=B7"), getFormula(0, 3, nTab));
7106 CPPUNIT_ASSERT_EQUAL(OUString("=C7"), getFormula(0, 4, nTab));
7107 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(1, 3, nTab));
7108 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), getFormula(1, 4, nTab));
7111 void TestCopyPaste::testTdf142201ColRel()
7113 const SCTAB nTab = 0;
7114 m_pDoc->InsertTab(nTab, "Test");
7116 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7117 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7118 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7119 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7121 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
7122 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
7123 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
7124 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
7126 // Check precondition
7127 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7128 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7129 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7130 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7132 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7133 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7134 printRange(m_pDoc, aReferencesRange, "References");
7135 printFormula(m_pDoc, 0, 3, nTab);
7136 printFormula(m_pDoc, 0, 4, nTab);
7137 printFormula(m_pDoc, 1, 3, nTab);
7138 printFormula(m_pDoc, 1, 4, nTab);
7140 // Cut values A1:B1 to the clip document.
7141 ScDocument aClipDoc(SCDOCMODE_CLIP);
7142 ScRange aSrcRange(0, 0, nTab, 1, 0, nTab);
7143 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7145 // To B7:B8
7146 ScRange aDestRange(1, 6, nTab, 1, 7, nTab);
7147 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7149 // Transpose
7150 ScDocument* pOrigClipDoc = &aClipDoc;
7151 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7152 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7153 aDestMark.SetMarkArea(aDestRange);
7154 // Paste
7155 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7156 true, false, true, false);
7157 printRange(m_pDoc, aReferencesRange, "References after paste");
7158 printFormula(m_pDoc, 0, 3, nTab);
7159 printFormula(m_pDoc, 0, 4, nTab);
7160 printFormula(m_pDoc, 1, 3, nTab);
7161 printFormula(m_pDoc, 1, 4, nTab);
7162 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7163 pTransClip.reset();
7165 printRange(m_pDoc, aReferencesRange, "References after paste transposed");
7166 printFormula(m_pDoc, 0, 3, nTab);
7167 printFormula(m_pDoc, 0, 4, nTab);
7168 printFormula(m_pDoc, 1, 3, nTab);
7169 printFormula(m_pDoc, 1, 4, nTab);
7171 // Check results
7172 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7173 // Without the fix in place, this would have failed with
7174 // - Expected: 2
7175 // - Actual : 11
7176 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7177 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7178 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7180 CPPUNIT_ASSERT_EQUAL(OUString("=B7"), getFormula(0, 3, nTab));
7181 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(0, 4, nTab));
7182 CPPUNIT_ASSERT_EQUAL(OUString("=B8"), getFormula(1, 3, nTab));
7183 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), getFormula(1, 4, nTab));
7186 void TestCopyPaste::testTdf142201ColAbs()
7188 const SCTAB nTab = 0;
7189 m_pDoc->InsertTab(nTab, "Test");
7191 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7192 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7193 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7194 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7196 m_pDoc->SetString(0, 3, nTab, "=$A$1"); // A4
7197 m_pDoc->SetString(0, 4, nTab, "=$A$2"); // A5
7198 m_pDoc->SetString(1, 3, nTab, "=$B$1"); // B4
7199 m_pDoc->SetString(1, 4, nTab, "=$B$2"); // B5
7201 // Check precondition
7202 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7203 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7204 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7205 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7207 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7208 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7209 printRange(m_pDoc, aReferencesRange, "References");
7210 printFormula(m_pDoc, 0, 3, nTab);
7211 printFormula(m_pDoc, 0, 4, nTab);
7212 printFormula(m_pDoc, 1, 3, nTab);
7213 printFormula(m_pDoc, 1, 4, nTab);
7215 // Cut values A1:B1 to the clip document.
7216 ScDocument aClipDoc(SCDOCMODE_CLIP);
7217 ScRange aSrcRange(0, 0, nTab, 1, 0, nTab);
7218 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7220 // To B7:B8
7221 ScRange aDestRange(1, 6, nTab, 1, 7, nTab);
7222 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7224 // Transpose
7225 ScDocument* pOrigClipDoc = &aClipDoc;
7226 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7227 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7228 aDestMark.SetMarkArea(aDestRange);
7229 // Paste
7230 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7231 true, false, true, false);
7232 printRange(m_pDoc, aReferencesRange, "References after paste");
7233 printFormula(m_pDoc, 0, 3, nTab);
7234 printFormula(m_pDoc, 0, 4, nTab);
7235 printFormula(m_pDoc, 1, 3, nTab);
7236 printFormula(m_pDoc, 1, 4, nTab);
7237 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7238 pTransClip.reset();
7240 printRange(m_pDoc, aReferencesRange, "References after paste transposed");
7241 printFormula(m_pDoc, 0, 3, nTab);
7242 printFormula(m_pDoc, 0, 4, nTab);
7243 printFormula(m_pDoc, 1, 3, nTab);
7244 printFormula(m_pDoc, 1, 4, nTab);
7246 // Check results
7247 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7248 // Without the fix in place, this would have failed with
7249 // - Expected: 2
7250 // - Actual : 11
7251 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7252 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7253 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7255 CPPUNIT_ASSERT_EQUAL(OUString("=$B$7"), getFormula(0, 3, nTab));
7256 CPPUNIT_ASSERT_EQUAL(OUString("=$A$2"), getFormula(0, 4, nTab));
7257 CPPUNIT_ASSERT_EQUAL(OUString("=$B$8"), getFormula(1, 3, nTab));
7258 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), getFormula(1, 4, nTab));
7261 void TestCopyPaste::checkReferencedCutRangesRowIntitial(const SCTAB nSrcTab, const OUString& rDesc)
7263 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 3, 2, nSrcTab), rDesc.toUtf8() + ": Source");
7264 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(1, 1, nSrcTab));
7265 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 1, nSrcTab));
7266 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(3, 1, nSrcTab));
7267 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7268 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7269 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7271 // Guards
7272 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7273 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7274 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7275 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7276 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7277 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7278 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7279 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7280 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7281 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7282 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7283 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7284 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7285 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7286 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7287 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7288 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7289 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7290 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7291 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7292 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7293 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7294 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7295 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7296 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7297 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7298 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7299 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7300 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(20, 0, nSrcTab)); // U1
7301 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(21, 0, nSrcTab)); // V1
7302 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(22, 0, nSrcTab)); // W1
7303 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), getFormula(23, 0, nSrcTab)); // X1
7304 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), getFormula(24, 0, nSrcTab)); // Y1
7305 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(20, 1, nSrcTab)); // U2
7306 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), getFormula(24, 1, nSrcTab)); // Y2
7307 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(20, 2, nSrcTab)); // U3
7308 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), getFormula(24, 2, nSrcTab)); // Y3
7309 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), getFormula(20, 3, nSrcTab)); // U4
7310 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), getFormula(21, 3, nSrcTab)); // B4
7311 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), getFormula(22, 3, nSrcTab)); // W4
7312 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), getFormula(23, 3, nSrcTab)); // X4
7313 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), getFormula(24, 3, nSrcTab)); // Y4
7315 for (int i = 10; i < 20; ++i)
7316 for (int j = 0; j < 10; ++j)
7318 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(j, i, nSrcTab));
7319 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(j, i, nSrcTab));
7322 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7323 rDesc.toUtf8() + ": Relative references");
7324 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), getFormula(0, 20, nSrcTab)); // A21
7325 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), getFormula(1, 20, nSrcTab)); // B21
7326 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), getFormula(2, 20, nSrcTab)); // C21
7327 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), getFormula(0, 21, nSrcTab)); // A22
7328 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), getFormula(1, 21, nSrcTab)); // B22
7329 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), getFormula(2, 21, nSrcTab)); // C22
7330 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7331 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7332 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7333 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7334 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7335 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7337 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 30, nSrcTab, 2, 31, nSrcTab),
7338 rDesc.toUtf8() + ": Absolute references");
7339 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), getFormula(0, 30, nSrcTab)); // A31
7340 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), getFormula(1, 30, nSrcTab)); // B31
7341 CPPUNIT_ASSERT_EQUAL(OUString("=$D$2"), getFormula(2, 30, nSrcTab)); // C31
7342 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), getFormula(0, 31, nSrcTab)); // A32
7343 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), getFormula(1, 31, nSrcTab)); // B32
7344 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), getFormula(2, 31, nSrcTab)); // C32
7345 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7346 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7347 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7348 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7349 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7350 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7352 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2"), getRangeByName("Range_B2"));
7353 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
7354 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$2"), getRangeByName("Range_D2"));
7355 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3"));
7356 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
7357 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3"));
7358 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$2"), getRangeByName("Range_B2_D2"));
7359 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3"));
7360 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3"));
7361 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
7363 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 40, nSrcTab, 2, 41, nSrcTab),
7364 rDesc.toUtf8() + ": Absolute ranges");
7365 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), getFormula(0, 40, nSrcTab)); // A41
7366 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), getFormula(1, 40, nSrcTab)); // B41
7367 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), getFormula(2, 40, nSrcTab)); // C41
7368 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), getFormula(0, 41, nSrcTab)); // A42
7369 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), getFormula(1, 41, nSrcTab)); // B42
7370 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), getFormula(2, 41, nSrcTab)); // C42
7371 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7372 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7373 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7374 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7375 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7376 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7378 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 50, nSrcTab, 2, 51, nSrcTab),
7379 rDesc.toUtf8() + ": Relative ranges");
7380 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 50, nSrcTab)); // A51
7381 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 50, nSrcTab)); // B51
7382 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(2, 50, nSrcTab)); // C51
7383 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 51, nSrcTab)); // A52
7384 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 51, nSrcTab)); // B52
7385 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(2, 51, nSrcTab)); // C52
7386 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7387 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7388 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7389 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7390 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7391 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7393 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 60, nSrcTab, 2, 61, nSrcTab),
7394 rDesc.toUtf8() + ": Relative sum");
7395 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), getFormula(0, 60, nSrcTab)); // A61
7396 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), getFormula(1, 60, nSrcTab)); // B61
7397 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), getFormula(2, 60, nSrcTab)); // C61
7398 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(0, 61, nSrcTab)); // A62
7399 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(1, 61, nSrcTab)); // B62
7400 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(2, 61, nSrcTab)); // C62
7401 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7402 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7403 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7404 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7405 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7406 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7408 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 70, nSrcTab, 2, 71, nSrcTab),
7409 rDesc.toUtf8() + ": Absolute sum");
7410 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), getFormula(0, 70, nSrcTab)); // A71
7411 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), getFormula(1, 70, nSrcTab)); // B71
7412 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), getFormula(2, 70, nSrcTab)); // C71
7413 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(0, 71, nSrcTab)); // A72
7414 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(1, 71, nSrcTab)); // B72
7415 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(2, 71, nSrcTab)); // C72
7416 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7417 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7418 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7419 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7420 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7421 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7423 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 80, nSrcTab, 2, 81, nSrcTab),
7424 rDesc.toUtf8() + ": Relative range sum");
7425 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(0, 80, nSrcTab)); // A81
7426 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(1, 80, nSrcTab)); // B81
7427 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(2, 80, nSrcTab)); // C81
7428 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(0, 81, nSrcTab)); // A82
7429 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(1, 81, nSrcTab)); // B82
7430 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(2, 81, nSrcTab)); // C82
7431 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7432 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7433 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7434 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7435 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7436 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7438 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 90, nSrcTab, 2, 91, nSrcTab),
7439 rDesc.toUtf8() + ": Absolute sum");
7440 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(0, 90, nSrcTab)); // A91
7441 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(1, 90, nSrcTab)); // B91
7442 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(2, 90, nSrcTab)); // C91
7443 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(0, 91, nSrcTab)); // A92
7444 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(1, 91, nSrcTab)); // B92
7445 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(2, 91, nSrcTab)); // C92
7446 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 90, nSrcTab));
7447 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 90, nSrcTab));
7448 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 90, nSrcTab));
7449 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 91, nSrcTab));
7450 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 91, nSrcTab));
7451 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 91, nSrcTab));
7453 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 100, nSrcTab, 2, 101, nSrcTab),
7454 rDesc.toUtf8() + ": Relative range sum");
7455 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(0, 100, nSrcTab)); // A101
7456 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(1, 100, nSrcTab)); // B101
7457 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(2, 100, nSrcTab)); // C101
7458 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(0, 101, nSrcTab)); // A102
7459 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(1, 101, nSrcTab)); // B102
7460 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(2, 101, nSrcTab)); // C102
7461 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 100, nSrcTab));
7462 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 100, nSrcTab));
7463 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 100, nSrcTab));
7464 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 101, nSrcTab));
7465 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 101, nSrcTab));
7466 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 101, nSrcTab));
7469 void TestCopyPaste::executeReferencedCutRangesRow(const bool bTransposed, const SCTAB nSrcTab,
7470 const SCTAB nDestTab, const bool bUndo,
7471 std::unique_ptr<ScUndoCut>& pUndoCut,
7472 std::unique_ptr<ScUndoPaste>& pUndoPaste)
7474 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
7476 for (int i = 0; i < nSrcTab; ++i)
7477 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7478 m_pDoc->InsertTab(nSrcTab, "Test");
7480 m_pDoc->SetValue(1, 1, nSrcTab, 01.0); // B2 \.
7481 m_pDoc->SetValue(2, 1, nSrcTab, 11.0); // C2 | cut
7482 m_pDoc->SetValue(3, 1, nSrcTab, 21.0); // D2 /
7483 m_pDoc->SetValue(1, 2, nSrcTab, 02.0); // B3
7484 m_pDoc->SetValue(2, 2, nSrcTab, 12.0); // C3
7485 m_pDoc->SetValue(3, 2, nSrcTab, 22.0); // D3
7486 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 3, 2, nSrcTab), "Source");
7488 // Guard values
7489 m_pDoc->SetValue(0, 0, nSrcTab, 1000.0); // A1
7490 m_pDoc->SetValue(1, 0, nSrcTab, 1001.0); // B1
7491 m_pDoc->SetValue(2, 0, nSrcTab, 1002.0); // C1
7492 m_pDoc->SetValue(3, 0, nSrcTab, 1003.0); // D1
7493 m_pDoc->SetValue(4, 0, nSrcTab, 1004.0); // E1
7494 m_pDoc->SetValue(0, 1, nSrcTab, 1010.0); // A2
7495 m_pDoc->SetValue(4, 1, nSrcTab, 1014.0); // E2
7496 m_pDoc->SetValue(0, 2, nSrcTab, 1020.0); // A3
7497 m_pDoc->SetValue(4, 2, nSrcTab, 1024.0); // E3
7498 m_pDoc->SetValue(0, 3, nSrcTab, 1030.0); // A4
7499 m_pDoc->SetValue(1, 3, nSrcTab, 1031.0); // B4
7500 m_pDoc->SetValue(2, 3, nSrcTab, 1032.0); // C4
7501 m_pDoc->SetValue(3, 3, nSrcTab, 1033.0); // D4
7502 m_pDoc->SetValue(4, 3, nSrcTab, 1034.0); // E4
7504 m_pDoc->SetString(20, 0, nSrcTab, "=A1"); // U1
7505 m_pDoc->SetString(21, 0, nSrcTab, "=B1"); // V1
7506 m_pDoc->SetString(22, 0, nSrcTab, "=C1"); // W1
7507 m_pDoc->SetString(23, 0, nSrcTab, "=D1"); // X1
7508 m_pDoc->SetString(24, 0, nSrcTab, "=E1"); // Y1
7509 m_pDoc->SetString(20, 1, nSrcTab, "=A2"); // U2
7510 m_pDoc->SetString(24, 1, nSrcTab, "=E2"); // Y2
7511 m_pDoc->SetString(20, 2, nSrcTab, "=A3"); // U3
7512 m_pDoc->SetString(24, 2, nSrcTab, "=E3"); // Y3
7513 m_pDoc->SetString(20, 3, nSrcTab, "=A4"); // U4
7514 m_pDoc->SetString(21, 3, nSrcTab, "=B4"); // B4
7515 m_pDoc->SetString(22, 3, nSrcTab, "=C4"); // W4
7516 m_pDoc->SetString(23, 3, nSrcTab, "=D4"); // X4
7517 m_pDoc->SetString(24, 3, nSrcTab, "=E4"); // Y4
7519 // Cell position is used for ranges relative to current position
7520 ScAddress cellA1(0, 0, nSrcTab);
7521 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2", cellA1, "$Test.$B$2"));
7522 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2", cellA1, "$Test.$C$2"));
7523 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_D2", cellA1, "$Test.$D$2"));
7524 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3", cellA1, "$Test.$B$3"));
7525 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C3", cellA1, "$Test.$C$3"));
7526 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_D3", cellA1, "$Test.$D$3"));
7527 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_D2", cellA1, "$Test.$B$2:$D$2"));
7528 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3_D3", cellA1, "$Test.$B$3:$D$3"));
7529 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_D3", cellA1, "$Test.$B$2:$D$3"));
7530 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("RelRange_Cm20_R0", ScAddress(1, 21, nSrcTab), "B2"));
7532 m_pDoc->SetString(0, 20, nSrcTab, "=B2"); // A21
7533 m_pDoc->SetString(1, 20, nSrcTab, "=C2"); // B21
7534 m_pDoc->SetString(2, 20, nSrcTab, "=D2"); // C21
7535 m_pDoc->SetString(0, 21, nSrcTab, "=B3"); // A22
7536 m_pDoc->SetString(1, 21, nSrcTab, "=C3"); // B22
7537 m_pDoc->SetString(2, 21, nSrcTab, "=D3"); // C22
7539 m_pDoc->SetString(0, 30, nSrcTab, "=$B$2"); // A31
7540 m_pDoc->SetString(1, 30, nSrcTab, "=$C$2"); // B31
7541 m_pDoc->SetString(2, 30, nSrcTab, "=$D$2"); // C31
7542 m_pDoc->SetString(0, 31, nSrcTab, "=$B$3"); // A32
7543 m_pDoc->SetString(1, 31, nSrcTab, "=$C$3"); // B32
7544 m_pDoc->SetString(2, 31, nSrcTab, "=$D$3"); // C32
7546 m_pDoc->SetString(0, 40, nSrcTab, "=Range_B2"); // A41
7547 m_pDoc->SetString(1, 40, nSrcTab, "=Range_C2"); // B41
7548 m_pDoc->SetString(2, 40, nSrcTab, "=Range_D2"); // C41
7549 m_pDoc->SetString(0, 41, nSrcTab, "=Range_B3"); // A42
7550 m_pDoc->SetString(1, 41, nSrcTab, "=Range_C3"); // B42
7551 m_pDoc->SetString(2, 41, nSrcTab, "=Range_D3"); // C42
7553 m_pDoc->SetString(0, 50, nSrcTab, "=RelRange_Cm20_R0"); // A51
7554 m_pDoc->SetString(1, 50, nSrcTab, "=RelRange_Cm20_R0"); // B51
7555 m_pDoc->SetString(2, 50, nSrcTab, "=RelRange_Cm20_R0"); // C51
7556 m_pDoc->SetString(0, 51, nSrcTab, "=RelRange_Cm20_R0"); // A52
7557 m_pDoc->SetString(1, 51, nSrcTab, "=RelRange_Cm20_R0"); // B52
7558 m_pDoc->SetString(2, 51, nSrcTab, "=RelRange_Cm20_R0"); // C52
7560 m_pDoc->SetString(0, 60, nSrcTab, "=SUM(B2:D2)"); // A61
7561 m_pDoc->SetString(1, 60, nSrcTab, "=SUM(B2:D2)"); // B61
7562 m_pDoc->SetString(2, 60, nSrcTab, "=SUM(B2:D2)"); // C61
7563 m_pDoc->SetString(0, 61, nSrcTab, "=SUM(B3:D3)"); // A62
7564 m_pDoc->SetString(1, 61, nSrcTab, "=SUM(B3:D3)"); // B62
7565 m_pDoc->SetString(2, 61, nSrcTab, "=SUM(B3:D3)"); // C62
7567 m_pDoc->SetString(0, 70, nSrcTab, "=SUM($B$2:$D$2)"); // A71
7568 m_pDoc->SetString(1, 70, nSrcTab, "=SUM($B$2:$D$2)"); // B71
7569 m_pDoc->SetString(2, 70, nSrcTab, "=SUM($B$2:$D$2)"); // C71
7570 m_pDoc->SetString(0, 71, nSrcTab, "=SUM($B$3:$D$3)"); // A72
7571 m_pDoc->SetString(1, 71, nSrcTab, "=SUM($B$3:$D$3)"); // B72
7572 m_pDoc->SetString(2, 71, nSrcTab, "=SUM($B$3:$D$3)"); // C72
7574 m_pDoc->SetString(0, 80, nSrcTab, "=SUM(Range_B2_D2)"); // A81
7575 m_pDoc->SetString(1, 80, nSrcTab, "=SUM(Range_B2_D2)"); // B81
7576 m_pDoc->SetString(2, 80, nSrcTab, "=SUM(Range_B2_D2)"); // C81
7577 m_pDoc->SetString(0, 81, nSrcTab, "=SUM(Range_B3_D3)"); // A82
7578 m_pDoc->SetString(1, 81, nSrcTab, "=SUM(Range_B3_D3)"); // B82
7579 m_pDoc->SetString(2, 81, nSrcTab, "=SUM(Range_B3_D3)"); // C82
7581 m_pDoc->SetString(0, 90, nSrcTab, "=SUM($B$2:$D$3)"); // A91
7582 m_pDoc->SetString(1, 90, nSrcTab, "=SUM($B$2:$D$3)"); // B91
7583 m_pDoc->SetString(2, 90, nSrcTab, "=SUM($B$2:$D$3)"); // C91
7584 m_pDoc->SetString(0, 91, nSrcTab, "=SUM($B$2:$D$3)"); // A92
7585 m_pDoc->SetString(1, 91, nSrcTab, "=SUM($B$2:$D$3)"); // B92
7586 m_pDoc->SetString(2, 91, nSrcTab, "=SUM($B$2:$D$3)"); // C92
7588 m_pDoc->SetString(0, 100, nSrcTab, "=SUM(Range_B2_D3)"); // A101
7589 m_pDoc->SetString(1, 100, nSrcTab, "=SUM(Range_B2_D3)"); // B101
7590 m_pDoc->SetString(2, 100, nSrcTab, "=SUM(Range_B2_D3)"); // C101
7591 m_pDoc->SetString(0, 101, nSrcTab, "=SUM(Range_B2_D3)"); // A102
7592 m_pDoc->SetString(1, 101, nSrcTab, "=SUM(Range_B2_D3)"); // B102
7593 m_pDoc->SetString(2, 101, nSrcTab, "=SUM(Range_B2_D3)"); // C102
7595 // Check precondition
7596 checkReferencedCutRangesRowIntitial(nSrcTab, "Initial");
7598 // Cut values B2:D2 to the clip document.
7599 ScDocument aClipDoc(SCDOCMODE_CLIP);
7600 ScRange aSrcRange(1, 1, nSrcTab, 3, 1, nSrcTab);
7601 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
7602 aSrcMark.SetMarkArea(aSrcRange);
7604 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, bUndo));
7606 for (int i = nSrcTab + 1; i < nDestTab; ++i)
7607 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7609 if (nSrcTab < nDestTab)
7610 m_pDoc->InsertTab(nDestTab, "Dest");
7611 else if (nSrcTab > nDestTab)
7612 m_pDoc->RenameTab(nDestTab, "Dest");
7614 int nTabCount = m_pDoc->GetTableCount();
7615 for (int i = nTabCount; i < nTabCount + 2; ++i)
7616 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7617 nTabCount = m_pDoc->GetTableCount();
7619 InsertDeleteFlags aFlags(InsertDeleteFlags::ALL);
7621 ScDocumentUniquePtr pPasteUndoDoc;
7622 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
7623 std::unique_ptr<ScRefUndoData> pUndoData;
7625 ScRange aDestRange;
7626 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7628 if (bTransposed)
7630 // To C12:C14
7631 aDestRange = ScRange(2, 11, nDestTab, 2, 13, nDestTab);
7632 aDestMark.SetMarkArea(aDestRange);
7634 if (bUndo)
7635 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
7636 pUndoData);
7638 // Transpose
7639 ScDocument* pOrigClipDoc = &aClipDoc;
7640 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7641 aClipDoc.TransposeClip(pTransClip.get(), aFlags, false, true);
7642 // Paste
7643 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
7644 pTransClip.get(), true, false, true, false);
7645 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7646 "Relative references after copy");
7648 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, pPasteRefUndoDoc.get());
7649 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7650 "Relative references after UpdateTranspose");
7651 pTransClip.reset();
7653 else
7655 // To C12:E12
7656 aDestRange = ScRange(2, 11, nDestTab, 4, 11, nDestTab);
7658 aDestMark.SetMarkArea(aDestRange);
7660 if (bUndo)
7661 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
7662 pUndoData);
7664 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc, true,
7665 false, false, false);
7668 if (bUndo)
7669 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
7670 pUndoPaste, bTransposed);
7673 void TestCopyPaste::checkReferencedCutRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab)
7675 // Cut B2:D2 and pasted to C12:E12
7677 OUString aFBase("=");
7678 if (nSrcTab != nDestTab)
7679 aFBase += "Dest.";
7681 // Precondition
7682 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab));
7683 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 11, nDestTab));
7684 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(4, 11, nDestTab));
7685 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7686 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7687 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7689 // Guards
7690 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7691 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7692 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7693 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7694 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7695 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7696 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7697 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7698 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7699 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7700 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7701 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7702 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7703 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7704 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7705 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7706 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7707 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7708 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7709 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7710 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7711 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7712 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7713 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7714 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7715 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7716 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7717 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7718 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(20, 0, nSrcTab)); // U1
7719 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(21, 0, nSrcTab)); // V1
7720 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(22, 0, nSrcTab)); // W1
7721 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), getFormula(23, 0, nSrcTab)); // X1
7722 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), getFormula(24, 0, nSrcTab)); // Y1
7723 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(20, 1, nSrcTab)); // U2
7724 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), getFormula(24, 1, nSrcTab)); // Y2
7725 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(20, 2, nSrcTab)); // U3
7726 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), getFormula(24, 2, nSrcTab)); // Y3
7727 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), getFormula(20, 3, nSrcTab)); // U4
7728 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), getFormula(21, 3, nSrcTab)); // B4
7729 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), getFormula(22, 3, nSrcTab)); // W4
7730 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), getFormula(23, 3, nSrcTab)); // X4
7731 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), getFormula(24, 3, nSrcTab)); // Y4
7733 // Note: Values (mostly) remain the same
7735 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 20, nSrcTab)); // A21
7736 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), getFormula(1, 20, nSrcTab)); // B21
7737 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), getFormula(2, 20, nSrcTab)); // C21
7738 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), getFormula(0, 21, nSrcTab)); // A22
7739 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), getFormula(1, 21, nSrcTab)); // B22
7740 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), getFormula(2, 21, nSrcTab)); // C22
7741 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7742 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7743 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7744 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7745 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7746 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7748 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), getFormula(0, 30, nSrcTab)); // A31
7749 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$D$12"), getFormula(1, 30, nSrcTab)); // B31
7750 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$E$12"), getFormula(2, 30, nSrcTab)); // C31
7751 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), getFormula(0, 31, nSrcTab)); // A32
7752 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), getFormula(1, 31, nSrcTab)); // B32
7753 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), getFormula(2, 31, nSrcTab)); // C32
7754 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7755 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7756 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7757 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7758 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7759 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7761 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
7762 getRangeByName("Range_B2"));
7763 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$D$12") : OUString("$Test.$D$12"),
7764 getRangeByName("Range_C2"));
7765 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$E$12") : OUString("$Test.$E$12"),
7766 getRangeByName("Range_D2"));
7767 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3")); // no change
7768 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3")); // no change
7769 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3")); // no change
7770 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$E$12")
7771 : OUString("$Test.$C$12:$E$12"),
7772 getRangeByName("Range_B2_D2"));
7773 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3")); // no change
7774 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3")); // no change
7775 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0")); // no change
7777 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), getFormula(0, 40, nSrcTab)); // A41
7778 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), getFormula(1, 40, nSrcTab)); // B41
7779 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), getFormula(2, 40, nSrcTab)); // C41
7780 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), getFormula(0, 41, nSrcTab)); // A42
7781 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), getFormula(1, 41, nSrcTab)); // B42
7782 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), getFormula(2, 41, nSrcTab)); // C42
7783 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7784 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7785 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7786 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7787 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7788 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7790 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 50, nSrcTab)); // A51
7791 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 50, nSrcTab)); // B51
7792 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(2, 50, nSrcTab)); // C51
7793 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 51, nSrcTab)); // A52
7794 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 51, nSrcTab)); // B52
7795 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(2, 51, nSrcTab)); // C52
7796 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7797 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7798 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7799 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7800 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7801 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7803 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7804 : OUString("=SUM(C12:E12)"),
7805 getFormula(0, 60, nSrcTab)); // A61
7806 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7807 : OUString("=SUM(C12:E12)"),
7808 getFormula(1, 60, nSrcTab)); // B61
7809 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7810 : OUString("=SUM(C12:E12)"),
7811 getFormula(2, 60, nSrcTab)); // C61
7812 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(0, 61, nSrcTab)); // A62
7813 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(1, 61, nSrcTab)); // B62
7814 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(2, 61, nSrcTab)); // C62
7815 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7816 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7817 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7818 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7819 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7820 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7822 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7823 : OUString("=SUM($C$12:$E$12)"),
7824 getFormula(0, 70, nSrcTab)); // A71
7825 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7826 : OUString("=SUM($C$12:$E$12)"),
7827 getFormula(1, 70, nSrcTab)); // B71
7828 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7829 : OUString("=SUM($C$12:$E$12)"),
7830 getFormula(2, 70, nSrcTab)); // C71
7831 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(0, 71, nSrcTab)); // A72
7832 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(1, 71, nSrcTab)); // B72
7833 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(2, 71, nSrcTab)); // C72
7834 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7835 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7836 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7837 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7838 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7839 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7841 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(0, 80, nSrcTab)); // A81
7842 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(1, 80, nSrcTab)); // B81
7843 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(2, 80, nSrcTab)); // C81
7844 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(0, 81, nSrcTab)); // A82
7845 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(1, 81, nSrcTab)); // B82
7846 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(2, 81, nSrcTab)); // C82
7847 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7848 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7849 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7850 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7851 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7852 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7854 // no change in formula after cut
7855 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(0, 90, nSrcTab)); // A91
7856 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(1, 90, nSrcTab)); // B91
7857 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(2, 90, nSrcTab)); // C91
7858 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(0, 91, nSrcTab)); // A92
7859 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(1, 91, nSrcTab)); // B92
7860 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(2, 91, nSrcTab)); // C92
7861 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab)); // only 2nd row
7862 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab)); // only 2nd row
7863 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 90, nSrcTab)); // only 2nd row
7864 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab)); // only 2nd row
7865 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab)); // only 2nd row
7866 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 91, nSrcTab)); // only 2nd row
7868 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(0, 100, nSrcTab)); // A101
7869 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(1, 100, nSrcTab)); // B101
7870 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(2, 100, nSrcTab)); // C101
7871 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(0, 101, nSrcTab)); // A102
7872 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(1, 101, nSrcTab)); // B102
7873 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(2, 101, nSrcTab)); // C102
7874 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab)); // only 2nd row
7875 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab)); // only 2nd row
7876 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 100, nSrcTab)); // only 2nd row
7877 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab)); // only 2nd row
7878 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab)); // only 2nd row
7879 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 101, nSrcTab)); // only 2nd row
7882 void TestCopyPaste::checkReferencedCutTransposedRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab)
7884 // Cut B2:D2 and pasted transposed to C12:C14
7886 OUString aFBase("=");
7887 if (nSrcTab != nDestTab)
7888 aFBase += "Dest.";
7890 // Precondition
7891 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab));
7892 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 12, nDestTab));
7893 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 13, nDestTab));
7894 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7895 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7896 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7898 // Guards
7899 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7900 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7901 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7902 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7903 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7904 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7905 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7906 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7907 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7908 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7909 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7910 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7911 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7912 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7913 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7914 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7915 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7916 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7917 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7918 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7919 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7920 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7921 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7922 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7923 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7924 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7925 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7926 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7927 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(20, 0, nSrcTab)); // U1
7928 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(21, 0, nSrcTab)); // V1
7929 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(22, 0, nSrcTab)); // W1
7930 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), getFormula(23, 0, nSrcTab)); // X1
7931 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), getFormula(24, 0, nSrcTab)); // Y1
7932 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(20, 1, nSrcTab)); // U2
7933 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), getFormula(24, 1, nSrcTab)); // Y2
7934 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(20, 2, nSrcTab)); // U3
7935 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), getFormula(24, 2, nSrcTab)); // Y3
7936 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), getFormula(20, 3, nSrcTab)); // U4
7937 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), getFormula(21, 3, nSrcTab)); // B4
7938 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), getFormula(22, 3, nSrcTab)); // W4
7939 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), getFormula(23, 3, nSrcTab)); // X4
7940 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), getFormula(24, 3, nSrcTab)); // Y4
7942 // Note: Values (mostly) remain the same
7944 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7945 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7946 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7947 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7948 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7949 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7951 // ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 20, nSrcTab), "C12", "Wrong reference");
7952 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 20, nSrcTab));
7953 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), getFormula(1, 20, nSrcTab));
7954 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), getFormula(2, 20, nSrcTab));
7955 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), getFormula(0, 21, nSrcTab));
7956 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), getFormula(1, 21, nSrcTab));
7957 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), getFormula(2, 21, nSrcTab));
7959 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7960 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7961 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7962 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7963 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7964 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7966 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), getFormula(0, 30, nSrcTab));
7967 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$13"), getFormula(1, 30, nSrcTab));
7968 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$14"), getFormula(2, 30, nSrcTab));
7969 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), getFormula(0, 31, nSrcTab));
7970 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), getFormula(1, 31, nSrcTab));
7971 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), getFormula(2, 31, nSrcTab));
7973 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
7974 getRangeByName("Range_B2"));
7975 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$13") : OUString("$Test.$C$13"),
7976 getRangeByName("Range_C2"));
7977 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$14") : OUString("$Test.$C$14"),
7978 getRangeByName("Range_D2"));
7979 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3")); // no change
7980 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3")); // no change
7981 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3")); // no change
7982 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$C$14")
7983 : OUString("$Test.$C$12:$C$14"),
7984 getRangeByName("Range_B2_D2"));
7985 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3")); // no change
7986 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3")); // no change
7987 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0")); // no change
7989 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), getFormula(0, 40, nSrcTab)); // A41
7990 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), getFormula(1, 40, nSrcTab)); // B41
7991 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), getFormula(2, 40, nSrcTab)); // C41
7992 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), getFormula(0, 41, nSrcTab)); // A42
7993 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), getFormula(1, 41, nSrcTab)); // B42
7994 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), getFormula(2, 41, nSrcTab)); // C42
7995 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7996 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7997 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7998 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7999 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8000 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
8002 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 50, nSrcTab)); // A51
8003 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 50, nSrcTab)); // B51
8004 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(2, 50, nSrcTab)); // C51
8005 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 51, nSrcTab)); // A52
8006 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 51, nSrcTab)); // B52
8007 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(2, 51, nSrcTab)); // C52
8008 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8009 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
8010 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
8011 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
8012 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8013 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
8015 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8016 : OUString("=SUM(C12:C14)"),
8017 getFormula(0, 60, nSrcTab)); // A61
8018 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8019 : OUString("=SUM(C12:C14)"),
8020 getFormula(1, 60, nSrcTab)); // B61
8021 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8022 : OUString("=SUM(C12:C14)"),
8023 getFormula(2, 60, nSrcTab)); // C61
8024 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(0, 61, nSrcTab)); // A62
8025 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(1, 61, nSrcTab)); // B62
8026 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), getFormula(2, 61, nSrcTab)); // C62
8027 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8028 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
8029 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
8030 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
8031 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8032 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
8034 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8035 : OUString("=SUM($C$12:$C$14)"),
8036 getFormula(0, 70, nSrcTab)); // A71
8037 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8038 : OUString("=SUM($C$12:$C$14)"),
8039 getFormula(1, 70, nSrcTab)); // B71
8040 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8041 : OUString("=SUM($C$12:$C$14)"),
8042 getFormula(2, 70, nSrcTab)); // C71
8043 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(0, 71, nSrcTab)); // A72
8044 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(1, 71, nSrcTab)); // B72
8045 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), getFormula(2, 71, nSrcTab)); // C72
8046 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8047 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
8048 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
8049 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
8050 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8051 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
8053 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(0, 80, nSrcTab)); // A81
8054 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(1, 80, nSrcTab)); // B81
8055 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), getFormula(2, 80, nSrcTab)); // C81
8056 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(0, 81, nSrcTab)); // A82
8057 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(1, 81, nSrcTab)); // B82
8058 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), getFormula(2, 81, nSrcTab)); // C82
8059 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8060 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
8061 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
8062 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
8063 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8064 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
8066 // no change in formula after cut
8067 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(0, 90, nSrcTab)); // A91
8068 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(1, 90, nSrcTab)); // B91
8069 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(2, 90, nSrcTab)); // C91
8070 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(0, 91, nSrcTab)); // A92
8071 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(1, 91, nSrcTab)); // B92
8072 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), getFormula(2, 91, nSrcTab)); // C92
8073 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab)); // only 2nd row
8074 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab)); // only 2nd row
8075 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 90, nSrcTab)); // only 2nd row
8076 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab)); // only 2nd row
8077 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab)); // only 2nd row
8078 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 91, nSrcTab)); // only 2nd row
8080 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(0, 100, nSrcTab)); // A101
8081 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(1, 100, nSrcTab)); // B101
8082 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(2, 100, nSrcTab)); // C101
8083 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(0, 101, nSrcTab)); // A102
8084 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(1, 101, nSrcTab)); // B102
8085 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"), getFormula(2, 101, nSrcTab)); // C102
8086 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab)); // only 2nd row
8087 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab)); // only 2nd row
8088 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 100, nSrcTab)); // only 2nd row
8089 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab)); // only 2nd row
8090 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab)); // only 2nd row
8091 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 101, nSrcTab)); // only 2nd row
8094 void TestCopyPaste::testReferencedCutRangesRow()
8096 const SCTAB nSrcTab = 0;
8097 const SCTAB nDestTab = 2;
8098 std::unique_ptr<ScUndoCut> pUndoCut;
8099 std::unique_ptr<ScUndoPaste> pUndoPaste;
8100 executeReferencedCutRangesRow(false, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8101 checkReferencedCutRangesRow(nSrcTab, nDestTab);
8103 pUndoPaste->Undo();
8104 pUndoCut->Undo();
8105 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8107 pUndoCut->Redo();
8108 pUndoPaste->Redo();
8109 checkReferencedCutRangesRow(nSrcTab, nDestTab);
8111 pUndoPaste->Undo();
8112 pUndoCut->Undo();
8113 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8115 pUndoPaste.reset();
8116 pUndoCut.reset();
8118 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
8119 m_pDoc->DeleteTab(i - 1);
8122 // tdf#142201
8123 void TestCopyPaste::testReferencedCutTransposedRangesRowTab0To0()
8125 checkReferencedCutTransposedRangesRowUndo(0, 0);
8128 // tdf#142201
8129 void TestCopyPaste::testReferencedCutTransposedRangesRowTab0To1()
8131 checkReferencedCutTransposedRangesRowUndo(0, 1);
8134 // tdf#142201
8135 void TestCopyPaste::testReferencedCutTransposedRangesRowTab1To3()
8137 checkReferencedCutTransposedRangesRowUndo(1, 3);
8140 // tdf#142201
8141 void TestCopyPaste::testReferencedCutTransposedRangesRowTab3To1()
8143 checkReferencedCutTransposedRangesRowUndo(3, 1);
8146 // tdf#142201
8147 void TestCopyPaste::checkReferencedCutTransposedRangesRowUndo(const SCTAB nSrcTab,
8148 const SCTAB nDestTab)
8150 std::unique_ptr<ScUndoCut> pUndoCut;
8151 std::unique_ptr<ScUndoPaste> pUndoPaste;
8152 executeReferencedCutRangesRow(true, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8153 checkReferencedCutTransposedRangesRow(nSrcTab, nDestTab);
8155 pUndoPaste->Undo();
8156 pUndoCut->Undo();
8157 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8159 pUndoCut->Redo();
8160 pUndoPaste->Redo();
8161 checkReferencedCutTransposedRangesRow(nSrcTab, nDestTab);
8163 pUndoPaste->Undo();
8164 pUndoCut->Undo();
8165 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8167 pUndoPaste.reset();
8168 pUndoCut.reset();
8170 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
8171 m_pDoc->DeleteTab(i - 1);
8174 void TestCopyPaste::checkReferencedCutRangesColIntitial(const SCTAB nSrcTab, const SCTAB nDestTab,
8175 const OUString& rDesc)
8177 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 2, 3, nSrcTab), rDesc.toUtf8() + ": Source");
8178 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(1, 1, nSrcTab));
8179 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 2, nSrcTab));
8180 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(1, 3, nSrcTab));
8181 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab));
8182 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
8183 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab));
8185 // Guards
8186 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8187 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8188 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8189 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8190 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8191 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8192 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8193 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8194 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8195 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8196 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8197 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8198 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8199 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8200 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8201 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8202 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8203 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8204 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8205 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8206 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8207 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8208 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8209 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8210 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8211 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8212 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8213 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8214 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(20, 0, nSrcTab)); // U1
8215 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(20, 1, nSrcTab)); // U2
8216 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(20, 2, nSrcTab)); // U3
8217 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), getFormula(20, 3, nSrcTab)); // U4
8218 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), getFormula(20, 4, nSrcTab)); // U5
8219 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(21, 0, nSrcTab)); // V1
8220 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), getFormula(21, 4, nSrcTab)); // V5
8221 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(22, 0, nSrcTab)); // W1
8222 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(22, 4, nSrcTab)); // W5
8223 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), getFormula(23, 0, nSrcTab)); // X1
8224 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), getFormula(23, 1, nSrcTab)); // X2
8225 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), getFormula(23, 2, nSrcTab)); // X3
8226 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), getFormula(23, 3, nSrcTab)); // X4
8227 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), getFormula(23, 4, nSrcTab)); // X5
8229 for (int i = 10; i < 20; ++i)
8230 for (int j = 0; j < 10; ++j)
8232 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(j, i, nSrcTab));
8233 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(j, i, nSrcTab));
8236 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 1, 22, nSrcTab),
8237 rDesc.toUtf8() + ": Relative references");
8238 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), getFormula(0, 20, nSrcTab)); // A21
8239 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), getFormula(0, 21, nSrcTab)); // A22
8240 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), getFormula(0, 22, nSrcTab)); // A23
8241 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), getFormula(1, 20, nSrcTab)); // B21
8242 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), getFormula(1, 21, nSrcTab)); // B22
8243 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), getFormula(1, 22, nSrcTab)); // B23
8244 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8245 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8246 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8247 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8248 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8249 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8251 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 30, nSrcTab, 1, 32, nSrcTab),
8252 rDesc.toUtf8() + ": Absolute references");
8253 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), getFormula(0, 30, nSrcTab)); // A31
8254 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), getFormula(0, 31, nSrcTab)); // A32
8255 CPPUNIT_ASSERT_EQUAL(OUString("=$B$4"), getFormula(0, 32, nSrcTab)); // A33
8256 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), getFormula(1, 30, nSrcTab)); // B31
8257 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), getFormula(1, 31, nSrcTab)); // B32
8258 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), getFormula(1, 32, nSrcTab)); // B33
8259 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8260 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8261 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8262 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8263 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8264 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8266 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2"), getRangeByName("Range_B2"));
8267 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3"));
8268 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$4"), getRangeByName("Range_B4"));
8269 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8270 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8271 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8272 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$B$4"), getRangeByName("Range_B2_B4"));
8273 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8274 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8275 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8277 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 40, nSrcTab, 1, 42, nSrcTab),
8278 rDesc.toUtf8() + ": Absolute ranges");
8279 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), getFormula(0, 40, nSrcTab)); // A41
8280 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), getFormula(0, 41, nSrcTab)); // A42
8281 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), getFormula(0, 42, nSrcTab)); // A43
8282 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), getFormula(1, 40, nSrcTab)); // B41
8283 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), getFormula(1, 41, nSrcTab)); // B42
8284 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), getFormula(1, 42, nSrcTab)); // B43
8285 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8286 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8287 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8288 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8289 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8290 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8292 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 50, nSrcTab, 1, 52, nSrcTab),
8293 rDesc.toUtf8() + ": Relative ranges");
8294 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 50, nSrcTab)); // A51
8295 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 51, nSrcTab)); // A52
8296 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 52, nSrcTab)); // A53
8297 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 50, nSrcTab)); // B51
8298 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 51, nSrcTab)); // B52
8299 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 52, nSrcTab)); // B53
8300 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8301 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8302 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8303 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8304 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8305 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8307 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 60, nSrcTab, 1, 62, nSrcTab),
8308 rDesc.toUtf8() + ": Relative sum");
8309 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), getFormula(0, 60, nSrcTab)); // A61
8310 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), getFormula(0, 61, nSrcTab)); // A62
8311 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), getFormula(0, 62, nSrcTab)); // A63
8312 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 60, nSrcTab)); // B61
8313 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 61, nSrcTab)); // B62
8314 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 62, nSrcTab)); // B63
8315 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8316 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8317 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8318 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8319 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8320 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8322 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 70, nSrcTab, 1, 72, nSrcTab),
8323 rDesc.toUtf8() + ": Absolute sum");
8324 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), getFormula(0, 70, nSrcTab)); // A71
8325 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), getFormula(0, 71, nSrcTab)); // A72
8326 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), getFormula(0, 72, nSrcTab)); // A73
8327 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 70, nSrcTab)); // B71
8328 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 71, nSrcTab)); // B72
8329 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 72, nSrcTab)); // B73
8330 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8331 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8332 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8333 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8334 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8335 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8337 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 80, nSrcTab, 1, 82, nSrcTab),
8338 rDesc.toUtf8() + ": Relative range sum");
8339 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 80, nSrcTab)); // A81
8340 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 81, nSrcTab)); // A82
8341 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 82, nSrcTab)); // A83
8342 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 80, nSrcTab)); // B81
8343 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 81, nSrcTab)); // B82
8344 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 82, nSrcTab)); // B83
8345 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8346 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8347 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8348 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8349 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8350 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8352 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 90, nSrcTab, 1, 92, nSrcTab),
8353 rDesc.toUtf8() + ": Absolute sum");
8354 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 90, nSrcTab)); // A91
8355 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 91, nSrcTab)); // A92
8356 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 92, nSrcTab)); // A93
8357 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 90, nSrcTab)); // B91
8358 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 91, nSrcTab)); // B92
8359 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 92, nSrcTab)); // B93
8360 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 90, nSrcTab));
8361 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 91, nSrcTab));
8362 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 92, nSrcTab));
8363 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 90, nSrcTab));
8364 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 91, nSrcTab));
8365 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 92, nSrcTab));
8367 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 100, nSrcTab, 1, 102, nSrcTab),
8368 rDesc.toUtf8() + ": Relative range sum");
8369 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 100, nSrcTab)); // A101
8370 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 101, nSrcTab)); // A102
8371 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 102, nSrcTab)); // A103
8372 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 100, nSrcTab)); // B101
8373 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 101, nSrcTab)); // B102
8374 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 102, nSrcTab)); // B103
8375 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 100, nSrcTab));
8376 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 101, nSrcTab));
8377 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 102, nSrcTab));
8378 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 100, nSrcTab));
8379 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 101, nSrcTab));
8380 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 102, nSrcTab));
8382 // References to the dest range
8383 OUString aFBase("=");
8384 if (nSrcTab != nDestTab)
8385 aFBase += "Dest.";
8387 // Existing references to the destination range must not change
8388 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 112, nSrcTab));
8389 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), getFormula(0, 113, nSrcTab));
8390 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), getFormula(0, 114, nSrcTab));
8391 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), getFormula(1, 112, nSrcTab));
8392 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), getFormula(1, 113, nSrcTab));
8393 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), getFormula(1, 114, nSrcTab));
8394 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), getFormula(2, 112, nSrcTab));
8395 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), getFormula(2, 113, nSrcTab));
8396 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), getFormula(2, 114, nSrcTab));
8399 void TestCopyPaste::executeReferencedCutRangesCol(const bool bTransposed, const SCTAB nSrcTab,
8400 const SCTAB nDestTab, const bool bUndo,
8401 std::unique_ptr<ScUndoCut>& pUndoCut,
8402 std::unique_ptr<ScUndoPaste>& pUndoPaste)
8404 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
8406 for (int i = 0; i < nSrcTab; ++i)
8407 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8408 m_pDoc->InsertTab(nSrcTab, "Test");
8410 m_pDoc->SetValue(1, 1, nSrcTab, 01.0); // B2 \.
8411 m_pDoc->SetValue(1, 2, nSrcTab, 11.0); // B3 | cut
8412 m_pDoc->SetValue(1, 3, nSrcTab, 21.0); // B4 /
8413 m_pDoc->SetValue(2, 1, nSrcTab, 02.0); // C2
8414 m_pDoc->SetValue(2, 2, nSrcTab, 12.0); // C3
8415 m_pDoc->SetValue(2, 3, nSrcTab, 22.0); // C4
8416 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 2, 3, nSrcTab), "Source");
8418 // Guard values
8419 m_pDoc->SetValue(0, 0, nSrcTab, 1000.0); // A1
8420 m_pDoc->SetValue(0, 1, nSrcTab, 1001.0); // A2
8421 m_pDoc->SetValue(0, 2, nSrcTab, 1002.0); // A3
8422 m_pDoc->SetValue(0, 3, nSrcTab, 1003.0); // A4
8423 m_pDoc->SetValue(0, 4, nSrcTab, 1004.0); // A5
8424 m_pDoc->SetValue(1, 0, nSrcTab, 1010.0); // B1
8425 m_pDoc->SetValue(1, 4, nSrcTab, 1014.0); // B5
8426 m_pDoc->SetValue(2, 0, nSrcTab, 1020.0); // C1
8427 m_pDoc->SetValue(2, 4, nSrcTab, 1024.0); // C5
8428 m_pDoc->SetValue(3, 0, nSrcTab, 1030.0); // D1
8429 m_pDoc->SetValue(3, 1, nSrcTab, 1031.0); // D2
8430 m_pDoc->SetValue(3, 2, nSrcTab, 1032.0); // D3
8431 m_pDoc->SetValue(3, 3, nSrcTab, 1033.0); // D4
8432 m_pDoc->SetValue(3, 4, nSrcTab, 1034.0); // D5
8434 m_pDoc->SetString(20, 0, nSrcTab, "=A1"); // U1
8435 m_pDoc->SetString(20, 1, nSrcTab, "=A2"); // U2
8436 m_pDoc->SetString(20, 2, nSrcTab, "=A3"); // U3
8437 m_pDoc->SetString(20, 3, nSrcTab, "=A4"); // U4
8438 m_pDoc->SetString(20, 4, nSrcTab, "=A5"); // U5
8439 m_pDoc->SetString(21, 0, nSrcTab, "=B1"); // V1
8440 m_pDoc->SetString(21, 4, nSrcTab, "=B5"); // V5
8441 m_pDoc->SetString(22, 0, nSrcTab, "=C1"); // W1
8442 m_pDoc->SetString(22, 4, nSrcTab, "=C5"); // W5
8443 m_pDoc->SetString(23, 0, nSrcTab, "=D1"); // X1
8444 m_pDoc->SetString(23, 1, nSrcTab, "=D2"); // X2
8445 m_pDoc->SetString(23, 2, nSrcTab, "=D3"); // X3
8446 m_pDoc->SetString(23, 3, nSrcTab, "=D4"); // X4
8447 m_pDoc->SetString(23, 4, nSrcTab, "=D5"); // X5
8449 // Cell position is used for ranges relative to current position
8450 ScAddress cellA1(0, 0, nSrcTab);
8451 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2", cellA1, "$Test.$B$2"));
8452 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3", cellA1, "$Test.$B$3"));
8453 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B4", cellA1, "$Test.$B$4"));
8454 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2", cellA1, "$Test.$C$2"));
8455 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C3", cellA1, "$Test.$C$3"));
8456 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C4", cellA1, "$Test.$C$4"));
8457 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_B4", cellA1, "$Test.$B$2:$B$4"));
8458 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2_C4", cellA1, "$Test.$C$2:$C$4"));
8459 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_C4", cellA1, "$Test.$B$2:$C$4"));
8460 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("RelRange_Cm20_R0", ScAddress(1, 21, nSrcTab), "B2"));
8462 m_pDoc->SetString(0, 20, nSrcTab, "=B2"); // A21
8463 m_pDoc->SetString(0, 21, nSrcTab, "=B3"); // A22
8464 m_pDoc->SetString(0, 22, nSrcTab, "=B4"); // A23
8465 m_pDoc->SetString(1, 20, nSrcTab, "=C2"); // B21
8466 m_pDoc->SetString(1, 21, nSrcTab, "=C3"); // B22
8467 m_pDoc->SetString(1, 22, nSrcTab, "=C4"); // B23
8469 m_pDoc->SetString(0, 30, nSrcTab, "=$B$2"); // A31
8470 m_pDoc->SetString(0, 31, nSrcTab, "=$B$3"); // A32
8471 m_pDoc->SetString(0, 32, nSrcTab, "=$B$4"); // A33
8472 m_pDoc->SetString(1, 30, nSrcTab, "=$C$2"); // B31
8473 m_pDoc->SetString(1, 31, nSrcTab, "=$C$3"); // B32
8474 m_pDoc->SetString(1, 32, nSrcTab, "=$C$4"); // B33
8476 m_pDoc->SetString(0, 40, nSrcTab, "=Range_B2"); // A41
8477 m_pDoc->SetString(0, 41, nSrcTab, "=Range_B3"); // A42
8478 m_pDoc->SetString(0, 42, nSrcTab, "=Range_B4"); // A43
8479 m_pDoc->SetString(1, 40, nSrcTab, "=Range_C2"); // B41
8480 m_pDoc->SetString(1, 41, nSrcTab, "=Range_C3"); // B42
8481 m_pDoc->SetString(1, 42, nSrcTab, "=Range_C4"); // B43
8483 m_pDoc->SetString(0, 50, nSrcTab, "=RelRange_Cm20_R0"); // A51
8484 m_pDoc->SetString(0, 51, nSrcTab, "=RelRange_Cm20_R0"); // A52
8485 m_pDoc->SetString(0, 52, nSrcTab, "=RelRange_Cm20_R0"); // A53
8486 m_pDoc->SetString(1, 50, nSrcTab, "=RelRange_Cm20_R0"); // B51
8487 m_pDoc->SetString(1, 51, nSrcTab, "=RelRange_Cm20_R0"); // B52
8488 m_pDoc->SetString(1, 52, nSrcTab, "=RelRange_Cm20_R0"); // B53
8490 m_pDoc->SetString(0, 60, nSrcTab, "=SUM(B2:B4"); // A61
8491 m_pDoc->SetString(0, 61, nSrcTab, "=SUM(B2:B4"); // A62
8492 m_pDoc->SetString(0, 62, nSrcTab, "=SUM(B2:B4"); // A63
8493 m_pDoc->SetString(1, 60, nSrcTab, "=SUM(C2:C4"); // B61
8494 m_pDoc->SetString(1, 61, nSrcTab, "=SUM(C2:C4"); // B62
8495 m_pDoc->SetString(1, 62, nSrcTab, "=SUM(C2:C4"); // B63
8497 m_pDoc->SetString(0, 70, nSrcTab, "=SUM($B$2:$B$4"); // A71
8498 m_pDoc->SetString(0, 71, nSrcTab, "=SUM($B$2:$B$4"); // A72
8499 m_pDoc->SetString(0, 72, nSrcTab, "=SUM($B$2:$B$4"); // A73
8500 m_pDoc->SetString(1, 70, nSrcTab, "=SUM($C$2:$C$4"); // B71
8501 m_pDoc->SetString(1, 71, nSrcTab, "=SUM($C$2:$C$4"); // B72
8502 m_pDoc->SetString(1, 72, nSrcTab, "=SUM($C$2:$C$4"); // B73
8504 m_pDoc->SetString(0, 80, nSrcTab, "=SUM(Range_B2_B4)"); // A81
8505 m_pDoc->SetString(0, 81, nSrcTab, "=SUM(Range_B2_B4)"); // A82
8506 m_pDoc->SetString(0, 82, nSrcTab, "=SUM(Range_B2_B4)"); // A83
8507 m_pDoc->SetString(1, 80, nSrcTab, "=SUM(Range_C2_C4)"); // B81
8508 m_pDoc->SetString(1, 81, nSrcTab, "=SUM(Range_C2_C4)"); // B82
8509 m_pDoc->SetString(1, 82, nSrcTab, "=SUM(Range_C2_C4)"); // B83
8511 m_pDoc->SetString(0, 90, nSrcTab, "=SUM($B$2:$C$4"); // A91
8512 m_pDoc->SetString(0, 91, nSrcTab, "=SUM($B$2:$C$4"); // A92
8513 m_pDoc->SetString(0, 92, nSrcTab, "=SUM($B$2:$C$4"); // A93
8514 m_pDoc->SetString(1, 90, nSrcTab, "=SUM($B$2:$C$4"); // B91
8515 m_pDoc->SetString(1, 91, nSrcTab, "=SUM($B$2:$C$4"); // B92
8516 m_pDoc->SetString(1, 92, nSrcTab, "=SUM($B$2:$C$4"); // B93
8518 m_pDoc->SetString(0, 100, nSrcTab, "=SUM(Range_B2_C4"); // A101
8519 m_pDoc->SetString(0, 101, nSrcTab, "=SUM(Range_B2_C4"); // A102
8520 m_pDoc->SetString(0, 102, nSrcTab, "=SUM(Range_B2_C4"); // A103
8521 m_pDoc->SetString(1, 100, nSrcTab, "=SUM(Range_B2_C4"); // B101
8522 m_pDoc->SetString(1, 101, nSrcTab, "=SUM(Range_B2_C4"); // B102
8523 m_pDoc->SetString(1, 102, nSrcTab, "=SUM(Range_B2_C4"); // B103
8525 for (int i = nSrcTab + 1; i < nDestTab; ++i)
8526 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8528 if (nSrcTab < nDestTab)
8529 m_pDoc->InsertTab(nDestTab, "Dest");
8530 else if (nSrcTab > nDestTab)
8531 m_pDoc->RenameTab(nDestTab, "Dest");
8533 int nTabCount = m_pDoc->GetTableCount();
8534 for (int i = nTabCount; i < nTabCount + 2; ++i)
8535 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8536 nTabCount = m_pDoc->GetTableCount();
8538 // References to the dest range
8539 OUString aFBase("=");
8540 if (nSrcTab != nDestTab)
8541 aFBase += "Dest.";
8543 m_pDoc->SetString(0, 112, nSrcTab, OUString(aFBase + "C12"));
8544 m_pDoc->SetString(0, 113, nSrcTab, OUString(aFBase + "C13"));
8545 m_pDoc->SetString(0, 114, nSrcTab, OUString(aFBase + "C14"));
8546 m_pDoc->SetString(1, 112, nSrcTab, OUString(aFBase + "D12"));
8547 m_pDoc->SetString(1, 113, nSrcTab, OUString(aFBase + "D13"));
8548 m_pDoc->SetString(1, 114, nSrcTab, OUString(aFBase + "D14"));
8549 m_pDoc->SetString(2, 112, nSrcTab, OUString(aFBase + "E12"));
8550 m_pDoc->SetString(2, 113, nSrcTab, OUString(aFBase + "E13"));
8551 m_pDoc->SetString(2, 114, nSrcTab, OUString(aFBase + "E14"));
8553 // Check precondition
8554 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "Initial");
8556 // Cut values B2:B4 to the clip document.
8557 ScDocument aClipDoc(SCDOCMODE_CLIP);
8558 ScRange aSrcRange(1, 1, nSrcTab, 1, 3, nSrcTab);
8559 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
8560 aSrcMark.SetMarkArea(aSrcRange);
8562 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, bUndo));
8564 InsertDeleteFlags aFlags(InsertDeleteFlags::ALL);
8566 ScDocumentUniquePtr pPasteUndoDoc;
8567 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
8568 std::unique_ptr<ScRefUndoData> pUndoData;
8570 ScRange aDestRange;
8571 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
8573 if (bTransposed)
8575 // To C12:E12
8576 aDestRange = ScRange(2, 11, nDestTab, 4, 11, nDestTab);
8577 aDestMark.SetMarkArea(aDestRange);
8579 if (bUndo)
8580 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
8581 pUndoData);
8583 // Transpose
8584 ScDocument* pOrigClipDoc = &aClipDoc;
8585 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
8586 aClipDoc.TransposeClip(pTransClip.get(), aFlags, false, true);
8587 // Paste
8588 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
8589 pTransClip.get(), true, false, true, false);
8590 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
8591 "Relative references after copy");
8593 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, pPasteRefUndoDoc.get());
8594 lcl_printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
8595 "Relative references after UpdateTranspose");
8596 pTransClip.reset();
8598 else
8600 // To C12:C14
8601 aDestRange = ScRange(2, 11, nDestTab, 2, 13, nDestTab);
8602 // aDestMark = ScMarkData(m_pDoc->GetSheetLimits());
8604 aDestMark.SetMarkArea(aDestRange);
8606 if (bUndo)
8607 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
8608 pUndoData);
8610 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc, true,
8611 false, false, false);
8614 if (bUndo)
8615 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
8616 pUndoPaste, bTransposed);
8619 void TestCopyPaste::checkReferencedCutRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab)
8621 // Cut B2:B4 and pasted to C12:C14
8623 OUString aFBase("=");
8624 if (nSrcTab != nDestTab)
8625 aFBase += "Dest.";
8627 // Precondition
8628 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab)); // C12
8629 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 12, nDestTab)); // C13
8630 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 13, nDestTab)); // C14
8631 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab)); // C2
8632 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab)); // C3
8633 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
8635 // Guards
8636 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8637 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8638 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8639 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8640 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8641 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8642 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8643 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8644 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8645 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8646 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8647 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8648 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8649 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8650 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8651 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8652 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8653 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8654 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8655 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8656 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8657 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8658 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8659 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8660 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8661 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8662 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8663 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8664 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(20, 0, nSrcTab)); // U1
8665 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(20, 1, nSrcTab)); // U2
8666 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(20, 2, nSrcTab)); // U3
8667 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), getFormula(20, 3, nSrcTab)); // U4
8668 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), getFormula(20, 4, nSrcTab)); // U5
8669 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(21, 0, nSrcTab)); // V1
8670 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), getFormula(21, 4, nSrcTab)); // V5
8671 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(22, 0, nSrcTab)); // W1
8672 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(22, 4, nSrcTab)); // W5
8673 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), getFormula(23, 0, nSrcTab)); // X1
8674 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), getFormula(23, 1, nSrcTab)); // X2
8675 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), getFormula(23, 2, nSrcTab)); // X3
8676 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), getFormula(23, 3, nSrcTab)); // X4
8677 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), getFormula(23, 4, nSrcTab)); // X5
8679 // Note: Values (mostly) remain the same
8681 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 20, nSrcTab)); // A21
8682 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), getFormula(0, 21, nSrcTab)); // A22
8683 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), getFormula(0, 22, nSrcTab)); // A23
8684 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), getFormula(1, 20, nSrcTab)); // B21
8685 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), getFormula(1, 21, nSrcTab)); // B22
8686 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), getFormula(1, 22, nSrcTab)); // B23
8687 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8688 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8689 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8690 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8691 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8692 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8694 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), getFormula(0, 30, nSrcTab)); // A31
8695 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$13"), getFormula(0, 31, nSrcTab)); // A32
8696 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$14"), getFormula(0, 32, nSrcTab)); // A33
8697 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), getFormula(1, 30, nSrcTab)); // B31
8698 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), getFormula(1, 31, nSrcTab)); // B32
8699 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), getFormula(1, 32, nSrcTab)); // B33
8700 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8701 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8702 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8703 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8704 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8705 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8707 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8708 getRangeByName("Range_B2"));
8709 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$13") : OUString("$Test.$C$13"),
8710 getRangeByName("Range_B3"));
8711 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$14") : OUString("$Test.$C$14"),
8712 getRangeByName("Range_B4"));
8713 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8714 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8715 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8716 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$C$14")
8717 : OUString("$Test.$C$12:$C$14"),
8718 getRangeByName("Range_B2_B4"));
8719 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8720 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8721 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8723 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), getFormula(0, 40, nSrcTab)); // A41
8724 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), getFormula(0, 41, nSrcTab)); // A42
8725 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), getFormula(0, 42, nSrcTab)); // A43
8726 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), getFormula(1, 40, nSrcTab)); // B41
8727 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), getFormula(1, 41, nSrcTab)); // B42
8728 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), getFormula(1, 42, nSrcTab)); // B43
8729 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8730 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8731 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8732 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8733 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8734 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8736 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 50, nSrcTab)); // A51
8737 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 51, nSrcTab)); // A52
8738 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 52, nSrcTab)); // A53
8739 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 50, nSrcTab)); // B51
8740 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 51, nSrcTab)); // B52
8741 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 52, nSrcTab)); // B53
8742 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8743 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8744 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8745 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8746 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8747 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8749 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8750 : OUString("=SUM(C12:C14)"),
8751 getFormula(0, 60, nSrcTab)); // A61
8752 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8753 : OUString("=SUM(C12:C14)"),
8754 getFormula(0, 61, nSrcTab)); // A62
8755 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8756 : OUString("=SUM(C12:C14)"),
8757 getFormula(0, 62, nSrcTab)); // A63
8758 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 60, nSrcTab)); // B61
8759 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 61, nSrcTab)); // B62
8760 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 62, nSrcTab)); // B63
8761 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8762 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8763 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8764 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8765 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8766 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8768 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8769 : OUString("=SUM($C$12:$C$14)"),
8770 getFormula(0, 70, nSrcTab)); // A71
8771 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8772 : OUString("=SUM($C$12:$C$14)"),
8773 getFormula(0, 71, nSrcTab)); // A72
8774 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8775 : OUString("=SUM($C$12:$C$14)"),
8776 getFormula(0, 72, nSrcTab)); // A73
8777 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 70, nSrcTab)); // B71
8778 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 71, nSrcTab)); // B72
8779 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 72, nSrcTab)); // B73
8780 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8781 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8782 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8783 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8784 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8785 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8787 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 80, nSrcTab)); // A81
8788 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 81, nSrcTab)); // A82
8789 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 82, nSrcTab)); // A83
8790 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 80, nSrcTab)); // B81
8791 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 81, nSrcTab)); // B82
8792 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 82, nSrcTab)); // B83
8793 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8794 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8795 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8796 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8797 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8798 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8800 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 90, nSrcTab)); // A91
8801 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 91, nSrcTab)); // A92
8802 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 92, nSrcTab)); // A93
8803 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 90, nSrcTab)); // B91
8804 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 91, nSrcTab)); // B92
8805 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 92, nSrcTab)); // B93
8806 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab));
8807 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab));
8808 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 92, nSrcTab));
8809 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab));
8810 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab));
8811 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 92, nSrcTab));
8813 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 100, nSrcTab)); // A101
8814 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 101, nSrcTab)); // A102
8815 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 102, nSrcTab)); // A103
8816 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 100, nSrcTab)); // B101
8817 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 101, nSrcTab)); // B102
8818 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 102, nSrcTab)); // B103
8819 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab));
8820 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab));
8821 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 102, nSrcTab));
8822 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab));
8823 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab));
8824 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 102, nSrcTab));
8826 // Existing references to the destination range must not change
8827 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 112, nSrcTab));
8828 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), getFormula(0, 113, nSrcTab));
8829 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), getFormula(0, 114, nSrcTab));
8830 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), getFormula(1, 112, nSrcTab));
8831 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), getFormula(1, 113, nSrcTab));
8832 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), getFormula(1, 114, nSrcTab));
8833 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), getFormula(2, 112, nSrcTab));
8834 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), getFormula(2, 113, nSrcTab));
8835 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), getFormula(2, 114, nSrcTab));
8838 void TestCopyPaste::checkReferencedCutTransposedRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab)
8840 // Cut B2:D2 and pasted transposed to C12:E12
8842 OUString aFBase("=");
8843 if (nSrcTab != nDestTab)
8844 aFBase += "Dest.";
8846 // Precondition
8847 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab)); // C12
8848 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 11, nDestTab)); // D12
8849 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(4, 11, nDestTab)); // E12
8850 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab)); // C2
8851 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab)); // C3
8852 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
8854 // Guards
8855 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8856 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8857 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8858 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8859 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8860 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8861 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8862 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8863 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8864 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8865 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8866 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8867 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8868 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8869 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8870 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8871 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8872 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8873 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8874 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8875 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8876 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8877 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8878 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8879 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8880 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8881 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8882 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8883 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(20, 0, nSrcTab)); // U1
8884 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(20, 1, nSrcTab)); // U2
8885 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(20, 2, nSrcTab)); // U3
8886 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), getFormula(20, 3, nSrcTab)); // U4
8887 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), getFormula(20, 4, nSrcTab)); // U5
8888 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(21, 0, nSrcTab)); // V1
8889 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), getFormula(21, 4, nSrcTab)); // V5
8890 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(22, 0, nSrcTab)); // W1
8891 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), getFormula(22, 4, nSrcTab)); // W5
8892 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), getFormula(23, 0, nSrcTab)); // X1
8893 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), getFormula(23, 1, nSrcTab)); // X2
8894 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), getFormula(23, 2, nSrcTab)); // X3
8895 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), getFormula(23, 3, nSrcTab)); // X4
8896 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), getFormula(23, 4, nSrcTab)); // X5
8898 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 20, nSrcTab)); // A21
8899 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), getFormula(0, 21, nSrcTab)); // A22
8900 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), getFormula(0, 22, nSrcTab)); // A23
8901 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), getFormula(1, 20, nSrcTab)); // B21
8902 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), getFormula(1, 21, nSrcTab)); // B22
8903 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), getFormula(1, 22, nSrcTab)); // B23
8904 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8905 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8906 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8907 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8908 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8909 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8911 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), getFormula(0, 30, nSrcTab)); // A31
8912 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$D$12"), getFormula(0, 31, nSrcTab)); // A32
8913 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$E$12"), getFormula(0, 32, nSrcTab)); // A33
8914 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), getFormula(1, 30, nSrcTab)); // B31
8915 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), getFormula(1, 31, nSrcTab)); // B32
8916 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), getFormula(1, 32, nSrcTab)); // B33
8917 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8918 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8919 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8920 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8921 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8922 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8924 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8925 getRangeByName("Range_B2"));
8926 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$D$12") : OUString("$Test.$D$12"),
8927 getRangeByName("Range_B3"));
8928 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$E$12") : OUString("$Test.$E$12"),
8929 getRangeByName("Range_B4"));
8930 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8931 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8932 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8933 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$E$12")
8934 : OUString("$Test.$C$12:$E$12"),
8935 getRangeByName("Range_B2_B4"));
8936 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8937 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8938 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8940 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), getFormula(0, 40, nSrcTab)); // A41
8941 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), getFormula(0, 41, nSrcTab)); // A42
8942 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), getFormula(0, 42, nSrcTab)); // A43
8943 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), getFormula(1, 40, nSrcTab)); // B41
8944 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), getFormula(1, 41, nSrcTab)); // B42
8945 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), getFormula(1, 42, nSrcTab)); // B43
8946 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8947 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8948 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8949 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8950 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8951 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8953 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 50, nSrcTab)); // A51
8954 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 51, nSrcTab)); // A52
8955 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(0, 52, nSrcTab)); // A53
8956 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 50, nSrcTab)); // B51
8957 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 51, nSrcTab)); // B52
8958 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), getFormula(1, 52, nSrcTab)); // B53
8959 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8960 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8961 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8962 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8963 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8964 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8966 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
8967 : OUString("=SUM(C12:E12)"),
8968 getFormula(0, 60, nSrcTab)); // A61
8969 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
8970 : OUString("=SUM(C12:E12)"),
8971 getFormula(0, 61, nSrcTab)); // A62
8972 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
8973 : OUString("=SUM(C12:E12)"),
8974 getFormula(0, 62, nSrcTab)); // A63
8975 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 60, nSrcTab)); // B61
8976 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 61, nSrcTab)); // B62
8977 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), getFormula(1, 62, nSrcTab)); // B63
8978 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8979 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8980 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8981 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8982 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8983 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8985 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
8986 : OUString("=SUM($C$12:$E$12)"),
8987 getFormula(0, 70, nSrcTab)); // A71
8988 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
8989 : OUString("=SUM($C$12:$E$12)"),
8990 getFormula(0, 71, nSrcTab)); // A72
8991 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
8992 : OUString("=SUM($C$12:$E$12)"),
8993 getFormula(0, 72, nSrcTab)); // A73
8994 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 70, nSrcTab)); // B71
8995 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 71, nSrcTab)); // B72
8996 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), getFormula(1, 72, nSrcTab)); // B73
8997 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8998 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8999 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
9000 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
9001 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
9002 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
9004 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 80, nSrcTab)); // A81
9005 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 81, nSrcTab)); // A82
9006 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), getFormula(0, 82, nSrcTab)); // A83
9007 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 80, nSrcTab)); // B81
9008 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 81, nSrcTab)); // B82
9009 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), getFormula(1, 82, nSrcTab)); // B83
9010 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
9011 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
9012 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
9013 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
9014 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
9015 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
9017 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 90, nSrcTab)); // A91
9018 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 91, nSrcTab)); // A92
9019 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(0, 92, nSrcTab)); // A93
9020 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 90, nSrcTab)); // B91
9021 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 91, nSrcTab)); // B92
9022 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), getFormula(1, 92, nSrcTab)); // B93
9023 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab));
9024 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab));
9025 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 92, nSrcTab));
9026 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab));
9027 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab));
9028 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 92, nSrcTab));
9030 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 100, nSrcTab)); // A101
9031 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 101, nSrcTab)); // A102
9032 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(0, 102, nSrcTab)); // A103
9033 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 100, nSrcTab)); // B101
9034 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 101, nSrcTab)); // B102
9035 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"), getFormula(1, 102, nSrcTab)); // B103
9036 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab));
9037 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab));
9038 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 102, nSrcTab));
9039 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab));
9040 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab));
9041 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 102, nSrcTab));
9043 // Existing references to the destination range must not change
9044 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), getFormula(0, 112, nSrcTab));
9045 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), getFormula(0, 113, nSrcTab));
9046 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), getFormula(0, 114, nSrcTab));
9047 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), getFormula(1, 112, nSrcTab));
9048 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), getFormula(1, 113, nSrcTab));
9049 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), getFormula(1, 114, nSrcTab));
9050 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), getFormula(2, 112, nSrcTab));
9051 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), getFormula(2, 113, nSrcTab));
9052 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), getFormula(2, 114, nSrcTab));
9055 void TestCopyPaste::testReferencedCutRangesCol()
9057 const SCTAB nSrcTab = 0;
9058 const SCTAB nDestTab = 2;
9059 std::unique_ptr<ScUndoCut> pUndoCut;
9060 std::unique_ptr<ScUndoPaste> pUndoPaste;
9061 executeReferencedCutRangesCol(false, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
9062 checkReferencedCutRangesCol(nSrcTab, nDestTab);
9064 pUndoPaste->Undo();
9065 pUndoCut->Undo();
9066 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9068 pUndoCut->Redo();
9069 pUndoPaste->Redo();
9070 checkReferencedCutRangesCol(nSrcTab, nDestTab);
9072 pUndoPaste->Undo();
9073 pUndoCut->Undo();
9074 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9076 pUndoPaste.reset();
9077 pUndoCut.reset();
9079 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
9080 m_pDoc->DeleteTab(i - 1);
9083 // tdf#142201
9084 void TestCopyPaste::testReferencedCutTransposedRangesColTab0To0()
9086 checkReferencedCutTransposedRangesColUndo(0, 0);
9089 // tdf#142201
9090 void TestCopyPaste::testReferencedCutTransposedRangesColTab0To1()
9092 checkReferencedCutTransposedRangesColUndo(0, 1);
9095 // tdf#142201
9096 void TestCopyPaste::testReferencedCutTransposedRangesColTab1To3()
9098 checkReferencedCutTransposedRangesColUndo(1, 3);
9101 // tdf#142201
9102 void TestCopyPaste::testReferencedCutTransposedRangesColTab3To1()
9104 checkReferencedCutTransposedRangesColUndo(3, 1);
9107 // tdf#142201
9108 void TestCopyPaste::checkReferencedCutTransposedRangesColUndo(const SCTAB nSrcTab,
9109 const SCTAB nDestTab)
9111 std::unique_ptr<ScUndoCut> pUndoCut;
9112 std::unique_ptr<ScUndoPaste> pUndoPaste;
9113 executeReferencedCutRangesCol(true, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
9114 checkReferencedCutTransposedRangesCol(nSrcTab, nDestTab);
9116 pUndoPaste->Undo();
9117 pUndoCut->Undo();
9118 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9120 pUndoCut->Redo();
9121 pUndoPaste->Redo();
9122 checkReferencedCutTransposedRangesCol(nSrcTab, nDestTab);
9124 pUndoPaste->Undo();
9125 pUndoCut->Undo();
9126 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
9128 pUndoPaste.reset();
9129 pUndoCut.reset();
9131 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
9132 m_pDoc->DeleteTab(i - 1);
9135 void TestCopyPaste::testCutTransposedFormulas()
9137 const SCTAB nTab = 0;
9138 m_pDoc->InsertTab(nTab, "Test");
9140 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9141 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
9143 m_pDoc->SetString(1, 1, nTab, "=A1"); // B2
9144 m_pDoc->SetString(2, 1, nTab, "=B1"); // C2
9145 m_pDoc->SetString(3, 1, nTab, "=SUM(A1:B1)"); // D2
9146 m_pDoc->SetString(4, 1, nTab, "=$B$1"); // E2
9147 m_pDoc->SetString(5, 1, nTab, "=$B1"); // F2
9148 m_pDoc->SetString(6, 1, nTab, "=B$1"); // G2
9150 // Check precondition
9151 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 1, nTab));
9153 // Cut formulas B2:G2 to the clip document.
9154 ScDocument aClipDoc(SCDOCMODE_CLIP);
9155 ScRange aSrcRange(1, 1, nTab, 6, 1, nTab);
9156 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9158 // To C3:C8
9159 ScRange aDestRange(2, 2, nTab, 2, 7, nTab);
9160 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9162 // Transpose
9163 ScDocument* pOrigClipDoc = &aClipDoc;
9164 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9165 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9166 aDestMark.SetMarkArea(aDestRange);
9167 // Paste
9168 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9169 true, false, true, false);
9170 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9171 pTransClip.reset();
9173 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(2, 2, nTab));
9174 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(2, 2, nTab));
9176 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(2, 3, nTab));
9177 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 3, nTab));
9179 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A1:B1)"), getFormula(2, 4, nTab));
9180 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 4, nTab));
9182 CPPUNIT_ASSERT_EQUAL(OUString("=$B$1"), getFormula(2, 5, nTab));
9183 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 5, nTab));
9185 CPPUNIT_ASSERT_EQUAL(OUString("=$B1"), getFormula(2, 6, nTab));
9186 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 6, nTab));
9188 CPPUNIT_ASSERT_EQUAL(OUString("=B$1"), getFormula(2, 7, nTab));
9189 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 7, nTab));
9192 void TestCopyPaste::testCutTransposedFormulasSquare()
9194 const SCTAB nTab = 0;
9195 m_pDoc->InsertTab(nTab, "Test");
9197 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9198 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
9199 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
9200 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
9201 m_pDoc->SetValue(2, 0, nTab, 21.0); // C1
9202 m_pDoc->SetValue(2, 1, nTab, 22.0); // C2
9204 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
9205 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
9206 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
9207 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
9208 m_pDoc->SetString(2, 3, nTab, "=C1"); // C4
9209 m_pDoc->SetString(2, 4, nTab, "=C2"); // C5
9211 // Check precondition
9212 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
9213 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
9214 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
9215 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
9216 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 3, nTab));
9217 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 4, nTab));
9219 printRange(m_pDoc, ScRange(0, 0, nTab, 2, 1, nTab), "Values");
9220 printRange(m_pDoc, ScRange(0, 3, nTab, 2, 4, nTab), "Formulas");
9221 printFormula(m_pDoc, 0, 4, nTab);
9223 // Cut formulas A4:B5 to the clip document.
9224 ScDocument aClipDoc(SCDOCMODE_CLIP);
9225 ScRange aSrcRange(0, 3, nTab, 2, 4, nTab);
9226 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9228 // To B7:C9
9229 ScRange aDestRange(1, 6, nTab, 2, 8, nTab);
9230 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9232 // Transpose
9233 ScDocument* pOrigClipDoc = &aClipDoc;
9234 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9235 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9236 aDestMark.SetMarkArea(aDestRange);
9237 // Paste
9238 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9239 true, false, true, false);
9240 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9241 pTransClip.reset();
9243 printRange(m_pDoc, aDestRange, "Formulas after cut transposed");
9244 printFormula(m_pDoc, 2, 6, nTab);
9246 // Check results
9247 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 6, nTab));
9248 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 6, nTab));
9249 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 7, nTab));
9250 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 7, nTab));
9251 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(1, 8, nTab));
9252 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 8, nTab));
9254 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), getFormula(1, 6, nTab));
9255 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), getFormula(2, 6, nTab));
9256 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), getFormula(1, 7, nTab));
9257 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), getFormula(2, 7, nTab));
9258 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), getFormula(1, 8, nTab));
9259 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), getFormula(2, 8, nTab));
9262 void TestCopyPaste::testTdf142065()
9264 const SCTAB nTab = 0;
9265 m_pDoc->InsertTab(nTab, "Test");
9267 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9268 m_pDoc->SetString(1, 0, nTab, "=A1"); // B1
9269 m_pDoc->SetString(2, 0, nTab, "=SUM(A1:B1)"); // C1
9270 m_pDoc->SetString(3, 0, nTab, "=$A$1"); // D1
9271 m_pDoc->SetString(4, 0, nTab, "=$A1"); // E1
9272 m_pDoc->SetString(5, 0, nTab, "=A$1"); // F1
9274 // Check precondition
9275 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 0, nTab));
9277 // Cut A1:F1 to the clip document.
9278 ScDocument aClipDoc(SCDOCMODE_CLIP);
9279 ScRange aSrcRange(0, 0, nTab, 5, 0, nTab);
9280 printRange(m_pDoc, aSrcRange, "Src sheet");
9281 printFormula(m_pDoc, 1, 0, nTab);
9282 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9283 printRange(&aClipDoc, aSrcRange, "clip doc (&aClipDoc)");
9284 printFormula(&aClipDoc, 1, 0, nTab);
9286 // To A3:A9
9287 ScRange aDestRange(0, 2, nTab, 0, 7, nTab);
9288 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9290 // Transpose
9291 ScDocument* pOrigClipDoc = &aClipDoc;
9292 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9293 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9294 printRange(pTransClip.get(), ScRange(0, 0, nTab, 0, 1, nTab),
9295 "transposed clip doc (pTransClip.get())");
9296 printFormula(pTransClip.get(), 0, 1, nTab);
9297 printFormula(pTransClip.get(), 1, 0, nTab);
9298 aDestMark.SetMarkArea(aDestRange);
9299 // Paste
9300 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9301 true, false, true, false);
9302 printRange(m_pDoc, aDestRange, "dest doc");
9303 printFormula(m_pDoc, 0, 3, nTab);
9304 printRange(pOrigClipDoc, aSrcRange, "orig clip doc (pOrigClipDoc)");
9305 printFormula(pOrigClipDoc, 1, 0, nTab);
9306 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9307 pTransClip.reset();
9308 printRange(m_pDoc, aDestRange, "dest doc after UpdateTranspose()");
9309 printFormula(m_pDoc, 0, 3, nTab);
9311 // Check results
9312 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 2, nTab));
9313 // Without the fix in place, this would have failed with
9314 // - Expected: =A3
9315 // - Actual : =#REF!#REF!
9316 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), getFormula(0, 3, nTab));
9317 // Without the fix in place, this would have failed with
9318 // - Expected: 1
9319 // - Actual : #REF!
9320 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
9321 // Without the fix in place, this would have failed with
9322 // - Expected: =SUM(A3:A4)
9323 // - Actual : =SUM(#REF!#REF!:#REF!#REF!)
9324 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A3:A4)"), getFormula(0, 4, nTab));
9325 // Without the fix in place, this would have failed with
9326 // - Expected: 2
9327 // - Actual : #REF!
9328 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
9330 CPPUNIT_ASSERT_EQUAL(OUString("=$A$3"), getFormula(0, 5, nTab));
9331 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 5, nTab));
9333 CPPUNIT_ASSERT_EQUAL(OUString("=$A3"), getFormula(0, 6, nTab));
9334 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 6, nTab));
9336 CPPUNIT_ASSERT_EQUAL(OUString("=A$3"), getFormula(0, 7, nTab));
9337 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 7, nTab));
9340 void TestCopyPaste::testCopyPasteMultiRange()
9342 m_pDoc->InsertTab(0, "Test");
9344 // Fill A2:B6 with numbers.
9345 for (SCROW nRow = 1; nRow <= 5; ++nRow)
9347 for (SCCOL nCol = 0; nCol <= 1; ++nCol)
9349 ScAddress aPos(nCol, nRow, 0);
9350 m_pDoc->SetValue(aPos, nRow + nCol);
9354 // Fill D9:E11 with numbers.
9355 for (SCROW nRow = 8; nRow <= 10; ++nRow)
9357 for (SCCOL nCol = 3; nCol <= 4; ++nCol)
9359 ScAddress aPos(nCol, nRow, 0);
9360 m_pDoc->SetValue(aPos, 10.0);
9364 ScMarkData aMark(m_pDoc->GetSheetLimits());
9365 aMark.SelectOneTable(0);
9367 // Copy A2:B2, A4:B4, and A6:B6 to clipboard.
9368 ScDocument aClipDoc(SCDOCMODE_CLIP);
9369 ScClipParam aClipParam;
9370 aClipParam.maRanges.push_back(ScRange(0, 1, 0, 1, 1, 0)); // A2:B2
9371 aClipParam.maRanges.push_back(ScRange(0, 3, 0, 1, 3, 0)); // A4:B4
9372 aClipParam.maRanges.push_back(ScRange(0, 5, 0, 1, 5, 0)); // A6:B6
9373 aClipParam.meDirection = ScClipParam::Row;
9374 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9376 // Paste to D9:E11, and make sure it won't crash (rhbz#1080196).
9377 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 8, 0), aMark, InsertDeleteFlags::CONTENTS,
9378 &aClipDoc);
9379 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(3, 8, 0)));
9380 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4, 8, 0)));
9381 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3, 9, 0)));
9382 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(4, 9, 0)));
9383 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(3, 10, 0)));
9384 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(4, 10, 0)));
9386 m_pDoc->DeleteTab(0);
9389 void TestCopyPaste::testCopyPasteSkipEmpty()
9391 struct Check
9393 const char* mpStr;
9394 Color maColor;
9395 bool mbHasNote;
9398 struct TestRange
9400 ScDocument* mpDoc;
9402 explicit TestRange(ScDocument* pDoc)
9403 : mpDoc(pDoc)
9407 bool checkRange(const ScAddress& rPos, const Check* p, const Check* pEnd)
9409 ScAddress aPos(rPos);
9410 OUString aPosStr = aPos.Format(ScRefFlags::VALID);
9411 for (; p != pEnd; ++p, aPos.IncRow())
9413 if (!mpDoc->GetString(aPos).equalsAscii(p->mpStr))
9415 cerr << aPosStr << ": incorrect string value: expected='" << p->mpStr
9416 << "' actual='" << mpDoc->GetString(aPos) << endl;
9417 return false;
9420 const SvxBrushItem* pBrush = mpDoc->GetAttr(aPos, ATTR_BACKGROUND);
9421 if (!pBrush)
9423 cerr << aPosStr << ": failed to get brush item from the cell." << endl;
9424 return false;
9427 if (pBrush->GetColor() != p->maColor)
9429 Color aExpected = p->maColor;
9430 Color aActual = pBrush->GetColor();
9431 cerr << aPosStr << ": incorrect cell background color: expected=("
9432 << static_cast<int>(aExpected.GetRed()) << ","
9433 << static_cast<int>(aExpected.GetGreen()) << ","
9434 << static_cast<int>(aExpected.GetBlue()) << "), actual=("
9435 << static_cast<int>(aActual.GetRed()) << ","
9436 << static_cast<int>(aActual.GetGreen()) << ","
9437 << static_cast<int>(aActual.GetBlue()) << ")" << endl;
9439 return false;
9442 bool bHasNote = mpDoc->HasNote(aPos);
9443 if (bHasNote != p->mbHasNote)
9445 cerr << aPosStr << ": ";
9446 if (p->mbHasNote)
9447 cerr << "this cell should have a cell note, but doesn't." << endl;
9448 else
9449 cerr << "this cell should NOT have a cell note, but one is found." << endl;
9451 return false;
9455 return true;
9458 } aTest(m_pDoc);
9460 m_pDoc->InsertTab(0, "Test");
9461 m_pDoc->InitDrawLayer(m_xDocShell.get()); // for cell note objects.
9463 ScRange aSrcRange(0, 0, 0, 0, 4, 0);
9464 ScRange aDestRange(1, 0, 0, 1, 4, 0);
9466 ScMarkData aMark(m_pDoc->GetSheetLimits());
9467 aMark.SetMarkArea(aDestRange);
9469 // Put some texts in B1:B5.
9470 m_pDoc->SetString(ScAddress(1, 0, 0), "A");
9471 m_pDoc->SetString(ScAddress(1, 1, 0), "B");
9472 m_pDoc->SetString(ScAddress(1, 2, 0), "C");
9473 m_pDoc->SetString(ScAddress(1, 3, 0), "D");
9474 m_pDoc->SetString(ScAddress(1, 4, 0), "E");
9476 // Set the background color of B1:B5 to blue.
9477 ScPatternAttr aCellBackColor(m_pDoc->GetPool());
9478 aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
9479 m_pDoc->ApplyPatternAreaTab(1, 0, 1, 4, 0, aCellBackColor);
9481 // Insert notes to B1:B5.
9482 m_pDoc->GetOrCreateNote(ScAddress(1, 0, 0));
9483 m_pDoc->GetOrCreateNote(ScAddress(1, 1, 0));
9484 m_pDoc->GetOrCreateNote(ScAddress(1, 2, 0));
9485 m_pDoc->GetOrCreateNote(ScAddress(1, 3, 0));
9486 m_pDoc->GetOrCreateNote(ScAddress(1, 4, 0));
9488 // Prepare a clipboard content interleaved with empty cells.
9489 ScDocument aClipDoc(SCDOCMODE_CLIP);
9490 aClipDoc.ResetClip(m_pDoc, &aMark);
9491 ScClipParam aParam(aSrcRange, false);
9492 aClipDoc.SetClipParam(aParam);
9493 aClipDoc.SetString(ScAddress(0, 0, 0), "Clip1");
9494 aClipDoc.SetString(ScAddress(0, 2, 0), "Clip2");
9495 aClipDoc.SetString(ScAddress(0, 4, 0), "Clip3");
9497 // Set the background color of A1:A5 to yellow.
9498 aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_YELLOW, ATTR_BACKGROUND));
9499 aClipDoc.ApplyPatternAreaTab(0, 0, 0, 4, 0, aCellBackColor);
9501 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 0, 0)));
9502 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0, 1, 0)));
9503 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 2, 0)));
9504 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0, 3, 0)));
9505 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 4, 0)));
9507 // Check the initial condition.
9509 static const Check aChecks[] = {
9510 { "A", COL_BLUE, true }, { "B", COL_BLUE, true }, { "C", COL_BLUE, true },
9511 { "D", COL_BLUE, true }, { "E", COL_BLUE, true },
9514 bool bRes
9515 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9516 CPPUNIT_ASSERT_MESSAGE("Initial check failed.", bRes);
9519 // Create undo document.
9520 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9521 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9522 m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, *pUndoDoc, &aMark);
9524 // Paste clipboard content onto A1:A5 but skip empty cells.
9525 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, pUndoDoc.get(), &aClipDoc, true,
9526 false, false, true /*bSkipEmpty*/);
9528 // Create redo document.
9529 ScDocumentUniquePtr pRedoDoc(new ScDocument(SCDOCMODE_UNDO));
9530 pRedoDoc->InitUndo(*m_pDoc, 0, 0);
9531 m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, *pRedoDoc, &aMark);
9533 // Create an undo object for this.
9534 std::unique_ptr<ScRefUndoData> pRefUndoData(new ScRefUndoData(m_pDoc));
9535 ScUndoPaste aUndo(m_xDocShell.get(), aDestRange, aMark, std::move(pUndoDoc),
9536 std::move(pRedoDoc), InsertDeleteFlags::ALL, std::move(pRefUndoData));
9538 // Check the content after the paste.
9540 static const Check aChecks[] = {
9541 { "Clip1", COL_YELLOW, false }, { "B", COL_BLUE, true },
9542 { "Clip2", COL_YELLOW, false }, { "D", COL_BLUE, true },
9543 { "Clip3", COL_YELLOW, false },
9546 bool bRes
9547 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9548 CPPUNIT_ASSERT_MESSAGE("Check after paste failed.", bRes);
9551 // Undo, and check the content.
9552 aUndo.Undo();
9554 static const Check aChecks[] = {
9555 { "A", COL_BLUE, true }, { "B", COL_BLUE, true }, { "C", COL_BLUE, true },
9556 { "D", COL_BLUE, true }, { "E", COL_BLUE, true },
9559 bool bRes
9560 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9561 CPPUNIT_ASSERT_MESSAGE("Check after undo failed.", bRes);
9564 // Redo, and check the content again.
9565 aUndo.Redo();
9567 static const Check aChecks[] = {
9568 { "Clip1", COL_YELLOW, false }, { "B", COL_BLUE, true },
9569 { "Clip2", COL_YELLOW, false }, { "D", COL_BLUE, true },
9570 { "Clip3", COL_YELLOW, false },
9573 bool bRes
9574 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9575 CPPUNIT_ASSERT_MESSAGE("Check after redo failed.", bRes);
9578 m_pDoc->DeleteTab(0);
9581 void TestCopyPaste::testCopyPasteSkipEmpty2()
9583 m_pDoc->InsertTab(0, "Test");
9585 m_pDoc->SetString(ScAddress(0, 0, 0), "A");
9586 m_pDoc->SetString(ScAddress(2, 0, 0), "C");
9588 // Copy A1:C1 to clipboard.
9589 ScDocument aClipDoc(SCDOCMODE_CLIP);
9590 aClipDoc.ResetClip(m_pDoc, static_cast<SCTAB>(0));
9591 copyToClip(m_pDoc, ScRange(0, 0, 0, 2, 0, 0), &aClipDoc);
9593 // Paste to A3 with the skip empty option set. This used to freeze. (fdo#77735)
9594 ScRange aDestRange(0, 2, 0, 2, 2, 0);
9595 ScMarkData aMark(m_pDoc->GetSheetLimits());
9596 aMark.SetMarkArea(aDestRange);
9597 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, false,
9598 false, true, true);
9600 CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(0, 2, 0)));
9601 CPPUNIT_ASSERT_EQUAL_MESSAGE("B3 should be empty.", CELLTYPE_NONE,
9602 m_pDoc->GetCellType(ScAddress(1, 2, 0)));
9603 CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(2, 2, 0)));
9605 m_pDoc->DeleteTab(0);
9608 void TestCopyPaste::testCutPasteRefUndo()
9610 // Testing scenario: A2 references B2, and B2 gets cut and pasted onto C2,
9611 // which updates A2's formula to reference C2. Then the paste action gets
9612 // undone, which should also undo A2's formula to reference back to B2.
9614 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9616 m_pDoc->InsertTab(0, "Test");
9618 // A2 references B2.
9619 m_pDoc->SetString(ScAddress(0, 1, 0), "=B2");
9621 ScMarkData aMark(m_pDoc->GetSheetLimits());
9622 aMark.SelectOneTable(0);
9624 // Set up clip document for cutting of B2.
9625 ScDocument aClipDoc(SCDOCMODE_CLIP);
9626 aClipDoc.ResetClip(m_pDoc, &aMark);
9627 ScClipParam aParam(ScAddress(1, 1, 0), true);
9628 aClipDoc.SetClipParam(aParam);
9629 aClipDoc.SetValue(ScAddress(1, 1, 0), 12.0);
9631 // Set up undo document for reference update.
9632 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9633 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9635 // Do the pasting of 12 into C2. This should update A2 to reference C2.
9636 m_pDoc->CopyFromClip(ScAddress(2, 1, 0), aMark, InsertDeleteFlags::CONTENTS, pUndoDoc.get(),
9637 &aClipDoc);
9638 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(0, 1, 0));
9640 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 0), "C2", "A2 should be referencing C2.");
9642 // At this point, the ref undo document should contain a formula cell at A2 that references B2.
9643 ASSERT_FORMULA_EQUAL(*pUndoDoc, ScAddress(0, 1, 0), "B2",
9644 "A2 in the undo document should be referencing B2.");
9646 ScUndoPaste aUndo(m_xDocShell.get(), ScRange(2, 1, 0), aMark, std::move(pUndoDoc), nullptr,
9647 InsertDeleteFlags::CONTENTS, nullptr, false, nullptr);
9648 aUndo.Undo();
9650 // Now A2 should be referencing B2 once again.
9651 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 0), "B2",
9652 "A2 should be referencing B2 after undo.");
9654 m_pDoc->DeleteTab(0);
9657 void TestCopyPaste::testCutPasteGroupRefUndo()
9659 // Test that Cut&Paste part of a grouped formula adjusts references
9660 // correctly and Undo works.
9662 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9664 m_pDoc->InsertTab(0, "Test");
9666 // Formula data in A1:A9
9667 std::vector<std::vector<const char*>> aData
9668 = { { "1" }, { "=A1+A1" }, { "=A2+A1" }, { "=A3+A2" }, { "=A4+A3" },
9669 { "=A5+A4" }, { "=A6+A5" }, { "=A7+A6" }, { "=A8+A7" } };
9671 ScAddress aPos(0, 0, 0);
9672 ScRange aDataRange = insertRangeData(m_pDoc, aPos, aData);
9673 CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to insert data", aPos, aDataRange.aStart);
9675 // Check initial data.
9676 const char* aDataCheck[][2] = { { "1", "" }, { "2", "=A1+A1" }, { "3", "=A2+A1" },
9677 { "5", "=A3+A2" }, { "8", "=A4+A3" }, { "13", "=A5+A4" },
9678 { "21", "=A6+A5" }, { "34", "=A7+A6" }, { "55", "=A8+A7" } };
9679 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataCheck); ++i)
9681 OUString aString = m_pDoc->GetString(0, i, 0);
9682 CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial data failure",
9683 OUString::createFromAscii(aDataCheck[i][0]), aString);
9684 aString = m_pDoc->GetFormula(0, i, 0);
9685 CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial formula failure",
9686 OUString::createFromAscii(aDataCheck[i][1]), aString);
9689 ScMarkData aMark(m_pDoc->GetSheetLimits());
9690 aMark.SelectOneTable(0);
9692 // Set up clip document.
9693 ScDocument aClipDoc(SCDOCMODE_CLIP);
9694 aClipDoc.ResetClip(m_pDoc, &aMark);
9695 // Cut A4:A6 to clipboard with Undo.
9696 std::unique_ptr<ScUndoCut> pUndoCut(
9697 cutToClip(*m_xDocShell, ScRange(0, 3, 0, 0, 5, 0), &aClipDoc, true));
9699 // Check data after Cut.
9700 const char* aCutCheck[] = { "1", "2", "3", "", "", "", "0", "0", "0" };
9701 for (size_t i = 0; i < SAL_N_ELEMENTS(aCutCheck); ++i)
9703 OUString aString = m_pDoc->GetString(0, i, 0);
9704 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cut data failure", OUString::createFromAscii(aCutCheck[i]),
9705 aString);
9708 // Paste to B5:B7 with Undo.
9709 ScRange aPasteRange(1, 4, 0, 1, 6, 0);
9710 aMark.SetMarkArea(aPasteRange);
9711 ScDocument* pPasteUndoDoc = new ScDocument(SCDOCMODE_UNDO);
9712 pPasteUndoDoc->InitUndoSelected(*m_pDoc, aMark);
9713 std::unique_ptr<ScUndoPaste> pUndoPaste(
9714 createUndoPaste(*m_xDocShell, aPasteRange, ScDocumentUniquePtr(pPasteUndoDoc)));
9715 m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::ALL, pPasteUndoDoc, &aClipDoc);
9717 // Check data after Paste.
9718 const char* aPasteCheck[][4] = { { "1", "", "", "" },
9719 { "2", "", "=A1+A1", "" },
9720 { "3", "", "=A2+A1", "" },
9721 { "", "", "", "" },
9722 { "", "5", "", "=A3+A2" },
9723 { "", "8", "", "=B5+A3" },
9724 { "21", "13", "=B7+B6", "=B6+B5" },
9725 { "34", "", "=A7+B7", "" },
9726 { "55", "", "=A8+A7", "" } };
9727 for (size_t i = 0; i < SAL_N_ELEMENTS(aPasteCheck); ++i)
9729 for (size_t j = 0; j < 2; ++j)
9731 OUString aString = m_pDoc->GetString(j, i, 0);
9732 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste data failure",
9733 OUString::createFromAscii(aPasteCheck[i][j]), aString);
9734 aString = m_pDoc->GetFormula(j, i, 0);
9735 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste formula failure",
9736 OUString::createFromAscii(aPasteCheck[i][2 + j]), aString);
9740 // Undo Paste and check, must be same as after Cut.
9741 pUndoPaste->Undo();
9742 for (size_t i = 0; i < SAL_N_ELEMENTS(aCutCheck); ++i)
9744 OUString aString = m_pDoc->GetString(0, i, 0);
9745 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Paste data failure",
9746 OUString::createFromAscii(aCutCheck[i]), aString);
9749 // Undo Cut and check, must be initial data.
9750 pUndoCut->Undo();
9751 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataCheck); ++i)
9753 OUString aString = m_pDoc->GetString(0, i, 0);
9754 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut data failure",
9755 OUString::createFromAscii(aDataCheck[i][0]), aString);
9756 aString = m_pDoc->GetFormula(0, i, 0);
9757 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut formula failure",
9758 OUString::createFromAscii(aDataCheck[i][1]), aString);
9761 m_pDoc->DeleteTab(0);
9764 void TestCopyPaste::testMoveRefBetweenSheets()
9766 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9768 m_pDoc->InsertTab(0, "Test1");
9769 m_pDoc->InsertTab(1, "Test2");
9771 m_pDoc->SetValue(ScAddress(0, 0, 0), 12.0);
9772 m_pDoc->SetValue(ScAddress(1, 0, 0), 10.0);
9773 m_pDoc->SetValue(ScAddress(2, 0, 0), 8.0);
9774 m_pDoc->SetString(ScAddress(0, 1, 0), "=A1");
9775 m_pDoc->SetString(ScAddress(0, 2, 0), "=SUM(A1:C1)");
9777 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 0, 0)));
9778 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
9779 CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
9781 // These formulas should not display the sheet name.
9782 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 0), "A1", "Wrong formula!");
9783 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 2, 0), "SUM(A1:C1)", "Wrong formula!");
9785 // Move Test1.A2:A3 to Test2.A2:A3.
9786 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
9787 bool bMoved
9788 = rFunc.MoveBlock(ScRange(0, 1, 0, 0, 2, 0), ScAddress(0, 1, 1), true, true, false, true);
9789 CPPUNIT_ASSERT(bMoved);
9791 CPPUNIT_ASSERT_EQUAL_MESSAGE("This cell should be empty after the move.", CELLTYPE_NONE,
9792 m_pDoc->GetCellType(ScAddress(0, 1, 0)));
9793 ASSERT_DOUBLES_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 1, 1)));
9794 ASSERT_DOUBLES_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 1)));
9796 // The reference in the pasted formula should display sheet name after the move.
9797 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 1), "Test1.A1", "Wrong formula!");
9798 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 2, 1), "SUM(Test1.A1:C1)", "Wrong formula!");
9800 m_pDoc->DeleteTab(1);
9801 m_pDoc->DeleteTab(0);
9804 void TestCopyPaste::testUndoCut()
9806 m_pDoc->InsertTab(0, "Test");
9808 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9810 // Insert values into A1:A3.
9811 m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
9812 m_pDoc->SetValue(ScAddress(0, 1, 0), 10.0);
9813 m_pDoc->SetValue(ScAddress(0, 2, 0), 100.0);
9815 // SUM in A4.
9816 m_pDoc->SetString(ScAddress(0, 3, 0), "=SUM(A1:A3)");
9817 CPPUNIT_ASSERT_EQUAL(111.0, m_pDoc->GetValue(0, 3, 0));
9819 // Select A1:A3.
9820 ScMarkData aMark(m_pDoc->GetSheetLimits());
9821 ScRange aRange(0, 0, 0, 0, 2, 0);
9822 aMark.SetMarkArea(aRange);
9823 aMark.MarkToMulti();
9825 // Set up an undo object for cutting A1:A3.
9826 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9827 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9828 m_pDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *pUndoDoc);
9829 ASSERT_DOUBLES_EQUAL(1.0, pUndoDoc->GetValue(ScAddress(0, 0, 0)));
9830 ASSERT_DOUBLES_EQUAL(10.0, pUndoDoc->GetValue(ScAddress(0, 1, 0)));
9831 ASSERT_DOUBLES_EQUAL(100.0, pUndoDoc->GetValue(ScAddress(0, 2, 0)));
9832 ScUndoCut aUndo(m_xDocShell.get(), aRange, aRange.aEnd, aMark, std::move(pUndoDoc));
9834 // "Cut" the selection.
9835 m_pDoc->DeleteSelection(InsertDeleteFlags::ALL, aMark);
9836 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 3, 0)); // The SUM should be zero after the "cut".
9838 // Undo it, and check the result.
9839 aUndo.Undo();
9840 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 0, 0)));
9841 ASSERT_DOUBLES_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
9842 ASSERT_DOUBLES_EQUAL(100.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
9843 ASSERT_DOUBLES_EQUAL(
9844 111.0, m_pDoc->GetValue(0, 3, 0)); // The SUM value should be back to the original.
9846 // Redo it and check.
9847 aUndo.Redo();
9848 ASSERT_DOUBLES_EQUAL(0.0, m_pDoc->GetValue(0, 3, 0));
9850 // Undo again.
9851 aUndo.Undo();
9852 ASSERT_DOUBLES_EQUAL(111.0, m_pDoc->GetValue(0, 3, 0));
9854 m_pDoc->DeleteTab(0);
9857 void TestCopyPaste::testMoveBlock()
9859 m_pDoc->InsertTab(0, "SheetNotes");
9861 // We need a drawing layer in order to create caption objects.
9862 m_pDoc->InitDrawLayer(m_xDocShell.get());
9864 m_pDoc->SetValue(0, 0, 0, 1);
9865 m_pDoc->SetString(1, 0, 0, "=A1+1");
9866 m_pDoc->SetString(2, 0, 0, "test");
9868 // add notes to A1:C1
9869 ScAddress aAddrA1 = setNote(0, 0, 0, "Hello world in A1");
9870 ScAddress aAddrB1 = setNote(1, 0, 0, "Hello world in B1");
9871 ScAddress aAddrC1 = setNote(2, 0, 0, "Hello world in C1");
9872 ScAddress aAddrD1(3, 0, 0);
9874 // previous tests on cell note content are ok. this one fails !!! :(
9875 //CPPUNIT_ASSERT_MESSAGE("Note content in B1 before move block", m_pDoc->GetNote(aAddrB1)->GetText() == aHelloB1);
9877 // move notes to B1:D1
9878 ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc();
9879 bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0, 0, 2, 0, 0), ScAddress(1, 0, 0),
9880 true /*bCut*/, false, false, false);
9882 CPPUNIT_ASSERT_MESSAGE("Cells not moved", bMoveDone);
9884 //check cell content
9885 OUString aString = m_pDoc->GetString(3, 0, 0);
9886 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D1 should contain: test", OUString("test"), aString);
9887 aString = m_pDoc->GetFormula(2, 0, 0);
9888 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C1 should contain an updated formula", OUString("=B1+1"),
9889 aString);
9890 double fValue = m_pDoc->GetValue(aAddrB1);
9891 ASSERT_DOUBLES_EQUAL_MESSAGE("Cell B1 should contain 1", fValue, 1);
9893 // cell notes has been moved 1 cell right (event when overlapping)
9894 CPPUNIT_ASSERT_MESSAGE("There should be NO note on A1", !m_pDoc->HasNote(aAddrA1));
9895 CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", m_pDoc->HasNote(aAddrB1));
9896 CPPUNIT_ASSERT_MESSAGE("There should be a note on C1", m_pDoc->HasNote(aAddrC1));
9897 CPPUNIT_ASSERT_MESSAGE("There should be a note on D1", m_pDoc->HasNote(aAddrD1));
9898 /* still failing, wrong content ???
9899 OUString sNoteText;
9900 sNoteText = m_pDoc->GetNote(aAddrB1)->GetText();
9901 CPPUNIT_ASSERT_MESSAGE("Note content in B1", sNoteText == aHelloA1);
9902 sNoteText = m_pDoc->GetNote(aAddrC1)->GetText();
9903 CPPUNIT_ASSERT_MESSAGE("Note content in C1", sNoteText == aHelloB1);
9904 sNoteText = m_pDoc->GetNote(aAddrD1)->GetText();
9905 CPPUNIT_ASSERT_MESSAGE("Note content in D1", sNoteText == aHelloC1);
9908 m_pDoc->DeleteTab(0);
9911 void TestCopyPaste::testCopyPasteRelativeFormula()
9913 m_pDoc->InsertTab(0, "Formula");
9915 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
9917 // Insert values to A2 and A4.
9918 m_pDoc->SetValue(ScAddress(0, 1, 0), 1);
9919 m_pDoc->SetValue(ScAddress(0, 3, 0), 2);
9921 // Insert formula to B4.
9922 m_pDoc->SetString(ScAddress(1, 3, 0), "=A4");
9923 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1, 3, 0)));
9925 // Select and copy B3:B4 to the clipboard.
9926 ScRange aRange(1, 2, 0, 1, 3, 0);
9927 ScClipParam aClipParam(aRange, false);
9928 ScMarkData aMark(m_pDoc->GetSheetLimits());
9929 aMark.SetMarkArea(aRange);
9930 ScDocument aClipDoc(SCDOCMODE_CLIP);
9931 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9933 // Paste it to B1:B2.
9934 InsertDeleteFlags nFlags = InsertDeleteFlags::ALL;
9935 ScRange aDestRange(1, 0, 0, 1, 1, 0);
9936 aMark.SetMarkArea(aDestRange);
9937 m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
9939 // B2 references A2, so the value should be 1.
9940 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1, 1, 0)));
9942 // Clear content and start over.
9943 clearSheet(m_pDoc, 0);
9944 clearSheet(&aClipDoc, 0);
9946 // Insert a single formula cell in A1.
9947 m_pDoc->SetString(ScAddress(0, 0, 0), "=ROW()");
9948 const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0, 0, 0));
9949 CPPUNIT_ASSERT(pFC);
9950 CPPUNIT_ASSERT(!pFC->IsShared()); // single formula cell is never shared.
9952 // Copy A1 to clipboard.
9953 aClipParam = ScClipParam(ScAddress(0, 0, 0), false);
9954 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9956 pFC = aClipDoc.GetFormulaCell(ScAddress(0, 0, 0));
9957 CPPUNIT_ASSERT(pFC);
9958 CPPUNIT_ASSERT(!pFC->IsShared());
9960 // Paste to A3.
9961 aDestRange = ScRange(0, 2, 0, 0, 2, 0);
9962 aMark.SetMarkArea(aDestRange);
9963 m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
9965 pFC = m_pDoc->GetFormulaCell(ScAddress(0, 2, 0));
9966 CPPUNIT_ASSERT(pFC);
9967 CPPUNIT_ASSERT(!pFC->IsShared());
9969 // Delete A3 and make sure it doesn't crash (see fdo#76132).
9970 clearRange(m_pDoc, ScAddress(0, 2, 0));
9971 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(ScAddress(0, 2, 0)));
9973 m_pDoc->DeleteTab(0);
9976 void TestCopyPaste::testCopyPasteRepeatOneFormula()
9978 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
9980 m_pDoc->InsertTab(0, "Test");
9982 ScDocument aClipDoc(SCDOCMODE_CLIP);
9983 ScMarkData aMark(m_pDoc->GetSheetLimits());
9985 // Insert values in A1:B10.
9986 for (SCROW i = 0; i < 10; ++i)
9988 m_pDoc->SetValue(ScAddress(0, i, 0), i + 1.0); // column A
9989 m_pDoc->SetValue(ScAddress(1, i, 0), (i + 1.0) * 10.0); // column B
9992 // Insert a formula in C1.
9993 ScAddress aPos(2, 0, 0); // C1
9994 m_pDoc->SetString(aPos, "=SUM(A1:B1)");
9995 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(aPos));
9997 // This check makes only sense if group listeners are activated.
9998 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
9999 // At this point, there should be only one normal area listener listening
10000 // on A1:B1.
10001 ScRange aWholeSheet(0, 0, 0, MAXCOL, MAXROW, 0);
10002 ScBroadcastAreaSlotMachine* pBASM = m_pDoc->GetBASM();
10003 CPPUNIT_ASSERT(pBASM);
10004 std::vector<sc::AreaListener> aListeners
10005 = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10006 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10007 const sc::AreaListener* pListener = aListeners.data();
10008 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 0, 0), pListener->maArea);
10009 CPPUNIT_ASSERT_MESSAGE("This listener shouldn't be a group listener.",
10010 !pListener->mbGroupListening);
10011 #endif
10013 // Copy C1 to clipboard.
10014 ScClipParam aClipParam(aPos, false);
10015 aMark.SetMarkArea(aPos);
10016 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10018 // Paste it to C2:C10.
10019 ScRange aDestRange(2, 1, 0, 2, 9, 0);
10020 aMark.SetMarkArea(aDestRange);
10021 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &aClipDoc);
10023 // Make sure C1:C10 are grouped.
10024 const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(aPos);
10025 CPPUNIT_ASSERT(pFC);
10026 CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength());
10028 // Check the formula results.
10029 for (SCROW i = 0; i < 10; ++i)
10031 double fExpected = (i + 1.0) * 11.0;
10032 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i, 0)));
10035 // This check makes only sense if group listeners are activated.
10036 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10037 // At this point, there should only be one area listener and it should be
10038 // a group listener listening on A1:B10.
10039 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10040 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10041 pListener = aListeners.data();
10042 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 9, 0), pListener->maArea);
10043 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
10044 pListener->mbGroupListening);
10045 #endif
10047 // Insert a new row at row 1.
10048 ScRange aRowOne(0, 0, 0, MAXCOL, 0, 0);
10049 aMark.SetMarkArea(aRowOne);
10050 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
10051 rFunc.InsertCells(aRowOne, &aMark, INS_INSROWS_BEFORE, true, true);
10053 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 should be empty.", CELLTYPE_NONE,
10054 m_pDoc->GetCellType(ScAddress(2, 0, 0)));
10056 // This check makes only sense if group listeners are activated.
10057 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10058 // Make there we only have one group area listener listening on A2:B11.
10059 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10060 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10061 pListener = aListeners.data();
10062 CPPUNIT_ASSERT_EQUAL(ScRange(0, 1, 0, 1, 10, 0), pListener->maArea);
10063 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
10064 pListener->mbGroupListening);
10065 #endif
10067 // Check the formula results.
10068 for (SCROW i = 0; i < 10; ++i)
10070 double fExpected = (i + 1.0) * 11.0;
10071 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i + 1, 0)));
10074 // Delete row at row 1 to shift the cells up.
10075 rFunc.DeleteCells(aRowOne, &aMark, DelCellCmd::Rows, true);
10077 // Check the formula results again.
10078 for (SCROW i = 0; i < 10; ++i)
10080 double fExpected = (i + 1.0) * 11.0;
10081 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i, 0)));
10084 // This check makes only sense if group listeners are activated.
10085 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
10086 // Check the group area listener again to make sure it's listening on A1:B10 once again.
10087 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
10088 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
10089 pListener = aListeners.data();
10090 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 9, 0), pListener->maArea);
10091 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
10092 pListener->mbGroupListening);
10093 #endif
10095 m_pDoc->DeleteTab(0);
10098 void TestCopyPaste::testCopyPasteMixedReferenceFormula()
10100 sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc.
10101 m_pDoc->InsertTab(0, "Test");
10103 // Insert value to C3
10104 m_pDoc->SetValue(2, 2, 0, 1.0);
10106 // Insert formula to A1 with mixed relative/absolute addressing.
10107 m_pDoc->SetString(0, 0, 0, "=SUM(B:$C)");
10108 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 0, 0), "SUM(B:$C)", "Wrong formula.");
10109 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, 0));
10111 // Copy formula in A1 to clipboard.
10112 ScRange aRange(ScAddress(0, 0, 0));
10113 ScDocument aClipDoc(SCDOCMODE_CLIP);
10114 copyToClip(m_pDoc, aRange, &aClipDoc);
10116 // Paste formula to B1.
10117 aRange = ScAddress(1, 0, 0);
10118 pasteFromClip(m_pDoc, aRange, &aClipDoc);
10119 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1, 0, 0), "SUM(C:$C)", "Wrong formula.");
10120 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 0, 0));
10121 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 0, 0));
10123 // Paste formula to C1. All three results now must be circular reference.
10124 aRange = ScAddress(2, 0, 0);
10125 pasteFromClip(m_pDoc, aRange, &aClipDoc);
10126 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2, 0, 0), "SUM($C:D)",
10127 "Wrong formula."); // reference put in order
10128 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(0, 0, 0));
10129 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(1, 0, 0));
10130 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(2, 0, 0));
10132 m_pDoc->DeleteTab(0);
10135 void TestCopyPaste::testCopyPasteFormulas()
10137 m_pDoc->InsertTab(0, "Sheet1");
10138 m_pDoc->InsertTab(1, "Sheet2");
10140 m_pDoc->SetString(0, 0, 0, "=COLUMN($A$1)");
10141 m_pDoc->SetString(0, 1, 0, "=$A$1+B2");
10142 m_pDoc->SetString(0, 2, 0, "=$Sheet2.A1");
10143 m_pDoc->SetString(0, 3, 0, "=$Sheet2.$A$1");
10144 m_pDoc->SetString(0, 4, 0, "=$Sheet2.A$1");
10146 // to prevent ScEditableTester in ScDocFunc::MoveBlock
10147 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(0, 0, 0), 1.0);
10148 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(0, 1, 0), 1.0);
10149 ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc();
10150 bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0, 0, 0, 4, 0), ScAddress(10, 10, 0), false,
10151 false, false, true);
10153 // check that moving was successful, mainly for editable tester
10154 CPPUNIT_ASSERT(bMoveDone);
10155 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(10, 10, 0), 1.0);
10156 ASSERT_DOUBLES_EQUAL(m_pDoc->GetValue(10, 11, 0), 1.0);
10157 CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($A$1)"), getFormula(10, 10, 0));
10158 CPPUNIT_ASSERT_EQUAL(OUString("=$A$1+L12"), getFormula(10, 11, 0));
10159 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.K11"), getFormula(10, 12, 0));
10160 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.$A$1"), getFormula(10, 13, 0));
10161 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.K$1"), getFormula(10, 14, 0));
10164 void TestCopyPaste::testCopyPasteFormulasExternalDoc()
10166 SfxMedium* pMedium = new SfxMedium("file:///source.fake", StreamMode::STD_READWRITE);
10167 m_xDocShell->DoLoad(pMedium);
10169 ScDocShellRef xExtDocSh = new ScDocShell;
10170 xExtDocSh->SetIsInUcalc();
10171 OUString const aExtDocName("file:///extdata.fake");
10172 SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
10173 xExtDocSh->DoLoad(pMed);
10174 CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
10175 findLoadedDocShellByName(aExtDocName) != nullptr);
10177 ScDocument& rExtDoc = xExtDocSh->GetDocument();
10178 rExtDoc.InsertTab(0, "ExtSheet1");
10179 rExtDoc.InsertTab(1, "ExtSheet2");
10181 m_pDoc->InsertTab(0, "Sheet1");
10182 m_pDoc->InsertTab(1, "Sheet2");
10184 m_pDoc->SetString(0, 0, 0, "=COLUMN($A$1)");
10185 m_pDoc->SetString(0, 1, 0, "=$A$1+B2");
10186 m_pDoc->SetString(0, 2, 0, "=$Sheet2.A1");
10187 m_pDoc->SetString(0, 3, 0, "=$Sheet2.$A$1");
10188 m_pDoc->SetString(0, 4, 0, "=$Sheet2.A$1");
10189 m_pDoc->SetString(0, 5, 0, "=$Sheet1.$A$1");
10191 ScRange aRange(0, 0, 0, 0, 5, 0);
10192 ScClipParam aClipParam(aRange, false);
10193 ScMarkData aMark(m_pDoc->GetSheetLimits());
10194 aMark.SetMarkArea(aRange);
10195 ScDocument aClipDoc(SCDOCMODE_CLIP);
10196 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10198 aRange = ScRange(1, 1, 1, 1, 6, 1);
10199 ScMarkData aMarkData2(m_pDoc->GetSheetLimits());
10200 aMarkData2.SetMarkArea(aRange);
10201 rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
10203 OUString aFormula = rExtDoc.GetFormula(1, 1, 1);
10204 //adjust absolute refs pointing to the copy area
10205 CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($B$2)"), aFormula);
10206 aFormula = rExtDoc.GetFormula(1, 2, 1);
10207 //adjust absolute refs and keep relative refs
10208 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2+C3"), aFormula);
10209 aFormula = rExtDoc.GetFormula(1, 3, 1);
10210 // make absolute sheet refs external refs
10211 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B2"), aFormula);
10212 aFormula = rExtDoc.GetFormula(1, 4, 1);
10213 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.$A$1"), aFormula);
10214 aFormula = rExtDoc.GetFormula(1, 5, 1);
10215 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B$1"), aFormula);
10216 aFormula = rExtDoc.GetFormula(1, 6, 1);
10217 CPPUNIT_ASSERT_EQUAL(OUString("=$ExtSheet2.$B$2"), aFormula);
10219 xExtDocSh->DoClose();
10222 void TestCopyPaste::testCopyPasteReferencesExternalDoc()
10224 SfxMedium* pMedium = new SfxMedium("file:///source.fake", StreamMode::STD_READWRITE);
10225 m_xDocShell->DoLoad(pMedium);
10227 ScDocShellRef xExtDocSh = new ScDocShell;
10228 xExtDocSh->SetIsInUcalc();
10229 OUString aExtDocName("file:///extdata.fake");
10230 SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
10231 xExtDocSh->DoLoad(pMed);
10232 CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
10233 findLoadedDocShellByName(aExtDocName) != nullptr);
10235 ScDocument& rExtDoc = xExtDocSh->GetDocument();
10236 rExtDoc.InsertTab(0, "ExtSheet1");
10238 m_pDoc->InsertTab(0, "Sheet1");
10240 m_pDoc->SetString(0, 5, 0, "=SUM($Sheet1.A1:A5)");
10242 ScRange aRange(0, 2, 0, 0, 5, 0);
10243 ScClipParam aClipParam(aRange, false);
10244 ScMarkData aMark(m_pDoc->GetSheetLimits());
10245 aMark.SetMarkArea(aRange);
10246 ScDocument aClipDoc(SCDOCMODE_CLIP);
10247 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10249 aRange = ScRange(0, 0, 0, 0, 3, 0);
10250 ScMarkData aMarkData2(m_pDoc->GetSheetLimits());
10251 aMarkData2.SetMarkArea(aRange);
10252 rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
10254 OUString aFormula = rExtDoc.GetFormula(0, 3, 0);
10255 //adjust absolute refs pointing to the copy area
10256 CPPUNIT_ASSERT_EQUAL(OUString("=SUM('file:///source.fake'#$Sheet1.A#REF!:A3)"), aFormula);
10258 xExtDocSh->DoClose();
10261 void TestCopyPaste::testTdf68976()
10263 const SCTAB nTab = 0;
10264 m_pDoc->InsertTab(nTab, "Test");
10266 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10267 m_pDoc->SetString(0, 1, nTab, "=$A$1"); // A2
10268 m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3
10270 // Cut A3 to the clip document.
10271 ScDocument aClipDoc(SCDOCMODE_CLIP);
10272 ScRange aSrcRange(0, 2, nTab, 0, 2, nTab);
10273 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false); // A3
10275 ScRange aDestRange(1, 3, nTab, 1, 3, nTab); // B4
10276 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10278 // Transpose
10279 ScDocument* pOrigClipDoc = &aClipDoc;
10280 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10281 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10282 aDestMark.SetMarkArea(aDestRange);
10283 // Paste
10284 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10285 true, false, true, false);
10286 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10287 pTransClip.reset();
10289 // Check results
10290 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, nTab)); // A1
10291 // Without the fix in place, this would have failed with
10292 // - Expected: =$A$1
10293 // - Actual : =$B$4
10294 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, nTab), "$A$1", "Wrong formula");
10295 // Without the fix in place, this would have failed with
10296 // - Expected: 1
10297 // - Actual : 1000
10298 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10299 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10300 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(1, 3, nTab)); // B4
10303 void TestCopyPaste::testTdf71058()
10305 const SCTAB nTab = 0;
10306 m_pDoc->InsertTab(nTab, "Test");
10308 m_pDoc->SetString(2, 2, nTab, "=C4"); // C3
10309 m_pDoc->SetString(3, 2, nTab, "=D4"); // D3
10310 m_pDoc->SetValue(2, 3, nTab, 1.0); // C4
10311 m_pDoc->SetValue(3, 3, nTab, 2.0); // D4
10313 // Cut C4:C5 to the clip document.
10314 ScDocument aClipDoc(SCDOCMODE_CLIP);
10315 ScRange aSrcRange(2, 3, nTab, 3, 3, nTab);
10316 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
10318 // To E6:E7
10319 ScRange aDestRange(4, 5, nTab, 4, 6, nTab);
10320 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10322 // Transpose
10323 ScDocument* pOrigClipDoc = &aClipDoc;
10324 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10325 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10326 aDestMark.SetMarkArea(aDestRange);
10327 // Paste
10328 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10329 true, false, true, false);
10330 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10331 pTransClip.reset();
10333 // Check precondition
10334 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(4, 5, nTab));
10335 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(4, 6, nTab));
10337 // Check results
10338 // Without the fix in place, this would have failed with
10339 // - Expected: =E6
10340 // - Actual : =C4
10341 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2, 2, nTab), "E6", "Wrong formula");
10342 // Without the fix in place, this would have failed with
10343 // - Expected: 1
10344 // - Actual : 0
10345 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(2, 2, nTab));
10347 // Without the fix in place, this would have failed with
10348 // - Expected: =E7
10349 // - Actual : =D4
10350 ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3, 2, nTab), "E7", "Wrong formula");
10351 // Without the fix in place, this would have failed with
10352 // - Expected: 2
10353 // - Actual : 0
10354 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, nTab));
10357 void TestCopyPaste::testMixData()
10359 m_pDoc->InsertTab(0, "Test");
10361 m_pDoc->SetValue(ScAddress(1, 0, 0), 2.0); // B1
10362 m_pDoc->SetValue(ScAddress(0, 1, 0), 3.0); // A2
10364 // Copy A1:B1 to the clip document.
10365 ScDocument aClipDoc(SCDOCMODE_CLIP);
10366 copyToClip(m_pDoc, ScRange(0, 0, 0, 1, 0, 0), &aClipDoc); // A1:B1
10368 // Copy A2:B2 to the mix document (for arithmetic paste).
10369 ScDocument aMixDoc(SCDOCMODE_CLIP);
10370 copyToClip(m_pDoc, ScRange(0, 1, 0, 1, 1, 0), &aMixDoc); // A2:B2
10372 // Paste A1:B1 to A2:B2 and perform addition.
10373 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 1, 1, 0), &aClipDoc);
10374 m_pDoc->MixDocument(ScRange(0, 1, 0, 1, 1, 0), ScPasteFunc::ADD, false, aMixDoc);
10376 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0, 1, 0)); // A2
10377 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 1, 0)); // B2
10379 // Clear everything and start over.
10380 clearSheet(m_pDoc, 0);
10381 clearSheet(&aClipDoc, 0);
10382 clearSheet(&aMixDoc, 0);
10384 // Set values to A1, A2, and B1. B2 will remain empty.
10385 m_pDoc->SetValue(ScAddress(0, 0, 0), 15.0);
10386 m_pDoc->SetValue(ScAddress(0, 1, 0), 16.0);
10387 m_pDoc->SetValue(ScAddress(1, 0, 0), 12.0);
10388 CPPUNIT_ASSERT_EQUAL_MESSAGE("B2 should be empty.", CELLTYPE_NONE,
10389 m_pDoc->GetCellType(ScAddress(1, 1, 0)));
10391 // Copy A1:A2 and paste it onto B1:B2 with subtraction operation.
10392 copyToClip(m_pDoc, ScRange(0, 0, 0, 0, 1, 0), &aClipDoc);
10393 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(0, 0, 0)),
10394 aClipDoc.GetValue(ScAddress(0, 0, 0)));
10395 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(0, 1, 0)),
10396 aClipDoc.GetValue(ScAddress(0, 1, 0)));
10398 copyToClip(m_pDoc, ScRange(1, 0, 0, 1, 1, 0), &aMixDoc);
10399 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(1, 0, 0)),
10400 aMixDoc.GetValue(ScAddress(1, 0, 0)));
10401 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(1, 1, 0)),
10402 aMixDoc.GetValue(ScAddress(1, 1, 0)));
10404 pasteFromClip(m_pDoc, ScRange(1, 0, 0, 1, 1, 0), &aClipDoc);
10405 m_pDoc->MixDocument(ScRange(1, 0, 0, 1, 1, 0), ScPasteFunc::SUB, false, aMixDoc);
10407 CPPUNIT_ASSERT_EQUAL(-3.0, m_pDoc->GetValue(ScAddress(1, 0, 0))); // 12 - 15
10408 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(ScAddress(1, 1, 0))); // 0 - 16
10410 m_pDoc->DeleteTab(0);
10413 void TestCopyPaste::testMixDataAsLinkTdf116413()
10415 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
10417 const SCTAB nTab = 0;
10418 m_pDoc->InsertTab(nTab, "Test");
10420 // Scenario 1: Past "As Link" and "Add" operation (as described in tdf#116413)
10421 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10422 m_pDoc->SetValue(0, 1, nTab, 1000.0); // A2
10424 // Copy A1 to the clip document.
10425 ScDocument aClipDoc(SCDOCMODE_CLIP);
10426 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 0, nTab), &aClipDoc); // A1
10428 ScRange aDestRange(0, 1, nTab, 0, 1, nTab);
10429 // Copy A2 to the mix document (for arithmetic paste).
10430 ScDocument aMixDoc(SCDOCMODE_CLIP);
10431 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A2
10433 // Paste A1 to A2 "As Link" and perform addition.
10434 ScMarkData aMark(m_pDoc->GetSheetLimits());
10435 aMark.SetMarkArea(aDestRange);
10436 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10438 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10440 // Test precondition
10441 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10442 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), getFormula(0, 1, nTab));
10444 // Change A1 from 1.0 to 2.0 (auto calculation is triggered)
10445 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10447 // Without the fix in place, this would have failed with
10448 // - Expected: =1002
10449 // - Actual : =1001
10450 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10451 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), getFormula(0, 1, nTab));
10453 // Clear everything and start over.
10454 clearSheet(m_pDoc, nTab);
10455 clearSheet(&aClipDoc, nTab);
10456 clearSheet(&aMixDoc, nTab);
10458 // Scenario 2: Like Scenario 1, but with a range (3 columns)
10459 m_pDoc->InsertTab(nTab, "Test");
10461 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10462 m_pDoc->SetValue(0, 1, nTab, 1000.0); // A2
10463 m_pDoc->SetValue(1, 0, nTab, 1.0); // B1
10464 m_pDoc->SetValue(1, 1, nTab, 1000.0); // B2
10465 m_pDoc->SetValue(2, 0, nTab, 1.0); // C1
10466 m_pDoc->SetValue(2, 1, nTab, 1000.0); // C2
10468 // Copy A1:C1 to the clip document.
10469 copyToClip(m_pDoc, ScRange(0, 0, nTab, 2, 0, nTab), &aClipDoc); // A1:C1
10471 aDestRange = ScRange(0, 1, nTab, 2, 1, nTab);
10472 // Copy A2:C2 to the mix document (for arithmetic paste).
10473 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A2:C2
10475 // Paste A1:C1 to A2:C2 "As Link" and perform addition.
10476 aMark = ScMarkData(m_pDoc->GetSheetLimits());
10477 aMark.SetMarkArea(aDestRange);
10478 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10480 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10482 // Test precondition
10483 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10484 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), getFormula(0, 1, nTab));
10486 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10487 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$B$1)"), getFormula(1, 1, nTab));
10489 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10490 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$C$1)"), getFormula(2, 1, nTab));
10492 // Change A1:C1 from 1.0 to 2.0 (auto calculation is triggered)
10493 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10494 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
10495 m_pDoc->SetValue(2, 0, nTab, 2.0); // C1
10497 // Without the fix in place, this would have failed with
10498 // - Expected: =1002
10499 // - Actual : =1001
10500 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10501 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), getFormula(0, 1, nTab));
10503 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10504 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$B$1)"), getFormula(1, 1, nTab));
10506 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10507 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$C$1)"), getFormula(2, 1, nTab));
10509 // Scenario 3: Like Scenario 2, but transposed
10510 m_pDoc->InsertTab(nTab, "Test");
10512 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10513 m_pDoc->SetValue(1, 0, nTab, 1000.0); // B1
10514 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10515 m_pDoc->SetValue(1, 1, nTab, 1000.0); // B2
10516 m_pDoc->SetValue(0, 2, nTab, 1.0); // A3
10517 m_pDoc->SetValue(1, 2, nTab, 1000.0); // B3
10519 // Copy A1:A3 to the clip document.
10520 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 2, nTab), &aClipDoc); // A1:A3
10522 aDestRange = ScRange(1, 0, nTab, 1, 2, nTab);
10523 // Copy B1:B3 to the mix document (for arithmetic paste).
10524 copyToClip(m_pDoc, aDestRange, &aMixDoc); // B1:B3
10526 // Paste A1:A3 to B1:B3 "As Link" and perform addition.
10527 aMark = ScMarkData(m_pDoc->GetSheetLimits());
10528 aMark.SetMarkArea(aDestRange);
10529 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10531 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10533 // Test precondition
10534 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nTab)); // B1
10535 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), getFormula(1, 0, nTab));
10537 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10538 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$2)"), getFormula(1, 1, nTab));
10540 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10541 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$3)"), getFormula(1, 2, nTab));
10543 // Change A1:C1 from 1.0 to 2.0 (auto calculation is triggered)
10544 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10545 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10546 m_pDoc->SetValue(0, 2, nTab, 2.0); // A3
10548 // Without the fix in place, this would have failed with
10549 // - Expected: =1002
10550 // - Actual : =1001
10551 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 0, nTab)); // B1
10552 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), getFormula(1, 0, nTab));
10554 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10555 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$2)"), getFormula(1, 1, nTab));
10557 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10558 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$3)"), getFormula(1, 2, nTab));
10560 m_pDoc->DeleteTab(nTab);
10563 void TestCopyPaste::testMixDataWithFormulaTdf116413()
10565 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
10567 const SCTAB nTab = 0;
10568 m_pDoc->InsertTab(nTab, "Test");
10570 // Scenario 1: There is already a reference in destination cell
10571 m_pDoc->InsertTab(nTab, "Test");
10573 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10574 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10575 m_pDoc->SetString(0, 2, nTab, "=A2"); // A3
10577 // Copy A1 to the clip document.
10578 ScDocument aClipDoc(SCDOCMODE_CLIP);
10579 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 0, nTab), &aClipDoc); // A1
10581 ScRange aDestRange(0, 2, nTab, 0, 2, nTab);
10582 ScDocument aMixDoc(SCDOCMODE_CLIP);
10583 // Copy A3 to the mix document (for arithmetic paste).
10584 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A3
10586 // Paste A1 to A3 and perform addition.
10587 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10588 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10590 // Test precondition
10591 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10592 CPPUNIT_ASSERT_EQUAL(OUString("=(A2)+100"), getFormula(0, 2, nTab));
10594 // Change A2 from 1.0 to 2.0 (auto calculation is triggered)
10595 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10597 // Without the fix in place, this would have failed with
10598 // - Expected: =102
10599 // - Actual : =101
10600 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10601 CPPUNIT_ASSERT_EQUAL(OUString("=(A2)+100"), getFormula(0, 2, nTab));
10603 // Clear everything and start over.
10604 clearSheet(m_pDoc, nTab);
10605 clearSheet(&aClipDoc, nTab);
10606 clearSheet(&aMixDoc, nTab);
10608 // Scenario 2: Similar to scenario 1, but a range of 4 cells and 2 of them have references
10609 m_pDoc->InsertTab(nTab, "Test");
10611 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10612 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10613 m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3
10615 m_pDoc->SetValue(1, 0, nTab, 100.0); // B1
10616 m_pDoc->SetValue(1, 1, nTab, 1.0); // B2
10617 m_pDoc->SetString(1, 2, nTab, "=B2"); // B3
10619 m_pDoc->SetValue(2, 0, nTab, 100.0); // C1
10620 m_pDoc->SetValue(2, 1, nTab, 1.0); // C2
10621 m_pDoc->SetString(2, 2, nTab, "=C2"); // C3
10623 m_pDoc->SetValue(3, 0, nTab, 100.0); // D1
10624 m_pDoc->SetValue(3, 1, nTab, 1.0); // D2
10625 m_pDoc->SetValue(3, 2, nTab, 1000.0); // D3
10627 // Copy A1:D1 to the clip document.
10628 copyToClip(m_pDoc, ScRange(0, 0, nTab, 3, 0, nTab), &aClipDoc); // A1:D1
10630 aDestRange = ScRange(0, 2, nTab, 3, 2, nTab);
10631 // Copy A3:D3 to the mix document (for arithmetic paste).
10632 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A3:D3
10634 // Paste A1:D1 to A3:D3 and perform addition.
10635 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10636 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10638 // Test precondition
10639 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10640 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(0, 2, nTab));
10642 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10643 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), getFormula(1, 2, nTab));
10645 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10646 CPPUNIT_ASSERT_EQUAL(OUString("=(C2)+100"), getFormula(2, 2, nTab));
10648 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(3, 2, nTab)); // D3
10649 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(3, 2, nTab));
10651 // Change A2:D2 from 1.0 to 2.0 (auto calculation is triggered)
10652 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10653 m_pDoc->SetValue(1, 1, nTab, 2.0); // B2
10654 m_pDoc->SetValue(2, 1, nTab, 2.0); // C2
10655 m_pDoc->SetValue(3, 1, nTab, 2.0); // D2
10657 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10658 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(0, 2, nTab));
10660 // Without the fix in place, this would have failed with
10661 // - Expected: =102
10662 // - Actual : =101
10663 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10664 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), getFormula(1, 2, nTab));
10666 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10667 CPPUNIT_ASSERT_EQUAL(OUString("=(C2)+100"), getFormula(2, 2, nTab));
10669 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(3, 2, nTab)); // D3
10670 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(3, 2, nTab));
10672 // Scenario 3: Similar to scenario 2, but transposed
10673 m_pDoc->InsertTab(nTab, "Test");
10675 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10676 m_pDoc->SetValue(1, 0, nTab, 1.0); // B1
10677 m_pDoc->SetValue(2, 0, nTab, 1000.0); // C1
10679 m_pDoc->SetValue(0, 1, nTab, 100.0); // A2
10680 m_pDoc->SetValue(1, 1, nTab, 1.0); // B2
10681 m_pDoc->SetString(2, 1, nTab, "=B2"); // C2
10683 m_pDoc->SetValue(0, 2, nTab, 100.0); // A3
10684 m_pDoc->SetValue(1, 2, nTab, 1.0); // B3
10685 m_pDoc->SetString(2, 2, nTab, "=B3"); // C3
10687 m_pDoc->SetValue(0, 3, nTab, 100.0); // A4
10688 m_pDoc->SetValue(1, 3, nTab, 1.0); // B4
10689 m_pDoc->SetValue(2, 3, nTab, 1000.0); // C4
10691 // Copy A1:A4 to the clip document.
10692 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 3, nTab), &aClipDoc); // A1:A4
10694 aDestRange = ScRange(2, 0, nTab, 2, 3, nTab);
10695 // Copy C1:C4 to the mix document (for arithmetic paste).
10696 copyToClip(m_pDoc, aDestRange, &aMixDoc); // C1:C4
10698 // Paste A1:A4 to C1:C4 and perform addition.
10699 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10700 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10702 // Test precondition
10703 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 0, nTab)); // C1
10704 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(2, 0, nTab));
10706 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10707 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), getFormula(2, 1, nTab));
10709 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10710 CPPUNIT_ASSERT_EQUAL(OUString("=(B3)+100"), getFormula(2, 2, nTab));
10712 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 3, nTab)); // C4
10713 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(2, 3, nTab));
10715 // Change B1:B4 from 1.0 to 2.0 (auto calculation is triggered)
10716 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
10717 m_pDoc->SetValue(1, 1, nTab, 2.0); // B2
10718 m_pDoc->SetValue(1, 2, nTab, 2.0); // B3
10719 m_pDoc->SetValue(1, 3, nTab, 2.0); // B4
10721 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 0, nTab)); // C1
10722 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(2, 0, nTab));
10724 // Without the fix in place, this would have failed with
10725 // - Expected: =102
10726 // - Actual : =101
10727 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10728 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), getFormula(2, 1, nTab));
10730 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10731 CPPUNIT_ASSERT_EQUAL(OUString("=(B3)+100"), getFormula(2, 2, nTab));
10733 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 3, nTab)); // C4
10734 CPPUNIT_ASSERT_EQUAL(OUString(), getFormula(2, 3, nTab));
10736 m_pDoc->DeleteTab(nTab);
10739 void TestCopyPaste::testCopyPasteMatrixFormula()
10741 m_pDoc->InsertTab(0, "hcv");
10743 // Set Values to B1, C1, D1
10744 m_pDoc->SetValue(ScAddress(1, 0, 0), 2.0); // B1
10745 m_pDoc->SetValue(ScAddress(2, 0, 0), 5.0); // C1
10746 m_pDoc->SetValue(ScAddress(3, 0, 0), 3.0); // D1
10748 // Set Values to B2, C2
10749 m_pDoc->SetString(ScAddress(1, 1, 0), "B2"); // B2
10750 //m_pDoc->SetString(ScAddress(2,1,0), "C2"); // C2
10751 m_pDoc->SetString(ScAddress(3, 1, 0), "D2"); // D2
10753 // Set Values to D3
10754 //m_pDoc->SetValue(ScAddress(1,2,0), 9.0); // B3
10755 //m_pDoc->SetString(ScAddress(2,2,0), "C3"); // C3
10756 m_pDoc->SetValue(ScAddress(3, 2, 0), 11.0); // D3
10758 // Insert matrix formula to A1
10759 ScMarkData aMark(m_pDoc->GetSheetLimits());
10760 aMark.SelectOneTable(0);
10761 m_pDoc->InsertMatrixFormula(0, 0, 0, 0, aMark, "=COUNTIF(ISBLANK(B1:D1);TRUE())");
10762 m_pDoc->CalcAll();
10763 // A1 should contain 0
10764 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0, 0, 0))); // A1
10766 // Copy cell A1 to clipboard.
10767 ScAddress aPos(0, 0, 0); // A1
10768 ScDocument aClipDoc(SCDOCMODE_CLIP);
10769 ScClipParam aParam(aPos, false);
10770 m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark, false, false);
10771 // Formula string should be equal.
10772 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
10774 // First try single range.
10775 // Paste matrix formula to A2
10776 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 0, 1, 0), &aClipDoc); // A2
10777 // A2 Cell value should contain 1.0
10778 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
10780 // Paste matrix formula to A3
10781 pasteFromClip(m_pDoc, ScRange(0, 2, 0, 0, 2, 0), &aClipDoc); // A3
10782 // A3 Cell value should contain 2.0
10783 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
10785 // Paste matrix formula to A4
10786 pasteFromClip(m_pDoc, ScRange(0, 3, 0, 0, 3, 0), &aClipDoc); // A4
10787 // A4 Cell value should contain 3.0
10788 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0, 3, 0)));
10790 // Clear cell A2:A4
10791 clearRange(m_pDoc, ScRange(0, 1, 0, 0, 3, 0));
10793 // Paste matrix formula to range A2:A4
10794 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 0, 3, 0), &aClipDoc); // A2:A4
10796 // A2 Cell value should contain 1.0
10797 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
10798 // A3 Cell value should contain 2.0
10799 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
10800 // A4 Cell value should contain 3.0
10801 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0, 3, 0)));
10803 m_pDoc->DeleteTab(0);
10806 CPPUNIT_TEST_SUITE_REGISTRATION(TestCopyPaste);
10808 CPPUNIT_PLUGIN_IMPLEMENT();
10810 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */