namespace sc_apitest
{ class CheckDataPilotField : public UnoApiTest, public apitest::XNamed, public apitest::XPropertySet
{ public:
CheckDataPilotField();
// position of the data pilot table
table::CellAddress sCellAddress;
sCellAddress.Sheet = 0;
sCellAddress.Column = 7;
sCellAddress.Row = 8; // Getting spreadsheet
uno::Reference<sheet::XSpreadsheets> xSpreadsheets = xSheetDoc->getSheets();
uno::Reference<container::XIndexAccess> oIndexAccess(xSpreadsheets, uno::UNO_QUERY_THROW);
// Per default there's now just one sheet, make sure we have at least two, then
xSpreadsheets->insertNewByName(u"Some Sheet"_ustr, 0);
uno::Any aAny = oIndexAccess->getByIndex(0);
uno::Reference<sheet::XSpreadsheet> oSheet;
CPPUNIT_ASSERT(aAny >>= oSheet);
//Filling a table for (int i = 1; i < mMaxFieldIndex; i++)
{
oSheet->getCellByPosition(i, 0)->setFormula("Col" + OUString::number(i));
oSheet->getCellByPosition(0, i)->setFormula("Row" + OUString::number(i));
oSheet2->getCellByPosition(i, 0)->setFormula("Col" + OUString::number(i));
oSheet2->getCellByPosition(0, i)->setFormula("Row" + OUString::number(i));
}
for (int i = 1; i < mMaxFieldIndex; i++)
{ for (int j = 1; j < mMaxFieldIndex; j++)
{
oSheet->getCellByPosition(i, j)->setValue(i * (j + 1));
oSheet2->getCellByPosition(i, j)->setValue(i * (j + 2));
}
}
// change a value of a cell and check the change in the data pilot // cell of data
uno::Any oChangeCell;
oChangeCell <<= oSheet->getCellByPosition(1, 5); int x = sCellAddress.Column; int y = sCellAddress.Row + 3; // cell of the data pilot output
uno::Any oCheckCell;
oCheckCell <<= oSheet->getCellByPosition(x, y); // create the test objects
uno::Reference<sheet::XDataPilotTablesSupplier> DPTS(oSheet, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XDataPilotTables> DPT = DPTS->getDataPilotTables();
uno::Reference<sheet::XDataPilotDescriptor> DPDsc = DPT->createDataPilotDescriptor();
DPDsc->setSourceRange(sCellRangeAddress);
uno::Any sum;
sum <<= sheet::GeneralFunction_SUM;
fieldPropSet->setPropertyValue(u"Function"_ustr, sum);
uno::Any data;
data <<= sheet::DataPilotFieldOrientation_DATA;
fieldPropSet->setPropertyValue(u"Orientation"_ustr, data);
//Insert the DataPilotTable if (DPT->hasByName(u"DataPilotField"_ustr))
DPT->removeByName(u"DataPilotField"_ustr);
DPT->insertNewByName(u"DataPilotTField"_ustr, sCellAddress, DPDsc);
uno::Reference<container::XIndexAccess> IA = DPDsc->getDataPilotFields();
uno::Reference<uno::XInterface> xDataPilotFieldObject;
data = IA->getByIndex(0);
CPPUNIT_ASSERT(data >>= xDataPilotFieldObject);
mxObject = xDataPilotFieldObject;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.