Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
3edc49d1
Kaydet (Commit)
3edc49d1
authored
Mar 26, 2014
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#74322: Write unit test for this first.
Change-Id: If16a93ee371e9a4e0d0992fd0a62a4623fc284ab
üst
8bf22e7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
ucalc.hxx
sc/qa/unit/ucalc.hxx
+2
-0
ucalc_formula.cxx
sc/qa/unit/ucalc_formula.cxx
+80
-0
No files found.
sc/qa/unit/ucalc.hxx
Dosyayı görüntüle @
3edc49d1
...
...
@@ -121,6 +121,7 @@ public:
void
testFormulaRefUpdateMove
();
void
testFormulaRefUpdateMoveUndo
();
void
testFormulaRefUpdateNamedExpression
();
void
testFormulaRefUpdateNamedExpressionMove
();
void
testFormulaRefUpdateNamedExpressionExpandRef
();
void
testMultipleOperations
();
void
testFuncCOLUMN
();
...
...
@@ -367,6 +368,7 @@ public:
CPPUNIT_TEST
(
testFormulaRefUpdateMove
);
CPPUNIT_TEST
(
testFormulaRefUpdateMoveUndo
);
CPPUNIT_TEST
(
testFormulaRefUpdateNamedExpression
);
CPPUNIT_TEST
(
testFormulaRefUpdateNamedExpressionMove
);
CPPUNIT_TEST
(
testFormulaRefUpdateNamedExpressionExpandRef
);
CPPUNIT_TEST
(
testMultipleOperations
);
CPPUNIT_TEST
(
testFuncCOLUMN
);
...
...
sc/qa/unit/ucalc_formula.cxx
Dosyayı görüntüle @
3edc49d1
...
...
@@ -1818,6 +1818,86 @@ void Test::testFormulaRefUpdateNamedExpression()
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testFormulaRefUpdateNamedExpressionMove
()
{
sc
::
AutoCalcSwitch
aACSwitch
(
*
m_pDoc
,
true
);
// turn auto calc on.
m_pDoc
->
InsertTab
(
0
,
"Test"
);
// Set values to B2:B4.
m_pDoc
->
SetValue
(
ScAddress
(
1
,
1
,
0
),
1.0
);
m_pDoc
->
SetValue
(
ScAddress
(
1
,
2
,
0
),
2.0
);
m_pDoc
->
SetValue
(
ScAddress
(
1
,
3
,
0
),
3.0
);
// Set named range for B2:B4.
bool
bInserted
=
m_pDoc
->
InsertNewRangeName
(
"MyRange"
,
ScAddress
(
0
,
0
,
0
),
"$Test.$B$2:$B$4"
);
CPPUNIT_ASSERT
(
bInserted
);
// Set formula in A10.
m_pDoc
->
SetString
(
ScAddress
(
0
,
9
,
0
),
"=SUM(MyRange)"
);
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
9
,
0
)));
ScRangeData
*
pData
=
m_pDoc
->
GetRangeName
()
->
findByUpperName
(
"MYRANGE"
);
CPPUNIT_ASSERT
(
pData
);
OUString
aSymbol
;
pData
->
GetSymbol
(
aSymbol
,
m_pDoc
->
GetGrammar
());
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"$Test.$B$2:$B$4"
),
aSymbol
);
// Move B2:B4 to D3.
ScDocFunc
&
rFunc
=
getDocShell
().
GetDocFunc
();
bool
bMoved
=
rFunc
.
MoveBlock
(
ScRange
(
1
,
1
,
0
,
1
,
3
,
0
),
ScAddress
(
3
,
2
,
0
),
true
,
true
,
false
,
true
);
CPPUNIT_ASSERT
(
bMoved
);
// The named range should have moved as well.
pData
->
GetSymbol
(
aSymbol
,
m_pDoc
->
GetGrammar
());
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"$Test.$D$3:$D$5"
),
aSymbol
);
// The value of A10 should remain unchanged.
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
9
,
0
)));
SfxUndoManager
*
pUndoMgr
=
m_pDoc
->
GetUndoManager
();
CPPUNIT_ASSERT
(
pUndoMgr
);
// Undo and check.
pUndoMgr
->
Undo
();
pData
=
m_pDoc
->
GetRangeName
()
->
findByUpperName
(
"MYRANGE"
);
CPPUNIT_ASSERT
(
pData
);
pData
->
GetSymbol
(
aSymbol
,
m_pDoc
->
GetGrammar
());
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"$Test.$B$2:$B$4"
),
aSymbol
);
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
9
,
0
)));
// Redo and check.
pUndoMgr
->
Redo
();
pData
=
m_pDoc
->
GetRangeName
()
->
findByUpperName
(
"MYRANGE"
);
CPPUNIT_ASSERT
(
pData
);
pData
->
GetSymbol
(
aSymbol
,
m_pDoc
->
GetGrammar
());
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"$Test.$D$3:$D$5"
),
aSymbol
);
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
9
,
0
)));
// Undo again to bring it back to the initial condition, and clear the undo buffer.
pUndoMgr
->
Undo
();
pUndoMgr
->
Clear
();
// Add an identical formula to A11 and make a formula group over A10:A11.
m_pDoc
->
SetString
(
ScAddress
(
0
,
10
,
0
),
"=SUM(MyRange)"
);
ScFormulaCell
*
pFC
=
m_pDoc
->
GetFormulaCell
(
ScAddress
(
0
,
9
,
0
));
CPPUNIT_ASSERT
(
pFC
);
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
SCROW
>
(
9
),
pFC
->
GetSharedTopRow
());
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
SCROW
>
(
2
),
pFC
->
GetSharedLength
());
// Move B2:B4 to D3 again.
bMoved
=
rFunc
.
MoveBlock
(
ScRange
(
1
,
1
,
0
,
1
,
3
,
0
),
ScAddress
(
3
,
2
,
0
),
true
,
true
,
false
,
true
);
CPPUNIT_ASSERT
(
bMoved
);
// Values of A10 and A11 should remain the same.
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
9
,
0
)));
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
10
,
0
)));
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testFormulaRefUpdateNamedExpressionExpandRef
()
{
m_pDoc
->
InsertTab
(
0
,
"Test"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment