summaryrefslogtreecommitdiff
path: root/writerfilter/qa/cppunittests/dmapper
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/qa/cppunittests/dmapper')
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx23
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx110
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/create-date-preserve.docxbin0 -> 13310 bytes
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/tdf141540ChildRotation.docxbin0 -> 15385 bytes
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupLinePosSize.docxbin0 -> 19457 bytes
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupRotation.docxbin0 -> 18803 bytes
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docxbin0 -> 12637 bytes
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docxbin0 -> 12934 bytes
8 files changed, 133 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
index 77bd616f37d6..da7501e2ef2e 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
@@ -19,6 +19,8 @@
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <com/sun/star/text/XTextTable.hpp>
+#include <vcl/scheduler.hxx>
+
using namespace ::com::sun::star;
namespace
@@ -189,6 +191,27 @@ CPPUNIT_TEST_FIXTURE(Test, testFieldIfInsideIf)
// i.e. some of the inner fields escaped outside the outer field.
CPPUNIT_ASSERT_EQUAL(OUString("25"), xCell->getString());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testCreateDatePreserve)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "create-date-preserve.docx";
+ getComponent() = loadFromDesktop(aURL);
+ // Trigger idle layout.
+ Scheduler::ProcessEventsToIdle();
+ uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
+ uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<container::XEnumerationAccess> xPortionEnumAccess(xParaEnum->nextElement(),
+ uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xPortionEnum = xPortionEnumAccess->createEnumeration();
+ uno::Reference<text::XTextRange> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 7/7/2020 10:11:00 AM
+ // - Actual : 07/07/2020
+ // i.e. the formatting of the create date field was lost.
+ CPPUNIT_ASSERT_EQUAL(OUString("7/7/2020 10:11:00 AM"), xPortion->getString());
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index 28a0cc178410..0d0cd12c8c1c 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -10,11 +10,14 @@
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
@@ -52,6 +55,69 @@ void Test::tearDown()
char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/";
+CPPUNIT_TEST_FIXTURE(Test, testTdf141540ChildRotation)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141540ChildRotation.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<container::XIndexAccess> xGroup(xDrawPage->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xRotatedShape(xGroup->getByIndex(1), uno::UNO_QUERY);
+ sal_Int32 nShearAngle = 9000; // initialize with invalid value
+ xRotatedShape->getPropertyValue("ShearAngle") >>= nShearAngle;
+ // Without fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : 2494
+ // i.e. the rotated rectangle in the group was sheared, although the group itself is not rotated
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), nShearAngle);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf141540GroupRotation)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141540GroupRotation.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ sal_Int32 nShearAngle = 9000; // init with invalid value
+ xShape->getPropertyValue("ShearAngle") >>= nShearAngle;
+ // Without fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : -3190
+ // i.e. the group has got a shearing although MSO does not know shearing at all.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), nShearAngle);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf141540GroupLinePosSize)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141540GroupLinePosSize.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+
+ // Test line
+ uno::Reference<drawing::XShape> xLineShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ awt::Point aPosition = xLineShape->getPosition();
+ awt::Size aSize = xLineShape->getSize();
+ // Without fix in place, you had got Position = (19|6498), Size = 5001 x 2
+ // i.e. the line was nearly horizontal instead of vertical
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5022), aPosition.X);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2963), aPosition.Y);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aSize.Width);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7073), aSize.Height);
+
+ // Test group
+ uno::Reference<drawing::XShape> xGroupShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ aPosition = xGroupShape->getPosition();
+ aSize = xGroupShape->getSize();
+ // Without fix in place, you had got Position = (11511|3480), Size = 4022 x 4022
+ // i.e. the group was erroneously downscaled to unrotated size
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10679), aPosition.X);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2648), aPosition.Y);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5687), aSize.Width);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5687), aSize.Height);
+}
+
CPPUNIT_TEST_FIXTURE(Test, testGroupShapeRotation)
{
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "group-shape-rotation.docx";
@@ -165,6 +231,50 @@ CPPUNIT_TEST_FIXTURE(Test, testWrapPolyCrop)
// were wrapping around the image, not only 2 as Word does it.
CPPUNIT_ASSERT_EQUAL(2368., aPolygon.getB2DPoint(0).getY());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testTextboxTextline)
+{
+ // Load a document with a shape with a textbox.
+ // The shape's vertical relation is <wp:positionV relativeFrom="line">.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-textline.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ sal_Int16 nActualRelation{};
+ CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientRelation") >>= nActualRelation);
+ sal_Int32 nActualPosition{};
+ CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientPosition") >>= nActualPosition);
+
+ sal_Int16 nExpectedRelation = text::RelOrientation::TEXT_LINE;
+ CPPUNIT_ASSERT_EQUAL(nExpectedRelation, nActualRelation);
+ // 0 on this branch, but sw/qa/extras/ooxmlexport/data/tdf97371.docx shows that negative values
+ // work fine in general, don't bother:
+ // sal_Int32 nExpectedPosition = -2;
+ // CPPUNIT_ASSERT_EQUAL(nExpectedPosition, nActualPosition);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTextboxTextlineTop)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-textline-top.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ sal_Int16 nActualRelation{};
+ CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientRelation") >>= nActualRelation);
+ sal_Int16 nExpectedRelation = text::RelOrientation::TEXT_LINE;
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 9 (TEXT_LINE)
+ // - Actual : 0 (FRAME)
+ // i.e. the anchor point for the positioning was wrong, resulting in overlapping textboxes.
+ CPPUNIT_ASSERT_EQUAL(nExpectedRelation, nActualRelation);
+
+ sal_Int16 nActualOrient{};
+ CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrient") >>= nActualOrient);
+ sal_Int16 nExpectedOrient = text::VertOrientation::BOTTOM;
+ CPPUNIT_ASSERT_EQUAL(nExpectedOrient, nActualOrient);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/create-date-preserve.docx b/writerfilter/qa/cppunittests/dmapper/data/create-date-preserve.docx
new file mode 100644
index 000000000000..4a587ce0d2ef
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/create-date-preserve.docx
Binary files differ
diff --git a/writerfilter/qa/cppunittests/dmapper/data/tdf141540ChildRotation.docx b/writerfilter/qa/cppunittests/dmapper/data/tdf141540ChildRotation.docx
new file mode 100644
index 000000000000..902bb6192afe
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/tdf141540ChildRotation.docx
Binary files differ
diff --git a/writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupLinePosSize.docx b/writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupLinePosSize.docx
new file mode 100644
index 000000000000..d0ceff118eab
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupLinePosSize.docx
Binary files differ
diff --git a/writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupRotation.docx b/writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupRotation.docx
new file mode 100644
index 000000000000..13e65c1d122a
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/tdf141540GroupRotation.docx
Binary files differ
diff --git a/writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx
new file mode 100644
index 000000000000..dbd750092811
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx
Binary files differ
diff --git a/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx
new file mode 100644
index 000000000000..493604d778e9
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx
Binary files differ