LibreOffice Module cui (master)  1
TextColumnsPage.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 
10 #include <sal/config.h>
11 
12 #include <svtools/unitconv.hxx>
13 #include <svx/dlgutil.hxx>
14 #include <svx/sdmetitm.hxx>
15 #include <svx/svddef.hxx>
16 
17 #include <TextColumnsPage.hxx>
18 
20  SvxTextColumnsPage::pRanges(svl::Items<SDRATTR_TEXTCOLUMNS_FIRST, SDRATTR_TEXTCOLUMNS_LAST>);
21 
23  const SfxItemSet& rInAttrs)
24  : SfxTabPage(pPage, pController, "cui/ui/textcolumnstabpage.ui", "TextColumnsPage", &rInAttrs)
25  , m_xColumnsNumber(m_xBuilder->weld_spin_button("FLD_COL_NUMBER"))
26  , m_xColumnsSpacing(
27  m_xBuilder->weld_metric_spin_button("MTR_FLD_COL_SPACING", GetModuleFieldUnit(rInAttrs)))
28 {
29 }
30 
32 
33 // read the passed item set
35 {
36  SfxItemPool* pPool = rAttrs->GetPool();
37  assert(pPool);
38 
39  {
40  auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_NUMBER);
41  if (!pItem)
43  m_xColumnsNumber->set_value(pItem->GetValue());
44  m_xColumnsNumber->save_value();
45  }
46 
47  {
49  auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_SPACING);
50  if (!pItem)
52  SetMetricValue(*m_xColumnsSpacing, pItem->GetValue(), eUnit);
53  m_xColumnsSpacing->save_value();
54  }
55 }
56 
57 // fill the passed item set with dialog box attributes
59 {
60  if (m_xColumnsNumber->get_value_changed_from_saved())
62 
63  if (m_xColumnsSpacing->get_value_changed_from_saved())
64  {
65  SfxItemPool* pPool = rAttrs->GetPool();
66  assert(pPool);
68  sal_Int32 nValue = GetCoreValue(*m_xColumnsSpacing, eUnit);
70  }
71 
72  return true;
73 }
74 
75 std::unique_ptr<SfxTabPage> SvxTextColumnsPage::Create(weld::Container* pPage,
76  weld::DialogController* pController,
77  const SfxItemSet* rAttrs)
78 {
79  return std::make_unique<SvxTextColumnsPage>(pPage, pController, *rAttrs);
80 }
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXTCOLUMNS_SPACING(SDRATTR_TEXTCOLUMNS_FIRST+1)
virtual void Reset(const SfxItemSet *) override
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
std::unique_ptr< weld::SpinButton > m_xColumnsNumber
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
SvxTextColumnsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
virtual ~SvxTextColumnsPage() override
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::MetricSpinButton > m_xColumnsSpacing
constexpr TypedWhichId< SfxInt16Item > SDRATTR_TEXTCOLUMNS_NUMBER(SDRATTR_TEXTCOLUMNS_FIRST+0)
MapUnit
virtual bool FillItemSet(SfxItemSet *) override
static const WhichRangesContainer pRanges
sal_Int16 nValue