Kaydet (Commit) ce641ca3 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Xisco Faulí

tdf#125011 large ui scaling factor overflows spinbutton range

Change-Id: I6e41318a92f02e3cd7fde5c52272582345362533

clamp to target type bounds

Change-Id: I8d3f7653b7e9b64a2f433b4ebfb8a0fef1522e93
Reviewed-on: https://gerrit.libreoffice.org/71637
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
(cherry picked from commit ed67b443)
Reviewed-on: https://gerrit.libreoffice.org/71660Reviewed-by: 's avatarXisco Faulí <xiscofauli@libreoffice.org>
üst b6d84038
......@@ -94,17 +94,19 @@ void CopyDlg::Reset()
// Set Min/Max values
::tools::Rectangle aRect = mpView->GetAllMarkedRect();
Size aPageSize = mpView->GetSdrPageView()->GetPage()->GetSize();
SetMetricValue( *m_xMtrFldMoveX, long(1000000 / maUIScale), MapUnit::Map100thMM);
double fScaleFactor = m_xMtrFldMoveX->get_value(FieldUnit::NONE)/1000000.0;
long nPageWidth = aPageSize.Width() * fScaleFactor;
long nPageHeight = aPageSize.Height() * fScaleFactor;
long nRectWidth = aRect.GetWidth() * fScaleFactor;
long nRectHeight = aRect.GetHeight() * fScaleFactor;
m_xMtrFldMoveX->set_range(-nPageWidth, nPageWidth, FieldUnit::NONE);
m_xMtrFldMoveY->set_range(-nPageHeight, nPageHeight, FieldUnit::NONE);
m_xMtrFldWidth->set_range(-nRectWidth, nPageWidth, FieldUnit::NONE);
m_xMtrFldHeight->set_range(-nRectHeight, nPageHeight, FieldUnit::NONE);
// tdf#125011 draw/impress sizes are in mm_100th already, "normalize" to
// decimal shift by number of decimal places the widgets are using (2) then
// scale by the ui scaling factor
auto nPageWidth = long(m_xMtrFldMoveX->normalize(aPageSize.Width()) / maUIScale);
auto nPageHeight = long(m_xMtrFldMoveX->normalize(aPageSize.Height()) / maUIScale);
auto nRectWidth = long(m_xMtrFldMoveX->normalize(aRect.GetWidth()) / maUIScale);
auto nRectHeight = long(m_xMtrFldMoveX->normalize(aRect.GetHeight()) / maUIScale);
m_xMtrFldMoveX->set_range(-nPageWidth, nPageWidth, FieldUnit::MM_100TH);
m_xMtrFldMoveY->set_range(-nPageHeight, nPageHeight, FieldUnit::MM_100TH);
m_xMtrFldWidth->set_range(-nRectWidth, nPageWidth, FieldUnit::MM_100TH);
m_xMtrFldHeight->set_range(-nRectHeight, nPageHeight, FieldUnit::MM_100TH);
const SfxPoolItem* pPoolItem = nullptr;
OUString aStr;
......
......@@ -281,7 +281,13 @@ namespace weld
double fResult(0.0);
bool bRet = MetricFormatter::TextToValue(get_text(), fResult, 0, m_xSpinButton->get_digits(), rLocaleData, m_eSrcUnit);
if (bRet)
{
if (fResult > SAL_MAX_INT32)
fResult = SAL_MAX_INT32;
else if (fResult < SAL_MIN_INT32)
fResult = SAL_MIN_INT32;
*result = fResult;
}
return bRet;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment