Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / unit / ucalc_copypaste.cxx
blobbec9bb499b943dc9992fd90b4399c826b5abfb88
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "helper/debughelper.hxx"
11 #include "helper/qahelper.hxx"
13 #include <attrib.hxx>
14 #include <bcaslot.hxx>
15 #include <clipparam.hxx>
16 #include <dbdata.hxx>
17 #include <docfunc.hxx>
18 #include <docpool.hxx>
19 #include <editeng/borderline.hxx>
20 #include <editeng/brushitem.hxx>
21 #include <editutil.hxx>
22 #include <formulacell.hxx>
23 #include <iostream>
24 #include <patattr.hxx>
25 #include <postit.hxx>
26 #include <queryparam.hxx>
27 #include <refundo.hxx>
28 #include <scitems.hxx>
29 #include <scopetools.hxx>
30 #include <undomanager.hxx>
32 #include <sfx2/docfile.hxx>
34 #include <memory>
36 using ::std::cerr;
37 using ::std::endl;
39 class TestCopyPaste : public ScUcalcTestBase
41 protected:
42 enum CalcMode
44 NoCalc,
45 AutoCalc,
46 RecalcAtEnd,
47 HardRecalcAtEnd
50 void executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
51 bool bTranspose, bool bMultiRangeSelection, bool bSkipEmpty,
52 bool bCut = false,
53 ScClipParam::Direction eDirection = ScClipParam::Column,
54 CalcMode eCalcMode = CalcMode::AutoCalc,
55 InsertDeleteFlags aFlags
56 = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB);
57 void executeCopyPasteSpecial(const SCTAB srcSheet, const SCTAB destSheet, bool bApplyFilter,
58 bool bIncludedFiltered, bool bAsLink, bool bTranspose,
59 bool bMultiRangeSelection, bool bSkipEmpty,
60 std::unique_ptr<ScUndoCut>& pUndoCut,
61 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bCut = false,
62 ScClipParam::Direction eDirection = ScClipParam::Column,
63 CalcMode eCalcMode = CalcMode::AutoCalc,
64 InsertDeleteFlags aFlags
65 = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB);
66 void checkCopyPasteSpecialInitial(const SCTAB srcSheet);
67 void checkCopyPasteSpecial(bool bSkipEmpty, bool bCut = false);
68 void checkCopyPasteSpecialFiltered(bool bSkipEmpty);
69 void checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut = false);
70 void checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty);
71 void checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty);
72 void checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty);
73 void checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty);
74 void checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty);
75 void checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty);
76 void checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty);
77 void checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty);
78 void checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty);
79 void checkReferencedCutTransposedRangesRowUndo(const SCTAB nSrcTab, const SCTAB nDestTab);
80 void executeReferencedCutRangesRow(const bool bTransposed, const SCTAB nSrcTab,
81 const SCTAB nDestTab, const bool bUndo,
82 std::unique_ptr<ScUndoCut>& pUndoCut,
83 std::unique_ptr<ScUndoPaste>& pUndoPaste);
84 void checkReferencedCutRangesRowIntitial(const SCTAB nSrcTab, const OUString& rDesc);
85 void checkReferencedCutRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab);
86 void checkReferencedCutTransposedRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab);
87 void executeReferencedCutRangesCol(const bool bTransposed, const SCTAB nSrcTab,
88 const SCTAB nDestTab, const bool bUndo,
89 std::unique_ptr<ScUndoCut>& pUndoCut,
90 std::unique_ptr<ScUndoPaste>& pUndoPaste);
91 void checkReferencedCutRangesColIntitial(const SCTAB nSrcTab, const SCTAB nDestTab,
92 const OUString& rDesc);
93 void checkReferencedCutRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab);
94 void checkReferencedCutTransposedRangesColUndo(const SCTAB nSrcTab, const SCTAB nDestTab);
95 void checkReferencedCutTransposedRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab);
96 void prepareUndoBeforePaste(bool bCut, ScDocumentUniquePtr& pPasteUndoDoc,
97 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
98 const ScMarkData& rDestMark, const ScRange& rDestRange,
99 std::unique_ptr<ScRefUndoData>& pUndoData);
100 void prepareUndoAfterPaste(ScDocumentUniquePtr& pPasteUndoDoc,
101 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
102 const ScMarkData& rDestMark, const ScRange& rDestRange,
103 std::unique_ptr<ScRefUndoData>& pUndoData,
104 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bTranspose = false,
105 bool bAsLink = false, bool bSkipEmpty = false,
106 ScPasteFunc nFunction = ScPasteFunc::NONE,
107 InsCellCmd eMoveMode = InsCellCmd::INS_NONE);
109 void printValuesAndFormulasInRange(ScDocument* pDoc, const ScRange& rRange,
110 const OString& rCaption);
111 OUString getRangeByName(const OUString& aRangeName);
112 ScAddress setNote(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString noteText);
113 OUString getNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
116 static ScMF lcl_getMergeFlagOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
118 const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE_FLAG);
119 const ScMergeFlagAttr& rMergeFlag = static_cast<const ScMergeFlagAttr&>(rPoolItem);
120 return rMergeFlag.GetValue();
123 static ScAddress lcl_getMergeSizeOfCell(const ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
125 const SfxPoolItem& rPoolItem = rDoc.GetPattern(nCol, nRow, nTab)->GetItem(ATTR_MERGE);
126 const ScMergeAttr& rMerge = static_cast<const ScMergeAttr&>(rPoolItem);
127 return ScAddress(rMerge.GetColMerge(), rMerge.GetRowMerge(), nTab);
130 void TestCopyPaste::printValuesAndFormulasInRange(ScDocument* pDoc, const ScRange& rRange,
131 const OString& rCaption)
133 printRange(pDoc, rRange, rCaption, false);
134 printRange(pDoc, rRange, rCaption, true);
137 OUString TestCopyPaste::getRangeByName(const OUString& aRangeName)
139 return ScUcalcTestBase::getRangeByName(m_pDoc, aRangeName);
142 ScAddress TestCopyPaste::setNote(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString noteText)
144 ScAddress aAdr(nCol, nRow, nTab);
145 ScPostIt* pNote = m_pDoc->GetOrCreateNote(aAdr);
146 pNote->SetText(aAdr, noteText);
147 return aAdr;
150 OUString TestCopyPaste::getNote(SCCOL nCol, SCROW nRow, SCTAB nTab)
152 ScPostIt* pNote = m_pDoc->GetNote(nCol, nRow, nTab);
153 CPPUNIT_ASSERT_MESSAGE("Note expected", pNote);
154 return pNote->GetText();
157 // Cannot be moved to qahelper since ScDocument::CopyToDocument() is not SC_DLLPUBLIC
158 /** Executes the same steps for undo as ScViewFunc::PasteFromClip(). */
159 void TestCopyPaste::prepareUndoBeforePaste(bool bCut, ScDocumentUniquePtr& pPasteUndoDoc,
160 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
161 const ScMarkData& rDestMark, const ScRange& rDestRange,
162 std::unique_ptr<ScRefUndoData>& pUndoData)
164 InsertDeleteFlags nUndoFlags = InsertDeleteFlags::CONTENTS;
165 SCTAB nTabCount = m_pDoc->GetTableCount();
167 pPasteUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
168 pPasteUndoDoc->InitUndoSelected(*m_pDoc, rDestMark, false, false);
169 // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
170 m_pDoc->CopyToDocument(rDestRange.aStart.Col(), rDestRange.aStart.Row(), 0,
171 rDestRange.aEnd.Col(), rDestRange.aEnd.Row(), nTabCount - 1, nUndoFlags,
172 false, *pPasteUndoDoc);
174 if (bCut)
176 // save changed references
177 pPasteRefUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
178 pPasteRefUndoDoc->InitUndo(*m_pDoc, 0, nTabCount - 1);
180 pUndoData.reset(new ScRefUndoData(m_pDoc));
184 // Cannot be moved to qahelper since ScDocument::CopyToDocument() is not SC_DLLPUBLIC
185 /** Executes the same steps for undo as ScViewFunc::PasteFromClip(). */
186 void TestCopyPaste::prepareUndoAfterPaste(ScDocumentUniquePtr& pPasteUndoDoc,
187 std::unique_ptr<ScDocument>& pPasteRefUndoDoc,
188 const ScMarkData& rDestMark, const ScRange& rDestRange,
189 std::unique_ptr<ScRefUndoData>& pUndoData,
190 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bTranspose,
191 bool bAsLink, bool bSkipEmpty, ScPasteFunc nFunction,
192 InsCellCmd eMoveMode)
194 InsertDeleteFlags nUndoFlags = InsertDeleteFlags::CONTENTS;
195 SCTAB nTabCount = m_pDoc->GetTableCount();
197 ScDocumentUniquePtr pPasteRedoDoc;
198 // copy redo data after appearance of the first undo
199 // don't create Redo-Doc without RefUndoDoc
201 if (pPasteRefUndoDoc)
203 pPasteRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
204 pPasteRedoDoc->InitUndo(*m_pDoc, rDestRange.aStart.Tab(), rDestRange.aEnd.Tab(), false,
205 false);
207 // move adapted refs to Redo-Doc
209 pPasteRedoDoc->AddUndoTab(0, nTabCount - 1);
210 m_pDoc->CopyUpdated(pPasteRefUndoDoc.get(), pPasteRedoDoc.get());
212 pPasteUndoDoc->AddUndoTab(0, nTabCount - 1);
213 pPasteRefUndoDoc->DeleteArea(rDestRange.aStart.Col(), rDestRange.aStart.Row(),
214 rDestRange.aEnd.Col(), rDestRange.aEnd.Row(), rDestMark,
215 InsertDeleteFlags::ALL);
216 pPasteRefUndoDoc->CopyToDocument(0, 0, 0, pPasteUndoDoc->MaxCol(), pPasteUndoDoc->MaxRow(),
217 nTabCount - 1, InsertDeleteFlags::FORMULA, false,
218 *pPasteUndoDoc);
219 pPasteRefUndoDoc.reset();
222 ScUndoPasteOptions aOptions; // store options for repeat
223 aOptions.nFunction = nFunction;
224 aOptions.bSkipEmptyCells = bSkipEmpty;
225 aOptions.bTranspose = bTranspose;
226 aOptions.bAsLink = bAsLink;
227 aOptions.eMoveMode = eMoveMode;
229 pUndoPaste.reset(new ScUndoPaste(&*m_xDocShell, rDestRange, rDestMark, std::move(pPasteUndoDoc),
230 std::move(pPasteRedoDoc), nUndoFlags, std::move(pUndoData),
231 false,
232 &aOptions)); // false = Redo data not yet copied
235 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPaste)
237 m_pDoc->InsertTab(0, "Sheet1");
238 m_pDoc->InsertTab(1, "Sheet2");
240 // We need a drawing layer in order to create caption objects.
241 m_pDoc->InitDrawLayer(m_xDocShell.get());
243 //test copy&paste + ScUndoPaste
244 //copy local and global range names in formulas
245 //string cells and value cells
246 m_pDoc->SetValue(0, 0, 0, 1);
247 m_pDoc->SetValue(3, 0, 0, 0);
248 m_pDoc->SetValue(3, 1, 0, 1);
249 m_pDoc->SetValue(3, 2, 0, 2);
250 m_pDoc->SetValue(3, 3, 0, 3);
251 m_pDoc->SetString(2, 0, 0, "test");
252 ScAddress aAdr(0, 0, 0);
254 //create some range names, local and global
255 ScRangeData* pLocal1 = new ScRangeData(*m_pDoc, "local1", aAdr);
256 ScRangeData* pLocal2 = new ScRangeData(*m_pDoc, "local2", aAdr);
257 ScRangeData* pLocal3 = new ScRangeData(*m_pDoc, "local3", "$Sheet1.$A$1");
258 ScRangeData* pLocal4 = new ScRangeData(*m_pDoc, "local4", "Sheet1.$A$1");
259 ScRangeData* pLocal5
260 = new ScRangeData(*m_pDoc, "local5", "$A$1"); // implicit relative sheet reference
261 ScRangeData* pGlobal = new ScRangeData(*m_pDoc, "global", aAdr);
262 constexpr OUString aGlobal2Symbol(u"$Sheet1.$A$1:$A$23"_ustr);
263 ScRangeData* pGlobal2 = new ScRangeData(*m_pDoc, "global2", aGlobal2Symbol);
264 std::unique_ptr<ScRangeName> pGlobalRangeName(new ScRangeName());
265 pGlobalRangeName->insert(pGlobal);
266 pGlobalRangeName->insert(pGlobal2);
267 std::unique_ptr<ScRangeName> pLocalRangeName1(new ScRangeName());
268 pLocalRangeName1->insert(pLocal1);
269 pLocalRangeName1->insert(pLocal2);
270 pLocalRangeName1->insert(pLocal3);
271 pLocalRangeName1->insert(pLocal4);
272 pLocalRangeName1->insert(pLocal5);
273 m_pDoc->SetRangeName(std::move(pGlobalRangeName));
274 m_pDoc->SetRangeName(0, std::move(pLocalRangeName1));
276 // Add formula to B1.
277 OUString aFormulaString("=local1+global+SUM($C$1:$D$4)+local3+local4+local5");
278 m_pDoc->SetString(1, 0, 0, aFormulaString);
280 double fValue = m_pDoc->GetValue(ScAddress(1, 0, 0));
281 ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 11", 11, fValue);
283 // add notes to A1:C1
284 setNote(0, 0, 0, "Hello world in A1"); // empty cell content
285 setNote(1, 0, 0, "Hello world in B1"); // formula cell content
286 setNote(2, 0, 0, "Hello world in C1"); // string cell content
288 //copy Sheet1.A1:C1 to Sheet2.A2:C2
289 ScRange aRange(0, 0, 0, 2, 0, 0);
290 ScDocument aClipDoc(SCDOCMODE_CLIP);
291 copyToClip(m_pDoc, aRange, &aClipDoc);
293 aRange = ScRange(0, 1, 1, 2, 1, 1); //target: Sheet2.A2:C2
294 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
295 pUndoDoc->InitUndo(*m_pDoc, 1, 1, true, true);
296 std::unique_ptr<ScUndoPaste> pUndo(createUndoPaste(*m_xDocShell, aRange, std::move(pUndoDoc)));
297 ScMarkData aMark(m_pDoc->GetSheetLimits());
298 aMark.SetMarkArea(aRange);
299 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
301 //check values after copying
302 OUString aString = m_pDoc->GetFormula(1, 1, 1);
303 CPPUNIT_ASSERT_EQUAL_MESSAGE("formula string was not copied correctly", aString,
304 aFormulaString);
305 // Only the global range points to Sheet1.A1, all copied sheet-local ranges
306 // to Sheet2.A1 that is empty, hence the result is 1, not 2.
307 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
308 ASSERT_DOUBLES_EQUAL_MESSAGE("copied formula should return 1", 1.0, fValue);
309 fValue = m_pDoc->GetValue(ScAddress(0, 1, 1));
310 ASSERT_DOUBLES_EQUAL_MESSAGE("copied value should be 1", 1.0, fValue);
312 ScRange aSheet2A1(0, 0, 1, 0, 0, 1);
314 //check local range name after copying
315 pLocal1 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL1"));
316 CPPUNIT_ASSERT_MESSAGE("local range name 1 should be copied", pLocal1);
317 ScRange aRangeLocal1;
318 bool bIsValidRef1 = pLocal1->IsValidReference(aRangeLocal1);
319 CPPUNIT_ASSERT_MESSAGE("local range name 1 should be valid", bIsValidRef1);
320 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 1 should now point to Sheet2.A1", aSheet2A1,
321 aRangeLocal1);
323 pLocal2 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL2"));
324 CPPUNIT_ASSERT_MESSAGE("local2 should not be copied", !pLocal2);
326 pLocal3 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL3"));
327 CPPUNIT_ASSERT_MESSAGE("local range name 3 should be copied", pLocal3);
328 ScRange aRangeLocal3;
329 bool bIsValidRef3 = pLocal3->IsValidReference(aRangeLocal3);
330 CPPUNIT_ASSERT_MESSAGE("local range name 3 should be valid", bIsValidRef3);
331 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 3 should now point to Sheet2.A1", aSheet2A1,
332 aRangeLocal3);
334 pLocal4 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL4"));
335 CPPUNIT_ASSERT_MESSAGE("local range name 4 should be copied", pLocal4);
336 ScRange aRangeLocal4;
337 bool bIsValidRef4 = pLocal4->IsValidReference(aRangeLocal4);
338 CPPUNIT_ASSERT_MESSAGE("local range name 4 should be valid", bIsValidRef4);
339 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 4 should now point to Sheet2.A1", aSheet2A1,
340 aRangeLocal4);
342 pLocal5 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL5"));
343 CPPUNIT_ASSERT_MESSAGE("local range name 5 should be copied", pLocal5);
344 ScRange aRangeLocal5;
345 bool bIsValidRef5 = pLocal5->IsValidReference(aRangeLocal5);
346 CPPUNIT_ASSERT_MESSAGE("local range name 5 should be valid", bIsValidRef5);
347 CPPUNIT_ASSERT_EQUAL_MESSAGE("local range 5 should now point to Sheet2.A1", aSheet2A1,
348 aRangeLocal5);
350 // check notes after copying
351 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.A2", m_pDoc->HasNote(0, 1, 1));
352 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.B2", m_pDoc->HasNote(1, 1, 1));
353 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.C2", m_pDoc->HasNote(2, 1, 1));
354 CPPUNIT_ASSERT_EQUAL_MESSAGE(
355 "Note content on Sheet1.A1 not copied to Sheet2.A2, empty cell content",
356 m_pDoc->GetNote(0, 0, 0)->GetText(), m_pDoc->GetNote(0, 1, 1)->GetText());
357 CPPUNIT_ASSERT_EQUAL_MESSAGE(
358 "Note content on Sheet1.B1 not copied to Sheet2.B2, formula cell content",
359 m_pDoc->GetNote(1, 0, 0)->GetText(), m_pDoc->GetNote(1, 1, 1)->GetText());
360 CPPUNIT_ASSERT_EQUAL_MESSAGE(
361 "Note content on Sheet1.C1 not copied to Sheet2.C2, string cell content",
362 m_pDoc->GetNote(2, 0, 0)->GetText(), m_pDoc->GetNote(2, 1, 1)->GetText());
364 //check undo and redo
365 pUndo->Undo();
366 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
367 ASSERT_DOUBLES_EQUAL_MESSAGE("after undo formula should return nothing", 0, fValue);
368 aString = m_pDoc->GetString(2, 1, 1);
369 CPPUNIT_ASSERT_MESSAGE("after undo, string should be removed", aString.isEmpty());
370 CPPUNIT_ASSERT_MESSAGE("after undo, note on A2 should be removed", !m_pDoc->HasNote(0, 1, 1));
371 CPPUNIT_ASSERT_MESSAGE("after undo, note on B2 should be removed", !m_pDoc->HasNote(1, 1, 1));
372 CPPUNIT_ASSERT_MESSAGE("after undo, note on C2 should be removed", !m_pDoc->HasNote(2, 1, 1));
374 pUndo->Redo();
375 fValue = m_pDoc->GetValue(ScAddress(1, 1, 1));
376 ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 1 after redo", 1.0, fValue);
377 aString = m_pDoc->GetString(2, 1, 1);
378 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.C2 should contain: test", OUString("test"), aString);
379 aString = m_pDoc->GetFormula(1, 1, 1);
380 CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula should be correct again", aFormulaString, aString);
382 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.A2",
383 m_pDoc->HasNote(0, 1, 1));
384 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.B2",
385 m_pDoc->HasNote(1, 1, 1));
386 CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.C2",
387 m_pDoc->HasNote(2, 1, 1));
388 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.A2, empty cell content",
389 getNote(0, 0, 0), getNote(0, 1, 1));
390 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.B2, formula cell content",
391 getNote(1, 0, 0), getNote(1, 1, 1));
392 CPPUNIT_ASSERT_EQUAL_MESSAGE("After Redo, note again on Sheet2.C2, string cell content",
393 getNote(2, 0, 0), getNote(2, 1, 1));
395 // Copy Sheet1.A11:A13 to Sheet1.A7:A9, both within global2 range.
396 aRange = ScRange(0, 10, 0, 0, 12, 0);
397 ScDocument aClipDoc2(SCDOCMODE_CLIP);
398 copyToClip(m_pDoc, aRange, &aClipDoc2);
400 aRange = ScRange(0, 6, 0, 0, 8, 0);
401 aMark.SetMarkArea(aRange);
402 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc2);
404 // The global2 range must not have changed.
405 pGlobal2 = m_pDoc->GetRangeName()->findByUpperName("GLOBAL2");
406 CPPUNIT_ASSERT_MESSAGE("GLOBAL2 name not found", pGlobal2);
407 OUString aSymbol = pGlobal2->GetSymbol();
408 CPPUNIT_ASSERT_EQUAL_MESSAGE("GLOBAL2 named range changed", aGlobal2Symbol, aSymbol);
410 m_pDoc->DeleteTab(1);
411 m_pDoc->DeleteTab(0);
414 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteAsLink)
416 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
418 m_pDoc->InsertTab(0, "Sheet1");
419 m_pDoc->InsertTab(1, "Sheet2");
421 m_pDoc->SetValue(ScAddress(0, 0, 0), 1); // A1
422 m_pDoc->SetValue(ScAddress(0, 1, 0), 2); // A2
423 m_pDoc->SetValue(ScAddress(0, 2, 0), 3); // A3
425 ScRange aRange(0, 0, 0, 0, 2, 0); // Copy A1:A3 to clip.
426 ScDocument aClipDoc(SCDOCMODE_CLIP);
427 copyToClip(m_pDoc, aRange, &aClipDoc);
429 aRange = ScRange(1, 1, 1, 1, 3, 1); // Paste to B2:B4 on Sheet2.
430 ScMarkData aMark(m_pDoc->GetSheetLimits());
431 aMark.SetMarkArea(aRange);
432 // Paste range as link.
433 m_pDoc->CopyFromClip(aRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &aClipDoc, true,
434 true);
436 // Check pasted content to make sure they reference the correct cells.
437 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, 1));
438 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
439 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
441 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, 1));
442 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
443 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
445 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, 1));
446 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
447 CPPUNIT_ASSERT_EQUAL(3.0, pFC->GetValue());
449 m_pDoc->DeleteTab(1);
450 m_pDoc->DeleteTab(0);
453 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteTranspose)
455 m_pDoc->InsertTab(0, "Sheet1");
457 // We need a drawing layer in order to create caption objects.
458 m_pDoc->InitDrawLayer(m_xDocShell.get());
460 m_pDoc->SetValue(0, 0, 0, 1);
461 m_pDoc->SetString(1, 0, 0, "=A1+1");
462 m_pDoc->SetString(2, 0, 0, "test");
464 // add notes to A1:C1
465 setNote(0, 0, 0, "Hello world in A1"); // numerical cell content
466 setNote(1, 0, 0, "Hello world in B1"); // formula cell content
467 setNote(2, 0, 0, "Hello world in C1"); // string cell content
469 // transpose clipboard, paste and check on Sheet2
470 m_pDoc->InsertTab(1, "Sheet2");
472 ScRange aSrcRange(0, 0, 0, 2, 0, 0);
473 ScDocument aNewClipDoc(SCDOCMODE_CLIP);
474 copyToClip(m_pDoc, aSrcRange, &aNewClipDoc);
476 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
477 aNewClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, false);
479 ScRange aDestRange(3, 1, 1, 3, 3, 1); //target: Sheet2.D2:D4
480 ScMarkData aMark(m_pDoc->GetSheetLimits());
481 aMark.SetMarkArea(aDestRange);
482 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get());
483 pTransClip.reset();
485 //check cell content after transposed copy/paste
486 OUString aString = m_pDoc->GetString(3, 3, 1);
487 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell Sheet2.D4 should contain: test", OUString("test"), aString);
488 double fValue = m_pDoc->GetValue(ScAddress(3, 1, 1));
489 ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied cell should return 1", 1, fValue);
490 fValue = m_pDoc->GetValue(ScAddress(3, 2, 1));
491 ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied formula should return 2", 2, fValue);
492 aString = m_pDoc->GetFormula(3, 2, 1);
493 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed formula should point on Sheet2.D2", OUString("=D2+1"),
494 aString);
496 // check notes after transposed copy/paste
497 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D2", m_pDoc->HasNote(3, 1, 1));
498 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D3", m_pDoc->HasNote(3, 2, 1));
499 CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D4", m_pDoc->HasNote(3, 3, 1));
500 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D2", getNote(0, 0, 0),
501 getNote(3, 1, 1));
502 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D3", getNote(1, 0, 0),
503 getNote(3, 2, 1));
504 CPPUNIT_ASSERT_EQUAL_MESSAGE("Content of cell note on Sheet2.D4", getNote(2, 0, 0),
505 getNote(3, 3, 1));
507 m_pDoc->DeleteTab(1);
508 m_pDoc->DeleteTab(0);
511 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMergedCellsTranspose)
513 const SCTAB srcSheet = 0;
514 const SCTAB destSheet = 1;
516 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
518 m_pDoc->InsertTab(srcSheet, "Sheet1");
519 m_pDoc->InsertTab(destSheet, "Sheet2");
521 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
522 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
523 m_pDoc->SetValue(0, 2, srcSheet, 3); // A3
524 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
526 m_pDoc->DoMerge(0, 1, 1, 1, srcSheet, false); // Merge A2 and B2
527 m_pDoc->DoMerge(0, 2, 1, 2, srcSheet, false); // Merge A3 and B3
529 // Test precondition
530 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
531 lcl_getMergeSizeOfCell(*m_pDoc, 0, 0, srcSheet));
532 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 0, srcSheet));
533 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
534 lcl_getMergeSizeOfCell(*m_pDoc, 0, 1, srcSheet));
535 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
536 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, srcSheet));
537 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 1, srcSheet));
538 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
539 lcl_getMergeSizeOfCell(*m_pDoc, 0, 2, srcSheet));
540 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
541 lcl_getMergeSizeOfCell(*m_pDoc, 1, 2, srcSheet));
542 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, srcSheet));
543 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
544 lcl_getMergeSizeOfCell(*m_pDoc, 0, 3, srcSheet));
545 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 3, srcSheet));
547 ScRange aSrcRange(0, 0, srcSheet, 1, 3, srcSheet); // Copy A1:B4 to clip.
548 ScDocument aClipDoc(SCDOCMODE_CLIP);
549 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
551 // transpose
552 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
553 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
555 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
556 ScMarkData aMark(m_pDoc->GetSheetLimits());
557 aMark.SetMarkArea(aDestRange);
558 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
559 false);
560 pTransClip.reset();
562 // Check transpose of merged cells
563 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
564 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, destSheet));
565 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, destSheet));
566 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
567 lcl_getMergeSizeOfCell(*m_pDoc, 2, 1, destSheet));
568 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 1, destSheet));
569 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
570 lcl_getMergeSizeOfCell(*m_pDoc, 3, 1, destSheet));
571 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 1, destSheet));
572 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
573 lcl_getMergeSizeOfCell(*m_pDoc, 4, 1, destSheet));
574 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 4, 2, destSheet));
576 m_pDoc->DeleteTab(destSheet);
577 m_pDoc->DeleteTab(srcSheet);
580 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMergedCellsFilteredTranspose)
582 const SCTAB srcSheet = 0;
583 const SCTAB destSheet = 1;
585 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
587 m_pDoc->InsertTab(srcSheet, "Sheet1");
588 m_pDoc->InsertTab(destSheet, "Sheet2");
590 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
591 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
592 m_pDoc->SetValue(0, 2, srcSheet, 3); // A3
593 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
595 m_pDoc->DoMerge(0, 1, 1, 1, srcSheet, false); // Merge A2 and B2
596 m_pDoc->DoMerge(0, 2, 1, 2, srcSheet, false); // Merge A3 and B3
598 // Filter row 1
599 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
600 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
602 pDBData->SetAutoFilter(true);
603 ScRange aRange;
604 pDBData->GetArea(aRange);
605 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
606 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
608 //create the query param
609 ScQueryParam aParam;
610 pDBData->GetQueryParam(aParam);
611 ScQueryEntry& rEntry = aParam.GetEntry(0);
612 rEntry.bDoQuery = true;
613 rEntry.nField = 0;
614 rEntry.eOp = SC_NOT_EQUAL;
615 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
616 // add queryParam to database range.
617 pDBData->SetQueryParam(aParam);
619 // perform the query.
620 m_pDoc->Query(srcSheet, aParam, true);
622 // Test precondition
623 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
624 lcl_getMergeSizeOfCell(*m_pDoc, 0, 0, srcSheet));
625 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 0, srcSheet));
626 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
627 lcl_getMergeSizeOfCell(*m_pDoc, 0, 1, srcSheet));
628 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
629 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, srcSheet));
630 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 1, srcSheet));
631 CPPUNIT_ASSERT_EQUAL(ScAddress(2, 1, srcSheet),
632 lcl_getMergeSizeOfCell(*m_pDoc, 0, 2, srcSheet));
633 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
634 lcl_getMergeSizeOfCell(*m_pDoc, 1, 2, srcSheet));
635 CPPUNIT_ASSERT_EQUAL(ScMF::Hor, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, srcSheet));
636 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, srcSheet),
637 lcl_getMergeSizeOfCell(*m_pDoc, 0, 3, srcSheet));
638 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 3, srcSheet));
640 ScRange aSrcRange(0, 0, srcSheet, 1, 3, srcSheet); // Copy A1:B4 to clip.
641 ScDocument aClipDoc(SCDOCMODE_CLIP);
642 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
644 // transpose
645 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
646 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
648 ScRange aDestRange(1, 1, destSheet, 3, 2, destSheet); // Paste to B2:D3 on Sheet2.
649 ScMarkData aMark(m_pDoc->GetSheetLimits());
650 aMark.SetMarkArea(aDestRange);
651 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
652 false);
653 pTransClip.reset();
655 // Check transpose of merged cells
656 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
657 lcl_getMergeSizeOfCell(*m_pDoc, 1, 1, destSheet));
658 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 1, 2, destSheet));
659 CPPUNIT_ASSERT_EQUAL(ScAddress(1, 2, destSheet),
660 lcl_getMergeSizeOfCell(*m_pDoc, 2, 1, destSheet));
661 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 1, destSheet));
662 CPPUNIT_ASSERT_EQUAL(ScAddress(0, 0, destSheet),
663 lcl_getMergeSizeOfCell(*m_pDoc, 3, 1, destSheet));
664 CPPUNIT_ASSERT_EQUAL(ScMF::NONE, lcl_getMergeFlagOfCell(*m_pDoc, 3, 2, destSheet));
666 m_pDoc->DeleteTab(destSheet);
667 m_pDoc->DeleteTab(srcSheet);
670 // InsertDeleteFlags::CONTENTS
671 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialAsLinkTranspose)
673 const SCTAB srcSheet = 0;
674 const SCTAB destSheet = 1;
676 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
678 m_pDoc->InsertTab(srcSheet, "Sheet1");
679 m_pDoc->InsertTab(destSheet, "Sheet2");
681 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
682 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
683 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
685 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet); // Copy A1:A4 to clip.
686 ScDocument aClipDoc(SCDOCMODE_CLIP);
687 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
689 // transpose
690 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
691 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::CONTENTS, true, false);
693 ScRange aDestRange(1, 1, destSheet, 4, 1, destSheet); // Paste to B2:E2 on Sheet2.
694 ScMarkData aMark(m_pDoc->GetSheetLimits());
695 aMark.SetMarkArea(aDestRange);
696 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, pTransClip.get(),
697 true, false);
698 pTransClip.reset();
700 // Check pasted content to make sure they reference the correct cells.
701 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
702 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
703 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
704 m_pDoc->GetFormula(1, 1, destSheet));
705 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
707 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
708 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
709 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"),
710 m_pDoc->GetFormula(2, 1, destSheet));
711 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
713 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
714 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D2.", !pFC);
716 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
717 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
718 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"),
719 m_pDoc->GetFormula(4, 1, destSheet));
720 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
722 m_pDoc->DeleteTab(destSheet);
723 m_pDoc->DeleteTab(srcSheet);
726 // InsertDeleteFlags::CONTENTS
727 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialAsLinkFilteredTranspose)
729 const SCTAB srcSheet = 0;
730 const SCTAB destSheet = 1;
732 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
734 m_pDoc->InsertTab(srcSheet, "Sheet1");
735 m_pDoc->InsertTab(destSheet, "Sheet2");
737 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
738 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
739 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
741 // Filter row 1
742 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
743 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
745 pDBData->SetAutoFilter(true);
746 ScRange aRange;
747 pDBData->GetArea(aRange);
748 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
749 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
751 //create the query param
752 ScQueryParam aParam;
753 pDBData->GetQueryParam(aParam);
754 ScQueryEntry& rEntry = aParam.GetEntry(0);
755 rEntry.bDoQuery = true;
756 rEntry.nField = 0;
757 rEntry.eOp = SC_NOT_EQUAL;
758 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
759 // add queryParam to database range.
760 pDBData->SetQueryParam(aParam);
762 // perform the query.
763 m_pDoc->Query(srcSheet, aParam, true);
765 // Check precondition for test: row 1 is hidden/filtered
766 SCROW nRow1, nRow2;
767 SCROW nFilteredRow1, nFilteredRow2;
768 bool bHidden = m_pDoc->RowHidden(SCROW(1), srcSheet, &nRow1, &nRow2);
769 CPPUNIT_ASSERT_MESSAGE("row 1 should be hidden", bHidden);
770 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow1);
771 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow2);
772 bool bFiltered = m_pDoc->RowFiltered(SCROW(1), srcSheet, &nFilteredRow1, &nFilteredRow2);
773 CPPUNIT_ASSERT_MESSAGE("row 1 should be filtered", bFiltered);
774 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow1);
775 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow2);
777 // Copy A1:A4 to clip.
778 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet);
779 ScDocument aClipDoc(SCDOCMODE_CLIP);
780 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
782 // transpose
783 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
784 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::CONTENTS, true, false);
786 ScRange aDestRange(1, 1, destSheet, 3, 1, destSheet); // Paste to B2:D2 on Sheet2.
787 ScMarkData aMark(m_pDoc->GetSheetLimits());
788 aMark.SetMarkArea(aDestRange);
789 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, pTransClip.get(),
790 true, false, false);
791 pTransClip.reset();
793 // Check pasted content to make sure they reference the correct cells.
794 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
795 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
796 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
797 m_pDoc->GetFormula(1, 1, destSheet));
798 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
800 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
801 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C2.", !pFC);
803 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
804 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
805 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"),
806 m_pDoc->GetFormula(3, 1, destSheet));
807 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
809 m_pDoc->DeleteTab(destSheet);
810 m_pDoc->DeleteTab(srcSheet);
813 // tdf#141683
814 // InsertDeleteFlags::VALUE
815 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowAsLinkTranspose)
817 const SCTAB srcSheet = 0;
818 const SCTAB destSheet = 1;
820 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
822 m_pDoc->InsertTab(srcSheet, "Sheet1");
823 m_pDoc->InsertTab(destSheet, "Sheet2");
825 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
826 m_pDoc->SetValue(1, 0, srcSheet, 2); // B1
827 m_pDoc->SetValue(3, 0, srcSheet, 4); // D1
829 m_pDoc->SetValue(0, 2, srcSheet, 11); // A3
830 m_pDoc->SetValue(1, 2, srcSheet, 12); // B3
831 m_pDoc->SetValue(3, 2, srcSheet, 14); // D3
833 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
834 aSrcMark.SelectOneTable(0);
835 ScClipParam aClipParam;
836 aClipParam.meDirection = ScClipParam::Row;
837 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 3, 0, srcSheet)); // A1:D1
838 aClipParam.maRanges.push_back(ScRange(0, 2, srcSheet, 3, 2, srcSheet)); // A3:D3
840 ScDocument aClipDoc(SCDOCMODE_CLIP);
841 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
843 // transpose
844 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
845 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
847 ScRange aDestRange(1, 1, destSheet, 2, 4, destSheet); // Paste to B2:C5 on Sheet2.
848 ScMarkData aMark(m_pDoc->GetSheetLimits());
849 aMark.SetMarkArea(aDestRange);
850 m_pDoc->CopyMultiRangeFromClip(
851 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
852 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
853 pTransClip.reset();
855 // Check pasted content to make sure they reference the correct cells.
856 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
857 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
858 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
859 m_pDoc->GetFormula(1, 1, destSheet));
860 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
862 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
863 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
864 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$B$1"),
865 m_pDoc->GetFormula(1, 2, destSheet));
866 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
868 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, destSheet));
869 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell B4.", !pFC);
871 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 4, destSheet));
872 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
873 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B5", OUString("=$Sheet1.$D$1"),
874 m_pDoc->GetFormula(1, 4, destSheet));
875 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
877 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
878 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
879 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"),
880 m_pDoc->GetFormula(2, 1, destSheet));
881 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
883 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
884 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
885 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$B$3"),
886 m_pDoc->GetFormula(2, 2, destSheet));
887 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
889 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 3, destSheet));
890 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C4.", !pFC);
892 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 4, destSheet));
893 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
894 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C5", OUString("=$Sheet1.$D$3"),
895 m_pDoc->GetFormula(2, 4, destSheet));
896 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
898 m_pDoc->DeleteTab(destSheet);
899 m_pDoc->DeleteTab(srcSheet);
902 // tdf#141683
903 // InsertDeleteFlags::VALUE
904 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowAsLinkFilteredTranspose)
906 const SCTAB srcSheet = 0;
907 const SCTAB destSheet = 1;
909 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
911 m_pDoc->InsertTab(srcSheet, "Sheet1");
912 m_pDoc->InsertTab(destSheet, "Sheet2");
914 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
915 m_pDoc->SetValue(1, 0, srcSheet, 2); // B1
916 m_pDoc->SetValue(3, 0, srcSheet, 4); // D1
918 m_pDoc->SetValue(0, 1, srcSheet, -1); // A2, filtered and selected
919 m_pDoc->SetValue(1, 1, srcSheet, -2); // B2, filtered and selected
920 m_pDoc->SetValue(3, 1, srcSheet, -4); // D2, filtered and selected
922 m_pDoc->SetValue(0, 2, srcSheet, 11); // A3
923 m_pDoc->SetValue(1, 2, srcSheet, 12); // B3
924 m_pDoc->SetValue(3, 2, srcSheet, 14); // D3
926 m_pDoc->SetValue(0, 3, srcSheet, -11); // A4, filtered and not selected
927 m_pDoc->SetValue(1, 3, srcSheet, -12); // B4, filtered and not selected
928 m_pDoc->SetValue(3, 3, srcSheet, -14); // D4, filtered and not selected
930 m_pDoc->SetValue(0, 5, srcSheet, 111); // A6
931 m_pDoc->SetValue(1, 5, srcSheet, 112); // B6
932 m_pDoc->SetValue(3, 5, srcSheet, 114); // D6
934 // Filter row 1
935 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 3, 3);
936 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
938 pDBData->SetAutoFilter(true);
939 ScRange aRange;
940 pDBData->GetArea(aRange);
941 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
942 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
944 //create the query param
945 ScQueryParam aParam;
946 pDBData->GetQueryParam(aParam);
947 ScQueryEntry& rEntry = aParam.GetEntry(0);
948 rEntry.bDoQuery = true;
949 rEntry.nField = 0;
950 rEntry.eOp = SC_GREATER_EQUAL;
951 rEntry.GetQueryItem().mfVal = 0; // filtering negative values -> filtering row 1 and 2
952 // add queryParam to database range.
953 pDBData->SetQueryParam(aParam);
955 // perform the query.
956 m_pDoc->Query(srcSheet, aParam, true);
958 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
959 aSrcMark.SelectOneTable(0);
960 ScClipParam aClipParam;
961 aClipParam.meDirection = ScClipParam::Row;
962 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 3, 2, srcSheet)); // A1:C3
963 aClipParam.maRanges.push_back(ScRange(0, 5, srcSheet, 3, 5, srcSheet)); // A6:C6
965 ScDocument aClipDoc(SCDOCMODE_CLIP);
966 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
968 printRange(m_pDoc, aClipParam.getWholeRange(), "Src range");
969 // transpose
970 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
971 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
973 printRange(&aClipDoc, ScRange(0, 0, 0, 4, 5, 0), "Base doc (&aClipDoc)");
974 printRange(pTransClip.get(), ScRange(0, 0, 0, 3, 3, 0),
975 "Transposed filtered clipdoc (pTransClip.get())");
976 ScRange aDestRange(1, 1, destSheet, 3, 4, destSheet); // Paste to B2:D5 on Sheet2.
977 ScMarkData aMark(m_pDoc->GetSheetLimits());
978 aMark.SetMarkArea(aDestRange);
979 m_pDoc->CopyMultiRangeFromClip(
980 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
981 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
982 pTransClip.reset();
983 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
985 // Check pasted content to make sure they reference the correct cells.
986 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
987 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
988 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
989 m_pDoc->GetFormula(1, 1, destSheet));
990 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
992 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
993 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
994 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$B$1"),
995 m_pDoc->GetFormula(1, 2, destSheet));
996 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
998 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 3, destSheet));
999 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell B4.", !pFC);
1001 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 4, destSheet));
1002 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1003 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B5", OUString("=$Sheet1.$D$1"),
1004 m_pDoc->GetFormula(1, 4, destSheet));
1005 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1007 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1008 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1009 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"),
1010 m_pDoc->GetFormula(2, 1, destSheet));
1011 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1013 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1014 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1015 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$B$3"),
1016 m_pDoc->GetFormula(2, 2, destSheet));
1017 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1019 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 3, destSheet));
1020 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C4.", !pFC);
1022 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 4, destSheet));
1023 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1024 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C5", OUString("=$Sheet1.$D$3"),
1025 m_pDoc->GetFormula(2, 4, destSheet));
1026 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1028 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1029 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell D2.", pFC);
1030 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$6"),
1031 m_pDoc->GetFormula(3, 1, destSheet));
1032 CPPUNIT_ASSERT_EQUAL(111.0, pFC->GetValue());
1034 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1035 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell D3.", pFC);
1036 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("=$Sheet1.$B$6"),
1037 m_pDoc->GetFormula(3, 2, destSheet));
1038 CPPUNIT_ASSERT_EQUAL(112.0, pFC->GetValue());
1040 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 3, destSheet));
1041 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D4.", !pFC);
1043 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 4, destSheet));
1044 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1045 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("=$Sheet1.$D$6"),
1046 m_pDoc->GetFormula(3, 4, destSheet));
1047 CPPUNIT_ASSERT_EQUAL(114.0, pFC->GetValue());
1049 m_pDoc->DeleteTab(destSheet);
1050 m_pDoc->DeleteTab(srcSheet);
1053 // tdf#141683
1054 // InsertDeleteFlags::VALUE
1055 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColAsLinkTranspose)
1057 const SCTAB srcSheet = 0;
1058 const SCTAB destSheet = 1;
1060 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1062 m_pDoc->InsertTab(srcSheet, "Sheet1");
1063 m_pDoc->InsertTab(destSheet, "Sheet2");
1065 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1066 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1067 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1069 m_pDoc->SetValue(2, 0, srcSheet, 11); // C1
1070 m_pDoc->SetValue(2, 1, srcSheet, 12); // C2
1071 m_pDoc->SetValue(2, 3, srcSheet, 14); // C4
1073 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1074 aSrcMark.SelectOneTable(0);
1075 ScClipParam aClipParam;
1076 aClipParam.meDirection = ScClipParam::Column;
1077 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 0, 3, srcSheet)); // A1:A4
1078 aClipParam.maRanges.push_back(ScRange(2, 0, srcSheet, 2, 3, srcSheet)); // C1:C4
1080 ScDocument aClipDoc(SCDOCMODE_CLIP);
1081 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1083 // transpose
1084 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1085 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1087 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
1088 ScMarkData aMark(m_pDoc->GetSheetLimits());
1089 aMark.SetMarkArea(aDestRange);
1090 m_pDoc->CopyMultiRangeFromClip(
1091 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1092 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1093 pTransClip.reset();
1095 // Check pasted content to make sure they reference the correct cells.
1096 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1097 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1098 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1099 m_pDoc->GetFormula(1, 1, destSheet));
1100 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1102 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1103 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C2.", pFC);
1104 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"),
1105 m_pDoc->GetFormula(2, 1, destSheet));
1106 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1108 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1109 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D2.", !pFC);
1111 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
1112 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1113 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"),
1114 m_pDoc->GetFormula(4, 1, destSheet));
1115 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1117 pFC = m_pDoc->GetFormulaCell(ScAddress(1, 2, destSheet));
1118 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B3.", pFC);
1119 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B3", OUString("=$Sheet1.$C$1"),
1120 m_pDoc->GetFormula(1, 2, destSheet));
1121 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1123 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1124 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell C3.", pFC);
1125 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C3", OUString("=$Sheet1.$C$2"),
1126 m_pDoc->GetFormula(2, 2, destSheet));
1127 CPPUNIT_ASSERT_EQUAL(12.0, pFC->GetValue());
1129 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1130 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell D3.", !pFC);
1132 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 2, destSheet));
1133 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1134 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("=$Sheet1.$C$4"),
1135 m_pDoc->GetFormula(4, 2, destSheet));
1136 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1138 m_pDoc->DeleteTab(destSheet);
1139 m_pDoc->DeleteTab(srcSheet);
1142 // tdf#141683
1143 // InsertDeleteFlags::VALUE
1144 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColAsLinkFilteredTranspose)
1146 const SCTAB srcSheet = 0;
1147 const SCTAB destSheet = 1;
1149 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1151 m_pDoc->InsertTab(srcSheet, "Sheet1");
1152 m_pDoc->InsertTab(destSheet, "Sheet2");
1154 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1155 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1156 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1158 m_pDoc->SetValue(2, 0, srcSheet, 11); // C1
1159 m_pDoc->SetValue(2, 1, srcSheet, 12); // C2
1160 m_pDoc->SetValue(2, 3, srcSheet, 14); // C4
1162 // Filter row 1
1163 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
1164 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1166 pDBData->SetAutoFilter(true);
1167 ScRange aRange;
1168 pDBData->GetArea(aRange);
1169 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1170 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1172 //create the query param
1173 ScQueryParam aParam;
1174 pDBData->GetQueryParam(aParam);
1175 ScQueryEntry& rEntry = aParam.GetEntry(0);
1176 rEntry.bDoQuery = true;
1177 rEntry.nField = 0;
1178 rEntry.eOp = SC_NOT_EQUAL;
1179 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1180 // add queryParam to database range.
1181 pDBData->SetQueryParam(aParam);
1183 // perform the query.
1184 m_pDoc->Query(srcSheet, aParam, true);
1186 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1187 aSrcMark.SelectOneTable(0);
1188 ScClipParam aClipParam;
1189 aClipParam.meDirection = ScClipParam::Column;
1190 aClipParam.maRanges.push_back(ScRange(0, 0, srcSheet, 0, 3, srcSheet)); // A1:A4
1191 aClipParam.maRanges.push_back(ScRange(2, 0, srcSheet, 2, 3, srcSheet)); // C1:C4
1193 ScDocument aClipDoc(SCDOCMODE_CLIP);
1194 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1196 // transpose
1197 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1198 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::VALUE, true, false);
1200 ScRange aDestRange(1, 1, destSheet, 4, 2, destSheet); // Paste to B2:E3 on Sheet2.
1201 ScMarkData aMark(m_pDoc->GetSheetLimits());
1202 aMark.SetMarkArea(aDestRange);
1203 m_pDoc->CopyMultiRangeFromClip(
1204 ScAddress(1, 1, destSheet), aMark, InsertDeleteFlags::VALUE | InsertDeleteFlags::FORMULA,
1205 pTransClip.get(), true, false /* false fixes tdf#141683 */, false, false);
1206 pTransClip.reset();
1208 // Check pasted content to make sure they reference the correct cells.
1209 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1210 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1211 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1212 m_pDoc->GetFormula(1, 1, destSheet));
1213 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1215 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1216 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C2.", !pFC);
1218 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1219 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1220 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"),
1221 m_pDoc->GetFormula(3, 1, destSheet));
1222 CPPUNIT_ASSERT_EQUAL(4.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.$C$1"),
1227 m_pDoc->GetFormula(1, 2, destSheet));
1228 CPPUNIT_ASSERT_EQUAL(11.0, pFC->GetValue());
1230 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 2, destSheet));
1231 CPPUNIT_ASSERT_MESSAGE("This should be no formula cell C3.", !pFC);
1233 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 2, destSheet));
1234 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1235 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("=$Sheet1.$C$4"),
1236 m_pDoc->GetFormula(3, 2, destSheet));
1237 CPPUNIT_ASSERT_EQUAL(14.0, pFC->GetValue());
1239 m_pDoc->DeleteTab(destSheet);
1240 m_pDoc->DeleteTab(srcSheet);
1243 // InsertDeleteFlags::ALL
1244 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialAllAsLinkTranspose)
1246 const SCTAB srcSheet = 0;
1247 const SCTAB destSheet = 1;
1249 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1251 m_pDoc->InsertTab(srcSheet, "Sheet1");
1252 m_pDoc->InsertTab(destSheet, "Sheet2");
1254 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1255 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1256 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1258 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet); // Copy A1:A4 to clip.
1259 ScDocument aClipDoc(SCDOCMODE_CLIP);
1260 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1262 // transpose
1263 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1264 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
1266 ScRange aDestRange(1, 1, destSheet, 4, 1, destSheet); // Paste to B2:E2 on Sheet2.
1267 ScMarkData aMark(m_pDoc->GetSheetLimits());
1268 aMark.SetMarkArea(aDestRange);
1269 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
1270 false);
1271 pTransClip.reset();
1273 // Check pasted content to make sure they reference the correct cells.
1274 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1275 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1276 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1277 m_pDoc->GetFormula(1, 1, destSheet));
1278 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1280 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1281 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1282 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$2"),
1283 m_pDoc->GetFormula(2, 1, destSheet));
1284 CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue());
1286 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1287 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1288 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$3"),
1289 m_pDoc->GetFormula(3, 1, destSheet));
1290 CPPUNIT_ASSERT_EQUAL(0.0, pFC->GetValue());
1292 pFC = m_pDoc->GetFormulaCell(ScAddress(4, 1, destSheet));
1293 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1294 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("=$Sheet1.$A$4"),
1295 m_pDoc->GetFormula(4, 1, destSheet));
1296 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1298 m_pDoc->DeleteTab(destSheet);
1299 m_pDoc->DeleteTab(srcSheet);
1302 // InsertDeleteFlags::ALL
1303 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialAllAsLinkFilteredTranspose)
1305 const SCTAB srcSheet = 0;
1306 const SCTAB destSheet = 1;
1308 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc.
1310 m_pDoc->InsertTab(srcSheet, "Sheet1");
1311 m_pDoc->InsertTab(destSheet, "Sheet2");
1313 m_pDoc->SetValue(0, 0, srcSheet, 1); // A1
1314 m_pDoc->SetValue(0, 1, srcSheet, 2); // A2
1315 m_pDoc->SetValue(0, 3, srcSheet, 4); // A4
1317 // Filter row 1
1318 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, 0, 0, 0, 3);
1319 m_pDoc->SetAnonymousDBData(0, std::unique_ptr<ScDBData>(pDBData));
1321 pDBData->SetAutoFilter(true);
1322 ScRange aRange;
1323 pDBData->GetArea(aRange);
1324 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1325 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1327 //create the query param
1328 ScQueryParam aParam;
1329 pDBData->GetQueryParam(aParam);
1330 ScQueryEntry& rEntry = aParam.GetEntry(0);
1331 rEntry.bDoQuery = true;
1332 rEntry.nField = 0;
1333 rEntry.eOp = SC_NOT_EQUAL;
1334 rEntry.GetQueryItem().mfVal = 2; // value of row A2 -> filtering row 1
1335 // add queryParam to database range.
1336 pDBData->SetQueryParam(aParam);
1338 // perform the query.
1339 m_pDoc->Query(srcSheet, aParam, true);
1341 // Check precondition for test: row 1 is hidden/filtered
1342 SCROW nRow1, nRow2;
1343 SCROW nFilteredRow1, nFilteredRow2;
1344 bool bHidden = m_pDoc->RowHidden(SCROW(1), srcSheet, &nRow1, &nRow2);
1345 CPPUNIT_ASSERT_MESSAGE("row 1 should be hidden", bHidden);
1346 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow1);
1347 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be hidden", SCROW(1), nRow2);
1348 bool bFiltered = m_pDoc->RowFiltered(SCROW(1), srcSheet, &nFilteredRow1, &nFilteredRow2);
1349 CPPUNIT_ASSERT_MESSAGE("row 1 should be filtered", bFiltered);
1350 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow1);
1351 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 1 should be filtered", SCROW(1), nFilteredRow2);
1353 // Copy A1:A4 to clip.
1354 ScRange aSrcRange(0, 0, srcSheet, 0, 3, srcSheet);
1355 ScDocument aClipDoc(SCDOCMODE_CLIP);
1356 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1358 // transpose
1359 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1360 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, true, false);
1362 ScRange aDestRange(1, 1, destSheet, 3, 1, destSheet); // Paste to B2:D2 on Sheet2.
1363 ScMarkData aMark(m_pDoc->GetSheetLimits());
1364 aMark.SetMarkArea(aDestRange);
1365 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(), true,
1366 false, false);
1367 pTransClip.reset();
1369 // Check pasted content to make sure they reference the correct cells.
1370 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1, 1, destSheet));
1371 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell B2.", pFC);
1372 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B2", OUString("=$Sheet1.$A$1"),
1373 m_pDoc->GetFormula(1, 1, destSheet));
1374 CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue());
1376 pFC = m_pDoc->GetFormulaCell(ScAddress(2, 1, destSheet));
1377 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1378 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C2", OUString("=$Sheet1.$A$3"),
1379 m_pDoc->GetFormula(2, 1, destSheet));
1380 CPPUNIT_ASSERT_EQUAL(0.0, pFC->GetValue());
1382 pFC = m_pDoc->GetFormulaCell(ScAddress(3, 1, destSheet));
1383 CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
1384 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("=$Sheet1.$A$4"),
1385 m_pDoc->GetFormula(3, 1, destSheet));
1386 CPPUNIT_ASSERT_EQUAL(4.0, pFC->GetValue());
1388 m_pDoc->DeleteTab(destSheet);
1389 m_pDoc->DeleteTab(srcSheet);
1392 // Compatibility method since normal copy/paste tests do not test undo
1393 void TestCopyPaste::executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
1394 bool bTranspose, bool bMultiRangeSelection,
1395 bool bSkipEmpty, bool bCut,
1396 ScClipParam::Direction eDirection, CalcMode eCalcMode,
1397 InsertDeleteFlags aFlags)
1399 std::unique_ptr<ScUndoCut> pUndoCut;
1400 std::unique_ptr<ScUndoPaste> pUndoPaste;
1401 executeCopyPasteSpecial(0, 1, bApplyFilter, bIncludedFiltered, bAsLink, bTranspose,
1402 bMultiRangeSelection, bSkipEmpty, pUndoCut, pUndoPaste, bCut,
1403 eDirection, eCalcMode, aFlags);
1406 // This method is used to create the different copy/paste special test cases.
1407 // Principle: Creation of test cases is parameterized, whereas checking uses a minimum of logic
1408 void TestCopyPaste::executeCopyPasteSpecial(const SCTAB srcSheet, const SCTAB destSheet,
1409 bool bApplyFilter, bool bIncludedFiltered, bool bAsLink,
1410 bool bTranspose, bool bMultiRangeSelection,
1411 bool bSkipEmpty, std::unique_ptr<ScUndoCut>& pUndoCut,
1412 std::unique_ptr<ScUndoPaste>& pUndoPaste, bool bCut,
1413 ScClipParam::Direction eDirection, CalcMode eCalcMode,
1414 InsertDeleteFlags aFlags)
1416 // turn on/off auto calc
1417 sc::AutoCalcSwitch aACSwitch(*m_pDoc, eCalcMode == AutoCalc);
1419 for (int i = 0; i < srcSheet; ++i)
1420 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
1422 m_pDoc->InsertTab(srcSheet, "SrcSheet");
1424 // We need a drawing layer in order to create caption objects.
1425 m_pDoc->InitDrawLayer(m_xDocShell.get());
1426 ScFieldEditEngine& rEditEngine = m_pDoc->GetEditEngine();
1429 | B | C | D | E | F | G |
1431 3r | 1 B*| =B3+10 *| a | R1 *| =B3+B5+60 | =SUMIF(B3:B6;"<4") |
1432 4r | 2 B*| =B4+20 b | b *| R2 *| | *| <- filtered row
1433 5r | 3 B*| =E5+30 b*| c *| 5 *| B*| |
1434 6 | 4 | =B4+40 b*| d *| R4 *| =B3+B5+70 *| =C$3+$B$5+80 *|
1435 (7r | 6 | q | r bB*| s bB| t | u |) optional, for row range
1436 (8 | -1 | -2 | -3 | -4 | -5 | -6 |) optional, for row range
1437 (9r | -11 | -12 | -13 | -14 | -15 | -16 |) optional, for row range
1438 (10 | -21 | -22 | -23 | -24 | -25 | -26 |) optional, for row range
1440 \______________/ \________________________________________/
1441 col range 1 col range 2
1443 refs to cells (used for cut/paste tests)
1444 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) |
1445 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) |
1447 * means note attached
1448 B means background
1449 b means border
1450 r means row selected for row range in multi range selection
1452 The following test scenarios can be created:
1454 * Filtered row
1455 * Transpose
1456 * All cell types: numbers, strings, formulas, rich text, empty cell
1457 * Notes at different position
1458 * Formula references to rows before and after filtered row
1459 * Double reference (e.g. B3:B5)
1460 * Relative and absolute references
1461 * absolute references are not changed by transposing
1462 * Formatting patterns (e.g. cell backgrounds and borders)
1463 * Multi range selection with direction column and row
1466 SCCOL nSrcCols = 6;
1467 SCROW nSrcRows = 4;
1468 // Add additional row for MultiRange test cases
1469 if (bMultiRangeSelection)
1471 nSrcRows = eDirection == ScClipParam::Row ? nSrcRows + 2 : nSrcRows;
1472 nSrcCols = eDirection == ScClipParam::Column ? nSrcCols + 1 : nSrcCols;
1475 const SCCOL nStartCol = 1;
1476 const SCROW nStartRow = 2;
1478 // col B
1479 m_pDoc->SetValue(1, 2, srcSheet, 1);
1480 m_pDoc->SetValue(1, 3, srcSheet, 2);
1481 m_pDoc->SetValue(1, 4, srcSheet, 3);
1482 m_pDoc->SetValue(1, 5, srcSheet, 4);
1483 // col C
1484 m_pDoc->SetString(2, 2, srcSheet, "=B3+10");
1485 m_pDoc->SetString(2, 3, srcSheet, "=B4+20");
1486 m_pDoc->SetString(2, 4, srcSheet, "=E5+30");
1487 m_pDoc->SetString(2, 5, srcSheet, "=B4+40");
1488 // col D
1489 m_pDoc->SetString(3, 2, srcSheet, "a");
1490 m_pDoc->SetString(3, 3, srcSheet, "b");
1491 m_pDoc->SetString(3, 4, srcSheet, "c");
1492 m_pDoc->SetString(3, 5, srcSheet, "d");
1493 // col E
1494 rEditEngine.SetTextCurrentDefaults("R1");
1495 m_pDoc->SetEditText(ScAddress(4, 2, srcSheet), rEditEngine.CreateTextObject());
1496 rEditEngine.SetTextCurrentDefaults("R2");
1497 m_pDoc->SetEditText(ScAddress(4, 3, srcSheet), rEditEngine.CreateTextObject());
1498 m_pDoc->SetValue(4, 4, srcSheet, 5);
1499 rEditEngine.SetTextCurrentDefaults("R4");
1500 m_pDoc->SetEditText(ScAddress(4, 5, srcSheet), rEditEngine.CreateTextObject());
1501 // col F
1502 m_pDoc->SetValue(5, 2, srcSheet, 9);
1503 m_pDoc->SetString(5, 2, srcSheet, "=B3+B5+60");
1504 m_pDoc->SetEmptyCell(ScAddress(5, 3, srcSheet));
1505 m_pDoc->SetEmptyCell(ScAddress(5, 4, srcSheet));
1506 m_pDoc->SetString(5, 5, srcSheet, "=B3+B5+70");
1507 // col G
1508 m_pDoc->SetValue(6, 2, srcSheet, 9);
1509 m_pDoc->SetString(6, 2, srcSheet, "=SUMIF(B3:B6;\"<4\")");
1510 m_pDoc->SetEmptyCell(ScAddress(6, 3, srcSheet));
1511 m_pDoc->SetEmptyCell(ScAddress(6, 4, srcSheet));
1512 m_pDoc->SetString(6, 5, srcSheet, "=C$3+$B$5+80");
1514 const SfxPoolItem* pItem = nullptr;
1516 // row 6, additional row for MultiRange test case, otherwise not selected
1517 m_pDoc->SetValue(1, 6, srcSheet, 6);
1518 m_pDoc->SetString(2, 6, srcSheet, "q");
1519 m_pDoc->SetString(3, 6, srcSheet, "r");
1520 m_pDoc->SetString(4, 6, srcSheet, "s");
1521 m_pDoc->SetString(5, 6, srcSheet, "t");
1522 m_pDoc->SetString(6, 6, srcSheet, "u");
1524 // row 7, not selected
1525 m_pDoc->SetValue(1, 7, srcSheet, -1);
1526 m_pDoc->SetValue(2, 7, srcSheet, -2);
1527 m_pDoc->SetValue(3, 7, srcSheet, -3);
1528 m_pDoc->SetValue(4, 7, srcSheet, -4);
1529 m_pDoc->SetValue(5, 7, srcSheet, -5);
1530 m_pDoc->SetValue(6, 7, srcSheet, -6);
1532 // row 8, additional row for MultiRange test case, otherwise not selected
1533 m_pDoc->SetValue(1, 8, srcSheet, -11);
1534 m_pDoc->SetValue(2, 8, srcSheet, -12);
1535 m_pDoc->SetValue(3, 8, srcSheet, -13);
1536 m_pDoc->SetValue(4, 8, srcSheet, -14);
1537 m_pDoc->SetValue(5, 8, srcSheet, -15);
1538 m_pDoc->SetValue(6, 8, srcSheet, -16);
1540 // row 9, additional row for MultiRange test case, otherwise not selected
1541 m_pDoc->SetValue(1, 9, srcSheet, -21);
1542 m_pDoc->SetValue(2, 9, srcSheet, -22);
1543 m_pDoc->SetValue(3, 9, srcSheet, -23);
1544 m_pDoc->SetValue(4, 9, srcSheet, -24);
1545 m_pDoc->SetValue(5, 9, srcSheet, -25);
1546 m_pDoc->SetValue(6, 9, srcSheet, -26);
1548 // Col H, not selected
1549 m_pDoc->SetValue(7, 2, srcSheet, 111);
1550 m_pDoc->SetValue(7, 3, srcSheet, 112);
1551 m_pDoc->SetValue(7, 4, srcSheet, 113);
1552 m_pDoc->SetValue(7, 5, srcSheet, 114);
1553 m_pDoc->SetValue(7, 6, srcSheet, 115);
1554 m_pDoc->SetValue(7, 7, srcSheet, 116);
1556 // Col I, additional col for MultiRange test case, otherwise not selected
1557 m_pDoc->SetValue(8, 2, srcSheet, 121);
1558 m_pDoc->SetValue(8, 3, srcSheet, 122);
1559 m_pDoc->SetValue(8, 4, srcSheet, 123);
1560 m_pDoc->SetValue(8, 5, srcSheet, 124);
1561 m_pDoc->SetValue(8, 6, srcSheet, 125);
1562 m_pDoc->SetValue(8, 7, srcSheet, 126);
1564 // Col J, not selected
1565 m_pDoc->SetValue(9, 2, srcSheet, 131);
1566 m_pDoc->SetValue(9, 3, srcSheet, 132);
1567 m_pDoc->SetValue(9, 4, srcSheet, 133);
1568 m_pDoc->SetValue(9, 5, srcSheet, 134);
1569 m_pDoc->SetValue(9, 6, srcSheet, 135);
1570 m_pDoc->SetValue(9, 7, srcSheet, 136);
1572 // row 16, refs to copied/cut range
1573 m_pDoc->SetString(1, 16, srcSheet, "=C5");
1574 m_pDoc->SetString(2, 16, srcSheet, "=$C$5");
1575 m_pDoc->SetString(3, 16, srcSheet, "=$C5");
1576 m_pDoc->SetString(4, 16, srcSheet, "=C$5");
1577 m_pDoc->SetString(5, 16, srcSheet, "=SUM(C5:C5)");
1578 m_pDoc->SetString(6, 16, srcSheet, "=SUM($C$5:$C$5)");
1579 m_pDoc->SetString(7, 16, srcSheet, "=SUM($C5:$C5)");
1580 m_pDoc->SetString(8, 16, srcSheet, "=SUM(C$5:C$5)");
1581 m_pDoc->SetString(9, 16, srcSheet, "=SUM($B$3:$B$6)");
1582 m_pDoc->SetString(10, 16, srcSheet, "=SUM($B$3:$B$10)");
1584 // Cell position is used for ranges relative to current position
1585 ScAddress cellC6(2, 5, srcSheet);
1586 ScAddress cellA1(0, 0, srcSheet);
1587 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C5", cellC6, "$SrcSheet.C5"));
1588 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5", cellA1, "$SrcSheet.$C$5"));
1589 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5", cellC6, "$SrcSheet.$C5"));
1590 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_Ca5", cellC6, "$SrcSheet.C$5"));
1591 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C5_C5", cellC6, "$SrcSheet.C5:C5"));
1592 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa5", cellA1, "$SrcSheet.$C$5:$C$5"));
1593 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5_aC5", cellC6, "$SrcSheet.$C5:$C5"));
1594 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aC5_aC5", cellC6, "$SrcSheet.$C5:$C5"));
1595 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_Ca5_Ca5", cellC6, "$SrcSheet.C$5:C$5"));
1596 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa8", cellA1, "$SrcSheet.$B$3:$B$6"));
1597 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_aCa5_aCa10", cellA1, "$SrcSheet.$B$3:$B$10"));
1599 // row 17, refs to copied/cut range using range
1600 m_pDoc->SetString(1, 17, srcSheet, "=Range_C5");
1601 m_pDoc->SetString(2, 17, srcSheet, "=Range_aCa5");
1602 m_pDoc->SetString(3, 17, srcSheet, "=Range_aC5");
1603 m_pDoc->SetString(4, 17, srcSheet, "=Range_Ca5");
1604 m_pDoc->SetString(5, 17, srcSheet, "=SUM(Range_C5_C5)");
1605 m_pDoc->SetString(6, 17, srcSheet, "=SUM(Range_aCa5_aCa5)");
1606 m_pDoc->SetString(7, 17, srcSheet, "=SUM(Range_aC5_aC5)");
1607 m_pDoc->SetString(8, 17, srcSheet, "=SUM(Range_Ca5_Ca5)");
1608 m_pDoc->SetString(9, 17, srcSheet, "=SUM(Range_aCa5_aCa8)");
1609 m_pDoc->SetString(10, 17, srcSheet, "=SUM(Range_aCa5_aCa10)");
1611 // add patterns
1612 ScPatternAttr aCellBlueColor(m_pDoc->GetPool());
1613 aCellBlueColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
1614 m_pDoc->ApplyPatternAreaTab(1, 2, 1, 4, srcSheet, aCellBlueColor);
1616 // Check pattern precondition
1617 m_pDoc->GetPattern(ScAddress(1, 2, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1618 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B3 has a pattern", pItem);
1619 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
1620 m_pDoc->GetPattern(ScAddress(1, 3, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1621 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B4 has a pattern", pItem);
1622 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
1623 m_pDoc->GetPattern(ScAddress(1, 5, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
1624 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B6 has no pattern", !pItem);
1626 // row 2 on empty cell
1627 ScPatternAttr aCellGreenColor(m_pDoc->GetPool());
1628 aCellGreenColor.GetItemSet().Put(SvxBrushItem(COL_GREEN, ATTR_BACKGROUND));
1629 m_pDoc->ApplyPatternAreaTab(5, 4, 5, 4, srcSheet, aCellGreenColor);
1631 // row 4 for multi range row selection
1632 ScPatternAttr aCellRedColor(m_pDoc->GetPool());
1633 aCellRedColor.GetItemSet().Put(SvxBrushItem(COL_RED, ATTR_BACKGROUND));
1634 m_pDoc->ApplyPatternAreaTab(3, 6, 4, 6, srcSheet, aCellRedColor);
1636 // add borders
1637 ::editeng::SvxBorderLine aLine(nullptr, 50, SvxBorderLineStyle::SOLID);
1638 SvxBoxItem aBorderItem(ATTR_BORDER);
1639 aBorderItem.SetLine(&aLine, SvxBoxItemLine::LEFT);
1640 aBorderItem.SetLine(&aLine, SvxBoxItemLine::RIGHT);
1641 m_pDoc->ApplyAttr(2, 3, srcSheet, aBorderItem);
1642 m_pDoc->ApplyAttr(2, 4, srcSheet, aBorderItem);
1643 m_pDoc->ApplyAttr(2, 5, srcSheet, aBorderItem);
1644 // Check border precondition
1645 pItem = m_pDoc->GetAttr(ScAddress(2, 2, srcSheet), ATTR_BORDER);
1646 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B1 has a border", pItem);
1647 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1648 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
1649 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1650 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1651 pItem = m_pDoc->GetAttr(ScAddress(2, 3, srcSheet), ATTR_BORDER);
1652 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B2 has a border", pItem);
1653 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1654 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
1655 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1656 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1657 // Check border precondition 2
1658 m_pDoc->GetPattern(ScAddress(2, 3, srcSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
1659 CPPUNIT_ASSERT_MESSAGE("SrcSheet.B2 has a border", pItem);
1660 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
1661 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
1662 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
1663 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
1664 // row 4 for multi range row selection
1665 ::editeng::SvxBorderLine aDoubleLine(nullptr, 50, SvxBorderLineStyle::DOUBLE);
1666 SvxBoxItem aDoubleBorderItem(ATTR_BORDER);
1667 aDoubleBorderItem.SetLine(&aDoubleLine, SvxBoxItemLine::TOP);
1668 aDoubleBorderItem.SetLine(&aDoubleLine, SvxBoxItemLine::BOTTOM);
1669 m_pDoc->ApplyAttr(3, 6, srcSheet, aDoubleBorderItem);
1670 m_pDoc->ApplyAttr(4, 6, srcSheet, aDoubleBorderItem);
1672 // add notes to B3:F4
1674 // add notes row 2
1675 setNote(1, 2, srcSheet, "Note A1");
1676 setNote(2, 2, srcSheet, "Note B1");
1677 // No note on D3
1678 setNote(4, 2, srcSheet, "Note D1");
1679 // No note on F3
1680 // No note on G3
1682 // add notes row 3
1683 setNote(1, 3, srcSheet, "Note A2");
1684 // No note on C4
1685 setNote(3, 3, srcSheet, "Note C2");
1686 setNote(4, 3, srcSheet, "Note D2");
1687 setNote(5, 4, srcSheet, "Note E2");
1688 setNote(6, 3, srcSheet, "Note F2");
1690 // add notes row 4
1691 setNote(1, 4, srcSheet, "Note A3");
1692 setNote(2, 4, srcSheet, "Note B3");
1693 setNote(3, 4, srcSheet, "Note C3");
1694 setNote(4, 4, srcSheet, "Note D3");
1695 // No note on F5
1696 // No note on G5
1698 // add notes row 5
1699 // No note on B6
1700 setNote(2, 5, srcSheet, "Note B4");
1701 setNote(3, 5, srcSheet, "Note C4");
1702 setNote(4, 5, srcSheet, "Note D4");
1703 setNote(5, 5, srcSheet, "Note E4");
1704 setNote(6, 5, srcSheet, "Note F4");
1706 // row 6 for multi range row selection
1707 setNote(3, 6, srcSheet, "Note C5");
1709 // Recalc if needed
1710 if (bMultiRangeSelection && bTranspose && eDirection == ScClipParam::Row
1711 && eCalcMode == RecalcAtEnd)
1712 m_pDoc->CalcFormulaTree();
1713 else if (bMultiRangeSelection && bTranspose && eDirection == ScClipParam::Row
1714 && eCalcMode == HardRecalcAtEnd)
1715 m_pDoc->CalcAll();
1717 // Filter out row 3
1718 if (bApplyFilter)
1720 ScDBData* pDBData = new ScDBData("TRANSPOSE_TEST_DATA", srcSheet, nStartCol, nStartRow,
1721 nStartCol + nSrcCols - 1, nStartRow + nSrcRows - 1);
1722 m_pDoc->SetAnonymousDBData(srcSheet, std::unique_ptr<ScDBData>(pDBData));
1724 pDBData->SetAutoFilter(true);
1725 ScRange aRange;
1726 pDBData->GetArea(aRange);
1727 m_pDoc->ApplyFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(),
1728 aRange.aStart.Row(), aRange.aStart.Tab(), ScMF::Auto);
1730 //create the query param
1731 ScQueryParam aParam;
1732 pDBData->GetQueryParam(aParam);
1733 ScQueryEntry& rEntry = aParam.GetEntry(0);
1734 rEntry.bDoQuery = true;
1735 rEntry.nField = nStartCol;
1736 rEntry.eOp = SC_NOT_EQUAL;
1737 rEntry.GetQueryItem().mfVal = 2; // value of row B4 -> filtering row 3
1738 // add queryParam to database range.
1739 pDBData->SetQueryParam(aParam);
1741 // perform the query.
1742 m_pDoc->Query(srcSheet, aParam, true);
1744 // Check precondition for test: row 3 is hidden/filtered
1745 SCROW nRow1, nRow2;
1746 SCROW nFilteredRow1, nFilteredRow2;
1747 bool bHidden = m_pDoc->RowHidden(SCROW(3), srcSheet, &nRow1, &nRow2);
1748 CPPUNIT_ASSERT_MESSAGE("row 3 should be hidden", bHidden);
1749 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be hidden", SCROW(3), nRow1);
1750 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be hidden", SCROW(3), nRow2);
1751 bool bFiltered = m_pDoc->RowFiltered(SCROW(3), srcSheet, &nFilteredRow1, &nFilteredRow2);
1752 CPPUNIT_ASSERT_MESSAGE("row 3 should be filtered", bFiltered);
1753 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be filtered", SCROW(3), nFilteredRow1);
1754 CPPUNIT_ASSERT_EQUAL_MESSAGE("row 3 should be filtered", SCROW(3), nFilteredRow2);
1757 // create destination sheet
1758 // const SCTAB destSheet = 1;
1759 for (int i = srcSheet + 1; i < destSheet; ++i)
1760 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
1762 if (srcSheet != destSheet)
1763 m_pDoc->InsertTab(destSheet, "DestSheet");
1765 m_pDoc->SetString(3, 101, srcSheet, "=DestSheet.D1");
1766 m_pDoc->SetString(3, 102, srcSheet, "=DestSheet.D2");
1767 m_pDoc->SetString(3, 103, srcSheet, "=DestSheet.D3");
1768 m_pDoc->SetString(3, 104, srcSheet, "=DestSheet.D4");
1769 m_pDoc->SetString(3, 105, srcSheet, "=DestSheet.D5");
1770 m_pDoc->SetString(3, 106, srcSheet, "=DestSheet.D6");
1771 m_pDoc->SetString(3, 107, srcSheet, "=DestSheet.D7");
1772 m_pDoc->SetString(4, 101, srcSheet, "=DestSheet.E1");
1773 m_pDoc->SetString(4, 102, srcSheet, "=DestSheet.E2");
1774 m_pDoc->SetString(4, 103, srcSheet, "=DestSheet.E3");
1775 m_pDoc->SetString(4, 104, srcSheet, "=DestSheet.E4");
1776 m_pDoc->SetString(4, 105, srcSheet, "=DestSheet.E5");
1777 m_pDoc->SetString(4, 106, srcSheet, "=DestSheet.E6");
1778 m_pDoc->SetString(4, 107, srcSheet, "=DestSheet.E7");
1779 m_pDoc->SetString(5, 101, srcSheet, "=DestSheet.F1");
1780 m_pDoc->SetString(5, 102, srcSheet, "=DestSheet.F2");
1781 m_pDoc->SetString(5, 103, srcSheet, "=DestSheet.F3");
1782 m_pDoc->SetString(5, 104, srcSheet, "=DestSheet.F4");
1783 m_pDoc->SetString(5, 105, srcSheet, "=DestSheet.F5");
1784 m_pDoc->SetString(5, 106, srcSheet, "=DestSheet.F6");
1785 m_pDoc->SetString(5, 107, srcSheet, "=DestSheet.F7");
1786 m_pDoc->SetString(6, 101, srcSheet, "=DestSheet.G1");
1787 m_pDoc->SetString(6, 102, srcSheet, "=DestSheet.G2");
1788 m_pDoc->SetString(6, 103, srcSheet, "=DestSheet.G3");
1789 m_pDoc->SetString(6, 104, srcSheet, "=DestSheet.G4");
1790 m_pDoc->SetString(6, 105, srcSheet, "=DestSheet.G5");
1791 m_pDoc->SetString(6, 106, srcSheet, "=DestSheet.G6");
1792 m_pDoc->SetString(6, 107, srcSheet, "=DestSheet.G7");
1793 m_pDoc->SetString(7, 101, srcSheet, "=DestSheet.H1");
1794 m_pDoc->SetString(7, 102, srcSheet, "=DestSheet.H2");
1795 m_pDoc->SetString(7, 103, srcSheet, "=DestSheet.H3");
1796 m_pDoc->SetString(7, 104, srcSheet, "=DestSheet.H4");
1797 m_pDoc->SetString(7, 105, srcSheet, "=DestSheet.H5");
1798 m_pDoc->SetString(7, 106, srcSheet, "=DestSheet.H6");
1799 m_pDoc->SetString(7, 107, srcSheet, "=DestSheet.H7");
1800 m_pDoc->SetString(8, 101, srcSheet, "=DestSheet.I1");
1801 m_pDoc->SetString(8, 102, srcSheet, "=DestSheet.I2");
1802 m_pDoc->SetString(8, 103, srcSheet, "=DestSheet.I3");
1803 m_pDoc->SetString(8, 104, srcSheet, "=DestSheet.I4");
1804 m_pDoc->SetString(8, 105, srcSheet, "=DestSheet.I5");
1805 m_pDoc->SetString(8, 106, srcSheet, "=DestSheet.I6");
1806 m_pDoc->SetString(8, 107, srcSheet, "=DestSheet.I7");
1807 m_pDoc->SetString(9, 101, srcSheet, "=DestSheet.J1");
1808 m_pDoc->SetString(9, 102, srcSheet, "=DestSheet.J2");
1809 m_pDoc->SetString(9, 103, srcSheet, "=DestSheet.J3");
1810 m_pDoc->SetString(9, 104, srcSheet, "=DestSheet.J4");
1811 m_pDoc->SetString(9, 105, srcSheet, "=DestSheet.J5");
1812 m_pDoc->SetString(9, 106, srcSheet, "=DestSheet.J6");
1813 m_pDoc->SetString(9, 107, srcSheet, "=DestSheet.J7");
1815 // Check precondition
1816 checkCopyPasteSpecialInitial(srcSheet);
1818 // set cells to 1000 to check empty cell behaviour and to detect destination range problems
1819 for (int i = 0; i < 10; ++i)
1820 for (int j = 0; j < 10; ++j)
1821 m_pDoc->SetValue(i, j, destSheet, 1000);
1823 // transpose clipboard, paste on DestSheet
1824 ScDocument aClipDoc(SCDOCMODE_CLIP);
1825 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
1826 ScRange aDestRange;
1828 ScDocumentUniquePtr pPasteUndoDoc;
1829 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
1830 std::unique_ptr<ScRefUndoData> pUndoData;
1832 if (!bMultiRangeSelection)
1834 ScRange aSrcRange(nStartCol, nStartRow, srcSheet, nStartCol + nSrcCols - 1,
1835 nStartRow + nSrcRows - 1, srcSheet);
1836 printRange(m_pDoc, aSrcRange, "Src range");
1837 if (!bCut)
1838 copyToClip(m_pDoc, aSrcRange, &aClipDoc);
1839 else
1841 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, true));
1844 printRange(&aClipDoc,
1845 ScRange(nStartCol, nStartRow, srcSheet, nStartCol + nSrcCols,
1846 nStartRow + nSrcRows, srcSheet),
1847 "Base doc (&aClipDoc)");
1849 // ScDocument::TransposeClip() and ScDocument::CopyFromClip() calls
1850 // analog to ScViewFunc::PasteFromClip()
1851 if (bTranspose)
1853 ScDocument* pOrigClipDoc = &aClipDoc;
1854 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1855 aClipDoc.TransposeClip(pTransClip.get(), aFlags, bAsLink, bIncludedFiltered);
1856 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcRows - 1, 1 + nSrcCols - 1,
1857 destSheet); //target: D2:F6
1858 aDestMark.SetMarkArea(aDestRange);
1859 printRange(pTransClip.get(), ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
1860 "Transposed clipdoc (pTransClip.get())");
1862 if (bCut)
1863 prepareUndoBeforePaste(bCut, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
1864 pUndoData);
1866 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
1867 pTransClip.get(), true, bAsLink, bIncludedFiltered, bSkipEmpty);
1868 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
1869 if (bCut)
1871 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark,
1872 pPasteRefUndoDoc.get());
1873 printRange(m_pDoc, aDestRange, "Transposed dest sheet after UpdateTranspose()");
1875 pTransClip.reset();
1877 else
1879 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcCols - 1, 1 + nSrcRows - 1,
1880 destSheet); //target: D2:I5
1881 aDestMark.SetMarkArea(aDestRange);
1882 if (bCut)
1883 prepareUndoBeforePaste(bCut, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
1884 pUndoData);
1886 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc,
1887 true, bAsLink, bIncludedFiltered, bSkipEmpty);
1888 printValuesAndFormulasInRange(m_pDoc, aDestRange, "Dest sheet"_ostr);
1891 if (bCut)
1892 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
1893 pUndoPaste, bTranspose, bAsLink, bSkipEmpty);
1895 else // multi range selection
1897 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
1898 aSrcMark.SelectOneTable(0);
1899 ScClipParam aClipParam;
1900 aClipParam.meDirection = eDirection;
1901 if (eDirection == ScClipParam::Column)
1903 aClipParam.maRanges.push_back(ScRange(1, 2, srcSheet, 2, 5, srcSheet)); // B3:C6
1904 aClipParam.maRanges.push_back(ScRange(4, 2, srcSheet, 6, 5, srcSheet)); // E3:G6
1905 aClipParam.maRanges.push_back(ScRange(8, 2, srcSheet, 8, 5, srcSheet)); // I3:I6
1907 else if (eDirection == ScClipParam::Row)
1909 aClipParam.maRanges.push_back(ScRange(1, 2, srcSheet, 6, 4, srcSheet)); // B3:G5
1910 aClipParam.maRanges.push_back(ScRange(1, 6, srcSheet, 6, 6, srcSheet)); // B7:G7
1911 aClipParam.maRanges.push_back(ScRange(1, 8, srcSheet, 6, 8, srcSheet)); // A9:G9
1913 CPPUNIT_ASSERT(aClipParam.isMultiRange());
1914 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aSrcMark, false, false);
1916 // ScDocument::TransposeClip() and ScDocument::CopyMultiRangeFromClip() calls
1917 // analog to ScViewFunc::PasteFromClipToMultiRanges()
1918 if (bTranspose)
1920 printRange(m_pDoc, aClipParam.getWholeRange(), "Src range");
1921 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
1922 aClipDoc.TransposeClip(pTransClip.get(), aFlags, bAsLink, bIncludedFiltered);
1923 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcRows - 1, 1 + nSrcCols - 1 - 1,
1924 destSheet); //target col: D2:G6, target row: D2:H6
1925 aDestMark.SetMarkArea(aDestRange);
1926 printRange(&aClipDoc, ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
1927 "Base doc (&aClipDoc)");
1928 printRange(pTransClip.get(), ScRange(0, 0, srcSheet, nSrcCols, nSrcRows, srcSheet),
1929 "Transposed clipdoc (pTransClip.get())");
1930 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 1, destSheet), aDestMark, aFlags,
1931 pTransClip.get(), true, bAsLink && !bTranspose,
1932 bIncludedFiltered, bSkipEmpty);
1933 pTransClip.reset();
1934 printRange(m_pDoc, aDestRange, "Transposed dest sheet");
1936 else
1938 aDestRange = ScRange(3, 1, destSheet, 3 + nSrcCols - 1 - 1, 1 + nSrcRows - 1,
1939 destSheet); //target col: D2:I5, target row: D2:I6
1940 aDestMark.SetMarkArea(aDestRange);
1941 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 1, destSheet), aDestMark, aFlags, &aClipDoc,
1942 true, bAsLink && !bTranspose, bIncludedFiltered,
1943 bSkipEmpty);
1947 if (eCalcMode == RecalcAtEnd)
1948 m_pDoc->CalcFormulaTree();
1949 else if (eCalcMode == HardRecalcAtEnd)
1950 m_pDoc->CalcAll();
1953 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecial)
1955 executeCopyPasteSpecial(false, false, false, false, false, false);
1956 checkCopyPasteSpecial(false);
1959 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialFiltered)
1961 executeCopyPasteSpecial(true, false, false, false, false, false);
1962 checkCopyPasteSpecialFiltered(false);
1965 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialIncludeFiltered)
1967 // For bIncludeFiltered=true, the non-filtered outcome is expected
1968 executeCopyPasteSpecial(false, true, false, false, false, false);
1969 checkCopyPasteSpecial(false);
1972 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialFilteredIncludeFiltered)
1974 // For bIncludeFiltered=true, the non-filtered outcome is expected
1975 executeCopyPasteSpecial(true, true, false, false, false, false);
1976 checkCopyPasteSpecial(false);
1979 // similar to TestCopyPaste::testCopyPasteTranspose(), but this test is more complex
1980 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialTranspose)
1982 executeCopyPasteSpecial(false, false, false, true, false, false);
1983 checkCopyPasteSpecialTranspose(false);
1986 // tdf#107348
1987 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialFilteredTranspose)
1989 executeCopyPasteSpecial(true, false, false, true, false, false);
1990 checkCopyPasteSpecialFilteredTranspose(false);
1993 // tdf#107348
1994 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialTransposeIncludeFiltered)
1996 // For bIncludeFiltered=true, the non-filtered outcome is expected
1997 executeCopyPasteSpecial(true, true, false, true, false, false);
1998 checkCopyPasteSpecialTranspose(false);
2001 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeCol)
2003 executeCopyPasteSpecial(false, false, false, false, true, false, false, ScClipParam::Column);
2004 checkCopyPasteSpecialMultiRangeCol(false);
2007 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColIncludeFiltered)
2009 // For bIncludeFiltered=true, the non-filtered outcome is expected
2010 executeCopyPasteSpecial(false, true, false, false, true, false, false, ScClipParam::Column);
2011 checkCopyPasteSpecialMultiRangeCol(false);
2014 // tdf#45958
2015 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColFiltered)
2017 executeCopyPasteSpecial(true, false, false, false, true, false, false, ScClipParam::Column);
2018 checkCopyPasteSpecialMultiRangeColFiltered(false);
2021 // tdf#45958
2022 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColFilteredIncludeFiltered)
2024 // For bIncludeFiltered=true, the non-filtered outcome is expected
2025 executeCopyPasteSpecial(true, true, false, false, true, false, false, ScClipParam::Column);
2026 checkCopyPasteSpecialMultiRangeCol(false);
2029 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColTranspose)
2031 executeCopyPasteSpecial(false, false, false, true, true, false, false, ScClipParam::Column);
2032 checkCopyPasteSpecialMultiRangeColTranspose(false);
2035 // tdf#45958, tdf#107348
2036 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeColFilteredTranspose)
2038 executeCopyPasteSpecial(true, false, false, true, true, false, false, ScClipParam::Column);
2039 checkCopyPasteSpecialMultiRangeColFilteredTranspose(false);
2042 // tdf#45958, tdf#107348
2043 CPPUNIT_TEST_FIXTURE(TestCopyPaste,
2044 testCopyPasteSpecialMultiRangeColFilteredIncludeFilteredTranspose)
2046 // For bIncludeFiltered=true, the non-filtered outcome is expected
2047 executeCopyPasteSpecial(true, true, false, true, true, false, false, ScClipParam::Column);
2048 checkCopyPasteSpecialMultiRangeColTranspose(false);
2051 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRow)
2053 executeCopyPasteSpecial(false, false, false, false, true, false, false, ScClipParam::Row);
2054 checkCopyPasteSpecialMultiRangeRow(false);
2057 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowIncludeFiltered)
2059 // For bIncludeFiltered=true, the non-filtered outcome is expected
2060 executeCopyPasteSpecial(false, true, false, false, true, false, false, ScClipParam::Row);
2061 checkCopyPasteSpecialMultiRangeRow(false);
2064 // tdf#45958
2065 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowFiltered)
2067 executeCopyPasteSpecial(true, false, false, false, true, false, false, ScClipParam::Row);
2068 checkCopyPasteSpecialMultiRangeRowFiltered(false);
2071 // tdf#45958
2072 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowFilteredIncludeFiltered)
2074 // For bIncludeFiltered=true, the non-filtered outcome is expected
2075 executeCopyPasteSpecial(true, true, false, false, true, false, false, ScClipParam::Row);
2076 checkCopyPasteSpecialMultiRangeRow(false);
2079 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowTranspose)
2081 executeCopyPasteSpecial(false, false, false, true, true, false, false, ScClipParam::Row,
2082 HardRecalcAtEnd);
2083 checkCopyPasteSpecialMultiRangeRowTranspose(false);
2086 // tdf#45958, tdf#107348
2087 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialMultiRangeRowFilteredTranspose)
2089 executeCopyPasteSpecial(true, false, false, true, true, false, false, ScClipParam::Row,
2090 HardRecalcAtEnd);
2091 checkCopyPasteSpecialMultiRangeRowFilteredTranspose(false);
2094 // tdf#45958, tdf#107348
2095 CPPUNIT_TEST_FIXTURE(TestCopyPaste,
2096 testCopyPasteSpecialMultiRangeRowFilteredIncludeFilteredTranspose)
2098 // For bIncludeFiltered=true, the non-filtered outcome is expected
2099 executeCopyPasteSpecial(true, true, false, true, true, false, false, ScClipParam::Row,
2100 HardRecalcAtEnd);
2101 checkCopyPasteSpecialMultiRangeRowTranspose(false);
2104 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmpty)
2106 executeCopyPasteSpecial(false, false, false, false, false, true);
2107 checkCopyPasteSpecial(true);
2110 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyFiltered)
2112 executeCopyPasteSpecial(true, false, false, false, false, true);
2113 checkCopyPasteSpecialFiltered(true);
2116 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyIncludeFiltered)
2118 // For bIncludeFiltered=true, the non-filtered outcome is expected
2119 executeCopyPasteSpecial(false, true, false, false, false, true);
2120 checkCopyPasteSpecial(true);
2123 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyFilteredIncludeFiltered)
2125 // For bIncludeFiltered=true, the non-filtered outcome is expected
2126 executeCopyPasteSpecial(true, true, false, false, false, true);
2127 checkCopyPasteSpecial(true);
2130 // similar to TestCopyPaste::testCopyPasteTranspose(), but this test is more complex
2131 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyTranspose)
2133 executeCopyPasteSpecial(false, false, false, true, false, true);
2134 checkCopyPasteSpecialTranspose(true);
2137 // tdf#107348
2138 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyFilteredTranspose)
2140 executeCopyPasteSpecial(true, false, false, true, false, true);
2141 checkCopyPasteSpecialFilteredTranspose(true);
2144 // tdf#107348
2145 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyTransposeIncludeFiltered)
2147 // For bIncludeFiltered=true, the non-filtered outcome is expected
2148 executeCopyPasteSpecial(true, true, false, true, false, true);
2149 checkCopyPasteSpecialTranspose(true);
2152 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeCol)
2154 executeCopyPasteSpecial(false, false, false, false, true, true, false, ScClipParam::Column);
2155 checkCopyPasteSpecialMultiRangeCol(true);
2158 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeColIncludeFiltered)
2160 // For bIncludeFiltered=true, the non-filtered outcome is expected
2161 executeCopyPasteSpecial(false, true, false, false, true, true, false, ScClipParam::Column);
2162 checkCopyPasteSpecialMultiRangeCol(true);
2165 // tdf#45958
2166 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeColFiltered)
2168 executeCopyPasteSpecial(true, false, false, false, true, true, false, ScClipParam::Column);
2169 checkCopyPasteSpecialMultiRangeColFiltered(true);
2172 // tdf#45958
2173 CPPUNIT_TEST_FIXTURE(TestCopyPaste,
2174 testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFiltered)
2176 // For bIncludeFiltered=true, the non-filtered outcome is expected
2177 executeCopyPasteSpecial(true, true, false, false, true, true, false, ScClipParam::Column);
2178 checkCopyPasteSpecialMultiRangeCol(true);
2181 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeColTranspose)
2183 executeCopyPasteSpecial(false, false, false, true, true, true, false, ScClipParam::Column);
2184 checkCopyPasteSpecialMultiRangeColTranspose(true);
2187 // tdf#45958, tdf#107348
2188 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeColFilteredTranspose)
2190 // For bIncludeFiltered=true, the non-filtered outcome is expected
2191 executeCopyPasteSpecial(true, false, false, true, true, true, false, ScClipParam::Column);
2192 checkCopyPasteSpecialMultiRangeColFilteredTranspose(true);
2195 // tdf#45958, tdf#107348
2196 CPPUNIT_TEST_FIXTURE(TestCopyPaste,
2197 testCopyPasteSpecialSkipEmptyMultiRangeColFilteredIncludeFilteredTranspose)
2199 // For bIncludeFiltered=true, the non-filtered outcome is expected
2200 executeCopyPasteSpecial(true, true, false, true, true, true, false, ScClipParam::Column);
2201 checkCopyPasteSpecialMultiRangeColTranspose(true);
2204 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeRow)
2206 executeCopyPasteSpecial(false, false, false, false, true, true, false, ScClipParam::Row);
2207 checkCopyPasteSpecialMultiRangeRow(true);
2210 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeRowIncludeFiltered)
2212 // For bIncludeFiltered=true, the non-filtered outcome is expected
2213 executeCopyPasteSpecial(false, true, false, false, true, true, false, ScClipParam::Row);
2214 checkCopyPasteSpecialMultiRangeRow(true);
2217 // tdf#45958
2218 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeRowFiltered)
2220 executeCopyPasteSpecial(true, false, false, false, true, true, false, ScClipParam::Row);
2221 checkCopyPasteSpecialMultiRangeRowFiltered(true);
2224 // tdf#45958
2225 CPPUNIT_TEST_FIXTURE(TestCopyPaste,
2226 testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFiltered)
2228 // For bIncludeFiltered=true, the non-filtered outcome is expected
2229 executeCopyPasteSpecial(true, true, false, false, true, true, false, ScClipParam::Row);
2230 checkCopyPasteSpecialMultiRangeRow(true);
2233 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeRowTranspose)
2235 executeCopyPasteSpecial(false, false, false, true, true, true, false, ScClipParam::Row,
2236 HardRecalcAtEnd);
2237 checkCopyPasteSpecialMultiRangeRowTranspose(true);
2240 // tdf#45958, tdf#107348
2241 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredTranspose)
2243 executeCopyPasteSpecial(true, false, false, true, true, true, false, ScClipParam::Row,
2244 HardRecalcAtEnd);
2245 checkCopyPasteSpecialMultiRangeRowFilteredTranspose(true);
2248 // tdf#45958, tdf#107348
2249 CPPUNIT_TEST_FIXTURE(TestCopyPaste,
2250 testCopyPasteSpecialSkipEmptyMultiRangeRowFilteredIncludeFilteredTranspose)
2252 // For bIncludeFiltered=true, the non-filtered outcome is expected
2253 executeCopyPasteSpecial(true, true, false, true, true, true, false, ScClipParam::Row,
2254 HardRecalcAtEnd);
2255 checkCopyPasteSpecialMultiRangeRowTranspose(true);
2258 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutPasteSpecial)
2260 const SCTAB srcSheet = 0;
2261 const SCTAB destSheet = 1;
2262 std::unique_ptr<ScUndoCut> pUndoCut;
2263 std::unique_ptr<ScUndoPaste> pUndoPaste;
2265 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, false, false, false, pUndoCut,
2266 pUndoPaste, true);
2267 checkCopyPasteSpecial(false, true);
2269 pUndoPaste->Undo();
2270 pUndoCut->Undo();
2271 checkCopyPasteSpecialInitial(srcSheet);
2273 pUndoCut->Redo();
2274 pUndoPaste->Redo();
2275 checkCopyPasteSpecial(false, true);
2277 pUndoPaste->Undo();
2278 pUndoCut->Undo();
2279 checkCopyPasteSpecialInitial(srcSheet);
2281 pUndoPaste.reset();
2282 pUndoCut.reset();
2284 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2285 m_pDoc->DeleteTab(i - 1);
2288 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutPasteSpecialTranspose)
2290 const SCTAB srcSheet = 0;
2291 const SCTAB destSheet = 1;
2292 std::unique_ptr<ScUndoCut> pUndoCut;
2293 std::unique_ptr<ScUndoPaste> pUndoPaste;
2295 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, true, false, false, pUndoCut,
2296 pUndoPaste, true);
2297 checkCopyPasteSpecialTranspose(false, true);
2299 pUndoPaste->Undo();
2300 pUndoCut->Undo();
2301 checkCopyPasteSpecialInitial(srcSheet);
2303 pUndoCut->Redo();
2304 pUndoPaste->Redo();
2305 checkCopyPasteSpecialTranspose(false, true);
2307 pUndoPaste->Undo();
2308 pUndoCut->Undo();
2309 checkCopyPasteSpecialInitial(srcSheet);
2311 pUndoPaste.reset();
2312 pUndoCut.reset();
2314 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2315 m_pDoc->DeleteTab(i - 1);
2318 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutPasteSpecialSkipEmpty)
2320 const SCTAB srcSheet = 0;
2321 const SCTAB destSheet = 1;
2322 std::unique_ptr<ScUndoCut> pUndoCut;
2323 std::unique_ptr<ScUndoPaste> pUndoPaste;
2325 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, false, false, true, pUndoCut,
2326 pUndoPaste, true);
2327 checkCopyPasteSpecial(true, true);
2329 pUndoPaste->Undo();
2330 pUndoCut->Undo();
2331 checkCopyPasteSpecialInitial(srcSheet);
2333 pUndoCut->Redo();
2334 pUndoPaste->Redo();
2335 checkCopyPasteSpecial(true, true);
2337 pUndoPaste->Undo();
2338 pUndoCut->Undo();
2339 checkCopyPasteSpecialInitial(srcSheet);
2341 pUndoPaste.reset();
2342 pUndoCut.reset();
2344 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2345 m_pDoc->DeleteTab(i - 1);
2348 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutPasteSpecialSkipEmptyTranspose)
2350 const SCTAB srcSheet = 0;
2351 const SCTAB destSheet = 1;
2352 std::unique_ptr<ScUndoCut> pUndoCut;
2353 std::unique_ptr<ScUndoPaste> pUndoPaste;
2355 executeCopyPasteSpecial(srcSheet, destSheet, false, true, false, true, false, true, pUndoCut,
2356 pUndoPaste, true);
2357 checkCopyPasteSpecialTranspose(true, true);
2359 pUndoPaste->Undo();
2360 pUndoCut->Undo();
2361 checkCopyPasteSpecialInitial(srcSheet);
2363 pUndoCut->Redo();
2364 pUndoPaste->Redo();
2365 checkCopyPasteSpecialTranspose(true, true);
2367 pUndoPaste->Undo();
2368 pUndoCut->Undo();
2369 checkCopyPasteSpecialInitial(srcSheet);
2371 pUndoPaste.reset();
2372 pUndoCut.reset();
2374 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
2375 m_pDoc->DeleteTab(i - 1);
2378 // check initial source
2379 void TestCopyPaste::checkCopyPasteSpecialInitial(const SCTAB srcSheet)
2381 const EditTextObject* pEditObj;
2382 // col 1
2383 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 2, srcSheet));
2384 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 3, srcSheet));
2385 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1, 4, srcSheet));
2386 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(1, 5, srcSheet));
2387 // col 2, formulas
2388 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 2, srcSheet));
2389 CPPUNIT_ASSERT_EQUAL(OUString("=B3+10"), m_pDoc->GetFormula(2, 2, srcSheet));
2390 CPPUNIT_ASSERT_EQUAL(OUString("=B4+20"), m_pDoc->GetFormula(2, 3, srcSheet));
2391 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, srcSheet));
2392 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 4, srcSheet));
2393 CPPUNIT_ASSERT_EQUAL(OUString("=E5+30"), m_pDoc->GetFormula(2, 4, srcSheet));
2394 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(2, 5, srcSheet));
2395 CPPUNIT_ASSERT_EQUAL(OUString("=B4+40"), m_pDoc->GetFormula(2, 5, srcSheet));
2396 // col 3, strings
2397 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(3, 2, srcSheet));
2398 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(3, 3, srcSheet));
2399 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(3, 4, srcSheet));
2400 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(3, 5, srcSheet));
2401 // col 4, rich text
2402 pEditObj = m_pDoc->GetEditText(ScAddress(4, 2, srcSheet));
2403 CPPUNIT_ASSERT(pEditObj);
2404 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
2405 pEditObj = m_pDoc->GetEditText(ScAddress(4, 3, srcSheet));
2406 CPPUNIT_ASSERT(pEditObj);
2407 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
2408 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 4, srcSheet));
2409 pEditObj = m_pDoc->GetEditText(ScAddress(4, 5, srcSheet));
2410 CPPUNIT_ASSERT(pEditObj);
2411 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
2412 // col 5, formulas
2413 CPPUNIT_ASSERT_EQUAL(OUString("=B3+B5+60"), m_pDoc->GetFormula(5, 2, srcSheet));
2414 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(5, 2, srcSheet));
2415 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(5, 3, srcSheet));
2416 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(5, 4, srcSheet));
2417 CPPUNIT_ASSERT_EQUAL(OUString("=B3+B5+70"), m_pDoc->GetFormula(5, 5, srcSheet));
2418 CPPUNIT_ASSERT_EQUAL(74.0, m_pDoc->GetValue(5, 5, srcSheet));
2419 // col 6, formulas
2420 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(B3:B6;\"<4\")"), m_pDoc->GetFormula(6, 2, srcSheet));
2421 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(6, 2, srcSheet));
2422 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 3, srcSheet));
2423 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 4, srcSheet));
2424 CPPUNIT_ASSERT_EQUAL(OUString("=C$3+$B$5+80"), m_pDoc->GetFormula(6, 5, srcSheet));
2425 CPPUNIT_ASSERT_EQUAL(94.0, m_pDoc->GetValue(6, 5, srcSheet));
2427 // check patterns
2428 const SfxPoolItem* pItem = nullptr;
2429 m_pDoc->GetPattern(ScAddress(1, 2, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2430 CPPUNIT_ASSERT(pItem);
2431 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2432 m_pDoc->GetPattern(ScAddress(1, 3, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2433 CPPUNIT_ASSERT(pItem);
2434 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2435 m_pDoc->GetPattern(ScAddress(1, 4, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2436 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2437 m_pDoc->GetPattern(ScAddress(1, 5, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2438 CPPUNIT_ASSERT(!pItem);
2439 m_pDoc->GetPattern(ScAddress(1, 6, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2440 CPPUNIT_ASSERT(!pItem);
2441 m_pDoc->GetPattern(ScAddress(5, 4, srcSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2442 CPPUNIT_ASSERT(pItem);
2443 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2445 // check border, left and right borders were transformed to top and bottom borders
2446 pItem = m_pDoc->GetAttr(ScAddress(2, 2, srcSheet), ATTR_BORDER);
2447 CPPUNIT_ASSERT(pItem);
2448 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2449 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2450 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2451 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2452 pItem = m_pDoc->GetAttr(ScAddress(2, 3, srcSheet), ATTR_BORDER);
2453 CPPUNIT_ASSERT(pItem);
2454 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2455 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2456 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2457 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2458 pItem = m_pDoc->GetAttr(ScAddress(2, 4, srcSheet), ATTR_BORDER);
2459 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2460 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2461 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2462 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2463 pItem = m_pDoc->GetAttr(ScAddress(2, 5, srcSheet), ATTR_BORDER);
2464 CPPUNIT_ASSERT(pItem);
2465 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2466 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2467 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2468 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2469 pItem = m_pDoc->GetAttr(ScAddress(2, 6, srcSheet), ATTR_BORDER);
2470 CPPUNIT_ASSERT(pItem);
2471 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2472 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2473 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2474 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2476 // check notes after transposed copy/paste
2477 // check presence of notes
2478 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 2, srcSheet));
2479 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 2, srcSheet));
2480 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 2, srcSheet));
2481 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, srcSheet));
2482 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 2, srcSheet));
2483 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, srcSheet));
2484 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, srcSheet));
2485 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 3, srcSheet));
2486 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, srcSheet));
2487 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, srcSheet));
2488 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, srcSheet));
2489 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 3, srcSheet));
2490 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, srcSheet));
2491 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, srcSheet));
2492 CPPUNIT_ASSERT(m_pDoc->HasNote(1, 4, srcSheet));
2493 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 4, srcSheet));
2494 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 4, srcSheet));
2495 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, srcSheet));
2496 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, srcSheet));
2497 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, srcSheet));
2498 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, srcSheet));
2499 CPPUNIT_ASSERT(!m_pDoc->HasNote(1, 5, srcSheet));
2500 CPPUNIT_ASSERT(m_pDoc->HasNote(2, 5, srcSheet));
2501 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 5, srcSheet));
2502 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 5, srcSheet));
2503 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 5, srcSheet));
2504 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 5, srcSheet));
2505 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, srcSheet));
2506 CPPUNIT_ASSERT(!m_pDoc->HasNote(1, 6, srcSheet));
2507 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, srcSheet));
2508 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 6, srcSheet));
2509 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, srcSheet));
2510 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, srcSheet));
2511 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, srcSheet));
2512 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 6, srcSheet));
2514 // check values of notes
2515 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(1, 2, srcSheet));
2516 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(1, 3, srcSheet));
2517 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(1, 4, srcSheet));
2518 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(2, 2, srcSheet));
2519 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(2, 4, srcSheet));
2520 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(3, 3, srcSheet));
2521 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(3, 4, srcSheet));
2522 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(4, 2, srcSheet));
2523 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(4, 3, srcSheet));
2524 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(4, 4, srcSheet));
2525 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 4, srcSheet));
2526 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(5, 5, srcSheet));
2527 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(6, 3, srcSheet));
2528 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(6, 5, srcSheet));
2530 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
2531 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
2532 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
2533 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
2534 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
2535 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
2536 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
2537 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
2538 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
2539 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
2541 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
2542 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
2543 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
2544 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
2545 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
2546 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
2547 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
2548 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
2549 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
2550 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
2552 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
2553 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
2554 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
2555 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
2556 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
2557 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
2558 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
2559 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
2560 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
2561 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
2563 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
2564 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
2565 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
2566 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
2567 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
2568 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
2569 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
2570 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
2571 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
2572 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
2574 // Existing references to the destination range must not change
2575 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
2576 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
2577 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
2578 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
2579 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
2580 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
2581 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
2582 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
2583 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
2584 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
2585 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
2586 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
2587 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
2588 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
2589 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
2590 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
2591 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
2592 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
2593 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
2594 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
2595 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
2596 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
2597 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
2598 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
2599 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
2600 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
2601 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
2602 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
2603 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
2604 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
2605 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
2606 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
2607 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
2608 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
2609 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
2610 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
2611 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
2612 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
2613 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
2614 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
2615 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
2616 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
2617 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
2618 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
2619 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
2620 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
2621 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
2622 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
2623 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
2626 // Base check, nothing filtered, nothing transposed
2627 void TestCopyPaste::checkCopyPasteSpecial(bool bSkipEmpty, bool bCut)
2629 const SCTAB srcSheet = 0;
2630 const SCTAB destSheet = 1;
2633 | D | E | F | G | H | I |
2635 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
2636 3 | 2 B*| =D3+20 b | b *| R2 *| | *|
2637 4 | 3 B*| =G4+30 b*| c *| 5 *| B*| |
2638 5 | 4 | =D3+40 b*| d *| R4 *| =D2+D4+70 *| =E$3+$B$5+80 *|
2640 * means note attached
2641 B means background
2642 b means border
2645 const EditTextObject* pEditObj;
2646 // col 2
2647 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
2648 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
2649 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
2650 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
2651 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
2652 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
2653 // col 3, numbers
2654 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
2655 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
2656 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
2657 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
2658 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 4, destSheet));
2659 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
2660 // col 4, formulas
2661 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
2662 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
2663 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
2664 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), m_pDoc->GetFormula(4, 2, destSheet));
2665 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
2666 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 3, destSheet));
2667 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), m_pDoc->GetFormula(4, 3, destSheet));
2668 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(4, 4, destSheet));
2669 CPPUNIT_ASSERT_EQUAL(OUString("=D3+40"), m_pDoc->GetFormula(4, 4, destSheet));
2670 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
2671 // col 5, strings
2672 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
2673 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
2674 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
2675 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(5, 2, destSheet));
2676 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 3, destSheet));
2677 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(5, 4, destSheet));
2678 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
2679 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 5, destSheet));
2680 // col 6, rich text
2681 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
2682 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
2683 CPPUNIT_ASSERT(pEditObj == nullptr);
2684 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
2685 CPPUNIT_ASSERT(pEditObj);
2686 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
2687 pEditObj = m_pDoc->GetEditText(ScAddress(6, 2, destSheet));
2688 CPPUNIT_ASSERT(pEditObj);
2689 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
2690 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 3, destSheet));
2691 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
2692 CPPUNIT_ASSERT(pEditObj);
2693 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
2694 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
2695 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
2696 CPPUNIT_ASSERT(pEditObj == nullptr);
2697 // col 7, formulas
2698 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
2699 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
2700 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
2701 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(7, 1, destSheet));
2702 if (!bSkipEmpty)
2704 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
2705 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
2707 else
2709 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
2710 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
2712 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+70"), m_pDoc->GetFormula(7, 4, destSheet));
2713 CPPUNIT_ASSERT_EQUAL(74.0, m_pDoc->GetValue(7, 4, destSheet));
2714 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
2715 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
2716 // col 8, formulas
2717 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
2718 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
2719 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
2720 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
2721 if (!bSkipEmpty)
2723 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
2724 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 3, destSheet));
2726 else
2728 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
2729 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
2731 double fValue = m_pDoc->GetValue(8, 4, destSheet);
2732 OUString aStr = m_pDoc->GetFormula(8, 4, destSheet);
2733 if (!bCut)
2735 CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), aStr);
2736 CPPUNIT_ASSERT_EQUAL(1102.0, fValue);
2738 else
2740 CPPUNIT_ASSERT_EQUAL(OUString("=E$2+$D$4+80"), aStr);
2741 CPPUNIT_ASSERT_EQUAL(94.0, fValue);
2743 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
2744 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
2745 // col 9, numbers
2746 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
2747 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
2748 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
2749 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
2750 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
2751 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
2753 // check patterns
2754 const SfxPoolItem* pItem = nullptr;
2755 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2756 CPPUNIT_ASSERT(pItem);
2757 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2758 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2759 CPPUNIT_ASSERT(pItem);
2760 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2761 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2762 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2763 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2764 CPPUNIT_ASSERT(!pItem);
2765 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2766 CPPUNIT_ASSERT(!pItem);
2767 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
2768 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
2769 if (!bSkipEmpty)
2770 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
2772 // check border, left and right borders were transformed to top and bottom borders
2773 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
2774 CPPUNIT_ASSERT(pItem);
2775 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2776 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2777 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2778 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2779 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
2780 CPPUNIT_ASSERT(pItem);
2781 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2782 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2783 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2784 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2785 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
2786 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2787 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2788 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2789 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2790 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
2791 CPPUNIT_ASSERT(pItem);
2792 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2793 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2794 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2795 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
2796 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
2797 CPPUNIT_ASSERT(pItem);
2798 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
2799 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
2800 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
2801 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
2803 // check notes after transposed copy/paste
2804 // check presence of notes
2805 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
2806 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
2807 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
2808 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
2809 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
2810 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
2811 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
2812 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
2813 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
2814 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
2815 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
2816 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
2817 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
2818 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
2819 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
2820 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
2821 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
2822 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
2823 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
2824 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
2825 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
2826 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
2827 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(8, 2, destSheet));
2828 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
2829 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
2830 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
2831 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
2832 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
2833 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
2834 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 3, destSheet));
2835 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
2836 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
2837 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
2838 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
2839 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
2840 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
2841 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
2842 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 4, destSheet));
2843 CPPUNIT_ASSERT(m_pDoc->HasNote(8, 4, destSheet));
2844 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
2845 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
2846 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
2847 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
2848 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
2849 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
2850 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
2851 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
2852 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
2854 // check values of notes
2855 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
2856 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
2857 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
2858 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
2859 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
2860 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(5, 2, destSheet));
2861 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 3, destSheet));
2862 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
2863 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(6, 2, destSheet));
2864 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 3, destSheet));
2865 if (!bSkipEmpty)
2866 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 3, destSheet));
2867 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(7, 4, destSheet));
2868 if (!bSkipEmpty)
2869 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(8, 2, destSheet));
2870 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(8, 4, destSheet));
2872 // Existing references to the destination range must not change
2873 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
2874 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
2875 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
2876 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
2877 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
2878 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
2879 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
2880 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
2881 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
2882 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
2883 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
2884 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
2885 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
2886 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
2887 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
2888 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
2889 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
2890 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
2891 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
2892 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
2893 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
2894 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
2895 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
2896 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
2897 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
2898 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
2899 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
2900 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
2901 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
2902 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
2903 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
2904 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
2905 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
2906 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
2907 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
2908 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
2909 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
2910 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
2911 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
2912 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
2913 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
2914 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
2915 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
2916 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
2917 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
2918 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
2919 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
2920 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
2921 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
2923 // row 14 on src sheet, refs to copied/cut range
2924 if (!bCut)
2926 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
2927 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
2928 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
2929 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
2930 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
2931 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
2932 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
2933 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
2934 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
2935 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
2937 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
2938 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
2939 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
2940 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
2941 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
2942 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
2943 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
2944 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
2945 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
2946 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
2948 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
2949 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
2950 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
2951 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
2952 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
2953 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
2954 m_pDoc->GetFormula(6, 17, srcSheet));
2955 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
2956 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
2957 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
2958 m_pDoc->GetFormula(9, 17, srcSheet));
2959 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
2960 m_pDoc->GetFormula(10, 17, srcSheet));
2962 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
2963 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
2964 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
2965 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
2966 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
2967 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
2968 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
2969 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
2970 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
2971 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
2973 m_pDoc->DeleteTab(destSheet);
2974 m_pDoc->DeleteTab(srcSheet);
2976 else
2978 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(1, 16, srcSheet));
2979 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$E$4"), m_pDoc->GetFormula(2, 16, srcSheet));
2980 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$E4"), m_pDoc->GetFormula(3, 16, srcSheet));
2981 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E$4"), m_pDoc->GetFormula(4, 16, srcSheet));
2982 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.E4:E4)"),
2983 m_pDoc->GetFormula(5, 16, srcSheet));
2984 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$E$4:$E$4)"),
2985 m_pDoc->GetFormula(6, 16, srcSheet));
2986 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$E4:$E4)"),
2987 m_pDoc->GetFormula(7, 16, srcSheet));
2988 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.E$4:E$4)"),
2989 m_pDoc->GetFormula(8, 16, srcSheet));
2990 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$D$2:$D$5)"),
2991 m_pDoc->GetFormula(9, 16, srcSheet));
2992 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
2994 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
2995 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
2996 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
2997 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
2998 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
2999 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3000 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3001 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3002 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3003 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 16, srcSheet));
3005 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3006 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3007 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3008 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3009 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3010 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3011 m_pDoc->GetFormula(6, 17, srcSheet));
3012 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3013 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3014 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3015 m_pDoc->GetFormula(9, 17, srcSheet));
3016 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3017 m_pDoc->GetFormula(10, 17, srcSheet));
3019 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3020 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3021 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3022 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(4, 17, srcSheet));
3023 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3024 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3025 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3026 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3027 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3028 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 17, srcSheet));
3032 void TestCopyPaste::checkCopyPasteSpecialFiltered(bool bSkipEmpty)
3034 const SCTAB srcSheet = 0;
3035 const SCTAB destSheet = 1;
3038 | D | E | F | G | H | I |
3040 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
3041 3 | 3 B*| =G3+30 b*| c *| 5 *| B*| |
3042 4 | 4 | =D2+40 b*| d *| R4 *| =D1+D3+70 *| =E$3+$B$5+80 *|
3043 5 | 1 B*| =D5+10 *| a | R1 *| =D5+D7+60 | =SUMIF(D5:D8;"<4") | <- repeated row
3045 * means note attached
3046 B means background
3047 b means border
3050 const EditTextObject* pEditObj;
3052 // col 2
3053 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3054 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3055 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3056 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3057 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3058 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3059 // col 3, numbers
3060 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3061 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
3062 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
3063 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 3, destSheet));
3064 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 4, destSheet)); // repeated row 1
3065 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
3066 // col 4, formulas
3067 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3068 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 0, destSheet));
3069 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
3070 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
3071 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), m_pDoc->GetFormula(4, 2, destSheet));
3072 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 2, destSheet));
3073 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), m_pDoc->GetFormula(4, 3, destSheet));
3074 CPPUNIT_ASSERT_EQUAL(41.0, m_pDoc->GetValue(4, 3, destSheet));
3075 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 4, destSheet)); // repeated row 1
3076 CPPUNIT_ASSERT_EQUAL(OUString("=D5+10"), m_pDoc->GetFormula(4, 4, destSheet));
3077 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 4, destSheet));
3078 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3079 // col 5, strings
3080 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3081 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
3082 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 2, destSheet));
3083 CPPUNIT_ASSERT_EQUAL(OUString("d"), m_pDoc->GetString(5, 3, destSheet));
3084 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 4, destSheet)); // repeated row 1
3085 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
3086 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 5, destSheet));
3087 // col 6, rich text
3088 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3089 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
3090 CPPUNIT_ASSERT(pEditObj == nullptr);
3091 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
3092 CPPUNIT_ASSERT(pEditObj);
3093 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
3094 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 2, destSheet));
3095 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
3096 CPPUNIT_ASSERT(pEditObj);
3097 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
3098 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet)); // repeated row 1
3099 CPPUNIT_ASSERT(pEditObj);
3100 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
3101 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
3102 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
3103 CPPUNIT_ASSERT(pEditObj == nullptr);
3104 // col 7, formulas
3105 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3106 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
3107 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
3108 // formula is not adjusted due to filter row
3109 CPPUNIT_ASSERT_EQUAL(65.0, m_pDoc->GetValue(7, 1, destSheet));
3110 if (!bSkipEmpty)
3111 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
3112 else
3113 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3114 CPPUNIT_ASSERT_EQUAL(OUString("=D1+D3+70"), m_pDoc->GetFormula(7, 3, destSheet));
3115 CPPUNIT_ASSERT_EQUAL(1073.0, m_pDoc->GetValue(7, 3, destSheet));
3116 CPPUNIT_ASSERT_EQUAL(OUString("=D5+D7+60"),
3117 m_pDoc->GetFormula(7, 4, destSheet)); // repeated row 1
3118 // formula is not adjusted due to filter row
3119 CPPUNIT_ASSERT_EQUAL(1061.0, m_pDoc->GetValue(7, 4, destSheet));
3120 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3121 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3122 // col 8, formulas
3123 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
3124 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
3125 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
3126 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(8, 1, destSheet));
3127 if (!bSkipEmpty)
3128 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
3129 else
3130 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
3131 CPPUNIT_ASSERT_EQUAL(1115.0, m_pDoc->GetValue(8, 3, destSheet));
3132 CPPUNIT_ASSERT_EQUAL(OUString("=E$3+$B$5+80"), m_pDoc->GetFormula(8, 3, destSheet));
3133 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D5:D8;\"<4\")"), m_pDoc->GetFormula(8, 4, destSheet));
3134 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(8, 4, destSheet));
3135 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
3136 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
3137 // col 9, numbers
3138 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
3139 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
3140 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
3141 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
3142 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
3143 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
3145 // check patterns
3146 const SfxPoolItem* pItem = nullptr;
3147 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3148 CPPUNIT_ASSERT(pItem);
3149 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3150 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3151 CPPUNIT_ASSERT(pItem);
3152 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3153 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3154 CPPUNIT_ASSERT(!pItem);
3155 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3156 CPPUNIT_ASSERT(pItem);
3157 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3158 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3159 CPPUNIT_ASSERT(!pItem);
3160 m_pDoc->GetPattern(ScAddress(7, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3161 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3162 if (!bSkipEmpty)
3163 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3165 // check border, left and right borders were transformed to top and bottom borders
3166 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
3167 CPPUNIT_ASSERT(pItem);
3168 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3169 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3170 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3171 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3172 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3173 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3174 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3175 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3176 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
3177 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
3178 CPPUNIT_ASSERT(pItem);
3179 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3180 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3181 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3182 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
3183 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
3184 CPPUNIT_ASSERT(pItem);
3185 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
3186 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3187 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3188 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
3190 // check notes after transposed copy/paste
3191 // check presence of notes
3192 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
3193 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
3194 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
3195 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
3196 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
3197 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
3198 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
3199 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
3200 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
3201 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
3202 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
3203 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
3204 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
3205 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
3206 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
3207 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
3208 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
3209 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
3210 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
3211 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
3212 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
3213 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
3214 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
3215 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
3216 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
3217 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
3218 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
3219 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
3220 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
3221 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 3, destSheet));
3222 CPPUNIT_ASSERT(m_pDoc->HasNote(8, 3, destSheet));
3223 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
3224 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
3225 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 4, destSheet));
3226 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
3227 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
3228 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
3229 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
3230 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
3231 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
3232 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
3233 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
3234 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
3235 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
3236 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
3237 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
3238 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
3239 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
3241 // check values of notes
3242 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
3243 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
3244 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
3245 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
3246 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 2, destSheet));
3247 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
3248 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 2, destSheet));
3249 if (!bSkipEmpty)
3250 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 2, destSheet));
3251 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(7, 3, destSheet));
3252 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(8, 3, destSheet));
3254 m_pDoc->DeleteTab(destSheet);
3255 m_pDoc->DeleteTab(srcSheet);
3258 void TestCopyPaste::checkCopyPasteSpecialTranspose(bool bSkipEmpty, bool bCut)
3260 const SCTAB srcSheet = 0;
3261 const SCTAB destSheet = 1;
3264 | D | E | F | G |
3266 2 | 1 B*| 2 B*| 3 B*| 4 |
3267 3 | =D2+10 *| =E2+20 b | =F5+30 b*| =E2+40 b*|
3268 4 | a | b *| c *| d *|
3269 5 | R1 *| R2 *| 5 *| R4 *|
3270 6 | =D2+F2+60 | | B*| =D2+F2+70 *|
3271 7 | =SUMIF(D2:G2;"<4") | *| | =C$3+$B$5+80 *|
3273 * means note attached
3274 B means background
3275 b means border
3278 //check cell content after transposed copy/paste of filtered data
3279 // Note: column F is a repetition of srcSheet.Column A
3280 // Col C and G are checked to be empty
3281 const EditTextObject* pEditObj;
3282 // row 0
3283 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3284 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3285 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3286 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3287 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3288 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3289 // row 1, numbers
3290 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3291 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
3292 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 2.0, m_pDoc->GetValue(4, 1, destSheet));
3293 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 3.0, m_pDoc->GetValue(5, 1, destSheet));
3294 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2", 4.0, m_pDoc->GetValue(6, 1, destSheet));
3295 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
3296 // row 2, formulas
3297 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3298 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
3299 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
3300 m_pDoc->GetFormula(3, 2, destSheet));
3301 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
3302 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E2+20"),
3303 m_pDoc->GetFormula(4, 2, destSheet));
3304 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 22.0, m_pDoc->GetValue(4, 2, destSheet));
3305 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=F5+30"),
3306 m_pDoc->GetFormula(5, 2, destSheet));
3307 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 35.0, m_pDoc->GetValue(5, 2, destSheet));
3308 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3", OUString("=E2+40"),
3309 m_pDoc->GetFormula(6, 2, destSheet));
3310 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3", 42.0, m_pDoc->GetValue(6, 2, destSheet));
3311 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3312 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
3313 // row 3, strings
3314 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3315 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
3316 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
3317 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("b"), m_pDoc->GetString(4, 3, destSheet));
3318 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("c"), m_pDoc->GetString(5, 3, destSheet));
3319 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("d"), m_pDoc->GetString(6, 3, destSheet));
3320 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
3321 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
3322 // row 4, rich text
3323 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3324 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
3325 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
3326 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
3327 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
3328 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
3329 pEditObj->GetText(0));
3330 pEditObj = m_pDoc->GetEditText(ScAddress(4, 4, destSheet));
3331 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in E5.", pEditObj);
3332 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong E5.", OUString("R2"), pEditObj->GetText(0));
3333 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F5", 5.0, m_pDoc->GetValue(5, 4, destSheet));
3334 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
3335 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in G5.", pEditObj);
3336 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong G5.", OUString("R4"), pEditObj->GetText(0));
3337 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
3338 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
3339 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
3340 // row 5, formulas
3341 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3342 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
3343 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
3344 m_pDoc->GetFormula(3, 5, destSheet));
3345 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 64.0, m_pDoc->GetValue(3, 5, destSheet));
3346 if (!bSkipEmpty)
3348 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
3349 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
3351 else
3353 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3354 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
3356 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6", OUString("=D2+F2+70"),
3357 m_pDoc->GetFormula(6, 5, destSheet));
3358 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6", 74.0, m_pDoc->GetValue(6, 5, destSheet));
3359 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3360 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3361 // row 6, formulas
3362 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
3363 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
3364 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
3365 m_pDoc->GetFormula(3, 6, destSheet));
3366 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 6.0, m_pDoc->GetValue(3, 6, destSheet));
3367 if (!bSkipEmpty)
3369 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
3370 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 6, destSheet));
3372 else
3374 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
3375 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
3377 double fValue = m_pDoc->GetValue(6, 6, destSheet); // G7
3378 OUString aStr = m_pDoc->GetFormula(6, 6, destSheet); // G7
3379 if (!bCut)
3381 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", OUString("=C$3+$B$5+80"), aStr);
3382 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7", 2080.0, fValue);
3384 else
3386 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$F$2+80"), aStr);
3387 CPPUNIT_ASSERT_EQUAL(94.0, fValue);
3389 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
3390 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
3391 // row 7
3392 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
3393 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
3394 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
3395 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
3396 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
3397 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
3399 // check patterns
3400 const SfxPoolItem* pItem = nullptr;
3401 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3402 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
3403 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
3404 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3405 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3406 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
3407 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has blue background", COL_BLUE,
3408 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3409 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3410 CPPUNIT_ASSERT_MESSAGE("F2 has a pattern", pItem);
3411 CPPUNIT_ASSERT_EQUAL_MESSAGE("F2 has a pattern", COL_BLUE,
3412 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3413 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3414 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
3415 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3416 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
3417 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3418 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3419 if (!bSkipEmpty)
3420 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3422 // check border, left and right borders were transformed to top and bottom borders
3423 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
3424 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
3425 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
3426 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3427 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
3428 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3429 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
3430 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3431 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
3432 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3434 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
3435 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3436 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3438 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3439 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3440 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3442 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
3443 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3444 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
3445 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3446 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
3447 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3448 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
3449 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
3450 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3451 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
3452 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3453 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
3454 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3455 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
3456 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3457 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
3458 CPPUNIT_ASSERT_MESSAGE("G3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3459 CPPUNIT_ASSERT_MESSAGE("G3 has bottom border",
3460 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3461 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
3462 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3463 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
3464 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3465 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
3466 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
3467 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
3468 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3469 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
3470 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3471 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
3472 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3473 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
3474 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3476 // check notes after transposed copy/paste
3477 // check presence of notes
3478 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
3479 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
3480 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
3481 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
3482 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
3483 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
3484 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
3485 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
3486 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
3487 CPPUNIT_ASSERT_MESSAGE("F2: a note", m_pDoc->HasNote(5, 1, destSheet));
3488 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
3489 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
3490 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
3491 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
3492 CPPUNIT_ASSERT_MESSAGE("E3: no note", !m_pDoc->HasNote(4, 2, destSheet));
3493 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
3494 CPPUNIT_ASSERT_MESSAGE("G3: a note", m_pDoc->HasNote(6, 2, destSheet));
3495 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
3496 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
3497 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
3498 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
3499 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
3500 CPPUNIT_ASSERT_MESSAGE("G4: a note", m_pDoc->HasNote(6, 3, destSheet));
3501 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
3502 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
3503 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
3504 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
3505 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
3506 CPPUNIT_ASSERT_MESSAGE("G5: a note", m_pDoc->HasNote(6, 4, destSheet));
3507 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
3508 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
3509 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
3510 CPPUNIT_ASSERT_MESSAGE("E6: no note", !m_pDoc->HasNote(4, 5, destSheet));
3511 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 5, destSheet));
3512 CPPUNIT_ASSERT_MESSAGE("G6: a note", m_pDoc->HasNote(6, 5, destSheet));
3513 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
3514 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
3515 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
3516 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 6, destSheet));
3517 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
3518 CPPUNIT_ASSERT_MESSAGE("G7: a note", m_pDoc->HasNote(6, 6, destSheet));
3519 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
3520 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
3521 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
3522 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
3523 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
3524 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
3525 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
3527 // check values of notes
3528 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
3529 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A2"), getNote(4, 1, destSheet));
3530 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F2", OUString("Note A3"), getNote(5, 1, destSheet));
3531 // G2 has no note
3532 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
3533 // E3 has no note
3534 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B3"), getNote(5, 2, destSheet));
3535 // D4 has no note
3536 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C2"), getNote(4, 3, destSheet));
3537 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C3"), getNote(5, 3, destSheet));
3538 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
3539 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D2"), getNote(4, 4, destSheet));
3540 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D3"), getNote(5, 4, destSheet));
3541 if (!bSkipEmpty)
3542 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 5, destSheet));
3543 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G6", OUString("Note E4"), getNote(6, 5, destSheet));
3544 if (!bSkipEmpty)
3545 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString("Note F2"), getNote(4, 6, destSheet));
3546 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G7", OUString("Note F4"), getNote(6, 6, destSheet));
3548 // row 14 on src sheet, refs to copied/cut range
3549 if (!bCut)
3551 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
3552 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
3553 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
3554 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
3555 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
3556 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
3557 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
3558 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
3559 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
3560 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
3562 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3563 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3564 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3565 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3566 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3567 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3568 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3569 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3570 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3571 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
3573 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3574 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3575 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3576 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3577 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3578 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3579 m_pDoc->GetFormula(6, 17, srcSheet));
3580 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3581 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3582 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3583 m_pDoc->GetFormula(9, 17, srcSheet));
3584 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3585 m_pDoc->GetFormula(10, 17, srcSheet));
3587 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3588 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3589 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3590 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
3591 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3592 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3593 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3594 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3595 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3596 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
3598 // Existing references to the destination range must not change
3599 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
3600 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
3601 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
3602 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
3603 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
3604 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
3605 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
3606 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
3607 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
3608 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
3609 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
3610 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
3611 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
3612 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
3613 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
3614 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
3615 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
3616 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
3617 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
3618 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
3619 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
3620 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
3621 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
3622 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
3623 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
3624 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
3625 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
3626 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
3627 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
3628 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
3629 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
3630 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
3631 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
3632 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
3633 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
3634 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
3635 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
3636 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
3637 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
3638 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
3639 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
3640 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
3641 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
3642 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
3643 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
3644 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
3645 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
3646 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
3647 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
3649 m_pDoc->DeleteTab(destSheet);
3650 m_pDoc->DeleteTab(srcSheet);
3652 else
3654 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(1, 16, srcSheet));
3655 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$F$3"), m_pDoc->GetFormula(2, 16, srcSheet));
3656 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.$F3"), m_pDoc->GetFormula(3, 16, srcSheet));
3657 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F$3"), m_pDoc->GetFormula(4, 16, srcSheet));
3658 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.F3:F3)"),
3659 m_pDoc->GetFormula(5, 16, srcSheet));
3660 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$F$3:$F$3)"),
3661 m_pDoc->GetFormula(6, 16, srcSheet));
3662 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$F3:$F3)"),
3663 m_pDoc->GetFormula(7, 16, srcSheet));
3664 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.F$3:F$3)"),
3665 m_pDoc->GetFormula(8, 16, srcSheet));
3666 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(DestSheet.$D$2:$G$2)"),
3667 m_pDoc->GetFormula(9, 16, srcSheet));
3668 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
3670 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
3671 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
3672 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
3673 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
3674 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
3675 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
3676 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
3677 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
3678 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
3679 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 16, srcSheet));
3681 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
3682 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
3683 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
3684 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
3685 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
3686 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"),
3687 m_pDoc->GetFormula(6, 17, srcSheet));
3688 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
3689 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
3690 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"),
3691 m_pDoc->GetFormula(9, 17, srcSheet));
3692 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"),
3693 m_pDoc->GetFormula(10, 17, srcSheet));
3695 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
3696 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
3697 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
3698 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(4, 17, srcSheet));
3699 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
3700 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
3701 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
3702 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
3703 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
3704 CPPUNIT_ASSERT_EQUAL(-27.0, m_pDoc->GetValue(10, 17, srcSheet));
3706 // Existing references to the destination range must not change
3707 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
3708 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
3709 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
3710 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
3711 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
3712 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
3713 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
3714 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
3715 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
3716 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
3717 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
3718 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
3719 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
3720 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
3721 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
3722 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
3723 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
3724 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
3725 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
3726 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
3727 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
3728 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
3729 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
3730 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
3731 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
3732 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
3733 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
3734 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
3735 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
3736 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
3737 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
3738 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
3739 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
3740 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
3741 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
3742 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
3743 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
3744 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
3745 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
3746 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
3747 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
3748 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
3749 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
3750 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
3751 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
3752 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
3753 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
3754 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
3755 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
3759 void TestCopyPaste::checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty)
3761 const SCTAB srcSheet = 0;
3762 const SCTAB destSheet = 1;
3765 ┌--- filtered src row 2 ┌--- repeated row
3768 | D | E | F | G |
3770 2 | 1 B*| 3 B*| 4 | 1 B*|
3771 3 | =D2+10 *| =E5+30 b*| =D2+40 b*| =G2+10 *|
3772 4 | a | c *| d *| a |
3773 5 | R1 *| 5 *| R4 *| R1 *|
3774 6 | =D2+F2+60 | B*| =C2+E2+70 *| =G2+I2+60 |
3775 7 | =SUMIF(D2:G2;"<4") | | =B$3+$B$5+80 *| =SUMIF(G2:J2;"<4") |
3777 * means note attached
3780 //check cell content after transposed copy/paste of filtered data
3781 // Note: column F is a repetition of srcSheet.Column A
3782 // Col C and G are checked to be empty
3783 const EditTextObject* pEditObj;
3784 // row 0
3785 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
3786 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
3787 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
3788 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
3789 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
3790 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
3791 // row 1, numbers
3792 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
3793 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 1, destSheet));
3794 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
3795 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 3.0, m_pDoc->GetValue(4, 1, destSheet));
3796 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 4.0, m_pDoc->GetValue(5, 1, destSheet));
3797 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2 (repetition of D2)", 1.0,
3798 m_pDoc->GetValue(6, 1, destSheet));
3799 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
3800 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 1, destSheet));
3801 // row 2, formulas
3802 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
3803 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
3804 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
3805 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
3806 m_pDoc->GetFormula(3, 2, destSheet));
3807 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E5+30"),
3808 m_pDoc->GetFormula(4, 2, destSheet));
3809 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 35.0, m_pDoc->GetValue(4, 2, destSheet));
3810 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=D2+40"),
3811 m_pDoc->GetFormula(5, 2, destSheet));
3812 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 41.0, m_pDoc->GetValue(5, 2, destSheet));
3813 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 11.0, m_pDoc->GetValue(6, 2, destSheet));
3814 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G3 (repetition of D3)", OUString("=G2+10"),
3815 m_pDoc->GetFormula(6, 2, destSheet));
3816 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
3817 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
3818 // row 3, strings
3819 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
3820 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
3821 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
3822 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("c"), m_pDoc->GetString(4, 3, destSheet));
3823 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("d"), m_pDoc->GetString(5, 3, destSheet));
3824 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4 (repetition of D4)", OUString("a"),
3825 m_pDoc->GetString(6, 3, destSheet));
3826 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
3827 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
3828 // row 4, rich text
3829 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
3830 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
3831 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
3832 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
3833 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
3834 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
3835 pEditObj->GetText(0));
3836 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E5", 5.0, m_pDoc->GetValue(4, 4, destSheet));
3837 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
3838 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in F5.", pEditObj);
3839 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong F5.", OUString("R4"), pEditObj->GetText(0));
3840 pEditObj = m_pDoc->GetEditText(ScAddress(6, 4, destSheet));
3841 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in G5. (repetition of D5)", pEditObj);
3842 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong G5. (repetition of D5)", OUString("R1"),
3843 pEditObj->GetText(0));
3844 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
3845 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
3846 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
3847 // row 5, formulas
3848 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
3849 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
3850 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
3851 m_pDoc->GetFormula(3, 5, destSheet));
3852 // formulas over filtered rows are not adjusted
3853 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 65.0,
3854 m_pDoc->GetValue(ScAddress(3, 5, destSheet)));
3855 if (!bSkipEmpty)
3856 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
3857 else
3858 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
3859 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", OUString("=C2+E2+70"),
3860 m_pDoc->GetFormula(5, 5, destSheet));
3861 // F6, formulas over filtered rows are not adjusted
3862 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", 1073.0,
3863 m_pDoc->GetValue(ScAddress(5, 5, destSheet)));
3864 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6 (repetition of D6)", OUString("=G2+I2+60"),
3865 m_pDoc->GetFormula(6, 5, destSheet));
3866 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G6 (repetition of D6)", 1061.0,
3867 m_pDoc->GetValue(6, 5, destSheet));
3868 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
3869 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
3870 // row 6, formulas
3871 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
3872 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
3873 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
3874 m_pDoc->GetFormula(3, 6, destSheet));
3875 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 5.0, m_pDoc->GetValue(3, 6, destSheet));
3876 if (!bSkipEmpty)
3877 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
3878 else
3879 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
3880 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F7", OUString("=B$3+$B$5+80"),
3881 m_pDoc->GetFormula(5, 6, destSheet));
3882 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F6", 2080.0, m_pDoc->GetValue(5, 6, destSheet));
3883 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7 (repetition of D7)",
3884 OUString("=SUMIF(G2:J2;\"<4\")"),
3885 m_pDoc->GetFormula(6, 6, destSheet));
3886 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed G7 (repetition of D7)", 1061.0,
3887 m_pDoc->GetValue(6, 5, destSheet));
3888 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
3889 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
3891 // row
3892 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
3893 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
3894 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
3895 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
3896 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
3897 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
3899 // check patterns
3901 const SfxPoolItem* pItem = nullptr;
3902 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3903 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
3904 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
3905 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3906 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3907 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
3908 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3909 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3910 CPPUNIT_ASSERT_MESSAGE("F2 has no pattern", !pItem);
3911 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3912 CPPUNIT_ASSERT_MESSAGE("G2 has a pattern", pItem);
3913 CPPUNIT_ASSERT_EQUAL_MESSAGE("G2 has a pattern", COL_BLUE,
3914 static_cast<const SvxBrushItem*>(pItem)->GetColor());
3915 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3916 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
3917 m_pDoc->GetPattern(ScAddress(4, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
3918 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
3919 if (!bSkipEmpty)
3920 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
3922 // check border, left and right borders were transformed to top and bottom borders
3923 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
3924 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
3925 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
3926 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3927 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
3928 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3929 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
3930 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3931 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
3932 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3933 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
3934 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
3935 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3936 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
3937 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3938 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
3939 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3940 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
3941 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3942 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
3943 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
3944 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
3945 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
3946 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3947 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
3948 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3949 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
3950 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3951 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
3952 CPPUNIT_ASSERT_MESSAGE("G3 has a border", pItem);
3953 CPPUNIT_ASSERT_MESSAGE("G3 has no top border",
3954 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3955 CPPUNIT_ASSERT_MESSAGE("G3 has no bottom border",
3956 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3957 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
3958 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3959 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
3960 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3961 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
3962 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
3963 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
3964 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
3965 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
3966 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
3967 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
3968 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
3969 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
3970 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
3972 // check notes after transposed copy/paste
3973 // check presence of notes
3974 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
3975 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
3976 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
3977 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
3978 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
3979 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
3980 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
3981 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
3982 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
3983 CPPUNIT_ASSERT_MESSAGE("F2: no note", !m_pDoc->HasNote(5, 1, destSheet));
3984 CPPUNIT_ASSERT_MESSAGE("G2: a note", m_pDoc->HasNote(6, 1, destSheet));
3985 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
3986 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
3987 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
3988 CPPUNIT_ASSERT_MESSAGE("E3: a note", m_pDoc->HasNote(4, 2, destSheet));
3989 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
3990 CPPUNIT_ASSERT_MESSAGE("G3: a note", m_pDoc->HasNote(6, 2, destSheet));
3991 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
3992 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
3993 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
3994 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
3995 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
3996 CPPUNIT_ASSERT_MESSAGE("G4: no note", !m_pDoc->HasNote(6, 3, destSheet));
3997 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
3998 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
3999 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
4000 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
4001 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
4002 CPPUNIT_ASSERT_MESSAGE("G5: a note", m_pDoc->HasNote(6, 4, destSheet));
4003 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
4004 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
4005 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
4006 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
4007 CPPUNIT_ASSERT_MESSAGE("F6: a note", m_pDoc->HasNote(5, 5, destSheet));
4008 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
4009 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
4010 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
4011 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
4012 CPPUNIT_ASSERT_MESSAGE("E7: no note", !m_pDoc->HasNote(4, 6, destSheet));
4013 CPPUNIT_ASSERT_MESSAGE("F7: a note", m_pDoc->HasNote(5, 6, destSheet));
4014 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
4015 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
4016 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
4017 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
4018 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
4019 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
4020 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
4021 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
4023 // check values of notes
4024 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
4025 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A3"), getNote(4, 1, destSheet));
4026 // F2 has no note
4027 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G2", OUString("Note A1"), getNote(6, 1, destSheet));
4028 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
4029 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("Note B3"), getNote(4, 2, destSheet));
4030 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B4"), getNote(5, 2, destSheet));
4031 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G3", OUString("Note B1"), getNote(6, 2, destSheet));
4032 // D4 has no note
4033 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C3"), getNote(4, 3, destSheet));
4034 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C4"), getNote(5, 3, destSheet));
4035 // G4 has no note
4036 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
4037 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D3"), getNote(4, 4, destSheet));
4038 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D4"), getNote(5, 4, destSheet));
4039 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G5", OUString("Note D1"), getNote(6, 4, destSheet));
4040 if (!bSkipEmpty)
4041 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 5, destSheet));
4042 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F6", OUString("Note E4"), getNote(5, 5, destSheet));
4043 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F7", OUString("Note F4"), getNote(5, 6, destSheet));
4045 // check row 16 on src sheet, refs to copied/cut range
4046 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
4047 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
4048 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
4049 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
4050 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
4051 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
4052 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
4053 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
4054 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
4055 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
4057 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4058 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4059 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4060 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4061 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4062 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4063 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4064 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4065 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4066 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4068 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
4069 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
4070 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
4071 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
4072 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
4073 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
4074 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
4075 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
4076 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
4077 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
4079 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4080 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4081 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4082 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4083 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4084 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4085 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4086 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4087 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4088 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4090 // Existing references to the destination range must not change
4091 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
4092 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
4093 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
4094 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
4095 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
4096 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
4097 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
4098 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
4099 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
4100 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
4101 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
4102 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
4103 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
4104 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
4105 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
4106 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
4107 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
4108 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
4109 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
4110 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
4111 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
4112 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
4113 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
4114 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
4115 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
4116 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
4117 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
4118 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
4119 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
4120 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
4121 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
4122 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
4123 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
4124 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
4125 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
4126 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
4127 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
4128 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
4129 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
4130 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
4131 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
4132 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
4133 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
4134 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
4135 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
4136 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
4137 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
4138 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
4139 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
4141 m_pDoc->DeleteTab(destSheet);
4142 m_pDoc->DeleteTab(srcSheet);
4145 void TestCopyPaste::checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty)
4147 const SCTAB srcSheet = 0;
4148 const SCTAB destSheet = 1;
4151 ┌--- not selected src col C
4154 | D | E | F | G | H | I |
4156 2 | 1 B*| =D2+10 *| R1 *| =C2+C4+60 | =SUMIF(C2:C5;"<4") | 121 |
4157 3 | 2 B*| =D3+20 b | R2 *| | *| 122 | <- filtered row
4158 4 | 3 B*| =G4+30 b*| 5 *| B*| | 123 |
4159 5 | 4 | =D3+40 b*| R4 *| =C2+C4+70 *| =D$3+$B$5+80 *| 124 |
4161 * means note attached
4162 B means background
4163 b means border
4166 const EditTextObject* pEditObj;
4167 // col 2
4168 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4169 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4170 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4171 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4172 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4173 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4174 // col 3, numbers
4175 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4176 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4177 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
4178 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
4179 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 4, destSheet));
4180 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
4181 // col 4, formulas
4182 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4183 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
4184 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
4185 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
4186 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), m_pDoc->GetFormula(4, 2, destSheet));
4187 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
4188 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), m_pDoc->GetFormula(4, 3, destSheet));
4189 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4190 m_pDoc->GetValue(4, 3, destSheet)); // It was 35
4191 CPPUNIT_ASSERT_EQUAL(OUString("=D3+40"), m_pDoc->GetFormula(4, 4, destSheet));
4192 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(4, 4, destSheet));
4193 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
4194 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 5, destSheet));
4195 // col 5, strings are not selected
4196 // col 5, rich text
4197 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4198 pEditObj = m_pDoc->GetEditText(ScAddress(5, 0, destSheet));
4199 CPPUNIT_ASSERT(pEditObj == nullptr);
4200 pEditObj = m_pDoc->GetEditText(ScAddress(5, 1, destSheet));
4201 CPPUNIT_ASSERT(pEditObj);
4202 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4203 pEditObj = m_pDoc->GetEditText(ScAddress(5, 2, destSheet));
4204 CPPUNIT_ASSERT(pEditObj);
4205 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
4206 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 3, destSheet));
4207 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4208 CPPUNIT_ASSERT(pEditObj);
4209 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4210 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
4211 pEditObj = m_pDoc->GetEditText(ScAddress(5, 5, destSheet));
4212 CPPUNIT_ASSERT(pEditObj == nullptr);
4213 // col 6, formulas
4214 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4215 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 0, destSheet));
4216 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+60"), m_pDoc->GetFormula(6, 1, destSheet));
4217 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(6, 1, destSheet)); // It was 64
4218 if (!bSkipEmpty)
4220 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 2, destSheet));
4221 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 3, destSheet));
4223 else
4225 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
4226 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 3, destSheet));
4228 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+70"), m_pDoc->GetFormula(6, 4, destSheet));
4229 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 4, destSheet)); // It was 74
4230 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
4231 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 5, destSheet));
4232 // col 7, formulas
4233 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4234 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
4235 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(C2:C5;\"<4\")"), m_pDoc->GetFormula(7, 1, destSheet));
4236 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(7, 1, destSheet)); // It was 6
4237 if (!bSkipEmpty)
4239 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
4240 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
4242 else
4244 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4245 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
4247 CPPUNIT_ASSERT_EQUAL(1082.0, m_pDoc->GetValue(7, 4, destSheet));
4248 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$B$5+80"), m_pDoc->GetFormula(7, 4, destSheet));
4249 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
4250 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
4251 // col 8, numbers
4252 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
4253 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(8, 1, destSheet));
4254 CPPUNIT_ASSERT_EQUAL(122.0, m_pDoc->GetValue(8, 2, destSheet));
4255 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 3, destSheet));
4256 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(8, 4, destSheet));
4257 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
4258 // col 9, col repetition is not supported for multi range copy/paste
4259 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
4260 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
4261 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
4262 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
4263 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
4264 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
4266 // check patterns
4267 const SfxPoolItem* pItem = nullptr;
4268 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4269 CPPUNIT_ASSERT(pItem);
4270 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4271 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4272 CPPUNIT_ASSERT(pItem);
4273 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4274 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4275 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4276 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4277 CPPUNIT_ASSERT(!pItem);
4278 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4279 CPPUNIT_ASSERT(!pItem);
4280 m_pDoc->GetPattern(ScAddress(6, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4281 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4282 if (!bSkipEmpty)
4283 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4285 // check border, left and right borders were transformed to top and bottom borders
4286 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
4287 CPPUNIT_ASSERT(pItem);
4288 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4289 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4290 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4291 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4292 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4293 CPPUNIT_ASSERT(pItem);
4294 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4295 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4296 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4297 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4298 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
4299 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4300 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4301 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4302 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4303 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
4304 CPPUNIT_ASSERT(pItem);
4305 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4306 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4307 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4308 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4309 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
4310 CPPUNIT_ASSERT(pItem);
4311 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4312 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4313 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4314 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4316 // check notes after transposed copy/paste
4317 // check presence of notes
4318 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4319 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4320 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4321 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4322 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4323 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4324 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
4325 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4326 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4327 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4328 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4329 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4330 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4331 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
4332 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4333 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4334 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
4335 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4336 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, destSheet));
4337 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
4338 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
4339 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4340 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
4341 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4342 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4343 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(6, 3, destSheet));
4344 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
4345 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
4346 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4347 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4348 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 4, destSheet));
4349 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
4350 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
4351 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 4, destSheet));
4352 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
4353 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
4354 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
4355 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
4356 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
4357 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
4358 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
4359 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
4361 // check values of notes
4362 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4363 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
4364 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
4365 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
4366 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
4367 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(5, 1, destSheet));
4368 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(5, 2, destSheet));
4369 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 3, destSheet));
4370 if (!bSkipEmpty)
4371 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(6, 3, destSheet));
4372 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 4, destSheet));
4373 if (!bSkipEmpty)
4374 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(7, 2, destSheet));
4375 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(7, 4, destSheet));
4377 // check row 16 on src sheet, refs to copied/cut range
4378 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
4379 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
4380 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
4381 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
4382 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
4383 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
4384 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
4385 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
4386 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
4387 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
4389 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4390 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4391 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4392 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4393 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4394 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4395 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4396 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4397 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4398 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4400 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
4401 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
4402 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
4403 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
4404 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
4405 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
4406 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
4407 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
4408 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
4409 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
4411 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4412 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4413 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4414 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4415 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4416 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4417 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4418 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4419 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4420 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4422 // Existing references to the destination range must not change
4423 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
4424 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
4425 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
4426 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
4427 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
4428 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
4429 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
4430 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
4431 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
4432 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
4433 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
4434 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
4435 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
4436 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
4437 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
4438 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
4439 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
4440 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
4441 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
4442 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
4443 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
4444 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
4445 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
4446 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
4447 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
4448 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
4449 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
4450 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
4451 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
4452 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
4453 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
4454 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
4455 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
4456 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
4457 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
4458 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
4459 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
4460 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
4461 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
4462 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
4463 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
4464 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
4465 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
4466 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
4467 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
4468 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
4469 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
4470 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
4471 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
4473 m_pDoc->DeleteTab(destSheet);
4474 m_pDoc->DeleteTab(srcSheet);
4477 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty)
4479 const SCTAB srcSheet = 0;
4480 const SCTAB destSheet = 1;
4483 ┌--- not selected src col C
4486 | D | E | F | G | H | I |
4488 2 | 1 B*| =D2+10 *| R1 *| =C2+C4+60 | =SUMIF(C2:C5;"<4") | 121 |
4489 3 | 3 B*| =G4+30 b*| 5 *| B*| | 123 |
4490 4 | 4 | =D2+40 b*| R4 *| =C1+C3+70 *| =D$3+$B$5+80 *| 124 |
4492 * means note attached
4493 B means background
4494 b means border
4497 const EditTextObject* pEditObj;
4498 // col 2
4499 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4500 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4501 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4502 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4503 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4504 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4505 // col 3, numbers
4506 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4507 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4508 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
4509 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 3, destSheet));
4510 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 4, destSheet));
4511 // col 4, formulas
4512 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4513 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 0, destSheet));
4514 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
4515 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
4516 // references over selection gaps are not adjusted
4517 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), m_pDoc->GetFormula(4, 2, destSheet));
4518 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4519 m_pDoc->GetValue(4, 2, destSheet)); // It was 35
4520 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), m_pDoc->GetFormula(4, 3, destSheet));
4521 // was originally 42, not adjusted by filtering
4522 CPPUNIT_ASSERT_EQUAL(41.0, m_pDoc->GetValue(4, 3, destSheet));
4523 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
4524 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(4, 4, destSheet));
4525 // col 5, strings are not selected
4526 // col 5, rich text
4527 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4528 pEditObj = m_pDoc->GetEditText(ScAddress(5, 0, destSheet));
4529 CPPUNIT_ASSERT(pEditObj == nullptr);
4530 pEditObj = m_pDoc->GetEditText(ScAddress(5, 1, destSheet));
4531 CPPUNIT_ASSERT(pEditObj);
4532 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4533 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 2, destSheet));
4534 pEditObj = m_pDoc->GetEditText(ScAddress(5, 3, destSheet));
4535 CPPUNIT_ASSERT(pEditObj);
4536 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4537 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 4, destSheet));
4538 pEditObj = m_pDoc->GetEditText(ScAddress(5, 4, destSheet));
4539 CPPUNIT_ASSERT(pEditObj == nullptr);
4540 // col 6, formulas
4541 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4542 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(6, 0, destSheet));
4543 CPPUNIT_ASSERT_EQUAL(OUString("=C2+C4+60"), m_pDoc->GetFormula(6, 1, destSheet));
4544 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(6, 1, destSheet)); // It was 64
4545 if (!bSkipEmpty)
4546 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(6, 2, destSheet));
4547 else
4548 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
4549 CPPUNIT_ASSERT_EQUAL(OUString("=C1+C3+70"), m_pDoc->GetFormula(6, 3, destSheet));
4550 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 3, destSheet)); // It was 74
4551 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 4, destSheet));
4552 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(6, 4, destSheet));
4553 // col 7, formulas
4554 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4555 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(7, 0, destSheet));
4556 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(C2:C5;\"<4\")"), m_pDoc->GetFormula(7, 1, destSheet));
4557 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(7, 1, destSheet)); // It was 6
4558 if (!bSkipEmpty)
4559 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
4560 else
4561 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4562 CPPUNIT_ASSERT_EQUAL(1083.0, m_pDoc->GetValue(7, 3, destSheet));
4563 CPPUNIT_ASSERT_EQUAL(OUString("=D$3+$B$5+80"), m_pDoc->GetFormula(7, 3, destSheet));
4564 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
4565 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(7, 4, destSheet));
4566 // col 8, numbers
4567 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
4568 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(8, 1, destSheet));
4569 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 2, destSheet));
4570 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(8, 3, destSheet));
4571 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 4, destSheet));
4572 // col 9, col repetition is not supported for multi range copy/paste
4573 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
4574 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
4575 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
4576 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
4577 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
4578 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
4580 // check patterns
4581 const SfxPoolItem* pItem = nullptr;
4582 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4583 CPPUNIT_ASSERT(pItem);
4584 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4585 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4586 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4587 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4588 CPPUNIT_ASSERT(!pItem);
4589 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4590 CPPUNIT_ASSERT(!pItem);
4591 m_pDoc->GetPattern(ScAddress(6, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4592 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4593 if (!bSkipEmpty)
4594 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4596 // check border, left and right borders were transformed to top and bottom borders
4597 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
4598 CPPUNIT_ASSERT(pItem);
4599 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4600 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4601 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4602 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4603 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4604 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4605 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4606 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4607 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4608 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
4609 CPPUNIT_ASSERT(pItem);
4610 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4611 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4612 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4613 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
4614 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
4615 CPPUNIT_ASSERT(pItem);
4616 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4617 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4618 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4619 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4621 // check notes after transposed copy/paste
4622 // check presence of notes
4623 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4624 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4625 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4626 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4627 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4628 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4629 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
4630 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4631 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4632 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4633 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4634 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4635 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4636 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
4637 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4638 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4639 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
4640 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4641 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(6, 2, destSheet));
4642 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
4643 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
4644 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4645 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
4646 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4647 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4648 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
4649 CPPUNIT_ASSERT(m_pDoc->HasNote(7, 3, destSheet));
4650 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
4651 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4652 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4653 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
4654 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
4655 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
4656 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
4657 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
4659 // check values of notes
4660 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4661 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
4662 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
4663 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
4664 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(5, 1, destSheet));
4665 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 2, destSheet));
4666 if (!bSkipEmpty)
4667 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(6, 2, destSheet));
4668 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 3, destSheet));
4669 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(7, 3, destSheet));
4671 // check row 16 on src sheet, refs to copied/cut range
4672 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
4673 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
4674 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
4675 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
4676 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
4677 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
4678 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
4679 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
4680 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
4681 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
4683 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
4684 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
4685 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
4686 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
4687 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
4688 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
4689 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
4690 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
4691 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
4692 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
4694 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
4695 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
4696 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
4697 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
4698 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
4699 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
4700 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
4701 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
4702 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
4703 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
4705 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
4706 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
4707 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
4708 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
4709 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
4710 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
4711 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
4712 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
4713 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
4714 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
4716 // Existing references to the destination range must not change
4717 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
4718 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
4719 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
4720 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
4721 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
4722 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
4723 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
4724 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
4725 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
4726 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
4727 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
4728 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
4729 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
4730 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
4731 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
4732 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
4733 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
4734 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
4735 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
4736 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
4737 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
4738 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
4739 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
4740 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
4741 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
4742 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
4743 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
4744 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
4745 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
4746 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
4747 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
4748 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
4749 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
4750 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
4751 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
4752 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
4753 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
4754 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
4755 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
4756 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
4757 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
4758 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
4759 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
4760 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
4761 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
4762 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
4763 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
4764 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
4765 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
4767 m_pDoc->DeleteTab(destSheet);
4768 m_pDoc->DeleteTab(srcSheet);
4771 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty)
4773 const SCTAB srcSheet = 0;
4774 const SCTAB destSheet = 1;
4777 | D | E | F | G |
4779 2 | 1 B*| 2 B*| 3 B*| 4 |
4780 3 | =D2+10 *| =E2+20 b | =F5+30 b*| =E2+40 b*|
4781 4 | R1 *| R2 *| 5 *| R4 *|
4782 5 | =D1+F1+60 | | B*| =D1+F1+70 *|
4783 6 | =SUMIF(D1:G1;"<4") | *| | =C$3+$B$5+80 *|
4784 7 | 121 | 122 | 123 | 124 |
4786 * means note attached
4787 B means background
4788 b means border
4791 // check cell content after transposed copy/paste of filtered data
4792 // Col C and G are checked to be empty
4793 const EditTextObject* pEditObj;
4794 // row 0
4795 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
4796 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
4797 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
4798 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
4799 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
4800 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
4801 // row 1, numbers
4802 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
4803 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
4804 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(4, 1, destSheet));
4805 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(5, 1, destSheet));
4806 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(6, 1, destSheet));
4807 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 1, destSheet));
4808 // row 2, formulas
4809 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
4810 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
4811 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 2, destSheet));
4812 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(3, 2, destSheet));
4813 CPPUNIT_ASSERT_EQUAL(OUString("=E2+20"), m_pDoc->GetFormula(4, 2, destSheet));
4814 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
4815 CPPUNIT_ASSERT_EQUAL(OUString("=F5+30"), m_pDoc->GetFormula(5, 2, destSheet));
4816 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
4817 m_pDoc->GetValue(5, 2, destSheet)); // It was 35
4818 CPPUNIT_ASSERT_EQUAL(OUString("=E2+40"), m_pDoc->GetFormula(6, 2, destSheet));
4819 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(6, 2, destSheet));
4820 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
4821 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
4822 // row 3, strings was not selected in multi range selection
4823 // row 3, rich text
4824 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
4825 pEditObj = m_pDoc->GetEditText(ScAddress(2, 3, destSheet));
4826 CPPUNIT_ASSERT(pEditObj == nullptr);
4827 pEditObj = m_pDoc->GetEditText(ScAddress(3, 3, destSheet));
4828 CPPUNIT_ASSERT(pEditObj);
4829 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
4830 pEditObj = m_pDoc->GetEditText(ScAddress(4, 3, destSheet));
4831 CPPUNIT_ASSERT(pEditObj);
4832 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
4833 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(5, 3, destSheet));
4834 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
4835 CPPUNIT_ASSERT(pEditObj);
4836 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
4837 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
4838 pEditObj = m_pDoc->GetEditText(ScAddress(7, 3, destSheet));
4839 CPPUNIT_ASSERT(pEditObj == nullptr);
4840 // row 4, formulas
4841 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
4842 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 4, destSheet));
4843 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+60"), m_pDoc->GetFormula(3, 4, destSheet));
4844 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(3, 4, destSheet)); // It was 64
4845 if (!bSkipEmpty)
4847 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString(), m_pDoc->GetString(4, 4, destSheet));
4848 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString(), m_pDoc->GetString(5, 4, destSheet));
4850 else
4852 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
4853 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 4, destSheet));
4855 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+70"), m_pDoc->GetFormula(6, 4, destSheet));
4856 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(6, 4, destSheet)); // It was 74
4857 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
4858 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 4, destSheet));
4859 // row 5, formulas
4860 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
4861 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
4862 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D1:G1;\"<4\")"), m_pDoc->GetFormula(3, 5, destSheet));
4863 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(3, 5, destSheet)); // It was 6
4864 if (!bSkipEmpty)
4866 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
4867 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
4869 else
4871 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
4872 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
4875 CPPUNIT_ASSERT_EQUAL(OUString("=C$3+$B$5+80"), m_pDoc->GetFormula(6, 5, destSheet));
4876 CPPUNIT_ASSERT_EQUAL(2080.0, m_pDoc->GetValue(6, 5, destSheet));
4877 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
4878 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
4879 // row 6, numbers
4880 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
4881 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(3, 6, destSheet));
4882 CPPUNIT_ASSERT_EQUAL(122.0, m_pDoc->GetValue(4, 6, destSheet));
4883 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(5, 6, destSheet));
4884 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(6, 6, destSheet));
4885 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
4886 // row 7, not selected
4887 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
4888 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
4889 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
4890 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
4891 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
4892 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
4894 // check patterns
4895 const SfxPoolItem* pItem = nullptr;
4896 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4897 CPPUNIT_ASSERT(pItem);
4898 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4899 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4900 CPPUNIT_ASSERT(pItem);
4901 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4902 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4903 CPPUNIT_ASSERT(pItem);
4904 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4905 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4906 CPPUNIT_ASSERT(!pItem);
4907 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4908 CPPUNIT_ASSERT(!pItem);
4909 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
4910 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
4911 // std::cout << "bSkipEmpty: " << bSkipEmpty << ", pItem == nullptr: " << (pItem == nullptr) << std::endl;
4912 if (!bSkipEmpty)
4913 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
4915 // check border, left and right borders were transformed to top and bottom borders
4916 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
4917 CPPUNIT_ASSERT(pItem);
4918 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4919 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4920 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4921 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4923 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
4924 CPPUNIT_ASSERT(pItem);
4925 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
4926 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
4927 CPPUNIT_ASSERT(pItem);
4928 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
4929 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4930 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4931 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4932 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
4933 CPPUNIT_ASSERT(pItem);
4934 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
4935 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4936 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4937 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4938 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
4939 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
4940 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4941 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4942 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4943 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
4944 CPPUNIT_ASSERT(pItem);
4945 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
4946 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
4947 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
4948 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
4950 // check notes after transposed copy/paste
4951 // check presence of notes
4952 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
4953 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
4954 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
4955 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
4956 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
4957 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
4958 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
4959 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
4960 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
4961 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 1, destSheet));
4962 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
4963 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
4964 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
4965 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
4966 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
4967 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
4968 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
4969 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
4970 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
4971 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
4972 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
4973 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
4974 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
4975 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
4976 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
4977 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
4978 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
4979 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 4, destSheet));
4980 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 4, destSheet));
4981 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
4982 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
4983 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
4984 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
4985 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
4986 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 5, destSheet));
4987 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
4988 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, destSheet));
4989 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 6, destSheet));
4990 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, destSheet));
4991 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, destSheet));
4992 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, destSheet));
4993 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 6, destSheet));
4995 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
4996 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(4, 1, destSheet));
4997 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(5, 1, destSheet));
4998 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(3, 2, destSheet));
4999 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(5, 2, destSheet));
5000 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(3, 3, destSheet));
5001 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(4, 3, destSheet));
5002 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(5, 3, destSheet));
5003 if (!bSkipEmpty)
5004 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 4, destSheet));
5005 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(6, 4, destSheet));
5006 if (!bSkipEmpty)
5007 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(4, 5, destSheet));
5008 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(6, 5, destSheet));
5010 // check row 16 on src sheet, refs to copied/cut range
5011 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
5012 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
5013 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
5014 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
5015 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
5016 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
5017 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
5018 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
5019 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
5020 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
5022 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5023 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5024 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5025 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5026 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5027 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5028 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5029 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5030 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5031 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5033 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
5034 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
5035 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
5036 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
5037 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
5038 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
5039 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
5040 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
5041 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
5042 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
5044 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5045 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5046 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5047 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5048 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5049 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5050 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5051 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5052 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5053 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5055 // Existing references to the destination range must not change
5056 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
5057 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
5058 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
5059 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
5060 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
5061 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
5062 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
5063 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
5064 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
5065 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
5066 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
5067 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
5068 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
5069 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
5070 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
5071 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
5072 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
5073 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
5074 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
5075 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
5076 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
5077 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
5078 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
5079 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
5080 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
5081 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
5082 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
5083 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
5084 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
5085 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
5086 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
5087 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
5088 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
5089 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
5090 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
5091 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
5092 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
5093 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
5094 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
5095 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
5096 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
5097 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
5098 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
5099 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
5100 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
5101 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
5102 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
5103 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
5104 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
5106 m_pDoc->DeleteTab(destSheet);
5107 m_pDoc->DeleteTab(srcSheet);
5110 void TestCopyPaste::checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty)
5112 const SCTAB srcSheet = 0;
5113 const SCTAB destSheet = 1;
5116 ┌--- filtered src row 2
5119 | D | E | F |
5121 2 | 1 B*| 3 B*| 4 |
5122 3 | =D2+10 *| =E5+30 b*| =D2+40 b*|
5123 <- not copied col C
5124 4 | R1 *| 5 *| R4 *|
5125 5 | =D1+F1+60 | B*| =C1+E1+70 *|
5126 6 | =SUMIF(D1:G1;"<4") | | =B$3+$B$5+80 *|
5127 7 | 121 | 123 | 124 |
5129 * means note attached
5130 B means background
5131 b means border
5134 // check cell content after transposed copy/paste of filtered data
5135 // Col C and G are checked to be empty
5136 const EditTextObject* pEditObj;
5137 // row 0
5138 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5139 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5140 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5141 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5142 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5143 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5144 // row 1, numbers
5145 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5146 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5147 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(4, 1, destSheet));
5148 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(5, 1, destSheet));
5149 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 1, destSheet));
5150 // row 2, formulas
5151 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5152 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5153 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 2, destSheet));
5154 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(3, 2, destSheet));
5155 CPPUNIT_ASSERT_EQUAL(OUString("=E5+30"), m_pDoc->GetFormula(4, 2, destSheet));
5156 CPPUNIT_ASSERT_EQUAL(bSkipEmpty ? 1030.0 : 30.0,
5157 m_pDoc->GetValue(4, 2, destSheet)); // It was 35
5158 CPPUNIT_ASSERT_EQUAL(OUString("=D2+40"), m_pDoc->GetFormula(5, 2, destSheet));
5159 CPPUNIT_ASSERT_EQUAL(
5160 41.0, m_pDoc->GetValue(5, 2, destSheet)); // was originally 42, not adjusted by filtering
5161 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 2, destSheet));
5162 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 2, destSheet));
5163 // row 3, strings was not selected in multi range selection
5164 // row 3, rich text
5165 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5166 pEditObj = m_pDoc->GetEditText(ScAddress(2, 3, destSheet));
5167 CPPUNIT_ASSERT(pEditObj == nullptr);
5168 pEditObj = m_pDoc->GetEditText(ScAddress(3, 3, destSheet));
5169 CPPUNIT_ASSERT(pEditObj);
5170 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5171 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 3, destSheet));
5172 pEditObj = m_pDoc->GetEditText(ScAddress(5, 3, destSheet));
5173 CPPUNIT_ASSERT(pEditObj);
5174 CPPUNIT_ASSERT_EQUAL(OUString("R4"), pEditObj->GetText(0));
5175 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 3, destSheet));
5176 pEditObj = m_pDoc->GetEditText(ScAddress(6, 3, destSheet));
5177 CPPUNIT_ASSERT(pEditObj == nullptr);
5178 // row 4, formulas
5179 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5180 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 4, destSheet));
5181 // formulas over filtered rows are not adjusted
5182 CPPUNIT_ASSERT_EQUAL(OUString("=D1+F1+60"), m_pDoc->GetFormula(3, 4, destSheet));
5183 CPPUNIT_ASSERT_EQUAL(2060.0, m_pDoc->GetValue(3, 4, destSheet)); // It was 64
5184 if (!bSkipEmpty)
5185 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(4, 4, destSheet));
5186 else
5187 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 4, destSheet));
5188 CPPUNIT_ASSERT_EQUAL(OUString("=C1+E1+70"), m_pDoc->GetFormula(5, 4, destSheet));
5189 CPPUNIT_ASSERT_EQUAL(2070.0, m_pDoc->GetValue(5, 4, destSheet)); // It was 74
5190 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 4, destSheet));
5191 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 4, destSheet));
5192 // row 5, formulas
5193 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5194 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
5195 // formulas over filtered rows are not adjusted
5196 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D1:G1;\"<4\")"), m_pDoc->GetFormula(3, 5, destSheet));
5197 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(3, 5, destSheet)); // It was 6
5198 if (!bSkipEmpty)
5199 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
5200 else
5201 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
5202 CPPUNIT_ASSERT_EQUAL(OUString("=B$3+$B$5+80"), m_pDoc->GetFormula(5, 5, destSheet));
5203 CPPUNIT_ASSERT_EQUAL(2080.0, m_pDoc->GetValue(5, 5, destSheet));
5204 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
5205 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(6, 5, destSheet));
5206 // row 6, numbers
5207 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
5208 CPPUNIT_ASSERT_EQUAL(121.0, m_pDoc->GetValue(3, 6, destSheet));
5209 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(4, 6, destSheet));
5210 CPPUNIT_ASSERT_EQUAL(124.0, m_pDoc->GetValue(5, 6, destSheet));
5211 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 6, destSheet));
5212 // row 7, not copied
5213 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5214 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5215 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5216 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5217 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5218 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5219 // row 8, not copied
5220 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
5221 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
5222 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
5223 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
5224 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
5225 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
5227 // check patterns
5228 const SfxPoolItem* pItem = nullptr;
5229 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5230 CPPUNIT_ASSERT(pItem);
5231 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5232 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5233 CPPUNIT_ASSERT(pItem);
5234 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5235 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5236 CPPUNIT_ASSERT(!pItem);
5237 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5238 CPPUNIT_ASSERT(!pItem);
5239 m_pDoc->GetPattern(ScAddress(4, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5240 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5241 if (!bSkipEmpty)
5242 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5244 // check border, left and right borders were transformed to top and bottom borders
5245 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
5246 CPPUNIT_ASSERT(pItem);
5247 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5248 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5249 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5250 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5252 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
5253 CPPUNIT_ASSERT(pItem);
5254 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5256 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5257 CPPUNIT_ASSERT(pItem);
5258 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5259 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5260 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5261 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5262 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
5263 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5264 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5265 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5266 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5267 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
5268 CPPUNIT_ASSERT(pItem);
5269 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5270 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5271 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5272 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5274 // check notes after transposed copy/paste
5275 // check presence of notes
5276 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5277 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5278 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5279 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5280 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5281 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5282 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5283 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5284 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
5285 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 1, destSheet));
5286 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5287 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5288 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
5289 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5290 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 2, destSheet));
5291 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5292 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5293 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5294 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5295 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 3, destSheet));
5296 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5297 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5298 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 4, destSheet));
5299 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
5300 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
5301 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5302 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5303 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
5304 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 5, destSheet));
5305 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
5306 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 6, destSheet));
5307 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 6, destSheet));
5308 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 6, destSheet));
5309 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 6, destSheet));
5310 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 6, destSheet));
5312 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5313 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(4, 1, destSheet));
5314 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(3, 2, destSheet));
5315 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
5316 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(3, 3, destSheet));
5317 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(4, 3, destSheet));
5318 if (!bSkipEmpty)
5319 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 4, destSheet));
5320 CPPUNIT_ASSERT_EQUAL(OUString("Note E4"), getNote(5, 4, destSheet));
5321 CPPUNIT_ASSERT_EQUAL(OUString("Note F4"), getNote(5, 5, destSheet));
5323 // check row 16 on src sheet, refs to copied/cut range
5324 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
5325 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
5326 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
5327 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
5328 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
5329 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
5330 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
5331 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
5332 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
5333 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
5335 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5336 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5337 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5338 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5339 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5340 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5341 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5342 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5343 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5344 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5346 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
5347 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
5348 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
5349 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
5350 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
5351 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
5352 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
5353 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
5354 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
5355 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
5357 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5358 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5359 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5360 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5361 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5362 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5363 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5364 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5365 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5366 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5368 // Existing references to the destination range must not change
5369 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
5370 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
5371 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
5372 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
5373 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
5374 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
5375 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
5376 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
5377 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
5378 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
5379 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
5380 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
5381 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
5382 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
5383 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
5384 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
5385 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
5386 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
5387 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
5388 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
5389 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
5390 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
5391 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
5392 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
5393 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
5394 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
5395 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
5396 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
5397 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
5398 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
5399 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
5400 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
5401 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
5402 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
5403 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
5404 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
5405 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
5406 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
5407 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
5408 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
5409 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
5410 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
5411 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
5412 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
5413 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
5414 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
5415 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
5416 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
5417 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
5419 m_pDoc->DeleteTab(destSheet);
5420 m_pDoc->DeleteTab(srcSheet);
5423 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty)
5425 const SCTAB srcSheet = 0;
5426 const SCTAB destSheet = 1;
5429 | D | E | F | G | H | I |
5431 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
5432 3 | 2 B*| =D3+20 b | b *| R2 *| | *| <- filtered row
5433 4 | 3 B*| =G4+30 b*| c *| 5 *| B*| |
5434 <- not selected row
5435 5 | 6 | q | r bB*| s bB| t | u |
5436 6 | -11 | -12 | -13 | -14 | -15 | -16 |
5438 * means note attached
5439 B means background
5440 b means border
5443 const EditTextObject* pEditObj;
5444 // col 2
5445 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5446 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5447 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
5448 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5449 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5450 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5451 // col 3, numbers
5452 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5453 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5454 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, destSheet));
5455 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 3, destSheet));
5456 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(3, 4, destSheet));
5457 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(3, 5, destSheet));
5458 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 6, destSheet));
5459 // col 4, formulas
5460 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5461 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
5462 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
5463 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
5464 CPPUNIT_ASSERT_EQUAL(OUString("=D3+20"), m_pDoc->GetFormula(4, 2, destSheet));
5465 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(4, 2, destSheet));
5466 CPPUNIT_ASSERT_EQUAL(OUString("=G4+30"), m_pDoc->GetFormula(4, 3, destSheet));
5467 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 3, destSheet));
5468 CPPUNIT_ASSERT_EQUAL(OUString("q"), m_pDoc->GetString(4, 4, destSheet));
5469 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(4, 5, destSheet));
5470 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
5471 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 6, destSheet));
5472 // col 5, strings
5473 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5474 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
5475 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
5476 CPPUNIT_ASSERT_EQUAL(OUString("b"), m_pDoc->GetString(5, 2, destSheet));
5477 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 3, destSheet));
5478 CPPUNIT_ASSERT_EQUAL(OUString("r"), m_pDoc->GetString(5, 4, destSheet));
5479 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(5, 5, destSheet));
5480 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
5481 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 6, destSheet));
5482 // col 6, rich text
5483 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5484 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
5485 CPPUNIT_ASSERT(pEditObj == nullptr);
5486 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
5487 CPPUNIT_ASSERT(pEditObj);
5488 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5489 pEditObj = m_pDoc->GetEditText(ScAddress(6, 2, destSheet));
5490 CPPUNIT_ASSERT(pEditObj);
5491 CPPUNIT_ASSERT_EQUAL(OUString("R2"), pEditObj->GetText(0));
5492 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 3, destSheet));
5493 CPPUNIT_ASSERT_EQUAL(OUString("s"), m_pDoc->GetString(6, 4, destSheet));
5494 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 5, destSheet));
5495 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 6, destSheet));
5496 pEditObj = m_pDoc->GetEditText(ScAddress(6, 6, destSheet));
5497 CPPUNIT_ASSERT(pEditObj == nullptr);
5498 // col 7, formulas
5499 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5500 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5501 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
5502 CPPUNIT_ASSERT_EQUAL(64.0, m_pDoc->GetValue(7, 1, destSheet));
5503 if (!bSkipEmpty)
5505 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
5506 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 3, destSheet));
5508 else
5510 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
5511 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
5513 CPPUNIT_ASSERT_EQUAL(OUString("t"), m_pDoc->GetString(7, 4, destSheet));
5514 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 5, destSheet));
5515 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
5516 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
5517 // col 8, formulas
5518 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
5519 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5520 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
5521 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
5522 if (!bSkipEmpty)
5524 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
5525 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 3, destSheet));
5527 else
5529 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
5530 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
5532 CPPUNIT_ASSERT_EQUAL(OUString("u"), m_pDoc->GetString(8, 4, destSheet));
5533 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(8, 5, destSheet));
5534 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 6, destSheet));
5535 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 6, destSheet));
5536 // col 9
5537 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
5538 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
5539 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
5540 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
5541 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
5542 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
5544 // check patterns
5545 const SfxPoolItem* pItem = nullptr;
5546 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5547 CPPUNIT_ASSERT(pItem);
5548 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5549 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5550 CPPUNIT_ASSERT(pItem);
5551 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5552 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5553 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5554 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5555 CPPUNIT_ASSERT(!pItem);
5556 m_pDoc->GetPattern(ScAddress(3, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5557 CPPUNIT_ASSERT(!pItem);
5558 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5559 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5560 if (!bSkipEmpty)
5561 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5563 m_pDoc->GetPattern(ScAddress(4, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5564 CPPUNIT_ASSERT(!pItem);
5565 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5566 CPPUNIT_ASSERT(pItem);
5567 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5568 m_pDoc->GetPattern(ScAddress(6, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5569 CPPUNIT_ASSERT(pItem);
5570 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5571 m_pDoc->GetPattern(ScAddress(7, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5572 CPPUNIT_ASSERT(!pItem);
5574 // check border, left and right borders were transformed to top and bottom borders
5575 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
5576 CPPUNIT_ASSERT(pItem);
5577 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5578 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5579 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5580 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5581 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5582 CPPUNIT_ASSERT(pItem);
5583 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5584 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5585 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5586 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5587 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
5588 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5589 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5590 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5591 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5592 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5593 CPPUNIT_ASSERT(pItem);
5594 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5595 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5596 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5597 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5598 pItem = m_pDoc->GetAttr(ScAddress(4, 5, destSheet), ATTR_BORDER);
5599 CPPUNIT_ASSERT(pItem);
5600 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5601 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5602 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5603 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5605 pItem = m_pDoc->GetAttr(ScAddress(3, 4, destSheet), ATTR_BORDER);
5606 CPPUNIT_ASSERT(pItem);
5607 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5608 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5609 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5610 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5611 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5612 CPPUNIT_ASSERT(pItem);
5613 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5614 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5615 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5616 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5617 pItem = m_pDoc->GetAttr(ScAddress(5, 4, destSheet), ATTR_BORDER);
5618 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5619 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5620 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5621 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5622 pItem = m_pDoc->GetAttr(ScAddress(6, 4, destSheet), ATTR_BORDER);
5623 CPPUNIT_ASSERT(pItem);
5624 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5625 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5626 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5627 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5628 pItem = m_pDoc->GetAttr(ScAddress(7, 4, destSheet), ATTR_BORDER);
5629 CPPUNIT_ASSERT(pItem);
5630 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5631 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5632 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5633 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5635 // check notes after transposed copy/paste
5636 // check presence of notes
5637 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5638 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5639 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5640 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5641 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5642 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
5643 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
5644 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
5645 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5646 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5647 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5648 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
5649 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
5650 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
5651 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
5652 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
5653 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
5654 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
5655 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 2, destSheet));
5656 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
5657 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
5658 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 2, destSheet));
5659 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(8, 2, destSheet));
5660 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
5661 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
5662 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 3, destSheet));
5663 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 3, destSheet));
5664 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
5665 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 3, destSheet));
5666 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 3, destSheet));
5667 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
5668 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
5669 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
5670 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
5671 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
5672 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 4, destSheet));
5673 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
5674 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
5675 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
5676 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
5677 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 5, destSheet));
5678 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 5, destSheet));
5679 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 5, destSheet));
5680 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 5, destSheet));
5681 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 5, destSheet));
5682 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 5, destSheet));
5683 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 5, destSheet));
5684 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 5, destSheet));
5686 // check values of notes
5687 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
5688 CPPUNIT_ASSERT_EQUAL(OUString("Note A2"), getNote(3, 2, destSheet));
5689 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 3, destSheet));
5690 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
5691 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 3, destSheet));
5692 CPPUNIT_ASSERT_EQUAL(OUString("Note C2"), getNote(5, 2, destSheet));
5693 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 3, destSheet));
5694 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
5695 CPPUNIT_ASSERT_EQUAL(OUString("Note D2"), getNote(6, 2, destSheet));
5696 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 3, destSheet));
5697 if (!bSkipEmpty)
5698 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 3, destSheet));
5699 if (!bSkipEmpty)
5700 CPPUNIT_ASSERT_EQUAL(OUString("Note F2"), getNote(8, 2, destSheet));
5701 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 4, destSheet));
5703 // check row 16 on src sheet, refs to copied/cut range
5704 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
5705 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
5706 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
5707 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
5708 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
5709 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
5710 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
5711 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
5712 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
5713 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
5715 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
5716 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
5717 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
5718 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
5719 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
5720 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
5721 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
5722 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
5723 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
5724 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
5726 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
5727 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
5728 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
5729 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
5730 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
5731 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
5732 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
5733 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
5734 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
5735 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
5737 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
5738 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
5739 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
5740 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
5741 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
5742 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
5743 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
5744 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
5745 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
5746 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
5748 // Existing references to the destination range must not change
5749 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
5750 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
5751 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
5752 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
5753 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
5754 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
5755 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
5756 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
5757 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
5758 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
5759 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
5760 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
5761 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
5762 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
5763 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
5764 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
5765 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
5766 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
5767 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
5768 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
5769 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
5770 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
5771 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
5772 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
5773 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
5774 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
5775 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
5776 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
5777 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
5778 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
5779 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
5780 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
5781 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
5782 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
5783 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
5784 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
5785 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
5786 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
5787 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
5788 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
5789 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
5790 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
5791 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
5792 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
5793 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
5794 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
5795 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
5796 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
5797 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
5799 m_pDoc->DeleteTab(destSheet);
5800 m_pDoc->DeleteTab(srcSheet);
5803 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty)
5805 const SCTAB srcSheet = 0;
5806 const SCTAB destSheet = 1;
5809 | D | E | F | G | H | I |
5811 2 | 1 B*| =D2+10 *| a | R1 *| =D2+D4+60 | =SUMIF(D2:D5;"<4") |
5812 3 | 3 B*| =G3+30 b*| c *| 5 *| B*| |
5813 <- not selected
5814 4 | 6 | q | r | s | t | u |
5815 5 | -11 | -12 |-13 | -14 | -15 | -16 |
5817 * means note attached
5818 B means background
5819 b means border
5822 const EditTextObject* pEditObj;
5823 // col 2
5824 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
5825 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 1, destSheet));
5826 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
5827 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
5828 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
5829 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
5830 // col 3, numbers
5831 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
5832 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(3, 1, destSheet));
5833 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 2, destSheet));
5834 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(3, 3, destSheet));
5835 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(3, 4, destSheet));
5836 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 5, destSheet));
5837 // col 4, formulas
5838 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
5839 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 0, destSheet));
5840 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(4, 1, destSheet));
5841 CPPUNIT_ASSERT_EQUAL(OUString("=D2+10"), m_pDoc->GetFormula(4, 1, destSheet));
5842 CPPUNIT_ASSERT_EQUAL(OUString("=G3+30"), m_pDoc->GetFormula(4, 2, destSheet));
5843 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 2, destSheet));
5844 CPPUNIT_ASSERT_EQUAL(OUString("q"), m_pDoc->GetString(4, 3, destSheet));
5845 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(4, 4, destSheet));
5846 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
5847 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(4, 5, destSheet));
5848 // col 5, strings
5849 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
5850 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 0, destSheet));
5851 CPPUNIT_ASSERT_EQUAL(OUString("a"), m_pDoc->GetString(5, 1, destSheet));
5852 CPPUNIT_ASSERT_EQUAL(OUString("c"), m_pDoc->GetString(5, 2, destSheet));
5853 CPPUNIT_ASSERT_EQUAL(OUString("r"), m_pDoc->GetString(5, 3, destSheet));
5854 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(5, 4, destSheet));
5855 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
5856 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(5, 5, destSheet));
5857 // col 6, rich text
5858 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
5859 pEditObj = m_pDoc->GetEditText(ScAddress(6, 0, destSheet));
5860 CPPUNIT_ASSERT(pEditObj == nullptr);
5861 pEditObj = m_pDoc->GetEditText(ScAddress(6, 1, destSheet));
5862 CPPUNIT_ASSERT(pEditObj);
5863 CPPUNIT_ASSERT_EQUAL(OUString("R1"), pEditObj->GetText(0));
5864 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(6, 2, destSheet));
5865 CPPUNIT_ASSERT_EQUAL(OUString("s"), m_pDoc->GetString(6, 3, destSheet));
5866 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 4, destSheet));
5867 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 5, destSheet));
5868 pEditObj = m_pDoc->GetEditText(ScAddress(6, 5, destSheet));
5869 CPPUNIT_ASSERT(pEditObj == nullptr);
5870 // col 7, formulas
5871 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
5872 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 0, destSheet));
5873 CPPUNIT_ASSERT_EQUAL(OUString("=D2+D4+60"), m_pDoc->GetFormula(7, 1, destSheet));
5874 CPPUNIT_ASSERT_EQUAL(67.0, m_pDoc->GetValue(7, 1, destSheet));
5875 if (!bSkipEmpty)
5876 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(7, 2, destSheet));
5877 else
5878 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
5879 CPPUNIT_ASSERT_EQUAL(OUString("t"), m_pDoc->GetString(7, 3, destSheet));
5880 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 4, destSheet));
5881 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
5882 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
5883 // col 8, formulas
5884 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 0, destSheet));
5885 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 0, destSheet));
5886 CPPUNIT_ASSERT_EQUAL(OUString("=SUMIF(D2:D5;\"<4\")"), m_pDoc->GetFormula(8, 1, destSheet));
5887 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(8, 1, destSheet));
5888 if (!bSkipEmpty)
5889 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(8, 2, destSheet));
5890 else
5891 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
5892 CPPUNIT_ASSERT_EQUAL(OUString("u"), m_pDoc->GetString(8, 3, destSheet));
5893 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(8, 4, destSheet));
5894 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
5895 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
5896 // col 9
5897 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 0, destSheet));
5898 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 1, destSheet));
5899 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 2, destSheet));
5900 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 3, destSheet));
5901 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 4, destSheet));
5902 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(9, 5, destSheet));
5904 // check patterns
5905 const SfxPoolItem* pItem = nullptr;
5906 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5907 CPPUNIT_ASSERT(pItem);
5908 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5909 m_pDoc->GetPattern(ScAddress(3, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5910 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5911 m_pDoc->GetPattern(ScAddress(3, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5912 CPPUNIT_ASSERT(!pItem);
5913 m_pDoc->GetPattern(ScAddress(3, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5914 CPPUNIT_ASSERT(!pItem);
5915 m_pDoc->GetPattern(ScAddress(7, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5916 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
5917 if (!bSkipEmpty)
5918 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5920 m_pDoc->GetPattern(ScAddress(4, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5921 CPPUNIT_ASSERT(!pItem);
5922 m_pDoc->GetPattern(ScAddress(5, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5923 CPPUNIT_ASSERT(pItem);
5924 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5925 m_pDoc->GetPattern(ScAddress(6, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5926 CPPUNIT_ASSERT(pItem);
5927 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
5928 m_pDoc->GetPattern(ScAddress(7, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
5929 CPPUNIT_ASSERT(!pItem);
5931 // check border, left and right borders were transformed to top and bottom borders
5932 pItem = m_pDoc->GetAttr(ScAddress(4, 1, destSheet), ATTR_BORDER);
5933 CPPUNIT_ASSERT(pItem);
5934 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5935 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5936 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5937 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5938 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
5939 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5940 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5941 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5942 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
5943 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
5944 CPPUNIT_ASSERT(pItem);
5945 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5946 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5947 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5948 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5949 pItem = m_pDoc->GetAttr(ScAddress(4, 4, destSheet), ATTR_BORDER);
5950 CPPUNIT_ASSERT(pItem);
5951 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5952 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5953 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5954 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5956 pItem = m_pDoc->GetAttr(ScAddress(3, 3, destSheet), ATTR_BORDER);
5957 CPPUNIT_ASSERT(pItem);
5958 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5959 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5960 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5961 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5962 pItem = m_pDoc->GetAttr(ScAddress(4, 3, destSheet), ATTR_BORDER);
5963 CPPUNIT_ASSERT(pItem);
5964 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5965 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5966 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5967 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5968 pItem = m_pDoc->GetAttr(ScAddress(5, 3, destSheet), ATTR_BORDER);
5969 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5970 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5971 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5972 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5973 pItem = m_pDoc->GetAttr(ScAddress(6, 3, destSheet), ATTR_BORDER);
5974 CPPUNIT_ASSERT(pItem);
5975 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetTop());
5976 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5977 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5978 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5979 pItem = m_pDoc->GetAttr(ScAddress(7, 3, destSheet), ATTR_BORDER);
5980 CPPUNIT_ASSERT(pItem);
5981 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
5982 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
5983 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetLeft());
5984 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetRight());
5986 // check notes after transposed copy/paste
5987 // check presence of notes
5988 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 0, destSheet));
5989 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 0, destSheet));
5990 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 0, destSheet));
5991 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 0, destSheet));
5992 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 0, destSheet));
5993 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 0, destSheet));
5994 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 0, destSheet));
5995 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 0, destSheet));
5996 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 1, destSheet));
5997 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 1, destSheet));
5998 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 1, destSheet));
5999 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 1, destSheet));
6000 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 1, destSheet));
6001 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 1, destSheet));
6002 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 1, destSheet));
6003 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 1, destSheet));
6004 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 2, destSheet));
6005 CPPUNIT_ASSERT(m_pDoc->HasNote(3, 2, destSheet));
6006 CPPUNIT_ASSERT(m_pDoc->HasNote(4, 2, destSheet));
6007 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 2, destSheet));
6008 CPPUNIT_ASSERT(m_pDoc->HasNote(6, 2, destSheet));
6009 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(7, 2, destSheet));
6010 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 2, destSheet));
6011 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 2, destSheet));
6012 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 3, destSheet));
6013 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 3, destSheet));
6014 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 3, destSheet));
6015 CPPUNIT_ASSERT(m_pDoc->HasNote(5, 3, destSheet));
6016 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 3, destSheet));
6017 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 3, destSheet));
6018 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 3, destSheet));
6019 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 3, destSheet));
6020 CPPUNIT_ASSERT(!m_pDoc->HasNote(2, 4, destSheet));
6021 CPPUNIT_ASSERT(!m_pDoc->HasNote(3, 4, destSheet));
6022 CPPUNIT_ASSERT(!m_pDoc->HasNote(4, 4, destSheet));
6023 CPPUNIT_ASSERT(!m_pDoc->HasNote(5, 4, destSheet));
6024 CPPUNIT_ASSERT(!m_pDoc->HasNote(6, 4, destSheet));
6025 CPPUNIT_ASSERT(!m_pDoc->HasNote(7, 4, destSheet));
6026 CPPUNIT_ASSERT(!m_pDoc->HasNote(8, 4, destSheet));
6027 CPPUNIT_ASSERT(!m_pDoc->HasNote(9, 4, destSheet));
6029 // check values of notes
6030 CPPUNIT_ASSERT_EQUAL(OUString("Note A1"), getNote(3, 1, destSheet));
6031 CPPUNIT_ASSERT_EQUAL(OUString("Note A3"), getNote(3, 2, destSheet));
6032 CPPUNIT_ASSERT_EQUAL(OUString("Note B1"), getNote(4, 1, destSheet));
6033 CPPUNIT_ASSERT_EQUAL(OUString("Note B3"), getNote(4, 2, destSheet));
6034 CPPUNIT_ASSERT_EQUAL(OUString("Note C3"), getNote(5, 2, destSheet));
6035 CPPUNIT_ASSERT_EQUAL(OUString("Note D1"), getNote(6, 1, destSheet));
6036 CPPUNIT_ASSERT_EQUAL(OUString("Note D3"), getNote(6, 2, destSheet));
6037 if (!bSkipEmpty)
6038 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(7, 2, destSheet));
6039 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 3, destSheet));
6041 // check row 16 on src sheet, refs to copied/cut range
6042 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
6043 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
6044 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
6045 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
6046 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
6047 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
6048 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
6049 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
6050 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
6051 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
6053 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6054 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6055 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6056 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6057 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6058 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6059 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6060 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6061 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6062 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6064 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
6065 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
6066 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
6067 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
6068 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
6069 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
6070 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
6071 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
6072 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
6073 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
6075 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6076 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6077 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6078 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6079 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6080 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6081 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6082 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6083 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6084 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6086 // Existing references to the destination range must not change
6087 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
6088 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
6089 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
6090 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
6091 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
6092 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
6093 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
6094 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
6095 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
6096 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
6097 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
6098 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
6099 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
6100 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
6101 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
6102 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
6103 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
6104 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
6105 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
6106 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
6107 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
6108 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
6109 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
6110 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
6111 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
6112 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
6113 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
6114 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
6115 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
6116 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
6117 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
6118 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
6119 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
6120 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
6121 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
6122 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
6123 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
6124 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
6125 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
6126 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
6127 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
6128 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
6129 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
6130 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
6131 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
6132 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
6133 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
6134 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
6135 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
6137 m_pDoc->DeleteTab(destSheet);
6138 m_pDoc->DeleteTab(srcSheet);
6141 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty)
6143 const SCTAB srcSheet = 0;
6144 const SCTAB destSheet = 1;
6147 | D | E | F | G | H |
6149 2 | 1 B*| 2 B*| 3 B*| 6 | -11 |
6150 3 | =D2+10 *| =E2+20 b | =F5+30 b*| q | -12 |
6151 4 | a | b *| c *| r | -13 |
6152 5 | R1 *| R2 *| 5 *| s | -14 |
6153 6 | =D2+F2+60 | | B*| t | -15 |
6154 7 | =SUMIF(D2:G2;"<4") | *| | u | -16 |
6156 * means note attached
6157 B means background
6158 b means border
6161 //check cell content after transposed copy/paste of filtered data
6162 // Note: column F is a repetition of srcSheet.Column A
6163 // Col C and G are checked to be empty
6164 const EditTextObject* pEditObj;
6165 // row 0
6166 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6167 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6168 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6169 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6170 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6171 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6172 // row 1, numbers
6173 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell C2", 1000.0, m_pDoc->GetValue(2, 1, destSheet));
6174 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
6175 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 2.0, m_pDoc->GetValue(4, 1, destSheet));
6176 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 3.0, m_pDoc->GetValue(5, 1, destSheet));
6177 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell G2", 6.0, m_pDoc->GetValue(6, 1, destSheet));
6178 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(7, 1, destSheet));
6179 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell I2", 1000.0, m_pDoc->GetValue(8, 1, destSheet));
6180 // row 2, formulas
6181 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6182 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
6183 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
6184 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
6185 m_pDoc->GetFormula(3, 2, destSheet));
6186 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E2+20"),
6187 m_pDoc->GetFormula(4, 2, destSheet));
6188 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 22.0, m_pDoc->GetValue(4, 2, destSheet));
6189 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", 35.0, m_pDoc->GetValue(5, 2, destSheet));
6190 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed F3", OUString("=F5+30"),
6191 m_pDoc->GetFormula(5, 2, destSheet));
6192 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("q"), m_pDoc->GetString(6, 2, destSheet));
6193 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(7, 2, destSheet));
6194 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 2, destSheet));
6195 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 2, destSheet));
6196 // row 3, strings
6197 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6198 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
6199 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
6200 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("b"), m_pDoc->GetString(4, 3, destSheet));
6201 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("c"), m_pDoc->GetString(5, 3, destSheet));
6202 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G4", OUString("r"), m_pDoc->GetString(6, 3, destSheet));
6203 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(7, 3, destSheet));
6204 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 3, destSheet));
6205 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 3, destSheet));
6206 // row 4, rich text
6207 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6208 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
6209 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
6210 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
6211 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
6212 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
6213 pEditObj->GetText(0));
6214 pEditObj = m_pDoc->GetEditText(ScAddress(4, 4, destSheet));
6215 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in E5.", pEditObj);
6216 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong E5.", OUString("R2"), pEditObj->GetText(0));
6217 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F5", 5.0, m_pDoc->GetValue(5, 4, destSheet));
6218 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G5", OUString("s"), m_pDoc->GetString(6, 4, destSheet));
6219 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(7, 4, destSheet));
6220 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 4, destSheet));
6221 pEditObj = m_pDoc->GetEditText(ScAddress(8, 4, destSheet));
6222 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in I5.", pEditObj == nullptr);
6223 // row 5, formulas
6224 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6225 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
6226 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
6227 m_pDoc->GetFormula(3, 5, destSheet));
6228 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 64.0, m_pDoc->GetValue(3, 5, destSheet));
6229 if (!bSkipEmpty)
6231 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
6232 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 5, destSheet));
6234 else
6236 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6237 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 5, destSheet));
6239 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G6", OUString("t"), m_pDoc->GetString(6, 5, destSheet));
6240 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(7, 5, destSheet));
6241 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 5, destSheet));
6242 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 5, destSheet));
6243 // row 6, formulas
6244 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
6245 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
6246 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
6247 m_pDoc->GetFormula(3, 6, destSheet));
6248 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", 6.0, m_pDoc->GetValue(3, 6, destSheet));
6249 if (!bSkipEmpty)
6251 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 6, destSheet));
6252 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(5, 6, destSheet));
6254 else
6256 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
6257 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 6, destSheet));
6259 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell G7", OUString("u"), m_pDoc->GetString(6, 6, destSheet));
6260 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(7, 6, destSheet));
6261 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(8, 6, destSheet));
6262 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(8, 6, destSheet));
6263 // row 7
6264 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
6265 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
6266 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
6267 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
6268 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
6269 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
6271 // check patterns
6272 const SfxPoolItem* pItem = nullptr;
6273 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6274 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
6275 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
6276 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6277 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6278 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
6279 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has blue background", COL_BLUE,
6280 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6281 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6282 CPPUNIT_ASSERT_MESSAGE("F2 has a pattern", pItem);
6283 CPPUNIT_ASSERT_EQUAL_MESSAGE("F2 has a pattern", COL_BLUE,
6284 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6285 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6286 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
6287 m_pDoc->GetPattern(ScAddress(7, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6288 CPPUNIT_ASSERT_MESSAGE("H2 has no pattern", !pItem);
6289 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6290 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6291 if (!bSkipEmpty)
6292 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6294 // check border, left and right borders were transformed to top and bottom borders
6295 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
6296 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
6297 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
6298 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6299 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
6300 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6301 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
6302 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6303 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
6304 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6306 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
6307 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6308 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6310 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6311 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6312 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6313 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
6314 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6315 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
6316 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6317 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
6318 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6319 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
6320 CPPUNIT_ASSERT_MESSAGE("F3 has a border", pItem);
6321 CPPUNIT_ASSERT_MESSAGE("F3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6322 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
6323 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6324 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
6325 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6326 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
6327 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6328 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
6329 CPPUNIT_ASSERT_MESSAGE("G3 has top border", !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6330 CPPUNIT_ASSERT_MESSAGE("G3 has bottom border",
6331 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6332 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
6333 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6334 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
6335 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6336 pItem = m_pDoc->GetAttr(ScAddress(7, 2, destSheet), ATTR_BORDER);
6337 CPPUNIT_ASSERT_MESSAGE("H3 has a border", pItem);
6338 CPPUNIT_ASSERT_MESSAGE("H3 has no top border",
6339 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6340 CPPUNIT_ASSERT_MESSAGE("H3 has no bottom border",
6341 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6342 CPPUNIT_ASSERT_MESSAGE("H3 has no left border",
6343 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6344 CPPUNIT_ASSERT_MESSAGE("H3 has no right border",
6345 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6347 // check notes after transposed copy/paste
6348 // check presence of notes
6349 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
6350 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
6351 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
6352 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
6353 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
6354 CPPUNIT_ASSERT_MESSAGE("H1: no note", !m_pDoc->HasNote(7, 0, destSheet));
6355 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
6356 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
6357 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
6358 CPPUNIT_ASSERT_MESSAGE("F2: a note", m_pDoc->HasNote(5, 1, destSheet));
6359 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
6360 CPPUNIT_ASSERT_MESSAGE("H2: no note", !m_pDoc->HasNote(7, 1, destSheet));
6361 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
6362 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
6363 CPPUNIT_ASSERT_MESSAGE("E3: no note", !m_pDoc->HasNote(4, 2, destSheet));
6364 CPPUNIT_ASSERT_MESSAGE("F3: a note", m_pDoc->HasNote(5, 2, destSheet));
6365 CPPUNIT_ASSERT_MESSAGE("G3: no note", !m_pDoc->HasNote(6, 2, destSheet));
6366 CPPUNIT_ASSERT_MESSAGE("H3: no note", !m_pDoc->HasNote(7, 2, destSheet));
6367 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
6368 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
6369 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
6370 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
6371 CPPUNIT_ASSERT_MESSAGE("G4: a note", m_pDoc->HasNote(6, 3, destSheet));
6372 CPPUNIT_ASSERT_MESSAGE("H4: no note", !m_pDoc->HasNote(7, 3, destSheet));
6373 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
6374 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
6375 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
6376 CPPUNIT_ASSERT_MESSAGE("F5: a note", m_pDoc->HasNote(5, 4, destSheet));
6377 CPPUNIT_ASSERT_MESSAGE("G5: no note", !m_pDoc->HasNote(6, 4, destSheet));
6378 CPPUNIT_ASSERT_MESSAGE("H5: no note", !m_pDoc->HasNote(7, 4, destSheet));
6379 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
6380 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
6381 CPPUNIT_ASSERT_MESSAGE("E6: no note", !m_pDoc->HasNote(4, 5, destSheet));
6382 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(5, 5, destSheet));
6383 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
6384 CPPUNIT_ASSERT_MESSAGE("H6: no note", !m_pDoc->HasNote(7, 5, destSheet));
6385 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
6386 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
6387 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 6, destSheet));
6388 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
6389 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
6390 CPPUNIT_ASSERT_MESSAGE("H7: no note", !m_pDoc->HasNote(7, 6, destSheet));
6391 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
6392 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
6393 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
6394 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
6395 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
6396 CPPUNIT_ASSERT_MESSAGE("H8: no note", !m_pDoc->HasNote(7, 7, destSheet));
6398 // check values of notes
6399 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
6400 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A2"), getNote(4, 1, destSheet));
6401 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F2", OUString("Note A3"), getNote(5, 1, destSheet));
6402 // G2 has no note
6403 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
6404 // E3 has no note
6405 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F3", OUString("Note B3"), getNote(5, 2, destSheet));
6406 // D4 has no note
6407 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C2"), getNote(4, 3, destSheet));
6408 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("Note C3"), getNote(5, 3, destSheet));
6409 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
6410 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D2"), getNote(4, 4, destSheet));
6411 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("Note D3"), getNote(5, 4, destSheet));
6412 if (!bSkipEmpty)
6413 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(5, 5, destSheet));
6414 if (!bSkipEmpty)
6415 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString("Note F2"), getNote(4, 6, destSheet));
6416 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(6, 3, destSheet));
6418 // check row 16 on src sheet, refs to copied/cut range
6419 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
6420 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
6421 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
6422 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
6423 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
6424 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
6425 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
6426 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
6427 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
6428 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
6430 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6431 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6432 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6433 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6434 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6435 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6436 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6437 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6438 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6439 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6441 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
6442 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
6443 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
6444 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
6445 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
6446 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
6447 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
6448 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
6449 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
6450 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
6452 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6453 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6454 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6455 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6456 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6457 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6458 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6459 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6460 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6461 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6463 // Existing references to the destination range must not change
6464 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
6465 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
6466 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
6467 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
6468 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
6469 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
6470 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
6471 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
6472 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
6473 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
6474 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
6475 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
6476 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
6477 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
6478 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
6479 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
6480 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
6481 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
6482 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
6483 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
6484 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
6485 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
6486 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
6487 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
6488 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
6489 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
6490 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
6491 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
6492 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
6493 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
6494 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
6495 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
6496 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
6497 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
6498 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
6499 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
6500 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
6501 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
6502 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
6503 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
6504 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
6505 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
6506 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
6507 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
6508 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
6509 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
6510 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
6511 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
6512 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
6514 m_pDoc->DeleteTab(destSheet);
6515 m_pDoc->DeleteTab(srcSheet);
6518 void TestCopyPaste::checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty)
6520 const SCTAB srcSheet = 0;
6521 const SCTAB destSheet = 1;
6524 | D | E | F | G |
6526 2 | 1 B*| 3 B*| 6 | -11 |
6527 3 | =D2+10 *| =F5+30 b*| q | -12 |
6528 4 | a | c *| r | -13 |
6529 5 | R1 *| 5 *| s | -14 |
6530 6 | =D2+F2+60 | B*| t | -15 |
6531 7 | =SUMIF(D2:G2;"<4") | | u | -16 |
6533 * means note attached
6534 B means background
6535 b means border
6538 //check cell content after transposed copy/paste of filtered data
6539 // Note: column F is a repetition of srcSheet.Column A
6540 // Col C and G are checked to be empty
6541 const EditTextObject* pEditObj;
6542 // row 0
6543 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 0, destSheet));
6544 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 0, destSheet));
6545 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 0, destSheet));
6546 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 0, destSheet));
6547 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 0, destSheet));
6548 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 0, destSheet));
6549 // row 1, numbers
6550 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell C2", 1000.0, m_pDoc->GetValue(2, 1, destSheet));
6551 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell D2", 1.0, m_pDoc->GetValue(3, 1, destSheet));
6552 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E2", 3.0, m_pDoc->GetValue(4, 1, destSheet));
6553 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell F2", 6.0, m_pDoc->GetValue(5, 1, destSheet));
6554 CPPUNIT_ASSERT_EQUAL(-11.0, m_pDoc->GetValue(6, 1, destSheet));
6555 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell H2", 1000.0, m_pDoc->GetValue(7, 1, destSheet));
6556 // row 2, formulas
6557 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 2, destSheet));
6558 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 2, destSheet));
6559 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", 11.0, m_pDoc->GetValue(3, 2, destSheet));
6560 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D3", OUString("=D2+10"),
6561 m_pDoc->GetFormula(3, 2, destSheet));
6562 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", 35.0, m_pDoc->GetValue(4, 2, destSheet));
6563 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed E3", OUString("=E5+30"),
6564 m_pDoc->GetFormula(4, 2, destSheet));
6565 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("q"), m_pDoc->GetString(5, 2, destSheet));
6566 CPPUNIT_ASSERT_EQUAL(-12.0, m_pDoc->GetValue(6, 2, destSheet));
6567 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 2, destSheet));
6568 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 2, destSheet));
6569 // row 3, strings
6570 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 3, destSheet));
6571 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 3, destSheet));
6572 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D4", OUString("a"), m_pDoc->GetString(3, 3, destSheet));
6573 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("c"), m_pDoc->GetString(4, 3, destSheet));
6574 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F4", OUString("r"), m_pDoc->GetString(5, 3, destSheet));
6575 CPPUNIT_ASSERT_EQUAL(-13.0, m_pDoc->GetValue(6, 3, destSheet));
6576 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 3, destSheet));
6577 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 3, destSheet));
6578 // row 4, rich text
6579 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 4, destSheet));
6580 pEditObj = m_pDoc->GetEditText(ScAddress(2, 4, destSheet));
6581 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in C5.", pEditObj == nullptr);
6582 pEditObj = m_pDoc->GetEditText(ScAddress(3, 4, destSheet));
6583 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in D5.", pEditObj);
6584 CPPUNIT_ASSERT_EQUAL_MESSAGE("Edit cell value wrong in D5 ", OUString("R1"),
6585 pEditObj->GetText(0));
6586 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed cell E5", 5.0, m_pDoc->GetValue(4, 4, destSheet));
6587 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F5", OUString("s"), m_pDoc->GetString(5, 4, destSheet));
6588 CPPUNIT_ASSERT_EQUAL(-14.0, m_pDoc->GetValue(6, 4, destSheet));
6589 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 4, destSheet));
6590 pEditObj = m_pDoc->GetEditText(ScAddress(7, 4, destSheet));
6591 CPPUNIT_ASSERT_MESSAGE("There should be no edit cell in H5.", pEditObj == nullptr);
6592 // row 5, formulas
6593 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 5, destSheet));
6594 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 5, destSheet));
6595 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", OUString("=D2+F2+60"),
6596 m_pDoc->GetFormula(3, 5, destSheet));
6597 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D6", 67.0, m_pDoc->GetValue(3, 5, destSheet));
6598 if (!bSkipEmpty)
6600 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E6", OUString(), m_pDoc->GetString(4, 5, destSheet));
6602 else
6603 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 5, destSheet));
6604 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F6", OUString("t"), m_pDoc->GetString(5, 5, destSheet));
6605 CPPUNIT_ASSERT_EQUAL(-15.0, m_pDoc->GetValue(6, 5, destSheet));
6606 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 5, destSheet));
6607 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 5, destSheet));
6608 // row 6, formulas
6609 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 6, destSheet));
6610 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(2, 6, destSheet));
6611 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", OUString("=SUMIF(D2:G2;\"<4\")"),
6612 m_pDoc->GetFormula(3, 6, destSheet));
6613 CPPUNIT_ASSERT_EQUAL_MESSAGE("transposed D7", -7.0, m_pDoc->GetValue(3, 6, destSheet));
6614 if (!bSkipEmpty)
6615 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E7", OUString(), m_pDoc->GetString(4, 6, destSheet));
6616 else
6617 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 6, destSheet));
6618 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell F7", OUString("u"), m_pDoc->GetString(5, 6, destSheet));
6619 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(6, 6, destSheet));
6620 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 6, destSheet));
6621 CPPUNIT_ASSERT_EQUAL(OUString("1000"), m_pDoc->GetString(7, 6, destSheet));
6622 // row 7
6623 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(2, 7, destSheet));
6624 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(3, 7, destSheet));
6625 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(4, 7, destSheet));
6626 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(5, 7, destSheet));
6627 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(6, 7, destSheet));
6628 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(7, 7, destSheet));
6630 // check patterns
6631 const SfxPoolItem* pItem = nullptr;
6632 m_pDoc->GetPattern(ScAddress(3, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6633 CPPUNIT_ASSERT_MESSAGE("D2 has a pattern", pItem);
6634 CPPUNIT_ASSERT_EQUAL_MESSAGE("D2 has blue background", COL_BLUE,
6635 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6636 m_pDoc->GetPattern(ScAddress(4, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6637 CPPUNIT_ASSERT_MESSAGE("E2 has a pattern", pItem);
6638 CPPUNIT_ASSERT_EQUAL_MESSAGE("E2 has a pattern", COL_BLUE,
6639 static_cast<const SvxBrushItem*>(pItem)->GetColor());
6640 m_pDoc->GetPattern(ScAddress(5, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6641 CPPUNIT_ASSERT_MESSAGE("F2 has no pattern", !pItem);
6642 m_pDoc->GetPattern(ScAddress(6, 1, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6643 CPPUNIT_ASSERT_MESSAGE("G2 has no pattern", !pItem);
6644 m_pDoc->GetPattern(ScAddress(4, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6645 CPPUNIT_ASSERT_EQUAL(bSkipEmpty, pItem == nullptr);
6646 if (!bSkipEmpty)
6647 CPPUNIT_ASSERT_EQUAL(COL_GREEN, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6649 m_pDoc->GetPattern(ScAddress(5, 2, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6650 CPPUNIT_ASSERT(!pItem);
6651 m_pDoc->GetPattern(ScAddress(5, 3, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6652 CPPUNIT_ASSERT(pItem);
6653 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6654 m_pDoc->GetPattern(ScAddress(5, 4, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6655 CPPUNIT_ASSERT(pItem);
6656 CPPUNIT_ASSERT_EQUAL(COL_RED, static_cast<const SvxBrushItem*>(pItem)->GetColor());
6657 m_pDoc->GetPattern(ScAddress(5, 5, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6658 CPPUNIT_ASSERT(!pItem);
6659 m_pDoc->GetPattern(ScAddress(5, 6, destSheet))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
6660 CPPUNIT_ASSERT(!pItem);
6662 // check border, left and right borders were transformed to top and bottom borders
6663 pItem = m_pDoc->GetAttr(ScAddress(3, 2, destSheet), ATTR_BORDER);
6664 CPPUNIT_ASSERT_MESSAGE("D3 has a border", pItem);
6665 CPPUNIT_ASSERT_MESSAGE("D3 has no top border",
6666 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6667 CPPUNIT_ASSERT_MESSAGE("D3 has no bottom border",
6668 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6669 CPPUNIT_ASSERT_MESSAGE("D3 has no left border",
6670 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6671 CPPUNIT_ASSERT_MESSAGE("D3 has no right border",
6672 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6673 m_pDoc->GetPattern(ScAddress(4, 2, destSheet))->GetItemSet().HasItem(ATTR_BORDER, &pItem);
6674 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6675 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6676 pItem = m_pDoc->GetAttr(ScAddress(4, 2, destSheet), ATTR_BORDER);
6677 CPPUNIT_ASSERT_MESSAGE("E3 has a border", pItem);
6678 CPPUNIT_ASSERT_MESSAGE("E3 has top border", static_cast<const SvxBoxItem*>(pItem)->GetTop());
6679 CPPUNIT_ASSERT_MESSAGE("E3 has bottom border",
6680 static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6681 CPPUNIT_ASSERT_MESSAGE("E3 has no left border",
6682 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6683 CPPUNIT_ASSERT_MESSAGE("E3 has no right border",
6684 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6685 pItem = m_pDoc->GetAttr(ScAddress(5, 2, destSheet), ATTR_BORDER);
6686 CPPUNIT_ASSERT_MESSAGE("F3 has top border", !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6687 CPPUNIT_ASSERT_MESSAGE("F3 has bottom border",
6688 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6689 CPPUNIT_ASSERT_MESSAGE("F3 has no left border",
6690 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6691 CPPUNIT_ASSERT_MESSAGE("F3 has no right border",
6692 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6693 pItem = m_pDoc->GetAttr(ScAddress(6, 2, destSheet), ATTR_BORDER);
6694 CPPUNIT_ASSERT_MESSAGE("G3 has a border", pItem);
6695 CPPUNIT_ASSERT_MESSAGE("G3 has no top border",
6696 !static_cast<const SvxBoxItem*>(pItem)->GetTop());
6697 CPPUNIT_ASSERT_MESSAGE("G3 has no bottom border",
6698 !static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6699 CPPUNIT_ASSERT_MESSAGE("G3 has no left border",
6700 !static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6701 CPPUNIT_ASSERT_MESSAGE("G3 has no right border",
6702 !static_cast<const SvxBoxItem*>(pItem)->GetRight());
6703 pItem = m_pDoc->GetAttr(ScAddress(5, 3, destSheet), ATTR_BORDER);
6704 CPPUNIT_ASSERT(pItem);
6705 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6706 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6707 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6708 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6709 pItem = m_pDoc->GetAttr(ScAddress(5, 4, destSheet), ATTR_BORDER);
6710 CPPUNIT_ASSERT(pItem);
6711 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetTop());
6712 CPPUNIT_ASSERT(!static_cast<const SvxBoxItem*>(pItem)->GetBottom());
6713 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetLeft());
6714 CPPUNIT_ASSERT(static_cast<const SvxBoxItem*>(pItem)->GetRight());
6716 // check notes after transposed copy/paste
6717 // check presence of notes
6718 CPPUNIT_ASSERT_MESSAGE("C1: no note", !m_pDoc->HasNote(2, 0, destSheet));
6719 CPPUNIT_ASSERT_MESSAGE("D1: no note", !m_pDoc->HasNote(3, 0, destSheet));
6720 CPPUNIT_ASSERT_MESSAGE("E1: no note", !m_pDoc->HasNote(4, 0, destSheet));
6721 CPPUNIT_ASSERT_MESSAGE("F1: no note", !m_pDoc->HasNote(5, 0, destSheet));
6722 CPPUNIT_ASSERT_MESSAGE("G1: no note", !m_pDoc->HasNote(6, 0, destSheet));
6723 CPPUNIT_ASSERT_MESSAGE("C2: no note", !m_pDoc->HasNote(2, 1, destSheet));
6724 CPPUNIT_ASSERT_MESSAGE("D2: a note", m_pDoc->HasNote(3, 1, destSheet));
6725 CPPUNIT_ASSERT_MESSAGE("E2: a note", m_pDoc->HasNote(4, 1, destSheet));
6726 CPPUNIT_ASSERT_MESSAGE("F2: no note", !m_pDoc->HasNote(5, 1, destSheet));
6727 CPPUNIT_ASSERT_MESSAGE("G2: no note", !m_pDoc->HasNote(6, 1, destSheet));
6728 CPPUNIT_ASSERT_MESSAGE("C3: no note", !m_pDoc->HasNote(2, 2, destSheet));
6729 CPPUNIT_ASSERT_MESSAGE("D3: a note", m_pDoc->HasNote(3, 2, destSheet));
6730 CPPUNIT_ASSERT_MESSAGE("E3: a note", m_pDoc->HasNote(4, 2, destSheet));
6731 CPPUNIT_ASSERT_MESSAGE("F3: no note", !m_pDoc->HasNote(5, 2, destSheet));
6732 CPPUNIT_ASSERT_MESSAGE("G3: no note", !m_pDoc->HasNote(6, 2, destSheet));
6733 CPPUNIT_ASSERT_MESSAGE("C4: no note", !m_pDoc->HasNote(2, 3, destSheet));
6734 CPPUNIT_ASSERT_MESSAGE("D4: no note", !m_pDoc->HasNote(3, 3, destSheet));
6735 CPPUNIT_ASSERT_MESSAGE("E4: a note", m_pDoc->HasNote(4, 3, destSheet));
6736 CPPUNIT_ASSERT_MESSAGE("F4: a note", m_pDoc->HasNote(5, 3, destSheet));
6737 CPPUNIT_ASSERT_MESSAGE("G4: no note", !m_pDoc->HasNote(6, 3, destSheet));
6738 CPPUNIT_ASSERT_MESSAGE("C5: no note", !m_pDoc->HasNote(2, 4, destSheet));
6739 CPPUNIT_ASSERT_MESSAGE("D5: a note", m_pDoc->HasNote(3, 4, destSheet));
6740 CPPUNIT_ASSERT_MESSAGE("E5: a note", m_pDoc->HasNote(4, 4, destSheet));
6741 CPPUNIT_ASSERT_MESSAGE("F5: no note", !m_pDoc->HasNote(5, 4, destSheet));
6742 CPPUNIT_ASSERT_MESSAGE("G5: no note", !m_pDoc->HasNote(6, 4, destSheet));
6743 CPPUNIT_ASSERT_MESSAGE("C6: no note", !m_pDoc->HasNote(2, 5, destSheet));
6744 CPPUNIT_ASSERT_MESSAGE("D6: no note", !m_pDoc->HasNote(3, 5, destSheet));
6745 CPPUNIT_ASSERT_EQUAL(!bSkipEmpty, m_pDoc->HasNote(4, 5, destSheet));
6746 CPPUNIT_ASSERT_MESSAGE("F6: no note", !m_pDoc->HasNote(5, 5, destSheet));
6747 CPPUNIT_ASSERT_MESSAGE("G6: no note", !m_pDoc->HasNote(6, 5, destSheet));
6748 CPPUNIT_ASSERT_MESSAGE("C7: no note", !m_pDoc->HasNote(2, 6, destSheet));
6749 CPPUNIT_ASSERT_MESSAGE("D7: no note", !m_pDoc->HasNote(3, 6, destSheet));
6750 CPPUNIT_ASSERT_MESSAGE("E7: no note", !m_pDoc->HasNote(4, 6, destSheet));
6751 CPPUNIT_ASSERT_MESSAGE("F7: no note", !m_pDoc->HasNote(5, 6, destSheet));
6752 CPPUNIT_ASSERT_MESSAGE("G7: no note", !m_pDoc->HasNote(6, 6, destSheet));
6753 CPPUNIT_ASSERT_MESSAGE("C8: no note", !m_pDoc->HasNote(2, 7, destSheet));
6754 CPPUNIT_ASSERT_MESSAGE("D8: no note", !m_pDoc->HasNote(3, 7, destSheet));
6755 CPPUNIT_ASSERT_MESSAGE("E8: no note", !m_pDoc->HasNote(4, 7, destSheet));
6756 CPPUNIT_ASSERT_MESSAGE("F8: no note", !m_pDoc->HasNote(5, 7, destSheet));
6757 CPPUNIT_ASSERT_MESSAGE("G8: no note", !m_pDoc->HasNote(6, 7, destSheet));
6759 // check values of notes
6760 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D2", OUString("Note A1"), getNote(3, 1, destSheet));
6761 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E2", OUString("Note A3"), getNote(4, 1, destSheet));
6762 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D3", OUString("Note B1"), getNote(3, 2, destSheet));
6763 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E3", OUString("Note B3"), getNote(4, 2, destSheet));
6764 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E4", OUString("Note C3"), getNote(4, 3, destSheet));
6765 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D5", OUString("Note D1"), getNote(3, 4, destSheet));
6766 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell E5", OUString("Note D3"), getNote(4, 4, destSheet));
6767 if (!bSkipEmpty)
6768 CPPUNIT_ASSERT_EQUAL(OUString("Note E2"), getNote(4, 5, destSheet));
6769 CPPUNIT_ASSERT_EQUAL(OUString("Note C5"), getNote(5, 3, destSheet));
6771 // check row 16 on src sheet, refs to copied/cut range
6772 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(1, 16, srcSheet));
6773 CPPUNIT_ASSERT_EQUAL(OUString("=$C$5"), m_pDoc->GetFormula(2, 16, srcSheet));
6774 CPPUNIT_ASSERT_EQUAL(OUString("=$C5"), m_pDoc->GetFormula(3, 16, srcSheet));
6775 CPPUNIT_ASSERT_EQUAL(OUString("=C$5"), m_pDoc->GetFormula(4, 16, srcSheet));
6776 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C5:C5)"), m_pDoc->GetFormula(5, 16, srcSheet));
6777 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$5:$C$5)"), m_pDoc->GetFormula(6, 16, srcSheet));
6778 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C5:$C5)"), m_pDoc->GetFormula(7, 16, srcSheet));
6779 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C$5:C$5)"), m_pDoc->GetFormula(8, 16, srcSheet));
6780 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$6)"), m_pDoc->GetFormula(9, 16, srcSheet));
6781 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$B$10)"), m_pDoc->GetFormula(10, 16, srcSheet));
6783 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 16, srcSheet));
6784 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 16, srcSheet));
6785 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 16, srcSheet));
6786 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(4, 16, srcSheet));
6787 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 16, srcSheet));
6788 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 16, srcSheet));
6789 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 16, srcSheet));
6790 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(8, 16, srcSheet));
6791 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 16, srcSheet));
6792 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 16, srcSheet));
6794 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C5"), m_pDoc->GetFormula(1, 17, srcSheet));
6795 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aCa5"), m_pDoc->GetFormula(2, 17, srcSheet));
6796 CPPUNIT_ASSERT_EQUAL(OUString("=Range_aC5"), m_pDoc->GetFormula(3, 17, srcSheet));
6797 CPPUNIT_ASSERT_EQUAL(OUString("=Range_Ca5"), m_pDoc->GetFormula(4, 17, srcSheet));
6798 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C5_C5)"), m_pDoc->GetFormula(5, 17, srcSheet));
6799 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa5)"), m_pDoc->GetFormula(6, 17, srcSheet));
6800 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aC5_aC5)"), m_pDoc->GetFormula(7, 17, srcSheet));
6801 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_Ca5_Ca5)"), m_pDoc->GetFormula(8, 17, srcSheet));
6802 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa8)"), m_pDoc->GetFormula(9, 17, srcSheet));
6803 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_aCa5_aCa10)"), m_pDoc->GetFormula(10, 17, srcSheet));
6805 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(1, 17, srcSheet));
6806 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(2, 17, srcSheet));
6807 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(3, 17, srcSheet));
6808 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(4, 17, srcSheet));
6809 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(5, 17, srcSheet));
6810 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(6, 17, srcSheet));
6811 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(7, 17, srcSheet));
6812 CPPUNIT_ASSERT_EQUAL(123.0, m_pDoc->GetValue(8, 17, srcSheet));
6813 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(9, 17, srcSheet));
6814 CPPUNIT_ASSERT_EQUAL(-17.0, m_pDoc->GetValue(10, 17, srcSheet));
6816 // Existing references to the destination range must not change
6817 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D1"), m_pDoc->GetFormula(3, 101, srcSheet));
6818 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D2"), m_pDoc->GetFormula(3, 102, srcSheet));
6819 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D3"), m_pDoc->GetFormula(3, 103, srcSheet));
6820 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D4"), m_pDoc->GetFormula(3, 104, srcSheet));
6821 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D5"), m_pDoc->GetFormula(3, 105, srcSheet));
6822 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D6"), m_pDoc->GetFormula(3, 106, srcSheet));
6823 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.D7"), m_pDoc->GetFormula(3, 107, srcSheet));
6824 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E1"), m_pDoc->GetFormula(4, 101, srcSheet));
6825 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E2"), m_pDoc->GetFormula(4, 102, srcSheet));
6826 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E3"), m_pDoc->GetFormula(4, 103, srcSheet));
6827 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E4"), m_pDoc->GetFormula(4, 104, srcSheet));
6828 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E5"), m_pDoc->GetFormula(4, 105, srcSheet));
6829 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E6"), m_pDoc->GetFormula(4, 106, srcSheet));
6830 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.E7"), m_pDoc->GetFormula(4, 107, srcSheet));
6831 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F1"), m_pDoc->GetFormula(5, 101, srcSheet));
6832 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F2"), m_pDoc->GetFormula(5, 102, srcSheet));
6833 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F3"), m_pDoc->GetFormula(5, 103, srcSheet));
6834 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F4"), m_pDoc->GetFormula(5, 104, srcSheet));
6835 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F5"), m_pDoc->GetFormula(5, 105, srcSheet));
6836 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F6"), m_pDoc->GetFormula(5, 106, srcSheet));
6837 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.F7"), m_pDoc->GetFormula(5, 107, srcSheet));
6838 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G1"), m_pDoc->GetFormula(6, 101, srcSheet));
6839 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G2"), m_pDoc->GetFormula(6, 102, srcSheet));
6840 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G3"), m_pDoc->GetFormula(6, 103, srcSheet));
6841 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G4"), m_pDoc->GetFormula(6, 104, srcSheet));
6842 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G5"), m_pDoc->GetFormula(6, 105, srcSheet));
6843 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G6"), m_pDoc->GetFormula(6, 106, srcSheet));
6844 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.G7"), m_pDoc->GetFormula(6, 107, srcSheet));
6845 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H1"), m_pDoc->GetFormula(7, 101, srcSheet));
6846 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H2"), m_pDoc->GetFormula(7, 102, srcSheet));
6847 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H3"), m_pDoc->GetFormula(7, 103, srcSheet));
6848 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H4"), m_pDoc->GetFormula(7, 104, srcSheet));
6849 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H5"), m_pDoc->GetFormula(7, 105, srcSheet));
6850 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H6"), m_pDoc->GetFormula(7, 106, srcSheet));
6851 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.H7"), m_pDoc->GetFormula(7, 107, srcSheet));
6852 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I1"), m_pDoc->GetFormula(8, 101, srcSheet));
6853 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I2"), m_pDoc->GetFormula(8, 102, srcSheet));
6854 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I3"), m_pDoc->GetFormula(8, 103, srcSheet));
6855 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I4"), m_pDoc->GetFormula(8, 104, srcSheet));
6856 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I5"), m_pDoc->GetFormula(8, 105, srcSheet));
6857 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I6"), m_pDoc->GetFormula(8, 106, srcSheet));
6858 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.I7"), m_pDoc->GetFormula(8, 107, srcSheet));
6859 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J1"), m_pDoc->GetFormula(9, 101, srcSheet));
6860 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J2"), m_pDoc->GetFormula(9, 102, srcSheet));
6861 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J3"), m_pDoc->GetFormula(9, 103, srcSheet));
6862 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J4"), m_pDoc->GetFormula(9, 104, srcSheet));
6863 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J5"), m_pDoc->GetFormula(9, 105, srcSheet));
6864 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J6"), m_pDoc->GetFormula(9, 106, srcSheet));
6865 CPPUNIT_ASSERT_EQUAL(OUString("=DestSheet.J7"), m_pDoc->GetFormula(9, 107, srcSheet));
6867 m_pDoc->DeleteTab(destSheet);
6868 m_pDoc->DeleteTab(srcSheet);
6871 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf142201Row)
6873 const SCTAB nTab = 0;
6874 m_pDoc->InsertTab(nTab, "Test");
6876 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
6877 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
6878 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
6879 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
6881 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
6882 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
6883 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
6884 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
6886 // Check precondition
6887 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
6888 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
6889 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
6890 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
6892 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
6893 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
6894 printRange(m_pDoc, aReferencesRange, "References");
6895 printFormula(m_pDoc, 0, 3, nTab);
6896 printFormula(m_pDoc, 0, 4, nTab);
6897 printFormula(m_pDoc, 1, 3, nTab);
6898 printFormula(m_pDoc, 1, 4, nTab);
6900 // Cut A1:A2 to the clip document.
6901 ScDocument aClipDoc(SCDOCMODE_CLIP);
6902 ScRange aSrcRange(0, 0, nTab, 0, 1, nTab);
6903 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
6905 // To B7:C7
6906 ScRange aDestRange(1, 6, nTab, 2, 6, nTab);
6907 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
6909 // Transpose
6910 ScDocument* pOrigClipDoc = &aClipDoc;
6911 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
6912 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
6913 aDestMark.SetMarkArea(aDestRange);
6914 // Paste
6915 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
6916 true, false, true, false);
6917 printRange(m_pDoc, aReferencesRange, "References after cut");
6918 printFormula(m_pDoc, 0, 3, nTab);
6919 printFormula(m_pDoc, 0, 4, nTab);
6920 printFormula(m_pDoc, 1, 3, nTab);
6921 printFormula(m_pDoc, 1, 4, nTab);
6922 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
6923 pTransClip.reset();
6925 printRange(m_pDoc, aReferencesRange, "References after cut transposed");
6926 printFormula(m_pDoc, 0, 3, nTab);
6927 printFormula(m_pDoc, 0, 4, nTab);
6928 printFormula(m_pDoc, 1, 3, nTab);
6929 printFormula(m_pDoc, 1, 4, nTab);
6931 // Check results
6932 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
6933 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
6934 // Without the fix in place, this would have failed with
6935 // - Expected: 11
6936 // - Actual : 2
6937 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
6938 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
6940 CPPUNIT_ASSERT_EQUAL(OUString("=B7"), m_pDoc->GetFormula(0, 3, nTab));
6941 CPPUNIT_ASSERT_EQUAL(OUString("=C7"), m_pDoc->GetFormula(0, 4, nTab));
6942 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(1, 3, nTab));
6943 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(1, 4, nTab));
6946 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf142201ColRel)
6948 const SCTAB nTab = 0;
6949 m_pDoc->InsertTab(nTab, "Test");
6951 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
6952 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
6953 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
6954 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
6956 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
6957 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
6958 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
6959 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
6961 // Check precondition
6962 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
6963 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
6964 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
6965 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
6967 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
6968 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
6969 printRange(m_pDoc, aReferencesRange, "References");
6970 printFormula(m_pDoc, 0, 3, nTab);
6971 printFormula(m_pDoc, 0, 4, nTab);
6972 printFormula(m_pDoc, 1, 3, nTab);
6973 printFormula(m_pDoc, 1, 4, nTab);
6975 // Cut values A1:B1 to the clip document.
6976 ScDocument aClipDoc(SCDOCMODE_CLIP);
6977 ScRange aSrcRange(0, 0, nTab, 1, 0, nTab);
6978 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
6980 // To B7:B8
6981 ScRange aDestRange(1, 6, nTab, 1, 7, nTab);
6982 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
6984 // Transpose
6985 ScDocument* pOrigClipDoc = &aClipDoc;
6986 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
6987 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
6988 aDestMark.SetMarkArea(aDestRange);
6989 // Paste
6990 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
6991 true, false, true, false);
6992 printRange(m_pDoc, aReferencesRange, "References after paste");
6993 printFormula(m_pDoc, 0, 3, nTab);
6994 printFormula(m_pDoc, 0, 4, nTab);
6995 printFormula(m_pDoc, 1, 3, nTab);
6996 printFormula(m_pDoc, 1, 4, nTab);
6997 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
6998 pTransClip.reset();
7000 printRange(m_pDoc, aReferencesRange, "References after paste transposed");
7001 printFormula(m_pDoc, 0, 3, nTab);
7002 printFormula(m_pDoc, 0, 4, nTab);
7003 printFormula(m_pDoc, 1, 3, nTab);
7004 printFormula(m_pDoc, 1, 4, nTab);
7006 // Check results
7007 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7008 // Without the fix in place, this would have failed with
7009 // - Expected: 2
7010 // - Actual : 11
7011 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7012 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7013 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7015 CPPUNIT_ASSERT_EQUAL(OUString("=B7"), m_pDoc->GetFormula(0, 3, nTab));
7016 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(0, 4, nTab));
7017 CPPUNIT_ASSERT_EQUAL(OUString("=B8"), m_pDoc->GetFormula(1, 3, nTab));
7018 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(1, 4, nTab));
7021 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf142201ColAbs)
7023 const SCTAB nTab = 0;
7024 m_pDoc->InsertTab(nTab, "Test");
7026 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
7027 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
7028 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
7029 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
7031 m_pDoc->SetString(0, 3, nTab, "=$A$1"); // A4
7032 m_pDoc->SetString(0, 4, nTab, "=$A$2"); // A5
7033 m_pDoc->SetString(1, 3, nTab, "=$B$1"); // B4
7034 m_pDoc->SetString(1, 4, nTab, "=$B$2"); // B5
7036 // Check precondition
7037 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7038 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7039 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7040 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7042 ScRange aReferencesRange(0, 3, nTab, 1, 4, nTab);
7043 printRange(m_pDoc, ScRange(0, 0, nTab, 1, 1, nTab), "Source");
7044 printRange(m_pDoc, aReferencesRange, "References");
7045 printFormula(m_pDoc, 0, 3, nTab);
7046 printFormula(m_pDoc, 0, 4, nTab);
7047 printFormula(m_pDoc, 1, 3, nTab);
7048 printFormula(m_pDoc, 1, 4, nTab);
7050 // Cut values A1:B1 to the clip document.
7051 ScDocument aClipDoc(SCDOCMODE_CLIP);
7052 ScRange aSrcRange(0, 0, nTab, 1, 0, nTab);
7053 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
7055 // To B7:B8
7056 ScRange aDestRange(1, 6, nTab, 1, 7, nTab);
7057 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7059 // Transpose
7060 ScDocument* pOrigClipDoc = &aClipDoc;
7061 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7062 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
7063 aDestMark.SetMarkArea(aDestRange);
7064 // Paste
7065 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
7066 true, false, true, false);
7067 printRange(m_pDoc, aReferencesRange, "References after paste");
7068 printFormula(m_pDoc, 0, 3, nTab);
7069 printFormula(m_pDoc, 0, 4, nTab);
7070 printFormula(m_pDoc, 1, 3, nTab);
7071 printFormula(m_pDoc, 1, 4, nTab);
7072 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
7073 pTransClip.reset();
7075 printRange(m_pDoc, aReferencesRange, "References after paste transposed");
7076 printFormula(m_pDoc, 0, 3, nTab);
7077 printFormula(m_pDoc, 0, 4, nTab);
7078 printFormula(m_pDoc, 1, 3, nTab);
7079 printFormula(m_pDoc, 1, 4, nTab);
7081 // Check results
7082 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
7083 // Without the fix in place, this would have failed with
7084 // - Expected: 2
7085 // - Actual : 11
7086 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
7087 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
7088 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
7090 CPPUNIT_ASSERT_EQUAL(OUString("=$B$7"), m_pDoc->GetFormula(0, 3, nTab));
7091 CPPUNIT_ASSERT_EQUAL(OUString("=$A$2"), m_pDoc->GetFormula(0, 4, nTab));
7092 CPPUNIT_ASSERT_EQUAL(OUString("=$B$8"), m_pDoc->GetFormula(1, 3, nTab));
7093 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), m_pDoc->GetFormula(1, 4, nTab));
7096 void TestCopyPaste::checkReferencedCutRangesRowIntitial(const SCTAB nSrcTab, const OUString& rDesc)
7098 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 3, 2, nSrcTab), rDesc.toUtf8() + ": Source");
7099 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(1, 1, nSrcTab));
7100 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 1, nSrcTab));
7101 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(3, 1, nSrcTab));
7102 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7103 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7104 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7106 // Guards
7107 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7108 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7109 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7110 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7111 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7112 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7113 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7114 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7115 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7116 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7117 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7118 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7119 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7120 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7121 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7122 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7123 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7124 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7125 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7126 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7127 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7128 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7129 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7130 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7131 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7132 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7133 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7134 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7135 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
7136 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
7137 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
7138 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
7139 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), m_pDoc->GetFormula(24, 0, nSrcTab)); // Y1
7140 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
7141 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), m_pDoc->GetFormula(24, 1, nSrcTab)); // Y2
7142 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
7143 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), m_pDoc->GetFormula(24, 2, nSrcTab)); // Y3
7144 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
7145 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(21, 3, nSrcTab)); // B4
7146 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(22, 3, nSrcTab)); // W4
7147 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
7148 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), m_pDoc->GetFormula(24, 3, nSrcTab)); // Y4
7150 for (int i = 10; i < 20; ++i)
7151 for (int j = 0; j < 10; ++j)
7153 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(j, i, nSrcTab));
7154 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(j, i, nSrcTab));
7157 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7158 rDesc.toUtf8() + ": Relative references");
7159 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
7160 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
7161 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(2, 20, nSrcTab)); // C21
7162 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
7163 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
7164 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(2, 21, nSrcTab)); // C22
7165 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7166 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7167 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7168 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7169 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7170 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7172 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 30, nSrcTab, 2, 31, nSrcTab),
7173 rDesc.toUtf8() + ": Absolute references");
7174 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
7175 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
7176 CPPUNIT_ASSERT_EQUAL(OUString("=$D$2"), m_pDoc->GetFormula(2, 30, nSrcTab)); // C31
7177 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
7178 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
7179 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), m_pDoc->GetFormula(2, 31, nSrcTab)); // C32
7180 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7181 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7182 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7183 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7184 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7185 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7187 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2"), getRangeByName("Range_B2"));
7188 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
7189 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$2"), getRangeByName("Range_D2"));
7190 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3"));
7191 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
7192 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3"));
7193 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$2"), getRangeByName("Range_B2_D2"));
7194 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3"));
7195 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3"));
7196 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
7198 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 40, nSrcTab, 2, 41, nSrcTab),
7199 rDesc.toUtf8() + ": Absolute ranges");
7200 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
7201 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
7202 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), m_pDoc->GetFormula(2, 40, nSrcTab)); // C41
7203 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
7204 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
7205 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), m_pDoc->GetFormula(2, 41, nSrcTab)); // C42
7206 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7207 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7208 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7209 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7210 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7211 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7213 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 50, nSrcTab, 2, 51, nSrcTab),
7214 rDesc.toUtf8() + ": Relative ranges");
7215 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
7216 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
7217 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 50, nSrcTab)); // C51
7218 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
7219 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
7220 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 51, nSrcTab)); // C52
7221 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7222 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7223 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7224 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7225 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7226 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7228 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 60, nSrcTab, 2, 61, nSrcTab),
7229 rDesc.toUtf8() + ": Relative sum");
7230 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
7231 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
7232 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:D2)"), m_pDoc->GetFormula(2, 60, nSrcTab)); // C61
7233 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
7234 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
7235 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(2, 61, nSrcTab)); // C62
7236 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7237 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7238 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7239 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7240 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7241 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7243 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 70, nSrcTab, 2, 71, nSrcTab),
7244 rDesc.toUtf8() + ": Absolute sum");
7245 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
7246 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
7247 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$2)"), m_pDoc->GetFormula(2, 70, nSrcTab)); // C71
7248 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
7249 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
7250 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(2, 71, nSrcTab)); // C72
7251 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7252 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7253 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7254 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7255 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7256 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7258 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 80, nSrcTab, 2, 81, nSrcTab),
7259 rDesc.toUtf8() + ": Relative range sum");
7260 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
7261 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
7262 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(2, 80, nSrcTab)); // C81
7263 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
7264 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
7265 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(2, 81, nSrcTab)); // C82
7266 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7267 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7268 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7269 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7270 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7271 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7273 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 90, nSrcTab, 2, 91, nSrcTab),
7274 rDesc.toUtf8() + ": Absolute sum");
7275 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
7276 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
7277 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 90, nSrcTab)); // C91
7278 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
7279 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
7280 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 91, nSrcTab)); // C92
7281 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 90, nSrcTab));
7282 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 90, nSrcTab));
7283 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 90, nSrcTab));
7284 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 91, nSrcTab));
7285 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 91, nSrcTab));
7286 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 91, nSrcTab));
7288 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 100, nSrcTab, 2, 101, nSrcTab),
7289 rDesc.toUtf8() + ": Relative range sum");
7290 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7291 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
7292 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7293 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
7294 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7295 m_pDoc->GetFormula(2, 100, nSrcTab)); // C101
7296 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7297 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
7298 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7299 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
7300 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7301 m_pDoc->GetFormula(2, 101, nSrcTab)); // C102
7302 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 100, nSrcTab));
7303 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 100, nSrcTab));
7304 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 100, nSrcTab));
7305 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 101, nSrcTab));
7306 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 101, nSrcTab));
7307 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(2, 101, nSrcTab));
7310 void TestCopyPaste::executeReferencedCutRangesRow(const bool bTransposed, const SCTAB nSrcTab,
7311 const SCTAB nDestTab, const bool bUndo,
7312 std::unique_ptr<ScUndoCut>& pUndoCut,
7313 std::unique_ptr<ScUndoPaste>& pUndoPaste)
7315 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
7317 for (int i = 0; i < nSrcTab; ++i)
7318 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7319 m_pDoc->InsertTab(nSrcTab, "Test");
7321 m_pDoc->SetValue(1, 1, nSrcTab, 01.0); // B2 \.
7322 m_pDoc->SetValue(2, 1, nSrcTab, 11.0); // C2 | cut
7323 m_pDoc->SetValue(3, 1, nSrcTab, 21.0); // D2 /
7324 m_pDoc->SetValue(1, 2, nSrcTab, 02.0); // B3
7325 m_pDoc->SetValue(2, 2, nSrcTab, 12.0); // C3
7326 m_pDoc->SetValue(3, 2, nSrcTab, 22.0); // D3
7327 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 3, 2, nSrcTab), "Source");
7329 // Guard values
7330 m_pDoc->SetValue(0, 0, nSrcTab, 1000.0); // A1
7331 m_pDoc->SetValue(1, 0, nSrcTab, 1001.0); // B1
7332 m_pDoc->SetValue(2, 0, nSrcTab, 1002.0); // C1
7333 m_pDoc->SetValue(3, 0, nSrcTab, 1003.0); // D1
7334 m_pDoc->SetValue(4, 0, nSrcTab, 1004.0); // E1
7335 m_pDoc->SetValue(0, 1, nSrcTab, 1010.0); // A2
7336 m_pDoc->SetValue(4, 1, nSrcTab, 1014.0); // E2
7337 m_pDoc->SetValue(0, 2, nSrcTab, 1020.0); // A3
7338 m_pDoc->SetValue(4, 2, nSrcTab, 1024.0); // E3
7339 m_pDoc->SetValue(0, 3, nSrcTab, 1030.0); // A4
7340 m_pDoc->SetValue(1, 3, nSrcTab, 1031.0); // B4
7341 m_pDoc->SetValue(2, 3, nSrcTab, 1032.0); // C4
7342 m_pDoc->SetValue(3, 3, nSrcTab, 1033.0); // D4
7343 m_pDoc->SetValue(4, 3, nSrcTab, 1034.0); // E4
7345 m_pDoc->SetString(20, 0, nSrcTab, "=A1"); // U1
7346 m_pDoc->SetString(21, 0, nSrcTab, "=B1"); // V1
7347 m_pDoc->SetString(22, 0, nSrcTab, "=C1"); // W1
7348 m_pDoc->SetString(23, 0, nSrcTab, "=D1"); // X1
7349 m_pDoc->SetString(24, 0, nSrcTab, "=E1"); // Y1
7350 m_pDoc->SetString(20, 1, nSrcTab, "=A2"); // U2
7351 m_pDoc->SetString(24, 1, nSrcTab, "=E2"); // Y2
7352 m_pDoc->SetString(20, 2, nSrcTab, "=A3"); // U3
7353 m_pDoc->SetString(24, 2, nSrcTab, "=E3"); // Y3
7354 m_pDoc->SetString(20, 3, nSrcTab, "=A4"); // U4
7355 m_pDoc->SetString(21, 3, nSrcTab, "=B4"); // B4
7356 m_pDoc->SetString(22, 3, nSrcTab, "=C4"); // W4
7357 m_pDoc->SetString(23, 3, nSrcTab, "=D4"); // X4
7358 m_pDoc->SetString(24, 3, nSrcTab, "=E4"); // Y4
7360 // Cell position is used for ranges relative to current position
7361 ScAddress cellA1(0, 0, nSrcTab);
7362 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2", cellA1, "$Test.$B$2"));
7363 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2", cellA1, "$Test.$C$2"));
7364 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_D2", cellA1, "$Test.$D$2"));
7365 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3", cellA1, "$Test.$B$3"));
7366 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C3", cellA1, "$Test.$C$3"));
7367 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_D3", cellA1, "$Test.$D$3"));
7368 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_D2", cellA1, "$Test.$B$2:$D$2"));
7369 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3_D3", cellA1, "$Test.$B$3:$D$3"));
7370 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_D3", cellA1, "$Test.$B$2:$D$3"));
7371 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("RelRange_Cm20_R0", ScAddress(1, 21, nSrcTab), "B2"));
7373 m_pDoc->SetString(0, 20, nSrcTab, "=B2"); // A21
7374 m_pDoc->SetString(1, 20, nSrcTab, "=C2"); // B21
7375 m_pDoc->SetString(2, 20, nSrcTab, "=D2"); // C21
7376 m_pDoc->SetString(0, 21, nSrcTab, "=B3"); // A22
7377 m_pDoc->SetString(1, 21, nSrcTab, "=C3"); // B22
7378 m_pDoc->SetString(2, 21, nSrcTab, "=D3"); // C22
7380 m_pDoc->SetString(0, 30, nSrcTab, "=$B$2"); // A31
7381 m_pDoc->SetString(1, 30, nSrcTab, "=$C$2"); // B31
7382 m_pDoc->SetString(2, 30, nSrcTab, "=$D$2"); // C31
7383 m_pDoc->SetString(0, 31, nSrcTab, "=$B$3"); // A32
7384 m_pDoc->SetString(1, 31, nSrcTab, "=$C$3"); // B32
7385 m_pDoc->SetString(2, 31, nSrcTab, "=$D$3"); // C32
7387 m_pDoc->SetString(0, 40, nSrcTab, "=Range_B2"); // A41
7388 m_pDoc->SetString(1, 40, nSrcTab, "=Range_C2"); // B41
7389 m_pDoc->SetString(2, 40, nSrcTab, "=Range_D2"); // C41
7390 m_pDoc->SetString(0, 41, nSrcTab, "=Range_B3"); // A42
7391 m_pDoc->SetString(1, 41, nSrcTab, "=Range_C3"); // B42
7392 m_pDoc->SetString(2, 41, nSrcTab, "=Range_D3"); // C42
7394 m_pDoc->SetString(0, 50, nSrcTab, "=RelRange_Cm20_R0"); // A51
7395 m_pDoc->SetString(1, 50, nSrcTab, "=RelRange_Cm20_R0"); // B51
7396 m_pDoc->SetString(2, 50, nSrcTab, "=RelRange_Cm20_R0"); // C51
7397 m_pDoc->SetString(0, 51, nSrcTab, "=RelRange_Cm20_R0"); // A52
7398 m_pDoc->SetString(1, 51, nSrcTab, "=RelRange_Cm20_R0"); // B52
7399 m_pDoc->SetString(2, 51, nSrcTab, "=RelRange_Cm20_R0"); // C52
7401 m_pDoc->SetString(0, 60, nSrcTab, "=SUM(B2:D2)"); // A61
7402 m_pDoc->SetString(1, 60, nSrcTab, "=SUM(B2:D2)"); // B61
7403 m_pDoc->SetString(2, 60, nSrcTab, "=SUM(B2:D2)"); // C61
7404 m_pDoc->SetString(0, 61, nSrcTab, "=SUM(B3:D3)"); // A62
7405 m_pDoc->SetString(1, 61, nSrcTab, "=SUM(B3:D3)"); // B62
7406 m_pDoc->SetString(2, 61, nSrcTab, "=SUM(B3:D3)"); // C62
7408 m_pDoc->SetString(0, 70, nSrcTab, "=SUM($B$2:$D$2)"); // A71
7409 m_pDoc->SetString(1, 70, nSrcTab, "=SUM($B$2:$D$2)"); // B71
7410 m_pDoc->SetString(2, 70, nSrcTab, "=SUM($B$2:$D$2)"); // C71
7411 m_pDoc->SetString(0, 71, nSrcTab, "=SUM($B$3:$D$3)"); // A72
7412 m_pDoc->SetString(1, 71, nSrcTab, "=SUM($B$3:$D$3)"); // B72
7413 m_pDoc->SetString(2, 71, nSrcTab, "=SUM($B$3:$D$3)"); // C72
7415 m_pDoc->SetString(0, 80, nSrcTab, "=SUM(Range_B2_D2)"); // A81
7416 m_pDoc->SetString(1, 80, nSrcTab, "=SUM(Range_B2_D2)"); // B81
7417 m_pDoc->SetString(2, 80, nSrcTab, "=SUM(Range_B2_D2)"); // C81
7418 m_pDoc->SetString(0, 81, nSrcTab, "=SUM(Range_B3_D3)"); // A82
7419 m_pDoc->SetString(1, 81, nSrcTab, "=SUM(Range_B3_D3)"); // B82
7420 m_pDoc->SetString(2, 81, nSrcTab, "=SUM(Range_B3_D3)"); // C82
7422 m_pDoc->SetString(0, 90, nSrcTab, "=SUM($B$2:$D$3)"); // A91
7423 m_pDoc->SetString(1, 90, nSrcTab, "=SUM($B$2:$D$3)"); // B91
7424 m_pDoc->SetString(2, 90, nSrcTab, "=SUM($B$2:$D$3)"); // C91
7425 m_pDoc->SetString(0, 91, nSrcTab, "=SUM($B$2:$D$3)"); // A92
7426 m_pDoc->SetString(1, 91, nSrcTab, "=SUM($B$2:$D$3)"); // B92
7427 m_pDoc->SetString(2, 91, nSrcTab, "=SUM($B$2:$D$3)"); // C92
7429 m_pDoc->SetString(0, 100, nSrcTab, "=SUM(Range_B2_D3)"); // A101
7430 m_pDoc->SetString(1, 100, nSrcTab, "=SUM(Range_B2_D3)"); // B101
7431 m_pDoc->SetString(2, 100, nSrcTab, "=SUM(Range_B2_D3)"); // C101
7432 m_pDoc->SetString(0, 101, nSrcTab, "=SUM(Range_B2_D3)"); // A102
7433 m_pDoc->SetString(1, 101, nSrcTab, "=SUM(Range_B2_D3)"); // B102
7434 m_pDoc->SetString(2, 101, nSrcTab, "=SUM(Range_B2_D3)"); // C102
7436 // Check precondition
7437 checkReferencedCutRangesRowIntitial(nSrcTab, "Initial");
7439 // Cut values B2:D2 to the clip document.
7440 ScDocument aClipDoc(SCDOCMODE_CLIP);
7441 ScRange aSrcRange(1, 1, nSrcTab, 3, 1, nSrcTab);
7442 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
7443 aSrcMark.SetMarkArea(aSrcRange);
7445 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, bUndo));
7447 for (int i = nSrcTab + 1; i < nDestTab; ++i)
7448 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7450 if (nSrcTab < nDestTab)
7451 m_pDoc->InsertTab(nDestTab, "Dest");
7452 else if (nSrcTab > nDestTab)
7453 m_pDoc->RenameTab(nDestTab, "Dest");
7455 int nTabCount = m_pDoc->GetTableCount();
7456 for (int i = nTabCount; i < nTabCount + 2; ++i)
7457 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
7458 nTabCount = m_pDoc->GetTableCount();
7460 InsertDeleteFlags aFlags(InsertDeleteFlags::ALL);
7462 ScDocumentUniquePtr pPasteUndoDoc;
7463 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
7464 std::unique_ptr<ScRefUndoData> pUndoData;
7466 ScRange aDestRange;
7467 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
7469 if (bTransposed)
7471 // To C12:C14
7472 aDestRange = ScRange(2, 11, nDestTab, 2, 13, nDestTab);
7473 aDestMark.SetMarkArea(aDestRange);
7475 if (bUndo)
7476 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
7477 pUndoData);
7479 // Transpose
7480 ScDocument* pOrigClipDoc = &aClipDoc;
7481 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
7482 aClipDoc.TransposeClip(pTransClip.get(), aFlags, false, true);
7483 // Paste
7484 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
7485 pTransClip.get(), true, false, true, false);
7486 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7487 "Relative references after copy"_ostr);
7489 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, pPasteRefUndoDoc.get());
7490 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
7491 "Relative references after UpdateTranspose"_ostr);
7492 pTransClip.reset();
7494 else
7496 // To C12:E12
7497 aDestRange = ScRange(2, 11, nDestTab, 4, 11, nDestTab);
7499 aDestMark.SetMarkArea(aDestRange);
7501 if (bUndo)
7502 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
7503 pUndoData);
7505 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc, true,
7506 false, false, false);
7509 if (bUndo)
7510 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
7511 pUndoPaste, bTransposed);
7514 void TestCopyPaste::checkReferencedCutRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab)
7516 // Cut B2:D2 and pasted to C12:E12
7518 OUString aFBase("=");
7519 if (nSrcTab != nDestTab)
7520 aFBase += "Dest.";
7522 // Precondition
7523 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab));
7524 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 11, nDestTab));
7525 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(4, 11, nDestTab));
7526 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7527 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7528 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7530 // Guards
7531 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7532 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7533 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7534 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7535 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7536 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7537 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7538 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7539 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7540 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7541 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7542 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7543 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7544 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7545 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7546 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7547 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7548 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7549 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7550 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7551 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7552 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7553 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7554 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7555 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7556 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7557 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7558 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7559 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
7560 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
7561 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
7562 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
7563 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), m_pDoc->GetFormula(24, 0, nSrcTab)); // Y1
7564 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
7565 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), m_pDoc->GetFormula(24, 1, nSrcTab)); // Y2
7566 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
7567 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), m_pDoc->GetFormula(24, 2, nSrcTab)); // Y3
7568 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
7569 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(21, 3, nSrcTab)); // B4
7570 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(22, 3, nSrcTab)); // W4
7571 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
7572 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), m_pDoc->GetFormula(24, 3, nSrcTab)); // Y4
7574 // Note: Values (mostly) remain the same
7576 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
7577 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
7578 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 20, nSrcTab)); // C21
7579 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
7580 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
7581 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(2, 21, nSrcTab)); // C22
7582 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7583 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7584 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7585 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7586 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7587 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7589 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
7590 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$D$12"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
7591 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$E$12"), m_pDoc->GetFormula(2, 30, nSrcTab)); // C31
7592 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
7593 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
7594 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), m_pDoc->GetFormula(2, 31, nSrcTab)); // C32
7595 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7596 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7597 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7598 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7599 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7600 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7602 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
7603 getRangeByName("Range_B2"));
7604 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$D$12") : OUString("$Test.$D$12"),
7605 getRangeByName("Range_C2"));
7606 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$E$12") : OUString("$Test.$E$12"),
7607 getRangeByName("Range_D2"));
7608 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3")); // no change
7609 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3")); // no change
7610 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3")); // no change
7611 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$E$12")
7612 : OUString("$Test.$C$12:$E$12"),
7613 getRangeByName("Range_B2_D2"));
7614 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3")); // no change
7615 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3")); // no change
7616 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0")); // no change
7618 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
7619 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
7620 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), m_pDoc->GetFormula(2, 40, nSrcTab)); // C41
7621 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
7622 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
7623 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), m_pDoc->GetFormula(2, 41, nSrcTab)); // C42
7624 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7625 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7626 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7627 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7628 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7629 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7631 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
7632 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
7633 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 50, nSrcTab)); // C51
7634 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
7635 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
7636 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 51, nSrcTab)); // C52
7637 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7638 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7639 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7640 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7641 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7642 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7644 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7645 : OUString("=SUM(C12:E12)"),
7646 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
7647 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7648 : OUString("=SUM(C12:E12)"),
7649 m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
7650 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
7651 : OUString("=SUM(C12:E12)"),
7652 m_pDoc->GetFormula(2, 60, nSrcTab)); // C61
7653 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
7654 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
7655 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(2, 61, nSrcTab)); // C62
7656 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7657 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7658 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7659 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7660 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7661 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7663 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7664 : OUString("=SUM($C$12:$E$12)"),
7665 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
7666 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7667 : OUString("=SUM($C$12:$E$12)"),
7668 m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
7669 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
7670 : OUString("=SUM($C$12:$E$12)"),
7671 m_pDoc->GetFormula(2, 70, nSrcTab)); // C71
7672 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
7673 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
7674 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(2, 71, nSrcTab)); // C72
7675 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7676 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7677 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7678 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7679 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7680 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7682 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
7683 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
7684 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(2, 80, nSrcTab)); // C81
7685 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
7686 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
7687 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(2, 81, nSrcTab)); // C82
7688 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7689 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7690 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7691 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7692 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7693 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7695 // no change in formula after cut
7696 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
7697 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
7698 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 90, nSrcTab)); // C91
7699 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
7700 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
7701 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 91, nSrcTab)); // C92
7702 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab)); // only 2nd row
7703 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab)); // only 2nd row
7704 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 90, nSrcTab)); // only 2nd row
7705 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab)); // only 2nd row
7706 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab)); // only 2nd row
7707 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 91, nSrcTab)); // only 2nd row
7709 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7710 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
7711 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7712 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
7713 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7714 m_pDoc->GetFormula(2, 100, nSrcTab)); // C101
7715 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7716 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
7717 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7718 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
7719 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7720 m_pDoc->GetFormula(2, 101, nSrcTab)); // C102
7721 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab)); // only 2nd row
7722 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab)); // only 2nd row
7723 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 100, nSrcTab)); // only 2nd row
7724 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab)); // only 2nd row
7725 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab)); // only 2nd row
7726 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 101, nSrcTab)); // only 2nd row
7729 void TestCopyPaste::checkReferencedCutTransposedRangesRow(const SCTAB nSrcTab, const SCTAB nDestTab)
7731 // Cut B2:D2 and pasted transposed to C12:C14
7733 OUString aFBase("=");
7734 if (nSrcTab != nDestTab)
7735 aFBase += "Dest.";
7737 // Precondition
7738 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab));
7739 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 12, nDestTab));
7740 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 13, nDestTab));
7741 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 2, nSrcTab));
7742 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
7743 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(3, 2, nSrcTab));
7745 // Guards
7746 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
7747 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
7748 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
7749 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
7750 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(4, 0, nSrcTab)); // E1
7751 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
7752 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(4, 1, nSrcTab)); // E2
7753 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
7754 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(4, 2, nSrcTab)); // E3
7755 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
7756 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(1, 3, nSrcTab)); // B4
7757 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
7758 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
7759 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(4, 3, nSrcTab)); // E4
7760 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
7761 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
7762 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
7763 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
7764 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(24, 0, nSrcTab)); // Y1
7765 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
7766 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(24, 1, nSrcTab)); // Y2
7767 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
7768 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(24, 2, nSrcTab)); // Y3
7769 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
7770 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(21, 3, nSrcTab)); // B4
7771 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(22, 3, nSrcTab)); // W4
7772 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
7773 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(24, 3, nSrcTab)); // Y4
7774 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
7775 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
7776 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
7777 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
7778 CPPUNIT_ASSERT_EQUAL(OUString("=E1"), m_pDoc->GetFormula(24, 0, nSrcTab)); // Y1
7779 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
7780 CPPUNIT_ASSERT_EQUAL(OUString("=E2"), m_pDoc->GetFormula(24, 1, nSrcTab)); // Y2
7781 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
7782 CPPUNIT_ASSERT_EQUAL(OUString("=E3"), m_pDoc->GetFormula(24, 2, nSrcTab)); // Y3
7783 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
7784 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(21, 3, nSrcTab)); // B4
7785 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(22, 3, nSrcTab)); // W4
7786 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
7787 CPPUNIT_ASSERT_EQUAL(OUString("=E4"), m_pDoc->GetFormula(24, 3, nSrcTab)); // Y4
7789 // Note: Values (mostly) remain the same
7791 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
7792 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 20, nSrcTab));
7793 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 20, nSrcTab));
7794 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 21, nSrcTab));
7795 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
7796 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 21, nSrcTab));
7798 // ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 20, nSrcTab), "C12", "Wrong reference");
7799 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab));
7800 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(1, 20, nSrcTab));
7801 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(2, 20, nSrcTab));
7802 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab));
7803 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab));
7804 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(2, 21, nSrcTab));
7806 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
7807 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 30, nSrcTab));
7808 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 30, nSrcTab));
7809 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 31, nSrcTab));
7810 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
7811 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 31, nSrcTab));
7813 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab));
7814 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$13"), m_pDoc->GetFormula(1, 30, nSrcTab));
7815 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$14"), m_pDoc->GetFormula(2, 30, nSrcTab));
7816 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab));
7817 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab));
7818 CPPUNIT_ASSERT_EQUAL(OUString("=$D$3"), m_pDoc->GetFormula(2, 31, nSrcTab));
7820 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
7821 getRangeByName("Range_B2"));
7822 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$13") : OUString("$Test.$C$13"),
7823 getRangeByName("Range_C2"));
7824 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$14") : OUString("$Test.$C$14"),
7825 getRangeByName("Range_D2"));
7826 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3")); // no change
7827 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3")); // no change
7828 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$D$3"), getRangeByName("Range_D3")); // no change
7829 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$C$14")
7830 : OUString("$Test.$C$12:$C$14"),
7831 getRangeByName("Range_B2_D2"));
7832 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3:$D$3"), getRangeByName("Range_B3_D3")); // no change
7833 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$D$3"), getRangeByName("Range_B2_D3")); // no change
7834 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0")); // no change
7836 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
7837 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
7838 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D2"), m_pDoc->GetFormula(2, 40, nSrcTab)); // C41
7839 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
7840 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
7841 CPPUNIT_ASSERT_EQUAL(OUString("=Range_D3"), m_pDoc->GetFormula(2, 41, nSrcTab)); // C42
7842 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
7843 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 40, nSrcTab));
7844 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 40, nSrcTab));
7845 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 41, nSrcTab));
7846 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
7847 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 41, nSrcTab));
7849 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
7850 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
7851 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 50, nSrcTab)); // C51
7852 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
7853 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
7854 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(2, 51, nSrcTab)); // C52
7855 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
7856 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 50, nSrcTab));
7857 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 50, nSrcTab));
7858 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(0, 51, nSrcTab));
7859 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
7860 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 51, nSrcTab));
7862 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
7863 : OUString("=SUM(C12:C14)"),
7864 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
7865 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
7866 : OUString("=SUM(C12:C14)"),
7867 m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
7868 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
7869 : OUString("=SUM(C12:C14)"),
7870 m_pDoc->GetFormula(2, 60, nSrcTab)); // C61
7871 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
7872 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
7873 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B3:D3)"), m_pDoc->GetFormula(2, 61, nSrcTab)); // C62
7874 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
7875 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 60, nSrcTab));
7876 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 60, nSrcTab));
7877 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 61, nSrcTab));
7878 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
7879 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 61, nSrcTab));
7881 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
7882 : OUString("=SUM($C$12:$C$14)"),
7883 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
7884 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
7885 : OUString("=SUM($C$12:$C$14)"),
7886 m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
7887 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
7888 : OUString("=SUM($C$12:$C$14)"),
7889 m_pDoc->GetFormula(2, 70, nSrcTab)); // C71
7890 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
7891 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
7892 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$3:$D$3)"), m_pDoc->GetFormula(2, 71, nSrcTab)); // C72
7893 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
7894 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 70, nSrcTab));
7895 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 70, nSrcTab));
7896 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 71, nSrcTab));
7897 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
7898 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 71, nSrcTab));
7900 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
7901 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
7902 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D2)"), m_pDoc->GetFormula(2, 80, nSrcTab)); // C81
7903 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
7904 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
7905 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B3_D3)"), m_pDoc->GetFormula(2, 81, nSrcTab)); // C82
7906 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
7907 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(1, 80, nSrcTab));
7908 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(2, 80, nSrcTab));
7909 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 81, nSrcTab));
7910 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
7911 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 81, nSrcTab));
7913 // no change in formula after cut
7914 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
7915 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
7916 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 90, nSrcTab)); // C91
7917 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
7918 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
7919 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$D$3)"), m_pDoc->GetFormula(2, 91, nSrcTab)); // C92
7920 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab)); // only 2nd row
7921 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab)); // only 2nd row
7922 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 90, nSrcTab)); // only 2nd row
7923 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab)); // only 2nd row
7924 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab)); // only 2nd row
7925 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 91, nSrcTab)); // only 2nd row
7927 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7928 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
7929 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7930 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
7931 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7932 m_pDoc->GetFormula(2, 100, nSrcTab)); // C101
7933 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7934 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
7935 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7936 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
7937 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_D3)"),
7938 m_pDoc->GetFormula(2, 101, nSrcTab)); // C102
7939 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab)); // only 2nd row
7940 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab)); // only 2nd row
7941 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 100, nSrcTab)); // only 2nd row
7942 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab)); // only 2nd row
7943 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab)); // only 2nd row
7944 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(2, 101, nSrcTab)); // only 2nd row
7947 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutRangesRow)
7949 const SCTAB nSrcTab = 0;
7950 const SCTAB nDestTab = 2;
7951 std::unique_ptr<ScUndoCut> pUndoCut;
7952 std::unique_ptr<ScUndoPaste> pUndoPaste;
7953 executeReferencedCutRangesRow(false, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
7954 checkReferencedCutRangesRow(nSrcTab, nDestTab);
7956 pUndoPaste->Undo();
7957 pUndoCut->Undo();
7958 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
7960 pUndoCut->Redo();
7961 pUndoPaste->Redo();
7962 checkReferencedCutRangesRow(nSrcTab, nDestTab);
7964 pUndoPaste->Undo();
7965 pUndoCut->Undo();
7966 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
7968 pUndoPaste.reset();
7969 pUndoCut.reset();
7971 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
7972 m_pDoc->DeleteTab(i - 1);
7975 // tdf#142201
7976 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesRowTab0To0)
7978 checkReferencedCutTransposedRangesRowUndo(0, 0);
7981 // tdf#142201
7982 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesRowTab0To1)
7984 checkReferencedCutTransposedRangesRowUndo(0, 1);
7987 // tdf#142201
7988 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesRowTab1To3)
7990 checkReferencedCutTransposedRangesRowUndo(1, 3);
7993 // tdf#142201
7994 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesRowTab3To1)
7996 checkReferencedCutTransposedRangesRowUndo(3, 1);
7999 // tdf#142201
8000 void TestCopyPaste::checkReferencedCutTransposedRangesRowUndo(const SCTAB nSrcTab,
8001 const SCTAB nDestTab)
8003 std::unique_ptr<ScUndoCut> pUndoCut;
8004 std::unique_ptr<ScUndoPaste> pUndoPaste;
8005 executeReferencedCutRangesRow(true, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8006 checkReferencedCutTransposedRangesRow(nSrcTab, nDestTab);
8008 pUndoPaste->Undo();
8009 pUndoCut->Undo();
8010 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8012 pUndoCut->Redo();
8013 pUndoPaste->Redo();
8014 checkReferencedCutTransposedRangesRow(nSrcTab, nDestTab);
8016 pUndoPaste->Undo();
8017 pUndoCut->Undo();
8018 checkReferencedCutRangesRowIntitial(nSrcTab, "After undo");
8020 pUndoPaste.reset();
8021 pUndoCut.reset();
8023 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
8024 m_pDoc->DeleteTab(i - 1);
8027 void TestCopyPaste::checkReferencedCutRangesColIntitial(const SCTAB nSrcTab, const SCTAB nDestTab,
8028 const OUString& rDesc)
8030 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 2, 3, nSrcTab), rDesc.toUtf8() + ": Source");
8031 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(1, 1, nSrcTab));
8032 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 2, nSrcTab));
8033 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(1, 3, nSrcTab));
8034 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab));
8035 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab));
8036 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab));
8038 // Guards
8039 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8040 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8041 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8042 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8043 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8044 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8045 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8046 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8047 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8048 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8049 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8050 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8051 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8052 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8053 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8054 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8055 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8056 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8057 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8058 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8059 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8060 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8061 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8062 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8063 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8064 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8065 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8066 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8067 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
8068 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
8069 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
8070 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
8071 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), m_pDoc->GetFormula(20, 4, nSrcTab)); // U5
8072 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
8073 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), m_pDoc->GetFormula(21, 4, nSrcTab)); // V5
8074 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
8075 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(22, 4, nSrcTab)); // W5
8076 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
8077 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(23, 1, nSrcTab)); // X2
8078 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(23, 2, nSrcTab)); // X3
8079 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
8080 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), m_pDoc->GetFormula(23, 4, nSrcTab)); // X5
8082 for (int i = 10; i < 20; ++i)
8083 for (int j = 0; j < 10; ++j)
8085 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(j, i, nSrcTab));
8086 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(j, i, nSrcTab));
8089 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 1, 22, nSrcTab),
8090 rDesc.toUtf8() + ": Relative references");
8091 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
8092 CPPUNIT_ASSERT_EQUAL(OUString("=B3"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
8093 CPPUNIT_ASSERT_EQUAL(OUString("=B4"), m_pDoc->GetFormula(0, 22, nSrcTab)); // A23
8094 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
8095 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
8096 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(1, 22, nSrcTab)); // B23
8097 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8098 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8099 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8100 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8101 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8102 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8104 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 30, nSrcTab, 1, 32, nSrcTab),
8105 rDesc.toUtf8() + ": Absolute references");
8106 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
8107 CPPUNIT_ASSERT_EQUAL(OUString("=$B$3"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
8108 CPPUNIT_ASSERT_EQUAL(OUString("=$B$4"), m_pDoc->GetFormula(0, 32, nSrcTab)); // A33
8109 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
8110 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
8111 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), m_pDoc->GetFormula(1, 32, nSrcTab)); // B33
8112 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8113 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8114 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8115 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8116 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8117 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8119 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2"), getRangeByName("Range_B2"));
8120 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$3"), getRangeByName("Range_B3"));
8121 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$4"), getRangeByName("Range_B4"));
8122 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8123 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8124 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8125 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$B$4"), getRangeByName("Range_B2_B4"));
8126 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8127 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8128 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8130 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 40, nSrcTab, 1, 42, nSrcTab),
8131 rDesc.toUtf8() + ": Absolute ranges");
8132 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
8133 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
8134 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), m_pDoc->GetFormula(0, 42, nSrcTab)); // A43
8135 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
8136 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
8137 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), m_pDoc->GetFormula(1, 42, nSrcTab)); // B43
8138 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8139 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8140 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8141 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8142 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8143 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8145 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 50, nSrcTab, 1, 52, nSrcTab),
8146 rDesc.toUtf8() + ": Relative ranges");
8147 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
8148 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
8149 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 52, nSrcTab)); // A53
8150 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
8151 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
8152 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 52, nSrcTab)); // B53
8153 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8154 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8155 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8156 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8157 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8158 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8160 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 60, nSrcTab, 1, 62, nSrcTab),
8161 rDesc.toUtf8() + ": Relative sum");
8162 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
8163 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
8164 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B2:B4)"), m_pDoc->GetFormula(0, 62, nSrcTab)); // A63
8165 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
8166 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
8167 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 62, nSrcTab)); // B63
8168 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8169 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8170 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8171 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8172 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8173 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8175 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 70, nSrcTab, 1, 72, nSrcTab),
8176 rDesc.toUtf8() + ": Absolute sum");
8177 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
8178 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
8179 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$B$4)"), m_pDoc->GetFormula(0, 72, nSrcTab)); // A73
8180 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
8181 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
8182 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 72, nSrcTab)); // B73
8183 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8184 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8185 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8186 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8187 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8188 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8190 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 80, nSrcTab, 1, 82, nSrcTab),
8191 rDesc.toUtf8() + ": Relative range sum");
8192 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
8193 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
8194 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 82, nSrcTab)); // A83
8195 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
8196 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
8197 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 82, nSrcTab)); // B83
8198 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8199 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8200 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8201 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8202 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8203 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8205 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 90, nSrcTab, 1, 92, nSrcTab),
8206 rDesc.toUtf8() + ": Absolute sum");
8207 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
8208 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
8209 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 92, nSrcTab)); // A93
8210 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
8211 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
8212 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 92, nSrcTab)); // B93
8213 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 90, nSrcTab));
8214 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 91, nSrcTab));
8215 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 92, nSrcTab));
8216 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 90, nSrcTab));
8217 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 91, nSrcTab));
8218 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 92, nSrcTab));
8220 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 100, nSrcTab, 1, 102, nSrcTab),
8221 rDesc.toUtf8() + ": Relative range sum");
8222 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8223 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
8224 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8225 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
8226 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8227 m_pDoc->GetFormula(0, 102, nSrcTab)); // A103
8228 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8229 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
8230 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8231 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
8232 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8233 m_pDoc->GetFormula(1, 102, nSrcTab)); // B103
8234 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 100, nSrcTab));
8235 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 101, nSrcTab));
8236 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(0, 102, nSrcTab));
8237 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 100, nSrcTab));
8238 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 101, nSrcTab));
8239 CPPUNIT_ASSERT_EQUAL(69.0, m_pDoc->GetValue(1, 102, nSrcTab));
8241 // References to the dest range
8242 OUString aFBase("=");
8243 if (nSrcTab != nDestTab)
8244 aFBase += "Dest.";
8246 // Existing references to the destination range must not change
8247 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 112, nSrcTab));
8248 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 113, nSrcTab));
8249 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 114, nSrcTab));
8250 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 112, nSrcTab));
8251 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), m_pDoc->GetFormula(1, 113, nSrcTab));
8252 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), m_pDoc->GetFormula(1, 114, nSrcTab));
8253 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 112, nSrcTab));
8254 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), m_pDoc->GetFormula(2, 113, nSrcTab));
8255 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), m_pDoc->GetFormula(2, 114, nSrcTab));
8258 void TestCopyPaste::executeReferencedCutRangesCol(const bool bTransposed, const SCTAB nSrcTab,
8259 const SCTAB nDestTab, const bool bUndo,
8260 std::unique_ptr<ScUndoCut>& pUndoCut,
8261 std::unique_ptr<ScUndoPaste>& pUndoPaste)
8263 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
8265 for (int i = 0; i < nSrcTab; ++i)
8266 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8267 m_pDoc->InsertTab(nSrcTab, "Test");
8269 m_pDoc->SetValue(1, 1, nSrcTab, 01.0); // B2 \.
8270 m_pDoc->SetValue(1, 2, nSrcTab, 11.0); // B3 | cut
8271 m_pDoc->SetValue(1, 3, nSrcTab, 21.0); // B4 /
8272 m_pDoc->SetValue(2, 1, nSrcTab, 02.0); // C2
8273 m_pDoc->SetValue(2, 2, nSrcTab, 12.0); // C3
8274 m_pDoc->SetValue(2, 3, nSrcTab, 22.0); // C4
8275 printRange(m_pDoc, ScRange(1, 1, nSrcTab, 2, 3, nSrcTab), "Source");
8277 // Guard values
8278 m_pDoc->SetValue(0, 0, nSrcTab, 1000.0); // A1
8279 m_pDoc->SetValue(0, 1, nSrcTab, 1001.0); // A2
8280 m_pDoc->SetValue(0, 2, nSrcTab, 1002.0); // A3
8281 m_pDoc->SetValue(0, 3, nSrcTab, 1003.0); // A4
8282 m_pDoc->SetValue(0, 4, nSrcTab, 1004.0); // A5
8283 m_pDoc->SetValue(1, 0, nSrcTab, 1010.0); // B1
8284 m_pDoc->SetValue(1, 4, nSrcTab, 1014.0); // B5
8285 m_pDoc->SetValue(2, 0, nSrcTab, 1020.0); // C1
8286 m_pDoc->SetValue(2, 4, nSrcTab, 1024.0); // C5
8287 m_pDoc->SetValue(3, 0, nSrcTab, 1030.0); // D1
8288 m_pDoc->SetValue(3, 1, nSrcTab, 1031.0); // D2
8289 m_pDoc->SetValue(3, 2, nSrcTab, 1032.0); // D3
8290 m_pDoc->SetValue(3, 3, nSrcTab, 1033.0); // D4
8291 m_pDoc->SetValue(3, 4, nSrcTab, 1034.0); // D5
8293 m_pDoc->SetString(20, 0, nSrcTab, "=A1"); // U1
8294 m_pDoc->SetString(20, 1, nSrcTab, "=A2"); // U2
8295 m_pDoc->SetString(20, 2, nSrcTab, "=A3"); // U3
8296 m_pDoc->SetString(20, 3, nSrcTab, "=A4"); // U4
8297 m_pDoc->SetString(20, 4, nSrcTab, "=A5"); // U5
8298 m_pDoc->SetString(21, 0, nSrcTab, "=B1"); // V1
8299 m_pDoc->SetString(21, 4, nSrcTab, "=B5"); // V5
8300 m_pDoc->SetString(22, 0, nSrcTab, "=C1"); // W1
8301 m_pDoc->SetString(22, 4, nSrcTab, "=C5"); // W5
8302 m_pDoc->SetString(23, 0, nSrcTab, "=D1"); // X1
8303 m_pDoc->SetString(23, 1, nSrcTab, "=D2"); // X2
8304 m_pDoc->SetString(23, 2, nSrcTab, "=D3"); // X3
8305 m_pDoc->SetString(23, 3, nSrcTab, "=D4"); // X4
8306 m_pDoc->SetString(23, 4, nSrcTab, "=D5"); // X5
8308 // Cell position is used for ranges relative to current position
8309 ScAddress cellA1(0, 0, nSrcTab);
8310 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2", cellA1, "$Test.$B$2"));
8311 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B3", cellA1, "$Test.$B$3"));
8312 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B4", cellA1, "$Test.$B$4"));
8313 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2", cellA1, "$Test.$C$2"));
8314 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C3", cellA1, "$Test.$C$3"));
8315 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C4", cellA1, "$Test.$C$4"));
8316 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_B4", cellA1, "$Test.$B$2:$B$4"));
8317 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_C2_C4", cellA1, "$Test.$C$2:$C$4"));
8318 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("Range_B2_C4", cellA1, "$Test.$B$2:$C$4"));
8319 CPPUNIT_ASSERT(m_pDoc->InsertNewRangeName("RelRange_Cm20_R0", ScAddress(1, 21, nSrcTab), "B2"));
8321 m_pDoc->SetString(0, 20, nSrcTab, "=B2"); // A21
8322 m_pDoc->SetString(0, 21, nSrcTab, "=B3"); // A22
8323 m_pDoc->SetString(0, 22, nSrcTab, "=B4"); // A23
8324 m_pDoc->SetString(1, 20, nSrcTab, "=C2"); // B21
8325 m_pDoc->SetString(1, 21, nSrcTab, "=C3"); // B22
8326 m_pDoc->SetString(1, 22, nSrcTab, "=C4"); // B23
8328 m_pDoc->SetString(0, 30, nSrcTab, "=$B$2"); // A31
8329 m_pDoc->SetString(0, 31, nSrcTab, "=$B$3"); // A32
8330 m_pDoc->SetString(0, 32, nSrcTab, "=$B$4"); // A33
8331 m_pDoc->SetString(1, 30, nSrcTab, "=$C$2"); // B31
8332 m_pDoc->SetString(1, 31, nSrcTab, "=$C$3"); // B32
8333 m_pDoc->SetString(1, 32, nSrcTab, "=$C$4"); // B33
8335 m_pDoc->SetString(0, 40, nSrcTab, "=Range_B2"); // A41
8336 m_pDoc->SetString(0, 41, nSrcTab, "=Range_B3"); // A42
8337 m_pDoc->SetString(0, 42, nSrcTab, "=Range_B4"); // A43
8338 m_pDoc->SetString(1, 40, nSrcTab, "=Range_C2"); // B41
8339 m_pDoc->SetString(1, 41, nSrcTab, "=Range_C3"); // B42
8340 m_pDoc->SetString(1, 42, nSrcTab, "=Range_C4"); // B43
8342 m_pDoc->SetString(0, 50, nSrcTab, "=RelRange_Cm20_R0"); // A51
8343 m_pDoc->SetString(0, 51, nSrcTab, "=RelRange_Cm20_R0"); // A52
8344 m_pDoc->SetString(0, 52, nSrcTab, "=RelRange_Cm20_R0"); // A53
8345 m_pDoc->SetString(1, 50, nSrcTab, "=RelRange_Cm20_R0"); // B51
8346 m_pDoc->SetString(1, 51, nSrcTab, "=RelRange_Cm20_R0"); // B52
8347 m_pDoc->SetString(1, 52, nSrcTab, "=RelRange_Cm20_R0"); // B53
8349 m_pDoc->SetString(0, 60, nSrcTab, "=SUM(B2:B4"); // A61
8350 m_pDoc->SetString(0, 61, nSrcTab, "=SUM(B2:B4"); // A62
8351 m_pDoc->SetString(0, 62, nSrcTab, "=SUM(B2:B4"); // A63
8352 m_pDoc->SetString(1, 60, nSrcTab, "=SUM(C2:C4"); // B61
8353 m_pDoc->SetString(1, 61, nSrcTab, "=SUM(C2:C4"); // B62
8354 m_pDoc->SetString(1, 62, nSrcTab, "=SUM(C2:C4"); // B63
8356 m_pDoc->SetString(0, 70, nSrcTab, "=SUM($B$2:$B$4"); // A71
8357 m_pDoc->SetString(0, 71, nSrcTab, "=SUM($B$2:$B$4"); // A72
8358 m_pDoc->SetString(0, 72, nSrcTab, "=SUM($B$2:$B$4"); // A73
8359 m_pDoc->SetString(1, 70, nSrcTab, "=SUM($C$2:$C$4"); // B71
8360 m_pDoc->SetString(1, 71, nSrcTab, "=SUM($C$2:$C$4"); // B72
8361 m_pDoc->SetString(1, 72, nSrcTab, "=SUM($C$2:$C$4"); // B73
8363 m_pDoc->SetString(0, 80, nSrcTab, "=SUM(Range_B2_B4)"); // A81
8364 m_pDoc->SetString(0, 81, nSrcTab, "=SUM(Range_B2_B4)"); // A82
8365 m_pDoc->SetString(0, 82, nSrcTab, "=SUM(Range_B2_B4)"); // A83
8366 m_pDoc->SetString(1, 80, nSrcTab, "=SUM(Range_C2_C4)"); // B81
8367 m_pDoc->SetString(1, 81, nSrcTab, "=SUM(Range_C2_C4)"); // B82
8368 m_pDoc->SetString(1, 82, nSrcTab, "=SUM(Range_C2_C4)"); // B83
8370 m_pDoc->SetString(0, 90, nSrcTab, "=SUM($B$2:$C$4"); // A91
8371 m_pDoc->SetString(0, 91, nSrcTab, "=SUM($B$2:$C$4"); // A92
8372 m_pDoc->SetString(0, 92, nSrcTab, "=SUM($B$2:$C$4"); // A93
8373 m_pDoc->SetString(1, 90, nSrcTab, "=SUM($B$2:$C$4"); // B91
8374 m_pDoc->SetString(1, 91, nSrcTab, "=SUM($B$2:$C$4"); // B92
8375 m_pDoc->SetString(1, 92, nSrcTab, "=SUM($B$2:$C$4"); // B93
8377 m_pDoc->SetString(0, 100, nSrcTab, "=SUM(Range_B2_C4"); // A101
8378 m_pDoc->SetString(0, 101, nSrcTab, "=SUM(Range_B2_C4"); // A102
8379 m_pDoc->SetString(0, 102, nSrcTab, "=SUM(Range_B2_C4"); // A103
8380 m_pDoc->SetString(1, 100, nSrcTab, "=SUM(Range_B2_C4"); // B101
8381 m_pDoc->SetString(1, 101, nSrcTab, "=SUM(Range_B2_C4"); // B102
8382 m_pDoc->SetString(1, 102, nSrcTab, "=SUM(Range_B2_C4"); // B103
8384 for (int i = nSrcTab + 1; i < nDestTab; ++i)
8385 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8387 if (nSrcTab < nDestTab)
8388 m_pDoc->InsertTab(nDestTab, "Dest");
8389 else if (nSrcTab > nDestTab)
8390 m_pDoc->RenameTab(nDestTab, "Dest");
8392 int nTabCount = m_pDoc->GetTableCount();
8393 for (int i = nTabCount; i < nTabCount + 2; ++i)
8394 m_pDoc->InsertTab(i, "Empty Tab " + OUString::number(i));
8395 nTabCount = m_pDoc->GetTableCount();
8397 // References to the dest range
8398 OUString aFBase("=");
8399 if (nSrcTab != nDestTab)
8400 aFBase += "Dest.";
8402 m_pDoc->SetString(0, 112, nSrcTab, OUString(aFBase + "C12"));
8403 m_pDoc->SetString(0, 113, nSrcTab, OUString(aFBase + "C13"));
8404 m_pDoc->SetString(0, 114, nSrcTab, OUString(aFBase + "C14"));
8405 m_pDoc->SetString(1, 112, nSrcTab, OUString(aFBase + "D12"));
8406 m_pDoc->SetString(1, 113, nSrcTab, OUString(aFBase + "D13"));
8407 m_pDoc->SetString(1, 114, nSrcTab, OUString(aFBase + "D14"));
8408 m_pDoc->SetString(2, 112, nSrcTab, OUString(aFBase + "E12"));
8409 m_pDoc->SetString(2, 113, nSrcTab, OUString(aFBase + "E13"));
8410 m_pDoc->SetString(2, 114, nSrcTab, OUString(aFBase + "E14"));
8412 // Check precondition
8413 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "Initial");
8415 // Cut values B2:B4 to the clip document.
8416 ScDocument aClipDoc(SCDOCMODE_CLIP);
8417 ScRange aSrcRange(1, 1, nSrcTab, 1, 3, nSrcTab);
8418 ScMarkData aSrcMark(m_pDoc->GetSheetLimits());
8419 aSrcMark.SetMarkArea(aSrcRange);
8421 pUndoCut.reset(cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, bUndo));
8423 InsertDeleteFlags aFlags(InsertDeleteFlags::ALL);
8425 ScDocumentUniquePtr pPasteUndoDoc;
8426 std::unique_ptr<ScDocument> pPasteRefUndoDoc;
8427 std::unique_ptr<ScRefUndoData> pUndoData;
8429 ScRange aDestRange;
8430 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
8432 if (bTransposed)
8434 // To C12:E12
8435 aDestRange = ScRange(2, 11, nDestTab, 4, 11, nDestTab);
8436 aDestMark.SetMarkArea(aDestRange);
8438 if (bUndo)
8439 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
8440 pUndoData);
8442 // Transpose
8443 ScDocument* pOrigClipDoc = &aClipDoc;
8444 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
8445 aClipDoc.TransposeClip(pTransClip.get(), aFlags, false, true);
8446 // Paste
8447 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(),
8448 pTransClip.get(), true, false, true, false);
8449 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
8450 "Relative references after copy"_ostr);
8452 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, pPasteRefUndoDoc.get());
8453 printValuesAndFormulasInRange(m_pDoc, ScRange(0, 20, nSrcTab, 2, 21, nSrcTab),
8454 "Relative references after UpdateTranspose"_ostr);
8455 pTransClip.reset();
8457 else
8459 // To C12:C14
8460 aDestRange = ScRange(2, 11, nDestTab, 2, 13, nDestTab);
8461 // aDestMark = ScMarkData(m_pDoc->GetSheetLimits());
8463 aDestMark.SetMarkArea(aDestRange);
8465 if (bUndo)
8466 prepareUndoBeforePaste(true, pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange,
8467 pUndoData);
8469 m_pDoc->CopyFromClip(aDestRange, aDestMark, aFlags, pPasteRefUndoDoc.get(), &aClipDoc, true,
8470 false, false, false);
8473 if (bUndo)
8474 prepareUndoAfterPaste(pPasteUndoDoc, pPasteRefUndoDoc, aDestMark, aDestRange, pUndoData,
8475 pUndoPaste, bTransposed);
8478 void TestCopyPaste::checkReferencedCutRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab)
8480 // Cut B2:B4 and pasted to C12:C14
8482 OUString aFBase("=");
8483 if (nSrcTab != nDestTab)
8484 aFBase += "Dest.";
8486 // Precondition
8487 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab)); // C12
8488 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(2, 12, nDestTab)); // C13
8489 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 13, nDestTab)); // C14
8490 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab)); // C2
8491 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab)); // C3
8492 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
8494 // Guards
8495 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8496 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8497 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8498 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8499 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8500 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8501 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8502 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8503 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8504 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8505 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8506 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8507 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8508 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8509 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8510 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8511 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8512 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8513 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8514 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8515 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8516 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8517 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8518 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8519 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8520 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8521 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8522 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8523 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
8524 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
8525 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
8526 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
8527 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), m_pDoc->GetFormula(20, 4, nSrcTab)); // U5
8528 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
8529 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), m_pDoc->GetFormula(21, 4, nSrcTab)); // V5
8530 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
8531 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(22, 4, nSrcTab)); // W5
8532 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
8533 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(23, 1, nSrcTab)); // X2
8534 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(23, 2, nSrcTab)); // X3
8535 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
8536 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), m_pDoc->GetFormula(23, 4, nSrcTab)); // X5
8538 // Note: Values (mostly) remain the same
8540 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
8541 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
8542 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 22, nSrcTab)); // A23
8543 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
8544 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
8545 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(1, 22, nSrcTab)); // B23
8546 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8547 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8548 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8549 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8550 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8551 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8553 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
8554 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$13"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
8555 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$14"), m_pDoc->GetFormula(0, 32, nSrcTab)); // A33
8556 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
8557 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
8558 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), m_pDoc->GetFormula(1, 32, nSrcTab)); // B33
8559 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8560 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8561 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8562 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8563 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8564 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8566 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8567 getRangeByName("Range_B2"));
8568 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$13") : OUString("$Test.$C$13"),
8569 getRangeByName("Range_B3"));
8570 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$14") : OUString("$Test.$C$14"),
8571 getRangeByName("Range_B4"));
8572 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8573 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8574 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8575 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$C$14")
8576 : OUString("$Test.$C$12:$C$14"),
8577 getRangeByName("Range_B2_B4"));
8578 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8579 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8580 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8582 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
8583 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
8584 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), m_pDoc->GetFormula(0, 42, nSrcTab)); // A43
8585 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
8586 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
8587 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), m_pDoc->GetFormula(1, 42, nSrcTab)); // B43
8588 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8589 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8590 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8591 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8592 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8593 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8595 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
8596 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
8597 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 52, nSrcTab)); // A53
8598 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
8599 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
8600 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 52, nSrcTab)); // B53
8601 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8602 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8603 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8604 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8605 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8606 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8608 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8609 : OUString("=SUM(C12:C14)"),
8610 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
8611 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8612 : OUString("=SUM(C12:C14)"),
8613 m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
8614 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:C14)")
8615 : OUString("=SUM(C12:C14)"),
8616 m_pDoc->GetFormula(0, 62, nSrcTab)); // A63
8617 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
8618 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
8619 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 62, nSrcTab)); // B63
8620 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8621 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8622 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8623 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8624 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8625 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8627 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8628 : OUString("=SUM($C$12:$C$14)"),
8629 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
8630 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8631 : OUString("=SUM($C$12:$C$14)"),
8632 m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
8633 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$C$14)")
8634 : OUString("=SUM($C$12:$C$14)"),
8635 m_pDoc->GetFormula(0, 72, nSrcTab)); // A73
8636 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
8637 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
8638 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 72, nSrcTab)); // B73
8639 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8640 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8641 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8642 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8643 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8644 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8646 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
8647 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
8648 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 82, nSrcTab)); // A83
8649 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
8650 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
8651 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 82, nSrcTab)); // B83
8652 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8653 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8654 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8655 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8656 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8657 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8659 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
8660 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
8661 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 92, nSrcTab)); // A93
8662 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
8663 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
8664 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 92, nSrcTab)); // B93
8665 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab));
8666 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab));
8667 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 92, nSrcTab));
8668 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab));
8669 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab));
8670 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 92, nSrcTab));
8672 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8673 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
8674 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8675 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
8676 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8677 m_pDoc->GetFormula(0, 102, nSrcTab)); // A103
8678 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8679 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
8680 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8681 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
8682 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8683 m_pDoc->GetFormula(1, 102, nSrcTab)); // B103
8684 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab));
8685 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab));
8686 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 102, nSrcTab));
8687 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab));
8688 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab));
8689 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 102, nSrcTab));
8691 // Existing references to the destination range must not change
8692 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 112, nSrcTab));
8693 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 113, nSrcTab));
8694 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 114, nSrcTab));
8695 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 112, nSrcTab));
8696 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), m_pDoc->GetFormula(1, 113, nSrcTab));
8697 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), m_pDoc->GetFormula(1, 114, nSrcTab));
8698 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 112, nSrcTab));
8699 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), m_pDoc->GetFormula(2, 113, nSrcTab));
8700 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), m_pDoc->GetFormula(2, 114, nSrcTab));
8703 void TestCopyPaste::checkReferencedCutTransposedRangesCol(const SCTAB nSrcTab, const SCTAB nDestTab)
8705 // Cut B2:D2 and pasted transposed to C12:E12
8707 OUString aFBase("=");
8708 if (nSrcTab != nDestTab)
8709 aFBase += "Dest.";
8711 // Precondition
8712 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(2, 11, nDestTab)); // C12
8713 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(3, 11, nDestTab)); // D12
8714 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(4, 11, nDestTab)); // E12
8715 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(2, 1, nSrcTab)); // C2
8716 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 2, nSrcTab)); // C3
8717 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 3, nSrcTab)); // C4
8719 // Guards
8720 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(0, 0, nSrcTab)); // A1
8721 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nSrcTab)); // A2
8722 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 2, nSrcTab)); // A3
8723 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(0, 3, nSrcTab)); // A4
8724 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(0, 4, nSrcTab)); // A5
8725 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(1, 0, nSrcTab)); // B1
8726 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(1, 4, nSrcTab)); // B5
8727 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(2, 0, nSrcTab)); // C1
8728 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(2, 4, nSrcTab)); // C5
8729 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(3, 0, nSrcTab)); // D1
8730 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(3, 1, nSrcTab)); // D2
8731 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(3, 2, nSrcTab)); // D3
8732 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(3, 3, nSrcTab)); // D4
8733 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(3, 4, nSrcTab)); // D5
8734 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(20, 0, nSrcTab)); // U1
8735 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(20, 1, nSrcTab)); // U2
8736 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(20, 2, nSrcTab)); // U3
8737 CPPUNIT_ASSERT_EQUAL(1003.0, m_pDoc->GetValue(20, 3, nSrcTab)); // U4
8738 CPPUNIT_ASSERT_EQUAL(1004.0, m_pDoc->GetValue(20, 4, nSrcTab)); // U5
8739 CPPUNIT_ASSERT_EQUAL(1010.0, m_pDoc->GetValue(21, 0, nSrcTab)); // V1
8740 CPPUNIT_ASSERT_EQUAL(1014.0, m_pDoc->GetValue(21, 4, nSrcTab)); // V5
8741 CPPUNIT_ASSERT_EQUAL(1020.0, m_pDoc->GetValue(22, 0, nSrcTab)); // W1
8742 CPPUNIT_ASSERT_EQUAL(1024.0, m_pDoc->GetValue(22, 4, nSrcTab)); // W5
8743 CPPUNIT_ASSERT_EQUAL(1030.0, m_pDoc->GetValue(23, 0, nSrcTab)); // X1
8744 CPPUNIT_ASSERT_EQUAL(1031.0, m_pDoc->GetValue(23, 1, nSrcTab)); // X2
8745 CPPUNIT_ASSERT_EQUAL(1032.0, m_pDoc->GetValue(23, 2, nSrcTab)); // X3
8746 CPPUNIT_ASSERT_EQUAL(1033.0, m_pDoc->GetValue(23, 3, nSrcTab)); // X4
8747 CPPUNIT_ASSERT_EQUAL(1034.0, m_pDoc->GetValue(23, 4, nSrcTab)); // X5
8748 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(20, 0, nSrcTab)); // U1
8749 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(20, 1, nSrcTab)); // U2
8750 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(20, 2, nSrcTab)); // U3
8751 CPPUNIT_ASSERT_EQUAL(OUString("=A4"), m_pDoc->GetFormula(20, 3, nSrcTab)); // U4
8752 CPPUNIT_ASSERT_EQUAL(OUString("=A5"), m_pDoc->GetFormula(20, 4, nSrcTab)); // U5
8753 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(21, 0, nSrcTab)); // V1
8754 CPPUNIT_ASSERT_EQUAL(OUString("=B5"), m_pDoc->GetFormula(21, 4, nSrcTab)); // V5
8755 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(22, 0, nSrcTab)); // W1
8756 CPPUNIT_ASSERT_EQUAL(OUString("=C5"), m_pDoc->GetFormula(22, 4, nSrcTab)); // W5
8757 CPPUNIT_ASSERT_EQUAL(OUString("=D1"), m_pDoc->GetFormula(23, 0, nSrcTab)); // X1
8758 CPPUNIT_ASSERT_EQUAL(OUString("=D2"), m_pDoc->GetFormula(23, 1, nSrcTab)); // X2
8759 CPPUNIT_ASSERT_EQUAL(OUString("=D3"), m_pDoc->GetFormula(23, 2, nSrcTab)); // X3
8760 CPPUNIT_ASSERT_EQUAL(OUString("=D4"), m_pDoc->GetFormula(23, 3, nSrcTab)); // X4
8761 CPPUNIT_ASSERT_EQUAL(OUString("=D5"), m_pDoc->GetFormula(23, 4, nSrcTab)); // X5
8763 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 20, nSrcTab)); // A21
8764 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(0, 21, nSrcTab)); // A22
8765 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(0, 22, nSrcTab)); // A23
8766 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(1, 20, nSrcTab)); // B21
8767 CPPUNIT_ASSERT_EQUAL(OUString("=C3"), m_pDoc->GetFormula(1, 21, nSrcTab)); // B22
8768 CPPUNIT_ASSERT_EQUAL(OUString("=C4"), m_pDoc->GetFormula(1, 22, nSrcTab)); // B23
8769 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 20, nSrcTab));
8770 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 21, nSrcTab));
8771 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 22, nSrcTab));
8772 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 20, nSrcTab));
8773 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 21, nSrcTab));
8774 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 22, nSrcTab));
8776 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$C$12"), m_pDoc->GetFormula(0, 30, nSrcTab)); // A31
8777 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$D$12"), m_pDoc->GetFormula(0, 31, nSrcTab)); // A32
8778 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "$E$12"), m_pDoc->GetFormula(0, 32, nSrcTab)); // A33
8779 CPPUNIT_ASSERT_EQUAL(OUString("=$C$2"), m_pDoc->GetFormula(1, 30, nSrcTab)); // B31
8780 CPPUNIT_ASSERT_EQUAL(OUString("=$C$3"), m_pDoc->GetFormula(1, 31, nSrcTab)); // B32
8781 CPPUNIT_ASSERT_EQUAL(OUString("=$C$4"), m_pDoc->GetFormula(1, 32, nSrcTab)); // B33
8782 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 30, nSrcTab));
8783 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 31, nSrcTab));
8784 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 32, nSrcTab));
8785 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 30, nSrcTab));
8786 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 31, nSrcTab));
8787 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 32, nSrcTab));
8789 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12") : OUString("$Test.$C$12"),
8790 getRangeByName("Range_B2"));
8791 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$D$12") : OUString("$Test.$D$12"),
8792 getRangeByName("Range_B3"));
8793 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$E$12") : OUString("$Test.$E$12"),
8794 getRangeByName("Range_B4"));
8795 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2"), getRangeByName("Range_C2"));
8796 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$3"), getRangeByName("Range_C3"));
8797 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$4"), getRangeByName("Range_C4"));
8798 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("$Dest.$C$12:$E$12")
8799 : OUString("$Test.$C$12:$E$12"),
8800 getRangeByName("Range_B2_B4"));
8801 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$C$2:$C$4"), getRangeByName("Range_C2_C4"));
8802 CPPUNIT_ASSERT_EQUAL(OUString("$Test.$B$2:$C$4"), getRangeByName("Range_B2_C4"));
8803 CPPUNIT_ASSERT_EQUAL(OUString("B2"), getRangeByName("RelRange_Cm20_R0"));
8805 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B2"), m_pDoc->GetFormula(0, 40, nSrcTab)); // A41
8806 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B3"), m_pDoc->GetFormula(0, 41, nSrcTab)); // A42
8807 CPPUNIT_ASSERT_EQUAL(OUString("=Range_B4"), m_pDoc->GetFormula(0, 42, nSrcTab)); // A43
8808 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C2"), m_pDoc->GetFormula(1, 40, nSrcTab)); // B41
8809 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C3"), m_pDoc->GetFormula(1, 41, nSrcTab)); // B42
8810 CPPUNIT_ASSERT_EQUAL(OUString("=Range_C4"), m_pDoc->GetFormula(1, 42, nSrcTab)); // B43
8811 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 40, nSrcTab));
8812 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 41, nSrcTab));
8813 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 42, nSrcTab));
8814 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 40, nSrcTab));
8815 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 41, nSrcTab));
8816 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 42, nSrcTab));
8818 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 50, nSrcTab)); // A51
8819 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 51, nSrcTab)); // A52
8820 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(0, 52, nSrcTab)); // A53
8821 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 50, nSrcTab)); // B51
8822 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 51, nSrcTab)); // B52
8823 CPPUNIT_ASSERT_EQUAL(OUString("=RelRange_Cm20_R0"), m_pDoc->GetFormula(1, 52, nSrcTab)); // B53
8824 CPPUNIT_ASSERT_EQUAL(01.0, m_pDoc->GetValue(0, 50, nSrcTab));
8825 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(0, 51, nSrcTab));
8826 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(0, 52, nSrcTab));
8827 CPPUNIT_ASSERT_EQUAL(02.0, m_pDoc->GetValue(1, 50, nSrcTab));
8828 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 51, nSrcTab));
8829 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(1, 52, nSrcTab));
8831 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
8832 : OUString("=SUM(C12:E12)"),
8833 m_pDoc->GetFormula(0, 60, nSrcTab)); // A61
8834 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
8835 : OUString("=SUM(C12:E12)"),
8836 m_pDoc->GetFormula(0, 61, nSrcTab)); // A62
8837 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.C12:E12)")
8838 : OUString("=SUM(C12:E12)"),
8839 m_pDoc->GetFormula(0, 62, nSrcTab)); // A63
8840 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 60, nSrcTab)); // B61
8841 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 61, nSrcTab)); // B62
8842 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C2:C4)"), m_pDoc->GetFormula(1, 62, nSrcTab)); // B63
8843 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 60, nSrcTab));
8844 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 61, nSrcTab));
8845 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 62, nSrcTab));
8846 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 60, nSrcTab));
8847 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 61, nSrcTab));
8848 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 62, nSrcTab));
8850 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
8851 : OUString("=SUM($C$12:$E$12)"),
8852 m_pDoc->GetFormula(0, 70, nSrcTab)); // A71
8853 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
8854 : OUString("=SUM($C$12:$E$12)"),
8855 m_pDoc->GetFormula(0, 71, nSrcTab)); // A72
8856 CPPUNIT_ASSERT_EQUAL(nSrcTab != nDestTab ? OUString("=SUM(Dest.$C$12:$E$12)")
8857 : OUString("=SUM($C$12:$E$12)"),
8858 m_pDoc->GetFormula(0, 72, nSrcTab)); // A73
8859 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 70, nSrcTab)); // B71
8860 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 71, nSrcTab)); // B72
8861 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($C$2:$C$4)"), m_pDoc->GetFormula(1, 72, nSrcTab)); // B73
8862 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 70, nSrcTab));
8863 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 71, nSrcTab));
8864 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 72, nSrcTab));
8865 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 70, nSrcTab));
8866 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 71, nSrcTab));
8867 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 72, nSrcTab));
8869 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 80, nSrcTab)); // A81
8870 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 81, nSrcTab)); // A82
8871 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_B4)"), m_pDoc->GetFormula(0, 82, nSrcTab)); // A83
8872 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 80, nSrcTab)); // B81
8873 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 81, nSrcTab)); // B82
8874 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_C2_C4)"), m_pDoc->GetFormula(1, 82, nSrcTab)); // B83
8875 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 80, nSrcTab));
8876 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 81, nSrcTab));
8877 CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(0, 82, nSrcTab));
8878 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 80, nSrcTab));
8879 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 81, nSrcTab));
8880 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 82, nSrcTab));
8882 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 90, nSrcTab)); // A91
8883 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 91, nSrcTab)); // A92
8884 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0, 92, nSrcTab)); // A93
8885 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 90, nSrcTab)); // B91
8886 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 91, nSrcTab)); // B92
8887 CPPUNIT_ASSERT_EQUAL(OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(1, 92, nSrcTab)); // B93
8888 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 90, nSrcTab));
8889 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 91, nSrcTab));
8890 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 92, nSrcTab));
8891 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 90, nSrcTab));
8892 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 91, nSrcTab));
8893 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 92, nSrcTab));
8895 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8896 m_pDoc->GetFormula(0, 100, nSrcTab)); // A101
8897 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8898 m_pDoc->GetFormula(0, 101, nSrcTab)); // A102
8899 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8900 m_pDoc->GetFormula(0, 102, nSrcTab)); // A103
8901 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8902 m_pDoc->GetFormula(1, 100, nSrcTab)); // B101
8903 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8904 m_pDoc->GetFormula(1, 101, nSrcTab)); // B102
8905 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(Range_B2_C4)"),
8906 m_pDoc->GetFormula(1, 102, nSrcTab)); // B103
8907 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 100, nSrcTab));
8908 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 101, nSrcTab));
8909 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(0, 102, nSrcTab));
8910 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 100, nSrcTab));
8911 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 101, nSrcTab));
8912 CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(1, 102, nSrcTab));
8914 // Existing references to the destination range must not change
8915 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C12"), m_pDoc->GetFormula(0, 112, nSrcTab));
8916 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C13"), m_pDoc->GetFormula(0, 113, nSrcTab));
8917 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "C14"), m_pDoc->GetFormula(0, 114, nSrcTab));
8918 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D12"), m_pDoc->GetFormula(1, 112, nSrcTab));
8919 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D13"), m_pDoc->GetFormula(1, 113, nSrcTab));
8920 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "D14"), m_pDoc->GetFormula(1, 114, nSrcTab));
8921 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E12"), m_pDoc->GetFormula(2, 112, nSrcTab));
8922 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E13"), m_pDoc->GetFormula(2, 113, nSrcTab));
8923 CPPUNIT_ASSERT_EQUAL(OUString(aFBase + "E14"), m_pDoc->GetFormula(2, 114, nSrcTab));
8926 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutRangesCol)
8928 const SCTAB nSrcTab = 0;
8929 const SCTAB nDestTab = 2;
8930 std::unique_ptr<ScUndoCut> pUndoCut;
8931 std::unique_ptr<ScUndoPaste> pUndoPaste;
8932 executeReferencedCutRangesCol(false, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8933 checkReferencedCutRangesCol(nSrcTab, nDestTab);
8935 pUndoPaste->Undo();
8936 pUndoCut->Undo();
8937 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
8939 pUndoCut->Redo();
8940 pUndoPaste->Redo();
8941 checkReferencedCutRangesCol(nSrcTab, nDestTab);
8943 pUndoPaste->Undo();
8944 pUndoCut->Undo();
8945 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
8947 pUndoPaste.reset();
8948 pUndoCut.reset();
8950 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
8951 m_pDoc->DeleteTab(i - 1);
8954 // tdf#142201
8955 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesColTab0To0)
8957 checkReferencedCutTransposedRangesColUndo(0, 0);
8960 // tdf#142201
8961 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesColTab0To1)
8963 checkReferencedCutTransposedRangesColUndo(0, 1);
8966 // tdf#142201
8967 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesColTab1To3)
8969 checkReferencedCutTransposedRangesColUndo(1, 3);
8972 // tdf#142201
8973 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testReferencedCutTransposedRangesColTab3To1)
8975 checkReferencedCutTransposedRangesColUndo(3, 1);
8978 // tdf#142201
8979 void TestCopyPaste::checkReferencedCutTransposedRangesColUndo(const SCTAB nSrcTab,
8980 const SCTAB nDestTab)
8982 std::unique_ptr<ScUndoCut> pUndoCut;
8983 std::unique_ptr<ScUndoPaste> pUndoPaste;
8984 executeReferencedCutRangesCol(true, nSrcTab, nDestTab, true, pUndoCut, pUndoPaste);
8985 checkReferencedCutTransposedRangesCol(nSrcTab, nDestTab);
8987 pUndoPaste->Undo();
8988 pUndoCut->Undo();
8989 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
8991 pUndoCut->Redo();
8992 pUndoPaste->Redo();
8993 checkReferencedCutTransposedRangesCol(nSrcTab, nDestTab);
8995 pUndoPaste->Undo();
8996 pUndoCut->Undo();
8997 checkReferencedCutRangesColIntitial(nSrcTab, nDestTab, "After undo");
8999 pUndoPaste.reset();
9000 pUndoCut.reset();
9002 for (int i = m_pDoc->GetTableCount(); i > 0; --i)
9003 m_pDoc->DeleteTab(i - 1);
9006 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutTransposedFormulas)
9008 const SCTAB nTab = 0;
9009 m_pDoc->InsertTab(nTab, "Test");
9011 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9012 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
9014 m_pDoc->SetString(1, 1, nTab, "=A1"); // B2
9015 m_pDoc->SetString(2, 1, nTab, "=B1"); // C2
9016 m_pDoc->SetString(3, 1, nTab, "=SUM(A1:B1)"); // D2
9017 m_pDoc->SetString(4, 1, nTab, "=$B$1"); // E2
9018 m_pDoc->SetString(5, 1, nTab, "=$B1"); // F2
9019 m_pDoc->SetString(6, 1, nTab, "=B$1"); // G2
9021 // Check precondition
9022 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(3, 1, nTab));
9024 // Cut formulas B2:G2 to the clip document.
9025 ScDocument aClipDoc(SCDOCMODE_CLIP);
9026 ScRange aSrcRange(1, 1, nTab, 6, 1, nTab);
9027 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9029 // To C3:C8
9030 ScRange aDestRange(2, 2, nTab, 2, 7, nTab);
9031 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9033 // Transpose
9034 ScDocument* pOrigClipDoc = &aClipDoc;
9035 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9036 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9037 aDestMark.SetMarkArea(aDestRange);
9038 // Paste
9039 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9040 true, false, true, false);
9041 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9042 pTransClip.reset();
9044 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(2, 2, nTab));
9045 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(2, 2, nTab));
9047 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(2, 3, nTab));
9048 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 3, nTab));
9050 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A1:B1)"), m_pDoc->GetFormula(2, 4, nTab));
9051 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 4, nTab));
9053 CPPUNIT_ASSERT_EQUAL(OUString("=$B$1"), m_pDoc->GetFormula(2, 5, nTab));
9054 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 5, nTab));
9056 CPPUNIT_ASSERT_EQUAL(OUString("=$B1"), m_pDoc->GetFormula(2, 6, nTab));
9057 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 6, nTab));
9059 CPPUNIT_ASSERT_EQUAL(OUString("=B$1"), m_pDoc->GetFormula(2, 7, nTab));
9060 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 7, nTab));
9063 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutTransposedFormulasSquare)
9065 const SCTAB nTab = 0;
9066 m_pDoc->InsertTab(nTab, "Test");
9068 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9069 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
9070 m_pDoc->SetValue(1, 0, nTab, 11.0); // B1
9071 m_pDoc->SetValue(1, 1, nTab, 12.0); // B2
9072 m_pDoc->SetValue(2, 0, nTab, 21.0); // C1
9073 m_pDoc->SetValue(2, 1, nTab, 22.0); // C2
9075 m_pDoc->SetString(0, 3, nTab, "=A1"); // A4
9076 m_pDoc->SetString(0, 4, nTab, "=A2"); // A5
9077 m_pDoc->SetString(1, 3, nTab, "=B1"); // B4
9078 m_pDoc->SetString(1, 4, nTab, "=B2"); // B5
9079 m_pDoc->SetString(2, 3, nTab, "=C1"); // C4
9080 m_pDoc->SetString(2, 4, nTab, "=C2"); // C5
9082 // Check precondition
9083 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
9084 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
9085 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 3, nTab));
9086 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(1, 4, nTab));
9087 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(2, 3, nTab));
9088 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 4, nTab));
9090 printRange(m_pDoc, ScRange(0, 0, nTab, 2, 1, nTab), "Values");
9091 printRange(m_pDoc, ScRange(0, 3, nTab, 2, 4, nTab), "Formulas");
9092 printFormula(m_pDoc, 0, 4, nTab);
9094 // Cut formulas A4:B5 to the clip document.
9095 ScDocument aClipDoc(SCDOCMODE_CLIP);
9096 ScRange aSrcRange(0, 3, nTab, 2, 4, nTab);
9097 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9099 // To B7:C9
9100 ScRange aDestRange(1, 6, nTab, 2, 8, nTab);
9101 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9103 // Transpose
9104 ScDocument* pOrigClipDoc = &aClipDoc;
9105 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9106 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9107 aDestMark.SetMarkArea(aDestRange);
9108 // Paste
9109 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9110 true, false, true, false);
9111 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9112 pTransClip.reset();
9114 printRange(m_pDoc, aDestRange, "Formulas after cut transposed");
9115 printFormula(m_pDoc, 2, 6, nTab);
9117 // Check results
9118 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 6, nTab));
9119 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 6, nTab));
9120 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(1, 7, nTab));
9121 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(2, 7, nTab));
9122 CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(1, 8, nTab));
9123 CPPUNIT_ASSERT_EQUAL(22.0, m_pDoc->GetValue(2, 8, nTab));
9125 CPPUNIT_ASSERT_EQUAL(OUString("=A1"), m_pDoc->GetFormula(1, 6, nTab));
9126 CPPUNIT_ASSERT_EQUAL(OUString("=A2"), m_pDoc->GetFormula(2, 6, nTab));
9127 CPPUNIT_ASSERT_EQUAL(OUString("=B1"), m_pDoc->GetFormula(1, 7, nTab));
9128 CPPUNIT_ASSERT_EQUAL(OUString("=B2"), m_pDoc->GetFormula(2, 7, nTab));
9129 CPPUNIT_ASSERT_EQUAL(OUString("=C1"), m_pDoc->GetFormula(1, 8, nTab));
9130 CPPUNIT_ASSERT_EQUAL(OUString("=C2"), m_pDoc->GetFormula(2, 8, nTab));
9133 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf142065)
9135 const SCTAB nTab = 0;
9136 m_pDoc->InsertTab(nTab, "Test");
9138 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
9139 m_pDoc->SetString(1, 0, nTab, "=A1"); // B1
9140 m_pDoc->SetString(2, 0, nTab, "=SUM(A1:B1)"); // C1
9141 m_pDoc->SetString(3, 0, nTab, "=$A$1"); // D1
9142 m_pDoc->SetString(4, 0, nTab, "=$A1"); // E1
9143 m_pDoc->SetString(5, 0, nTab, "=A$1"); // F1
9145 // Check precondition
9146 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2, 0, nTab));
9148 // Cut A1:F1 to the clip document.
9149 ScDocument aClipDoc(SCDOCMODE_CLIP);
9150 ScRange aSrcRange(0, 0, nTab, 5, 0, nTab);
9151 printRange(m_pDoc, aSrcRange, "Src sheet");
9152 printFormula(m_pDoc, 1, 0, nTab);
9153 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
9154 printRange(&aClipDoc, aSrcRange, "clip doc (&aClipDoc)");
9155 printFormula(&aClipDoc, 1, 0, nTab);
9157 // To A3:A9
9158 ScRange aDestRange(0, 2, nTab, 0, 7, nTab);
9159 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
9161 // Transpose
9162 ScDocument* pOrigClipDoc = &aClipDoc;
9163 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
9164 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
9165 printRange(pTransClip.get(), ScRange(0, 0, nTab, 0, 1, nTab),
9166 "transposed clip doc (pTransClip.get())");
9167 printFormula(pTransClip.get(), 0, 1, nTab);
9168 printFormula(pTransClip.get(), 1, 0, nTab);
9169 aDestMark.SetMarkArea(aDestRange);
9170 // Paste
9171 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
9172 true, false, true, false);
9173 printRange(m_pDoc, aDestRange, "dest doc");
9174 printFormula(m_pDoc, 0, 3, nTab);
9175 printRange(pOrigClipDoc, aSrcRange, "orig clip doc (pOrigClipDoc)");
9176 printFormula(pOrigClipDoc, 1, 0, nTab);
9177 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
9178 pTransClip.reset();
9179 printRange(m_pDoc, aDestRange, "dest doc after UpdateTranspose()");
9180 printFormula(m_pDoc, 0, 3, nTab);
9182 // Check results
9183 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 2, nTab));
9184 // Without the fix in place, this would have failed with
9185 // - Expected: =A3
9186 // - Actual : =#REF!#REF!
9187 CPPUNIT_ASSERT_EQUAL(OUString("=A3"), m_pDoc->GetFormula(0, 3, nTab));
9188 // Without the fix in place, this would have failed with
9189 // - Expected: 1
9190 // - Actual : #REF!
9191 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 3, nTab));
9192 // Without the fix in place, this would have failed with
9193 // - Expected: =SUM(A3:A4)
9194 // - Actual : =SUM(#REF!#REF!:#REF!#REF!)
9195 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A3:A4)"), m_pDoc->GetFormula(0, 4, nTab));
9196 // Without the fix in place, this would have failed with
9197 // - Expected: 2
9198 // - Actual : #REF!
9199 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 4, nTab));
9201 CPPUNIT_ASSERT_EQUAL(OUString("=$A$3"), m_pDoc->GetFormula(0, 5, nTab));
9202 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 5, nTab));
9204 CPPUNIT_ASSERT_EQUAL(OUString("=$A3"), m_pDoc->GetFormula(0, 6, nTab));
9205 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 6, nTab));
9207 CPPUNIT_ASSERT_EQUAL(OUString("=A$3"), m_pDoc->GetFormula(0, 7, nTab));
9208 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 7, nTab));
9211 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteMultiRange)
9213 m_pDoc->InsertTab(0, "Test");
9215 // Fill A2:B6 with numbers.
9216 for (SCROW nRow = 1; nRow <= 5; ++nRow)
9218 for (SCCOL nCol = 0; nCol <= 1; ++nCol)
9220 ScAddress aPos(nCol, nRow, 0);
9221 m_pDoc->SetValue(aPos, nRow + nCol);
9225 // Fill D9:E11 with numbers.
9226 for (SCROW nRow = 8; nRow <= 10; ++nRow)
9228 for (SCCOL nCol = 3; nCol <= 4; ++nCol)
9230 ScAddress aPos(nCol, nRow, 0);
9231 m_pDoc->SetValue(aPos, 10.0);
9235 ScMarkData aMark(m_pDoc->GetSheetLimits());
9236 aMark.SelectOneTable(0);
9238 // Copy A2:B2, A4:B4, and A6:B6 to clipboard.
9239 ScDocument aClipDoc(SCDOCMODE_CLIP);
9240 ScClipParam aClipParam;
9241 aClipParam.maRanges.push_back(ScRange(0, 1, 0, 1, 1, 0)); // A2:B2
9242 aClipParam.maRanges.push_back(ScRange(0, 3, 0, 1, 3, 0)); // A4:B4
9243 aClipParam.maRanges.push_back(ScRange(0, 5, 0, 1, 5, 0)); // A6:B6
9244 aClipParam.meDirection = ScClipParam::Row;
9245 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9247 // Paste to D9:E11, and make sure it won't crash (rhbz#1080196).
9248 m_pDoc->CopyMultiRangeFromClip(ScAddress(3, 8, 0), aMark, InsertDeleteFlags::CONTENTS,
9249 &aClipDoc);
9250 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(3, 8, 0)));
9251 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4, 8, 0)));
9252 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3, 9, 0)));
9253 CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(4, 9, 0)));
9254 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(3, 10, 0)));
9255 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(4, 10, 0)));
9257 m_pDoc->DeleteTab(0);
9260 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSkipEmpty)
9262 struct Check
9264 const char* mpStr;
9265 Color maColor;
9266 bool mbHasNote;
9269 struct TestRange
9271 ScDocument* mpDoc;
9273 explicit TestRange(ScDocument* pDoc)
9274 : mpDoc(pDoc)
9278 bool checkRange(const ScAddress& rPos, const Check* p, const Check* pEnd)
9280 ScAddress aPos(rPos);
9281 OUString aPosStr = aPos.Format(ScRefFlags::VALID);
9282 for (; p != pEnd; ++p, aPos.IncRow())
9284 if (!mpDoc->GetString(aPos).equalsAscii(p->mpStr))
9286 cerr << aPosStr << ": incorrect string value: expected='" << p->mpStr
9287 << "' actual='" << mpDoc->GetString(aPos) << endl;
9288 return false;
9291 const SvxBrushItem* pBrush = mpDoc->GetAttr(aPos, ATTR_BACKGROUND);
9292 if (!pBrush)
9294 cerr << aPosStr << ": failed to get brush item from the cell." << endl;
9295 return false;
9298 if (pBrush->GetColor() != p->maColor)
9300 Color aExpected = p->maColor;
9301 Color aActual = pBrush->GetColor();
9302 cerr << aPosStr << ": incorrect cell background color: expected=("
9303 << static_cast<int>(aExpected.GetRed()) << ","
9304 << static_cast<int>(aExpected.GetGreen()) << ","
9305 << static_cast<int>(aExpected.GetBlue()) << "), actual=("
9306 << static_cast<int>(aActual.GetRed()) << ","
9307 << static_cast<int>(aActual.GetGreen()) << ","
9308 << static_cast<int>(aActual.GetBlue()) << ")" << endl;
9310 return false;
9313 bool bHasNote = mpDoc->HasNote(aPos);
9314 if (bHasNote != p->mbHasNote)
9316 cerr << aPosStr << ": ";
9317 if (p->mbHasNote)
9318 cerr << "this cell should have a cell note, but doesn't." << endl;
9319 else
9320 cerr << "this cell should NOT have a cell note, but one is found." << endl;
9322 return false;
9326 return true;
9329 } aTest(m_pDoc);
9331 m_pDoc->InsertTab(0, "Test");
9332 m_pDoc->InitDrawLayer(m_xDocShell.get()); // for cell note objects.
9334 ScRange aSrcRange(0, 0, 0, 0, 4, 0);
9335 ScRange aDestRange(1, 0, 0, 1, 4, 0);
9337 ScMarkData aMark(m_pDoc->GetSheetLimits());
9338 aMark.SetMarkArea(aDestRange);
9340 // Put some texts in B1:B5.
9341 m_pDoc->SetString(ScAddress(1, 0, 0), "A");
9342 m_pDoc->SetString(ScAddress(1, 1, 0), "B");
9343 m_pDoc->SetString(ScAddress(1, 2, 0), "C");
9344 m_pDoc->SetString(ScAddress(1, 3, 0), "D");
9345 m_pDoc->SetString(ScAddress(1, 4, 0), "E");
9347 // Set the background color of B1:B5 to blue.
9348 ScPatternAttr aCellBackColor(m_pDoc->GetPool());
9349 aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
9350 m_pDoc->ApplyPatternAreaTab(1, 0, 1, 4, 0, aCellBackColor);
9352 // Insert notes to B1:B5.
9353 m_pDoc->GetOrCreateNote(ScAddress(1, 0, 0));
9354 m_pDoc->GetOrCreateNote(ScAddress(1, 1, 0));
9355 m_pDoc->GetOrCreateNote(ScAddress(1, 2, 0));
9356 m_pDoc->GetOrCreateNote(ScAddress(1, 3, 0));
9357 m_pDoc->GetOrCreateNote(ScAddress(1, 4, 0));
9359 // Prepare a clipboard content interleaved with empty cells.
9360 ScDocument aClipDoc(SCDOCMODE_CLIP);
9361 aClipDoc.ResetClip(m_pDoc, &aMark);
9362 ScClipParam aParam(aSrcRange, false);
9363 aClipDoc.SetClipParam(aParam);
9364 aClipDoc.SetString(ScAddress(0, 0, 0), "Clip1");
9365 aClipDoc.SetString(ScAddress(0, 2, 0), "Clip2");
9366 aClipDoc.SetString(ScAddress(0, 4, 0), "Clip3");
9368 // Set the background color of A1:A5 to yellow.
9369 aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_YELLOW, ATTR_BACKGROUND));
9370 aClipDoc.ApplyPatternAreaTab(0, 0, 0, 4, 0, aCellBackColor);
9372 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 0, 0)));
9373 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0, 1, 0)));
9374 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 2, 0)));
9375 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0, 3, 0)));
9376 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0, 4, 0)));
9378 // Check the initial condition.
9380 static const Check aChecks[] = {
9381 { "A", COL_BLUE, true }, { "B", COL_BLUE, true }, { "C", COL_BLUE, true },
9382 { "D", COL_BLUE, true }, { "E", COL_BLUE, true },
9385 bool bRes
9386 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9387 CPPUNIT_ASSERT_MESSAGE("Initial check failed.", bRes);
9390 // Create undo document.
9391 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9392 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9393 m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, *pUndoDoc, &aMark);
9395 // Paste clipboard content onto A1:A5 but skip empty cells.
9396 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, pUndoDoc.get(), &aClipDoc, true,
9397 false, false, true /*bSkipEmpty*/);
9399 // Create redo document.
9400 ScDocumentUniquePtr pRedoDoc(new ScDocument(SCDOCMODE_UNDO));
9401 pRedoDoc->InitUndo(*m_pDoc, 0, 0);
9402 m_pDoc->CopyToDocument(aDestRange, InsertDeleteFlags::ALL, false, *pRedoDoc, &aMark);
9404 // Create an undo object for this.
9405 std::unique_ptr<ScRefUndoData> pRefUndoData(new ScRefUndoData(m_pDoc));
9406 ScUndoPaste aUndo(m_xDocShell.get(), aDestRange, aMark, std::move(pUndoDoc),
9407 std::move(pRedoDoc), InsertDeleteFlags::ALL, std::move(pRefUndoData));
9409 // Check the content after the paste.
9411 // tdf#141440 - do not delete notes when pasting contents
9412 static const Check aChecks[] = {
9413 { "Clip1", COL_YELLOW, true }, { "B", COL_BLUE, true },
9414 { "Clip2", COL_YELLOW, true }, { "D", COL_BLUE, true },
9415 { "Clip3", COL_YELLOW, true },
9418 bool bRes
9419 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9420 CPPUNIT_ASSERT_MESSAGE("Check after paste failed.", bRes);
9423 // Undo, and check the content.
9424 aUndo.Undo();
9426 static const Check aChecks[] = {
9427 { "A", COL_BLUE, true }, { "B", COL_BLUE, true }, { "C", COL_BLUE, true },
9428 { "D", COL_BLUE, true }, { "E", COL_BLUE, true },
9431 bool bRes
9432 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9433 CPPUNIT_ASSERT_MESSAGE("Check after undo failed.", bRes);
9436 // Redo, and check the content again.
9437 aUndo.Redo();
9439 // tdf#141440 - do not delete notes when pasting contents
9440 static const Check aChecks[] = {
9441 { "Clip1", COL_YELLOW, true }, { "B", COL_BLUE, true },
9442 { "Clip2", COL_YELLOW, true }, { "D", COL_BLUE, true },
9443 { "Clip3", COL_YELLOW, true },
9446 bool bRes
9447 = aTest.checkRange(ScAddress(1, 0, 0), aChecks, aChecks + SAL_N_ELEMENTS(aChecks));
9448 CPPUNIT_ASSERT_MESSAGE("Check after redo failed.", bRes);
9451 m_pDoc->DeleteTab(0);
9454 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteSkipEmpty2)
9456 m_pDoc->InsertTab(0, "Test");
9458 m_pDoc->SetString(ScAddress(0, 0, 0), "A");
9459 m_pDoc->SetString(ScAddress(2, 0, 0), "C");
9461 // Copy A1:C1 to clipboard.
9462 ScDocument aClipDoc(SCDOCMODE_CLIP);
9463 aClipDoc.ResetClip(m_pDoc, static_cast<SCTAB>(0));
9464 copyToClip(m_pDoc, ScRange(0, 0, 0, 2, 0, 0), &aClipDoc);
9466 // Paste to A3 with the skip empty option set. This used to freeze. (fdo#77735)
9467 ScRange aDestRange(0, 2, 0, 2, 2, 0);
9468 ScMarkData aMark(m_pDoc->GetSheetLimits());
9469 aMark.SetMarkArea(aDestRange);
9470 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, false,
9471 false, true, true);
9473 CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(0, 2, 0)));
9474 CPPUNIT_ASSERT_EQUAL_MESSAGE("B3 should be empty.", CELLTYPE_NONE,
9475 m_pDoc->GetCellType(ScAddress(1, 2, 0)));
9476 CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(2, 2, 0)));
9478 m_pDoc->DeleteTab(0);
9481 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutPasteRefUndo)
9483 // Testing scenario: A2 references B2, and B2 gets cut and pasted onto C2,
9484 // which updates A2's formula to reference C2. Then the paste action gets
9485 // undone, which should also undo A2's formula to reference back to B2.
9487 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9489 m_pDoc->InsertTab(0, "Test");
9491 // A2 references B2.
9492 m_pDoc->SetString(ScAddress(0, 1, 0), "=B2");
9494 ScMarkData aMark(m_pDoc->GetSheetLimits());
9495 aMark.SelectOneTable(0);
9497 // Set up clip document for cutting of B2.
9498 ScDocument aClipDoc(SCDOCMODE_CLIP);
9499 aClipDoc.ResetClip(m_pDoc, &aMark);
9500 ScClipParam aParam(ScAddress(1, 1, 0), true);
9501 aClipDoc.SetClipParam(aParam);
9502 aClipDoc.SetValue(ScAddress(1, 1, 0), 12.0);
9504 // Set up undo document for reference update.
9505 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9506 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9508 // Do the pasting of 12 into C2. This should update A2 to reference C2.
9509 m_pDoc->CopyFromClip(ScAddress(2, 1, 0), aMark, InsertDeleteFlags::CONTENTS, pUndoDoc.get(),
9510 &aClipDoc);
9511 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(0, 1, 0));
9513 CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 should be referencing C2.", OUString("=C2"),
9514 m_pDoc->GetFormula(0, 1, 0));
9516 // At this point, the ref undo document should contain a formula cell at A2 that references B2.
9517 CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 in the undo document should be referencing B2.",
9518 OUString("=B2"), pUndoDoc->GetFormula(0, 1, 0));
9520 ScUndoPaste aUndo(m_xDocShell.get(), ScRange(2, 1, 0), aMark, std::move(pUndoDoc), nullptr,
9521 InsertDeleteFlags::CONTENTS, nullptr, false, nullptr);
9522 aUndo.Undo();
9524 // Now A2 should be referencing B2 once again.
9525 CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 should be referencing B2 after undo.", OUString("=B2"),
9526 m_pDoc->GetFormula(0, 1, 0));
9528 m_pDoc->DeleteTab(0);
9531 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCutPasteGroupRefUndo)
9533 // Test that Cut&Paste part of a grouped formula adjusts references
9534 // correctly and Undo works.
9536 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9538 m_pDoc->InsertTab(0, "Test");
9540 // Formula data in A1:A9
9541 std::vector<std::vector<const char*>> aData
9542 = { { "1" }, { "=A1+A1" }, { "=A2+A1" }, { "=A3+A2" }, { "=A4+A3" },
9543 { "=A5+A4" }, { "=A6+A5" }, { "=A7+A6" }, { "=A8+A7" } };
9545 ScAddress aPos(0, 0, 0);
9546 ScRange aDataRange = insertRangeData(m_pDoc, aPos, aData);
9547 CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to insert data", aPos, aDataRange.aStart);
9549 // Check initial data.
9550 const char* aDataCheck[][2] = { { "1", "" }, { "2", "=A1+A1" }, { "3", "=A2+A1" },
9551 { "5", "=A3+A2" }, { "8", "=A4+A3" }, { "13", "=A5+A4" },
9552 { "21", "=A6+A5" }, { "34", "=A7+A6" }, { "55", "=A8+A7" } };
9553 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataCheck); ++i)
9555 OUString aString = m_pDoc->GetString(0, i, 0);
9556 CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial data failure",
9557 OUString::createFromAscii(aDataCheck[i][0]), aString);
9558 aString = m_pDoc->GetFormula(0, i, 0);
9559 CPPUNIT_ASSERT_EQUAL_MESSAGE("Initial formula failure",
9560 OUString::createFromAscii(aDataCheck[i][1]), aString);
9563 ScMarkData aMark(m_pDoc->GetSheetLimits());
9564 aMark.SelectOneTable(0);
9566 // Set up clip document.
9567 ScDocument aClipDoc(SCDOCMODE_CLIP);
9568 aClipDoc.ResetClip(m_pDoc, &aMark);
9569 // Cut A4:A6 to clipboard with Undo.
9570 std::unique_ptr<ScUndoCut> pUndoCut(
9571 cutToClip(*m_xDocShell, ScRange(0, 3, 0, 0, 5, 0), &aClipDoc, true));
9573 // Check data after Cut.
9574 const char* aCutCheck[] = { "1", "2", "3", "", "", "", "0", "0", "0" };
9575 for (size_t i = 0; i < SAL_N_ELEMENTS(aCutCheck); ++i)
9577 OUString aString = m_pDoc->GetString(0, i, 0);
9578 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cut data failure", OUString::createFromAscii(aCutCheck[i]),
9579 aString);
9582 // Paste to B5:B7 with Undo.
9583 ScRange aPasteRange(1, 4, 0, 1, 6, 0);
9584 aMark.SetMarkArea(aPasteRange);
9585 ScDocument* pPasteUndoDoc = new ScDocument(SCDOCMODE_UNDO);
9586 pPasteUndoDoc->InitUndoSelected(*m_pDoc, aMark);
9587 std::unique_ptr<ScUndoPaste> pUndoPaste(
9588 createUndoPaste(*m_xDocShell, aPasteRange, ScDocumentUniquePtr(pPasteUndoDoc)));
9589 m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::ALL, pPasteUndoDoc, &aClipDoc);
9591 // Check data after Paste.
9592 const char* aPasteCheck[][4] = { { "1", "", "", "" },
9593 { "2", "", "=A1+A1", "" },
9594 { "3", "", "=A2+A1", "" },
9595 { "", "", "", "" },
9596 { "", "5", "", "=A3+A2" },
9597 { "", "8", "", "=B5+A3" },
9598 { "21", "13", "=B7+B6", "=B6+B5" },
9599 { "34", "", "=A7+B7", "" },
9600 { "55", "", "=A8+A7", "" } };
9601 for (size_t i = 0; i < SAL_N_ELEMENTS(aPasteCheck); ++i)
9603 for (size_t j = 0; j < 2; ++j)
9605 OUString aString = m_pDoc->GetString(j, i, 0);
9606 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste data failure",
9607 OUString::createFromAscii(aPasteCheck[i][j]), aString);
9608 aString = m_pDoc->GetFormula(j, i, 0);
9609 CPPUNIT_ASSERT_EQUAL_MESSAGE("Paste formula failure",
9610 OUString::createFromAscii(aPasteCheck[i][2 + j]), aString);
9614 // Undo Paste and check, must be same as after Cut.
9615 pUndoPaste->Undo();
9616 for (size_t i = 0; i < SAL_N_ELEMENTS(aCutCheck); ++i)
9618 OUString aString = m_pDoc->GetString(0, i, 0);
9619 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Paste data failure",
9620 OUString::createFromAscii(aCutCheck[i]), aString);
9623 // Undo Cut and check, must be initial data.
9624 pUndoCut->Undo();
9625 for (size_t i = 0; i < SAL_N_ELEMENTS(aDataCheck); ++i)
9627 OUString aString = m_pDoc->GetString(0, i, 0);
9628 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut data failure",
9629 OUString::createFromAscii(aDataCheck[i][0]), aString);
9630 aString = m_pDoc->GetFormula(0, i, 0);
9631 CPPUNIT_ASSERT_EQUAL_MESSAGE("Undo Cut formula failure",
9632 OUString::createFromAscii(aDataCheck[i][1]), aString);
9635 m_pDoc->DeleteTab(0);
9638 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMoveRefBetweenSheets)
9640 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9642 m_pDoc->InsertTab(0, "Test1");
9643 m_pDoc->InsertTab(1, "Test2");
9645 m_pDoc->SetValue(ScAddress(0, 0, 0), 12.0);
9646 m_pDoc->SetValue(ScAddress(1, 0, 0), 10.0);
9647 m_pDoc->SetValue(ScAddress(2, 0, 0), 8.0);
9648 m_pDoc->SetString(ScAddress(0, 1, 0), "=A1");
9649 m_pDoc->SetString(ScAddress(0, 2, 0), "=SUM(A1:C1)");
9651 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 0, 0)));
9652 CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
9653 CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
9655 // These formulas should not display the sheet name.
9656 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=A1"), m_pDoc->GetFormula(0, 1, 0));
9657 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A1:C1)"),
9658 m_pDoc->GetFormula(0, 2, 0));
9660 // Move Test1.A2:A3 to Test2.A2:A3.
9661 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
9662 bool bMoved
9663 = rFunc.MoveBlock(ScRange(0, 1, 0, 0, 2, 0), ScAddress(0, 1, 1), true, true, false, true);
9664 CPPUNIT_ASSERT(bMoved);
9666 CPPUNIT_ASSERT_EQUAL_MESSAGE("This cell should be empty after the move.", CELLTYPE_NONE,
9667 m_pDoc->GetCellType(ScAddress(0, 1, 0)));
9668 ASSERT_DOUBLES_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0, 1, 1)));
9669 ASSERT_DOUBLES_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 1)));
9671 // The reference in the pasted formula should display sheet name after the move.
9672 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=Test1.A1"),
9673 m_pDoc->GetFormula(0, 1, 1));
9674 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(Test1.A1:C1)"),
9675 m_pDoc->GetFormula(0, 2, 1));
9677 m_pDoc->DeleteTab(1);
9678 m_pDoc->DeleteTab(0);
9681 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testUndoCut)
9683 m_pDoc->InsertTab(0, "Test");
9685 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
9687 // Insert values into A1:A3.
9688 m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
9689 m_pDoc->SetValue(ScAddress(0, 1, 0), 10.0);
9690 m_pDoc->SetValue(ScAddress(0, 2, 0), 100.0);
9692 // SUM in A4.
9693 m_pDoc->SetString(ScAddress(0, 3, 0), "=SUM(A1:A3)");
9694 CPPUNIT_ASSERT_EQUAL(111.0, m_pDoc->GetValue(0, 3, 0));
9696 // Select A1:A3.
9697 ScMarkData aMark(m_pDoc->GetSheetLimits());
9698 ScRange aRange(0, 0, 0, 0, 2, 0);
9699 aMark.SetMarkArea(aRange);
9700 aMark.MarkToMulti();
9702 // Set up an undo object for cutting A1:A3.
9703 ScDocumentUniquePtr pUndoDoc(new ScDocument(SCDOCMODE_UNDO));
9704 pUndoDoc->InitUndo(*m_pDoc, 0, 0);
9705 m_pDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *pUndoDoc);
9706 ASSERT_DOUBLES_EQUAL(1.0, pUndoDoc->GetValue(ScAddress(0, 0, 0)));
9707 ASSERT_DOUBLES_EQUAL(10.0, pUndoDoc->GetValue(ScAddress(0, 1, 0)));
9708 ASSERT_DOUBLES_EQUAL(100.0, pUndoDoc->GetValue(ScAddress(0, 2, 0)));
9709 ScUndoCut aUndo(m_xDocShell.get(), aRange, aRange.aEnd, aMark, std::move(pUndoDoc));
9711 // "Cut" the selection.
9712 m_pDoc->DeleteSelection(InsertDeleteFlags::ALL, aMark);
9713 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 3, 0)); // The SUM should be zero after the "cut".
9715 // Undo it, and check the result.
9716 aUndo.Undo();
9717 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 0, 0)));
9718 ASSERT_DOUBLES_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
9719 ASSERT_DOUBLES_EQUAL(100.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
9720 ASSERT_DOUBLES_EQUAL(
9721 111.0, m_pDoc->GetValue(0, 3, 0)); // The SUM value should be back to the original.
9723 // Redo it and check.
9724 aUndo.Redo();
9725 ASSERT_DOUBLES_EQUAL(0.0, m_pDoc->GetValue(0, 3, 0));
9727 // Undo again.
9728 aUndo.Undo();
9729 ASSERT_DOUBLES_EQUAL(111.0, m_pDoc->GetValue(0, 3, 0));
9731 m_pDoc->DeleteTab(0);
9734 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMoveBlock)
9736 m_pDoc->InsertTab(0, "SheetNotes");
9738 // We need a drawing layer in order to create caption objects.
9739 m_pDoc->InitDrawLayer(m_xDocShell.get());
9741 m_pDoc->SetValue(0, 0, 0, 1);
9742 m_pDoc->SetString(1, 0, 0, "=A1+1");
9743 m_pDoc->SetString(2, 0, 0, "test");
9745 // add notes to A1:C1
9746 ScAddress aAddrA1 = setNote(0, 0, 0, "Hello world in A1");
9747 ScAddress aAddrB1 = setNote(1, 0, 0, "Hello world in B1");
9748 ScAddress aAddrC1 = setNote(2, 0, 0, "Hello world in C1");
9749 ScAddress aAddrD1(3, 0, 0);
9751 // previous tests on cell note content are ok. this one fails !!! :(
9752 //CPPUNIT_ASSERT_MESSAGE("Note content in B1 before move block", m_pDoc->GetNote(aAddrB1)->GetText() == aHelloB1);
9754 // move notes to B1:D1
9755 ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc();
9756 bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0, 0, 2, 0, 0), ScAddress(1, 0, 0),
9757 true /*bCut*/, false, false, false);
9759 CPPUNIT_ASSERT_MESSAGE("Cells not moved", bMoveDone);
9761 //check cell content
9762 OUString aString = m_pDoc->GetString(3, 0, 0);
9763 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell D1 should contain: test", OUString("test"), aString);
9764 aString = m_pDoc->GetFormula(2, 0, 0);
9765 CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell C1 should contain an updated formula", OUString("=B1+1"),
9766 aString);
9767 double fValue = m_pDoc->GetValue(aAddrB1);
9768 ASSERT_DOUBLES_EQUAL_MESSAGE("Cell B1 should contain 1", 1, fValue);
9770 // cell notes has been moved 1 cell right (event when overlapping)
9771 CPPUNIT_ASSERT_MESSAGE("There should be NO note on A1", !m_pDoc->HasNote(aAddrA1));
9772 CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", m_pDoc->HasNote(aAddrB1));
9773 CPPUNIT_ASSERT_MESSAGE("There should be a note on C1", m_pDoc->HasNote(aAddrC1));
9774 CPPUNIT_ASSERT_MESSAGE("There should be a note on D1", m_pDoc->HasNote(aAddrD1));
9775 /* still failing, wrong content ???
9776 OUString sNoteText;
9777 sNoteText = m_pDoc->GetNote(aAddrB1)->GetText();
9778 CPPUNIT_ASSERT_MESSAGE("Note content in B1", sNoteText == aHelloA1);
9779 sNoteText = m_pDoc->GetNote(aAddrC1)->GetText();
9780 CPPUNIT_ASSERT_MESSAGE("Note content in C1", sNoteText == aHelloB1);
9781 sNoteText = m_pDoc->GetNote(aAddrD1)->GetText();
9782 CPPUNIT_ASSERT_MESSAGE("Note content in D1", sNoteText == aHelloC1);
9785 m_pDoc->DeleteTab(0);
9788 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteRelativeFormula)
9790 m_pDoc->InsertTab(0, "Formula");
9792 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
9794 // Insert values to A2 and A4.
9795 m_pDoc->SetValue(ScAddress(0, 1, 0), 1);
9796 m_pDoc->SetValue(ScAddress(0, 3, 0), 2);
9798 // Insert formula to B4.
9799 m_pDoc->SetString(ScAddress(1, 3, 0), "=A4");
9800 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1, 3, 0)));
9802 // Select and copy B3:B4 to the clipboard.
9803 ScRange aRange(1, 2, 0, 1, 3, 0);
9804 ScClipParam aClipParam(aRange, false);
9805 ScMarkData aMark(m_pDoc->GetSheetLimits());
9806 aMark.SetMarkArea(aRange);
9807 ScDocument aClipDoc(SCDOCMODE_CLIP);
9808 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9810 // Paste it to B1:B2.
9811 InsertDeleteFlags nFlags = InsertDeleteFlags::ALL;
9812 ScRange aDestRange(1, 0, 0, 1, 1, 0);
9813 aMark.SetMarkArea(aDestRange);
9814 m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
9816 // B2 references A2, so the value should be 1.
9817 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1, 1, 0)));
9819 // Clear content and start over.
9820 clearSheet(m_pDoc, 0);
9821 clearSheet(&aClipDoc, 0);
9823 // Insert a single formula cell in A1.
9824 m_pDoc->SetString(ScAddress(0, 0, 0), "=ROW()");
9825 const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0, 0, 0));
9826 CPPUNIT_ASSERT(pFC);
9827 CPPUNIT_ASSERT(!pFC->IsShared()); // single formula cell is never shared.
9829 // Copy A1 to clipboard.
9830 aClipParam = ScClipParam(ScAddress(0, 0, 0), false);
9831 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9833 pFC = aClipDoc.GetFormulaCell(ScAddress(0, 0, 0));
9834 CPPUNIT_ASSERT(pFC);
9835 CPPUNIT_ASSERT(!pFC->IsShared());
9837 // Paste to A3.
9838 aDestRange = ScRange(0, 2, 0, 0, 2, 0);
9839 aMark.SetMarkArea(aDestRange);
9840 m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
9842 pFC = m_pDoc->GetFormulaCell(ScAddress(0, 2, 0));
9843 CPPUNIT_ASSERT(pFC);
9844 CPPUNIT_ASSERT(!pFC->IsShared());
9846 // Delete A3 and make sure it doesn't crash (see fdo#76132).
9847 clearRange(m_pDoc, ScAddress(0, 2, 0));
9848 CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(ScAddress(0, 2, 0)));
9850 m_pDoc->DeleteTab(0);
9853 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteRepeatOneFormula)
9855 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
9857 m_pDoc->InsertTab(0, "Test");
9859 ScDocument aClipDoc(SCDOCMODE_CLIP);
9860 ScMarkData aMark(m_pDoc->GetSheetLimits());
9862 // Insert values in A1:B10.
9863 for (SCROW i = 0; i < 10; ++i)
9865 m_pDoc->SetValue(ScAddress(0, i, 0), i + 1.0); // column A
9866 m_pDoc->SetValue(ScAddress(1, i, 0), (i + 1.0) * 10.0); // column B
9869 // Insert a formula in C1.
9870 ScAddress aPos(2, 0, 0); // C1
9871 m_pDoc->SetString(aPos, "=SUM(A1:B1)");
9872 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(aPos));
9874 // This check makes only sense if group listeners are activated.
9875 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
9876 // At this point, there should be only one normal area listener listening
9877 // on A1:B1.
9878 ScRange aWholeSheet(0, 0, 0, m_pDoc->MaxCol(), m_pDoc->MaxRow(), 0);
9879 ScBroadcastAreaSlotMachine* pBASM = m_pDoc->GetBASM();
9880 CPPUNIT_ASSERT(pBASM);
9881 std::vector<sc::AreaListener> aListeners
9882 = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
9883 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
9884 const sc::AreaListener* pListener = aListeners.data();
9885 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 0, 0), pListener->maArea);
9886 CPPUNIT_ASSERT_MESSAGE("This listener shouldn't be a group listener.",
9887 !pListener->mbGroupListening);
9888 #endif
9890 // Copy C1 to clipboard.
9891 ScClipParam aClipParam(aPos, false);
9892 aMark.SetMarkArea(aPos);
9893 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
9895 // Paste it to C2:C10.
9896 ScRange aDestRange(2, 1, 0, 2, 9, 0);
9897 aMark.SetMarkArea(aDestRange);
9898 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &aClipDoc);
9900 // Make sure C1:C10 are grouped.
9901 const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(aPos);
9902 CPPUNIT_ASSERT(pFC);
9903 CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength());
9905 // Check the formula results.
9906 for (SCROW i = 0; i < 10; ++i)
9908 double fExpected = (i + 1.0) * 11.0;
9909 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i, 0)));
9912 // This check makes only sense if group listeners are activated.
9913 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
9914 // At this point, there should only be one area listener and it should be
9915 // a group listener listening on A1:B10.
9916 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
9917 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
9918 pListener = aListeners.data();
9919 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 9, 0), pListener->maArea);
9920 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
9921 pListener->mbGroupListening);
9922 #endif
9924 // Insert a new row at row 1.
9925 ScRange aRowOne(0, 0, 0, m_pDoc->MaxCol(), 0, 0);
9926 aMark.SetMarkArea(aRowOne);
9927 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
9928 rFunc.InsertCells(aRowOne, &aMark, INS_INSROWS_BEFORE, true, true);
9930 CPPUNIT_ASSERT_EQUAL_MESSAGE("C1 should be empty.", CELLTYPE_NONE,
9931 m_pDoc->GetCellType(ScAddress(2, 0, 0)));
9933 // This check makes only sense if group listeners are activated.
9934 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
9935 // Make there we only have one group area listener listening on A2:B11.
9936 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
9937 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
9938 pListener = aListeners.data();
9939 CPPUNIT_ASSERT_EQUAL(ScRange(0, 1, 0, 1, 10, 0), pListener->maArea);
9940 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
9941 pListener->mbGroupListening);
9942 #endif
9944 // Check the formula results.
9945 for (SCROW i = 0; i < 10; ++i)
9947 double fExpected = (i + 1.0) * 11.0;
9948 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i + 1, 0)));
9951 // Delete row at row 1 to shift the cells up.
9952 rFunc.DeleteCells(aRowOne, &aMark, DelCellCmd::Rows, true);
9954 // Check the formula results again.
9955 for (SCROW i = 0; i < 10; ++i)
9957 double fExpected = (i + 1.0) * 11.0;
9958 CPPUNIT_ASSERT_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(2, i, 0)));
9961 // This check makes only sense if group listeners are activated.
9962 #if !defined(USE_FORMULA_GROUP_LISTENER) || USE_FORMULA_GROUP_LISTENER
9963 // Check the group area listener again to make sure it's listening on A1:B10 once again.
9964 aListeners = pBASM->GetAllListeners(aWholeSheet, sc::AreaOverlapType::Inside);
9965 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aListeners.size());
9966 pListener = aListeners.data();
9967 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 1, 9, 0), pListener->maArea);
9968 CPPUNIT_ASSERT_MESSAGE("This listener should be a group listener.",
9969 pListener->mbGroupListening);
9970 #endif
9972 m_pDoc->DeleteTab(0);
9975 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteMixedReferenceFormula)
9977 sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc.
9978 m_pDoc->InsertTab(0, "Test");
9980 // Insert value to C3
9981 m_pDoc->SetValue(2, 2, 0, 1.0);
9983 // Insert formula to A1 with mixed relative/absolute addressing.
9984 m_pDoc->SetString(0, 0, 0, "=SUM(B:$C)");
9985 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B:$C)"),
9986 m_pDoc->GetFormula(0, 0, 0));
9987 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, 0));
9989 // Copy formula in A1 to clipboard.
9990 ScRange aRange(ScAddress(0, 0, 0));
9991 ScDocument aClipDoc(SCDOCMODE_CLIP);
9992 copyToClip(m_pDoc, aRange, &aClipDoc);
9994 // Paste formula to B1.
9995 aRange = ScAddress(1, 0, 0);
9996 pasteFromClip(m_pDoc, aRange, &aClipDoc);
9997 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(C:$C)"),
9998 m_pDoc->GetFormula(1, 0, 0));
9999 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 0, 0));
10000 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 0, 0));
10002 // Paste formula to C1. All three results now must be circular reference.
10003 aRange = ScAddress(2, 0, 0);
10004 pasteFromClip(m_pDoc, aRange, &aClipDoc);
10005 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM($C:D)"),
10006 m_pDoc->GetFormula(2, 0, 0)); // reference put in order
10007 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(0, 0, 0));
10008 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(1, 0, 0));
10009 CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(2, 0, 0));
10011 m_pDoc->DeleteTab(0);
10014 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteFormulas)
10016 m_pDoc->InsertTab(0, "Sheet1");
10017 m_pDoc->InsertTab(1, "Sheet2");
10019 m_pDoc->SetString(0, 0, 0, "=COLUMN($A$1)");
10020 m_pDoc->SetString(0, 1, 0, "=$A$1+B2");
10021 m_pDoc->SetString(0, 2, 0, "=$Sheet2.A1");
10022 m_pDoc->SetString(0, 3, 0, "=$Sheet2.$A$1");
10023 m_pDoc->SetString(0, 4, 0, "=$Sheet2.A$1");
10025 // to prevent ScEditableTester in ScDocFunc::MoveBlock
10026 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(0, 0, 0));
10027 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(0, 1, 0));
10028 ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc();
10029 bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0, 0, 0, 4, 0), ScAddress(10, 10, 0), false,
10030 false, false, true);
10032 // check that moving was successful, mainly for editable tester
10033 CPPUNIT_ASSERT(bMoveDone);
10034 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(10, 10, 0));
10035 ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(10, 11, 0));
10036 CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($A$1)"), m_pDoc->GetFormula(10, 10, 0));
10037 CPPUNIT_ASSERT_EQUAL(OUString("=$A$1+L12"), m_pDoc->GetFormula(10, 11, 0));
10038 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.K11"), m_pDoc->GetFormula(10, 12, 0));
10039 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.$A$1"), m_pDoc->GetFormula(10, 13, 0));
10040 CPPUNIT_ASSERT_EQUAL(OUString("=$Sheet2.K$1"), m_pDoc->GetFormula(10, 14, 0));
10043 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteFormulasExternalDoc)
10045 SfxMedium* pMedium = new SfxMedium("file:///source.fake", StreamMode::STD_READWRITE);
10046 m_xDocShell->DoLoad(pMedium);
10048 ScDocShellRef xExtDocSh = new ScDocShell;
10049 OUString constexpr aExtDocName(u"file:///extdata.fake"_ustr);
10050 SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
10051 xExtDocSh->DoLoad(pMed);
10052 CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
10053 findLoadedDocShellByName(aExtDocName) != nullptr);
10055 ScDocument& rExtDoc = xExtDocSh->GetDocument();
10056 rExtDoc.InsertTab(0, "ExtSheet1");
10057 rExtDoc.InsertTab(1, "ExtSheet2");
10059 m_pDoc->InsertTab(0, "Sheet1");
10060 m_pDoc->InsertTab(1, "Sheet2");
10062 m_pDoc->SetString(0, 0, 0, "=COLUMN($A$1)");
10063 m_pDoc->SetString(0, 1, 0, "=$A$1+B2");
10064 m_pDoc->SetString(0, 2, 0, "=$Sheet2.A1");
10065 m_pDoc->SetString(0, 3, 0, "=$Sheet2.$A$1");
10066 m_pDoc->SetString(0, 4, 0, "=$Sheet2.A$1");
10067 m_pDoc->SetString(0, 5, 0, "=$Sheet1.$A$1");
10069 ScRange aRange(0, 0, 0, 0, 5, 0);
10070 ScClipParam aClipParam(aRange, false);
10071 ScMarkData aMark(m_pDoc->GetSheetLimits());
10072 aMark.SetMarkArea(aRange);
10073 ScDocument aClipDoc(SCDOCMODE_CLIP);
10074 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10076 aRange = ScRange(1, 1, 1, 1, 6, 1);
10077 ScMarkData aMarkData2(m_pDoc->GetSheetLimits());
10078 aMarkData2.SetMarkArea(aRange);
10079 rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
10081 OUString aFormula = rExtDoc.GetFormula(1, 1, 1);
10082 //adjust absolute refs pointing to the copy area
10083 CPPUNIT_ASSERT_EQUAL(OUString("=COLUMN($B$2)"), aFormula);
10084 aFormula = rExtDoc.GetFormula(1, 2, 1);
10085 //adjust absolute refs and keep relative refs
10086 CPPUNIT_ASSERT_EQUAL(OUString("=$B$2+C3"), aFormula);
10087 aFormula = rExtDoc.GetFormula(1, 3, 1);
10088 // make absolute sheet refs external refs
10089 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B2"), aFormula);
10090 aFormula = rExtDoc.GetFormula(1, 4, 1);
10091 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.$A$1"), aFormula);
10092 aFormula = rExtDoc.GetFormula(1, 5, 1);
10093 CPPUNIT_ASSERT_EQUAL(OUString("='file:///source.fake'#$Sheet2.B$1"), aFormula);
10094 aFormula = rExtDoc.GetFormula(1, 6, 1);
10095 CPPUNIT_ASSERT_EQUAL(OUString("=$ExtSheet2.$B$2"), aFormula);
10097 xExtDocSh->DoClose();
10100 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteReferencesExternalDoc)
10102 SfxMedium* pMedium = new SfxMedium("file:///source.fake", StreamMode::STD_READWRITE);
10103 m_xDocShell->DoLoad(pMedium);
10105 ScDocShellRef xExtDocSh = new ScDocShell;
10106 OUString aExtDocName("file:///extdata.fake");
10107 SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
10108 xExtDocSh->DoLoad(pMed);
10109 CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
10110 findLoadedDocShellByName(aExtDocName) != nullptr);
10112 ScDocument& rExtDoc = xExtDocSh->GetDocument();
10113 rExtDoc.InsertTab(0, "ExtSheet1");
10115 m_pDoc->InsertTab(0, "Sheet1");
10117 m_pDoc->SetString(0, 5, 0, "=SUM($Sheet1.A1:A5)");
10119 ScRange aRange(0, 2, 0, 0, 5, 0);
10120 ScClipParam aClipParam(aRange, false);
10121 ScMarkData aMark(m_pDoc->GetSheetLimits());
10122 aMark.SetMarkArea(aRange);
10123 ScDocument aClipDoc(SCDOCMODE_CLIP);
10124 m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
10126 aRange = ScRange(0, 0, 0, 0, 3, 0);
10127 ScMarkData aMarkData2(m_pDoc->GetSheetLimits());
10128 aMarkData2.SetMarkArea(aRange);
10129 rExtDoc.CopyFromClip(aRange, aMarkData2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
10131 OUString aFormula = rExtDoc.GetFormula(0, 3, 0);
10132 //adjust absolute refs pointing to the copy area
10133 CPPUNIT_ASSERT_EQUAL(OUString("=SUM('file:///source.fake'#$Sheet1.A#REF!:A3)"), aFormula);
10135 xExtDocSh->DoClose();
10138 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf68976)
10140 const SCTAB nTab = 0;
10141 m_pDoc->InsertTab(nTab, "Test");
10143 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10144 m_pDoc->SetString(0, 1, nTab, "=$A$1"); // A2
10145 m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3
10147 // Cut A3 to the clip document.
10148 ScDocument aClipDoc(SCDOCMODE_CLIP);
10149 ScRange aSrcRange(0, 2, nTab, 0, 2, nTab);
10150 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false); // A3
10152 ScRange aDestRange(1, 3, nTab, 1, 3, nTab); // B4
10153 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10155 // Transpose
10156 ScDocument* pOrigClipDoc = &aClipDoc;
10157 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10158 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10159 aDestMark.SetMarkArea(aDestRange);
10160 // Paste
10161 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10162 true, false, true, false);
10163 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10164 pTransClip.reset();
10166 // Check results
10167 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, nTab)); // A1
10168 // Without the fix in place, this would have failed with
10169 // - Expected: =$A$1
10170 // - Actual : =$B$4
10171 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=$A$1"),
10172 m_pDoc->GetFormula(0, 1, nTab));
10173 // Without the fix in place, this would have failed with
10174 // - Expected: 1
10175 // - Actual : 1000
10176 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10177 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10178 CPPUNIT_ASSERT_EQUAL(1000.0, m_pDoc->GetValue(1, 3, nTab)); // B4
10181 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf71058)
10183 const SCTAB nTab = 0;
10184 m_pDoc->InsertTab(nTab, "Test");
10186 m_pDoc->SetString(2, 2, nTab, "=C4"); // C3
10187 m_pDoc->SetString(3, 2, nTab, "=D4"); // D3
10188 m_pDoc->SetValue(2, 3, nTab, 1.0); // C4
10189 m_pDoc->SetValue(3, 3, nTab, 2.0); // D4
10191 // Cut C4:C5 to the clip document.
10192 ScDocument aClipDoc(SCDOCMODE_CLIP);
10193 ScRange aSrcRange(2, 3, nTab, 3, 3, nTab);
10194 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
10196 // To E6:E7
10197 ScRange aDestRange(4, 5, nTab, 4, 6, nTab);
10198 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10200 // Transpose
10201 ScDocument* pOrigClipDoc = &aClipDoc;
10202 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10203 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10204 aDestMark.SetMarkArea(aDestRange);
10205 // Paste
10206 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10207 true, false, true, false);
10208 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10209 pTransClip.reset();
10211 // Check precondition
10212 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(4, 5, nTab));
10213 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(4, 6, nTab));
10215 // Check results
10216 // Without the fix in place, this would have failed with
10217 // - Expected: =E6
10218 // - Actual : =C4
10219 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=E6"), m_pDoc->GetFormula(2, 2, nTab));
10220 // Without the fix in place, this would have failed with
10221 // - Expected: 1
10222 // - Actual : 0
10223 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(2, 2, nTab));
10225 // Without the fix in place, this would have failed with
10226 // - Expected: =E7
10227 // - Actual : =D4
10228 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=E7"), m_pDoc->GetFormula(3, 2, nTab));
10229 // Without the fix in place, this would have failed with
10230 // - Expected: 2
10231 // - Actual : 0
10232 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, nTab));
10235 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testTdf149554)
10237 const SCTAB nTab = 0;
10238 m_pDoc->InsertTab(nTab, "Test");
10240 // Cut C4:C5 to the clip document.
10241 ScDocument aClipDoc(SCDOCMODE_CLIP);
10242 ScRange aSrcRange(2, 3, nTab, 3, 3, nTab);
10243 cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
10245 // To E6:E7
10246 ScRange aDestRange(4, 5, nTab, 4, 6, nTab);
10247 ScMarkData aDestMark(m_pDoc->GetSheetLimits());
10249 // Transpose
10250 ScDocument* pOrigClipDoc = &aClipDoc;
10251 ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
10252 aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, true);
10253 aDestMark.SetMarkArea(aDestRange);
10254 // Paste. Without the fix in place, this test would have crashed here
10255 m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, pTransClip.get(),
10256 true, false, true, false);
10257 m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, nullptr);
10258 pTransClip.reset();
10260 m_pDoc->DeleteTab(0);
10263 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMixData)
10265 m_pDoc->InsertTab(0, "Test");
10267 m_pDoc->SetValue(ScAddress(1, 0, 0), 2.0); // B1
10268 m_pDoc->SetValue(ScAddress(0, 1, 0), 3.0); // A2
10270 // Copy A1:B1 to the clip document.
10271 ScDocument aClipDoc(SCDOCMODE_CLIP);
10272 copyToClip(m_pDoc, ScRange(0, 0, 0, 1, 0, 0), &aClipDoc); // A1:B1
10274 // Copy A2:B2 to the mix document (for arithmetic paste).
10275 ScDocument aMixDoc(SCDOCMODE_CLIP);
10276 copyToClip(m_pDoc, ScRange(0, 1, 0, 1, 1, 0), &aMixDoc); // A2:B2
10278 // Paste A1:B1 to A2:B2 and perform addition.
10279 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 1, 1, 0), &aClipDoc);
10280 m_pDoc->MixDocument(ScRange(0, 1, 0, 1, 1, 0), ScPasteFunc::ADD, false, aMixDoc);
10282 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0, 1, 0)); // A2
10283 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 1, 0)); // B2
10285 // Clear everything and start over.
10286 clearSheet(m_pDoc, 0);
10287 clearSheet(&aClipDoc, 0);
10288 clearSheet(&aMixDoc, 0);
10290 // Set values to A1, A2, and B1. B2 will remain empty.
10291 m_pDoc->SetValue(ScAddress(0, 0, 0), 15.0);
10292 m_pDoc->SetValue(ScAddress(0, 1, 0), 16.0);
10293 m_pDoc->SetValue(ScAddress(1, 0, 0), 12.0);
10294 CPPUNIT_ASSERT_EQUAL_MESSAGE("B2 should be empty.", CELLTYPE_NONE,
10295 m_pDoc->GetCellType(ScAddress(1, 1, 0)));
10297 // Copy A1:A2 and paste it onto B1:B2 with subtraction operation.
10298 copyToClip(m_pDoc, ScRange(0, 0, 0, 0, 1, 0), &aClipDoc);
10299 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(0, 0, 0)),
10300 aClipDoc.GetValue(ScAddress(0, 0, 0)));
10301 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(0, 1, 0)),
10302 aClipDoc.GetValue(ScAddress(0, 1, 0)));
10304 copyToClip(m_pDoc, ScRange(1, 0, 0, 1, 1, 0), &aMixDoc);
10305 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(1, 0, 0)),
10306 aMixDoc.GetValue(ScAddress(1, 0, 0)));
10307 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(ScAddress(1, 1, 0)),
10308 aMixDoc.GetValue(ScAddress(1, 1, 0)));
10310 pasteFromClip(m_pDoc, ScRange(1, 0, 0, 1, 1, 0), &aClipDoc);
10311 m_pDoc->MixDocument(ScRange(1, 0, 0, 1, 1, 0), ScPasteFunc::SUB, false, aMixDoc);
10313 CPPUNIT_ASSERT_EQUAL(-3.0, m_pDoc->GetValue(ScAddress(1, 0, 0))); // 12 - 15
10314 CPPUNIT_ASSERT_EQUAL(-16.0, m_pDoc->GetValue(ScAddress(1, 1, 0))); // 0 - 16
10316 m_pDoc->DeleteTab(0);
10319 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMixDataAsLinkTdf116413)
10321 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
10323 const SCTAB nTab = 0;
10324 m_pDoc->InsertTab(nTab, "Test");
10326 // Scenario 1: Past "As Link" and "Add" operation (as described in tdf#116413)
10327 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10328 m_pDoc->SetValue(0, 1, nTab, 1000.0); // A2
10330 // Copy A1 to the clip document.
10331 ScDocument aClipDoc(SCDOCMODE_CLIP);
10332 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 0, nTab), &aClipDoc); // A1
10334 ScRange aDestRange(0, 1, nTab, 0, 1, nTab);
10335 // Copy A2 to the mix document (for arithmetic paste).
10336 ScDocument aMixDoc(SCDOCMODE_CLIP);
10337 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A2
10339 // Paste A1 to A2 "As Link" and perform addition.
10340 ScMarkData aMark(m_pDoc->GetSheetLimits());
10341 aMark.SetMarkArea(aDestRange);
10342 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10344 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10346 // Test precondition
10347 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10348 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10350 // Change A1 from 1.0 to 2.0 (auto calculation is triggered)
10351 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10353 // Without the fix in place, this would have failed with
10354 // - Expected: =1002
10355 // - Actual : =1001
10356 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10357 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10359 // Clear everything and start over.
10360 clearSheet(m_pDoc, nTab);
10361 clearSheet(&aClipDoc, nTab);
10362 clearSheet(&aMixDoc, nTab);
10364 // Scenario 2: Like Scenario 1, but with a range (3 columns)
10365 m_pDoc->InsertTab(nTab, "Test");
10367 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10368 m_pDoc->SetValue(0, 1, nTab, 1000.0); // A2
10369 m_pDoc->SetValue(1, 0, nTab, 1.0); // B1
10370 m_pDoc->SetValue(1, 1, nTab, 1000.0); // B2
10371 m_pDoc->SetValue(2, 0, nTab, 1.0); // C1
10372 m_pDoc->SetValue(2, 1, nTab, 1000.0); // C2
10374 // Copy A1:C1 to the clip document.
10375 copyToClip(m_pDoc, ScRange(0, 0, nTab, 2, 0, nTab), &aClipDoc); // A1:C1
10377 aDestRange = ScRange(0, 1, nTab, 2, 1, nTab);
10378 // Copy A2:C2 to the mix document (for arithmetic paste).
10379 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A2:C2
10381 // Paste A1:C1 to A2:C2 "As Link" and perform addition.
10382 aMark = ScMarkData(m_pDoc->GetSheetLimits());
10383 aMark.SetMarkArea(aDestRange);
10384 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10386 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10388 // Test precondition
10389 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10390 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10392 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10393 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$B$1)"), m_pDoc->GetFormula(1, 1, nTab));
10395 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10396 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$C$1)"), m_pDoc->GetFormula(2, 1, nTab));
10398 // Change A1:C1 from 1.0 to 2.0 (auto calculation is triggered)
10399 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10400 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
10401 m_pDoc->SetValue(2, 0, nTab, 2.0); // C1
10403 // Without the fix in place, this would have failed with
10404 // - Expected: =1002
10405 // - Actual : =1001
10406 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(0, 1, nTab)); // A2
10407 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(0, 1, nTab));
10409 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10410 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$B$1)"), m_pDoc->GetFormula(1, 1, nTab));
10412 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10413 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$C$1)"), m_pDoc->GetFormula(2, 1, nTab));
10415 // Scenario 3: Like Scenario 2, but transposed
10416 m_pDoc->InsertTab(nTab, "Test");
10418 m_pDoc->SetValue(0, 0, nTab, 1.0); // A1
10419 m_pDoc->SetValue(1, 0, nTab, 1000.0); // B1
10420 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10421 m_pDoc->SetValue(1, 1, nTab, 1000.0); // B2
10422 m_pDoc->SetValue(0, 2, nTab, 1.0); // A3
10423 m_pDoc->SetValue(1, 2, nTab, 1000.0); // B3
10425 // Copy A1:A3 to the clip document.
10426 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 2, nTab), &aClipDoc); // A1:A3
10428 aDestRange = ScRange(1, 0, nTab, 1, 2, nTab);
10429 // Copy B1:B3 to the mix document (for arithmetic paste).
10430 copyToClip(m_pDoc, aDestRange, &aMixDoc); // B1:B3
10432 // Paste A1:A3 to B1:B3 "As Link" and perform addition.
10433 aMark = ScMarkData(m_pDoc->GetSheetLimits());
10434 aMark.SetMarkArea(aDestRange);
10435 m_pDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc, true, true);
10437 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10439 // Test precondition
10440 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 0, nTab)); // B1
10441 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(1, 0, nTab));
10443 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10444 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$2)"), m_pDoc->GetFormula(1, 1, nTab));
10446 CPPUNIT_ASSERT_EQUAL(1001.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10447 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$3)"), m_pDoc->GetFormula(1, 2, nTab));
10449 // Change A1:C1 from 1.0 to 2.0 (auto calculation is triggered)
10450 m_pDoc->SetValue(0, 0, nTab, 2.0); // A1
10451 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10452 m_pDoc->SetValue(0, 2, nTab, 2.0); // A3
10454 // Without the fix in place, this would have failed with
10455 // - Expected: =1002
10456 // - Actual : =1001
10457 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 0, nTab)); // B1
10458 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$1)"), m_pDoc->GetFormula(1, 0, nTab));
10460 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 1, nTab)); // B2
10461 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$2)"), m_pDoc->GetFormula(1, 1, nTab));
10463 CPPUNIT_ASSERT_EQUAL(1002.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10464 CPPUNIT_ASSERT_EQUAL(OUString("=1000+($Test.$A$3)"), m_pDoc->GetFormula(1, 2, nTab));
10466 m_pDoc->DeleteTab(nTab);
10469 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMixDataWithFormulaTdf116413)
10471 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
10473 const SCTAB nTab = 0;
10474 m_pDoc->InsertTab(nTab, "Test");
10476 // Scenario 1: There is already a reference in destination cell
10477 m_pDoc->InsertTab(nTab, "Test");
10479 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10480 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10481 m_pDoc->SetString(0, 2, nTab, "=A2"); // A3
10483 // Copy A1 to the clip document.
10484 ScDocument aClipDoc(SCDOCMODE_CLIP);
10485 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 0, nTab), &aClipDoc); // A1
10487 ScRange aDestRange(0, 2, nTab, 0, 2, nTab);
10488 ScDocument aMixDoc(SCDOCMODE_CLIP);
10489 // Copy A3 to the mix document (for arithmetic paste).
10490 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A3
10492 // Paste A1 to A3 and perform addition.
10493 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10494 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10496 // Test precondition
10497 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10498 CPPUNIT_ASSERT_EQUAL(OUString("=(A2)+100"), m_pDoc->GetFormula(0, 2, nTab));
10500 // Change A2 from 1.0 to 2.0 (auto calculation is triggered)
10501 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10503 // Without the fix in place, this would have failed with
10504 // - Expected: =102
10505 // - Actual : =101
10506 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10507 CPPUNIT_ASSERT_EQUAL(OUString("=(A2)+100"), m_pDoc->GetFormula(0, 2, nTab));
10509 // Clear everything and start over.
10510 clearSheet(m_pDoc, nTab);
10511 clearSheet(&aClipDoc, nTab);
10512 clearSheet(&aMixDoc, nTab);
10514 // Scenario 2: Similar to scenario 1, but a range of 4 cells and 2 of them have references
10515 m_pDoc->InsertTab(nTab, "Test");
10517 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10518 m_pDoc->SetValue(0, 1, nTab, 1.0); // A2
10519 m_pDoc->SetValue(0, 2, nTab, 1000.0); // A3
10521 m_pDoc->SetValue(1, 0, nTab, 100.0); // B1
10522 m_pDoc->SetValue(1, 1, nTab, 1.0); // B2
10523 m_pDoc->SetString(1, 2, nTab, "=B2"); // B3
10525 m_pDoc->SetValue(2, 0, nTab, 100.0); // C1
10526 m_pDoc->SetValue(2, 1, nTab, 1.0); // C2
10527 m_pDoc->SetString(2, 2, nTab, "=C2"); // C3
10529 m_pDoc->SetValue(3, 0, nTab, 100.0); // D1
10530 m_pDoc->SetValue(3, 1, nTab, 1.0); // D2
10531 m_pDoc->SetValue(3, 2, nTab, 1000.0); // D3
10533 // Copy A1:D1 to the clip document.
10534 copyToClip(m_pDoc, ScRange(0, 0, nTab, 3, 0, nTab), &aClipDoc); // A1:D1
10536 aDestRange = ScRange(0, 2, nTab, 3, 2, nTab);
10537 // Copy A3:D3 to the mix document (for arithmetic paste).
10538 copyToClip(m_pDoc, aDestRange, &aMixDoc); // A3:D3
10540 // Paste A1:D1 to A3:D3 and perform addition.
10541 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10542 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10544 // Test precondition
10545 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10546 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(0, 2, nTab));
10548 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10549 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(1, 2, nTab));
10551 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10552 CPPUNIT_ASSERT_EQUAL(OUString("=(C2)+100"), m_pDoc->GetFormula(2, 2, nTab));
10554 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(3, 2, nTab)); // D3
10555 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(3, 2, nTab));
10557 // Change A2:D2 from 1.0 to 2.0 (auto calculation is triggered)
10558 m_pDoc->SetValue(0, 1, nTab, 2.0); // A2
10559 m_pDoc->SetValue(1, 1, nTab, 2.0); // B2
10560 m_pDoc->SetValue(2, 1, nTab, 2.0); // C2
10561 m_pDoc->SetValue(3, 1, nTab, 2.0); // D2
10563 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(0, 2, nTab)); // A3
10564 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(0, 2, nTab));
10566 // Without the fix in place, this would have failed with
10567 // - Expected: =102
10568 // - Actual : =101
10569 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(1, 2, nTab)); // B3
10570 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(1, 2, nTab));
10572 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10573 CPPUNIT_ASSERT_EQUAL(OUString("=(C2)+100"), m_pDoc->GetFormula(2, 2, nTab));
10575 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(3, 2, nTab)); // D3
10576 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(3, 2, nTab));
10578 // Scenario 3: Similar to scenario 2, but transposed
10579 m_pDoc->InsertTab(nTab, "Test");
10581 m_pDoc->SetValue(0, 0, nTab, 100.0); // A1
10582 m_pDoc->SetValue(1, 0, nTab, 1.0); // B1
10583 m_pDoc->SetValue(2, 0, nTab, 1000.0); // C1
10585 m_pDoc->SetValue(0, 1, nTab, 100.0); // A2
10586 m_pDoc->SetValue(1, 1, nTab, 1.0); // B2
10587 m_pDoc->SetString(2, 1, nTab, "=B2"); // C2
10589 m_pDoc->SetValue(0, 2, nTab, 100.0); // A3
10590 m_pDoc->SetValue(1, 2, nTab, 1.0); // B3
10591 m_pDoc->SetString(2, 2, nTab, "=B3"); // C3
10593 m_pDoc->SetValue(0, 3, nTab, 100.0); // A4
10594 m_pDoc->SetValue(1, 3, nTab, 1.0); // B4
10595 m_pDoc->SetValue(2, 3, nTab, 1000.0); // C4
10597 // Copy A1:A4 to the clip document.
10598 copyToClip(m_pDoc, ScRange(0, 0, nTab, 0, 3, nTab), &aClipDoc); // A1:A4
10600 aDestRange = ScRange(2, 0, nTab, 2, 3, nTab);
10601 // Copy C1:C4 to the mix document (for arithmetic paste).
10602 copyToClip(m_pDoc, aDestRange, &aMixDoc); // C1:C4
10604 // Paste A1:A4 to C1:C4 and perform addition.
10605 pasteFromClip(m_pDoc, aDestRange, &aClipDoc);
10606 m_pDoc->MixDocument(aDestRange, ScPasteFunc::ADD, false, aMixDoc);
10608 // Test precondition
10609 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 0, nTab)); // C1
10610 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 0, nTab));
10612 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10613 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(2, 1, nTab));
10615 CPPUNIT_ASSERT_EQUAL(101.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10616 CPPUNIT_ASSERT_EQUAL(OUString("=(B3)+100"), m_pDoc->GetFormula(2, 2, nTab));
10618 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 3, nTab)); // C4
10619 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 3, nTab));
10621 // Change B1:B4 from 1.0 to 2.0 (auto calculation is triggered)
10622 m_pDoc->SetValue(1, 0, nTab, 2.0); // B1
10623 m_pDoc->SetValue(1, 1, nTab, 2.0); // B2
10624 m_pDoc->SetValue(1, 2, nTab, 2.0); // B3
10625 m_pDoc->SetValue(1, 3, nTab, 2.0); // B4
10627 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 0, nTab)); // C1
10628 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 0, nTab));
10630 // Without the fix in place, this would have failed with
10631 // - Expected: =102
10632 // - Actual : =101
10633 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 1, nTab)); // C2
10634 CPPUNIT_ASSERT_EQUAL(OUString("=(B2)+100"), m_pDoc->GetFormula(2, 1, nTab));
10636 CPPUNIT_ASSERT_EQUAL(102.0, m_pDoc->GetValue(2, 2, nTab)); // C3
10637 CPPUNIT_ASSERT_EQUAL(OUString("=(B3)+100"), m_pDoc->GetFormula(2, 2, nTab));
10639 CPPUNIT_ASSERT_EQUAL(1100.0, m_pDoc->GetValue(2, 3, nTab)); // C4
10640 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetFormula(2, 3, nTab));
10642 m_pDoc->DeleteTab(nTab);
10645 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testCopyPasteMatrixFormula)
10647 // tdf#80137
10648 m_pDoc->InsertTab(0, "hcv");
10650 // Set Values to B1, C1, D1
10651 m_pDoc->SetValue(ScAddress(1, 0, 0), 2.0); // B1
10652 m_pDoc->SetValue(ScAddress(2, 0, 0), 5.0); // C1
10653 m_pDoc->SetValue(ScAddress(3, 0, 0), 3.0); // D1
10655 // Set Values to B2, C2
10656 m_pDoc->SetString(ScAddress(1, 1, 0), "B2"); // B2
10657 //m_pDoc->SetString(ScAddress(2,1,0), "C2"); // C2
10658 m_pDoc->SetString(ScAddress(3, 1, 0), "D2"); // D2
10660 // Set Values to D3
10661 //m_pDoc->SetValue(ScAddress(1,2,0), 9.0); // B3
10662 //m_pDoc->SetString(ScAddress(2,2,0), "C3"); // C3
10663 m_pDoc->SetValue(ScAddress(3, 2, 0), 11.0); // D3
10665 // Insert matrix formula to A1
10666 ScMarkData aMark(m_pDoc->GetSheetLimits());
10667 aMark.SelectOneTable(0);
10668 m_pDoc->InsertMatrixFormula(0, 0, 0, 0, aMark, "=COUNTIF(ISBLANK(B1:D1);TRUE())");
10669 m_pDoc->CalcAll();
10670 // A1 should contain 0
10671 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0, 0, 0))); // A1
10673 // Copy cell A1 to clipboard.
10674 ScAddress aPos(0, 0, 0); // A1
10675 ScDocument aClipDoc(SCDOCMODE_CLIP);
10676 ScClipParam aParam(aPos, false);
10677 m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark, false, false);
10678 // Formula string should be equal.
10679 CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
10681 // First try single range.
10682 // Paste matrix formula to A2
10683 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 0, 1, 0), &aClipDoc); // A2
10684 // A2 Cell value should contain 1.0
10685 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
10687 // Paste matrix formula to A3
10688 pasteFromClip(m_pDoc, ScRange(0, 2, 0, 0, 2, 0), &aClipDoc); // A3
10689 // A3 Cell value should contain 2.0
10690 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
10692 // Paste matrix formula to A4
10693 pasteFromClip(m_pDoc, ScRange(0, 3, 0, 0, 3, 0), &aClipDoc); // A4
10694 // A4 Cell value should contain 3.0
10695 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0, 3, 0)));
10697 // Clear cell A2:A4
10698 clearRange(m_pDoc, ScRange(0, 1, 0, 0, 3, 0));
10700 // Paste matrix formula to range A2:A4
10701 pasteFromClip(m_pDoc, ScRange(0, 1, 0, 0, 3, 0), &aClipDoc); // A2:A4
10703 // A2 Cell value should contain 1.0
10704 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0, 1, 0)));
10705 // A3 Cell value should contain 2.0
10706 CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0, 2, 0)));
10707 // A4 Cell value should contain 3.0
10708 CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0, 3, 0)));
10710 m_pDoc->DeleteTab(0);
10713 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testUndoBackgroundColor)
10715 m_pDoc->InsertTab(0, "Table1");
10717 ScDocument aClipDoc(SCDOCMODE_CLIP);
10718 ScMarkData aMark(m_pDoc->GetSheetLimits());
10720 // Set Values to B1, C2, D5
10721 m_pDoc->SetValue(ScAddress(1, 0, 0), 1.0); // B1
10722 m_pDoc->SetValue(ScAddress(2, 1, 0), 2.0); // C2
10723 m_pDoc->SetValue(ScAddress(3, 4, 0), 3.0); // D5
10725 // Add patterns
10726 ScPatternAttr aCellBlueColor(m_pDoc->GetPool());
10727 aCellBlueColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
10728 m_pDoc->ApplyPatternAreaTab(0, 3, m_pDoc->MaxCol(), 3, 0, aCellBlueColor);
10730 // Insert a new row at row 3
10731 ScRange aRowOne(0, 2, 0, m_pDoc->MaxCol(), 2, 0);
10732 aMark.SetMarkArea(aRowOne);
10733 ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
10734 rFunc.InsertCells(aRowOne, &aMark, INS_INSROWS_BEFORE, true, true);
10736 // Check patterns
10737 const SfxPoolItem* pItem = nullptr;
10738 m_pDoc->GetPattern(ScAddress(1000, 4, 0))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
10739 CPPUNIT_ASSERT(pItem);
10740 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
10742 // Undo the new row
10743 m_pDoc->GetUndoManager()->Undo();
10745 // Check patterns
10746 // Failed if row 3 is not blue all the way through
10747 pItem = nullptr;
10748 m_pDoc->GetPattern(ScAddress(1000, 3, 0))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
10749 CPPUNIT_ASSERT(pItem);
10750 CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const SvxBrushItem*>(pItem)->GetColor());
10752 m_pDoc->DeleteTab(0);
10755 CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMergedHyperlink)
10757 m_pDoc->InsertTab(0, "Table1");
10758 m_pDoc->InitDrawLayer(m_xDocShell.get());
10760 ScFieldEditEngine& pEE = m_pDoc->GetEditEngine();
10761 pEE.SetTextCurrentDefaults("https://libreoffice.org/");
10762 m_pDoc->SetEditText(ScAddress(1, 0, 0), pEE.CreateTextObject()); // B1
10764 m_pDoc->DoMergeContents(0, 0, 1, 0, 0); // A1:B1
10766 CPPUNIT_ASSERT_EQUAL(CELLTYPE_EDIT, m_pDoc->GetCellType(ScAddress(0, 0, 0))); // A1
10767 const EditTextObject* pEditObj = m_pDoc->GetEditText(ScAddress(0, 0, 0)); // A1
10768 CPPUNIT_ASSERT(pEditObj);
10769 CPPUNIT_ASSERT_EQUAL(OUString("https://libreoffice.org/"), pEditObj->GetText(0));
10772 CPPUNIT_PLUGIN_IMPLEMENT();
10774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */