[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 21 09:34:11 UTC 2021


 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 c0b951024c2ec815f1ef70d59d31860df2434d28
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Sep 20 19:56:37 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Sep 21 11:33:37 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 <vmiklos at collabora.com>
    (cherry picked from commit 7246e57216bb20c15af0ecf6a0183f5ffa81e780)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122287
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 15a44ccfdfed..959a792b48ce 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 d0f3833aea7e..e446bcd0910b 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -445,15 +445,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 bb86c1e7a7a1..cbff2ac32b7a 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -982,8 +982,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)
                         {
@@ -1003,9 +1003,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)


More information about the Libreoffice-commits mailing list