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
a3d71e97
Kaydet (Commit)
a3d71e97
authored
Mar 23, 2012
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
New unit test for pivot table with date grouping.
üst
914e7978
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
2 deletions
+120
-2
ucalc.cxx
sc/qa/unit/ucalc.cxx
+120
-2
No files found.
sc/qa/unit/ucalc.cxx
Dosyayı görüntüle @
a3d71e97
...
...
@@ -75,6 +75,7 @@
#include <sfx2/docfile.hxx>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <ucbhelper/contentbroker.hxx>
...
...
@@ -161,8 +162,8 @@ public:
void
testPivotTableDuplicateDataFields
();
void
testPivotTableNormalGrouping
();
void
testPivotTableNumberGrouping
();
void
testPivotTableDateGrouping
();
void
testSheetCopy
();
void
testSheetMove
();
...
...
@@ -222,6 +223,7 @@ public:
CPPUNIT_TEST
(
testPivotTableDuplicateDataFields
);
CPPUNIT_TEST
(
testPivotTableNormalGrouping
);
CPPUNIT_TEST
(
testPivotTableNumberGrouping
);
CPPUNIT_TEST
(
testPivotTableDateGrouping
);
CPPUNIT_TEST
(
testSheetCopy
);
CPPUNIT_TEST
(
testSheetMove
);
CPPUNIT_TEST
(
testExternalRef
);
...
...
@@ -1245,7 +1247,6 @@ ScDPObject* createDPFromSourceDesc(
ScDPSaveDimension
*
pDim
=
aSaveData
.
GetNewDimensionByName
(
aDimName
);
pDim
->
SetOrientation
(
static_cast
<
sal_uInt16
>
(
aFields
[
i
].
eOrient
));
pDim
->
SetUsedHierarchy
(
0
);
pDim
->
SetShowEmpty
(
true
);
if
(
aFields
[
i
].
eOrient
==
sheet
::
DataPilotFieldOrientation_DATA
)
{
...
...
@@ -2424,6 +2425,123 @@ void Test::testPivotTableNumberGrouping()
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testPivotTableDateGrouping
()
{
m_pDoc
->
InsertTab
(
0
,
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Data"
)));
m_pDoc
->
InsertTab
(
1
,
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"Table"
)));
// Raw data
const
char
*
aData
[][
2
]
=
{
{
"Date"
,
"Value"
},
{
"2011-01-01"
,
"1"
},
{
"2011-03-02"
,
"2"
},
{
"2012-01-04"
,
"3"
},
{
"2012-02-23"
,
"4"
},
{
"2012-02-24"
,
"5"
},
{
"2012-03-15"
,
"6"
},
{
"2011-09-03"
,
"7"
},
{
"2012-12-25"
,
"8"
}
};
// Dimension definition
DPFieldDef
aFields
[]
=
{
{
"Date"
,
sheet
::
DataPilotFieldOrientation_ROW
,
0
},
{
"Value"
,
sheet
::
DataPilotFieldOrientation_DATA
,
sheet
::
GeneralFunction_SUM
},
};
ScAddress
aPos
(
1
,
1
,
0
);
ScRange
aDataRange
=
insertRangeData
(
m_pDoc
,
aPos
,
aData
,
SAL_N_ELEMENTS
(
aData
));
CPPUNIT_ASSERT_MESSAGE
(
"failed to insert range data at correct position"
,
aDataRange
.
aStart
==
aPos
);
ScDPObject
*
pDPObj
=
createDPFromRange
(
m_pDoc
,
aDataRange
,
aFields
,
SAL_N_ELEMENTS
(
aFields
),
false
);
ScDPCollection
*
pDPs
=
m_pDoc
->
GetDPCollection
();
bool
bSuccess
=
pDPs
->
InsertNewTable
(
pDPObj
);
CPPUNIT_ASSERT_MESSAGE
(
"failed to insert a new pivot table object into document."
,
bSuccess
);
CPPUNIT_ASSERT_MESSAGE
(
"there should be only one data pilot table."
,
pDPs
->
GetCount
()
==
1
);
pDPObj
->
SetName
(
pDPs
->
CreateNewName
());
ScDPSaveData
*
pSaveData
=
pDPObj
->
GetSaveData
();
CPPUNIT_ASSERT_MESSAGE
(
"No save data !?"
,
pSaveData
);
ScDPDimensionSaveData
*
pDimData
=
pSaveData
->
GetDimensionData
();
CPPUNIT_ASSERT_MESSAGE
(
"No dimension data !?"
,
pDimData
);
rtl
::
OUString
aBaseDimName
(
RTL_CONSTASCII_USTRINGPARAM
(
"Date"
));
ScDPNumGroupInfo
aInfo
;
aInfo
.
mbEnable
=
true
;
aInfo
.
mbAutoStart
=
true
;
aInfo
.
mbAutoEnd
=
true
;
{
// Turn the Date dimension into months. The first of the date
// dimensions is always a number-group dimension which replaces the
// original dimension.
ScDPSaveNumGroupDimension
aGroup
(
aBaseDimName
,
aInfo
,
sheet
::
DataPilotFieldGroupBy
::
MONTHS
);
pDimData
->
AddNumGroupDimension
(
aGroup
);
}
{
// Add quarter dimension. This will be an additional dimension.
rtl
::
OUString
aGroupDimName
=
pDimData
->
CreateDateGroupDimName
(
sheet
::
DataPilotFieldGroupBy
::
QUARTERS
,
*
pDPObj
,
true
,
NULL
);
ScDPSaveGroupDimension
aGroupDim
(
aBaseDimName
,
aGroupDimName
);
aGroupDim
.
SetDateInfo
(
aInfo
,
sheet
::
DataPilotFieldGroupBy
::
QUARTERS
);
pDimData
->
AddGroupDimension
(
aGroupDim
);
// Set orientation.
ScDPSaveDimension
*
pDim
=
pSaveData
->
GetDimensionByName
(
aGroupDimName
);
pDim
->
SetOrientation
(
sheet
::
DataPilotFieldOrientation_ROW
);
pSaveData
->
SetPosition
(
pDim
,
0
);
// set it to the left end.
}
{
// Add year dimension. This is a new dimension also.
rtl
::
OUString
aGroupDimName
=
pDimData
->
CreateDateGroupDimName
(
sheet
::
DataPilotFieldGroupBy
::
YEARS
,
*
pDPObj
,
true
,
NULL
);
ScDPSaveGroupDimension
aGroupDim
(
aBaseDimName
,
aGroupDimName
);
aGroupDim
.
SetDateInfo
(
aInfo
,
sheet
::
DataPilotFieldGroupBy
::
YEARS
);
pDimData
->
AddGroupDimension
(
aGroupDim
);
// Set orientation.
ScDPSaveDimension
*
pDim
=
pSaveData
->
GetDimensionByName
(
aGroupDimName
);
pDim
->
SetOrientation
(
sheet
::
DataPilotFieldOrientation_ROW
);
pSaveData
->
SetPosition
(
pDim
,
0
);
// set it to the left end.
}
pDPObj
->
SetSaveData
(
*
pSaveData
);
ScRange
aOutRange
=
refreshGroups
(
pDPs
,
pDPObj
);
{
// Expected output table content. 0 = empty cell
const
char
*
aOutputCheck
[][
4
]
=
{
{
"Years"
,
"Quarters"
,
"Date"
,
0
},
{
"2011"
,
"Q1"
,
"Jan"
,
"1"
},
{
0
,
0
,
"Mar"
,
"2"
},
{
0
,
"Q3"
,
"Sep"
,
"7"
},
{
"2012"
,
"Q1"
,
"Jan"
,
"3"
},
{
0
,
0
,
"Feb"
,
"9"
},
{
0
,
0
,
"Mar"
,
"6"
},
{
0
,
"Q4"
,
"Dec"
,
"8"
},
{
"Total Result"
,
0
,
0
,
"36"
},
};
bSuccess
=
checkDPTableOutput
<
4
>
(
m_pDoc
,
aOutRange
,
aOutputCheck
,
"Years, quarters and months date groups."
);
CPPUNIT_ASSERT_MESSAGE
(
"Table output check failed"
,
bSuccess
);
}
pDPs
->
FreeTable
(
pDPObj
);
CPPUNIT_ASSERT_MESSAGE
(
"There should be no more tables."
,
pDPs
->
GetCount
()
==
0
);
CPPUNIT_ASSERT_MESSAGE
(
"There shouldn't be any more cache stored."
,
pDPs
->
GetSheetCaches
().
size
()
==
0
);
m_pDoc
->
DeleteTab
(
1
);
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testSheetCopy
()
{
OUString
aTabName
(
RTL_CONSTASCII_USTRINGPARAM
(
"TestTab"
));
...
...
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