sw/source/core/unocore/unodraw.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit ebacfb1a63566077eb10cbe53dfac8fac9da898f
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 21 19:59:48 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 30 08:58:24 2024 +0100

    tdf#158451 sw: fix crash in text formatting of as-char group shape
    
    The problem is that during formatting of a SwTextFrame, SwTextFly
    contains a list of all anchored objects that could overlap, and then
    creating a portion for the as-char anchored group shape sets the anchor
    property and thereby unexpectedly deletes the child anchored object,
    while SwTextFly stores a pointer to it:
    
    4  SwFlyLayFrame::~SwFlyLayFrame()
    5  SwFrame::DestroyFrame()
    6  SwFrameFormat::DelFrames()
    7  SwDoc::SetFlyFrameAnchor()
    8  lcl_SetFlyFrameAttr()
    10 SwXFrame::setPropertyValue()
       (this=0x4042de0, rPropertyName="AnchorType", 
_rValue=uno::Any("com.sun.star.text.TextContentAnchorType": 
com::sun::star::text::TextContentAnchorType::TextContentAnchorType_AT_CHARACTER))
 at sw/source/core/unocore/unoframe.cxx:1941
    11 SwTextBoxHelper::changeAnchor()
    12 SwTextBoxHelper::synchronizeGroupTextBoxProperty()
    13 SwTextBoxHelper::synchronizeGroupTextBoxProperty()
    14 SwFlyCntPortion::SetBase()
    15 sw::DrawFlyCntPortion::Create()
    16 SwTextFormatter::NewFlyCntPortion()
    
    This is because after the import is complete, only the group shape has
    its anchor set, while the child shapes all have a default FLY_AT_PAGE
    anchor.
    
    There is already code in SwXShape::setPropertyValue() to propagate the
    new anchor to children, but it's limited to group shape with more than 1
    text frame; very unclear why this limit exists so just remove it.
    
    Change-Id: Ide0f9def36e3b4eff6140206e3dfa4ee2c65e3eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161137
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.hensc...@t-online.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 59ece793dbfc23dddccc56cfaff60d3558dc2b6b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161213
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit ce9a5a9abbfa998312c62c61b27992d01df214d2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162730
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 8f72cc2bee0a..9300765d22cf 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1408,12 +1408,12 @@ void SwXShape::setPropertyValue(const OUString& 
rPropertyName, const uno::Any& a
                     // If this property is an anchor change, and there is a 
group shape with textboxes
                     // do anchor sync in time unless the anchor sync in the 
porfly will cause crash during
                     // layout calculation (When importing an inline shape in 
docx via dmapper).
-                    if (pFormat->Which() == RES_DRAWFRMFMT && 
pFormat->GetOtherTextBoxFormats()
-                        && pFormat->GetOtherTextBoxFormats()->GetTextBoxCount()
-                               > o3tl::make_unsigned(1))
+                    if (pFormat->Which() == RES_DRAWFRMFMT && 
pFormat->GetOtherTextBoxFormats())
+                    {
                         SwTextBoxHelper::synchronizeGroupTextBoxProperty(
                             SwTextBoxHelper::changeAnchor, pFormat,
                             SdrObject::getSdrObjectFromXShape(mxShape));
+                    }
                 }
                 else
                     pFormat->SetFormatAttr(aSet);

Reply via email to