LibreOffice Module test (master) 1
captionshape.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
12
13#include <com/sun/star/beans/XPropertySet.hpp>
14#include <com/sun/star/uno/Any.hxx>
15#include <com/sun/star/uno/Reference.hxx>
16#include <com/sun/star/awt/Point.hpp>
17
18#include <cppunit/TestAssert.h>
19
20using namespace com::sun::star;
21using namespace com::sun::star::uno;
22
23namespace apitest
24{
26{
27 uno::Reference<beans::XPropertySet> xCaptionShape(init(), UNO_QUERY_THROW);
28 OUString propName;
29 uno::Any aNewValue;
30
31 propName = "CornerRadius";
32 sal_Int32 nCornerRadiusGet = 5;
33 sal_Int32 nCornerRadiusSet = 0;
34 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CornerRadius",
35 xCaptionShape->getPropertyValue(propName) >>= nCornerRadiusGet);
36
37 aNewValue <<= nCornerRadiusGet + 5;
38 xCaptionShape->setPropertyValue(propName, aNewValue);
39 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= nCornerRadiusSet);
40 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue CornerRadius", nCornerRadiusGet + 5,
41 nCornerRadiusSet);
42
43 propName = "CaptionPoint";
44 awt::Point aCaptionPointGet;
45 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionPoint",
46 xCaptionShape->getPropertyValue(propName) >>= aCaptionPointGet);
47
48 awt::Point aCaptionPointSet;
49 aNewValue <<= awt::Point(5, 5);
50 xCaptionShape->setPropertyValue(propName, aNewValue);
51 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= aCaptionPointSet);
52 CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue of CaptionPoint", aCaptionPointSet,
53 awt::Point(5, 5));
54
55 propName = "CaptionType";
56 sal_Int16 captionTypeGet = 0;
57 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionType",
58 xCaptionShape->getPropertyValue(propName) >>= captionTypeGet);
59
60 sal_Int16 captionTypeSet = 0;
61 const sal_Int16 FIVE = 5;
62 aNewValue <<= FIVE;
63 xCaptionShape->setPropertyValue(propName, aNewValue);
64 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionTypeSet);
65 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionType", FIVE,
66 captionTypeSet);
67
68 propName = "CaptionIsFixedAngle";
69 bool captionIsFixedAngleGet = false;
70 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionPointIsFixedAngle",
71 xCaptionShape->getPropertyValue(propName) >>= captionIsFixedAngleGet);
72
73 bool captionIsFixedAngleSet = false;
74 aNewValue <<= !captionIsFixedAngleGet;
75 xCaptionShape->setPropertyValue(propName, aNewValue);
76 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionIsFixedAngleSet);
77 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionPointisFixedAngle",
78 captionIsFixedAngleSet, !captionIsFixedAngleGet);
79
80 propName = "CaptionAngle";
81 sal_Int32 captionAngleGet = {};
82 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionAngle",
83 xCaptionShape->getPropertyValue(propName) >>= captionAngleGet);
84
85 sal_Int32 captionAngleSet = 0;
86 aNewValue <<= captionAngleGet + 5;
87 xCaptionShape->setPropertyValue(propName, aNewValue);
88 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionAngleSet);
89 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionAngle", captionAngleSet,
90 captionAngleGet + 5);
91
92 propName = "CaptionGap";
93 sal_Int32 captionGapGet = {};
94 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionGap",
95 xCaptionShape->getPropertyValue(propName) >>= captionGapGet);
96
97 sal_Int32 captionGapSet = 0;
98 aNewValue <<= captionGapGet + 5;
99 xCaptionShape->setPropertyValue(propName, aNewValue);
100 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionGapSet);
101 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionGap", captionGapSet,
102 captionGapGet + 5);
103
104 propName = "CaptionEscapeDirection";
105 sal_Int32 captionEscapeDirectionGet = {};
106 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeDirection",
107 xCaptionShape->getPropertyValue(propName) >>= captionEscapeDirectionGet);
108
109 sal_Int32 captionEscapeDirectionSet = 0;
110 aNewValue <<= captionEscapeDirectionGet + 5;
111 xCaptionShape->setPropertyValue(propName, aNewValue);
112 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionEscapeDirectionSet);
113 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeDirection",
114 captionEscapeDirectionSet, captionEscapeDirectionGet + 5);
115
116 propName = "CaptionIsEscapeRelative";
117 bool captionIsEscapeRelativeGet = false;
118 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionIsEscapeRelative",
119 xCaptionShape->getPropertyValue(propName)
120 >>= captionIsEscapeRelativeGet);
121
122 bool captionIsEscapeRelativeSet = false;
123 aNewValue <<= !captionIsEscapeRelativeGet;
124 xCaptionShape->setPropertyValue(propName, aNewValue);
125 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionIsEscapeRelativeSet);
126 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionIsEscapeRelative",
127 captionIsEscapeRelativeSet, !captionIsEscapeRelativeGet);
128
129 propName = "CaptionEscapeRelative";
130 sal_Int32 captionEscapeRelativeGet = {};
131 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeRelative",
132 xCaptionShape->getPropertyValue(propName) >>= captionEscapeRelativeGet);
133
134 sal_Int32 captionEscapeRelativeSet = 0;
135 aNewValue <<= captionEscapeRelativeGet + 5;
136 xCaptionShape->setPropertyValue(propName, aNewValue);
137 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionEscapeRelativeSet);
138 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeRelative",
139 captionEscapeRelativeSet, captionEscapeRelativeGet + 5);
140
141 propName = "CaptionEscapeAbsolute";
142 sal_Int32 captionEscapeAbsoluteGet = {};
143 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeAbsolute",
144 xCaptionShape->getPropertyValue(propName) >>= captionEscapeAbsoluteGet);
145
146 sal_Int32 captionEscapeAbsoluteSet = 0;
147 aNewValue <<= captionEscapeAbsoluteGet + 5;
148 xCaptionShape->setPropertyValue(propName, aNewValue);
149 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionEscapeAbsoluteSet);
150 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeAbsolute",
151 captionEscapeAbsoluteSet, captionEscapeAbsoluteGet + 5);
152
153 propName = "CaptionLineLength";
154 sal_Int32 captionLineLengthGet = {};
155 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionLineLength",
156 xCaptionShape->getPropertyValue(propName) >>= captionLineLengthGet);
157
158 sal_Int32 captionLineLengthSet = 0;
159 aNewValue <<= captionLineLengthGet + 5;
160 xCaptionShape->setPropertyValue(propName, aNewValue);
161 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionLineLengthSet);
162 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeAbsolute",
163 captionLineLengthSet, captionLineLengthGet + 5);
164
165 propName = "CaptionIsFitLineLength";
166 bool captionIsFitLineLengthGet = false;
167 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionIsFitLineLength",
168 xCaptionShape->getPropertyValue(propName) >>= captionIsFitLineLengthGet);
169
170 bool captionIsFitLineLengthSet = false;
171 aNewValue <<= !captionIsFitLineLengthGet;
172 xCaptionShape->setPropertyValue(propName, aNewValue);
173 CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionIsFitLineLengthSet);
174 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionIsFitLineLength",
175 captionIsFitLineLengthSet, !captionIsFitLineLengthGet);
176}
177}
178/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0