12#include <com/sun/star/awt/Point.hpp>
13#include <com/sun/star/beans/PropertyValue.hpp>
14#include <com/sun/star/container/XIndexAccess.hpp>
15#include <com/sun/star/container/XNamed.hpp>
16#include <com/sun/star/drawing/XDrawPage.hpp>
17#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
18#include <com/sun/star/drawing/XShape.hpp>
19#include <com/sun/star/frame/DispatchHelper.hpp>
20#include <com/sun/star/frame/XDispatchHelper.hpp>
21#include <com/sun/star/frame/XDispatchProvider.hpp>
22#include <com/sun/star/frame/XFrame.hpp>
23#include <com/sun/star/frame/XModel.hpp>
24#include <com/sun/star/sheet/XDocumentAuditing.hpp>
25#include <com/sun/star/sheet/XSheetAuditing.hpp>
26#include <com/sun/star/sheet/XSpreadsheet.hpp>
27#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
28#include <com/sun/star/sheet/XSpreadsheets.hpp>
29#include <com/sun/star/table/CellAddress.hpp>
30#include <com/sun/star/uno/Reference.hxx>
31#include <com/sun/star/uno/Sequence.hxx>
32#include <com/sun/star/uno/XComponentContext.hpp>
37#include <cppunit/TestAssert.h>
45 const uno::Sequence<beans::PropertyValue>& rArguments)
47 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
48 uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext),
50 CPPUNIT_ASSERT(xDispatchHelper.is());
52 uno::Reference<frame::XDispatchProvider> xDispatchProvider(
xFrame, UNO_QUERY_THROW);
53 CPPUNIT_ASSERT(xDispatchProvider.is());
55 xDispatchHelper->executeDispatch(xDispatchProvider,
".uno:AutoRefreshArrows",
"", 0,
60 sal_Int32 nElementCount, sal_Int32 nShapes)
62 const sal_Int32
nCount = xDrawPage->getCount();
63 if (
nCount != nElementCount + nShapes)
69 for (sal_Int32
i = nElementCount;
i <
nCount;
i++)
71 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(
i), UNO_QUERY_THROW);
81 uno::Reference<sheet::XDocumentAuditing> xDocumentAuditing(
init(), UNO_QUERY_THROW);
83 uno::Reference<sheet::XSpreadsheetDocument> xDoc(xDocumentAuditing, UNO_QUERY_THROW);
84 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW);
85 uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
86 uno::Reference<sheet::XSpreadsheet> xSheet1(xIA->getByIndex(0), UNO_QUERY_THROW);
87 uno::Reference<sheet::XSpreadsheet> xSheet2(xIA->getByIndex(1), UNO_QUERY_THROW);
89 uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDocumentAuditing, UNO_QUERY_THROW);
90 uno::Reference<drawing::XDrawPage> xDrawPage(xDPS->getDrawPages()->getByIndex(1),
93 sal_Int32 nDrawPageElementCount = 0;
94 if (xDrawPage->hasElements())
95 nDrawPageElementCount = xDrawPage->getCount();
98 "AutoRefreshArrows",
false) };
99 uno::Reference<frame::XModel>
xModel(xDocumentAuditing, UNO_QUERY_THROW);
100 dispatch(
xModel->getCurrentController()->getFrame(), aPropertyValue);
102 xSheet1->getCellByPosition(6, 6)->setValue(9);
103 uno::Reference<container::XNamed> xNA1(xSheet1, UNO_QUERY_THROW);
104 OUString sSheet1Name = xNA1->getName();
106 xSheet2->getCellByPosition(6, 6)->setValue(16);
107 xSheet2->getCellByPosition(6, 7)->setFormula(
"= SQRT(G7)");
109 uno::Reference<sheet::XSheetAuditing> xSheetAuditing(xSheet2, UNO_QUERY_THROW);
110 xSheetAuditing->showPrecedents(table::CellAddress(1, 6, 7));
112 CPPUNIT_ASSERT_MESSAGE(
"Wrong amount of shapes on page", bResult);
115 CPPUNIT_ASSERT_DOUBLES_EQUAL(4, xSheet2->getCellByPosition(6, 7)->getValue(), 0.1);
116 xSheet2->getCellByPosition(6, 7)->setFormula(
"= SQRT(" + sSheet1Name +
".G7)");
117 CPPUNIT_ASSERT_DOUBLES_EQUAL(3, xSheet2->getCellByPosition(6, 7)->getValue(), 0.1);
120 CPPUNIT_ASSERT_MESSAGE(
"Wrong amount of shapes on page", bResult);
123 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Arrow has been refreshed", Position0.X, Position1.X);
124 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Arrow has been refreshed", Position0.Y, Position1.Y);
126 xDocumentAuditing->refreshArrows();
129 CPPUNIT_ASSERT_MESSAGE(
"Wrong amount of shapes on page", bResult);
132 CPPUNIT_ASSERT_MESSAGE(
"Arrow has not been refreshed",
133 Position1.X != Position2.X || Position1.Y != Position2.Y);
virtual css::uno::Reference< css::uno::XInterface > init()=0
static void dispatch(const css::uno::Reference< css::frame::XFrame > &xFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments)
bool hasRightAmountOfShapes(const css::uno::Reference< css::drawing::XDrawPage > &xDrawPage, sal_Int32 nElementCount, sal_Int32 nShapes)
css::awt::Point m_Position
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Reference< XFrame > xFrame
Reference< XModel > xModel