officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |    8 +
 sw/inc/cmdid.h                                                      |    1 
 sw/inc/strings.hrc                                                  |    2 
 sw/sdi/_textsh.sdi                                                  |    7 
 sw/sdi/swriter.sdi                                                  |   15 ++
 sw/source/uibase/shells/textsh1.cxx                                 |   72 
++++++++++
 sw/uiconfig/swriter/menubar/menubar.xml                             |    1 
 7 files changed, 106 insertions(+)

New commits:
commit d2cd98b66f099b77ad7c45f8d9a9f6f4adae1439
Author:     shlok3640 <[email protected]>
AuthorDate: Fri Feb 27 10:54:06 2026 +0000
Commit:     Heiko Tietze <[email protected]>
CommitDate: Sun Mar 1 14:24:17 2026 +0100

    tdf#168272 Add Insert Landscape Page function
    
    Change-Id: I9efd61029b400d4af1662259937ca272e4709938
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200606
    Reviewed-by: Heiko Tietze <[email protected]>
    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 936b8bb57838..8e8bd514810f 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -847,6 +847,14 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:InsertLandscapePage" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Insert Landscape Page Break</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:InsertTable" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Table</value>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index b77f535a6d3d..1b0449c5b67f 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -236,6 +236,7 @@ class SwUINumRuleItem;
 #define FN_INSERT_CHECKBOX_CONTENT_CONTROL (FN_INSERT + 21)  /* Checkbox 
content control */
 #define FN_INSERT_OBJECT_DLG    (FN_INSERT + 22)    /* Object */
 #define FN_INSERT_PAGEBREAK     (FN_INSERT + 23)    /* Page break*/
+#define FN_INSERT_LANDSCAPE_PAGE    (FN_INSERT + 55)
 #define FN_INSERT_DROPDOWN_CONTENT_CONTROL (FN_INSERT + 24)  /* Dropdown 
content control */
 #define FN_CONTENT_CONTROL_PROPERTIES (FN_INSERT + 25)  /* Content control 
properties */
 #define FN_INSERT_PICTURE_CONTENT_CONTROL (FN_INSERT + 26) /* Picture content 
control */
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index cd0160b28e72..04763d6a3097 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -462,6 +462,8 @@
 #define STR_COPY_UNDO                           NC_("STR_COPY_UNDO", "Copy: 
$1")
 #define STR_REPLACE_UNDO                        NC_("STR_REPLACE_UNDO", 
"Replace $1 $2 $3")
 #define STR_INSERT_PAGE_BREAK_UNDO              
NC_("STR_INSERT_PAGE_BREAK_UNDO", "Insert page break")
+#define STR_INSERT_PORTRAIT_PAGE                
NC_("STR_INSERT_PORTRAIT_PAGE", "Insert Portrait Page Break")
+#define STR_INSERT_LANDSCAPE_PAGE               
NC_("STR_INSERT_LANDSCAPE_PAGE", "Insert Landscape Page Break")
 #define STR_INSERT_COLUMN_BREAK_UNDO            
NC_("STR_INSERT_COLUMN_BREAK_UNDO", "Insert column break")
 #define STR_INSERT_ENV_UNDO                     NC_("STR_INSERT_ENV_UNDO", 
"Insert Envelope")
 #define STR_DRAG_AND_COPY                       NC_("STR_DRAG_AND_COPY", 
"Copy: $1")
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 87aeb4c9935d..c74f30430ea3 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -277,6 +277,13 @@ interface BaseText
         StateMethod = GetState ;
     ]
 
+FN_INSERT_LANDSCAPE_PAGE // status(final|play)
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState ;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor" ;
+    ]
+
     FN_INSERT_PAGEBREAK // status(final|play)
     [
         ExecMethod = ExecInsert ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index a39a202c1cda..e4a5b523ad0a 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -3408,7 +3408,22 @@ SfxVoidItem TransformDocumentStructure 
FN_TRANSFORM_DOCUMENT_STRUCTURE
     ToolBoxConfig = TRUE,
     GroupId = SfxGroupId::Edit;
 ]
+SfxVoidItem InsertLandscapePage FN_INSERT_LANDSCAPE_PAGE
+()
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
 
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Insert;
+]
 SfxVoidItem InsertMultiIndex FN_INSERT_MULTI_TOX
 ()
 [
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index e00d90ab7be6..b7cb581d95f3 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -92,6 +92,8 @@
 #include <editeng/acorrcfg.hxx>
 #include <swabstdlg.hxx>
 #include <sfx2/sfxdlg.hxx>
+#include <poolfmt.hxx>
+#include <SwStyleNameMapper.hxx>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
@@ -957,6 +959,57 @@ void SwTextShell::Execute(SfxRequest &rReq)
         pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot), false, 
&pItem);
     switch( nSlot )
     {
+        case FN_INSERT_LANDSCAPE_PAGE:
+        {
+            SwWrtShell& rSh = GetShell();
+
+            rSh.StartAllAction();
+            rSh.StartUndo(SwUndoId::INSERT);
+
+            const SwPageDesc& rPageDesc = 
rSh.GetPageDesc(rSh.GetCurPageDesc());
+            const bool bIsLandscape = rPageDesc.GetLandscape();
+
+            UIName aStandardName;
+            SwStyleNameMapper::FillUIName(SwPoolFormatId::PAGE_STANDARD, 
aStandardName);
+            UIName aLandscapeName;
+            SwStyleNameMapper::FillUIName(SwPoolFormatId::PAGE_LANDSCAPE, 
aLandscapeName);
+
+            UIName aOriginalStyle = rSh.GetCurPageStyle();
+            if (aOriginalStyle.isEmpty() || (bIsLandscape && aOriginalStyle == 
aLandscapeName))
+            {
+                aOriginalStyle = aStandardName;
+            }
+
+            UIName aTargetStyle = bIsLandscape ? aStandardName : 
aLandscapeName;
+
+            if (rSh.HasSelection())
+            {
+                if (!rSh.IsCursorPtAtEnd())
+                    rSh.SwapPam();
+
+                rSh.Push();
+                rSh.ClearMark();
+
+                rSh.InsertPageBreak(&aOriginalStyle);
+
+                rSh.Pop(SwCursorShell::PopMode::DeleteCurrent);
+
+                rSh.SwapPam();
+                rSh.ClearMark();
+
+                rSh.InsertPageBreak(&aTargetStyle);
+            }
+            else
+            {
+                rSh.InsertPageBreak(&aTargetStyle);
+            }
+
+            rSh.EndUndo(SwUndoId::INSERT);
+            rSh.EndAllAction();
+
+            rReq.Done();
+            break;
+        }
         case SID_UNICODE_NOTATION_TOGGLE:
         {
             tools::Long nMaxUnits = 256;
@@ -3884,6 +3937,25 @@ void SwTextShell::GetState( SfxItemSet &rSet )
             }
             break;
 
+        case FN_INSERT_LANDSCAPE_PAGE:
+            if( rSh.CursorInsideInputField() || 
rSh.CursorInsideContentControl() )
+            {
+                rSet.DisableItem( nWhich );
+            }
+            else
+            {
+                const SwPageDesc& rPageDesc = 
rSh.GetPageDesc(rSh.GetCurPageDesc());
+                if (rPageDesc.GetLandscape())
+                {
+                    rSet.Put(SfxStringItem(nWhich, 
SwResId(STR_INSERT_PORTRAIT_PAGE)));
+                }
+                else
+                {
+                    rSet.Put(SfxStringItem(nWhich, 
SwResId(STR_INSERT_LANDSCAPE_PAGE)));
+                }
+            }
+            break;
+
         case FN_INSERT_PAGEHEADER:
         case FN_INSERT_PAGEFOOTER:
             if (comphelper::LibreOfficeKit::isActive())
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml 
b/sw/uiconfig/swriter/menubar/menubar.xml
index 98b9177a0728..cbe39b64072a 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -260,6 +260,7 @@
           <menu:menuitem menu:id=".uno:InsertLinebreak"/>
           <menu:menuitem menu:id=".uno:InsertColumnBreak"/>
           <menu:menuseparator/>
+          <menu:menuitem menu:id=".uno:InsertLandscapePage"/>
           <menu:menuitem menu:id=".uno:InsertBreak"/>
         </menu:menupopup>
       </menu:menu>

Reply via email to