diff options
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/spacinglistbox.cxx | 135 |
1 files changed, 39 insertions, 96 deletions
diff --git a/svx/source/dialog/spacinglistbox.cxx b/svx/source/dialog/spacinglistbox.cxx index ac31393b3a2f..4412e958c7ac 100644 --- a/svx/source/dialog/spacinglistbox.cxx +++ b/svx/source/dialog/spacinglistbox.cxx @@ -20,114 +20,57 @@ #include <svx/dialmgr.hxx> #include <svx/spacinglistbox.hxx> #include <unotools/localedatawrapper.hxx> -#include <vcl/builderfactory.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <vcl/weld.hxx> #include <spacing.hrc> -SpacingListBox::SpacingListBox(vcl::Window* pParent) - : ListBox( pParent, WB_BORDER | WB_DROPDOWN) +namespace SpacingListBox { -} - -void SpacingListBox::Init(SpacingType eType) -{ - auto nSelected = GetSelectedEntryPos(); - if (nSelected == LISTBOX_ENTRY_NOTFOUND) - nSelected = 0; - Clear(); - - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - OUString sSuffix; - - const measurement* pResources; - switch (eType) + void Fill(SpacingType eType, weld::ComboBox& rComboBox) { - case SpacingType::SPACING_INCH: - pResources = RID_SVXSTRARY_SPACING_INCH; - sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); - break; - case SpacingType::MARGINS_INCH: - pResources = RID_SVXSTRARY_MARGINS_INCH; - sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); - break; - case SpacingType::SPACING_CM: - pResources = RID_SVXSTRARY_SPACING_CM; - sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); - break; - default: - case SpacingType::MARGINS_CM: - sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); - pResources = RID_SVXSTRARY_MARGINS_CM; - break; - } - - while (pResources->key) - { - OUString sMeasurement = rLocaleData.getNum(pResources->human, 2, true, false) + sSuffix; - OUString aStr = SvxResId(pResources->key).replaceFirst("%1", sMeasurement); - sal_uInt16 nData = pResources->twips; - sal_Int32 nPos = InsertEntry( aStr ); - - SetEntryData( nPos, reinterpret_cast<void*>(static_cast<sal_uLong>(nData)) ); - ++pResources; - } + auto nSelected = rComboBox.get_active(); + if (nSelected == -1) + nSelected = 0; + rComboBox.clear(); - SetDropDownLineCount(8); - SelectEntryPos(nSelected); -} + const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); + OUString sSuffix; -void SpacingListBox::Fill(SpacingType eType, weld::ComboBox& rComboBox) -{ - auto nSelected = rComboBox.get_active(); - if (nSelected == -1) - nSelected = 0; - rComboBox.clear(); + const measurement* pResources; + switch (eType) + { + case SpacingType::SPACING_INCH: + pResources = RID_SVXSTRARY_SPACING_INCH; + sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); + break; + case SpacingType::MARGINS_INCH: + pResources = RID_SVXSTRARY_MARGINS_INCH; + sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); + break; + case SpacingType::SPACING_CM: + pResources = RID_SVXSTRARY_SPACING_CM; + sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); + break; + default: + case SpacingType::MARGINS_CM: + sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); + pResources = RID_SVXSTRARY_MARGINS_CM; + break; + } - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - OUString sSuffix; + while (pResources->key) + { + OUString sMeasurement = rLocaleData.getNum(pResources->human, 2, true, false) + sSuffix; + OUString aStr = SvxResId(pResources->key).replaceFirst("%1", sMeasurement); + sal_uInt32 nData = pResources->twips; + rComboBox.append(OUString::number(nData), aStr); + ++pResources; + } - const measurement* pResources; - switch (eType) - { - case SpacingType::SPACING_INCH: - pResources = RID_SVXSTRARY_SPACING_INCH; - sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); - break; - case SpacingType::MARGINS_INCH: - pResources = RID_SVXSTRARY_MARGINS_INCH; - sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH); - break; - case SpacingType::SPACING_CM: - pResources = RID_SVXSTRARY_SPACING_CM; - sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); - break; - default: - case SpacingType::MARGINS_CM: - sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM); - pResources = RID_SVXSTRARY_MARGINS_CM; - break; - } + rComboBox.set_active(nSelected); - while (pResources->key) - { - OUString sMeasurement = rLocaleData.getNum(pResources->human, 2, true, false) + sSuffix; - OUString aStr = SvxResId(pResources->key).replaceFirst("%1", sMeasurement); - sal_uInt32 nData = pResources->twips; - rComboBox.append(OUString::number(nData), aStr); - ++pResources; + rComboBox.set_size_request(150, -1); } - - rComboBox.set_active(nSelected); - - rComboBox.set_size_request(150, -1); } -VCL_BUILDER_FACTORY(SpacingListBox); - -Size SpacingListBox::GetOptimalSize() const -{ - return Size(150, ListBox::GetOptimalSize().Height()); -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |