From 36f60428477be0e5acbfcc2051c6c6fd45c91bbb Mon Sep 17 00:00:00 2001 From: Andreas Heinisch Date: Wed, 13 May 2026 11:30:27 +0200 Subject: [PATCH] tdf#148629 - Disable demote command on non-list paragraphs Change-Id: I04fe77233539ecaa614eed3e28d4243e41392432 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205158 Tested-by: Jenkins Reviewed-by: Andreas Heinisch --- sd/qa/unit/uiimpress.cxx | 32 ++++++++++++++++++++++++++++++++ sd/source/ui/view/drtxtob.cxx | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index e44dfddb607f..a51caab799f0 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -550,6 +550,38 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf169813_prevent_unintended_dashed_li CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, rStyleItem.GetValue()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf148629_disabled_demote_command) +{ + createSdImpressDoc(); + SdXImpressDocument* pXImpressDocument = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pXImpressDocument); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + + // Start text edit of the empty content shape + SdPage* pActualPage = pViewShell->GetActualPage(); + pActualPage->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT, true); + insertStringToObject(1, u"List Item", /*bUseEscape*/ false); + + // Check that the demote command is enabled + std::unique_ptr pItem; + CPPUNIT_ASSERT_EQUAL( + SfxItemState::DEFAULT, + pViewShell->GetViewFrame()->GetBindings().QueryState(SID_OUTLINE_RIGHT, pItem)); + + // Start text edit of the empty title shape + typeKey(pXImpressDocument, KEY_ESCAPE); + insertStringToObject(0, u"Title", /*bUseEscape*/ false); + + // Without the fix in place, this test would have failed with: + // - Expected: 1 (SfxItemState::DISABLED) + // - Actual : 32 (SfxItemState::DEFAULT) + // i.e. the demote command was not disabled + CPPUNIT_ASSERT_EQUAL( + SfxItemState::DISABLED, + pViewShell->GetViewFrame()->GetBindings().QueryState(SID_OUTLINE_RIGHT, pItem)); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf162455) { createSdImpressDoc(); diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index 8f064f631d95..ab111f906142 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -314,7 +314,8 @@ void TextObjectBar::GetAttrStateImpl(const ViewShell& rViewShell, ::sd::View* pV bDisableLeft = false; } - if( (nDepth < pOLV->GetOutliner().GetMaxDepth() && ( !bOutlineViewSh || rOutl.GetAbsPos(pPara) != 0 )) || + // tdf#148629 - disable demote command on non-list paragraphs + if( (nDepth >= 0 && nDepth < pOLV->GetOutliner().GetMaxDepth() && ( !bOutlineViewSh || rOutl.GetAbsPos(pPara) != 0 )) || (bOutlineViewSh && (nDepth <= 0) && ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) && rOutl.GetAbsPos(pPara) != 0) ) { // not maximum depth and not at top