workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / cui / source / tabpages / TextColumnsPage.cxx
blob5723258ad8eee457c2c5fad81dacd6267ab3b34d
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.
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 */
10 #include <sal/config.h>
12 #include <svtools/unitconv.hxx>
13 #include <svx/dlgutil.hxx>
14 #include <svx/sdmetitm.hxx>
15 #include <svx/svddef.hxx>
17 #include <TextColumnsPage.hxx>
19 const WhichRangesContainer
20 SvxTextColumnsPage::pRanges(svl::Items<SDRATTR_TEXTCOLUMNS_FIRST, SDRATTR_TEXTCOLUMNS_LAST>);
22 SvxTextColumnsPage::SvxTextColumnsPage(weld::Container* pPage, weld::DialogController* pController,
23 const SfxItemSet& rInAttrs)
24 : SfxTabPage(pPage, pController, u"cui/ui/textcolumnstabpage.ui"_ustr, u"TextColumnsPage"_ustr,
25 &rInAttrs)
26 , m_xColumnsNumber(m_xBuilder->weld_spin_button(u"FLD_COL_NUMBER"_ustr))
27 , m_xColumnsSpacing(m_xBuilder->weld_metric_spin_button(u"MTR_FLD_COL_SPACING"_ustr,
28 GetModuleFieldUnit(rInAttrs)))
32 SvxTextColumnsPage::~SvxTextColumnsPage() = default;
34 // read the passed item set
35 void SvxTextColumnsPage::Reset(const SfxItemSet* rAttrs)
37 SfxItemPool* pPool = rAttrs->GetPool();
38 assert(pPool);
41 auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_NUMBER);
42 if (!pItem)
43 pItem = &pPool->GetUserOrPoolDefaultItem(SDRATTR_TEXTCOLUMNS_NUMBER);
44 m_xColumnsNumber->set_value(pItem->GetValue());
45 m_xColumnsNumber->save_value();
49 MapUnit eUnit = pPool->GetMetric(SDRATTR_TEXTCOLUMNS_SPACING);
50 auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_SPACING);
51 if (!pItem)
52 pItem = &pPool->GetUserOrPoolDefaultItem(SDRATTR_TEXTCOLUMNS_SPACING);
53 SetMetricValue(*m_xColumnsSpacing, pItem->GetValue(), eUnit);
54 m_xColumnsSpacing->save_value();
58 // fill the passed item set with dialog box attributes
59 bool SvxTextColumnsPage::FillItemSet(SfxItemSet* rAttrs)
61 if (m_xColumnsNumber->get_value_changed_from_saved())
62 rAttrs->Put(SfxInt16Item(SDRATTR_TEXTCOLUMNS_NUMBER, m_xColumnsNumber->get_value()));
64 if (m_xColumnsSpacing->get_value_changed_from_saved())
66 SfxItemPool* pPool = rAttrs->GetPool();
67 assert(pPool);
68 MapUnit eUnit = pPool->GetMetric(SDRATTR_TEXTCOLUMNS_SPACING);
69 sal_Int32 nValue = GetCoreValue(*m_xColumnsSpacing, eUnit);
70 rAttrs->Put(SdrMetricItem(SDRATTR_TEXTCOLUMNS_SPACING, nValue));
73 return true;
76 std::unique_ptr<SfxTabPage> SvxTextColumnsPage::Create(weld::Container* pPage,
77 weld::DialogController* pController,
78 const SfxItemSet* rAttrs)
80 return std::make_unique<SvxTextColumnsPage>(pPage, pController, *rAttrs);
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */