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 "sdmodeltestbase.hxx"
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/drawing/XControlShape.hpp>
14 #include <com/sun/star/awt/TextAlign.hpp>
15 #include <com/sun/star/style/VerticalAlignment.hpp>
16 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
17 #include <com/sun/star/awt/VisualEffect.hpp>
18 #include <com/sun/star/awt/ImagePosition.hpp>
19 #include <com/sun/star/awt/ImageScaleMode.hpp>
20 #include <com/sun/star/awt/FontWeight.hpp>
21 #include <com/sun/star/awt/FontSlant.hpp>
22 #include <com/sun/star/awt/FontUnderline.hpp>
23 #include <com/sun/star/awt/FontStrikeout.hpp>
24 #include <com/sun/star/graphic/XGraphic.hpp>
27 class SdActiveXControlsTest
: public SdModelTestBase
30 SdActiveXControlsTest()
31 : SdModelTestBase("/sd/qa/unit/data/")
35 void testBackgroundColor();
36 void testLabelProperties();
37 void testTextBoxProperties();
38 void testSpinButtonProperties();
39 void testCommandButtonProperties();
40 void testScrollBarProperties();
41 void testCheckBoxProperties();
42 void testOptionButtonProperties();
43 void testComboBoxProperties();
44 void testListBoxProperties();
45 void testToggleButtonProperties();
46 void testPictureProperties();
47 void testFontProperties();
49 CPPUNIT_TEST_SUITE(SdActiveXControlsTest
);
51 CPPUNIT_TEST(testBackgroundColor
);
52 CPPUNIT_TEST(testLabelProperties
);
53 CPPUNIT_TEST(testTextBoxProperties
);
54 CPPUNIT_TEST(testSpinButtonProperties
);
55 CPPUNIT_TEST(testCommandButtonProperties
);
56 CPPUNIT_TEST(testScrollBarProperties
);
57 CPPUNIT_TEST(testCheckBoxProperties
);
58 CPPUNIT_TEST(testOptionButtonProperties
);
59 CPPUNIT_TEST(testComboBoxProperties
);
60 CPPUNIT_TEST(testListBoxProperties
);
61 CPPUNIT_TEST(testToggleButtonProperties
);
62 CPPUNIT_TEST(testPictureProperties
);
63 CPPUNIT_TEST(testFontProperties
);
65 CPPUNIT_TEST_SUITE_END();
68 void SdActiveXControlsTest::testBackgroundColor()
70 // Check whether all system colors are imported correctly
71 createSdImpressDoc("pptx/control_background_color.pptx");
73 const std::vector
<Color
> vBackgroundColors
=
75 0xD4D0C8, // Scroll Bars
77 0x0054E3, // Active Title Bar
78 0x7A96DF, // Inactive Title Bar
80 0xFFFFFF, // Window Background
81 0x000000, // Window Frame
82 0x000000, // Menu Text
83 0x000000, // Window Text
84 0xFFFFFF, // Active Title Bar Text
85 0xD4D0C8, // Active Border
86 0xD4D0C8, // Inactive Border
87 0x808080, // Application Workspace
88 0x316AC5, // Highlight
89 0xFFFFFF, // Highlight Text
90 0xECE9D8, // Button Face
91 0xACA899, // Button Shadow
92 0xACA899, // Disabled Text
93 0x000000, // Button Text
94 0xD8E4F8, // Inactive Title Bar Text
95 0xFFFFFF, // Button Highlight
96 0x716F64, // Button Dark Shadow
97 0xF1EFE2, // Button Light Shadow
98 0x000000, // Tooltip Text
100 0xFF0000, // Custom red color
103 for (size_t i
= 0; i
< vBackgroundColors
.size(); ++i
)
105 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(i
, 0), uno::UNO_QUERY_THROW
);
107 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
109 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
110 OString sMessage
= "The wrong control's index is: " + OString::number(i
);
111 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), vBackgroundColors
[i
], nColor
);
115 void SdActiveXControlsTest::testLabelProperties()
117 createSdImpressDoc("pptx/activex_label.pptx");
119 // First control has default properties
120 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
121 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
124 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
125 CPPUNIT_ASSERT_EQUAL(OUString("Label1"), sLabel
);
128 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
129 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
132 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
133 CPPUNIT_ASSERT_EQUAL(true, bMultiLine
);
136 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
137 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
139 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
140 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
142 sal_Int16 nBorderStyle
;
143 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
144 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle
);
147 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
148 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
150 style::VerticalAlignment eAlign
;
151 xPropertySet
->getPropertyValue("VerticalAlign") >>= eAlign
;
152 CPPUNIT_ASSERT_EQUAL(style::VerticalAlignment_TOP
, eAlign
);
154 // Second control has custom properties
155 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
156 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
158 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
159 CPPUNIT_ASSERT_EQUAL(OUString("Custom Label"), sLabel
);
161 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
162 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
164 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
165 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
167 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
168 CPPUNIT_ASSERT_EQUAL(Color(0xE0E0E0), nColor
);
170 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
171 CPPUNIT_ASSERT_EQUAL(Color(0x0000FF), nColor
);
173 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
174 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle
);
177 xPropertySet
->getPropertyValue("BorderColor") >>= nBorderColor
;
178 CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), nBorderColor
);
180 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
181 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
183 xPropertySet
->getPropertyValue("VerticalAlign") >>= eAlign
;
184 CPPUNIT_ASSERT_EQUAL(style::VerticalAlignment_TOP
, eAlign
);
186 // Third control has transparent background
187 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
188 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
190 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
);
193 void SdActiveXControlsTest::testTextBoxProperties()
195 createSdImpressDoc("pptx/activex_textbox.pptx");
197 // First control has default properties
198 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
199 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
202 xPropertySet
->getPropertyValue("Text") >>= sText
;
203 CPPUNIT_ASSERT_EQUAL(OUString(), sText
);
206 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
207 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
210 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
211 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
214 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
215 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
217 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
218 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
220 sal_Int16 nBorderStyle
;
221 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
222 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle
);
225 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
226 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
228 style::VerticalAlignment eAlign
;
229 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("VerticalAlign") >>= eAlign
);
232 xPropertySet
->getPropertyValue("HideInactiveSelection") >>= bHideSelection
;
233 CPPUNIT_ASSERT_EQUAL(true, bHideSelection
);
235 sal_Int16 nMaxLength
;
236 xPropertySet
->getPropertyValue("MaxTextLen") >>= nMaxLength
;
237 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nMaxLength
);
240 xPropertySet
->getPropertyValue("EchoChar") >>= nEchoChar
;
241 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nEchoChar
);
244 xPropertySet
->getPropertyValue("HScroll") >>= bHScroll
;
245 CPPUNIT_ASSERT_EQUAL(false, bHScroll
);
248 xPropertySet
->getPropertyValue("VScroll") >>= bVScroll
;
249 CPPUNIT_ASSERT_EQUAL(false, bVScroll
);
252 xPropertySet
->getPropertyValue("ReadOnly") >>= bReadOnly
;
253 CPPUNIT_ASSERT_EQUAL(false, bReadOnly
);
255 // Second control has custom properties
256 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
257 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
259 xPropertySet
->getPropertyValue("Text") >>= sText
;
260 CPPUNIT_ASSERT_EQUAL(OUString("Some Text"), sText
);
262 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
263 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
265 // These textfields are not multilines in the pptx testfile
266 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
267 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
269 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
270 CPPUNIT_ASSERT_EQUAL(Color(0x404040), nColor
);
272 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
273 CPPUNIT_ASSERT_EQUAL(Color(0x00C000), nColor
);
275 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
276 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle
);
278 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
279 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
281 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("VerticalAlign") >>= eAlign
);
283 xPropertySet
->getPropertyValue("HideInactiveSelection") >>= bHideSelection
;
284 CPPUNIT_ASSERT_EQUAL(false, bHideSelection
);
286 xPropertySet
->getPropertyValue("MaxTextLen") >>= nMaxLength
;
287 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nMaxLength
);
289 xPropertySet
->getPropertyValue("EchoChar") >>= nEchoChar
;
290 CPPUNIT_ASSERT_EQUAL(sal_Int16('x'), nEchoChar
);
292 xPropertySet
->getPropertyValue("HScroll") >>= bHScroll
;
293 CPPUNIT_ASSERT_EQUAL(true, bHScroll
);
295 xPropertySet
->getPropertyValue("VScroll") >>= bVScroll
;
296 CPPUNIT_ASSERT_EQUAL(false, bVScroll
);
298 xPropertySet
->getPropertyValue("ReadOnly") >>= bReadOnly
;
299 CPPUNIT_ASSERT_EQUAL(true, bReadOnly
);
301 // Third shape has some other custom properties
302 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
303 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
305 // Transparent background
306 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
);
308 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
309 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT
), nAlign
);
311 xPropertySet
->getPropertyValue("HScroll") >>= bHScroll
;
312 CPPUNIT_ASSERT_EQUAL(false, bHScroll
);
314 xPropertySet
->getPropertyValue("VScroll") >>= bVScroll
;
315 CPPUNIT_ASSERT_EQUAL(true, bVScroll
);
317 // Fourth shape has both scroll bar
318 xControlShape
.set(getShapeFromPage(3, 0), uno::UNO_QUERY_THROW
);
319 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
321 xPropertySet
->getPropertyValue("HScroll") >>= bHScroll
;
322 CPPUNIT_ASSERT_EQUAL(true, bHScroll
);
324 xPropertySet
->getPropertyValue("VScroll") >>= bVScroll
;
325 CPPUNIT_ASSERT_EQUAL(true, bVScroll
);
328 void SdActiveXControlsTest::testSpinButtonProperties()
330 createSdImpressDoc("pptx/activex_spinbutton.pptx");
332 // First control has default properties
333 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
334 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
337 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
338 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
341 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
342 CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor
);
345 xPropertySet
->getPropertyValue("SpinValueMax") >>= nMax
;
346 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nMax
);
349 xPropertySet
->getPropertyValue("SpinValueMin") >>= nMin
;
350 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nMin
);
352 sal_Int32 nIncrement
;
353 xPropertySet
->getPropertyValue("SpinIncrement") >>= nIncrement
;
354 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nIncrement
);
357 xPropertySet
->getPropertyValue("Repeat") >>= bRepeat
;
358 CPPUNIT_ASSERT_EQUAL(true, bRepeat
);
361 xPropertySet
->getPropertyValue("RepeatDelay") >>= nDelay
;
362 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nDelay
);
365 xPropertySet
->getPropertyValue("SymbolColor") >>= nArrowColor
;
366 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nArrowColor
);
368 sal_Int32 nOrientation
;
369 xPropertySet
->getPropertyValue("Orientation") >>= nOrientation
;
370 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL
), nOrientation
);
372 sal_Int32 nSpinValue
;
373 xPropertySet
->getPropertyValue("SpinValue") >>= nSpinValue
;
374 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nSpinValue
);
376 // Second control has custom properties
377 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
378 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
380 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
381 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
383 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
384 CPPUNIT_ASSERT_EQUAL(Color(0xFFFF00), nColor
);
386 xPropertySet
->getPropertyValue("SpinValueMax") >>= nMax
;
387 CPPUNIT_ASSERT_EQUAL(sal_Int32(320), nMax
);
389 xPropertySet
->getPropertyValue("SpinValueMin") >>= nMin
;
390 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nMin
);
392 xPropertySet
->getPropertyValue("SpinIncrement") >>= nIncrement
;
393 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nIncrement
);
395 xPropertySet
->getPropertyValue("Repeat") >>= bRepeat
;
396 CPPUNIT_ASSERT_EQUAL(true, bRepeat
);
398 xPropertySet
->getPropertyValue("RepeatDelay") >>= nDelay
;
399 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nDelay
);
401 xPropertySet
->getPropertyValue("SymbolColor") >>= nArrowColor
;
402 CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), nArrowColor
);
404 xPropertySet
->getPropertyValue("Orientation") >>= nOrientation
;
405 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL
), nOrientation
);
407 xPropertySet
->getPropertyValue("SpinValue") >>= nSpinValue
;
408 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nSpinValue
);
410 // Third control has horizontal orientation
411 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
412 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
414 xPropertySet
->getPropertyValue("Orientation") >>= nOrientation
;
415 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL
), nOrientation
);
418 void SdActiveXControlsTest::testCommandButtonProperties()
420 createSdImpressDoc("pptx/activex_commandbutton.pptx");
422 // First control has default properties
423 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
424 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
427 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
428 CPPUNIT_ASSERT_EQUAL(OUString("CommandButton1"), sLabel
);
431 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
432 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
435 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
436 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
439 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
440 CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor
);
442 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
443 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
446 xPropertySet
->getPropertyValue("FocusOnClick") >>= bFocusOnClick
;
447 CPPUNIT_ASSERT_EQUAL(true, bFocusOnClick
);
450 xPropertySet
->getPropertyValue("Repeat") >>= bRepeat
;
451 CPPUNIT_ASSERT_EQUAL(false, bRepeat
);
453 // Second control has custom properties
454 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
455 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
457 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
458 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel
);
460 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
461 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
463 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
464 CPPUNIT_ASSERT_EQUAL(true, bMultiLine
);
466 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
467 CPPUNIT_ASSERT_EQUAL(Color(0x0000FF), nColor
);
469 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
470 CPPUNIT_ASSERT_EQUAL(Color(0xFFFF80), nColor
);
472 xPropertySet
->getPropertyValue("FocusOnClick") >>= bFocusOnClick
;
473 CPPUNIT_ASSERT_EQUAL(false, bFocusOnClick
);
475 xPropertySet
->getPropertyValue("Repeat") >>= bRepeat
;
476 CPPUNIT_ASSERT_EQUAL(false, bRepeat
);
478 // Third shape has some other custom properties
479 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
480 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
482 // Transparent background
483 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
484 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
487 void SdActiveXControlsTest::testScrollBarProperties()
489 createSdImpressDoc("pptx/activex_scrollbar.pptx");
491 // First control has default properties
492 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
493 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
496 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
497 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
500 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
501 CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor
);
503 xPropertySet
->getPropertyValue("SymbolColor") >>= nColor
;
504 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
507 xPropertySet
->getPropertyValue("RepeatDelay") >>= nDelay
;
508 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nDelay
);
510 sal_Int16 nBorderStyle
;
511 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
512 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle
);
514 sal_Int32 nVisibleSize
;
515 xPropertySet
->getPropertyValue("VisibleSize") >>= nVisibleSize
;
516 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nVisibleSize
);
518 sal_Int32 nScrollValueMin
;
519 xPropertySet
->getPropertyValue("ScrollValueMin") >>= nScrollValueMin
;
520 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nScrollValueMin
);
522 sal_Int32 nScrollValueMax
;
523 xPropertySet
->getPropertyValue("ScrollValueMax") >>= nScrollValueMax
;
524 CPPUNIT_ASSERT_EQUAL(sal_Int32(32767), nScrollValueMax
);
526 sal_Int32 nScrollValue
;
527 xPropertySet
->getPropertyValue("DefaultScrollValue") >>= nScrollValue
;
528 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nScrollValue
);
530 sal_Int32 nLineIncrement
;
531 xPropertySet
->getPropertyValue("LineIncrement") >>= nLineIncrement
;
532 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nLineIncrement
);
534 sal_Int32 nBlockIncrement
;
535 xPropertySet
->getPropertyValue("BlockIncrement") >>= nBlockIncrement
;
536 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nBlockIncrement
);
538 sal_Int32 nOrientation
;
539 xPropertySet
->getPropertyValue("Orientation") >>= nOrientation
;
540 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL
), nOrientation
);
542 // Second control has custom properties
543 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
544 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
546 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
547 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
549 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
550 CPPUNIT_ASSERT_EQUAL(Color(0x00FFFF), nColor
);
552 xPropertySet
->getPropertyValue("SymbolColor") >>= nColor
;
553 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor
);
555 xPropertySet
->getPropertyValue("RepeatDelay") >>= nDelay
;
556 CPPUNIT_ASSERT_EQUAL(sal_Int32(230), nDelay
);
558 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
559 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle
);
561 xPropertySet
->getPropertyValue("VisibleSize") >>= nVisibleSize
;
562 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nVisibleSize
);
564 xPropertySet
->getPropertyValue("ScrollValueMin") >>= nScrollValueMin
;
565 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nScrollValueMin
);
567 xPropertySet
->getPropertyValue("ScrollValueMax") >>= nScrollValueMax
;
568 CPPUNIT_ASSERT_EQUAL(sal_Int32(1234567), nScrollValueMax
);
570 xPropertySet
->getPropertyValue("DefaultScrollValue") >>= nScrollValue
;
571 CPPUNIT_ASSERT_EQUAL(sal_Int32(125), nScrollValue
);
573 xPropertySet
->getPropertyValue("LineIncrement") >>= nLineIncrement
;
574 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nLineIncrement
);
576 xPropertySet
->getPropertyValue("BlockIncrement") >>= nBlockIncrement
;
577 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), nBlockIncrement
);
579 xPropertySet
->getPropertyValue("Orientation") >>= nOrientation
;
580 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL
), nOrientation
);
582 // Third shape has some other custom properties
583 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
584 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
586 xPropertySet
->getPropertyValue("Orientation") >>= nOrientation
;
587 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL
), nOrientation
);
589 xPropertySet
->getPropertyValue("VisibleSize") >>= nVisibleSize
;
590 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nVisibleSize
);
593 void SdActiveXControlsTest::testCheckBoxProperties()
595 createSdImpressDoc("pptx/activex_checkbox.pptx");
597 // First control has default properties
598 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
599 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
602 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
603 CPPUNIT_ASSERT_EQUAL(OUString("CheckBox1"), sLabel
);
606 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
607 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
610 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
611 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
613 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
614 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
617 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
618 CPPUNIT_ASSERT_EQUAL(true, bMultiLine
);
620 sal_Int16 nVisualEffect
;
621 xPropertySet
->getPropertyValue("VisualEffect") >>= nVisualEffect
;
622 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::LOOK3D
), nVisualEffect
);
625 xPropertySet
->getPropertyValue("TriState") >>= bTriState
;
626 CPPUNIT_ASSERT_EQUAL(false, bTriState
);
629 xPropertySet
->getPropertyValue("State") >>= nState
;
630 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState
);
633 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
634 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
636 // Second control has custom properties
637 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
638 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
640 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
641 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel
);
643 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
644 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
646 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
647 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor
);
649 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
650 CPPUNIT_ASSERT_EQUAL(Color(0xFF80FF), nColor
);
652 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
653 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
655 xPropertySet
->getPropertyValue("VisualEffect") >>= nVisualEffect
;
656 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::FLAT
), nVisualEffect
);
658 xPropertySet
->getPropertyValue("TriState") >>= bTriState
;
659 CPPUNIT_ASSERT_EQUAL(true, bTriState
);
661 xPropertySet
->getPropertyValue("State") >>= nState
;
662 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState
);
664 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
665 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
667 // Third shape has some other custom properties
668 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
669 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
671 xPropertySet
->getPropertyValue("TriState") >>= bTriState
;
672 CPPUNIT_ASSERT_EQUAL(true, bTriState
);
674 xPropertySet
->getPropertyValue("State") >>= nState
;
675 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nState
);
677 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
678 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT
), nAlign
);
680 // Transparent background
681 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
);
684 void SdActiveXControlsTest::testOptionButtonProperties()
686 createSdImpressDoc("pptx/activex_optionbutton.pptx");
688 // First control has default properties
689 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
690 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
693 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
694 CPPUNIT_ASSERT_EQUAL(OUString("OptionButton1"), sLabel
);
697 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
698 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
701 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
702 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
704 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
705 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
708 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
709 CPPUNIT_ASSERT_EQUAL(true, bMultiLine
);
711 sal_Int16 nVisualEffect
;
712 xPropertySet
->getPropertyValue("VisualEffect") >>= nVisualEffect
;
713 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::LOOK3D
), nVisualEffect
);
716 xPropertySet
->getPropertyValue("State") >>= nState
;
717 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState
);
720 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
721 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
723 // Second control has custom properties
724 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
725 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
727 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
728 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel
);
730 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
731 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
733 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
734 CPPUNIT_ASSERT_EQUAL(Color(0x00FFFF), nColor
);
736 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
737 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor
);
739 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
740 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
742 xPropertySet
->getPropertyValue("VisualEffect") >>= nVisualEffect
;
743 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::FLAT
), nVisualEffect
);
745 xPropertySet
->getPropertyValue("State") >>= nState
;
746 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState
);
748 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
749 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
751 // Third shape has some other custom properties
752 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
753 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
755 xPropertySet
->getPropertyValue("State") >>= nState
;
756 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState
); // TriState / undefined imported as unchecked
758 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
759 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT
), nAlign
);
761 // Transparent background
762 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
);
765 void SdActiveXControlsTest::testComboBoxProperties()
767 createSdImpressDoc("pptx/activex_combobox.pptx");
769 // First control has default properties
770 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
771 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
774 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
775 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
778 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
779 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
781 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
782 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
785 xPropertySet
->getPropertyValue("Autocomplete") >>= bAutocomplete
;
786 CPPUNIT_ASSERT_EQUAL(true, bAutocomplete
);
788 sal_Int16 nBorderStyle
;
789 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
790 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle
);
793 xPropertySet
->getPropertyValue("BorderColor") >>= nBorderColor
;
794 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nBorderColor
);
797 xPropertySet
->getPropertyValue("Dropdown") >>= bDropdown
;
798 CPPUNIT_ASSERT_EQUAL(true, bDropdown
);
800 bool bHideInactiveSelection
;
801 xPropertySet
->getPropertyValue("HideInactiveSelection") >>= bHideInactiveSelection
;
802 CPPUNIT_ASSERT_EQUAL(true, bHideInactiveSelection
);
804 sal_Int16 nLineCount
;
805 xPropertySet
->getPropertyValue("LineCount") >>= nLineCount
;
806 CPPUNIT_ASSERT_EQUAL(sal_Int16(8), nLineCount
);
808 sal_Int16 nMaxTextLen
;
809 xPropertySet
->getPropertyValue("MaxTextLen") >>= nMaxTextLen
;
810 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nMaxTextLen
);
813 xPropertySet
->getPropertyValue("ReadOnly") >>= bReadOnly
;
814 CPPUNIT_ASSERT_EQUAL(false, bReadOnly
);
817 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
818 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
820 // Second control has custom properties
821 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
822 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
824 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
825 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
827 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
828 CPPUNIT_ASSERT_EQUAL(Color(0x800000), nColor
);
830 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
831 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
833 xPropertySet
->getPropertyValue("Autocomplete") >>= bAutocomplete
;
834 CPPUNIT_ASSERT_EQUAL(true, bAutocomplete
);
836 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
837 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle
);
839 xPropertySet
->getPropertyValue("BorderColor") >>= nBorderColor
;
840 CPPUNIT_ASSERT_EQUAL(Color(0x404040), nBorderColor
);
842 xPropertySet
->getPropertyValue("Dropdown") >>= bDropdown
;
843 CPPUNIT_ASSERT_EQUAL(true, bDropdown
);
845 xPropertySet
->getPropertyValue("HideInactiveSelection") >>= bHideInactiveSelection
;
846 CPPUNIT_ASSERT_EQUAL(false, bHideInactiveSelection
);
848 xPropertySet
->getPropertyValue("LineCount") >>= nLineCount
;
849 CPPUNIT_ASSERT_EQUAL(sal_Int16(12), nLineCount
);
851 xPropertySet
->getPropertyValue("MaxTextLen") >>= nMaxTextLen
;
852 CPPUNIT_ASSERT_EQUAL(sal_Int16(130), nMaxTextLen
);
854 xPropertySet
->getPropertyValue("ReadOnly") >>= bReadOnly
;
855 CPPUNIT_ASSERT_EQUAL(false, bReadOnly
); // Bogus, should be true (tdf#111417)
857 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
858 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
860 // Third shape has some other custom properties
861 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
862 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
864 xPropertySet
->getPropertyValue("Autocomplete") >>= bAutocomplete
;
865 CPPUNIT_ASSERT_EQUAL(false, bAutocomplete
);
867 xPropertySet
->getPropertyValue("Dropdown") >>= bDropdown
;
868 CPPUNIT_ASSERT_EQUAL(false, bDropdown
);
870 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
871 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT
), nAlign
);
873 // Transparent background
874 CPPUNIT_ASSERT_EQUAL(false, xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
);
877 void SdActiveXControlsTest::testListBoxProperties()
879 createSdImpressDoc("pptx/activex_listbox.pptx");
881 // First control has default properties
882 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
883 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
886 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
887 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
890 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
891 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
893 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
894 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
896 sal_Int16 nBorderStyle
;
897 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
898 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle
);
901 xPropertySet
->getPropertyValue("BorderColor") >>= nBorderColor
;
902 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nBorderColor
);
905 xPropertySet
->getPropertyValue("Dropdown") >>= bDropdown
;
906 CPPUNIT_ASSERT_EQUAL(false, bDropdown
);
908 bool bMultiSelection
;
909 xPropertySet
->getPropertyValue("MultiSelection") >>= bMultiSelection
;
910 CPPUNIT_ASSERT_EQUAL(false, bMultiSelection
);
912 sal_Int16 nLineCount
;
913 xPropertySet
->getPropertyValue("LineCount") >>= nLineCount
;
914 CPPUNIT_ASSERT_EQUAL(sal_Int16(5), nLineCount
);
917 xPropertySet
->getPropertyValue("ReadOnly") >>= bReadOnly
;
918 CPPUNIT_ASSERT_EQUAL(false, bReadOnly
);
921 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
922 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
924 // Second control has custom properties
925 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
926 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
928 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
929 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
931 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
932 CPPUNIT_ASSERT_EQUAL(Color(0xFFFF00), nColor
);
934 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
935 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor
);
937 xPropertySet
->getPropertyValue("Border") >>= nBorderStyle
;
938 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle
);
940 xPropertySet
->getPropertyValue("BorderColor") >>= nBorderColor
;
941 CPPUNIT_ASSERT_EQUAL(Color(0xFF00FF), nBorderColor
);
943 xPropertySet
->getPropertyValue("MultiSelection") >>= bMultiSelection
;
944 CPPUNIT_ASSERT_EQUAL(true, bMultiSelection
);
946 xPropertySet
->getPropertyValue("ReadOnly") >>= bReadOnly
;
947 CPPUNIT_ASSERT_EQUAL(false, bReadOnly
); // Bogus, should be true (tdf#111417)
949 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
950 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
952 // Third shape has some other custom properties
953 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
954 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
956 xPropertySet
->getPropertyValue("MultiSelection") >>= bMultiSelection
;
957 CPPUNIT_ASSERT_EQUAL(true, bMultiSelection
);
959 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
960 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT
), nAlign
);
963 void SdActiveXControlsTest::testToggleButtonProperties()
965 createSdImpressDoc("pptx/activex_togglebutton.pptx");
967 // First control has default properties
968 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
969 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
972 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
973 CPPUNIT_ASSERT_EQUAL(OUString("ToggleButton1"), sLabel
);
976 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
977 CPPUNIT_ASSERT_EQUAL(true, bEnabled
);
980 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
981 CPPUNIT_ASSERT_EQUAL(true, bMultiLine
);
984 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
985 CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor
);
987 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
988 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
991 xPropertySet
->getPropertyValue("Toggle") >>= bToggle
;
992 CPPUNIT_ASSERT_EQUAL(true, bToggle
);
995 xPropertySet
->getPropertyValue("State") >>= nState
;
996 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState
);
999 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
1000 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER
), nAlign
);
1002 // Second control has custom properties
1003 xControlShape
.set(getShapeFromPage(1, 0), uno::UNO_QUERY_THROW
);
1004 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
1006 xPropertySet
->getPropertyValue("Label") >>= sLabel
;
1007 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel
);
1009 xPropertySet
->getPropertyValue("Enabled") >>= bEnabled
;
1010 CPPUNIT_ASSERT_EQUAL(false, bEnabled
);
1012 xPropertySet
->getPropertyValue("MultiLine") >>= bMultiLine
;
1013 CPPUNIT_ASSERT_EQUAL(false, bMultiLine
);
1015 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
1016 CPPUNIT_ASSERT_EQUAL(Color(0xFF80FF), nColor
);
1018 xPropertySet
->getPropertyValue("TextColor") >>= nColor
;
1019 CPPUNIT_ASSERT_EQUAL(Color(0x808080), nColor
);
1021 xPropertySet
->getPropertyValue("Toggle") >>= bToggle
;
1022 CPPUNIT_ASSERT_EQUAL(true, bToggle
);
1024 xPropertySet
->getPropertyValue("State") >>= nState
;
1025 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState
);
1027 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
1028 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT
), nAlign
);
1030 // Third shape has some other custom properties
1031 xControlShape
.set(getShapeFromPage(2, 0), uno::UNO_QUERY_THROW
);
1032 xPropertySet
.set(xControlShape
->getControl(), uno::UNO_QUERY
);
1034 xPropertySet
->getPropertyValue("State") >>= nState
;
1035 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState
); // Undefined state
1037 xPropertySet
->getPropertyValue("Align") >>= nAlign
;
1038 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT
), nAlign
);
1040 // Transparent background
1041 xPropertySet
->getPropertyValue("BackgroundColor") >>= nColor
;
1042 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nColor
);
1045 void SdActiveXControlsTest::testPictureProperties()
1047 createSdImpressDoc("pptx/activex_picture.pptx");
1049 // Different controls has different image positioning
1051 // Command buttons here with icons
1052 const std::vector
<sal_Int16
> vImagePositions
=
1054 awt::ImagePosition::AboveCenter
,
1055 awt::ImagePosition::LeftTop
,
1056 awt::ImagePosition::LeftCenter
,
1057 awt::ImagePosition::LeftBottom
,
1058 awt::ImagePosition::RightTop
,
1059 awt::ImagePosition::RightCenter
,
1060 awt::ImagePosition::RightBottom
,
1061 awt::ImagePosition::AboveLeft
,
1062 awt::ImagePosition::AboveRight
,
1063 awt::ImagePosition::BelowLeft
,
1064 awt::ImagePosition::BelowCenter
,
1065 awt::ImagePosition::BelowRight
,
1066 awt::ImagePosition::Centered
,
1069 for (size_t i
= 0; i
< vImagePositions
.size(); ++i
)
1071 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(i
, 0), uno::UNO_QUERY_THROW
);
1072 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
1074 uno::Reference
<graphic::XGraphic
> xGraphic
;
1075 xPropertySet
->getPropertyValue("Graphic") >>= xGraphic
;
1076 CPPUNIT_ASSERT(xGraphic
.is());
1079 xPropertySet
->getPropertyValue("ImagePosition") >>= nColor
;
1080 OString sMessage
= "The wrong control's index is: " + OString::number(i
);
1081 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), vImagePositions
[i
], nColor
);
1084 // Picture controls with different properties
1085 for (size_t i
= 0; i
< 4; ++i
)
1087 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(vImagePositions
.size() + i
, 0), uno::UNO_QUERY_THROW
);
1088 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
1090 OString sMessage
= "The wrong control's index is: " + OString::number(i
);
1092 uno::Reference
<graphic::XGraphic
> xGraphic
;
1093 xPropertySet
->getPropertyValue("Graphic") >>= xGraphic
;
1094 if (i
== 0) // First control has no image specified
1095 CPPUNIT_ASSERT_MESSAGE(sMessage
.getStr(), !xGraphic
.is());
1097 CPPUNIT_ASSERT_MESSAGE(sMessage
.getStr(), xGraphic
.is());
1099 sal_Int16 nScaleMode
;
1100 xPropertySet
->getPropertyValue("ScaleMode") >>= nScaleMode
;
1101 if (i
== 2) // Stretch mode
1102 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), awt::ImageScaleMode::ANISOTROPIC
, nScaleMode
);
1103 else if (i
== 3) // Zoom mode
1104 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), awt::ImageScaleMode::ISOTROPIC
, nScaleMode
);
1106 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), awt::ImageScaleMode::NONE
, nScaleMode
);
1109 // Note: LO picture control does not support tiled image and also image positioning
1110 // When there is no scaling picture positioned to center.
1113 void SdActiveXControlsTest::testFontProperties()
1115 createSdImpressDoc("pptx/activex_fontproperties.pptx");
1117 // Different controls has different font properties
1119 for (size_t i
= 0; i
< 8; ++i
)
1121 uno::Reference
< drawing::XControlShape
> xControlShape(getShapeFromPage(i
, 0), uno::UNO_QUERY_THROW
);
1122 uno::Reference
<beans::XPropertySet
> xPropertySet(xControlShape
->getControl(), uno::UNO_QUERY
);
1124 OString sMessage
= "The wrong control's index is: " + OString::number(i
);
1127 xPropertySet
->getPropertyValue("FontName") >>= sFontName
;
1128 if (i
== 4 || i
== 5)
1129 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), OUString("Times New Roman"), sFontName
);
1131 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), OUString("Arial"), sFontName
);
1134 xPropertySet
->getPropertyValue("FontWeight") >>= fFontWeight
;
1135 if (i
== 2 || i
== 4)
1136 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), awt::FontWeight::BOLD
, fFontWeight
);
1138 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), awt::FontWeight::NORMAL
, fFontWeight
);
1140 sal_Int16 nFontSlant
;
1141 xPropertySet
->getPropertyValue("FontSlant") >>= nFontSlant
;
1142 if (i
== 3 || i
== 4)
1143 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), sal_Int16(awt::FontSlant_ITALIC
), nFontSlant
);
1145 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), sal_Int16(awt::FontSlant_NONE
), nFontSlant
);
1147 sal_Int16 nFontUnderline
;
1148 xPropertySet
->getPropertyValue("FontUnderline") >>= nFontUnderline
;
1150 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), sal_Int16(awt::FontUnderline::SINGLE
), nFontUnderline
);
1152 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), sal_Int16(awt::FontUnderline::NONE
), nFontUnderline
);
1154 sal_Int16 nFontStrikeout
;
1155 xPropertySet
->getPropertyValue("FontStrikeout") >>= nFontStrikeout
;
1156 if (i
== 6 || i
== 7)
1157 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), sal_Int16(awt::FontStrikeout::SINGLE
), nFontStrikeout
);
1159 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), sal_Int16(awt::FontStrikeout::NONE
), nFontStrikeout
);
1162 xPropertySet
->getPropertyValue("FontHeight") >>= fFontHeight
;
1164 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), 24.0f
, fFontHeight
);
1166 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage
.getStr(), 14.0f
, fFontHeight
);
1170 CPPUNIT_TEST_SUITE_REGISTRATION(SdActiveXControlsTest
);
1172 CPPUNIT_PLUGIN_IMPLEMENT();
1174 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */