officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu | 8 ++ sw/inc/cmdid.h | 1 sw/sdi/_tabsh.sdi | 5 + sw/sdi/swriter.sdi | 18 ++++++ sw/source/uibase/shells/tabsh.cxx | 27 ++++++++++ sw/uiconfig/swriter/popupmenu/table.xml | 1 6 files changed, 60 insertions(+)
New commits: commit 1b03f6ea0362a38c6c4e5e767fcb5cf87ddd28dd Author: Ujjawal Kumar <randomfores...@gmail.com> AuthorDate: Thu Mar 13 20:42:21 2025 +0530 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Wed Mar 19 12:17:58 2025 +0100 tdf#149825 Add command to insert a paragraph break before table Change-Id: I7af1a4bba7222f7989aa99bc158f6e4081aad226 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182873 Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> Tested-by: Jenkins diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index d012861cf696..ef3152896a4d 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -1583,6 +1583,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:BreakAboveTable" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Insert Paragraph Break Above Table</value> + </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Inserts a paragraph break above the table if it is the first element in the page.</value> + </prop> + </node> <node oor:name=".uno:FootnoteDialog" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Footnote/Endnote Settings...</value> diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 9baa9c18f86a..079f0d0f00bf 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -420,6 +420,7 @@ class SwUINumRuleItem; #define FN_CONVERT_TEXT_TO_TABLE (FN_FORMAT + 131) /* convert selected text to table */ #define FN_CONVERT_TABLE_TO_TEXT (FN_FORMAT + 132) /* convert a table to text */ #define FN_TABLE_SORT_DIALOG (FN_FORMAT + 133) /* sorting in tables*/ +#define FN_BREAK_ABOVE_TABLE (FN_FORMAT + 134) // Region: Page Template #define FN_PAGE_STYLE_SET_LR_MARGIN (FN_FORMAT + 130) /* left / right margin */ diff --git a/sw/sdi/_tabsh.sdi b/sw/sdi/_tabsh.sdi index 7596d2c29bda..f173f15daaa7 100644 --- a/sw/sdi/_tabsh.sdi +++ b/sw/sdi/_tabsh.sdi @@ -24,6 +24,11 @@ interface BaseTextTable ExecMethod = Execute ; StateMethod = NoState ; ] + FN_BREAK_ABOVE_TABLE + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] SID_ATTR_BRUSH [ ExecMethod = Execute ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 6fd96a160846..cbc33ee85e34 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -6454,6 +6454,24 @@ SfxVoidItem TableDialog FN_FORMAT_TABLE_DLG GroupId = SfxGroupId::Table; ] +SfxVoidItem BreakAboveTable FN_BREAK_ABOVE_TABLE +() +[ + AutoUpdate = FALSE, + FastCall = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerItem; + Asynchron; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Table; +] + SfxBoolItem TableModeFix FN_TABLE_MODE_FIX () [ diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 3664e17c50de..6ebf4b9e1063 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -73,6 +73,9 @@ #include <tblsel.hxx> #include <viewopt.hxx> #include <tabfrm.hxx> +#include <frame.hxx> +#include <pagefrm.hxx> +#include <cntfrm.hxx> #include <strings.hrc> #include <cmdid.h> @@ -598,6 +601,12 @@ void SwTableShell::Execute(SfxRequest &rReq) case FN_INSERT_TABLE: InsertTable( rReq ); break; + case FN_BREAK_ABOVE_TABLE: + { + rSh.MoveTable( GotoCurrTable, fnTableStart ); + rSh.SplitNode( false ); + break; + } case FN_FORMAT_TABLE_DLG: { //#127012# get the bindings before the dialog is called @@ -1539,7 +1548,25 @@ void SwTableShell::GetState(SfxItemSet &rSet) rSet.Put(SfxBoolItem(nSlot, bSet)); } break; + case FN_BREAK_ABOVE_TABLE: + { + // exec just moves on top and adds the break, which however makes only sense if the table + // is the very first item of the document; the command should be hidden otherwise + SwContentFrame* curFrame = rSh.GetCurrFrame(); + SwPageFrame* pageFrame = curFrame->FindPageFrame(); + SwFrame* frame = pageFrame->Lower(); + while(!frame->IsContentFrame()) + { + frame = frame->GetLower(); + } + + if(frame->FindTabFrame() != curFrame->FindTabFrame()) + { + rSet.DisableItem(nSlot); + } + } + break; case SID_ATTR_PARA_SPLIT: rSet.Put( pFormat->GetKeep() ); break; diff --git a/sw/uiconfig/swriter/popupmenu/table.xml b/sw/uiconfig/swriter/popupmenu/table.xml index 296e6e388e2b..fc04ff6aadb5 100644 --- a/sw/uiconfig/swriter/popupmenu/table.xml +++ b/sw/uiconfig/swriter/popupmenu/table.xml @@ -148,6 +148,7 @@ <menu:menuitem menu:id=".uno:OpenSmartTagMenuOnCursor"/> <menu:menuitem menu:id=".uno:ThesaurusFromContext"/> <menu:menuseparator/> + <menu:menuitem menu:id=".uno:BreakAboveTable"/> <menu:menuitem menu:id=".uno:InsertCaptionDialog"/> <menu:menuitem menu:id=".uno:TableDialog"/> </menu:menupopup>