tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / controller / dialogs / tp_PolarOptions.cxx
blobcb646e3266be67158152ffdf1dcdd629d36ae197
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 <svx/sdangitm.hxx>
25 #include <officecfg/Office/Compatibility.hxx>
27 namespace chart
30 PolarOptionsTabPage::PolarOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs)
31 : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_PolarOptions.ui"_ustr, u"tp_PolarOptions"_ustr, &rInAttrs)
32 , m_xCB_Clockwise(m_xBuilder->weld_check_button(u"CB_CLOCKWISE"_ustr))
33 , m_xFL_StartingAngle(m_xBuilder->weld_frame(u"frameANGLE"_ustr))
34 , m_xNF_StartingAngle(m_xBuilder->weld_metric_spin_button(u"NF_STARTING_ANGLE"_ustr, FieldUnit::DEGREE))
35 , m_xFL_PlotOptions(m_xBuilder->weld_frame(u"framePLOT_OPTIONS"_ustr))
36 , m_xCB_IncludeHiddenCells(m_xBuilder->weld_check_button(u"CB_INCLUDE_HIDDEN_CELLS_POLAR"_ustr))
37 , m_xAngleDial(new svx::DialControl)
38 , m_xAngleDialWin(new weld::CustomWeld(*m_xBuilder, u"CT_ANGLE_DIAL"_ustr, *m_xAngleDial))
40 m_xAngleDial->SetLinkedField(m_xNF_StartingAngle.get());
43 PolarOptionsTabPage::~PolarOptionsTabPage()
45 m_xAngleDialWin.reset();
46 m_xAngleDial.reset();
49 std::unique_ptr<SfxTabPage> PolarOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rOutAttrs)
51 return std::make_unique<PolarOptionsTabPage>(pPage, pController, *rOutAttrs);
54 bool PolarOptionsTabPage::FillItemSet( SfxItemSet* rOutAttrs )
56 if (m_xAngleDialWin->get_visible())
58 rOutAttrs->Put(SdrAngleItem(SCHATTR_STARTING_ANGLE, m_xAngleDial->GetRotation()));
61 if( m_xCB_Clockwise->get_visible() )
62 rOutAttrs->Put(SfxBoolItem(SCHATTR_CLOCKWISE,m_xCB_Clockwise->get_active()));
64 if (m_xCB_IncludeHiddenCells->get_visible())
65 rOutAttrs->Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_xCB_IncludeHiddenCells->get_active()));
67 return true;
70 void PolarOptionsTabPage::Reset(const SfxItemSet* rInAttrs)
72 if (const SdrAngleItem* pAngleItem = rInAttrs->GetItemIfSet(SCHATTR_STARTING_ANGLE))
74 Degree100 nTmp = pAngleItem->GetValue();
75 m_xAngleDial->SetRotation( nTmp );
77 else
79 m_xFL_StartingAngle->hide();
81 // tdf#108059 Hide clockwise orientation checkbox in OOXML-heavy environments it would be useless anyways
82 const SfxBoolItem* pClockWiseItem = nullptr;
83 if (!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get() &&
84 (pClockWiseItem = rInAttrs->GetItemIfSet(SCHATTR_CLOCKWISE)))
86 bool bCheck = pClockWiseItem->GetValue();
87 m_xCB_Clockwise->set_active(bCheck);
89 else
91 m_xCB_Clockwise->hide();
93 if (const SfxBoolItem* pHiddenCellsItem = rInAttrs->GetItemIfSet(SCHATTR_INCLUDE_HIDDEN_CELLS))
95 bool bVal = pHiddenCellsItem->GetValue();
96 m_xCB_IncludeHiddenCells->set_active(bVal);
98 else
100 m_xFL_PlotOptions->hide();
104 } //namespace chart
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */