summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-23 14:15:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-28 14:02:20 +0200
commit4883fd31141c3598b25a123033297f847cd18552 (patch)
tree2558d6a498a3466ab04a5b81e7289099766a6695 /svx
parentf66510f1da3ab0584cd13e55f59728f7a2f2f488 (diff)
weld ScTabBgColorDlg
Change-Id: I864382bc55dead850c13faae9958fb660fd4f156 Reviewed-on: https://gerrit.libreoffice.org/54809 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/SvxColorValueSet.cxx74
1 files changed, 74 insertions, 0 deletions
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index b56fd4d7be12..62e2dc8a596e 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -29,6 +29,11 @@ SvxColorValueSet::SvxColorValueSet(vcl::Window* _pParent, WinBits nWinStyle)
SetEdgeBlending(true);
}
+ColorValueSet::ColorValueSet()
+{
+ SetEdgeBlending(true);
+}
+
VCL_BUILDER_FACTORY_CONSTRUCTOR(SvxColorValueSet, WB_TABSTOP)
sal_uInt32 SvxColorValueSet::getMaxRowCount()
@@ -71,6 +76,25 @@ void SvxColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sa
}
}
+void ColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex)
+{
+ const sal_uInt32 nColorCount(rXColorList.Count());
+
+ for(sal_uInt32 nIndex(0); nIndex < nColorCount; nIndex++, nStartIndex++)
+ {
+ const XColorEntry* pEntry = rXColorList.GetColor(nIndex);
+
+ if(pEntry)
+ {
+ InsertItem(nStartIndex, pEntry->GetColor(), pEntry->GetName());
+ }
+ else
+ {
+ OSL_ENSURE(false, "OOps, XColorList with empty entries (!)");
+ }
+ }
+}
+
void SvxColorValueSet::addEntriesForColorSet(const std::set<Color>& rColorSet, const OUString& rNamePrefix)
{
sal_uInt32 nStartIndex = 1;
@@ -126,6 +150,12 @@ void SvxColorValueSet::Resize()
ValueSet::Resize();
}
+void ColorValueSet::Resize()
+{
+ layoutToGivenHeight(GetOutputSizePixel().Height(), GetItemCount());
+ SvtValueSet::Resize();
+}
+
Size SvxColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount)
{
if(!nEntryCount)
@@ -170,4 +200,48 @@ Size SvxColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntry
return aNewSize;
}
+Size ColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount)
+{
+ if(!nEntryCount)
+ {
+ nEntryCount++;
+ }
+
+ const Size aItemSize(SvxColorValueSet::getEntryEdgeLength() - 2, SvxColorValueSet::getEntryEdgeLength() - 2);
+ const WinBits aWinBits(GetStyle() & ~WB_VSCROLL);
+
+ // get size with all fields disabled
+ const WinBits aWinBitsNoScrollNoFields(GetStyle() & ~(WB_VSCROLL|WB_NAMEFIELD|WB_NONEFIELD));
+ SetStyle(aWinBitsNoScrollNoFields);
+ const Size aSizeNoScrollNoFields(CalcWindowSizePixel(aItemSize, SvxColorValueSet::getColumnCount()));
+
+ // get size with all needed fields
+ SetStyle(aWinBits);
+ Size aNewSize(CalcWindowSizePixel(aItemSize, SvxColorValueSet::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 + aItemSizePixel.Height() - 1 : 0);
+
+ // calculate how many lines can be shown there
+ const sal_uInt32 nLineCount(nAvailableHeight / aItemSizePixel.Height());
+ const sal_uInt32 nLineMax(ceil(double(nEntryCount)/SvxColorValueSet::getColumnCount()));
+
+ if(nLineMax > nLineCount)
+ {
+ SetStyle(aWinBits|WB_VSCROLL);
+ }
+
+ // set height to wanted height
+ aNewSize.setHeight( nHeight );
+
+ SetItemWidth(aItemSize.Width());
+ SetItemHeight(aItemSize.Height());
+ SetColCount(SvxColorValueSet::getColumnCount());
+ SetLineCount(nLineCount);
+
+ return aNewSize;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */