Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / sd / qa / unit / activex-controls-tests.cxx
blob4903d25b04e2389fd9928777dd9d5ed5a27df55d
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.
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 */
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
29 public:
30 void testBackgroundColor();
31 void testLabelProperties();
32 void testTextBoxProperties();
33 void testSpinButtonProperties();
34 void testCommandButtonProperties();
35 void testScrollBarProperties();
36 void testCheckBoxProperties();
37 void testOptionButtonProperties();
38 void testComboBoxProperties();
39 void testListBoxProperties();
40 void testToggleButtonProperties();
41 void testPictureProperties();
42 void testFontProperties();
44 CPPUNIT_TEST_SUITE(SdActiveXControlsTest);
46 CPPUNIT_TEST(testBackgroundColor);
47 CPPUNIT_TEST(testLabelProperties);
48 CPPUNIT_TEST(testTextBoxProperties);
49 CPPUNIT_TEST(testSpinButtonProperties);
50 CPPUNIT_TEST(testCommandButtonProperties);
51 CPPUNIT_TEST(testScrollBarProperties);
52 CPPUNIT_TEST(testCheckBoxProperties);
53 CPPUNIT_TEST(testOptionButtonProperties);
54 CPPUNIT_TEST(testComboBoxProperties);
55 CPPUNIT_TEST(testListBoxProperties);
56 CPPUNIT_TEST(testToggleButtonProperties);
57 CPPUNIT_TEST(testPictureProperties);
58 CPPUNIT_TEST(testFontProperties);
60 CPPUNIT_TEST_SUITE_END();
63 void SdActiveXControlsTest::testBackgroundColor()
65 // Check whether all system colors are imported correctly
66 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/control_background_color.pptx"), PPTX);
68 const std::vector<sal_Int32> vBackgroundColors =
70 0xD4D0C8, // Scroll Bars
71 0x004E98, // Desktop
72 0x0054E3, // Active Title Bar
73 0x7A96DF, // Inactive Title Bar
74 0xFFFFFF, // Menu Bar
75 0xFFFFFF, // Window Background
76 0x000000, // Window Frame
77 0x000000, // Menu Text
78 0x000000, // Window Text
79 0xFFFFFF, // Active Title Bar Text
80 0xD4D0C8, // Active Border
81 0xD4D0C8, // Inactive Border
82 0x808080, // Application Workspace
83 0x316AC5, // Highlight
84 0xFFFFFF, // Highlight Text
85 0xECE9D8, // Button Face
86 0xACA899, // Button Shadow
87 0xACA899, // Disabled Text
88 0x000000, // Button Text
89 0xD8E4F8, // Inactive Title Bar Text
90 0xFFFFFF, // Button Highlight
91 0x716F64, // Button Dark Shadow
92 0xF1EFE2, // Button Light Shadow
93 0x000000, // Tooltip Text
94 0xFFFFE1, // Tooltip
95 0xFF0000, // Custom red color
98 for (size_t i = 0; i < vBackgroundColors.size(); ++i)
100 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(i, 0, xDocShRef), uno::UNO_QUERY_THROW);
102 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
103 sal_Int32 nColor;
104 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
105 OString sMessage = "The wrong control's index is: " + OString::number(i);
106 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), vBackgroundColors[i], nColor);
109 xDocShRef->DoClose();
112 void SdActiveXControlsTest::testLabelProperties()
114 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_label.pptx"), PPTX);
116 // First control has default properties
117 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
118 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
120 OUString sLabel;
121 xPropertySet->getPropertyValue("Label") >>= sLabel;
122 CPPUNIT_ASSERT_EQUAL(OUString("Label1"), sLabel);
124 bool bEnabled;
125 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
126 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
128 bool bMultiLine;
129 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
130 CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
132 sal_Int32 nColor;
133 xPropertySet->getPropertyValue("TextColor") >>= nColor;
134 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
136 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
137 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
139 sal_Int16 nBorderStyle;
140 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
141 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle);
143 sal_Int16 nAlign;
144 xPropertySet->getPropertyValue("Align") >>= nAlign;
145 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
147 style::VerticalAlignment eAlign;
148 xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign;
149 CPPUNIT_ASSERT_EQUAL(style::VerticalAlignment_TOP, eAlign);
151 // Second control has custom properties
152 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
153 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
155 xPropertySet->getPropertyValue("Label") >>= sLabel;
156 CPPUNIT_ASSERT_EQUAL(OUString("Custom Label"), sLabel);
158 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
159 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
161 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
162 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
164 xPropertySet->getPropertyValue("TextColor") >>= nColor;
165 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xE0E0E0), nColor);
167 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
168 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000FF), nColor);
170 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
171 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
173 sal_Int32 nBorderColor;
174 xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
175 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), nBorderColor);
177 xPropertySet->getPropertyValue("Align") >>= nAlign;
178 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
180 xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign;
181 CPPUNIT_ASSERT_EQUAL(style::VerticalAlignment_TOP, eAlign);
183 // Third control has transparent background
184 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
185 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
187 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
189 xDocShRef->DoClose();
192 void SdActiveXControlsTest::testTextBoxProperties()
194 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_textbox.pptx"), PPTX);
196 // First control has default properties
197 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
198 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
200 OUString sText;
201 xPropertySet->getPropertyValue("Text") >>= sText;
202 CPPUNIT_ASSERT_EQUAL(OUString(), sText);
204 bool bEnabled;
205 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
206 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
208 bool bMultiLine;
209 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
210 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
212 sal_Int32 nColor;
213 xPropertySet->getPropertyValue("TextColor") >>= nColor;
214 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
216 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
217 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
219 sal_Int16 nBorderStyle;
220 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
221 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle);
223 sal_Int16 nAlign;
224 xPropertySet->getPropertyValue("Align") >>= nAlign;
225 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
227 style::VerticalAlignment eAlign;
228 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign);
230 bool bHideSelection;
231 xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideSelection;
232 CPPUNIT_ASSERT_EQUAL(true, bHideSelection);
234 sal_Int16 nMaxLength;
235 xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxLength;
236 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nMaxLength);
238 sal_Int16 nEchoChar;
239 xPropertySet->getPropertyValue("EchoChar") >>= nEchoChar;
240 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nEchoChar);
242 bool bHScroll;
243 xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
244 CPPUNIT_ASSERT_EQUAL(false, bHScroll);
246 bool bVScroll;
247 xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
248 CPPUNIT_ASSERT_EQUAL(false, bVScroll);
250 bool bReadOnly;
251 xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
252 CPPUNIT_ASSERT_EQUAL(false, bReadOnly);
254 // Second control has custom properties
255 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
256 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
258 xPropertySet->getPropertyValue("Text") >>= sText;
259 CPPUNIT_ASSERT_EQUAL(OUString("Some Text"), sText);
261 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
262 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
264 // These textfields are not multilines in the pptx testfile
265 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
266 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
268 xPropertySet->getPropertyValue("TextColor") >>= nColor;
269 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x404040), nColor);
271 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
272 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00C000), nColor);
274 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
275 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
277 xPropertySet->getPropertyValue("Align") >>= nAlign;
278 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
280 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign);
282 xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideSelection;
283 CPPUNIT_ASSERT_EQUAL(false, bHideSelection);
285 xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxLength;
286 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nMaxLength);
288 xPropertySet->getPropertyValue("EchoChar") >>= nEchoChar;
289 CPPUNIT_ASSERT_EQUAL(sal_Int16('x'), nEchoChar);
291 xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
292 CPPUNIT_ASSERT_EQUAL(true, bHScroll);
294 xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
295 CPPUNIT_ASSERT_EQUAL(false, bVScroll);
297 xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
298 CPPUNIT_ASSERT_EQUAL(true, bReadOnly);
300 // Third shape has some other custom properties
301 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
302 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
304 // Transparent background
305 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
307 xPropertySet->getPropertyValue("Align") >>= nAlign;
308 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
310 xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
311 CPPUNIT_ASSERT_EQUAL(false, bHScroll);
313 xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
314 CPPUNIT_ASSERT_EQUAL(true, bVScroll);
316 // Fourth shape has both scroll bar
317 xControlShape.set(getShapeFromPage(3, 0, xDocShRef), uno::UNO_QUERY_THROW);
318 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
320 xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
321 CPPUNIT_ASSERT_EQUAL(true, bHScroll);
323 xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
324 CPPUNIT_ASSERT_EQUAL(true, bVScroll);
326 xDocShRef->DoClose();
329 void SdActiveXControlsTest::testSpinButtonProperties()
331 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_spinbutton.pptx"), PPTX);
333 // First control has default properties
334 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
335 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
337 bool bEnabled;
338 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
339 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
341 sal_Int32 nColor;
342 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
343 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xECE9D8), nColor);
345 sal_Int32 nMax;
346 xPropertySet->getPropertyValue("SpinValueMax") >>= nMax;
347 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nMax);
349 sal_Int32 nMin;
350 xPropertySet->getPropertyValue("SpinValueMin") >>= nMin;
351 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nMin);
353 sal_Int32 nIncrement;
354 xPropertySet->getPropertyValue("SpinIncrement") >>= nIncrement;
355 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nIncrement);
357 bool bRepeat;
358 xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
359 CPPUNIT_ASSERT_EQUAL(true, bRepeat);
361 sal_Int32 nDelay;
362 xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
363 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nDelay);
365 sal_Int32 nArrowColor;
366 xPropertySet->getPropertyValue("SymbolColor") >>= nArrowColor;
367 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nArrowColor);
369 sal_Int32 nOrientation;
370 xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
371 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL), nOrientation);
373 sal_Int32 nSpinValue;
374 xPropertySet->getPropertyValue("SpinValue") >>= nSpinValue;
375 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nSpinValue);
377 // Second control has custom properties
378 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
379 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
381 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
382 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
384 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
385 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF00), nColor);
387 xPropertySet->getPropertyValue("SpinValueMax") >>= nMax;
388 CPPUNIT_ASSERT_EQUAL(sal_Int32(320), nMax);
390 xPropertySet->getPropertyValue("SpinValueMin") >>= nMin;
391 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nMin);
393 xPropertySet->getPropertyValue("SpinIncrement") >>= nIncrement;
394 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nIncrement);
396 xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
397 CPPUNIT_ASSERT_EQUAL(true, bRepeat);
399 xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
400 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nDelay);
402 xPropertySet->getPropertyValue("SymbolColor") >>= nArrowColor;
403 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), nArrowColor);
405 xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
406 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL), nOrientation);
408 xPropertySet->getPropertyValue("SpinValue") >>= nSpinValue;
409 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nSpinValue);
411 // Third control has horizontal orientation
412 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
413 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
415 xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
416 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL), nOrientation);
418 xDocShRef->DoClose();
421 void SdActiveXControlsTest::testCommandButtonProperties()
423 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_commandbutton.pptx"), PPTX);
425 // First control has default properties
426 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
427 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
429 OUString sLabel;
430 xPropertySet->getPropertyValue("Label") >>= sLabel;
431 CPPUNIT_ASSERT_EQUAL(OUString("CommandButton1"), sLabel);
433 bool bEnabled;
434 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
435 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
437 bool bMultiLine;
438 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
439 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
441 sal_Int32 nColor;
442 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
443 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xECE9D8), nColor);
445 xPropertySet->getPropertyValue("TextColor") >>= nColor;
446 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
448 bool bFocusOnClick;
449 xPropertySet->getPropertyValue("FocusOnClick") >>= bFocusOnClick;
450 CPPUNIT_ASSERT_EQUAL(true, bFocusOnClick);
452 bool bRepeat;
453 xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
454 CPPUNIT_ASSERT_EQUAL(false, bRepeat);
456 // Second control has custom properties
457 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
458 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
460 xPropertySet->getPropertyValue("Label") >>= sLabel;
461 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
463 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
464 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
466 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
467 CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
469 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
470 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000FF), nColor);
472 xPropertySet->getPropertyValue("TextColor") >>= nColor;
473 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF80), nColor);
475 xPropertySet->getPropertyValue("FocusOnClick") >>= bFocusOnClick;
476 CPPUNIT_ASSERT_EQUAL(false, bFocusOnClick);
478 xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
479 CPPUNIT_ASSERT_EQUAL(false, bRepeat);
481 // Third shape has some other custom properties
482 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
483 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
485 // Transparent background
486 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
487 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
489 xDocShRef->DoClose();
492 void SdActiveXControlsTest::testScrollBarProperties()
494 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_scrollbar.pptx"), PPTX);
496 // First control has default properties
497 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
498 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
500 bool bEnabled;
501 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
502 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
504 sal_Int32 nColor;
505 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
506 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xECE9D8), nColor);
508 xPropertySet->getPropertyValue("SymbolColor") >>= nColor;
509 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
511 sal_Int32 nDelay;
512 xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
513 CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nDelay);
515 sal_Int16 nBorderStyle;
516 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
517 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle);
519 sal_Int32 nVisibleSize;
520 xPropertySet->getPropertyValue("VisibleSize") >>= nVisibleSize;
521 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nVisibleSize);
523 sal_Int32 nScrollValueMin;
524 xPropertySet->getPropertyValue("ScrollValueMin") >>= nScrollValueMin;
525 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nScrollValueMin);
527 sal_Int32 nScrollValueMax;
528 xPropertySet->getPropertyValue("ScrollValueMax") >>= nScrollValueMax;
529 CPPUNIT_ASSERT_EQUAL(sal_Int32(32767), nScrollValueMax);
531 sal_Int32 nScrollValue;
532 xPropertySet->getPropertyValue("DefaultScrollValue") >>= nScrollValue;
533 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nScrollValue);
535 sal_Int32 nLineIncrement;
536 xPropertySet->getPropertyValue("LineIncrement") >>= nLineIncrement;
537 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nLineIncrement);
539 sal_Int32 nBlockIncrement;
540 xPropertySet->getPropertyValue("BlockIncrement") >>= nBlockIncrement;
541 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nBlockIncrement);
543 sal_Int32 nOrientation;
544 xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
545 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL), nOrientation);
547 // Second control has custom properties
548 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
549 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
551 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
552 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
554 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
555 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FFFF), nColor);
557 xPropertySet->getPropertyValue("SymbolColor") >>= nColor;
558 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), nColor);
560 xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
561 CPPUNIT_ASSERT_EQUAL(sal_Int32(230), nDelay);
563 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
564 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle);
566 xPropertySet->getPropertyValue("VisibleSize") >>= nVisibleSize;
567 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nVisibleSize);
569 xPropertySet->getPropertyValue("ScrollValueMin") >>= nScrollValueMin;
570 CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nScrollValueMin);
572 xPropertySet->getPropertyValue("ScrollValueMax") >>= nScrollValueMax;
573 CPPUNIT_ASSERT_EQUAL(sal_Int32(1234567), nScrollValueMax);
575 xPropertySet->getPropertyValue("DefaultScrollValue") >>= nScrollValue;
576 CPPUNIT_ASSERT_EQUAL(sal_Int32(125), nScrollValue);
578 xPropertySet->getPropertyValue("LineIncrement") >>= nLineIncrement;
579 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nLineIncrement);
581 xPropertySet->getPropertyValue("BlockIncrement") >>= nBlockIncrement;
582 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), nBlockIncrement);
584 xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
585 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL), nOrientation);
587 // Third shape has some other custom properties
588 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
589 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
591 xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
592 CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL), nOrientation);
594 xPropertySet->getPropertyValue("VisibleSize") >>= nVisibleSize;
595 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nVisibleSize);
597 xDocShRef->DoClose();
600 void SdActiveXControlsTest::testCheckBoxProperties()
602 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_checkbox.pptx"), PPTX);
604 // First control has default properties
605 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
606 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
608 OUString sLabel;
609 xPropertySet->getPropertyValue("Label") >>= sLabel;
610 CPPUNIT_ASSERT_EQUAL(OUString("CheckBox1"), sLabel);
612 bool bEnabled;
613 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
614 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
616 sal_Int32 nColor;
617 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
618 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
620 xPropertySet->getPropertyValue("TextColor") >>= nColor;
621 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
623 bool bMultiLine;
624 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
625 CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
627 sal_Int16 nVisualEffect;
628 xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
629 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::LOOK3D), nVisualEffect);
631 bool bTriState;
632 xPropertySet->getPropertyValue("TriState") >>= bTriState;
633 CPPUNIT_ASSERT_EQUAL(false, bTriState);
635 sal_Int16 nState;
636 xPropertySet->getPropertyValue("State") >>= nState;
637 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState);
639 sal_Int16 nAlign;
640 xPropertySet->getPropertyValue("Align") >>= nAlign;
641 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
643 // Second control has custom properties
644 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
645 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
647 xPropertySet->getPropertyValue("Label") >>= sLabel;
648 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
650 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
651 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
653 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
654 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), nColor);
656 xPropertySet->getPropertyValue("TextColor") >>= nColor;
657 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF80FF), nColor);
659 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
660 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
662 xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
663 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::FLAT), nVisualEffect);
665 xPropertySet->getPropertyValue("TriState") >>= bTriState;
666 CPPUNIT_ASSERT_EQUAL(true, bTriState);
668 xPropertySet->getPropertyValue("State") >>= nState;
669 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
671 xPropertySet->getPropertyValue("Align") >>= nAlign;
672 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
674 // Third shape has some other custom properties
675 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
676 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
678 xPropertySet->getPropertyValue("TriState") >>= bTriState;
679 CPPUNIT_ASSERT_EQUAL(true, bTriState);
681 xPropertySet->getPropertyValue("State") >>= nState;
682 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nState);
684 xPropertySet->getPropertyValue("Align") >>= nAlign;
685 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
687 // Transparent background
688 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
690 xDocShRef->DoClose();
693 void SdActiveXControlsTest::testOptionButtonProperties()
695 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_optionbutton.pptx"), PPTX);
697 // First control has default properties
698 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
699 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
701 OUString sLabel;
702 xPropertySet->getPropertyValue("Label") >>= sLabel;
703 CPPUNIT_ASSERT_EQUAL(OUString("OptionButton1"), sLabel);
705 bool bEnabled;
706 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
707 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
709 sal_Int32 nColor;
710 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
711 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
713 xPropertySet->getPropertyValue("TextColor") >>= nColor;
714 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
716 bool bMultiLine;
717 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
718 CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
720 sal_Int16 nVisualEffect;
721 xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
722 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::LOOK3D), nVisualEffect);
724 sal_Int16 nState;
725 xPropertySet->getPropertyValue("State") >>= nState;
726 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState);
728 sal_Int16 nAlign;
729 xPropertySet->getPropertyValue("Align") >>= nAlign;
730 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
732 // Second control has custom properties
733 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
734 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
736 xPropertySet->getPropertyValue("Label") >>= sLabel;
737 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
739 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
740 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
742 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
743 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FFFF), nColor);
745 xPropertySet->getPropertyValue("TextColor") >>= nColor;
746 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), nColor);
748 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
749 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
751 xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
752 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::FLAT), nVisualEffect);
754 xPropertySet->getPropertyValue("State") >>= nState;
755 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
757 xPropertySet->getPropertyValue("Align") >>= nAlign;
758 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
760 // Third shape has some other custom properties
761 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
762 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
764 xPropertySet->getPropertyValue("State") >>= nState;
765 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState); // TriState / undefined imported as unchecked
767 xPropertySet->getPropertyValue("Align") >>= nAlign;
768 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
770 // Transparent background
771 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
773 xDocShRef->DoClose();
776 void SdActiveXControlsTest::testComboBoxProperties()
778 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_combobox.pptx"), PPTX);
780 // First control has default properties
781 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
782 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
784 bool bEnabled;
785 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
786 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
788 sal_Int32 nColor;
789 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
790 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
792 xPropertySet->getPropertyValue("TextColor") >>= nColor;
793 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
795 bool bAutocomplete;
796 xPropertySet->getPropertyValue("Autocomplete") >>= bAutocomplete;
797 CPPUNIT_ASSERT_EQUAL(true, bAutocomplete);
799 sal_Int16 nBorderStyle;
800 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
801 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle);
803 sal_Int32 nBorderColor;
804 xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
805 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nBorderColor);
807 bool bDropdown;
808 xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
809 CPPUNIT_ASSERT_EQUAL(true, bDropdown);
811 bool bHideInactiveSelection;
812 xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideInactiveSelection;
813 CPPUNIT_ASSERT_EQUAL(true, bHideInactiveSelection);
815 sal_Int16 nLineCount;
816 xPropertySet->getPropertyValue("LineCount") >>= nLineCount;
817 CPPUNIT_ASSERT_EQUAL(sal_Int16(8), nLineCount);
819 sal_Int16 nMaxTextLen;
820 xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxTextLen;
821 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nMaxTextLen);
823 bool bReadOnly;
824 xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
825 CPPUNIT_ASSERT_EQUAL(false, bReadOnly);
827 sal_Int16 nAlign;
828 xPropertySet->getPropertyValue("Align") >>= nAlign;
829 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
831 // Second control has custom properties
832 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
833 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
835 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
836 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
838 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
839 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x800000), nColor);
841 xPropertySet->getPropertyValue("TextColor") >>= nColor;
842 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
844 xPropertySet->getPropertyValue("Autocomplete") >>= bAutocomplete;
845 CPPUNIT_ASSERT_EQUAL(true, bAutocomplete);
847 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
848 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
850 xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
851 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x404040), nBorderColor);
853 xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
854 CPPUNIT_ASSERT_EQUAL(true, bDropdown);
856 xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideInactiveSelection;
857 CPPUNIT_ASSERT_EQUAL(false, bHideInactiveSelection);
859 xPropertySet->getPropertyValue("LineCount") >>= nLineCount;
860 CPPUNIT_ASSERT_EQUAL(sal_Int16(12), nLineCount);
862 xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxTextLen;
863 CPPUNIT_ASSERT_EQUAL(sal_Int16(130), nMaxTextLen);
865 xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
866 CPPUNIT_ASSERT_EQUAL(false, bReadOnly); // Bogus, should be true (tdf#111417)
868 xPropertySet->getPropertyValue("Align") >>= nAlign;
869 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
871 // Third shape has some other custom properties
872 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
873 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
875 xPropertySet->getPropertyValue("Autocomplete") >>= bAutocomplete;
876 CPPUNIT_ASSERT_EQUAL(false, bAutocomplete);
878 xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
879 CPPUNIT_ASSERT_EQUAL(false, bDropdown);
881 xPropertySet->getPropertyValue("Align") >>= nAlign;
882 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
884 // Transparent background
885 CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
887 xDocShRef->DoClose();
890 void SdActiveXControlsTest::testListBoxProperties()
892 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_listbox.pptx"), PPTX);
894 // First control has default properties
895 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
896 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
898 bool bEnabled;
899 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
900 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
902 sal_Int32 nColor;
903 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
904 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
906 xPropertySet->getPropertyValue("TextColor") >>= nColor;
907 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
909 sal_Int16 nBorderStyle;
910 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
911 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle);
913 sal_Int32 nBorderColor;
914 xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
915 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nBorderColor);
917 bool bDropdown;
918 xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
919 CPPUNIT_ASSERT_EQUAL(false, bDropdown);
921 bool bMultiSelection;
922 xPropertySet->getPropertyValue("MultiSelection") >>= bMultiSelection;
923 CPPUNIT_ASSERT_EQUAL(false, bMultiSelection);
925 sal_Int16 nLineCount;
926 xPropertySet->getPropertyValue("LineCount") >>= nLineCount;
927 CPPUNIT_ASSERT_EQUAL(sal_Int16(5), nLineCount);
929 bool bReadOnly;
930 xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
931 CPPUNIT_ASSERT_EQUAL(false, bReadOnly);
933 sal_Int16 nAlign;
934 xPropertySet->getPropertyValue("Align") >>= nAlign;
935 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
937 // Second control has custom properties
938 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
939 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
941 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
942 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
944 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
945 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF00), nColor);
947 xPropertySet->getPropertyValue("TextColor") >>= nColor;
948 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), nColor);
950 xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
951 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
953 xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
954 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF00FF), nBorderColor);
956 xPropertySet->getPropertyValue("MultiSelection") >>= bMultiSelection;
957 CPPUNIT_ASSERT_EQUAL(true, bMultiSelection);
959 xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
960 CPPUNIT_ASSERT_EQUAL(false, bReadOnly); // Bogus, should be true (tdf#111417)
962 xPropertySet->getPropertyValue("Align") >>= nAlign;
963 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
965 // Third shape has some other custom properties
966 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
967 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
969 xPropertySet->getPropertyValue("MultiSelection") >>= bMultiSelection;
970 CPPUNIT_ASSERT_EQUAL(true, bMultiSelection);
972 xPropertySet->getPropertyValue("Align") >>= nAlign;
973 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
975 xDocShRef->DoClose();
978 void SdActiveXControlsTest::testToggleButtonProperties()
980 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_togglebutton.pptx"), PPTX);
982 // First control has default properties
983 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
984 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
986 OUString sLabel;
987 xPropertySet->getPropertyValue("Label") >>= sLabel;
988 CPPUNIT_ASSERT_EQUAL(OUString("ToggleButton1"), sLabel);
990 bool bEnabled;
991 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
992 CPPUNIT_ASSERT_EQUAL(true, bEnabled);
994 bool bMultiLine;
995 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
996 CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
998 sal_Int32 nColor;
999 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
1000 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xECE9D8), nColor);
1002 xPropertySet->getPropertyValue("TextColor") >>= nColor;
1003 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), nColor);
1005 bool bToggle;
1006 xPropertySet->getPropertyValue("Toggle") >>= bToggle;
1007 CPPUNIT_ASSERT_EQUAL(true, bToggle);
1009 sal_Int16 nState;
1010 xPropertySet->getPropertyValue("State") >>= nState;
1011 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState);
1013 sal_Int16 nAlign;
1014 xPropertySet->getPropertyValue("Align") >>= nAlign;
1015 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
1017 // Second control has custom properties
1018 xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
1019 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
1021 xPropertySet->getPropertyValue("Label") >>= sLabel;
1022 CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
1024 xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
1025 CPPUNIT_ASSERT_EQUAL(false, bEnabled);
1027 xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
1028 CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
1030 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
1031 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF80FF), nColor);
1033 xPropertySet->getPropertyValue("TextColor") >>= nColor;
1034 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x808080), nColor);
1036 xPropertySet->getPropertyValue("Toggle") >>= bToggle;
1037 CPPUNIT_ASSERT_EQUAL(true, bToggle);
1039 xPropertySet->getPropertyValue("State") >>= nState;
1040 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
1042 xPropertySet->getPropertyValue("Align") >>= nAlign;
1043 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
1045 // Third shape has some other custom properties
1046 xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
1047 xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
1049 xPropertySet->getPropertyValue("State") >>= nState;
1050 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState); // Undefined state
1052 xPropertySet->getPropertyValue("Align") >>= nAlign;
1053 CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
1055 // Transparent background
1056 xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
1057 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFFFF), nColor);
1059 xDocShRef->DoClose();
1062 void SdActiveXControlsTest::testPictureProperties()
1064 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_picture.pptx"), PPTX);
1066 // Different controls has different image positioning
1068 // Command buttons here with icons
1069 const std::vector<sal_Int16> vImagePositions =
1071 awt::ImagePosition::AboveCenter,
1072 awt::ImagePosition::LeftTop,
1073 awt::ImagePosition::LeftCenter,
1074 awt::ImagePosition::LeftBottom,
1075 awt::ImagePosition::RightTop,
1076 awt::ImagePosition::RightCenter,
1077 awt::ImagePosition::RightBottom,
1078 awt::ImagePosition::AboveLeft,
1079 awt::ImagePosition::AboveRight,
1080 awt::ImagePosition::BelowLeft,
1081 awt::ImagePosition::BelowCenter,
1082 awt::ImagePosition::BelowRight,
1083 awt::ImagePosition::Centered,
1086 for (size_t i = 0; i < vImagePositions.size(); ++i)
1088 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(i, 0, xDocShRef), uno::UNO_QUERY_THROW);
1089 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1091 uno::Reference<graphic::XGraphic> xGraphic;
1092 xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
1093 CPPUNIT_ASSERT(xGraphic.is());
1095 sal_Int16 nColor;
1096 xPropertySet->getPropertyValue("ImagePosition") >>= nColor;
1097 OString sMessage = "The wrong control's index is: " + OString::number(i);
1098 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), vImagePositions[i], nColor);
1101 // Picture controls with different properties
1102 for (size_t i = 0; i < 4; ++i)
1104 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(vImagePositions.size() + i, 0, xDocShRef), uno::UNO_QUERY_THROW);
1105 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1107 OString sMessage = "The wrong control's index is: " + OString::number(i);
1109 uno::Reference<graphic::XGraphic> xGraphic;
1110 xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
1111 if (i == 0) // First control has no image specified
1112 CPPUNIT_ASSERT_MESSAGE(sMessage.getStr(), !xGraphic.is());
1113 else
1114 CPPUNIT_ASSERT_MESSAGE(sMessage.getStr(), xGraphic.is());
1116 sal_Int16 nScaleMode;
1117 xPropertySet->getPropertyValue("ScaleMode") >>= nScaleMode;
1118 if (i == 2) // Stretch mode
1119 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::ImageScaleMode::ANISOTROPIC, nScaleMode);
1120 else if (i == 3) // Zoom mode
1121 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::ImageScaleMode::ISOTROPIC, nScaleMode);
1122 else // Clip mode
1123 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::ImageScaleMode::NONE, nScaleMode);
1126 // Note: LO picture control does not support tiled image and also image positioning
1127 // When there is no scaling picture positioned to center.
1129 xDocShRef->DoClose();
1132 void SdActiveXControlsTest::testFontProperties()
1134 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/activex_fontproperties.pptx"), PPTX);
1136 // Different controls has different font properties
1138 for (size_t i = 0; i < 8; ++i)
1140 uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(i, 0, xDocShRef), uno::UNO_QUERY_THROW);
1141 uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
1143 OString sMessage = "The wrong control's index is: " + OString::number(i);
1145 OUString sFontName;
1146 xPropertySet->getPropertyValue("FontName") >>= sFontName;
1147 if (i == 4 || i == 5)
1148 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), OUString("Times New Roman"), sFontName);
1149 else
1150 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), OUString("Arial"), sFontName);
1152 float fFontWeight;
1153 xPropertySet->getPropertyValue("FontWeight") >>= fFontWeight;
1154 if (i == 2 || i == 4)
1155 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::FontWeight::BOLD, fFontWeight);
1156 else
1157 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::FontWeight::NORMAL, fFontWeight);
1159 sal_Int16 nFontSlant;
1160 xPropertySet->getPropertyValue("FontSlant") >>= nFontSlant;
1161 if (i == 3 || i == 4)
1162 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontSlant_ITALIC), nFontSlant);
1163 else
1164 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontSlant_NONE), nFontSlant);
1166 sal_Int16 nFontUnderline;
1167 xPropertySet->getPropertyValue("FontUnderline") >>= nFontUnderline;
1168 if (i == 7)
1169 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontUnderline::SINGLE), nFontUnderline);
1170 else
1171 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontUnderline::NONE), nFontUnderline);
1173 sal_Int16 nFontStrikeout;
1174 xPropertySet->getPropertyValue("FontStrikeout") >>= nFontStrikeout;
1175 if (i == 6 || i == 7)
1176 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontStrikeout::SINGLE), nFontStrikeout);
1177 else
1178 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontStrikeout::NONE), nFontStrikeout);
1180 float fFontHeight;
1181 xPropertySet->getPropertyValue("FontHeight") >>= fFontHeight;
1182 if (i == 1)
1183 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), 24.0f, fFontHeight);
1184 else
1185 CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), 14.0f, fFontHeight);
1188 xDocShRef->DoClose();
1191 CPPUNIT_TEST_SUITE_REGISTRATION(SdActiveXControlsTest);
1193 CPPUNIT_PLUGIN_IMPLEMENT();
1195 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */