1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/bootstrapfixture.hxx>
11 #include <unotest/macros_test.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
15 #include <com/sun/star/frame/Desktop.hpp>
16 #include <com/sun/star/frame/XStorable.hpp>
18 #include <unotools/mediadescriptor.hxx>
19 #include <unotools/tempfile.hxx>
21 using namespace ::com::sun::star
;
23 char const DATA_DIRECTORY
[] = "/xmloff/qa/unit/data/";
25 /// Covers xmloff/source/draw/ fixes.
26 class XmloffDrawTest
: public test::BootstrapFixture
, public unotest::MacrosTest
29 uno::Reference
<lang::XComponent
> mxComponent
;
32 void setUp() override
;
33 void tearDown() override
;
34 uno::Reference
<lang::XComponent
>& getComponent() { return mxComponent
; }
37 void XmloffDrawTest::setUp()
39 test::BootstrapFixture::setUp();
41 mxDesktop
.set(frame::Desktop::create(mxComponentContext
));
44 void XmloffDrawTest::tearDown()
47 mxComponent
->dispose();
49 test::BootstrapFixture::tearDown();
52 CPPUNIT_TEST_FIXTURE(XmloffDrawTest
, testTextBoxLoss
)
54 // Load a document that has a shape with a textbox in it. Save it to ODF and reload.
55 OUString aURL
= m_directories
.getURLFromSrc(DATA_DIRECTORY
) + "textbox-loss.docx";
56 getComponent() = loadFromDesktop(aURL
);
57 uno::Reference
<frame::XStorable
> xStorable(getComponent(), uno::UNO_QUERY
);
58 utl::TempFile aTempFile
;
59 aTempFile
.EnableKillingFile();
60 utl::MediaDescriptor aMediaDescriptor
;
61 aMediaDescriptor
["FilterName"] <<= OUString("writer8");
62 xStorable
->storeToURL(aTempFile
.GetURL(), aMediaDescriptor
.getAsConstPropertyValueList());
63 getComponent()->dispose();
64 getComponent() = loadFromDesktop(aTempFile
.GetURL());
66 // Make sure that the shape is still a textbox.
67 uno::Reference
<drawing::XDrawPageSupplier
> xDrawPageSupplier(getComponent(), uno::UNO_QUERY
);
68 uno::Reference
<drawing::XDrawPage
> xDrawPage
= xDrawPageSupplier
->getDrawPage();
69 uno::Reference
<beans::XPropertySet
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
70 bool bTextBox
= false;
71 xShape
->getPropertyValue("TextBox") >>= bTextBox
;
73 // Without the accompanying fix in place, this test would have failed, as the shape only had
74 // editeng text, losing the image part of the shape text.
75 CPPUNIT_ASSERT(bTextBox
);
78 CPPUNIT_PLUGIN_IMPLEMENT();
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */