sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 3 ++- sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 8 ++++---- sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 12 +++++------- writerfilter/source/dmapper/GraphicImport.cxx | 7 ++----- 4 files changed, 13 insertions(+), 17 deletions(-)
New commits: commit 3973c5dc82b49b563c2534ca0cb3aa9a6a2c9d58 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Sep 20 19:56:37 2021 +0200 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Wed Jan 26 12:39:42 2022 +0100 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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128927 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 47307b49789e..6e789cabaa26 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -151,7 +151,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/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index cc63f77e5c56..08728107fc15 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -697,13 +697,13 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testSmartArtAnchoredInline, "fdo73227.docx") xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","id","1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","name","Diagram1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[1]/wp:anchor/wp:docPr","name","Picture 1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr","id","2"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr","id","3"); assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr","name","10-Point Star 3"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","id","3"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","name","Picture 1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","id","2"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing[2]/wp:anchor/wp:docPr","name","Diagram2"); } DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo65833, "fdo65833.docx") diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 43608c5bd136..9082916fcdb8 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -423,15 +423,13 @@ DECLARE_OOXMLIMPORT_TEST(testTextCopy, "text-copy.docx") 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); } DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx") diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 3d9c1c08448c..07669e8e66b5 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -986,8 +986,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) { @@ -1007,9 +1007,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)