summaryrefslogtreecommitdiff
path: root/writerfilter/qa/cppunittests/rtftok
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/qa/cppunittests/rtftok')
-rw-r--r--writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf29
-rw-r--r--writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx71
2 files changed, 100 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf b/writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf
new file mode 100644
index 000000000000..ec0a07690bdf
--- /dev/null
+++ b/writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf
@@ -0,0 +1,29 @@
+{\rtf1
+\paperw10080\paperh12960\margl1066\margr1066\margt1642\margb1066
+\pard\plain
+{\shp
+{\*\shpinst\shpleft31\shptop105\shpright4108\shpbottom3887\shpfhdr0\shpwr2\shpwrk3\shpfblwtxt0
+{\sp
+{\sn shapeType}
+{\sv 202}
+}
+{\shptxt \pard\plain
+before
+{\*\shppict
+{\pict
+{\*\picprop\shplid1025
+{\sp
+{\sn shapeType}
+{\sv 75}
+}
+}
+\picscalex23\picscaley24\piccropl0\piccropr0\piccropt0\piccropb0\picw30372\pich22437\picwgoal17219\pichgoal12720\pngblip
+47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b
+}
+}
+after\par
+}
+}
+}
+\par
+}
diff --git a/writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx b/writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx
new file mode 100644
index 000000000000..64c679f6e5cc
--- /dev/null
+++ b/writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx
@@ -0,0 +1,71 @@
+/* -*- 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 <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Tests for writerfilter/source/rtftok/rtfsdrimport.cxx.
+class Test : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+ uno::Reference<lang::XComponent> mxComponent;
+
+public:
+ void setUp() override;
+ void tearDown() override;
+ uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+};
+
+void Test::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void Test::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/rtftok/data/";
+
+CPPUNIT_TEST_FIXTURE(Test, testPictureInTextframe)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "picture-in-textframe.rtf";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xTextDocument->getDrawPage();
+ uno::Reference<beans::XPropertySet> xInnerShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
+ xInnerShape->getPropertyValue("AnchorType") >>= eAnchorType;
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 4
+ // i.e. the properties of the inner shape (including its anchor type and bitmap fill) were lost
+ // on import.
+ CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eAnchorType);
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */