[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 10 05:40:47 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf135943_shapeWithText_LayoutInCell0_compat15.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx                                        |   23 ++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx                                     |   17 ++++++-
 3 files changed, 38 insertions(+), 2 deletions(-)

New commits:
commit d865ae748ae3b1d054051b89938eaef30680e06c
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Tue Sep 8 16:49:09 2020 +0300
Commit:     Justin Luth <justin_luth at sil.org>
CommitDate: Thu Sep 10 07:40:04 2020 +0200

    tdf#135943 writerfilter: ignore compat LayoutInCell for txbx
    
    ... until such a time when the underlying problem of
    textbox position not syncing with the moved frame is fixed.
    
    Bug 77794 moved the frame to the correct position,
    but the text only followed when going to the frame property,
    looking at the values, and pressing OK.
    
    So, it seems like the layout is re-positioning the frame,
    but that frame change is not being synchronized back
    to the paired up textbox.
    
    Since I couldn't figure out how to resolve that,
    I'm just temporarily avoiding the problem
    that my 7.1 change for tdf#77794 has exposed.
    That means that the textbox/frame is in the wrong position
    (same as in previous LO versions), but at least the
    text is inside of the frame.
    
    Change-Id: I7dc712c613b164317bc4adf19ac231488d610c95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102258
    Tested-by: Justin Luth <justin_luth at sil.org>
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf135943_shapeWithText_LayoutInCell0_compat15.docx b/sw/qa/extras/ooxmlexport/data/tdf135943_shapeWithText_LayoutInCell0_compat15.docx
new file mode 100644
index 000000000000..b4bbcb94e82c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135943_shapeWithText_LayoutInCell0_compat15.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 834c59c785c2..fcbda86665cd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -111,6 +111,29 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135595_HFtableWrap, "tdf135595_HFtableWrap.odt")
     CPPUNIT_ASSERT_MESSAGE("Image must be contained inside the table cell", nRowHeight > 2000);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf135943_shapeWithText_L0c15,
+                         "tdf135943_shapeWithText_LayoutInCell0_compat15.docx")
+{
+    // With compat15, layoutinCell ought to be ignored/forced to true.
+    // HOWEVER, currently only the shape is correctly placed, while its text is un-synced separately.
+    // So to prevent this ugly mess, just leave everything together in the historical (wrong) spot.
+    xmlDocUniquePtr pDump = parseLayoutDump();
+    sal_Int32 nFrameLeft = getXPath(pDump, "//anchored/SwAnchoredDrawObject/bounds", "left").toInt32();
+    sal_Int32 nFrameRight = getXPath(pDump, "//anchored/SwAnchoredDrawObject/bounds", "right").toInt32();
+    sal_Int32 nTextLeft = getXPath(pDump, "//anchored/fly/infos/bounds", "left").toInt32();
+    sal_Int32 nTextRight = getXPath(pDump, "//anchored/fly/infos/bounds", "right").toInt32();
+    // The text must be inside of its frame boundaries
+    CPPUNIT_ASSERT(nFrameRight >= nTextRight);
+    CPPUNIT_ASSERT(nFrameLeft <= nTextLeft);
+    // LayoutInCell: The text must fit inside cell A1 //cell[1]/info/bounds/right = 4703
+    //CPPUNIT_ASSERT(nTextRight < 4704);
+
+    uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), uno::UNO_QUERY);
+    bool bValue;
+    xShapeProperties->getPropertyValue("IsFollowingTextFlow") >>= bValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("YOU FIXED ME? LayoutInCell ought to be true", false, bValue);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf135595_HFtableWrap_c12, "tdf135595_HFtableWrap_c12.docx")
 {
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index dde3e1adb3b7..9853bb48bb1e 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -206,6 +206,7 @@ public:
     sal_Int16 nVertRelation;
     text::WrapTextMode nWrap;
     bool      bLayoutInCell;
+    bool      bCompatForcedLayoutInCell;
     bool bAllowOverlap = true;
     bool      bOpaque;
     bool      bBehindDoc;
@@ -273,6 +274,7 @@ public:
         ,nVertRelation( text::RelOrientation::FRAME )
         ,nWrap(text::WrapTextMode_NONE)
         ,bLayoutInCell(true)
+        ,bCompatForcedLayoutInCell(false)
         ,bOpaque( !rDMapper.IsInHeaderFooter() )
         ,bBehindDoc(false)
         ,bContour(false)
@@ -626,8 +628,10 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
         break;
         case NS_ooxml::LN_CT_Anchor_layoutInCell: // 90991; - ignored
             // Starting in MSO 2013, anchors are ALWAYS considered to be laid out in table cell.
-            m_pImpl->bLayoutInCell = nIntValue != 0 ||
-                (m_pImpl->rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() > 14 && m_pImpl->rDomainMapper.IsInTable());
+            m_pImpl->bCompatForcedLayoutInCell = !nIntValue
+                && m_pImpl->rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() > 14
+                && m_pImpl->rDomainMapper.IsInTable();
+            m_pImpl->bLayoutInCell = m_pImpl->bCompatForcedLayoutInCell || nIntValue;
         break;
         case NS_ooxml::LN_CT_Anchor_hidden: // 90992; - ignored
         break;
@@ -855,6 +859,15 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                         // Avoid setting AnchorType for TextBoxes till SwTextBoxHelper::syncProperty() doesn't handle transition.
                         bool bTextBox = false;
                         xShapeProps->getPropertyValue("TextBox") >>= bTextBox;
+
+                        // The positioning change caused by LayoutInCell doesn't sync well
+                        // in the text / frame duo. So the compatibility fix only correctly
+                        // positions the frame and not the text currently.
+                        // tdf#135943: Instead of half-fixing and making a complete mess,
+                        // just avoid until layout's repositioning is sync'd to the text frame.
+                        if (m_pImpl->bLayoutInCell && bTextBox)
+                            m_pImpl->bLayoutInCell = !m_pImpl->bCompatForcedLayoutInCell;
+
                         if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE && !bTextBox)
                             eAnchorType = text::TextContentAnchorType_AT_CHARACTER;
 


More information about the Libreoffice-commits mailing list