[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/qa test/Library_subsequenttest.mk test/source

Jens Carl j.carl43 at gmx.de
Thu Jun 14 16:26:22 UTC 2018


 include/test/sheet/xformulaquery.hxx                            |   57 +++
 qadevOOo/Jar_OOoRunner.mk                                       |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv       |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv  |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv |    2 
 qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java               |  189 ----------
 sc/qa/extras/sccellcursorobj.cxx                                |   11 
 sc/qa/extras/sccellobj.cxx                                      |   23 +
 sc/qa/extras/sccellrangeobj.cxx                                 |    9 
 sc/qa/extras/sccellrangesobj.cxx                                |   23 +
 sc/qa/extras/sctablesheetobj.cxx                                |    9 
 test/Library_subsequenttest.mk                                  |    1 
 test/source/sheet/xformulaquery.cxx                             |   66 +++
 15 files changed, 196 insertions(+), 203 deletions(-)

New commits:
commit cceef188206358fdefaa9582230253b844b54216
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Thu Jun 14 07:48:34 2018 +0000

    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: Jens Carl <j.carl43 at gmx.de>

diff --git a/include/test/sheet/xformulaquery.hxx b/include/test/sheet/xformulaquery.hxx
new file mode 100644
index 000000000000..5dcfea27b49f
--- /dev/null
+++ b/include/test/sheet/xformulaquery.hxx
@@ -0,0 +1,57 @@
+/* -*- 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: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 7718aa632156..a7bc5b37b02d 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -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 \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv
index 74d9a7752bb9..2e0517525f23 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv
@@ -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()"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
index a217fac5191b..aab8c8f92f01 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
@@ -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()"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
index 581e8884dec1..eed12b69bc58 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
@@ -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()"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
index 94ac66e6be7c..9bd9774410f5 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
@@ -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()"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
index cb29417eb43b..59f92107cde8 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
@@ -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()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java b/qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java
deleted file mode 100644
index b4958937ee2f..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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();
-    }
-
-}
diff --git a/sc/qa/extras/sccellcursorobj.cxx b/sc/qa/extras/sccellcursorobj.cxx
index eb38ea141087..374a3ab5c117 100644
--- a/sc/qa/extras/sccellcursorobj.cxx
+++ b/sc/qa/extras/sccellcursorobj.cxx
@@ -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;
 }
 
diff --git a/sc/qa/extras/sccellobj.cxx b/sc/qa/extras/sccellobj.cxx
index 0db73b287500..ec8170b4e462 100644
--- a/sc/qa/extras/sccellobj.cxx
+++ b/sc/qa/extras/sccellobj.cxx
@@ -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();
diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
index 78670eef364c..57093eee6f92 100644
--- a/sc/qa/extras/sccellrangeobj.cxx
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -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;
 }
 
diff --git a/sc/qa/extras/sccellrangesobj.cxx b/sc/qa/extras/sccellrangesobj.cxx
index 0dd8a7520715..9bfe1dd88721 100644
--- a/sc/qa/extras/sccellrangesobj.cxx
+++ b/sc/qa/extras/sccellrangesobj.cxx
@@ -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();
diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index 8316207f605f..5006bbe98dd2 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -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;
 }
 
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 378720b3f6f9..83ba40a06850 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -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 \
diff --git a/test/source/sheet/xformulaquery.cxx b/test/source/sheet/xformulaquery.cxx
new file mode 100644
index 000000000000..a5e74f0cf68f
--- /dev/null
+++ b/test/source/sheet/xformulaquery.cxx
@@ -0,0 +1,66 @@
+/* -*- 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: */


More information about the Libreoffice-commits mailing list