summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svx/source/tbxctrls/SvxColorValueSet.cxx21
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx1
2 files changed, 10 insertions, 12 deletions
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index 4085912edf9f..11e90edc133e 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -162,22 +162,19 @@ Size SvxColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntry
SetStyle(aWinBits);
Size aNewSize(CalcWindowSizePixel(aItemSize, getColumnCount()));
- // evtl. activate vertical scroll
- const bool bAdaptHeight(static_cast< sal_uInt32 >(aNewSize.Height()) > nHeight);
-
- if(bAdaptHeight)
- {
- SetStyle(aWinBits|WB_VSCROLL);
- aNewSize = CalcWindowSizePixel(aItemSize, getColumnCount());
- }
-
+ const Size aItemSizePixel(CalcItemSizePixel(aItemSize));
// calculate field height and available height for requested height
const sal_uInt32 nFieldHeight(aNewSize.Height() - aSizeNoScrollNoFields.Height());
- const sal_uInt32 nAvailableHeight(nHeight >= nFieldHeight ? nHeight - nFieldHeight : 0);
+ const sal_uInt32 nAvailableHeight(nHeight >= nFieldHeight ? nHeight - nFieldHeight + aItemSizePixel.Height() - 1 : 0);
// calculate how many lines can be shown there
- const Size aItemSizePixel(CalcItemSizePixel(aItemSize));
- const sal_uInt32 nLineCount((nAvailableHeight + aItemSizePixel.Height() - 1) / aItemSizePixel.Height());
+ const sal_uInt32 nLineCount(nAvailableHeight / aItemSizePixel.Height());
+ const sal_uInt32 nLineMax(ceil(double(nEntryCount)/getColumnCount()));
+
+ if(nLineMax > nLineCount)
+ {
+ SetStyle(aWinBits|WB_VSCROLL);
+ }
// set height to wanted height
aNewSize.Height() = nHeight;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e5b0d1ae2c06..a0a9649e171d 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1270,6 +1270,7 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
sal_Int32 nPos = mpPaletteListBox->GetSelectEntryPos();
mrPaletteManager.SetPalette( nPos );
mrPaletteManager.ReloadColorSet(*mpColorSet);
+ mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount());
return 0;
}