writerfilter/source/rtftok/rtfdocumentimpl.cxx |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 442f8fa06e8988d79336923e976144b13ce2ccee
Author:     Miklos Vajna <[email protected]>
AuthorDate: Tue Jun 17 08:47:09 2025 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Jun 19 11:01:38 2025 +0200

    tdf#167044 sw RTF import: fix bad image size in shape text
    
    Regression from commit 57d9cc81b058757421cd082e5dbe32a919716807
    (tdf#127806: RTF import: use shape dimensions for pib picture,
    2022-09-01), open the bugdoc, the icon image inside the shape should be
    about 0.37cm x 0.37cm, is about 14.98 cm x 12.66 cm.
    
    What happens is that \pict was assumed to be inside the property value
    of a shape, in which case both the shape and the picture can have a
    size, and the old use-case requires to ignore the inner size. The new
    use-case is two user-visible shapes: an outer text frame and an inner
    small icon image, inside shape text. The different sizes are wanted in
    this case.
    
    Fix the problem by conditionally going back to the old behavior of not
    inheriting size for the inner shape. The name of the destination at the
    top of the parser stack is different for the "in property value" and the
    "in shape text" cases, so this keeps the old use-case working while
    restores the wanted small size for the new use-case.
    
    Here the difference between the old and new size was so large that the
    end-user saw this as "the image was not visible previously".
    
    [ No testcase on co-24.04; the test on co-25.04 uses sw/ internal APIs
    which are not available on this older branch. Tested manually instead. ]
    
    (cherry picked from commit 94418dd07322d94825bd86f9a496d28c43421317)
    
    Conflicts:
            sw/CppunitTest_sw_writerfilter_rtftok.mk
            
writerfilter/qa/cppunittests/rtftok/data/image-size-in-shape-text.rtf
            writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx
    
    Change-Id: Ife93089b967fc26b7180775db8fc507a896d160b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186702
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 91775484fe57..7871e7693bc5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -984,7 +984,14 @@ void RTFDocumentImpl::resolvePict(bool const bInline, 
uno::Reference<drawing::XS
     }
 
     uno::Reference<drawing::XShape> xShape(rShape);
-    if (m_aStates.top().getInShape() && xShape.is())
+
+    // \pict may be inside a shape property value, in which case the current 
destination is
+    // SHAPEINSTRUCTION. Or we may be inside shape text, when \pict is 
processed immediately.
+    bool bInShapeText = m_aStates.top().getDestination() == Destination::PICT;
+
+    // Only ignore the inner size for a shape property value, not for an 
inline shape inside shape
+    // text:
+    if (m_aStates.top().getInShape() && xShape.is() && !bInShapeText)
     {
         awt::Size aSize = xShape->getSize();
         if (aSize.Width || aSize.Height)

Reply via email to