1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <test/sheet/spreadsheet.hxx>
11 #include <test/unoapi_property_testers.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/container/XIndexAccess.hpp>
15 #include <com/sun/star/container/XNameContainer.hpp>
16 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
17 #include <com/sun/star/sheet/XConditionalFormats.hpp>
18 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
19 #include <com/sun/star/sheet/XSpreadsheet.hpp>
20 #include <com/sun/star/text/WritingMode2.hpp>
21 #include <com/sun/star/util/Color.hpp>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/uno/Reference.hxx>
25 #include <cppunit/TestAssert.h>
27 using namespace com::sun::star
;
28 using namespace com::sun::star::uno
;
32 void Spreadsheet::testSpreadsheetProperties()
34 uno::Reference
<beans::XPropertySet
> xSpreadsheet(init(), UNO_QUERY_THROW
);
38 propName
= "IsVisible";
39 testBooleanProperty(xSpreadsheet
, propName
);
41 propName
= "PageStyle";
42 testStringProperty(xSpreadsheet
, propName
, "Report");
44 propName
= "TableLayout";
45 testShortProperty(xSpreadsheet
, propName
, text::WritingMode2::RL_TB
);
47 propName
= "AutomaticPrintArea";
48 testBooleanProperty(xSpreadsheet
, propName
);
50 propName
= "TabColor";
51 util::Color aColorGet
;
52 util::Color aColorSet
;
53 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: TabColor",
54 xSpreadsheet
->getPropertyValue(propName
) >>= aColorGet
);
56 aNewValue
<<= util::Color(42);
57 xSpreadsheet
->setPropertyValue(propName
, aNewValue
);
58 CPPUNIT_ASSERT(xSpreadsheet
->getPropertyValue(propName
) >>= aColorSet
);
59 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: TabColor", util::Color(42),
62 propName
= "ConditionalFormats";
63 uno::Reference
<sheet::XConditionalFormats
> xConditionalFormatsGet
;
64 uno::Reference
<sheet::XConditionalFormats
> xConditionalFormatsSet
;
65 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ConditionalFormats",
66 xSpreadsheet
->getPropertyValue(propName
) >>= xConditionalFormatsGet
);
68 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(getXSpreadsheetDocument(), UNO_QUERY_THROW
);
69 uno::Reference
<container::XIndexAccess
> xIA(xDoc
->getSheets(), UNO_QUERY_THROW
);
70 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIA
->getByIndex(0), UNO_QUERY_THROW
);
72 uno::Reference
<lang::XMultiServiceFactory
> xMSF(xDoc
, UNO_QUERY_THROW
);
73 uno::Reference
<container::XNameContainer
> xRanges(
74 xMSF
->createInstance("com.sun.star.sheet.SheetCellRanges"), UNO_QUERY_THROW
);
75 uno::Reference
<sheet::XSheetCellRanges
> xSheetCellRanges(xRanges
, UNO_QUERY_THROW
);
78 xCellRange
<<= xSheet
->getCellRangeByName("C1:D4");
79 xRanges
->insertByName("Range1", xCellRange
);
80 xConditionalFormatsGet
->createByRange(xSheetCellRanges
);
82 aNewValue
<<= xConditionalFormatsGet
;
83 xSpreadsheet
->setPropertyValue(propName
, aNewValue
);
84 CPPUNIT_ASSERT(xSpreadsheet
->getPropertyValue(propName
) >>= xConditionalFormatsSet
);
85 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: ConditionalFormats", sal_Int32(1),
86 xConditionalFormatsSet
->getLength());
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */