svx/source/unodraw/unoshtxt.cxx | 8 +++----- xmloff/source/draw/ximpshap.cxx | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-)
New commits: commit 7134ea5137f13a72f1462898a3f47827259ddae1 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Feb 23 11:18:59 2022 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Mar 14 14:07:30 2022 +0100 tdf#72776 Allow text removal in the shapes Previous fix had crafted condition for fixing one specific case but it was braking other cases. (svx/source/unodraw/unoshtxt.cxx) For example it was not possible to remove text inside textbox and save that -> it was not saved in LOK case. Problem is that we had not saved text inside shape and due to calling GetBackgroundTextForwarder() we did reset to empty content. In this patch we force UpdateData() call by releasing lock just before we try to do some final text cursor operations what applies changes in the content and prevents us from losing it. Call which was invoking GetBackgroundTextForwarder() was: file: xmloff/source/draw/ximpshap.cxx method: SdXMLShapeContext::endFastElement line: mxCursor->gotoEnd( false ); After that I found that we had bug which breaks test: sd/qa/unit/import-tests.cxx odp/shapes-test.odp It occurs when using this patch or when not using my code but removing locking functionality for SvxTextEditSourceImpl. NbcSetOutlinerParaObjectForText triggers shape resizing even when no text is present inside. Summary: 1. revert hack from https://git.libreoffice.org/core/+/71b66b0039819f38c935b4eb5d5951ceaf6e8468%5E%21 2. trigger text update by releasing lock for a moment to keep correct state 3. fix bug with resizing empty shape Change-Id: Idf1fc6caf19dfb932ce7caa21034f76fa04ce5f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130415 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mert Tumer <mert.tu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131119 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 8ccf0e8e47b8..23c772daa1da 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -547,10 +547,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder() if( pOutlinerParaObject && ( bOwnParaObj || !mpObject->IsEmptyPresObj() || mpObject->getSdrPageFromSdrObject()->IsMasterPage() ) ) { - // tdf#72776: do not set empty text to SdrOutliner, if it is already set - if( !mpOutliner->GetEditEngine().GetTextLen() || pOutlinerParaObject->Count() > 1 || ( pOutlinerParaObject->Count() == 1 && - !pOutlinerParaObject->GetTextObject().GetText(0).isEmpty() ) ) - mpOutliner->SetText( *pOutlinerParaObject ); + mpOutliner->SetText( *pOutlinerParaObject ); // put text to object and set EmptyPresObj to FALSE if( mpText && bOwnParaObj && mpObject->IsEmptyPresObj() && pTextObj->IsReallyEdited() ) @@ -778,7 +775,8 @@ void SvxTextEditSourceImpl::UpdateData() SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject ); if( pTextObj ) { - if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) ) + if( (mpOutliner->GetParagraphCount() != 1 && mpOutliner->GetParagraphCount() != 2) + || mpOutliner->GetEditEngine().GetTextLen( 0 ) ) { pTextObj->NbcSetOutlinerParaObjectForText( mpOutliner->CreateParaObject(), mpText ); } diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index a19a6c19d936..76ca2c4fe4d9 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -326,6 +326,13 @@ void SdXMLShapeContext::endFastElement(sal_Int32 ) { if(mxCursor.is()) { + // tdf#72776 force UpdateData in the EditSource so we will not override text in SdrOutliner + if( mxLockable.is() ) + { + mxLockable->removeActionLock(); + mxLockable->addActionLock(); + } + // delete addition newline mxCursor->gotoEnd( false ); mxCursor->goLeft( 1, true );