include/test/helper/form.hxx                                  |   15 
 include/test/view/xformlayeraccess.hxx                        |   43 ++
 qadevOOo/Jar_OOoRunner.mk                                     |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScViewPaneObj.csv |    4 
 qadevOOo/tests/java/mod/_sc/ScViewPaneObj.java                |  174 ----------
 sc/qa/extras/scviewpaneobj.cxx                                |   65 ++-
 sc/qa/unoapi/sc_7.sce                                         |    1 
 solenv/clang-format/blacklist                                 |    1 
 test/Library_subsequenttest.mk                                |    1 
 test/source/helper/form.cxx                                   |    8 
 test/source/view/xformlayeraccess.cxx                         |   58 +++
 11 files changed, 171 insertions(+), 200 deletions(-)

New commits:
commit 2e0e7a15f66f5cb55f2a424fae6a9050c2c7f9ca
Author:     Jens Carl <j.car...@gmx.de>
AuthorDate: Fri Mar 29 22:06:59 2019 +0000
Commit:     Jens Carl <j.car...@gmx.de>
CommitDate: Sat Mar 30 22:40:23 2019 +0100

    tdf#45904 Move XFormLayerAccess Java tests to C++
    
    Move XFormLayerAccess Java tests to C++ for ScViewPaneObj.
    
    Change-Id: I7ed6ff51d435b6f3de85daec99a13583e50a450a
    Reviewed-on: https://gerrit.libreoffice.org/69942
    Tested-by: Jenkins
    Reviewed-by: Jens Carl <j.car...@gmx.de>

diff --git a/include/test/helper/form.hxx b/include/test/helper/form.hxx
index f6e035d64fec..d84794cc5b6d 100644
--- a/include/test/helper/form.hxx
+++ b/include/test/helper/form.hxx
@@ -26,6 +26,19 @@ namespace helper
 {
 namespace form
 {
+/** @brief Create a XControlShape of kind "CommandButton".
+ *
+ * @param r_xComponent  The document.
+ * @param nX            The x-position of the shape.
+ * @param nY            The y-position of the shape.
+ * @param nHeight       The height of the shape.
+ * @param nWidth        The width of the shape.
+ * @return  The created XControlShape.
+ */
+css::uno::Reference<css::drawing::XControlShape> OOO_DLLPUBLIC_TEST 
createCommandButton(
+    const css::uno::Reference<css::lang::XComponent>& r_xComponent, const 
sal_Int32 nX,
+    const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth);
+
 /** @brief Create a XControlShape
  *
  * @param r_xComponent  The document.
@@ -34,7 +47,7 @@ namespace form
  * @param nY            The y-position of the shape.
  * @param nHeight       The height of the shape.
  * @param nWidth        The width of the shape.
- * @return  The create XControlShape.
+ * @return  The created XControlShape.
  */
 css::uno::Reference<css::drawing::XControlShape> OOO_DLLPUBLIC_TEST 
createControlShape(
     const css::uno::Reference<css::lang::XComponent>& r_xComponent, const 
OUString& r_aKind,
diff --git a/include/test/view/xformlayeraccess.hxx 
b/include/test/view/xformlayeraccess.hxx
new file mode 100644
index 000000000000..ddd2542ab8ef
--- /dev/null
+++ b/include/test/view/xformlayeraccess.hxx
@@ -0,0 +1,43 @@
+/* -*- 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_VIEW_XFORMLAYERACCESS_HXX
+#define INCLUDED_TEST_VIEW_XFORMLAYERACCESS_HXX
+
+#include <com/sun/star/form/XForm.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 XFormLayerAccess
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+    void setForm(const css::uno::Reference<css::form::XForm>& r_xForm) { 
m_xForm = r_xForm; }
+
+    void testGetFormController();
+    void testIsFormDesignMode();
+    void testSetFormDesignMode();
+
+protected:
+    ~XFormLayerAccess() {}
+
+private:
+    css::uno::Reference<css::form::XForm> m_xForm;
+};
+
+} // namespace apitest
+
+#endif // INCLUDED_TEST_VIEW_XFORMLAYERACCESS_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 3cb59e2c61de..3539ddbfce9d 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -975,7 +975,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScTableSheetObj \
     qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \
     qadevOOo/tests/java/mod/_sc/ScTabViewObj \
-    qadevOOo/tests/java/mod/_sc/ScViewPaneObj \
     qadevOOo/tests/java/mod/_sc/XMLContentExporter \
     qadevOOo/tests/java/mod/_sc/XMLContentImporter \
     qadevOOo/tests/java/mod/_sc/XMLExporter \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScViewPaneObj.csv 
b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScViewPaneObj.csv
deleted file mode 100644
index a4a3586f943f..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScViewPaneObj.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-"ScViewPaneObj";"com::sun::star::view::XFormLayerAccess#optional";"getFromController()"
-"ScViewPaneObj";"com::sun::star::view::XFormLayerAccess#optional";"isFormDesignMode()"
-"ScViewPaneObj";"com::sun::star::view::XFormLayerAccess#optional";"setFormDesignMode()"
-
diff --git a/qadevOOo/tests/java/mod/_sc/ScViewPaneObj.java 
b/qadevOOo/tests/java/mod/_sc/ScViewPaneObj.java
deleted file mode 100644
index 133ca3ec32c3..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScViewPaneObj.java
+++ /dev/null
@@ -1,174 +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 mod._sc;
-
-import com.sun.star.container.NoSuchElementException;
-
-import java.io.PrintWriter;
-
-import lib.TestCase;
-import lib.TestEnvironment;
-import lib.TestParameters;
-import util.SOfficeFactory;
-
-import com.sun.star.container.XIndexAccess;
-import com.sun.star.container.XNameContainer;
-import com.sun.star.drawing.XDrawPage;
-import com.sun.star.drawing.XDrawPages;
-import com.sun.star.drawing.XDrawPagesSupplier;
-import com.sun.star.drawing.XShape;
-import com.sun.star.form.XForm;
-import com.sun.star.frame.XController;
-import com.sun.star.frame.XModel;
-import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.XComponent;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XViewPane;
-import com.sun.star.table.CellRangeAddress;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-import util.FormTools;
-
-/**
- * Test for object which is represented by service
- * <code>com.sun.star.sheet.SpreadsheetViewPane</code>. <p>
- * Object implements the following interfaces :
- * <ul>
- *  <li> <code>com::sun::star::sheet::XViewPane</code></li>
- *  <li> <code>com::sun::star::sheet::XCellRangeReferrer</code></li>
- * </ul>
- * @see com.sun.star.sheet.SpreadsheetViewPane
- * @see com.sun.star.sheet.XViewPane
- * @see com.sun.star.sheet.XCellRangeReferrer
- * @see ifc.sheet._XViewPane
- * @see ifc.sheet._XCellRangeReferrer
- */
-public class ScViewPaneObj extends TestCase {
-    private static XSpreadsheetDocument xSpreadsheetDoc;
-    private static SOfficeFactory SOF;
-    private static XInterface oObj;
-
-    /**
-     * Creates Spreadsheet document.
-     */
-    @Override
-    public void initialize( TestParameters Param, PrintWriter log ) throws 
Exception {
-        // get a soffice factory object
-        SOF = SOfficeFactory.getFactory( Param.getMSF());
-        log.println("creating a spreadsheetdocument");
-        xSpreadsheetDoc = SOF.createCalcDoc(null);
-    }
-
-    /**
-     * Disposes Spreadsheet document.
-     */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println("disposing xSpreadsheetDocument");
-        XComponent oComp = UnoRuntime.queryInterface(XComponent.class, 
xSpreadsheetDoc);
-        util.DesktopTools.closeDoc(oComp);
-    }
-
-    /**
-     * Creating a TestEnvironment for the interfaces to be tested.
-     * Retrieves the current controller of the spreadsheet document using the
-     * interface <code>XModel</code>. The controller contains the collection
-     * of the view panes so retrieves the view pane with index 0 from
-     * the collection. The retrieved view pane is the instance of the service
-     * <code>com.sun.star.sheet.SpreadsheetViewPane</code>. Retrieves the 
address
-     * of the cell range that consists of the cells which are visible in the 
pane.
-     * Object relations created :
-     * <ul>
-     *  <li> <code>'DATAAREA'</code> for
-     *      {@link ifc.sheet._XViewPane}(the retrieved address)</li>
-     * </ul>
-     * @see com.sun.star.frame.XModel
-     */
-    @Override
-    protected TestEnvironment createTestEnvironment(TestParameters Param, 
PrintWriter log) throws Exception {
-        XDrawPage oDrawPage;
-
-        XModel xm = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc);
-        XController xc = xm.getCurrentController();
-        XIndexAccess xIA = UnoRuntime.queryInterface(XIndexAccess.class, xc);
-        oObj = (XInterface) AnyConverter.toObject(
-            new Type(XInterface.class),xIA.getByIndex(0));
-
-        TestEnvironment tEnv = new TestEnvironment(oObj);
-
-        //Relation for XControlAccess
-        tEnv.addObjRelation("DOCUMENT", 
UnoRuntime.queryInterface(XComponent.class,xSpreadsheetDoc));
-        tEnv.addObjRelation("XControlAccess.isSheet", Boolean.TRUE);
-
-        XViewPane VP = UnoRuntime.queryInterface(XViewPane.class, oObj);
-        CellRangeAddress dataArea = VP.getVisibleRange();
-        tEnv.addObjRelation("DATAAREA", dataArea);
-
-        // XForm for com.sun.star.view.XFormLayerAccess
-        log.println("adding relation for com.sun.star.view.XFormLayerAccess: 
XForm");
-
-        XForm myForm = null;
-        String kindOfControl="CommandButton";
-        XShape aShape = null;
-        log.println("adding control shape '" + kindOfControl + "'");
-        XComponent oComp = UnoRuntime.queryInterface(XComponent.class, 
xSpreadsheetDoc) ;
-
-        aShape = FormTools.createControlShape(oComp, 3000, 4500, 15000, 10000, 
kindOfControl);
-
-        try {
-            log.println( "getting Drawpages" );
-            XDrawPagesSupplier oDPS = 
UnoRuntime.queryInterface(XDrawPagesSupplier.class,xSpreadsheetDoc);
-            XDrawPages oDP = oDPS.getDrawPages();
-            oDP.insertNewByIndex(1);
-            oDP.insertNewByIndex(2);
-            oDrawPage = (XDrawPage) AnyConverter.toObject(
-                new Type(XDrawPage.class),oDP.getByIndex(0));
-            if (oDrawPage == null)
-                log.println("ERROR: could not get DrawPage: null");
-
-            oDrawPage.add(aShape);
-            log.println("getting XForm");
-            XNameContainer xForm = FormTools.getForms(oDrawPage);
-            try {
-                myForm = (XForm) AnyConverter.toObject(new 
Type(XForm.class),xForm.getByName("Standard"));
-            } catch (WrappedTargetException ex) {
-                log.println("ERROR: could not XFormm 'Standard': " + 
ex.toString());
-            } catch (com.sun.star.lang.IllegalArgumentException ex) {
-                log.println("ERROR: could not XFormm 'Standard': " + 
ex.toString());
-            } catch (NoSuchElementException ex) {
-                log.println("ERROR: could not XFormm 'Standard': " + 
ex.toString());
-            }
-            if (myForm == null)
-                log.println("ERROR: could not get XForm: null");
-            tEnv.addObjRelation("XFormLayerAccess.XForm", myForm);
-        } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
-            log.println("ERROR: could not add ObjectRelation 
'XFormLayerAccess.XForm': " + ex.toString());
-        } catch (WrappedTargetException ex) {
-            log.println("ERROR: could not add ObjectRelation 
'XFormLayerAccess.XForm': " + ex.toString());
-        } catch (com.sun.star.lang.IllegalArgumentException ex) {
-            log.println("ERROR: could not add ObjectRelation 
'XFormLayerAccess.XForm': " + ex.toString());
-        }
-
-        return tEnv;
-    }
-}
-
diff --git a/sc/qa/extras/scviewpaneobj.cxx b/sc/qa/extras/scviewpaneobj.cxx
index 499cc7924f31..779b019e2506 100644
--- a/sc/qa/extras/scviewpaneobj.cxx
+++ b/sc/qa/extras/scviewpaneobj.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -11,8 +11,16 @@
 #include <test/sheet/xcellrangereferrer.hxx>
 #include <test/sheet/xviewpane.hxx>
 #include <test/view/xcontrolaccess.hxx>
+#include <test/view/xformlayeraccess.hxx>
+#include <test/helper/form.hxx>
 
 #include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPages.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
@@ -20,21 +28,23 @@
 #include <com/sun/star/sheet/XViewPane.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
 
-using namespace css;
-using namespace css::uno;
+#include <com/sun/star/uno/Reference.hxx>
 
-namespace sc_apitest {
+using namespace css;
 
+namespace sc_apitest
+{
 class ScViewPaneObj : public CalcUnoApiTest,
                       public apitest::XCellRangeReferrer,
                       public apitest::XControlAccess,
+                      public apitest::XFormLayerAccess,
                       public apitest::XViewPane
 {
 public:
     ScViewPaneObj();
 
-    virtual uno::Reference< uno::XInterface > init() override;
-    virtual uno::Reference< uno::XInterface > getXComponent() override;
+    virtual uno::Reference<uno::XInterface> init() override;
+    virtual uno::Reference<uno::XInterface> getXComponent() override;
     virtual void setUp() override;
     virtual void tearDown() override;
 
@@ -46,6 +56,11 @@ public:
     // XControlAccess
     CPPUNIT_TEST(testGetControl);
 
+    // XFormLayerAccess
+    CPPUNIT_TEST(testGetFormController);
+    CPPUNIT_TEST(testIsFormDesignMode);
+    CPPUNIT_TEST(testSetFormDesignMode);
+
     // XViewPane
     CPPUNIT_TEST(testFirstVisibleColumn);
     CPPUNIT_TEST(testFirstVisibleRow);
@@ -62,20 +77,34 @@ ScViewPaneObj::ScViewPaneObj()
 {
 }
 
-uno::Reference<uno::XInterface> ScViewPaneObj::getXComponent()
-{
-    return mxComponent;
-}
+uno::Reference<uno::XInterface> ScViewPaneObj::getXComponent() { return 
mxComponent; }
 
-uno::Reference< uno::XInterface > ScViewPaneObj::init()
+uno::Reference<uno::XInterface> ScViewPaneObj::init()
 {
-    uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+
+    uno::Reference<frame::XModel> xModel(xDoc, uno::UNO_QUERY_THROW);
+    uno::Reference<frame::XController> 
xController(xModel->getCurrentController(),
+                                                   uno::UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIA(xController, 
uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XViewPane> xViewPane(xIA->getByIndex(0), 
uno::UNO_QUERY_THROW);
+
+    uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDoc, 
uno::UNO_QUERY_THROW);
+    uno::Reference<drawing::XDrawPages> xDP(xDPS->getDrawPages(), 
uno::UNO_QUERY_THROW);
+    xDP->insertNewByIndex(1);
+    xDP->insertNewByIndex(2);
 
-    uno::Reference< frame::XModel > xModel(xSheetDoc, uno::UNO_QUERY_THROW);
-    uno::Reference< frame::XController > xController = 
xModel->getCurrentController();
-    uno::Reference< container::XIndexAccess > xIndexAccess(xController, 
uno::UNO_QUERY_THROW);
-    uno::Reference< sheet::XViewPane > xViewPane (xIndexAccess->getByIndex(0), 
uno::UNO_QUERY_THROW);
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDP->getByIndex(0), 
uno::UNO_QUERY_THROW);
+    xDrawPage->add(
+        apitest::helper::form::createCommandButton(mxComponent, 15000, 10000, 
3000, 4500));
 
+    uno::Reference<form::XFormsSupplier> xFS(xDrawPage, uno::UNO_QUERY_THROW);
+    uno::Reference<container::XNameContainer> xNC(xFS->getForms(), 
uno::UNO_QUERY_THROW);
+
+    // XFormLayerAccess
+    uno::Reference<form::XForm> xForm(xNC->getByName("Form"), 
uno::UNO_QUERY_THROW);
+    setForm(xForm);
+    // XCellRangeReferrer
     setCellRange(xViewPane->getVisibleRange());
 
     return xViewPane;
@@ -96,8 +125,8 @@ void ScViewPaneObj::tearDown()
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScViewPaneObj);
 
-} // End Namespace
+} // namespace sc_apitest
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/sc/qa/unoapi/sc_7.sce b/sc/qa/unoapi/sc_7.sce
index 306e95aebb48..0744d8c3075f 100644
--- a/sc/qa/unoapi/sc_7.sce
+++ b/sc/qa/unoapi/sc_7.sce
@@ -22,7 +22,6 @@
 # -o sc.ScTableRowObj
 # -o sc.ScTableSheetObj
 # -o sc.ScTableSheetsObj
-#-o sc.ScViewPaneObj
 # #i89411 -o sc.XMLContentExporter
 # #i89411 -o sc.XMLContentImporter
 # #i89411 -o sc.XMLExporter
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 09abf2370659..3ece0596c146 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -10028,7 +10028,6 @@ sc/qa/extras/scsubtotalfieldobj.cxx
 sc/qa/extras/sctablesheetobj.cxx
 sc/qa/extras/sctablesheetsobj.cxx
 sc/qa/extras/sctabviewobj.cxx
-sc/qa/extras/scviewpaneobj.cxx
 sc/qa/perf/scperfobj.cxx
 sc/qa/unit/bugfix-test.cxx
 sc/qa/unit/copy_paste_test.cxx
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 42cec9343c75..c636235913bf 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -187,6 +187,7 @@ $(eval $(call 
gb_Library_add_exception_objects,subsequenttest,\
        test/source/util/xreplaceable \
        test/source/util/xsearchable \
        test/source/view/xcontrolaccess \
+       test/source/view/xformlayeraccess \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/test/source/helper/form.cxx b/test/source/helper/form.cxx
index 3dbf079af59d..018a33ca4532 100644
--- a/test/source/helper/form.cxx
+++ b/test/source/helper/form.cxx
@@ -29,6 +29,14 @@ namespace helper
 {
 namespace form
 {
+uno::Reference<drawing::XControlShape>
+    OOO_DLLPUBLIC_TEST createCommandButton(const 
uno::Reference<lang::XComponent>& r_xComponent,
+                                           const sal_Int32 nX, const sal_Int32 
nY,
+                                           const sal_Int32 nHeight, const 
sal_Int32 nWidth)
+{
+    return createControlShape(r_xComponent, "CommandButton", nX, nY, nHeight, 
nWidth);
+}
+
 uno::Reference<drawing::XControlShape> OOO_DLLPUBLIC_TEST createControlShape(
     const uno::Reference<lang::XComponent>& r_xComponent, const OUString& 
r_aKind,
     const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const 
sal_Int32 nWidth)
diff --git a/test/source/view/xformlayeraccess.cxx 
b/test/source/view/xformlayeraccess.cxx
new file mode 100644
index 000000000000..699da4882da8
--- /dev/null
+++ b/test/source/view/xformlayeraccess.cxx
@@ -0,0 +1,58 @@
+/* -*- 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/view/xformlayeraccess.hxx>
+
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/view/XFormLayerAccess.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+
+namespace apitest
+{
+void XFormLayerAccess::testGetFormController()
+{
+    uno::Reference<view::XFormLayerAccess> xFLA(init(), uno::UNO_QUERY_THROW);
+
+    const bool bCurrentMode = xFLA->isFormDesignMode();
+
+    // delibritly don't use UNO_QUERY_THROW, so we can use
+    // uno::XInterface::is() in CPPUNIT_ASSERT()
+    xFLA->setFormDesignMode(false);
+    uno::Reference<form::runtime::XFormController> 
xFC(xFLA->getFormController(m_xForm),
+                                                       uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xFC.is());
+
+    xFLA->setFormDesignMode(bCurrentMode);
+}
+
+void XFormLayerAccess::testIsFormDesignMode() { testSetFormDesignMode(); }
+
+void XFormLayerAccess::testSetFormDesignMode()
+{
+    uno::Reference<view::XFormLayerAccess> xFLA(init(), uno::UNO_QUERY_THROW);
+
+    const bool bCurrentMode = xFLA->isFormDesignMode();
+    xFLA->setFormDesignMode(!bCurrentMode);
+
+    const bool bNewMode = xFLA->isFormDesignMode();
+    CPPUNIT_ASSERT_EQUAL(!bCurrentMode, bNewMode);
+
+    xFLA->setFormDesignMode(bCurrentMode);
+    CPPUNIT_ASSERT_EQUAL(bCurrentMode, 
static_cast<bool>(xFLA->isFormDesignMode()));
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to