include/svx/svxids.hrc | 5 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 33 +++++ sc/sdi/docsh.sdi | 2 sc/source/ui/docshell/docsh4.cxx | 48 ++++++++ sc/uiconfig/scalc/popupmenu/graphic.xml | 6 + sd/sdi/ViewShellBase.sdi | 10 + sd/source/ui/view/ViewShellBase.cxx | 57 +++++++++- sd/uiconfig/sdraw/popupmenu/graphic.xml | 6 + sd/uiconfig/simpress/popupmenu/graphic.xml | 6 + svx/sdi/svx.sdi | 32 +++++ sw/sdi/_basesh.sdi | 11 + sw/source/uibase/shells/basesh.cxx | 38 ++++++ sw/uiconfig/swriter/popupmenu/graphic.xml | 6 + 13 files changed, 258 insertions(+), 2 deletions(-)
New commits: commit 01b1e0f172c1912dac24337692d85a9caf637d9a Author: Heiko Tietze <[email protected]> AuthorDate: Wed Mar 26 09:52:55 2025 +0100 Commit: Heiko Tietze <[email protected]> CommitDate: Mon Mar 31 14:25:03 2025 +0200 Resolves tdf#84375 - Commands to protect image size and position Change-Id: Id693e4198d5feb1bb4d71a59785d0ab651b3cc68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183330 Tested-by: Jenkins Reviewed-by: Heiko Tietze <[email protected]> diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index e815e4a3f165..8b18de6306e8 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -1073,8 +1073,11 @@ class XFillGradientItem; #define SID_ATTR_POSTIT_HTML TypedWhichId<SvxPostItTextItem>( SID_SVX_START + 1215 ) +#define SID_PROTECTSIZE TypedWhichId<SfxBoolItem>( SID_SVX_START + 1216 ) +#define SID_PROTECTPOS TypedWhichId<SfxBoolItem>( SID_SVX_START + 1217 ) + // IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id -#define SID_SVX_FIRSTFREE ( SID_SVX_START + 1215 + 1 ) +#define SID_SVX_FIRSTFREE ( SID_SVX_START + 1217 + 1 ) // Overflow check for slot IDs diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index a096e245ce45..c9c3ff1d327d 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -2320,6 +2320,39 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 <value>1</value> </prop> </node> + <node oor:name=".uno:ProtectGraphicMenu" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Protect</value> + </prop> + </node> + <node oor:name=".uno:ProtectSize" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Protect Size</value> + </prop> + <prop oor:name="ContextLabel" oor:type="xs:string"> + <value xml:lang="en-US">Size</value> + </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Protect graphic size</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:ProtectPos" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Protect Position</value> + </prop> + <prop oor:name="ContextLabel" oor:type="xs:string"> + <value xml:lang="en-US">Position</value> + </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Protect graphic position</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:OriginalSize" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Original Size</value> diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 380ddb08e620..2d9a50ccb8ae 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -81,6 +81,8 @@ interface TableDocument SID_SPELLCHECK_APPLY_SUGGESTION [ ExecMethod = Execute; StateMethod = GetState; ] SID_REFRESH_VIEW [ ExecMethod = Execute; StateMethod = GetState; ] + SID_PROTECTPOS [ ExecMethod = Execute; StateMethod = GetState; ] + SID_PROTECTSIZE [ ExecMethod = Execute; StateMethod = GetState; ]; } diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index a00bf023c74c..79cd9433783f 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -36,6 +36,7 @@ #include <basic/sberrors.hxx> #include <svtools/sfxecode.hxx> #include <svx/ofaitem.hxx> +#include <svx/svdograf.hxx> #include <svl/stritem.hxx> #include <svl/whiter.hxx> #include <vcl/stdtext.hxx> @@ -1362,6 +1363,23 @@ void ScDocShell::Execute( SfxRequest& rReq ) PostPaintGridAll(); } break; + case SID_PROTECTPOS: + case SID_PROTECTSIZE: + { + ScDrawView* pScDrawView = GetBestViewShell()->GetViewData().GetScDrawView(); + if (!pScDrawView) + return; + + const SdrMarkList& rMarkList = pScDrawView->GetMarkedObjectList(); + assert ( rMarkList.GetMarkCount() == 1 ); + + SdrObject* pGraphicObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if (nSlot == SID_PROTECTSIZE) + pGraphicObj->SetResizeProtect(!pGraphicObj->IsResizeProtect()); + else + pGraphicObj->SetMoveProtect(!pGraphicObj->IsMoveProtect()); + } + break; default: { // small (?) hack -> forwarding of the slots to TabViewShell @@ -2345,7 +2363,37 @@ void ScDocShell::GetState( SfxItemSet &rSet ) rSet.Put(SfxStringItem(nWhich, sLanguage)); } break; + case SID_PROTECTPOS: + case SID_PROTECTSIZE: + { + ScViewData* pViewData = GetViewData(); + if (pViewData) + { + const ScDrawView* pDrView = pViewData->GetScDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + if ( rMarkList.GetMarkCount() == 1 ) + { + const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + const SdrObjKind nSdrObjKind = pObj->GetObjIdentifier(); + if ( nSdrObjKind == SdrObjKind::Graphic ) + { + if (nWhich == SID_PROTECTSIZE) + { + rSet.Put(SfxBoolItem(nWhich, pObj->IsResizeProtect())); + if (pObj->IsMoveProtect()) + rSet.DisableItem( nWhich ); + } + else + rSet.Put(SfxBoolItem(nWhich, pObj->IsMoveProtect())); + + break; + } + } + } + rSet.DisableItem( nWhich ); + } + break; default: { } diff --git a/sc/uiconfig/scalc/popupmenu/graphic.xml b/sc/uiconfig/scalc/popupmenu/graphic.xml index cb14ac724f35..10f813f1e702 100644 --- a/sc/uiconfig/scalc/popupmenu/graphic.xml +++ b/sc/uiconfig/scalc/popupmenu/graphic.xml @@ -16,6 +16,12 @@ <menu:menuitem menu:id=".uno:ExternalEdit"/> <menu:menuitem menu:id=".uno:ChangePicture"/> <menu:menuitem menu:id=".uno:CompressGraphic"/> + <menu:menu menu:id=".uno:ProtectGraphicMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:ProtectPos"/> + <menu:menuitem menu:id=".uno:ProtectSize"/> + </menu:menupopup> + </menu:menu> <menu:menuitem menu:id=".uno:SaveGraphic"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:OriginalSize"/> diff --git a/sd/sdi/ViewShellBase.sdi b/sd/sdi/ViewShellBase.sdi index f196e549ba25..f774ddeffee7 100644 --- a/sd/sdi/ViewShellBase.sdi +++ b/sd/sdi/ViewShellBase.sdi @@ -142,6 +142,16 @@ interface ViewShellBaseView ExecMethod = Execute ; StateMethod = GetState ; ] + SID_PROTECTPOS + [ + ExecMethod = Execute ; + StateMethod = GetState; + ] + SID_PROTECTSIZE + [ + ExecMethod = Execute ; + StateMethod = GetState; + ] SID_INSERT_DRAW [] } diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index bfbff51d1389..cceed0d4a823 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -681,6 +681,26 @@ void ViewShellBase::Execute (SfxRequest& rRequest) mpImpl->ProcessRestoreEditingViewSlot(); break; + case SID_PROTECTPOS: + case SID_PROTECTSIZE: + { + ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() ); + if (!pDocSh) + break; + ::sd::View* pView = pDocSh->GetViewShell()->GetView(); + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + assert ( rMarkList.GetMarkCount() == 1 ); + + SdrObject* pGraphicObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if (nSlotId == SID_PROTECTSIZE) + pGraphicObj->SetResizeProtect(!pGraphicObj->IsResizeProtect()); + else + pGraphicObj->SetMoveProtect(!pGraphicObj->IsMoveProtect()); + + } + break; + default: // Ignore any other slot. rRequest.Ignore (); @@ -1376,9 +1396,11 @@ void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet) while (nItemId > 0) { bool bState (false); + bool bEnabled; Reference<XResourceId> xResourceId; try { + bEnabled = true; // Check if the right view is active switch (nItemId) { @@ -1444,6 +1466,37 @@ void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet) case SID_TOGGLE_TABBAR_VISIBILITY: bState = GetUserWantsTabBar(); break; + case SID_PROTECTPOS: + case SID_PROTECTSIZE: + { + ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>(SfxObjectShell::Current()); + if (pDocSh) + { + ::sd::View* pView = pDocSh->GetViewShell()->GetView(); + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if ( rMarkList.GetMarkCount() == 1 ) // graphic menu only effective on single item + { + const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + const SdrObjKind nSdrObjKind = pObj->GetObjIdentifier(); + + if ( nSdrObjKind == SdrObjKind::Graphic ) + { + if ( nItemId == SID_PROTECTSIZE ) + { + bState = pObj->IsResizeProtect(); + if ( pObj->IsMoveProtect() ) + bEnabled = false; + } + else + bState = pObj->IsMoveProtect(); + + break; + } + } + } + bEnabled = false; + } + break; default: // Ignore all other items. They are not meant to be @@ -1456,7 +1509,7 @@ void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet) } // Check if edit mode fits too - if (bState) + if (bState && bEnabled) { ViewShell* const pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell( FrameworkHelper::msCenterPaneURL).get(); @@ -1480,6 +1533,8 @@ void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet) // And finally set the state. rSet.Put(SfxBoolItem(nItemId, bState)); + if (!bEnabled) + rSet.DisableItem( nItemId ); nItemId = aSetIterator.NextWhich(); } diff --git a/sd/uiconfig/sdraw/popupmenu/graphic.xml b/sd/uiconfig/sdraw/popupmenu/graphic.xml index 6e7c6ef33b0c..05403dad533a 100644 --- a/sd/uiconfig/sdraw/popupmenu/graphic.xml +++ b/sd/uiconfig/sdraw/popupmenu/graphic.xml @@ -16,6 +16,12 @@ <menu:menuitem menu:id=".uno:ExternalEdit"/> <menu:menuitem menu:id=".uno:ChangePicture"/> <menu:menuitem menu:id=".uno:CompressGraphic"/> + <menu:menu menu:id=".uno:ProtectGraphicMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:ProtectPos"/> + <menu:menuitem menu:id=".uno:ProtectSize"/> + </menu:menupopup> + </menu:menu> <menu:menuitem menu:id=".uno:SaveGraphic"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:OriginalSize"/> diff --git a/sd/uiconfig/simpress/popupmenu/graphic.xml b/sd/uiconfig/simpress/popupmenu/graphic.xml index 3da37f0515d2..c1ac06c48771 100644 --- a/sd/uiconfig/simpress/popupmenu/graphic.xml +++ b/sd/uiconfig/simpress/popupmenu/graphic.xml @@ -16,6 +16,12 @@ <menu:menuitem menu:id=".uno:ExternalEdit"/> <menu:menuitem menu:id=".uno:ChangePicture"/> <menu:menuitem menu:id=".uno:CompressGraphic"/> + <menu:menu menu:id=".uno:ProtectGraphicMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:ProtectPos"/> + <menu:menuitem menu:id=".uno:ProtectSize"/> + </menu:menupopup> + </menu:menu> <menu:menuitem menu:id=".uno:SaveGraphic"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:OriginalSize"/> diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 2fdfc5165172..dba7ddef043a 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -12857,3 +12857,35 @@ SfxBoolItem ClickChangeRotation SID_CLICK_CHANGE_ROTATION ToolBoxConfig = TRUE, GroupId = SfxGroupId::Options; ] + +SfxBoolItem ProtectSize SID_PROTECTSIZE +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Modify; +] + +SfxBoolItem ProtectPos SID_PROTECTPOS +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Modify; +] diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 6967020afbcc..009555504e5e 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -624,4 +624,15 @@ interface BaseTextSelection StateMethod = GetState; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_PROTECTPOS + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] + SID_PROTECTSIZE + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] } diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index bac55e07b73b..847c3facf4c4 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -50,6 +50,7 @@ #include <editeng/brushitem.hxx> #include <editeng/opaqitem.hxx> #include <editeng/sizeitem.hxx> +#include <editeng/protitem.hxx> #include <svx/flagsdef.hxx> #include <editeng/scripttypeitem.hxx> #include <sfx2/objface.hxx> @@ -1531,6 +1532,27 @@ void SwBaseShell::Execute(SfxRequest &rReq) } } break; + case SID_PROTECTSIZE: + case SID_PROTECTPOS: + { + const bool bIsProtected + = rSh.IsSelObjProtected(nSlot == SID_PROTECTSIZE ? FlyProtectFlags::Size + : FlyProtectFlags::Pos) + != FlyProtectFlags::NONE; + + SfxItemSet aSet( GetPool(), aFrameFormatSetRange ); + rSh.GetFlyFrameAttr( aSet ); + + SvxProtectItem rProt = aSet.Get( RES_PROTECT ); + if (nSlot == SID_PROTECTSIZE) + rProt.SetSizeProtect(!bIsProtected); + else + rProt.SetPosProtect(!bIsProtected); + aSet.Put( rProt ); + + rSh.SetFlyFrameAttr( aSet ); + } + break; default: bMore = true; @@ -2190,6 +2212,22 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) rSet.Put(SfxBoolItem(nWhich, bInsInMargin)); } break; + case SID_PROTECTSIZE: + case SID_PROTECTPOS: + { + if( rSh.GetGraphicType() == GraphicType::NONE ) + rSet.DisableItem(nWhich); + else + { + const bool bIsProtected + = rSh.IsSelObjProtected(nWhich == SID_PROTECTSIZE ? FlyProtectFlags::Size + : FlyProtectFlags::Pos) + != FlyProtectFlags::NONE; + rSet.Put(SfxBoolItem(nWhich, bIsProtected)); + } + } + break; + } nWhich = aIter.NextWhich(); } diff --git a/sw/uiconfig/swriter/popupmenu/graphic.xml b/sw/uiconfig/swriter/popupmenu/graphic.xml index 50e54339c034..098e692e5c65 100644 --- a/sw/uiconfig/swriter/popupmenu/graphic.xml +++ b/sw/uiconfig/swriter/popupmenu/graphic.xml @@ -16,6 +16,12 @@ <menu:menuitem menu:id=".uno:ExternalEdit"/> <menu:menuitem menu:id=".uno:ChangePicture"/> <menu:menuitem menu:id=".uno:CompressGraphic"/> + <menu:menu menu:id=".uno:ProtectGraphicMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:ProtectPos"/> + <menu:menuitem menu:id=".uno:ProtectSize"/> + </menu:menupopup> + </menu:menu> <menu:menuitem menu:id=".uno:SaveGraphic"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:AnchorMenu"/>
