/* -*- 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 "sdmodeltestbase.hxx" #include #include #include #include using namespace ::com::sun::star; class SdImportTestSmartArt : public SdModelTestBase { public: void testBase(); void testChildren(); void testText(); void testCnt(); void testDir(); void testMaxDepth(); void testRotation(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); CPPUNIT_TEST(testBase); CPPUNIT_TEST(testChildren); CPPUNIT_TEST(testText); CPPUNIT_TEST(testCnt); CPPUNIT_TEST(testDir); CPPUNIT_TEST(testMaxDepth); CPPUNIT_TEST(testRotation); CPPUNIT_TEST_SUITE_END(); }; void SdImportTestSmartArt::testBase() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart1.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xShapeGroup->getCount()); uno::Reference xText0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString()); uno::Reference xText1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString()); uno::Reference xText2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString()); uno::Reference xText3(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3->getString()); uno::Reference xText4(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4->getString()); uno::Reference xShape(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); sal_Int32 nFillColor = 0; xShape->getPropertyValue("FillColor") >>= nFillColor; CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4F81BD), nFillColor); sal_Int16 nParaAdjust = 0; uno::Reference xParagraph(getParagraphFromShape(0, xShape)); uno::Reference xPropSet(xParagraph, uno::UNO_QUERY_THROW); xPropSet->getPropertyValue("ParaAdjust") >>= nParaAdjust; CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast(nParaAdjust)); xDocShRef->DoClose(); } void SdImportTestSmartArt::testChildren() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-children.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup->getCount()); uno::Reference xShapeGroup0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup0->getCount()); uno::Reference xTextA(xShapeGroup0->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA->getString()); uno::Reference xChildren0(xShapeGroup0->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren0->getCount()); uno::Reference xChildB(xChildren0->getByIndex(0), uno::UNO_QUERY_THROW); uno::Reference xTextB(xChildB->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("b"), xTextB->getString()); uno::Reference xChildC(xChildren0->getByIndex(1), uno::UNO_QUERY_THROW); uno::Reference xTextC(xChildC->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("c"), xTextC->getString()); uno::Reference xShapeGroup1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup1->getCount()); uno::Reference xTextX(xShapeGroup1->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("x"), xTextX->getString()); uno::Reference xChildren1(xShapeGroup1->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren1->getCount()); uno::Reference xChildY(xChildren1->getByIndex(0), uno::UNO_QUERY_THROW); uno::Reference xTextY(xChildY->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("y"), xTextY->getString()); uno::Reference xChildZ(xChildren1->getByIndex(1), uno::UNO_QUERY_THROW); uno::Reference xTextZ(xChildZ->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("z"), xTextZ->getString()); xDocShRef->DoClose(); } void SdImportTestSmartArt::testText() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-text.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); uno::Reference xShapeGroup2(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); uno::Reference xText0(xShapeGroup2->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xText0->getString().isEmpty()); uno::Reference xText1(xShapeGroup2->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("test"), xText1->getString()); xDocShRef->DoClose(); } void SdImportTestSmartArt::testCnt() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-cnt.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); sal_Int32 nCount = xShapeGroup->getCount(); sal_Int32 nCorrect = 0; for (sal_Int32 i=0; i xText(xShapeGroup->getByIndex(i), uno::UNO_QUERY); if (xText.is() && !xText->getString().isEmpty()) nCorrect++; } CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nCorrect); xDocShRef->DoClose(); } void SdImportTestSmartArt::testDir() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-dir.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup->getCount()); uno::Reference xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); uno::Reference xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xShape0->getPosition().X > xShape1->getPosition().X); xDocShRef->DoClose(); } void SdImportTestSmartArt::testMaxDepth() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-maxdepth.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup->getCount()); uno::Reference xText0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("first"), xText0->getString()); uno::Reference xText1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(OUString("second"), xText1->getString()); xDocShRef->DoClose(); } void SdImportTestSmartArt::testRotation() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation.pptx"), PPTX); uno::Reference xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); uno::Reference xShape0(xShapeGroup->getByIndex(0), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape0->getPropertyValue("RotateAngle").get()); uno::Reference xShape1(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(24000), xShape1->getPropertyValue("RotateAngle").get()); uno::Reference xShape2(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(sal_Int32(12000), xShape2->getPropertyValue("RotateAngle").get()); xDocShRef->DoClose(); } CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */