diff options
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 38 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx | bin | 0 -> 12637 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 13 |
3 files changed, 38 insertions, 13 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx index 63bdb07e82a7..40bc31c498ed 100644 --- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx +++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx @@ -17,6 +17,7 @@ #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> @@ -240,16 +241,37 @@ CPPUNIT_TEST_FIXTURE(Test, testTextboxTextline) 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 nActual{}; - CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientRelation") >>= nActual); + 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); + 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: 0 (text::RelOrientation::FRAME) - // - Actual : 9 (text::RelOrientation::TEXT_LINE) - // i.e. the relation had a value which doesn't make sense for to-para anchoring (only for - // to-char anchoring). - sal_Int16 nExpected = text::RelOrientation::FRAME; - CPPUNIT_ASSERT_EQUAL(nExpected, nActual); + // - 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); } } diff --git a/writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx Binary files differnew file mode 100644 index 000000000000..dbd750092811 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline-top.docx diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 66f36e38959d..bb86c1e7a7a1 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1003,16 +1003,19 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) if (m_pImpl->bLayoutInCell && bTextBox) m_pImpl->bLayoutInCell = !m_pImpl->bCompatForcedLayoutInCell; - if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE && !bTextBox) + if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE) eAnchorType = text::TextContentAnchorType_AT_CHARACTER; xShapeProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType)); - if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE && bTextBox) + if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE) { - // TEXT_LINE to specific to to-char anchoring, we have to-para, so reset - // to default. - m_pImpl->nVertRelation = text::RelOrientation::FRAME; + // Word's "line" is "below the bottom of the line", our TEXT_LINE is + // "towards top, from the bottom of the line", so invert the vertical + // position. + awt::Point aPoint = xShape->getPosition(); + aPoint.Y *= -1; + xShape->setPosition(aPoint); } if (m_pImpl->bLayoutInCell && bTextBox && m_pImpl->rDomainMapper.IsInTable() |