diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx index d77d00c682fd..c1e5cb6faad6 100644 --- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx +++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx @@ -165,6 +165,27 @@ 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 . + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-textline.docx"; + getComponent() = loadFromDesktop(aURL); + uno::Reference xDrawPageSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + sal_Int16 nActual{}; + CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientRelation") >>= nActual); + + // 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); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx differ diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 02c348a05693..cc81850bfc86 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -872,6 +872,14 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) eAnchorType = text::TextContentAnchorType_AT_CHARACTER; xShapeProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType)); + + if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE && bTextBox) + { + // TEXT_LINE to specific to to-char anchoring, we have to-para, so reset + // to default. + m_pImpl->nVertRelation = text::RelOrientation::FRAME; + } + if (m_pImpl->bLayoutInCell && bTextBox && m_pImpl->rDomainMapper.IsInTable() && m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME) m_pImpl->nHoriRelation = text::RelOrientation::FRAME;