Kaydet (Commit) cceef188 authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move _XFormulaQuery Java tests to C++

Enable tests for ScTableSheetObj and fixes #i86793.

Change-Id: Ic9914fd74a70034e4adc7e55203c92935a472f9d
Reviewed-on: https://gerrit.libreoffice.org/55782
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 3a3bf63b
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_SHEET_XFORMULAQUERY_HXX
#define INCLUDED_TEST_SHEET_XFORMULAQUERY_HXX
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST XFormulaQuery
{
public:
XFormulaQuery(css::table::CellRangeAddress aCellRangeAddressDependents,
css::table::CellRangeAddress aCellRangeAddressPrecedents,
unsigned int nIdxDependents = 1, unsigned int nIdxPrecedents = 1)
: m_aCellRangeAddressDependents(aCellRangeAddressDependents)
, m_aCellRangeAddressPrecedents(aCellRangeAddressPrecedents)
, m_nIdxDependents(nIdxDependents)
, m_nIdxPrecedents(nIdxPrecedents)
{
}
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual css::uno::Reference<css::uno::XInterface> getXSpreadsheet() = 0;
void setXCell(css::uno::Reference<css::table::XCell> xCell) { m_xCell = xCell; }
css::uno::Reference<css::table::XCell> getXCell() { return m_xCell; }
void testQueryDependents();
void testQueryPrecedents();
protected:
~XFormulaQuery() {}
private:
css::uno::Reference<css::table::XCell> m_xCell;
css::table::CellRangeAddress m_aCellRangeAddressDependents;
css::table::CellRangeAddress m_aCellRangeAddressPrecedents;
unsigned int m_nIdxDependents;
unsigned int m_nIdxPrecedents;
};
} // namespace apitest
#endif // INCLUDED_TEST_SHEET_XFORMULAQUERY_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -568,7 +568,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
qadevOOo/tests/java/ifc/sheet/_XFormulaQuery \
qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
......
......@@ -114,8 +114,6 @@
"ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontPitchComplex"
"ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharPostureComplex"
"ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
"ScCellCursorObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScCellCursorObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScCellCursorObj";"com::sun::star::util::XIndent";"decrementIndent()"
"ScCellCursorObj";"com::sun::star::util::XIndent";"incrementIndent()"
"ScCellCursorObj";"com::sun::star::table::XAutoFormattable";"autoFormat()"
......
......@@ -109,8 +109,6 @@
"ScCellObj";"com::sun::star::style::CharacterPropertiesComplex";"CharPostureComplex"
"ScCellObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
"ScCellObj";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()"
"ScCellObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScCellObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()"
"ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionEnds()"
"ScCellObj";"com::sun::star::util::XIndent";"decrementIndent()"
......
......@@ -109,8 +109,6 @@
"ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontPitchComplex"
"ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharPostureComplex"
"ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
"ScCellRangeObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScCellRangeObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScCellRangeObj";"com::sun::star::util::XIndent";"decrementIndent()"
"ScCellRangeObj";"com::sun::star::util::XIndent";"incrementIndent()"
"ScCellRangeObj";"com::sun::star::table::XAutoFormattable";"autoFormat()"
......
......@@ -113,8 +113,6 @@
"ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontPitchComplex"
"ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharPostureComplex"
"ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
"ScCellRangesObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScCellRangesObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScCellRangesObj";"com::sun::star::util::XIndent";"decrementIndent()"
"ScCellRangesObj";"com::sun::star::util::XIndent";"incrementIndent()"
"ScCellRangesObj";"com::sun::star::sheet::XCellRangesQuery";"queryVisibleCells()"
......
......@@ -112,8 +112,6 @@
"ScTableSheetObj";"com::sun::star::util::XProtectable";"protect()"
"ScTableSheetObj";"com::sun::star::util::XProtectable";"unprotect()"
"ScTableSheetObj";"com::sun::star::util::XProtectable";"isProtected()"
"ScTableSheetObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScTableSheetObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScTableSheetObj";"com::sun::star::util::XIndent";"decrementIndent()"
"ScTableSheetObj";"com::sun::star::util::XIndent";"incrementIndent()"
"ScTableSheetObj";"com::sun::star::table::XAutoFormattable";"autoFormat()"
......
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package ifc.sheet;
import lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.sheet.XFormulaQuery;
import com.sun.star.sheet.XSheetCellRanges;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.table.XCell;
import com.sun.star.uno.UnoRuntime;
public class _XFormulaQuery extends MultiMethodTest {
public XFormulaQuery oObj;
protected XSpreadsheet oSheet = null;
private XCell mxCell;
private int miQueryThisDependentRange = 1;
private int miQueryThisPrecedentRange = 1;
private int[] miExpectedDependentValues;
private int[] miExpectedPrecedentValues;
@Override
protected void before() {
oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET");
if (oSheet == null) {
log.println("Object relation oSheet is missing");
log.println("Trying to query the needed Interface");
oSheet = UnoRuntime.queryInterface(
XSpreadsheet.class, tEnv.getTestObject());
if (oSheet == null) {
throw new StatusException(Status.failed(
"Object relation oSheet is missing"));
}
}
Object o = tEnv.getObjRelation("MAKEENTRYINCELL");
if (o != null) {
mxCell = (XCell)o;
}
else {
try {
mxCell = oSheet.getCellByPosition(15, 15);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
throw new StatusException(e, Status.failed("Couldn't get initial cell"));
}
}
o = tEnv.getObjRelation("RANGEINDICES");
if (o != null) {
int[]index = (int[])o;
miQueryThisDependentRange = index[0];
miQueryThisPrecedentRange = index[1];
}
o = tEnv.getObjRelation("EXPECTEDDEPENDENTVALUES");
if (o != null) {
miExpectedDependentValues = (int[])o;
}
else {
miExpectedDependentValues = new int[4];
miExpectedDependentValues[0] = 15;
miExpectedDependentValues[1] = 15;
miExpectedDependentValues[2] = 15;
miExpectedDependentValues[3] = 15;
}
o = tEnv.getObjRelation("EXPECTEDPRECEDENTVALUES");
if (o != null) {
miExpectedPrecedentValues = (int[])o;
}
else {
miExpectedPrecedentValues = new int[4];
miExpectedPrecedentValues[0] = 0;
miExpectedPrecedentValues[1] = 0;
miExpectedPrecedentValues[2] = 15;
miExpectedPrecedentValues[3] = 15;
}
}
public void _queryDependents() {
boolean res = true;
try {
mxCell.setFormula("=sum(A1:D1)");
oSheet.getCellByPosition(0, 0).setValue(1);
oSheet.getCellByPosition(1, 0).setValue(1);
oSheet.getCellByPosition(2, 0).setValue(1);
oSheet.getCellByPosition(3, 0).setValue(1);
log.println(
"calling oObj.queryDependents(false)");
XSheetCellRanges getting = oObj.queryDependents(false);
CellRangeAddress[] range = getting.getRangeAddresses();
res = ((range[miQueryThisDependentRange].StartColumn==miExpectedDependentValues[0]) &&
(range[miQueryThisDependentRange].EndColumn==miExpectedDependentValues[1]) &&
(range[miQueryThisDependentRange].StartRow==miExpectedDependentValues[2]) &&
(range[miQueryThisDependentRange].EndRow==miExpectedDependentValues[3]));
if (!res) {
log.println("Getting ("
+(range[miQueryThisDependentRange]).StartColumn+","
+(range[miQueryThisDependentRange]).EndColumn+","
+(range[miQueryThisDependentRange]).StartRow+","
+(range[miQueryThisDependentRange]).EndRow+")");
log.println("Expected (" + miExpectedDependentValues[0] + "," +
miExpectedDependentValues[1] + "," +
miExpectedDependentValues[2] + "," +
miExpectedDependentValues[3] + ")");
}
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Couldn't set initial version to cell");
res = false;
}
tRes.tested("queryDependents()", res);
}
public void _queryPrecedents() {
boolean res = true;
try {
mxCell.setFormula("=sum(A1:D1)");
oSheet.getCellByPosition(0, 0).setValue(1);
oSheet.getCellByPosition(1, 0).setValue(1);
oSheet.getCellByPosition(2, 0).setValue(1);
oSheet.getCellByPosition(3, 0).setValue(1);
oSheet.getCellByPosition(1, 2).setFormula("=A16*2");
log.println(
"calling oObj.queryPrecedents(false)");
XSheetCellRanges getting = oObj.queryPrecedents(false);
CellRangeAddress[] range = getting.getRangeAddresses();
res = ((range[miQueryThisPrecedentRange].StartColumn==miExpectedPrecedentValues[0]) &&
(range[miQueryThisPrecedentRange].EndColumn==miExpectedPrecedentValues[1]) &&
(range[miQueryThisPrecedentRange].StartRow==miExpectedPrecedentValues[2]) &&
(range[miQueryThisPrecedentRange].EndRow==miExpectedPrecedentValues[3]));
if (!res) {
log.println("Getting ("
+(range[miQueryThisPrecedentRange]).StartColumn+","
+(range[miQueryThisPrecedentRange]).EndColumn+","
+(range[miQueryThisPrecedentRange]).StartRow+","
+(range[miQueryThisPrecedentRange]).EndRow+")");
log.println("Expected (" + miExpectedPrecedentValues[0] + "," +
miExpectedPrecedentValues[1] + "," +
miExpectedPrecedentValues[2] + "," +
miExpectedPrecedentValues[3] + ")");
}
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Couldn't set initial version to cell");
res = false;
}
tRes.tested("queryPrecedents()", res);
}
/**
* Forces environment recreation.
*/
@Override
protected void after() {
disposeEnvironment();
}
}
......@@ -15,6 +15,7 @@
#include <test/sheet/xcellrangedata.hxx>
#include <test/sheet/xcellrangeformula.hxx>
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xmultipleoperation.hxx>
#include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx>
......@@ -40,6 +41,7 @@ class ScCellCursorObj : public CalcUnoApiTest, public apitest::SheetCellRange,
public apitest::XCellRangeData,
public apitest::XCellRangeFormula,
public apitest::XCellSeries,
public apitest::XFormulaQuery,
public apitest::XMultipleOperation,
public apitest::XSheetCellRange,
public apitest::XSheetFilterable,
......@@ -83,6 +85,10 @@ public:
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
// XFormulaQuery
CPPUNIT_TEST(testQueryDependents);
CPPUNIT_TEST(testQueryPrecedents);
// XMultipleOperation
CPPUNIT_TEST(testSetTableOperation);
......@@ -119,7 +125,8 @@ private:
ScCellCursorObj::ScCellCursorObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XCellSeries(0, 0)
apitest::XCellSeries(0, 0),
apitest::XFormulaQuery(table::CellRangeAddress(0, 15, 15, 15, 15), table::CellRangeAddress(0, 0, 15, 0, 15))
{
}
......@@ -149,6 +156,8 @@ uno::Reference< uno::XInterface > ScCellCursorObj::getXSpreadsheet()
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
setXCell(xSheet->getCellByPosition(15, 15));
return xSheet;
}
......
......@@ -10,6 +10,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/sheetcell.hxx>
#include <test/sheet/xcelladdressable.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xsheetannotationanchor.hxx>
#include <com/sun/star/lang/XComponent.hpp>
......@@ -29,12 +30,14 @@ namespace sc_apitest {
class ScCellObj : public CalcUnoApiTest, public apitest::SheetCell,
public apitest::XCellAddressable,
public apitest::XFormulaQuery,
public apitest::XSheetAnnotationAnchor
{
public:
ScCellObj();
virtual uno::Reference< uno::XInterface > init() override;
virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
virtual void setUp() override;
virtual void tearDown() override;
......@@ -46,6 +49,10 @@ public:
// XCellAddressable
CPPUNIT_TEST(testGetCellAddress);
// XFormulaQuery
CPPUNIT_TEST(testQueryDependents);
CPPUNIT_TEST(testQueryPrecedents);
// XSheetAnnotationAnchor
CPPUNIT_TEST(testGetAnnotation);
......@@ -56,7 +63,8 @@ private:
};
ScCellObj::ScCellObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
: CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XFormulaQuery(table::CellRangeAddress(0, 2, 3, 2, 3), table::CellRangeAddress(0, 0, 0, 3, 0), 0, 0)
{
}
......@@ -76,6 +84,19 @@ uno::Reference< uno::XInterface > ScCellObj::init()
return xSheet->getCellByPosition(2, 3);
}
uno::Reference<uno::XInterface> ScCellObj::getXSpreadsheet()
{
uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheets> xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
setXCell(xSheet->getCellByPosition(2, 3));
return xSheet;
}
void ScCellObj::setUp()
{
CalcUnoApiTest::setUp();
......
......@@ -17,6 +17,7 @@
#include <test/sheet/xcellrangeformula.hxx>
#include <test/sheet/xcellrangesquery.hxx>
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xmultipleoperation.hxx>
#include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx>
......@@ -58,6 +59,7 @@ class ScCellRangeObj : public CalcUnoApiTest, public apitest::CellProperties,
public apitest::XCellRangeFormula,
public apitest::XCellRangesQuery,
public apitest::XCellSeries,
public apitest::XFormulaQuery,
public apitest::XMultipleOperation,
public apitest::XReplaceable,
public apitest::XSearchable,
......@@ -116,6 +118,10 @@ public:
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
// XFormulaQuery
CPPUNIT_TEST(testQueryDependents);
CPPUNIT_TEST(testQueryPrecedents);
// XMultipleOperation
CPPUNIT_TEST(testSetTableOperation);
......@@ -159,6 +165,7 @@ private:
ScCellRangeObj::ScCellRangeObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XCellSeries(2, 1),
apitest::XFormulaQuery(table::CellRangeAddress(0, 15, 15, 15, 15), table::CellRangeAddress(0, 0, 15, 0, 15)),
apitest::XReplaceable("15", "35"),
apitest::XSearchable("15", 1)
{
......@@ -183,6 +190,8 @@ uno::Reference< uno::XInterface > ScCellRangeObj::getXSpreadsheet()
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
setXCell(xSheet->getCellByPosition(15, 15));
return xSheet;
}
......
......@@ -9,6 +9,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/sheetcellranges.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xsheetcellrangecontainer.hxx>
#include <test/sheet/xsheetcellranges.hxx>
#include <test/sheet/xsheetoperation.hxx>
......@@ -30,6 +31,7 @@ namespace sc_apitest {
class ScCellRangesObj : public CalcUnoApiTest,
public apitest::SheetCellRanges,
public apitest::XFormulaQuery,
public apitest::XSheetCellRangeContainer,
public apitest::XSheetCellRanges,
public apitest::XSheetOperation
......@@ -40,6 +42,7 @@ public:
virtual void setUp() override;
virtual void tearDown() override;
virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
virtual uno::Reference< uno::XInterface > init() override;
CPPUNIT_TEST_SUITE(ScCellRangesObj);
......@@ -47,6 +50,10 @@ public:
// SheetCellRanges
CPPUNIT_TEST(testSheetCellRangesProperties);
// XFormulaQuery
CPPUNIT_TEST(testQueryDependents);
CPPUNIT_TEST(testQueryPrecedents);
// XSheetCellRangeContainer
CPPUNIT_TEST(testAddRemoveRangeAddress);
CPPUNIT_TEST(testAddRemoveRangeAddresses);
......@@ -67,7 +74,8 @@ private:
};
ScCellRangesObj::ScCellRangesObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments")
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XFormulaQuery(table::CellRangeAddress(0, 4, 1, 5, 4), table::CellRangeAddress(0, 4, 1, 5, 4))
{
}
......@@ -101,6 +109,19 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init()
return xRanges;
}
uno::Reference<uno::XInterface> ScCellRangesObj::getXSpreadsheet()
{
uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheets> xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
setXCell(xSheet->getCellByPosition(15, 15));
return xSheet;
}
void ScCellRangesObj::setUp()
{
CalcUnoApiTest::setUp();
......
......@@ -19,6 +19,7 @@
#include <test/sheet/xcellrangemovement.hxx>
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xdatapilottablessupplier.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xmultipleoperation.hxx>
#include <test/sheet/xprintareas.hxx>
#include <test/sheet/xscenario.hxx>
......@@ -60,6 +61,7 @@ class ScTableSheetObj : public CalcUnoApiTest, public apitest::Scenario,
public apitest::XCellRangeMovement,
public apitest::XCellSeries,
public apitest::XDataPilotTablesSupplier,
public apitest::XFormulaQuery,
public apitest::XMultipleOperation,
public apitest::XPrintAreas,
public apitest::XReplaceable,
......@@ -137,6 +139,10 @@ public:
// XDataPilotTablesSupplier
CPPUNIT_TEST(testGetDataPilotTables);
// XFormulaQuery
CPPUNIT_TEST(testQueryDependents);
CPPUNIT_TEST(testQueryPrecedents);
// XSearchable
CPPUNIT_TEST(testFindAll);
CPPUNIT_TEST(testFindNext);
......@@ -220,6 +226,7 @@ private:
ScTableSheetObj::ScTableSheetObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XCellSeries(1, 0),
apitest::XFormulaQuery(table::CellRangeAddress(0, 0, 0, 1023, 1048575), table::CellRangeAddress(0, 0, 0, 1023, 1048575), 0, 0),
apitest::XReplaceable("searchReplaceString", "replaceReplaceString"),
apitest::XSearchable("test", 4)
{
......@@ -312,6 +319,8 @@ uno::Reference< uno::XInterface > ScTableSheetObj::getXSpreadsheet()
uno::Reference<sheet::XScenariosSupplier> xScence(xSheet, UNO_QUERY_THROW);
xScence->getScenarios()->addNewByName("Scenario", aCellRangeAddr, "Comment");
xSheets->getByName("Scenario");
setXCell(xSheet->getCellByPosition(15, 15));
return xSheet;
}
......
......@@ -97,6 +97,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xdatapilottables \
test/source/sheet/xdatapilottablessupplier \
test/source/sheet/xddelink \
test/source/sheet/xformulaquery \
test/source/sheet/xfunctiondescriptions \
test/source/sheet/xheaderfootercontent \
test/source/sheet/xlabelrange \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/cppunitasserthelper.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <com/sun/star/sheet/XFormulaQuery.hpp>
#include <com/sun/star/sheet/XSheetCellRanges.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest
{
void XFormulaQuery::testQueryDependents()
{
uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
xSheet->getCellByPosition(0, 0)->setValue(1);
xSheet->getCellByPosition(1, 0)->setValue(1);
xSheet->getCellByPosition(2, 0)->setValue(1);
xSheet->getCellByPosition(3, 0)->setValue(1);
uno::Reference<table::XCell> xCell = getXCell();
xCell->setFormula("=SUM(A1:D1)");
uno::Reference<sheet::XFormulaQuery> xFormulaQuery(init(), UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xSCR = xFormulaQuery->queryDependents(false);
uno::Sequence<table::CellRangeAddress> aCellRangeAddress = xSCR->getRangeAddresses();
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress[m_nIdxDependents], m_aCellRangeAddressDependents);
}
void XFormulaQuery::testQueryPrecedents()
{
uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
xSheet->getCellByPosition(0, 0)->setValue(1);
xSheet->getCellByPosition(1, 0)->setValue(1);
xSheet->getCellByPosition(2, 0)->setValue(1);
xSheet->getCellByPosition(3, 0)->setValue(1);
xSheet->getCellByPosition(1, 2)->setFormula("=A16 * 2");
uno::Reference<table::XCell> xCell = getXCell();
xCell->setFormula("=SUM(A1:D1)");
uno::Reference<sheet::XFormulaQuery> xFormulaQuery(init(), UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xSCR = xFormulaQuery->queryPrecedents(false);
uno::Sequence<table::CellRangeAddress> aCellRangeAddress = xSCR->getRangeAddresses();
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress[m_nIdxPrecedents], m_aCellRangeAddressPrecedents);
}
} // namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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