1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "tp_PolarOptions.hxx"
21 #include <chartview/ChartSfxItemIds.hxx>
23 #include <svl/eitem.hxx>
24 #include <svl/intitem.hxx>
29 PolarOptionsTabPage::PolarOptionsTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rInAttrs
)
30 : SfxTabPage(pPage
, pController
, "modules/schart/ui/tp_PolarOptions.ui", "tp_PolarOptions", &rInAttrs
)
31 , m_xCB_Clockwise(m_xBuilder
->weld_check_button("CB_CLOCKWISE"))
32 , m_xFL_StartingAngle(m_xBuilder
->weld_frame("frameANGLE"))
33 , m_xNF_StartingAngle(m_xBuilder
->weld_spin_button("NF_STARTING_ANGLE"))
34 , m_xFL_PlotOptions(m_xBuilder
->weld_frame("framePLOT_OPTIONS"))
35 , m_xCB_IncludeHiddenCells(m_xBuilder
->weld_check_button("CB_INCLUDE_HIDDEN_CELLS_POLAR"))
36 , m_xAngleDial(new weld::CustomWeld(*m_xBuilder
, "CT_ANGLE_DIAL", m_aAngleDial
))
38 m_aAngleDial
.SetLinkedField(m_xNF_StartingAngle
.get());
41 PolarOptionsTabPage::~PolarOptionsTabPage()
46 std::unique_ptr
<SfxTabPage
> PolarOptionsTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rOutAttrs
)
48 return std::make_unique
<PolarOptionsTabPage
>(pPage
, pController
, *rOutAttrs
);
51 bool PolarOptionsTabPage::FillItemSet( SfxItemSet
* rOutAttrs
)
53 if (m_xAngleDial
->get_visible())
55 rOutAttrs
->Put(SfxInt32Item(SCHATTR_STARTING_ANGLE
,
56 static_cast< sal_Int32
>(m_aAngleDial
.GetRotation()/100)));
59 if( m_xCB_Clockwise
->get_visible() )
60 rOutAttrs
->Put(SfxBoolItem(SCHATTR_CLOCKWISE
,m_xCB_Clockwise
->get_active()));
62 if (m_xCB_IncludeHiddenCells
->get_visible())
63 rOutAttrs
->Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS
, m_xCB_IncludeHiddenCells
->get_active()));
68 void PolarOptionsTabPage::Reset(const SfxItemSet
* rInAttrs
)
70 const SfxPoolItem
*pPoolItem
= nullptr;
72 if (rInAttrs
->GetItemState(SCHATTR_STARTING_ANGLE
, true, &pPoolItem
) == SfxItemState::SET
)
74 long nTmp
= static_cast<long>(static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue());
75 m_aAngleDial
.SetRotation( nTmp
*100 );
79 m_xFL_StartingAngle
->hide();
81 if (rInAttrs
->GetItemState(SCHATTR_CLOCKWISE
, true, &pPoolItem
) == SfxItemState::SET
)
83 bool bCheck
= static_cast< const SfxBoolItem
* >( pPoolItem
)->GetValue();
84 m_xCB_Clockwise
->set_active(bCheck
);
88 m_xCB_Clockwise
->hide();
90 if (rInAttrs
->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS
, true, &pPoolItem
) == SfxItemState::SET
)
92 bool bVal
= static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue();
93 m_xCB_IncludeHiddenCells
->set_active(bVal
);
97 m_xFL_PlotOptions
->hide();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */