/* -*- 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 #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star; namespace { char const DATA_DIRECTORY[] = "/svx/qa/unit/data/"; /// Tests for svx/source/unodraw/ code. class UnodrawTest : public test::BootstrapFixture, public unotest::MacrosTest { protected: uno::Reference mxComponentContext; uno::Reference mxComponent; public: void setUp() override; void tearDown() override; }; void UnodrawTest::setUp() { test::BootstrapFixture::setUp(); mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); mxDesktop.set(frame::Desktop::create(mxComponentContext)); } void UnodrawTest::tearDown() { if (mxComponent.is()) mxComponent->dispose(); test::BootstrapFixture::tearDown(); } CPPUNIT_TEST_FIXTURE(UnodrawTest, testWriterGraphicExport) { // Load a document with a Writer picture in it. OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "unodraw-writer-image.odt"; mxComponent = loadFromDesktop(aURL); uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDrawPage = xDrawPageSupplier->getDrawPage(); uno::Reference xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); // Export it as JPEG. uno::Reference xExportFilter = drawing::GraphicExportFilter::create(mxComponentContext); // This resulted in a css::lang::IllegalArgumentException for a Writer // picture. xExportFilter->setSourceDocument(xShape); utl::TempFile aTempFile; aTempFile.EnableKillingFile(); uno::Sequence aProperties( comphelper::InitPropertySequence({ { "URL", uno::Any(aTempFile.GetURL()) }, { "MediaType", uno::Any(OUString("image/jpeg")) } })); CPPUNIT_ASSERT(xExportFilter->filter(aProperties)); } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */