tdf#121741 sd: not modified when leaving an empty placeholder

When you ENTER a placeholder, it removes the placeholder text.
In that case it doesn't treat this as a change
(because SdrObject::SetOutlinerParaObject is never called).

However, when you LEAVE the placeholder,
it puts the placeholder text back in.
This was being treated as a modification event (x2).

I tested what happens if you delete text
and then leave the placeholder.
The deleted text is already handled before we can leave the placeholder,
so that doesn't cause any concern.

TODO: an undo event is also created.

Change-Id: I366eb7a174284dc07415342258fcf65e50641be6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174860
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
This commit is contained in:
Justin Luth
2024-10-16 00:42:33 +02:00
committed by Justin Luth
parent 21b5bb33f7
commit bd6349d3fe
2 changed files with 11 additions and 0 deletions
+2
View File
@@ -2875,6 +2875,8 @@ bool SdPage::RestoreDefaultText( SdrObject* pObj )
ePresObjKind == PresObjKind::Notes ||
ePresObjKind == PresObjKind::Text)
{
sd::ModifyGuard aGuard(static_cast<SdDrawDocument*>(&getSdrModelFromSdrPage()));
OUString aString( GetPresObjText(ePresObjKind) );
if (!aString.isEmpty())
+9
View File
@@ -783,11 +783,20 @@ SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally)
SdrTextObj* xObj = GetTextEditObject();
bool bDefaultTextRestored = RestoreDefaultText( xObj );
const bool bSaveSetModifiedEnabled = mpDocSh && mpDocSh->IsEnableSetModified();
if (bDefaultTextRestored)
{
if (bSaveSetModifiedEnabled)
mpDocSh->EnableSetModified(false);
}
SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
if( bDefaultTextRestored )
{
if (bSaveSetModifiedEnabled)
mpDocSh->EnableSetModified();
if( xObj && !xObj->IsEmptyPresObj() )
{
xObj->SetEmptyPresObj( true );