From 0a74b5fcfbfa68ad1cab228d74f08e8c35bc6820 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Fri, 28 Apr 2023 11:48:25 +0300 Subject: [PATCH] sc drawstyles: Enable the clear DF command .uno:StandardTextAttributes works for shape formatting already (despite its name), but it's a different command than Format > Clear DF. So let's connect the regular Clear DF command to the same code. Also includes a workaround for comments to maintain their size. Changing the size (because of the "Fit height to text" setting) is probably confusing for other shapes as well, but for comments this requires an extra step to undo, as comments can't be resized unless they're shown permanently. And manually resizing each comment back will also result with inconsistency in their size. Change-Id: I7c158523ecc4be18d17479632eaf9fd2a51dca12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151161 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- sc/sdi/drawsh.sdi | 1 + sc/sdi/drtxtob.sdi | 1 + sc/source/ui/drawfunc/drawsh.cxx | 10 ++++++++-- sc/source/ui/drawfunc/drtxtob.cxx | 13 ++++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sc/sdi/drawsh.sdi b/sc/sdi/drawsh.sdi index 13f1d6b150df..668608c549ab 100644 --- a/sc/sdi/drawsh.sdi +++ b/sc/sdi/drawsh.sdi @@ -37,6 +37,7 @@ interface TableDraw SID_DRAW_CHART [ StateMethod = StateDisableItems; ] SID_TEXT_STANDARD [ ExecMethod = ExecDrawAttr; StateMethod = NoState; ] + SID_CELL_FORMAT_RESET [ ExecMethod = ExecDrawAttr; StateMethod = NoState; ] SID_DRAWTEXT_ATTR_DLG [ ExecMethod = ExecDrawAttr; StateMethod = NoState; ] // ---- Slot-IDs for Objectbar: diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi index 4670d216fba2..a4df9af69108 100644 --- a/sc/sdi/drtxtob.sdi +++ b/sc/sdi/drtxtob.sdi @@ -47,6 +47,7 @@ interface TableDrawText SID_THESAURUS [ ExecMethod = Execute; StateMethod = GetState; ] // attribute: SID_TEXT_STANDARD [ ExecMethod = ExecuteAttr; StateMethod = GetState; ] + SID_CELL_FORMAT_RESET [ ExecMethod = ExecuteAttr; StateMethod = GetState; ] SID_DRAWTEXT_ATTR_DLG [ ExecMethod = ExecuteAttr; StateMethod = GetState; ] SID_ATTR_CHAR_FONT [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; ] SID_ATTR_CHAR_FONTHEIGHT [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; ] diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index 291ec3e236bc..52ec9d9d438a 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -161,9 +161,15 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq ) } break; - case SID_TEXT_STANDARD: // delete hard text attributes + case SID_CELL_FORMAT_RESET: + case SID_TEXT_STANDARD: { - SfxItemSetFixed aEmptyAttr(GetPool()); + SfxItemSetFixed aEmptyAttr(GetPool()); + + if (ScDrawLayer::IsNoteCaption(pSingleSelectedObj)) + aEmptyAttr.Put(pView->GetAttrFromMarked(true)); + pView->SetAttributes(aEmptyAttr, true); } break; diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index f428465936b3..79f2bd1a588c 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -791,7 +791,8 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) { switch ( nSlot ) { - case SID_TEXT_STANDARD: // delete hard text attributes + case SID_CELL_FORMAT_RESET: + case SID_TEXT_STANDARD: { OutlinerView* pOutView = pView->IsTextEdit() ? pView->GetTextEditOutlinerView() : nullptr; @@ -799,8 +800,18 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) pOutView->Paint( tools::Rectangle() ); SfxItemSetFixed aEmptyAttr( *aEditAttr.GetPool() ); + SfxItemSetFixed aSizeAttr(*aEditAttr.GetPool()); + + aSizeAttr.Put(pView->GetAttrFromMarked(true)); pView->SetAttributes( aEmptyAttr, true ); + if (IsNoteEdit()) + { + pView->SetAttributes(aSizeAttr, false); + pView->GetTextEditObject()->AdjustTextFrameWidthAndHeight(); + } + if ( pOutView ) { lcl_RemoveFields( *pOutView );