svx/source/unodraw/unoshtxt.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 7dfa3da02c32aacea2992aa3dfcf8cf3301cdd28
Author:     Hossein <[email protected]>
AuthorDate: Thu May 5 13:45:36 2022 +0200
Commit:     Aron Budea <[email protected]>
CommitDate: Tue Feb 14 08:01:19 2023 +0000

    tdf#148818 Fix missing text in boxes with empty first paragraph
    
    Text was lost from the text boxes with empty first paragraph. The
    problem was happening when there was 2 paragraphs in a text box, in
    which the first paragraph was completely empty. The regression was
    introduced in cf2449aac0141711a7610d67f7c50cd108e12443 because of the
    bad handling of the paragraphs, and only looking at the size of the
    text of the first paragraph.
    
    This is fixed by looking at mpOutliner->GetEditEngine().GetTextLen(i)
    for all i=1..k where k=min(2,mpOutliner->GetParagraphCount()).
    
    I have negated the condition to provide a better explanation of what
    the condition should be.
    
    Change-Id: Id5d8787df5111c734760afdd98a6fbe832047f32
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133527
    Tested-by: Jenkins
    Reviewed-by: Hossein <[email protected]>
    (cherry picked from commit 759792e40aceb17a621c37ed725d1e998acbd30d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146390
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Aron Budea <[email protected]>

diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 23c772daa1da..d4b6ddddb791 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -775,14 +775,15 @@ void SvxTextEditSourceImpl::UpdateData()
             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
             if( pTextObj )
             {
-                if( (mpOutliner->GetParagraphCount() != 1 && 
mpOutliner->GetParagraphCount() != 2)
-                    || mpOutliner->GetEditEngine().GetTextLen( 0 ) )
+                if( (mpOutliner->GetParagraphCount() == 1 && 
mpOutliner->GetEditEngine().GetTextLen( 0 ) == 0 )
+                        || (mpOutliner->GetParagraphCount() == 2 && 
mpOutliner->GetEditEngine().GetTextLen( 0 ) == 0
+                            && mpOutliner->GetEditEngine().GetTextLen( 1 ) == 
0) )
                 {
-                    pTextObj->NbcSetOutlinerParaObjectForText( 
mpOutliner->CreateParaObject(), mpText );
+                    pTextObj->NbcSetOutlinerParaObjectForText( std::nullopt, 
mpText );
                 }
                 else
                 {
-                    pTextObj->NbcSetOutlinerParaObjectForText( std::nullopt, 
mpText );
+                    pTextObj->NbcSetOutlinerParaObjectForText( 
mpOutliner->CreateParaObject(), mpText );
                 }
             }
 

Reply via email to