tdf#164393 Change themes UI as per UX feedback
[LibreOffice.git] / svx / source / dialog / spacinglistbox.cxx
blob90cc689ccc6fa3003016ab4296c1b54e79dddcb9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/dialmgr.hxx>
21 #include <svx/spacinglistbox.hxx>
22 #include <unotools/localedatawrapper.hxx>
23 #include <vcl/settings.hxx>
24 #include <vcl/svapp.hxx>
25 #include <spacing.hrc>
27 namespace SpacingListBox
29 void Fill(SpacingType eType, weld::ComboBox& rComboBox)
31 auto nSelected = rComboBox.get_active();
32 if (nSelected == -1)
33 nSelected = 0;
34 rComboBox.clear();
36 const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper();
37 OUString sSuffix;
39 const measurement* pResources;
40 switch (eType)
42 case SpacingType::SPACING_INCH:
43 pResources = RID_SVXSTRARY_SPACING_INCH;
44 sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
45 break;
46 case SpacingType::MARGINS_INCH:
47 pResources = RID_SVXSTRARY_MARGINS_INCH;
48 sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
49 break;
50 case SpacingType::SPACING_CM:
51 pResources = RID_SVXSTRARY_SPACING_CM;
52 sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
53 break;
54 default:
55 case SpacingType::MARGINS_CM:
56 sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
57 pResources = RID_SVXSTRARY_MARGINS_CM;
58 break;
61 while (pResources->key)
63 OUString sMeasurement = rLocaleData.getNum(pResources->human, 2, true, false) + sSuffix;
64 OUString aStr = SvxResId(pResources->key).replaceFirst("%1", sMeasurement);
65 sal_uInt32 nData = pResources->twips;
66 rComboBox.append(OUString::number(nData), aStr);
67 ++pResources;
70 rComboBox.set_active(nSelected);
72 rComboBox.set_size_request(150, -1);
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */