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
aa6c5b7f
Kaydet (Commit)
aa6c5b7f
authored
Şub 28, 2014
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#75053: Write test for this.
Change-Id: I51c552c23af5d1669e35817e4f54f75be6b54180
üst
f821b00c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
ucalc.hxx
sc/qa/unit/ucalc.hxx
+2
-0
ucalc_sharedformula.cxx
sc/qa/unit/ucalc_sharedformula.cxx
+90
-0
No files found.
sc/qa/unit/ucalc.hxx
Dosyayı görüntüle @
aa6c5b7f
...
...
@@ -267,6 +267,7 @@ public:
void
testSharedFormulasRefUpdate
();
void
testSharedFormulasRefUpdateRange
();
void
testSharedFormulasDeleteRows
();
void
testSharedFormulasDeleteColumns
();
void
testSharedFormulasRefUpdateMoveSheets
();
void
testSharedFormulasRefUpdateCopySheets
();
void
testSharedFormulasCopyPaste
();
...
...
@@ -439,6 +440,7 @@ public:
CPPUNIT_TEST
(
testSharedFormulasRefUpdate
);
CPPUNIT_TEST
(
testSharedFormulasRefUpdateRange
);
CPPUNIT_TEST
(
testSharedFormulasDeleteRows
);
CPPUNIT_TEST
(
testSharedFormulasDeleteColumns
);
CPPUNIT_TEST
(
testSharedFormulasRefUpdateMoveSheets
);
CPPUNIT_TEST
(
testSharedFormulasRefUpdateCopySheets
);
CPPUNIT_TEST
(
testSharedFormulasCopyPaste
);
...
...
sc/qa/unit/ucalc_sharedformula.cxx
Dosyayı görüntüle @
aa6c5b7f
...
...
@@ -16,6 +16,8 @@
#include "undoblk.hxx"
#include "scopetools.hxx"
#include <docfunc.hxx>
#include <tokenarray.hxx>
#include <tokenstringcontext.hxx>
#include "svl/sharedstring.hxx"
#include "formula/grammar.hxx"
...
...
@@ -519,6 +521,94 @@ void Test::testSharedFormulasDeleteRows()
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
SCROW
>
(
8
),
pFC
->
GetSharedLength
());
}
void
Test
::
testSharedFormulasDeleteColumns
()
{
using
namespace
formula
;
m_pDoc
->
InsertTab
(
0
,
"Test"
);
sc
::
AutoCalcSwitch
aACSwitch
(
*
m_pDoc
,
true
);
// turn on auto calc.
FormulaGrammarSwitch
aFGSwitch
(
m_pDoc
,
formula
::
FormulaGrammar
::
GRAM_ENGLISH_XL_R1C1
);
ScDocFunc
&
rFunc
=
getDocShell
().
GetDocFunc
();
ScMarkData
aMark
;
aMark
.
SelectOneTable
(
0
);
// First, test a single cell case. A value in B1 and formula in C1.
m_pDoc
->
SetValue
(
ScAddress
(
1
,
0
,
0
),
11.0
);
m_pDoc
->
SetString
(
ScAddress
(
2
,
0
,
0
),
"=RC[-1]"
);
CPPUNIT_ASSERT_EQUAL
(
11.0
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
0
,
0
)));
// Delete column B.
rFunc
.
DeleteCells
(
ScRange
(
1
,
0
,
0
,
1
,
MAXROW
,
0
),
&
aMark
,
DEL_CELLSLEFT
,
true
,
true
);
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"#REF!"
),
m_pDoc
->
GetString
(
ScAddress
(
1
,
0
,
0
)));
// The reference should still point to row 1 but the column status should be set to 'deleted'.
const
ScFormulaCell
*
pFC
=
m_pDoc
->
GetFormulaCell
(
ScAddress
(
1
,
0
,
0
));
CPPUNIT_ASSERT
(
pFC
);
const
ScTokenArray
*
pCode
=
pFC
->
GetCode
();
CPPUNIT_ASSERT
(
pCode
&&
pCode
->
GetLen
()
==
1
);
const
FormulaToken
*
pToken
=
pCode
->
GetArray
()[
0
];
CPPUNIT_ASSERT
(
pToken
->
GetType
()
==
svSingleRef
);
const
ScSingleRefData
*
pSRef
=
&
static_cast
<
const
ScToken
*>
(
pToken
)
->
GetSingleRef
();
CPPUNIT_ASSERT
(
pSRef
->
IsColDeleted
());
CPPUNIT_ASSERT_EQUAL
(
static_cast
<
SCROW
>
(
0
),
pSRef
->
toAbs
(
ScAddress
(
1
,
0
,
0
)).
Row
());
// The formula string should show #REF! in lieu of the column position (only for Calc A1 syntax).
sc
::
CompileFormulaContext
aCFCxt
(
m_pDoc
,
FormulaGrammar
::
GRAM_ENGLISH
);
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"=#REF!1"
),
pFC
->
GetFormula
(
aCFCxt
));
SfxUndoManager
*
pUndoMgr
=
m_pDoc
->
GetUndoManager
();
CPPUNIT_ASSERT
(
pUndoMgr
);
// Undo and make sure the deleted flag is gone.
pUndoMgr
->
Undo
();
CPPUNIT_ASSERT_EQUAL
(
11.0
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
0
,
0
)));
pFC
=
m_pDoc
->
GetFormulaCell
(
ScAddress
(
2
,
0
,
0
));
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"=B1"
),
pFC
->
GetFormula
(
aCFCxt
));
// Clear row 1 and move over to a formula group case.
clearRange
(
m_pDoc
,
ScRange
(
0
,
0
,
0
,
MAXCOL
,
0
,
0
));
// Fill A1:B2 with numbers, and C1:C2 with formula that reference those numbers.
for
(
SCROW
i
=
0
;
i
<=
1
;
++
i
)
{
m_pDoc
->
SetValue
(
ScAddress
(
0
,
i
,
0
),
(
i
+
1
));
m_pDoc
->
SetValue
(
ScAddress
(
1
,
i
,
0
),
(
i
+
11
));
m_pDoc
->
SetString
(
ScAddress
(
2
,
i
,
0
),
"=RC[-2]+RC[-1]"
);
double
fCheck
=
m_pDoc
->
GetValue
(
ScAddress
(
0
,
i
,
0
));
fCheck
+=
m_pDoc
->
GetValue
(
ScAddress
(
1
,
i
,
0
));
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
i
,
0
)));
}
// Delete column B.
rFunc
.
DeleteCells
(
ScRange
(
1
,
0
,
0
,
1
,
MAXROW
,
0
),
&
aMark
,
DEL_CELLSLEFT
,
true
,
true
);
for
(
SCROW
i
=
0
;
i
<=
1
;
++
i
)
{
ScAddress
aPos
(
1
,
i
,
0
);
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"#REF!"
),
m_pDoc
->
GetString
(
aPos
));
}
pFC
=
m_pDoc
->
GetFormulaCell
(
ScAddress
(
1
,
0
,
0
));
// B1
CPPUNIT_ASSERT
(
pFC
);
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"=A1+#REF!1"
),
pFC
->
GetFormula
(
aCFCxt
));
pFC
=
m_pDoc
->
GetFormulaCell
(
ScAddress
(
1
,
1
,
0
));
// B2
CPPUNIT_ASSERT
(
pFC
);
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"=A2+#REF!2"
),
pFC
->
GetFormula
(
aCFCxt
));
// Undo deletion of column B and check the results of C1:C2.
pUndoMgr
->
Undo
();
for
(
SCROW
i
=
0
;
i
<=
1
;
++
i
)
{
double
fCheck
=
m_pDoc
->
GetValue
(
ScAddress
(
0
,
i
,
0
));
fCheck
+=
m_pDoc
->
GetValue
(
ScAddress
(
1
,
i
,
0
));
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
i
,
0
)));
}
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testSharedFormulasRefUpdateMoveSheets
()
{
m_pDoc
->
InsertTab
(
0
,
"Sheet1"
);
...
...
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