sc/inc/sc.hrc | 1 sc/sdi/docsh.sdi | 1 sc/sdi/scalc.sdi | 20 ++++++++++++ sc/source/ui/docshell/docsh4.cxx | 62 +++++++++++++++++++++++++++++++++++++++ sfx2/source/control/unoctitm.cxx | 1 5 files changed, 85 insertions(+)
New commits: commit 1801ac9250859f795272e1c3f1aa03b3eddc11bc Author: Darshan-upadhyay1110 <darshan.upadh...@collabora.com> AuthorDate: Sat Jul 19 01:58:19 2025 +0530 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Aug 25 12:30:26 2025 +0200 Add CalcPageMargin UNO command to set sheet margins - Define in docsg.sdi with SvxLRSpaceItem (Left/Right) and SvxULSpaceItem (Top/Bottom). - In ScDocShell::Execute(), read Left/Right/Top/Bottom, update ATTR_LRSPACE/ATTR_ULSPACE, mark modified, repaint grid and invalidate bindings. Change-Id: I94eb439240f118da33efe7daa1261b390f7c8a80 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188053 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> (cherry picked from commit 86c51557e7075b2f4fdb5a438fea3a16a50ecf89) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189192 Tested-by: Jenkins diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 1749b87de475..f172e5fd1498 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -654,6 +654,7 @@ static_assert(SID_PREVIEW_END < SID_KEYFUNC_START, "calc slots ids trampling inf #define SID_INSERT_CURRENT_TIME (SC_RESOURCE_START+17) #define FID_TAB_TOGGLE_GRID (SC_RESOURCE_START+18) // toggle sheet grid #define WID_SIMPLE_REF (SC_RESOURCE_START+20) +#define SID_SC_ATTR_PAGE_MARGIN (SC_RESOURCE_START+22) #endif diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 38799c3761da..7efb92229908 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -85,6 +85,7 @@ interface TableDocument SID_PROTECTSIZE [ ExecMethod = Execute; StateMethod = GetState; ]; SID_ATTR_PAGE_ORIENTATION [ ExecMethod = Execute; StateMethod = GetState; ] + SID_SC_ATTR_PAGE_MARGIN [ ExecMethod = Execute; StateMethod = GetState; ] } diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 76678e70d94a..f386129cd9fe 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -6413,6 +6413,26 @@ SvxColorItem TabBgColor FID_TAB_SET_TAB_BG_COLOR GroupId = SfxGroupId::Format; ] +SvxSizeItem CalcPageMargin SID_SC_ATTR_PAGE_MARGIN +( + SvxLRSpaceItem Page SID_ATTR_LRSPACE, + SvxULSpaceItem Page SID_ATTR_ULSPACE, +) +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Format; +] + SfxVoidItem MarkPrecedents SID_DETECTIVE_MARK_PRED () diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index c70373acc421..db33df9f9dab 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -116,6 +116,8 @@ #include <officecfg/Office/Common.hxx> #include <svx/xdef.hxx> +#include <editeng/lrspitem.hxx> // Defines SvxLRSpaceItem +#include <editeng/ulspitem.hxx> // Defines SvxULSpaceItem using namespace ::com::sun::star; @@ -647,6 +649,65 @@ void ScDocShell::Execute( SfxRequest& rReq ) rReq.Done(); } break; + case SID_SC_ATTR_PAGE_MARGIN: + { + const SvxLRSpaceItem* pLR = rReq.GetArg<SvxLRSpaceItem>(SID_ATTR_LRSPACE); + if (!pLR) { + SAL_WARN( "sc", " Left & Right margins are missing"); + break; + } + + SvxIndentValue nLeft = pLR->GetLeft(); + SvxIndentValue nRight = pLR->GetRight(); + + const SvxULSpaceItem* pUL = rReq.GetArg<SvxULSpaceItem>(SID_ATTR_ULSPACE); + if (!pUL) { + SAL_WARN( "sc", " Top & Bottom margins are missing"); + break; + } + long nTop = pUL->GetUpper(); + long nBottom = pUL->GetLower(); + + ScViewData* pViewData = GetViewData(); + if (!pViewData) + { + break; + } + + ScDocument& rDoc = GetDocument(); + const SCTAB nTab = pViewData->GetTabNo(); + OUString aStyleName = rDoc.GetPageStyle(nTab); + ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find(aStyleName, SfxStyleFamily::Page); + assert(pStyleSheet); + SfxItemSet& rSet = pStyleSheet->GetItemSet(); + + SvxLRSpaceItem aLRItem(ATTR_LRSPACE); + aLRItem.SetLeft(nLeft); + aLRItem.SetRight(nRight); + rSet.Put(aLRItem); + + SvxULSpaceItem aULItem(ATTR_ULSPACE); + aULItem.SetUpper(nTop); + aULItem.SetLower(nBottom); + rSet.Put(aULItem); + + SetDocumentModified(); + + PostPaintGridAll(); + + if (pBindings) + { + pBindings->Invalidate(SID_SC_ATTR_PAGE_MARGIN); + pBindings->Invalidate(SID_ATTR_LRSPACE); + pBindings->Invalidate(SID_ATTR_ULSPACE); + pBindings->Invalidate(SID_ATTR_PAGE_SIZE); + pBindings->Invalidate(SID_ATTR_PAGE_ORIENTATION); + } + + rReq.Done(); + } + break; case SID_AUTO_STYLE: OSL_FAIL("use ScAutoStyleHint instead of SID_AUTO_STYLE"); break; @@ -2351,6 +2412,7 @@ void ScDocShell::GetState( SfxItemSet &rSet ) } break; case SID_ATTR_PAGE_ORIENTATION: + case SID_SC_ATTR_PAGE_MARGIN: { ScViewData* pViewData = GetViewData(); if (pViewData) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 7c4e2bdc72a2..361f38e2b18d 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1409,6 +1409,7 @@ const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList() { u"LayoutStatus", { PayloadType::StringPayload, true } }, { u"Scale", { PayloadType::StringPayload, true } }, { u"Context", { PayloadType::StringPayload, true } }, + { u"CalcPageMargin", { PayloadType::StringPayload, true } }, { u"RowColSelCount", { PayloadType::RowColSelCountPayload, true } },