1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <officecfg/Office/Common.hxx>
#include "sdmodeltestbase.hxx"
#include <sdpage.hxx>
#include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/colritem.hxx>
#include <svx/svdotext.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdomedia.hxx>
#include <unotools/mediadescriptor.hxx>
#include <rtl/ustring.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
#include <vcl/skia/SkiaHelper.hxx>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/graphic/GraphicType.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <svx/svdotable.hxx>
#include <config_features.h>
using namespace css;
using namespace css::animations;
class SdExportTest : public SdModelTestBaseXML
{
public:
void testBackgroundImage();
void testMediaEmbedding();
void testFdo84043();
void testTdf97630();
void testSwappedOutImageExport();
void testOOoXMLAnimations();
void testBnc480256();
void testUnknownAttributes();
void testTdf80020();
void testLinkedGraphicRT();
void testTdf79082();
void testImageWithSpecialID();
void testTdf62176();
void testTransparentBackground();
void testEmbeddedPdf();
void testEmbeddedText();
void testTransparenText();
void testDefaultSubscripts();
void testTdf98477();
void testAuthorField();
void testTdf50499();
void testTdf100926();
void testPageWithTransparentBackground();
void testTextRotation();
void testTdf115394PPT();
void testBulletsAsImage();
void testTdf113818();
void testTdf119629();
void testTdf123557();
void testTdf113822();
void testTdf126761();
void testGlow();
void testSoftEdges();
CPPUNIT_TEST_SUITE(SdExportTest);
CPPUNIT_TEST(testBackgroundImage);
CPPUNIT_TEST(testMediaEmbedding);
CPPUNIT_TEST(testFdo84043);
CPPUNIT_TEST(testTdf97630);
CPPUNIT_TEST(testSwappedOutImageExport);
CPPUNIT_TEST(testOOoXMLAnimations);
CPPUNIT_TEST(testBnc480256);
CPPUNIT_TEST(testUnknownAttributes);
CPPUNIT_TEST(testTdf80020);
CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST(testTdf79082);
CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST(testTdf62176);
CPPUNIT_TEST(testTransparentBackground);
CPPUNIT_TEST(testEmbeddedPdf);
CPPUNIT_TEST(testEmbeddedText);
CPPUNIT_TEST(testTransparenText);
CPPUNIT_TEST(testDefaultSubscripts);
CPPUNIT_TEST(testTdf98477);
CPPUNIT_TEST(testAuthorField);
CPPUNIT_TEST(testTdf50499);
CPPUNIT_TEST(testTdf100926);
CPPUNIT_TEST(testPageWithTransparentBackground);
CPPUNIT_TEST(testTextRotation);
CPPUNIT_TEST(testTdf115394PPT);
CPPUNIT_TEST(testBulletsAsImage);
CPPUNIT_TEST(testTdf113818);
CPPUNIT_TEST(testTdf119629);
CPPUNIT_TEST(testTdf123557);
CPPUNIT_TEST(testTdf113822);
CPPUNIT_TEST(testTdf126761);
CPPUNIT_TEST(testGlow);
CPPUNIT_TEST(testSoftEdges);
CPPUNIT_TEST_SUITE_END();
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
{
static const struct { char const * pPrefix; char const * pURI; } namespaces[] =
{
// ODF
{ "anim", "urn:oasis:names:tc:opendocument:xmlns:animation:1.0" },
{ "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" },
{ "fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" },
{ "number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" },
{ "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" },
{ "presentation", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" },
{ "style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" },
{ "svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" },
{ "table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" },
{ "text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" },
{ "xlink", "http://www.w3c.org/1999/xlink" },
{ "loext", "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" },
{ "smil", "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" },
// user-defined
{ "foo", "http://example.com/" },
};
for (size_t i = 0; i < SAL_N_ELEMENTS(namespaces); ++i)
{
xmlXPathRegisterNs(pXmlXPathCtx,
reinterpret_cast<xmlChar const *>(namespaces[i].pPrefix),
reinterpret_cast<xmlChar const *>(namespaces[i].pURI));
}
}
};
namespace
{
uno::Reference<awt::XBitmap> getBitmapFromTable(const sd::DrawDocShellRef& xDocShRef,
OUString const& rName)
{
uno::Reference<awt::XBitmap> xBitmap;
uno::Reference<lang::XMultiServiceFactory> xFactory(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
try
{
uno::Reference<container::XNameAccess> xBitmapTable(xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY);
uno::Any rValue = xBitmapTable->getByName(rName);
if (rValue.has<uno::Reference<awt::XBitmap>>())
{
return rValue.get<uno::Reference<awt::XBitmap>>();
}
}
catch (const uno::Exception & /*rEx*/)
{
}
return xBitmap;
}
}
void SdExportTest::testBackgroundImage()
{
// Initial bug: N821567
// Check if Slide background image is imported from PPTX and exported to PPTX, PPT and ODP correctly
OUString bgImageName;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n821567.pptx"), PPTX);
// Check that imported background image from PPTX exists
{
uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount());
uno::Reference<drawing::XDrawPage> xPage(getPage(0, xDocShRef));
uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
uno::Any aAny = xPropertySet->getPropertyValue("Background");
if (aAny.has<uno::Reference<beans::XPropertySet>>())
{
uno::Reference<beans::XPropertySet> xBackgroundPropSet;
aAny >>= xBackgroundPropSet;
aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
aAny >>= bgImageName;
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not imported from PPTX correctly", OUString("msFillBitmap 1"), bgImageName);
uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName);
CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when imported from PPTX", xBitmap.is());
}
// Save as PPTX, reload and check again so we make sure exporting to PPTX is working correctly
{
xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount());
uno::Reference<drawing::XDrawPage> xPage(getPage(0, xDocShRef));
uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
uno::Any aAny = xPropertySet->getPropertyValue("Background");
if (aAny.hasValue())
{
uno::Reference<beans::XPropertySet> xBackgroundPropSet;
aAny >>= xBackgroundPropSet;
aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
aAny >>= bgImageName;
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported from PPTX correctly", OUString("msFillBitmap 1"), bgImageName);
uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName);
CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported from PPTX", xBitmap.is());
}
// Save as ODP, reload and check again so we make sure exporting and importing to ODP is working correctly
{
xDocShRef = saveAndReload(xDocShRef.get(), ODP);
uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount());
uno::Reference<drawing::XDrawPage> xPage(getPage(0, xDocShRef));
uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
uno::Any aAny = xPropertySet->getPropertyValue("Background");
if (aAny.hasValue())
{
uno::Reference<beans::XPropertySet> xBackgroundPropSet;
aAny >>= xBackgroundPropSet;
aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
aAny >>= bgImageName;
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported or imported from ODP correctly", OUString("msFillBitmap 1"), bgImageName);
uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName);
CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported or imported from ODP", xBitmap.is());
}
xDocShRef->DoClose();
}
namespace {
template< typename ItemValue, typename ItemType >
void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal)
{
CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject();
std::vector<EECharAttrib> rLst;
aEdit.GetCharAttribs(0, rLst);
for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
{
const ItemType* pAttrib = dynamic_cast<const ItemType *>((*it).pAttr);
if (pAttrib)
{
CPPUNIT_ASSERT_EQUAL( nVal, static_cast<ItemValue>(pAttrib->GetValue()));
}
}
}
}
void SdExportTest::testTransparentBackground()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/transparent_background.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
const SdrPage *pPage = GetPage( 1, xDocShRef );
const SdrTextObj *pObj1 = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) );
checkFontAttributes<Color, SvxBackgroundColorItem>( pObj1, COL_TRANSPARENT );
const SdrTextObj *pObj2 = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) );
checkFontAttributes<Color, SvxBackgroundColorItem>( pObj2, COL_YELLOW);
xDocShRef->DoClose();
}
void SdExportTest::testMediaEmbedding()
{
#ifdef _WIN32
// This seems broken. This test should not be disabled for all cases except when OpenGL
// is found to be working, just because in some OpenGL setups this breaks (per the commit log message).
if (!OpenGLWrapper::isVCLOpenGLEnabled() && !SkiaHelper::isVCLSkiaEnabled())
return;
#endif
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/media_embedding.odp"), ODP);
const SdrPage *pPage = GetPage( 1, xDocShRef );
// Second object is a sound
SdrMediaObj *pMediaObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 3 ));
CPPUNIT_ASSERT_MESSAGE( "missing media object", pMediaObj != nullptr);
CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Media/button-1.wav" ), pMediaObj->getMediaProperties().getURL());
CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.sun.star.media" ), pMediaObj->getMediaProperties().getMimeType());
xDocShRef->DoClose();
}
void SdExportTest::testFdo84043()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo84043.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
// the bug was duplicate attributes, causing crash in a build with asserts
const SdrPage *pPage = GetPage( 1, xDocShRef );
SdrObject const* pShape = pPage->GetObj(1);
CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
xDocShRef->DoClose();
}
void SdExportTest::testTdf97630()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fit-to-size.fodp"), FODP);
{
uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDocShRef->GetModel(), uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDP(xDPS->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
drawing::TextFitToSizeType tmp;
// text shapes
uno::Reference<beans::XPropertySet> xShape0(xDP->getByIndex(0), uno::UNO_QUERY);
xShape0->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
uno::Reference<beans::XPropertySet> xShape1(xDP->getByIndex(1), uno::UNO_QUERY);
xShape1->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
uno::Reference<beans::XPropertySet> xShape2(xDP->getByIndex(2), uno::UNO_QUERY);
xShape2->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_ALLLINES, tmp);
uno::Reference<beans::XPropertySet> xShape3(xDP->getByIndex(3), uno::UNO_QUERY);
xShape3->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, tmp);
// fontworks
uno::Reference<beans::XPropertySet> xShape4(xDP->getByIndex(4), uno::UNO_QUERY);
xShape4->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
uno::Reference<beans::XPropertySet> xShape5(xDP->getByIndex(5), uno::UNO_QUERY);
xShape5->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_ALLLINES, tmp);
}
utl::TempFile aTempFile;
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &aTempFile);
{
uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDocShRef->GetModel(), uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDP(xDPS->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
drawing::TextFitToSizeType tmp;
// text shapes
uno::Reference<beans::XPropertySet> xShape0(xDP->getByIndex(0), uno::UNO_QUERY);
xShape0->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
uno::Reference<beans::XPropertySet> xShape1(xDP->getByIndex(1), uno::UNO_QUERY);
xShape1->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
uno::Reference<beans::XPropertySet> xShape2(xDP->getByIndex(2), uno::UNO_QUERY);
xShape2->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
uno::Reference<beans::XPropertySet> xShape3(xDP->getByIndex(3), uno::UNO_QUERY);
xShape3->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, tmp);
// fontworks
uno::Reference<beans::XPropertySet> xShape4(xDP->getByIndex(4), uno::UNO_QUERY);
xShape4->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
uno::Reference<beans::XPropertySet> xShape5(xDP->getByIndex(5), uno::UNO_QUERY);
xShape5->getPropertyValue("TextFitToSize") >>= tmp;
CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
}
xmlDocUniquePtr pXmlDoc = parseExport(aTempFile, "content.xml");
// text shapes
assertXPath(pXmlDoc, "//style:style[@style:family='presentation']/style:graphic-properties[@draw:fit-to-size='false' and @style:shrink-to-fit='false']", 1);
assertXPath(pXmlDoc, "//style:style[@style:family='presentation']/style:graphic-properties[@draw:fit-to-size='true' and @style:shrink-to-fit='false']", 2);
assertXPath(pXmlDoc, "//style:style[@style:family='presentation']/style:graphic-properties[@draw:fit-to-size='false' and @style:shrink-to-fit='true']", 1);
// fontworks
assertXPath(pXmlDoc, "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fit-to-size='false' and @style:shrink-to-fit='false']", 1);
assertXPath(pXmlDoc, "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fit-to-size='true' and @style:shrink-to-fit='false']", 1);
xDocShRef->DoClose();
}
void SdExportTest::testSwappedOutImageExport()
{
// Problem was with the swapped out images, which were not swapped in during export.
const sal_Int32 vFormats[] = {
ODP,
PPT,
PPTX,
};
// Set cache size to a very small value to make sure one of the images is swapped out
std::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), xBatch);
xBatch->commit();
for( size_t nExportFormat = 0; nExportFormat < SAL_N_ELEMENTS(vFormats); ++nExportFormat )
{
// Load the original file with one image
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/document_with_two_images.odp"), ODP);
const OString sFailedMessage = OStringLiteral("Failed on filter: ") + aFileFormats[vFormats[nExportFormat]].pFilterName;
// Export the document and import again for a check
uno::Reference< lang::XComponent > xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[vFormats[nExportFormat]].pFilterName), RTL_TEXTENCODING_UTF8);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xComponent.set(xStorable, uno::UNO_QUERY);
xComponent->dispose();
xDocShRef = loadURL(aTempFile.GetURL(), nExportFormat);
// Check whether graphic exported well after it was swapped out
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDrawPagesSupplier->getDrawPages()->getCount());
uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
// Check Graphic, Size
{
uno::Reference<graphic::XGraphic> xGraphic;
XPropSet->getPropertyValue("Graphic") >>= xGraphic;
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic->getType() != graphic::GraphicType::EMPTY);
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height );
}
// Second Image
xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check Graphic, Size
{
uno::Reference<graphic::XGraphic> xGraphic;
XPropSet->getPropertyValue("Graphic") >>= xGraphic;
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic->getType() != graphic::GraphicType::EMPTY);
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), xBitmap->getSize().Height );
}
xDocShRef->DoClose();
}
}
void SdExportTest::testOOoXMLAnimations()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/sxi/ooo41061-1.sxi"), SXI);
uno::Reference<lang::XComponent> xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(getFormat(ODP)->pFilterName), RTL_TEXTENCODING_UTF8);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xDocShRef->DoClose();
// the problem was that legacy OOoXML animations were lost if store
// immediately follows load because they were "converted" async by a timer
xmlDocUniquePtr pXmlDoc = parseExport(aTempFile, "content.xml");
assertXPath(pXmlDoc, "//anim:par[@presentation:node-type='timing-root']", 26);
// currently getting 52 of these without the fix (depends on timing)
assertXPath(pXmlDoc, "//anim:par", 223);
}
void SdExportTest::testBnc480256()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc480256.pptx"), PPTX);
// In the document, there are two tables with table background properties.
// Make sure colors are set properly for individual cells.
// TODO: If you are working on improving table background support, expect
// this unit test to fail. In that case, feel free to change the numbers.
const SdrPage *pPage = GetPage( 1, xDocShRef );
sdr::table::SdrTableObj *pTableObj;
uno::Reference< table::XCellRange > xTable;
uno::Reference< beans::XPropertySet > xCell;
sal_Int32 nColor;
table::BorderLine2 aBorderLine;
pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(10208238), nColor);
xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine.Color);
xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(13032959), nColor);
xCell->getPropertyValue("TopBorder") >>= aBorderLine;
CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine.Color);
pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(1));
CPPUNIT_ASSERT( pTableObj );
xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(7056614), nColor);
xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
CPPUNIT_ASSERT_EQUAL(util::Color(12505062), aBorderLine.Color);
xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(4626400), nColor);
xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
CPPUNIT_ASSERT_EQUAL(util::Color(COL_AUTO), aBorderLine.Color);
xDocShRef->DoClose();
}
void SdExportTest::testUnknownAttributes()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/unknown-attribute.fodp"), FODP);
uno::Reference<lang::XComponent> xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(getFormat(ODP)->pFilterName), RTL_TEXTENCODING_UTF8);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xDocShRef->DoClose();
xmlDocUniquePtr pXmlDoc = parseExport(aTempFile, "content.xml");
assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/style:graphic-properties[@foo:non-existent-att='bar']");
// TODO: if the namespace is *known*, the attribute is not preserved, but that seems to be a pre-existing problem, or maybe it's even intentional?
// assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/style:graphic-properties[@svg:non-existent-att='blah']");
// this was on style:graphic-properties on the import, but the export moves it to root node which is OK
assertXPathNSDef(pXmlDoc, "/office:document-content", "foo", "http://example.com/");
}
void SdExportTest::testTdf80020()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf80020.odp"), ODP);
{
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"), uno::UNO_QUERY);
uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("Test Style"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("text"), xStyle->getParentStyle());
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
}
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"), uno::UNO_QUERY);
uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("Test Style"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("text"), xStyle->getParentStyle());
xDocShRef->DoClose();
}
void SdExportTest::testLinkedGraphicRT()
{
// Problem was with linked images
const sal_Int32 vFormats[] = {
ODP,
PPT,
// PPTX, -> this fails now, need a fix
};
for( size_t nExportFormat = 0; nExportFormat < SAL_N_ELEMENTS(vFormats); ++nExportFormat )
{
// Load the original file with one image
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/document_with_linked_graphic.odp"), ODP);
// Export the document and import again for a check
uno::Reference< lang::XComponent > xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[vFormats[nExportFormat]].pFilterName), RTL_TEXTENCODING_UTF8);
// Check if the graphic has been imported correctly (before doing the export/import run)
{
const OString sFailedImportMessage = "Failed to correctly import the document";
SdDrawDocument* pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pDoc != nullptr);
const SdrPage* pPage = pDoc->GetPage(1);
CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pPage != nullptr);
SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject != nullptr );
CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject->IsLinkedGraphic() );
const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), sal_uLong(864900), rGraphicObj.GetGraphic().GetSizeBytes());
}
// Save and reload
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xComponent.set(xStorable, uno::UNO_QUERY);
xComponent->dispose();
xDocShRef = loadURL(aTempFile.GetURL(), nExportFormat);
// Check whether graphic imported well after export
{
const OString sFailedMessage = OStringLiteral("Failed on filter: ") + aFileFormats[vFormats[nExportFormat]].pFilterName;
SdDrawDocument *pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDoc != nullptr );
const SdrPage *pPage = pDoc->GetPage(1);
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != nullptr );
SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject != nullptr );
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject->IsLinkedGraphic() );
const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetGraphic().GetSizeBytes());
}
xDocShRef->DoClose();
}
}
void SdExportTest::testTdf79082()
{
sd::DrawDocShellRef xDocShRef
= loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf79082.ppt"), PPT);
utl::TempFile tempFile;
tempFile.EnableKillingFile();
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
// P1 should have 6 tab stops defined
assertXPathChildren(
pXmlDoc, "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops", 6);
assertXPath(pXmlDoc,
"//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
"style:tab-stop[1]",
"position", "0cm");
assertXPath(pXmlDoc,
"//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
"style:tab-stop[2]",
"position", "5.08cm");
assertXPath(pXmlDoc,
"//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
"style:tab-stop[3]",
"position", "10.16cm");
assertXPath(pXmlDoc,
"//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
"style:tab-stop[4]",
"position", "15.24cm");
assertXPath(pXmlDoc,
"//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
"style:tab-stop[5]",
"position", "20.32cm");
assertXPath(pXmlDoc,
"//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
"style:tab-stop[6]",
"position", "25.4cm");
xDocShRef->DoClose();
}
void SdExportTest::testImageWithSpecialID()
{
// Check how LO handles when the imported graphic's ID is different from that one
// which is generated by LO.
const sal_Int32 vFormats[] = {
ODP,
PPT,
PPTX,
};
// Trigger swap out mechanism to test swapped state factor too.
std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch);
batch->commit();
for( size_t nExportFormat = 0; nExportFormat < SAL_N_ELEMENTS(vFormats); ++nExportFormat )
{
// Load the original file
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/images_with_special_IDs.odp"), ODP);
const OString sFailedMessage = OStringLiteral("Failed on filter: ") + aFileFormats[vFormats[nExportFormat]].pFilterName;
// Export the document and import again for a check
uno::Reference< lang::XComponent > xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[vFormats[nExportFormat]].pFilterName), RTL_TEXTENCODING_UTF8);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xComponent.set(xStorable, uno::UNO_QUERY);
xComponent->dispose();
xDocShRef = loadURL(aTempFile.GetURL(), nExportFormat);
// Check whether graphic was exported well
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDrawPagesSupplier->getDrawPages()->getCount() );
uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
// Check Graphic, Size
{
uno::Reference<graphic::XGraphic> xGraphic;
XPropSet->getPropertyValue("Graphic") >>= xGraphic;
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic->getType() != graphic::GraphicType::EMPTY);
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height );
}
// Second Image
xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check Graphic, Size
{
uno::Reference<graphic::XGraphic> xGraphic;
XPropSet->getPropertyValue("Graphic") >>= xGraphic;
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic->getType() != graphic::GraphicType::EMPTY);
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), xBitmap->getSize().Height );
}
xDocShRef->DoClose();
}
}
void SdExportTest::testTdf62176()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/Tdf62176.odp"), ODP);
uno::Reference<drawing::XDrawPage> xPage( getPage( 0, xDocShRef ) );
//there should be only *one* shape
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage->getCount());
uno::Reference<beans::XPropertySet> xShape( getShape( 0, xPage ) );
//checking Paragraph's Left Margin with expected value
sal_Int32 nParaLeftMargin = 0;
xShape->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nParaLeftMargin);
//checking Paragraph's First Line Indent with expected value
sal_Int32 nParaFirstLineIndent = 0;
xShape->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent;
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent);
//Checking the *Text* in TextBox
uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph->getString());
//Saving and Reloading the file
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
uno::Reference<drawing::XDrawPage> xPage2( getPage(0, xDocShRef ) );
//there should be only *one* shape
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage2->getCount());
uno::Reference<beans::XPropertySet> xShape2( getShape( 0, xPage2 ) );
//checking Paragraph's Left Margin with expected value
sal_Int32 nParaLeftMargin2 = 0;
xShape2->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin2;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nParaLeftMargin2);
//checking Paragraph's First Line Indent with expected value
sal_Int32 nParaFirstLineIndent2 = 0;
xShape2->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent2;
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent2);
//Checking the *Text* in TextBox
uno::Reference<text::XTextRange> xParagraph2( getParagraphFromShape( 0, xShape2 ) );
CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph2->getString());
xDocShRef->DoClose();
}
void SdExportTest::testEmbeddedPdf()
{
#if HAVE_FEATURE_PDFIUM
sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/embedded-pdf.odp"), ODP);
xShell = saveAndReload( xShell.get(), ODP );
uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
uno::Reference<graphic::XGraphic> xGraphic;
xShape->getPropertyValue("ReplacementGraphic") >>= xGraphic;
CPPUNIT_ASSERT(xGraphic.is());
xShell->DoClose();
#endif
}
void SdExportTest::testEmbeddedText()
{
sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/objectwithtext.fodg"), FODG);
xShell = saveAndReload( xShell.get(), ODG );
uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XText> xText(xShape, uno::UNO_QUERY);
CPPUNIT_ASSERT(xText.is());
uno::Reference<container::XEnumerationAccess> xEA(xShape, uno::UNO_QUERY);
CPPUNIT_ASSERT(xEA->hasElements());
uno::Reference<container::XEnumeration> xEnum(xEA->createEnumeration());
uno::Reference<text::XTextContent> xTC;
xEnum->nextElement() >>= xTC;
CPPUNIT_ASSERT(xTC.is());
uno::Reference<container::XEnumerationAccess> xParaEA(xTC, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum(xParaEA->createEnumeration());
uno::Reference<beans::XPropertySet> xPortion(xParaEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT(xPortion.is());
uno::Reference<text::XTextRange> xRange(xPortion, uno::UNO_QUERY);
OUString type;
xPortion->getPropertyValue("TextPortionType") >>= type;
CPPUNIT_ASSERT_EQUAL(OUString("Text"), type);
CPPUNIT_ASSERT_EQUAL(OUString("foobar"), xRange->getString()); //tdf#112547
xShell->DoClose();
}
void SdExportTest::testTransparenText()
{
sd::DrawDocShellRef xShell
= loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/transparent-text.fodg"), FODG);
xShell = saveAndReload(xShell.get(), ODG);
uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
sal_Int16 nCharTransparence = 0;
xShape->getPropertyValue("CharTransparence") >>= nCharTransparence;
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 75
// - Actual : 0
// i.e. the 75% transparent text was turned into a "not transparent at all" text.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(75), nCharTransparence);
xShell->DoClose();
}
void SdExportTest::testDefaultSubscripts()
{
sd::DrawDocShellRef xShell
= loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf80194_defaultSubscripts.fodg"), FODG);
xShell = saveAndReload(xShell.get(), ODG);
uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
uno::Reference<drawing::XShape> xShape(xPage->getByIndex(1), uno::UNO_QUERY);
// Default subscripts were too large, enlarging the gap between the next line.
// The exact size isn't important. Was 18975, now 16604.
CPPUNIT_ASSERT(17000 > xShape->getSize().Height);
xShell->DoClose();
}
void SdExportTest::testTdf98477()
{
utl::TempFile tempFile;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf98477grow.pptx"), PPTX);
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
assertXPath(pXmlDoc, "//anim:animateTransform", "by", "0.5,0.5");
xDocShRef->DoClose();
}
void SdExportTest::testAuthorField()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/author_fixed.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef);
CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
uno::Reference< beans::XPropertySet > xPropSet( xField, uno::UNO_QUERY_THROW );
bool bFixed = false;
xPropSet->getPropertyValue("IsFixed") >>= bFixed;
CPPUNIT_ASSERT_MESSAGE("Author field is not fixed", bFixed);
xDocShRef->DoClose();
}
void SdExportTest::testTdf50499()
{
utl::TempFile tempFile;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf50499.pptx"), PPTX);
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
assertXPath(pXmlDoc, "//anim:animate[1]", "from", "(-width/2)");
assertXPath(pXmlDoc, "//anim:animate[1]", "to", "(x)");
assertXPath(pXmlDoc, "//anim:animate[3]", "by", "(height/3+width*0.1)");
xDocShRef->DoClose();
}
void SdExportTest::testTdf100926()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf100926_ODP.pptx"), PPTX);
xDocShRef = saveAndReload(xDocShRef.get(), ODP);
const SdrPage* pPage = GetPage(1, xDocShRef);
CPPUNIT_ASSERT(pPage != nullptr);
sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT(pTableObj != nullptr);
uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
sal_Int32 nRotation = 0;
uno::Reference< beans::XPropertySet > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("RotateAngle") >>= nRotation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation);
xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("RotateAngle") >>= nRotation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation);
xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("RotateAngle") >>= nRotation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation);
xDocShRef->DoClose();
}
void SdExportTest::testPageWithTransparentBackground()
{
::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/odp/page_transparent_background.odp"), ODP );
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
uno::Reference< drawing::XDrawPagesSupplier > xDoc(
xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "There should be exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount() );
uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) );
uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY );
uno::Any aAny = xPropSet->getPropertyValue( "Background" );
CPPUNIT_ASSERT_MESSAGE("Slide background is missing", aAny.hasValue());
uno::Reference< beans::XPropertySet > aXBackgroundPropSet;
aAny >>= aXBackgroundPropSet;
sal_Int32 nTransparence;
aAny = aXBackgroundPropSet->getPropertyValue( "FillTransparence" );
aAny >>= nTransparence;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide background transparency is wrong", sal_Int32(42), nTransparence);
xDocShRef->DoClose();
}
void SdExportTest::testTextRotation()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/shape-text-rotate.pptx"), PPTX);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
uno::Reference<drawing::XDrawPage> xPage(getPage(0, xDocShRef));
uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage));
CPPUNIT_ASSERT(xPropSet.is());
auto aGeomPropSeq = xPropSet->getPropertyValue("CustomShapeGeometry").get<uno::Sequence<beans::PropertyValue>>();
comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq);
auto it = aCustomShapeGeometry.find("TextRotateAngle");
CPPUNIT_ASSERT(it != aCustomShapeGeometry.end());
CPPUNIT_ASSERT_EQUAL(double(-90), aCustomShapeGeometry["TextRotateAngle"].get<double>());
xDocShRef->DoClose();
}
void SdExportTest::testTdf115394PPT()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/ppt/tdf115394.ppt"), PPT);
// Export the document and import again for a check
uno::Reference< lang::XComponent > xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[PPT].pFilterName), RTL_TEXTENCODING_UTF8);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xComponent.set(xStorable, uno::UNO_QUERY);
xComponent->dispose();
xDocShRef = loadURL(aTempFile.GetURL(), PPT);
double fTransitionDuration;
// Fast
SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
fTransitionDuration = pPage1->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
// Medium
SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
fTransitionDuration = pPage2->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
// Slow
SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
fTransitionDuration = pPage3->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
xDocShRef->DoClose();
}
void SdExportTest::testBulletsAsImage()
{
for (sal_Int32 nExportFormat : {ODP, PPTX, PPT})
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/BulletsAsImage.odp"), ODP);
const OString sFailedMessageBase = OStringLiteral("Failed on filter '") + aFileFormats[nExportFormat].pFilterName + "': ";
uno::Reference< lang::XComponent > xComponent = xDocShRef->GetModel();
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[nExportFormat].pFilterName), RTL_TEXTENCODING_UTF8);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
xComponent.set(xStorable, uno::UNO_QUERY);
xComponent->dispose();
xDocShRef = loadURL(aTempFile.GetURL(), nExportFormat);
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"), uno::UNO_QUERY_THROW);
uno::Sequence<beans::PropertyValue> aProperties;
xLevels->getByIndex(0) >>= aProperties; // 1st level
uno::Reference<awt::XBitmap> xBitmap;
awt::Size aSize;
sal_Int16 nNumberingType = -1;
for (beans::PropertyValue const & rProperty : std::as_const(aProperties))
{
if (rProperty.Name == "NumberingType")
{
nNumberingType = rProperty.Value.get<sal_Int16>();
}
else if (rProperty.Name == "GraphicBitmap")
{
xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
}
else if (rProperty.Name == "GraphicSize")
{
aSize = rProperty.Value.get<awt::Size>();
}
}
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), style::NumberingType::BITMAP, nNumberingType);
// Graphic Bitmap
const OString sFailed = sFailedMessageBase + "No bitmap for the bullets";
CPPUNIT_ASSERT_MESSAGE(sFailed.getStr(), xBitmap.is());
Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), GraphicType::Bitmap, aGraphic.GetType());
CPPUNIT_ASSERT_MESSAGE(sFailedMessageBase.getStr(), aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
if (nExportFormat == ODP || nExportFormat == PPT)
{
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), 16L, aGraphic.GetSizePixel().Width());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), 16L, aGraphic.GetSizePixel().Height());
}
else // FIXME: what happened here
{
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), 64L, aGraphic.GetSizePixel().Width());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), 64L, aGraphic.GetSizePixel().Height());
}
// Graphic Size
if (nExportFormat == ODP)
{
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), sal_Int32(500), aSize.Width);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), sal_Int32(500), aSize.Height);
}
else if (nExportFormat == PPT) // seems like a conversion error
{
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), sal_Int32(504), aSize.Width);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), sal_Int32(504), aSize.Height);
}
else // FIXME: totally wrong
{
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), sal_Int32(790), aSize.Width);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessageBase.getStr(), sal_Int32(790), aSize.Height);
}
xDocShRef->DoClose();
}
}
void SdExportTest::testTdf113822()
{
utl::TempFile tempFile;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf113822underline.pptx"), PPTX);
// Was unable to export iterate container (tdf#99213).
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
// Was unable to import iterate container (tdf#113822).
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
// IterateContainer was created as ParallelTimeContainer before, so
// the iterate type is not set too.
assertXPath(pXmlDoc, "//anim:iterate", "iterate-type", "by-letter");
// The target of the child animation nodes need to be in the iterate container.
assertXPath(pXmlDoc, "//anim:iterate", "targetElement", "id1");
assertXPath(pXmlDoc, "//anim:iterate/anim:set", "attributeName", "text-underline");
assertXPath(pXmlDoc, "//anim:iterate/anim:set", "to", "solid");
xDocShRef->DoClose();
}
void SdExportTest::testTdf113818()
{
utl::TempFile tempFile;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf113818-swivel.pptx"), PPTX);
xDocShRef = saveAndReload(xDocShRef.get(), PPT);
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
assertXPath(pXmlDoc, "//anim:animate[1]", "formula", "width*sin(2.5*pi*$)");
assertXPath(pXmlDoc, "//anim:animate[1]", "values", "0;1");
xDocShRef->DoClose();
}
void SdExportTest::testTdf119629()
{
utl::TempFile tempFile;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/ppt/tdf119629.ppt"), PPT);
xDocShRef = saveAndReload(xDocShRef.get(), PPT);
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
// MSO's effect node type Click parallel node, with group node, after group node
// were missing.
assertXPath(pXmlDoc, "//draw:page"
"/anim:par[@presentation:node-type='timing-root']"
"/anim:seq[@presentation:node-type='main-sequence']"
"/anim:par[@presentation:node-type='on-click']"
"/anim:par[@presentation:node-type='with-previous']"
"/anim:par[@presentation:node-type='on-click']"
"/anim:animate[@anim:formula='width*sin(2.5*pi*$)']", 1);
xDocShRef->DoClose();
}
void SdExportTest::testTdf123557()
{
utl::TempFile tempFile;
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/trigger.pptx"), PPTX);
xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
// Contains 2 interactive sequences and 3 triggered effects.
assertXPath(pXmlDoc, "//draw:page", 1);
assertXPath(pXmlDoc, "//draw:page/anim:par", 1);
assertXPath(pXmlDoc, "//draw:page"
"/anim:par[@presentation:node-type='timing-root']"
"/anim:seq[@presentation:node-type='interactive-sequence']", 2);
assertXPath(pXmlDoc, "//draw:page"
"/anim:par[@presentation:node-type='timing-root']"
"/anim:seq[@presentation:node-type='interactive-sequence']"
"/anim:par[@smil:begin]",3);
xDocShRef->DoClose();
}
void SdExportTest::testTdf126761()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf126761.ppt"), PPT);
xDocShRef = saveAndReload( xDocShRef.get(), ODP );
uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
// Get first paragraph of the text
uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
// Get first run of the paragraph
uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
// Check character underline, to make sure it has been set correctly
sal_uInt32 nCharUnderline;
xPropSet->getPropertyValue( "CharUnderline" ) >>= nCharUnderline;
CPPUNIT_ASSERT_EQUAL( sal_uInt32(1), nCharUnderline );
xDocShRef->DoClose();
}
void SdExportTest::testGlow()
{
auto xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odg/glow.odg"), ODG);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), ODG, &tempFile);
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
// Check glow properties
sal_Int32 nGlowEffectRad = 0;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectRadius") >>= nGlowEffectRad);
CPPUNIT_ASSERT_EQUAL(sal_Int32(529), nGlowEffectRad); // 15 pt = 529.166... mm/100
sal_Int32 nGlowEffectColor = 0;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectColor") >>= nGlowEffectColor);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF4000), nGlowEffectColor); // "Brick"
sal_Int16 nGlowEffectTransparency = 0;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectTransparency") >>= nGlowEffectTransparency);
CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nGlowEffectTransparency); // 60%
// Test ODF element
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
// check that we actually test graphic style
assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]",
"family", "graphic");
// check loext graphic attributes
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow-radius", "0.529cm");
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow-color", "#ff4000");
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow-transparency", "60%");
xDocShRef->DoClose();
}
void SdExportTest::testSoftEdges()
{
auto xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odg/softedges.odg"), ODG);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), ODG, &tempFile);
auto xShapeProps(getShapeFromPage(0, 0, xDocShRef));
// Check property
sal_Int32 nRad = 0;
CPPUNIT_ASSERT(xShapeProps->getPropertyValue("SoftEdgeRadius") >>= nRad);
CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nRad); // 18 pt
// Test ODF element
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
// check that we actually test graphic style
assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]",
"family", "graphic");
// check loext graphic attribute
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"softedge-radius", "0.635cm");
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|