LibreOffice Module svx (master)  1
spacinglistbox.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <svx/dialmgr.hxx>
21 #include <svx/spacinglistbox.hxx>
23 #include <vcl/settings.hxx>
24 #include <vcl/svapp.hxx>
25 #include <spacing.hrc>
26 
27 namespace SpacingListBox
28 {
30  {
31  auto nSelected = rComboBox.get_active();
32  if (nSelected == -1)
33  nSelected = 0;
34  rComboBox.clear();
35 
37  OUString sSuffix;
38 
39  const measurement* pResources;
40  switch (eType)
41  {
43  pResources = RID_SVXSTRARY_SPACING_INCH;
44  sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
45  break;
47  pResources = RID_SVXSTRARY_MARGINS_INCH;
48  sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
49  break;
51  pResources = RID_SVXSTRARY_SPACING_CM;
52  sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
53  break;
54  default:
56  sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
57  pResources = RID_SVXSTRARY_MARGINS_CM;
58  break;
59  }
60 
61  while (pResources->key)
62  {
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;
68  }
69 
70  rComboBox.set_active(nSelected);
71 
72  rComboBox.set_size_request(150, -1);
73  }
74 }
75 
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const LocaleDataWrapper & GetLocaleDataWrapper() const
static const AllSettings & GetSettings()
void append(const OUString &rId, const OUString &rStr)
virtual int get_active() const =0
static OUString MetricToString(FieldUnit rUnit)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
OUString sSuffix
SpacingType
void Fill(SpacingType eType, weld::ComboBox &rComboBox)
virtual void set_active(int pos)=0
virtual void clear()=0
DocumentType const eType
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
Custom Widget ListBox to hold entries for Spacing & Margin settings of Header/Footer.
virtual void set_size_request(int nWidth, int nHeight)=0
aStr