LibreOffice Module test (master)  1
sheetlink.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <test/sheet/sheetlink.hxx>
11 
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/uno/Any.hxx>
14 #include <com/sun/star/uno/Reference.hxx>
15 
16 #include <cppunit/TestAssert.h>
17 
18 using namespace com::sun::star;
19 using namespace com::sun::star::uno;
20 
21 namespace apitest
22 {
23 void SheetLink::testSheetLinkProperties()
24 {
25  uno::Reference<beans::XPropertySet> xSheetLink(init(), UNO_QUERY_THROW);
26  OUString propName;
27  uno::Any aNewValue;
28 
29  propName = "Url";
30  OUString aUrlGet;
31  OUString aUrlSet;
32  CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Url",
33  xSheetLink->getPropertyValue(propName) >>= aUrlGet);
34 
35  aNewValue <<= OUString("file:///tmp/ScSheetLinkObj.ods");
36  xSheetLink->setPropertyValue(propName, aNewValue);
37  CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aUrlSet);
38  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Url",
39  OUString("file:///tmp/ScSheetLinkObj.ods"), aUrlSet);
40 
41  propName = "Filter";
42  OUString aFilterGet;
43  OUString aFilterSet;
44  CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Filter",
45  xSheetLink->getPropertyValue(propName) >>= aFilterGet);
46 
47  aNewValue <<= OUString("Text - txt - csv (StarCalc)");
48  xSheetLink->setPropertyValue(propName, aNewValue);
49  CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterSet);
50  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Filter",
51  OUString("Text - txt - csv (StarCalc)"), aFilterSet);
52 
53  propName = "FilterOptions";
54  OUString aFilterOptionsGet;
55  OUString aFilterOptionsSet;
56  CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FilterOptions",
57  xSheetLink->getPropertyValue(propName) >>= aFilterOptionsGet);
58 
59  aNewValue <<= OUString("NewValue");
60  xSheetLink->setPropertyValue(propName, aNewValue);
61  CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterOptionsSet);
62  CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FilterOptions", OUString("NewValue"),
63  aFilterOptionsSet);
64 }
65 }
66 
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
FILE * init(int, char **)