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
a603ddf9
Kaydet (Commit)
a603ddf9
authored
Mar 25, 2014
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#76402: Write unit test for this first.
Change-Id: Ib4fccb0e29d4a21a211de4af2cdeaf956f9b9cc6
üst
76ada569
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
0 deletions
+87
-0
document.hxx
sc/inc/document.hxx
+13
-0
ucalc.hxx
sc/qa/unit/ucalc.hxx
+2
-0
ucalc_formula.cxx
sc/qa/unit/ucalc_formula.cxx
+62
-0
documen3.cxx
sc/source/core/data/documen3.cxx
+10
-0
No files found.
sc/inc/document.hxx
Dosyayı görüntüle @
a603ddf9
...
...
@@ -514,6 +514,19 @@ public:
SC_DLLPUBLIC
ScRangeName
*
GetRangeName
()
const
;
void
SetRangeName
(
SCTAB
nTab
,
ScRangeName
*
pNew
);
void
SetRangeName
(
ScRangeName
*
pNewRangeName
);
/**
* Insert a new named expression to the global scope.
*
* @param rName name for the expression.
* @param rPos base position.
* @param rExpr formula expression to be associated with the name. The
* current grammer is used to compile this expression.
*
* @return true if inserted successfully, false otherwise.
*/
bool
InsertNewRangeName
(
const
OUString
&
rName
,
const
ScAddress
&
rPos
,
const
OUString
&
rExpr
);
SCTAB
GetMaxTableNumber
()
{
return
static_cast
<
SCTAB
>
(
maTabs
.
size
())
-
1
;
}
void
SetMaxTableNumber
(
SCTAB
nNumber
)
{
nMaxTableNumber
=
nNumber
;
}
...
...
sc/qa/unit/ucalc.hxx
Dosyayı görüntüle @
a603ddf9
...
...
@@ -121,6 +121,7 @@ public:
void
testFormulaRefUpdateMove
();
void
testFormulaRefUpdateMoveUndo
();
void
testFormulaRefUpdateNamedExpression
();
void
testFormulaRefUpdateNamedExpressionExpandRef
();
void
testMultipleOperations
();
void
testFuncCOLUMN
();
void
testFuncCOUNT
();
...
...
@@ -366,6 +367,7 @@ public:
CPPUNIT_TEST
(
testFormulaRefUpdateMove
);
CPPUNIT_TEST
(
testFormulaRefUpdateMoveUndo
);
CPPUNIT_TEST
(
testFormulaRefUpdateNamedExpression
);
CPPUNIT_TEST
(
testFormulaRefUpdateNamedExpressionExpandRef
);
CPPUNIT_TEST
(
testMultipleOperations
);
CPPUNIT_TEST
(
testFuncCOLUMN
);
CPPUNIT_TEST
(
testFuncCOUNT
);
...
...
sc/qa/unit/ucalc_formula.cxx
Dosyayı görüntüle @
a603ddf9
...
...
@@ -1818,6 +1818,68 @@ void Test::testFormulaRefUpdateNamedExpression()
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testFormulaRefUpdateNamedExpressionExpandRef
()
{
m_pDoc
->
InsertTab
(
0
,
"Test"
);
m_pDoc
->
SetExpandRefs
(
true
);
// turn on automatic range expansion.
sc
::
AutoCalcSwitch
aACSwitch
(
*
m_pDoc
,
true
);
// turn auto calc on.
bool
bInserted
=
m_pDoc
->
InsertNewRangeName
(
"MyRange"
,
ScAddress
(
0
,
0
,
0
),
"$A$1:$A$3"
);
CPPUNIT_ASSERT
(
bInserted
);
// Set values to A1:A3.
m_pDoc
->
SetValue
(
ScAddress
(
0
,
0
,
0
),
1.0
);
m_pDoc
->
SetValue
(
ScAddress
(
0
,
1
,
0
),
2.0
);
m_pDoc
->
SetValue
(
ScAddress
(
0
,
2
,
0
),
3.0
);
m_pDoc
->
SetString
(
ScAddress
(
0
,
5
,
0
),
"=SUM(MyRange)"
);
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
5
,
0
)));
// Insert a new row at row 4, which should expand the named range to A1:A4.
ScDocFunc
&
rFunc
=
getDocShell
().
GetDocFunc
();
ScMarkData
aMark
;
aMark
.
SelectOneTable
(
0
);
rFunc
.
InsertCells
(
ScRange
(
0
,
3
,
0
,
MAXCOL
,
3
,
0
),
&
aMark
,
INS_INSROWS
,
false
,
true
,
false
);
ScRangeData
*
pName
=
m_pDoc
->
GetRangeName
()
->
findByUpperName
(
"MYRANGE"
);
CPPUNIT_ASSERT
(
pName
);
OUString
aSymbol
;
pName
->
GetSymbol
(
aSymbol
,
m_pDoc
->
GetGrammar
());
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"$A$1:$A$4"
),
aSymbol
);
// Make sure the listening area has been expanded as well. Note the
// formula cell has been pushed downward by one cell.
m_pDoc
->
SetValue
(
ScAddress
(
0
,
3
,
0
),
4.0
);
CPPUNIT_ASSERT_EQUAL
(
10.0
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
6
,
0
)));
// Clear the document and start over.
m_pDoc
->
GetRangeName
()
->
clear
();
clearSheet
(
m_pDoc
,
0
);
// Set values to B4:B6.
m_pDoc
->
SetValue
(
ScAddress
(
1
,
3
,
0
),
1.0
);
m_pDoc
->
SetValue
(
ScAddress
(
1
,
4
,
0
),
2.0
);
m_pDoc
->
SetValue
(
ScAddress
(
1
,
5
,
0
),
3.0
);
bInserted
=
m_pDoc
->
InsertNewRangeName
(
"MyRange"
,
ScAddress
(
0
,
0
,
0
),
"$B$4:$B$6"
);
CPPUNIT_ASSERT
(
bInserted
);
// Set formula to A1.
m_pDoc
->
SetString
(
ScAddress
(
0
,
0
,
0
),
"=SUM(MyRange)"
);
CPPUNIT_ASSERT_EQUAL
(
6.0
,
m_pDoc
->
GetValue
(
0
,
0
,
0
));
// Insert rows over 3:5 which should expand the range by 3 rows.
rFunc
.
InsertCells
(
ScRange
(
0
,
2
,
0
,
MAXCOL
,
4
,
0
),
&
aMark
,
INS_INSROWS
,
false
,
true
,
false
);
pName
=
m_pDoc
->
GetRangeName
()
->
findByUpperName
(
"MYRANGE"
);
CPPUNIT_ASSERT
(
pName
);
pName
->
GetSymbol
(
aSymbol
,
m_pDoc
->
GetGrammar
());
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"$B$4:$B$9"
),
aSymbol
);
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testMultipleOperations
()
{
m_pDoc
->
InsertTab
(
0
,
"MultiOp"
);
...
...
sc/source/core/data/documen3.cxx
Dosyayı görüntüle @
a603ddf9
...
...
@@ -207,6 +207,16 @@ void ScDocument::SetRangeName( ScRangeName* pNewRangeName )
pRangeName
=
pNewRangeName
;
}
bool
ScDocument
::
InsertNewRangeName
(
const
OUString
&
rName
,
const
ScAddress
&
rPos
,
const
OUString
&
rExpr
)
{
ScRangeName
*
pGlobalNames
=
GetRangeName
();
if
(
!
pGlobalNames
)
return
false
;
ScRangeData
*
pName
=
new
ScRangeData
(
this
,
rName
,
rExpr
,
rPos
,
RT_NAME
,
GetGrammar
());
return
pGlobalNames
->
insert
(
pName
);
}
const
ScRangeData
*
ScDocument
::
GetRangeAtBlock
(
const
ScRange
&
rBlock
,
OUString
*
pName
)
const
{
const
ScRangeData
*
pData
=
NULL
;
...
...
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