diff options
author | Katarina Behrens <bubli@bubli.org> | 2014-11-28 11:20:04 +0100 |
---|---|---|
committer | Katarina Behrens <bubli@bubli.org> | 2014-11-29 08:18:34 +0000 |
commit | 1386c348f81738a9966d1217db89d1f603466317 (patch) | |
tree | e4b1771a865a23b9f0ecd8bc43c4a2d947add396 /svx | |
parent | e22325ca9076de4cf11c82f21da611b8c7ba1b5a (diff) |
fdo#82616: set limits on spinboxes according to size of workarea
Do it the same way as position'n'size dialog does, for that matter
move shared code into a separate header/class.
This fixes regression from .ui migration that omitted spinbox limits
Change-Id: I884904719b2608dd80aecc5d7ffb3923de71774d
Reviewed-on: https://gerrit.libreoffice.org/13174
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Katarina Behrens <bubli@bubli.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sidebar/possize/PosSizePropertyPanel.cxx | 55 | ||||
-rw-r--r-- | svx/source/sidebar/possize/PosSizePropertyPanel.hxx | 5 |
2 files changed, 49 insertions, 11 deletions
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx index 6956bf6f2c11..44c52887a223 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx @@ -37,6 +37,7 @@ #include <vcl/toolbox.hxx> #include <svl/aeitem.hxx> #include <svx/svdview.hxx> +#include <svx/transfrmhelper.hxx> using namespace css; using namespace css::uno; @@ -949,10 +950,6 @@ void PosSizePropertyPanel::executePosX() lX = -lX; long lY = GetCoreValue( *mpMtrPosY, mePoolUnit ); - Rectangle aRect; - maRect = mpView->GetAllMarkedRect(); - aRect = mpView->GetAllMarkedRect(); - Fraction aUIScale = mpView->GetModel()->GetUIScale(); lX += maAnchorPos.X(); lX = Fraction( lX ) * aUIScale; @@ -976,10 +973,6 @@ void PosSizePropertyPanel::executePosY() long lX = GetCoreValue( *mpMtrPosX, mePoolUnit ); long lY = GetCoreValue( *mpMtrPosY, mePoolUnit ); - Rectangle aRect; - maRect = mpView->GetAllMarkedRect(); - aRect = mpView->GetAllMarkedRect(); - Fraction aUIScale = mpView->GetModel()->GetUIScale(); lX += maAnchorPos.X(); lX = Fraction( lX ) * aUIScale; @@ -1018,6 +1011,7 @@ void PosSizePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* SetFieldUnit( *mpMtrPosY, meDlgUnit, true ); if(bPosYBlank) mpMtrPosY->SetText(OUString()); + SetPosXYMinMax(); if (mpMtrWidth->GetText().isEmpty()) bWidthBlank = true; @@ -1153,8 +1147,49 @@ void PosSizePropertyPanel::DisableControls() } } - - +void PosSizePropertyPanel::SetPosXYMinMax() +{ + Rectangle aTmpRect(mpView->GetAllMarkedRect()); + mpView->GetSdrPageView()->LogicToPagePos(aTmpRect); + maRect = basegfx::B2DRange(aTmpRect.Left(), aTmpRect.Top(), aTmpRect.Right(), aTmpRect.Bottom()); + + Rectangle aTmpRect2(mpView->GetWorkArea()); + mpView->GetSdrPageView()->LogicToPagePos(aTmpRect2); + maWorkArea = basegfx::B2DRange(aTmpRect2.Left(), aTmpRect2.Top(), aTmpRect2.Right(), aTmpRect2.Bottom()); + + const Fraction aUIScale(mpView->GetModel()->GetUIScale()); + TransfrmHelper::ScaleRect( maWorkArea, aUIScale ); + TransfrmHelper::ScaleRect( maRect, aUIScale ); + + const sal_uInt16 nDigits(mpMtrPosX->GetDecimalDigits()); + TransfrmHelper::ConvertRect( maWorkArea, nDigits, (MapUnit) mePoolUnit, meDlgUnit ); + TransfrmHelper::ConvertRect( maRect, nDigits, (MapUnit) mePoolUnit, meDlgUnit ); + + double fLeft(maWorkArea.getMinX()); + double fTop(maWorkArea.getMinY()); + double fRight(maWorkArea.getMaxX()); + double fBottom(maWorkArea.getMaxY()); + + // seems that sidebar defaults to top left reference point + // and there's no way to set it to something else + fRight -= maRect.getWidth(); + fBottom -= maRect.getHeight(); + + const double fMaxLong((double)(MetricField::ConvertValue( LONG_MAX, 0, MAP_100TH_MM, meDlgUnit ) - 1L)); + fLeft = basegfx::clamp(fLeft, -fMaxLong, fMaxLong); + fRight = basegfx::clamp(fRight, -fMaxLong, fMaxLong); + fTop = basegfx::clamp(fTop, - fMaxLong, fMaxLong); + fBottom = basegfx::clamp(fBottom, -fMaxLong, fMaxLong); + + mpMtrPosX->SetMin(basegfx::fround64(fLeft)); + mpMtrPosX->SetFirst(basegfx::fround64(fLeft)); + mpMtrPosX->SetMax(basegfx::fround64(fRight)); + mpMtrPosX->SetLast(basegfx::fround64(fRight)); + mpMtrPosY->SetMin(basegfx::fround64(fTop)); + mpMtrPosY->SetFirst(basegfx::fround64(fTop)); + mpMtrPosY->SetMax(basegfx::fround64(fBottom)); + mpMtrPosY->SetLast(basegfx::fround64(fBottom)); +} void PosSizePropertyPanel::UpdateUIScale() { diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx index e9880c46974f..a0b39cd2c5e1 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx @@ -30,6 +30,7 @@ #include <tools/fldunit.hxx> #include <tools/fract.hxx> #include <com/sun/star/ui/XSidebar.hpp> +#include <basegfx/range/b2drange.hxx> class DialControl; class SdrView; @@ -95,7 +96,8 @@ private: ToolBox* mpFlipTbx; // Internal variables - Rectangle maRect; + basegfx::B2DRange maRect; + basegfx::B2DRange maWorkArea; const SdrView* mpView; sal_uInt32 mlOldWidth; sal_uInt32 mlOldHeight; @@ -163,6 +165,7 @@ private: void MetricState( SfxItemState eState, const SfxPoolItem* pState ); FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState ); void DisableControls(); + void SetPosXYMinMax(); /** Check if the UI scale has changed and handle such a change. UI scale is an SD only feature. The UI scale is represented by items |