Bump version to 5.0-14
[LibreOffice.git] / sc / qa / unit / ucalc_column.cxx
blob6b9ca51c2746dec3f479f92d25ec8937f3a9bdb8
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 "ucalc.hxx"
11 #include <editutil.hxx>
12 #include <cellvalue.hxx>
13 #include <svl/languageoptions.hxx>
15 void Test::testColumnFindEditCells()
17 m_pDoc->InsertTab(0, "Test");
19 // Test the basics with real edit cells, using Column A.
21 SCROW nResRow = m_pDoc->GetFirstEditTextRow(ScRange(0,0,0,0,MAXROW,0));
22 CPPUNIT_ASSERT_MESSAGE("There should be no edit cells.", nResRow == -1);
23 nResRow = m_pDoc->GetFirstEditTextRow(ScRange(0,0,0,0,0,0));
24 CPPUNIT_ASSERT_MESSAGE("There should be no edit cells.", nResRow == -1);
25 nResRow = m_pDoc->GetFirstEditTextRow(ScRange(0,0,0,0,10,0));
26 CPPUNIT_ASSERT_MESSAGE("There should be no edit cells.", nResRow == -1);
28 ScFieldEditEngine& rEE = m_pDoc->GetEditEngine();
29 rEE.SetText("Test");
30 m_pDoc->SetEditText(ScAddress(0,0,0), rEE.CreateTextObject());
31 const EditTextObject* pObj = m_pDoc->GetEditText(ScAddress(0,0,0));
32 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell here.", pObj);
34 ScRange aRange(0,0,0,0,0,0);
35 nResRow = m_pDoc->GetFirstEditTextRow(aRange);
36 CPPUNIT_ASSERT_MESSAGE("There is an edit cell here.", nResRow == 0);
38 aRange.aStart.SetRow(1);
39 aRange.aEnd.SetRow(1);
40 nResRow = m_pDoc->GetFirstEditTextRow(aRange);
41 CPPUNIT_ASSERT_MESSAGE("There shouldn't be an edit cell in specified range.", nResRow == -1);
43 aRange.aStart.SetRow(2);
44 aRange.aEnd.SetRow(4);
45 nResRow = m_pDoc->GetFirstEditTextRow(aRange);
46 CPPUNIT_ASSERT_MESSAGE("There shouldn't be an edit cell in specified range.", nResRow == -1);
48 aRange.aStart.SetRow(0);
49 aRange.aEnd.SetRow(MAXROW);
50 nResRow = m_pDoc->GetFirstEditTextRow(aRange);
51 CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in specified range.", nResRow == 0);
53 m_pDoc->SetString(ScAddress(0,0,0), "Test");
54 m_pDoc->SetValue(ScAddress(0,2,0), 1.0);
55 ScRefCellValue aCell;
56 aCell.assign(*m_pDoc, ScAddress(0,0,0));
57 CPPUNIT_ASSERT_MESSAGE("This should be a string cell.", aCell.meType == CELLTYPE_STRING);
58 aCell.assign(*m_pDoc, ScAddress(0,1,0));
59 CPPUNIT_ASSERT_MESSAGE("This should be an empty cell.", aCell.meType == CELLTYPE_NONE);
60 aCell.assign(*m_pDoc, ScAddress(0,2,0));
61 CPPUNIT_ASSERT_MESSAGE("This should be a numeric cell.", aCell.meType == CELLTYPE_VALUE);
62 aCell.assign(*m_pDoc, ScAddress(0,3,0));
63 CPPUNIT_ASSERT_MESSAGE("This should be an empty cell.", aCell.meType == CELLTYPE_NONE);
65 aRange.aStart.SetRow(1);
66 aRange.aEnd.SetRow(1);
67 nResRow = m_pDoc->GetFirstEditTextRow(aRange);
68 CPPUNIT_ASSERT_MESSAGE("There shouldn't be an edit cell in specified range.", nResRow == -1);
70 // Test with non-edit cell but with ambiguous script type.
72 m_pDoc->SetString(ScAddress(1,11,0), "Some text");
73 m_pDoc->SetString(ScAddress(1,12,0), "Some text");
74 m_pDoc->SetString(ScAddress(1,13,0), "Other text");
76 m_pDoc->SetScriptType(ScAddress(1,11,0), (SvtScriptType::LATIN | SvtScriptType::ASIAN));
77 m_pDoc->SetScriptType(ScAddress(1,12,0), (SvtScriptType::LATIN | SvtScriptType::ASIAN));
78 m_pDoc->SetScriptType(ScAddress(1,13,0), (SvtScriptType::LATIN | SvtScriptType::ASIAN));
80 nResRow = m_pDoc->GetFirstEditTextRow(ScAddress(1,11,0));
81 CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(11), nResRow);
82 nResRow = m_pDoc->GetFirstEditTextRow(ScAddress(1,12,0));
83 CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(12), nResRow);
85 for (SCROW i = 0; i <= 5; ++i)
86 m_pDoc->SetString(ScAddress(2,i,0), "Text");
88 m_pDoc->SetScriptType(ScAddress(2,5,0), (SvtScriptType::LATIN | SvtScriptType::ASIAN));
90 nResRow = m_pDoc->GetFirstEditTextRow(ScAddress(2,1,0));
91 CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(-1), nResRow);
93 m_pDoc->DeleteTab(0);
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */