sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 3 ++- sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 12 +++++------- writerfilter/source/dmapper/GraphicImport.cxx | 7 ++----- 3 files changed, 9 insertions(+), 13 deletions(-)
New commits: commit 7246e57216bb20c15af0ecf6a0183f5ffa81e780 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Sep 20 19:56:37 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Sep 21 08:18:40 2021 +0200 tdf#143591 DOCX import: handle anchored objects as at-char This partially reverts cc8f8ae55f681755f5da3bf64e4c30bb713f0383 (DOCX drawingML shape import: wp:anchor's behindDoc attribute, 2013-11-19), it seems to be more important to be consistent with the DOC import than with the VML import which is no longer used for DOCX shapes crated with Word >= 2010. Change-Id: I631da010bce1b4d3c392645e0ae3797a03665a42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122367 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index ce706929cf04..4afa90c3351e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -147,7 +147,8 @@ DECLARE_OOXMLEXPORT_TEST(testWpsOnly, "wps-only.docx") // Document has wp:anchor, not wp:inline, so handle it accordingly. uno::Reference<drawing::XShape> xShape = getShape(1); text::TextContentAnchorType eValue = getProperty<text::TextContentAnchorType>(xShape, "AnchorType"); - CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_PARAGRAPH, eValue); + // Word only as as-char and at-char, so at-char is our only choice. + CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eValue); // Check position, it was 0. This is a shape, so use getPosition(), not a property. CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(671830), xShape->getPosition().X); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 1890f2819d37..1b6b03225d4c 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -563,15 +563,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTextCopy) uno::Reference<beans::XPropertySet> xPageStyle( getStyles("PageStyles")->getByName(aPageStyleName), uno::UNO_QUERY); auto xHeaderText = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"); - uno::Reference<container::XContentEnumerationAccess> xHeaderPara( - getParagraphOfText(1, xHeaderText), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xHeaderShapes - = xHeaderPara->createContentEnumeration("com.sun.star.text.TextContent"); + uno::Reference<text::XTextRange> xHeaderPara = getParagraphOfText(1, xHeaderText); + auto aTextPortionType = getProperty<OUString>(getRun(xHeaderPara, 1), "TextPortionType"); // Without the accompanying fix in place, this test would have failed with: - // assertion failed - // - Expression: xHeaderShapes->hasMoreElements() + // - Expected: Frame + // - Actual : Text // i.e. the second page's header had no anchored shapes. - CPPUNIT_ASSERT(xHeaderShapes->hasMoreElements()); + CPPUNIT_ASSERT_EQUAL(OUString("Frame"), aTextPortionType); } CPPUNIT_TEST_FIXTURE(Test, testTdf112443) diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 3fc0b044a392..e0a2828b5606 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1227,8 +1227,8 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) // But they aren't Writer pictures, either (which are already handled above). uno::Reference< beans::XPropertySet > xShapeProps(m_xShape, uno::UNO_QUERY_THROW); - // This needs to be AT_PARAGRAPH by default and not AT_CHARACTER, otherwise shape will move when the user inserts a new paragraph. - text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH; + // Anchored: Word only supports at-char in that case. + text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_CHARACTER; if (m_pImpl->bHidden) { @@ -1248,9 +1248,6 @@ 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) - eAnchorType = text::TextContentAnchorType_AT_CHARACTER; - xShapeProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType)); if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE)