1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
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
, "cui/ui/textcolumnstabpage.ui", "TextColumnsPage", &rInAttrs
)
25 , m_xColumnsNumber(m_xBuilder
->weld_spin_button("FLD_COL_NUMBER"))
27 m_xBuilder
->weld_metric_spin_button("MTR_FLD_COL_SPACING", GetModuleFieldUnit(rInAttrs
)))
31 SvxTextColumnsPage::~SvxTextColumnsPage() = default;
33 // read the passed item set
34 void SvxTextColumnsPage::Reset(const SfxItemSet
* rAttrs
)
36 SfxItemPool
* pPool
= rAttrs
->GetPool();
40 auto pItem
= GetItem(*rAttrs
, SDRATTR_TEXTCOLUMNS_NUMBER
);
42 pItem
= &pPool
->GetDefaultItem(SDRATTR_TEXTCOLUMNS_NUMBER
);
43 m_xColumnsNumber
->set_value(pItem
->GetValue());
44 m_xColumnsNumber
->save_value();
48 MapUnit eUnit
= pPool
->GetMetric(SDRATTR_TEXTCOLUMNS_SPACING
);
49 auto pItem
= GetItem(*rAttrs
, SDRATTR_TEXTCOLUMNS_SPACING
);
51 pItem
= &pPool
->GetDefaultItem(SDRATTR_TEXTCOLUMNS_SPACING
);
52 SetMetricValue(*m_xColumnsSpacing
, pItem
->GetValue(), eUnit
);
53 m_xColumnsSpacing
->save_value();
57 // fill the passed item set with dialog box attributes
58 bool SvxTextColumnsPage::FillItemSet(SfxItemSet
* rAttrs
)
60 if (m_xColumnsNumber
->get_value_changed_from_saved())
61 rAttrs
->Put(SfxInt16Item(SDRATTR_TEXTCOLUMNS_NUMBER
, m_xColumnsNumber
->get_value()));
63 if (m_xColumnsSpacing
->get_value_changed_from_saved())
65 SfxItemPool
* pPool
= rAttrs
->GetPool();
67 MapUnit eUnit
= pPool
->GetMetric(SDRATTR_TEXTCOLUMNS_SPACING
);
68 sal_Int32 nValue
= GetCoreValue(*m_xColumnsSpacing
, eUnit
);
69 rAttrs
->Put(SdrMetricItem(SDRATTR_TEXTCOLUMNS_SPACING
, nValue
));
75 std::unique_ptr
<SfxTabPage
> SvxTextColumnsPage::Create(weld::Container
* pPage
,
76 weld::DialogController
* pController
,
77 const SfxItemSet
* rAttrs
)
79 return std::make_unique
<SvxTextColumnsPage
>(pPage
, pController
, *rAttrs
);
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */