include/svx/swframevalidation.hxx | 2 ++ sw/source/ui/frmdlg/frmpage.cxx | 20 ++++++++++++++------ sw/source/uibase/frmdlg/frmmgr.cxx | 10 ++++++++-- sw/source/uibase/inc/frmpage.hxx | 1 + sw/source/uibase/inc/prcntfld.hxx | 2 +- sw/source/uibase/utlui/prcntfld.cxx | 4 ++-- 6 files changed, 28 insertions(+), 11 deletions(-)
New commits: commit 5ad6e83caa695cca9ee25aa6f02c4d078311545b Author: Justin Luth <[email protected]> AuthorDate: Tue Nov 11 17:00:01 2025 -0500 Commit: Justin Luth <[email protected]> CommitDate: Wed Nov 12 16:20:50 2025 +0100 tdf#169219 swpagerelsize ui: immediately apply new RefValue The m_xWidthED shows either the actual width or the width as a percentage. When we switch m_xRelWidthRelationLB, the base that determines the percentage also needs to change. Prior to this patch changing the value from 'Entire Page' to 'Entire Paragraph Area' did not affect the percentage shown. Now the percentage increases (only the 'ruler' changed, not the width). It also means that changing the percentage also correctly synchronizes the width/height on the Crop tab. Change-Id: Ib5074fc57972df97c8bf400826e287d0a6070fcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193831 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/include/svx/swframevalidation.hxx b/include/svx/swframevalidation.hxx index 049fce9afac1..3931ea75b348 100644 --- a/include/svx/swframevalidation.hxx +++ b/include/svx/swframevalidation.hxx @@ -54,6 +54,8 @@ struct SvxSwFrameValidation sal_Int32 nMaxHeight; Size aPercentSize; // Size for 100% value + bool bEntirePageWidth = false; + bool bEntirePageHeight = false; SvxSwFrameValidation() : nAnchorType(RndStdIds::FLY_AT_PARA), diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 0e4ebd9da041..271ba3ced41d 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -724,6 +724,9 @@ SwFramePage::SwFramePage(weld::Container* pPage, weld::DialogController* pContro m_xRelWidthCB->connect_toggled(aLk2); m_xRelHeightCB->connect_toggled(aLk2); + m_xRelWidthRelationLB->connect_changed(LINK(this, SwFramePage, RelRelationClickHdl)); + m_xRelHeightRelationLB->connect_changed(LINK(this, SwFramePage, RelRelationClickHdl)); + m_xAutoWidthCB->connect_toggled(LINK(this, SwFramePage, AutoWidthClickHdl)); m_xAutoHeightCB->connect_toggled(LINK(this, SwFramePage, AutoHeightClickHdl)); @@ -1898,6 +1901,10 @@ IMPL_LINK( SwFramePage, RelSizeClickHdl, weld::Toggleable&, rBtn, void ) ModifyHdl(*m_xHeightED->get()); } +IMPL_LINK_NOARG(SwFramePage, RelRelationClickHdl, weld::ComboBox&, void) +{ + RangeModifyHdl(); +} // range check IMPL_LINK_NOARG(SwFramePage, RangeModifyClickHdl, weld::Toggleable&, void) { @@ -1951,6 +1958,11 @@ void SwFramePage::RangeModifyHdl() aVal.nHPos = nAtHorzPosVal; aVal.nVPos = nAtVertPosVal; + if (m_xRelWidthRelationLB->get_active() == 1) + aVal.bEntirePageWidth = true; + if (m_xRelHeightRelationLB->get_active() == 1) + aVal.bEntirePageHeight = true; + aMgr.ValidateMetrics(aVal, mpToCharContentPos, true); // one time, to get reference values for percental values // set reference values for percental values (100%) ... diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index c2eb9a86398f..e944e2b23513 100644 --- a/sw/source/uibase/frmdlg/frmmgr.cxx +++ b/sw/source/uibase/frmdlg/frmmgr.cxx @@ -278,14 +278,20 @@ void SwFlyFrameAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, // OD 18.09.2003 #i18732# - adjustment for allowing vertical position // aligned to page for fly frame anchored to paragraph or to character. const RndStdIds eAnchorType = rVal.nAnchorType; - const SwFormatFrameSize& rSize = m_aSet.Get(RES_FRM_SIZE); + + SwFormatFrameSize aFormatFrameSize; + if (rVal.bEntirePageWidth) + aFormatFrameSize.SetWidthPercentRelation(text::RelOrientation::PAGE_FRAME); + if (rVal.bEntirePageHeight) + aFormatFrameSize.SetHeightPercentRelation(text::RelOrientation::PAGE_FRAME); + m_pOwnSh->CalcBoundRect( aBoundRect, eAnchorType, rVal.nHRelOrient, rVal.nVRelOrient, pToCharContentPos, rVal.bFollowTextFlow, rVal.bMirror, nullptr, &rVal.aPercentSize, - &rSize); + &aFormatFrameSize); if (bOnlyPercentRefValue) return; diff --git a/sw/source/uibase/inc/frmpage.hxx b/sw/source/uibase/inc/frmpage.hxx index 567b11a79c81..da0e4c215f03 100644 --- a/sw/source/uibase/inc/frmpage.hxx +++ b/sw/source/uibase/inc/frmpage.hxx @@ -153,6 +153,7 @@ class SwFramePage final : public SfxTabPage DECL_LINK(RealSizeHdl, weld::Button&, void); DECL_LINK(RelSizeClickHdl, weld::Toggleable&, void); + DECL_LINK(RelRelationClickHdl, weld::ComboBox&, void); DECL_LINK(MirrorHdl, weld::Toggleable&, void); DECL_LINK(AutoWidthClickHdl, weld::Toggleable&, void); commit 03ee643e81cabed77d8b60329899d34e6b00b3f1 Author: Justin Luth <[email protected]> AuthorDate: Tue Nov 11 17:11:32 2025 -0500 Commit: Justin Luth <[email protected]> CommitDate: Wed Nov 12 16:20:43 2025 +0100 tdf#169219 swpagerelsize ui: don't limit toggle-on-percent to 100 Prior to this patch, if you open up image properties and the relative width percentage is, say, 163% and then you toogle relative width off and back on again, then the percentage would have shown 100%. Now it shows ~163%. From a code read, it appears the the other uses either don't set a maximum, or use 99, so this looks like the only place that can benefit from the change. Change-Id: I9d082f3149bcb0e68c73f496f6d7e809b76d86c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193830 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 0a5ca28768c3..0e4ebd9da041 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -1881,17 +1881,13 @@ IMPL_LINK( SwFramePage, RelSizeClickHdl, weld::Toggleable&, rBtn, void ) { if (&rBtn == m_xRelWidthCB.get()) { - m_xWidthED->ShowPercent(rBtn.get_active()); + m_xWidthED->ShowPercent(rBtn.get_active(), MAX_PERCENT_WIDTH); m_xRelWidthRelationLB->set_sensitive(rBtn.get_active()); - if (rBtn.get_active()) - m_xWidthED->get()->set_max(MAX_PERCENT_WIDTH, FieldUnit::NONE); } else // rBtn == m_xRelHeightCB.get() { - m_xHeightED->ShowPercent(rBtn.get_active()); + m_xHeightED->ShowPercent(rBtn.get_active(), MAX_PERCENT_WIDTH); m_xRelHeightRelationLB->set_sensitive(rBtn.get_active()); - if (rBtn.get_active()) - m_xHeightED->get()->set_max(MAX_PERCENT_HEIGHT, FieldUnit::NONE); } RangeModifyHdl(); // correct the values again diff --git a/sw/source/uibase/inc/prcntfld.hxx b/sw/source/uibase/inc/prcntfld.hxx index 03a80b0530cd..401292970d43 100644 --- a/sw/source/uibase/inc/prcntfld.hxx +++ b/sw/source/uibase/inc/prcntfld.hxx @@ -75,7 +75,7 @@ public: sal_Int64 Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit); - void ShowPercent(bool bPercent); + void ShowPercent(bool bPercent, sal_uInt16 nMaxPercent = 100); void LockAutoCalculation(bool bLock) {m_bLockAutoCalculation = bLock;} }; diff --git a/sw/source/uibase/utlui/prcntfld.cxx b/sw/source/uibase/utlui/prcntfld.cxx index 5f54c0165766..aa57a09d4c93 100644 --- a/sw/source/uibase/utlui/prcntfld.cxx +++ b/sw/source/uibase/utlui/prcntfld.cxx @@ -55,7 +55,7 @@ static sal_Int64 UpscaleTwoDecimalPlaces(sal_Int64 nCurrentWidth, int nOldDigits return nCurrentWidth; } -void SwPercentField::ShowPercent(bool bPercent) +void SwPercentField::ShowPercent(bool bPercent, sal_uInt16 nMaxPercent) { if ((bPercent && m_pField->get_unit() == FieldUnit::PERCENT) || (!bPercent && m_pField->get_unit() != FieldUnit::PERCENT)) @@ -81,7 +81,7 @@ void SwPercentField::ShowPercent(bool bPercent) // round to 0.5 percent int nPercent = m_nRefValue ? (((nCurrentWidth * 10) / m_nRefValue + 5) / 10) : 0; - m_pField->set_range(std::max(1, nPercent), 100, FieldUnit::NONE); + m_pField->set_range(std::max(1, nPercent), nMaxPercent, FieldUnit::NONE); m_pField->set_increments(5, 10, FieldUnit::NONE); if (nOldValue != m_nLastValue) {
