Kaydet (Commit) cbe46bbe authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Simplified the filter test a bit, and clear the filter afterward.

üst 97453f1e
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "undoblk.hxx" #include "undoblk.hxx"
#include "queryentry.hxx" #include "queryentry.hxx"
#include "postit.hxx" #include "postit.hxx"
#include "attrib.hxx"
#include "docsh.hxx" #include "docsh.hxx"
#include "docfunc.hxx" #include "docfunc.hxx"
...@@ -2194,53 +2195,64 @@ void Test::testToggleRefFlag() ...@@ -2194,53 +2195,64 @@ void Test::testToggleRefFlag()
void Test::testAutofilter() void Test::testAutofilter()
{ {
OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Test")); OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Test"));
OUString aDBName(RTL_CONSTASCII_USTRINGPARAM("NONAME"));
m_pDoc->InsertTab( 0, aTabName ); m_pDoc->InsertTab( 0, aTabName );
OUString aCol1(RTL_CONSTASCII_USTRINGPARAM("COL1")); // cell contents (0 = empty cell)
OUString aCol2(RTL_CONSTASCII_USTRINGPARAM("COL2")); const char* aData[][3] = {
OUString aDBName(RTL_CONSTASCII_USTRINGPARAM("NONAME")); { "C1", "C2", "C3" },
{ "0", "1", "A" },
{ "1", "2", 0 },
{ "1", "2", "B" },
{ "0", "2", "B" }
};
//set column headers SCCOL nCols = SAL_N_ELEMENTS(aData[0]);
m_pDoc->SetString(0,0,0,aCol1); SCROW nRows = SAL_N_ELEMENTS(aData);
m_pDoc->SetString(1,0,0,aCol2);
//set values // Populate cells.
m_pDoc->SetValue(0,1,0,0); for (SCROW i = 0; i < nRows; ++i)
m_pDoc->SetValue(1,1,0,1); for (SCCOL j = 0; j < nCols; ++j)
m_pDoc->SetValue(0,2,0,1); if (aData[i][j])
m_pDoc->SetValue(1,2,0,3); m_pDoc->SetString(j, i, 0, rtl::OUString::createFromAscii(aData[i][j]));
m_pDoc->SetValue(0,3,0,1);
m_pDoc->SetValue(1,3,0,2);
//create db data and set it to autofilter ScDBData* pDBData = new ScDBData(aDBName, 0, 0, 0, nCols-1, nRows-1);
ScDBData* pDBData = new ScDBData(aDBName,0,0,0,1,3);
m_pDoc->SetAnonymousDBData(0,pDBData); m_pDoc->SetAnonymousDBData(0,pDBData);
pDBData->SetAutoFilter(true); pDBData->SetAutoFilter(true);
ScRange aRange; ScRange aRange;
pDBData->GetArea(aRange); pDBData->GetArea(aRange);
m_pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(), m_pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
aRange.aStart.Tab(), 4 ); aRange.aStart.Tab(), SC_MF_AUTO);
//create the query param //create the query param
ScQueryParam aParam; ScQueryParam aParam;
aParam.Resize(1); pDBData->GetQueryParam(aParam);
ScQueryEntry& aEntry = aParam.GetEntry(0); ScQueryEntry& rEntry = aParam.GetEntry(0);
aEntry.bDoQuery = true; rEntry.bDoQuery = true;
aEntry.eOp = SC_EQUAL; rEntry.nField = 0;
aEntry.GetQueryItem().mfVal = 0; rEntry.eOp = SC_EQUAL;
//add queryParam to autofilter rEntry.GetQueryItem().mfVal = 0;
// add queryParam to database range.
pDBData->SetQueryParam(aParam); pDBData->SetQueryParam(aParam);
//perform the query
ScDBDocFunc aDBFunc(*m_xDocShRef); // perform the query.
aDBFunc.RepeatDB(aCol1,true,true,true,0); m_pDoc->Query(0, aParam, true);
//control output //control output
SCROW nRow1, nRow2; SCROW nRow1, nRow2;
bool bHidden = m_pDoc->RowHidden(2, 0, &nRow1, &nRow2); bool bHidden = m_pDoc->RowHidden(2, 0, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("rows 2 & 3 should be hidden", bHidden && nRow1 == 2 && nRow2 == 3); CPPUNIT_ASSERT_MESSAGE("rows 2 & 3 should be hidden", bHidden && nRow1 == 2 && nRow2 == 3);
// Remove filtering.
aParam.GetEntry(0).Clear();
pDBData->SetQueryParam(aParam);
m_pDoc->Query(0, aParam, true);
bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("All rows should be shown.", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0);
} }
......
...@@ -229,10 +229,9 @@ void ScQueryParam::Clear() ...@@ -229,10 +229,9 @@ void ScQueryParam::Clear()
bHasHeader = bCaseSens = bRegExp = bMixedComparison = false; bHasHeader = bCaseSens = bRegExp = bMixedComparison = false;
bInplace = bByRow = bDuplicate = sal_True; bInplace = bByRow = bDuplicate = sal_True;
boost::ptr_vector<ScQueryEntry> aNewEntries; boost::ptr_vector<ScQueryEntry>::iterator itr = maEntries.begin(), itrEnd = maEntries.end();
for (size_t i = 0; i < MAXQUERY; ++i) for (; itr != itrEnd; ++itr)
aNewEntries.push_back(new ScQueryEntry); itr->Clear();
maEntries.swap(aNewEntries);
ClearDestParams(); ClearDestParams();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment