LibreOffice Module chart2 (master) 1
tp_PolarOptions.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "tp_PolarOptions.hxx"
22
23#include <svl/eitem.hxx>
24#include <svx/sdangitm.hxx>
25#include <officecfg/Office/Compatibility.hxx>
26
27namespace chart
28{
29
31 : SfxTabPage(pPage, pController, "modules/schart/ui/tp_PolarOptions.ui", "tp_PolarOptions", &rInAttrs)
32 , m_xCB_Clockwise(m_xBuilder->weld_check_button("CB_CLOCKWISE"))
33 , m_xFL_StartingAngle(m_xBuilder->weld_frame("frameANGLE"))
34 , m_xNF_StartingAngle(m_xBuilder->weld_metric_spin_button("NF_STARTING_ANGLE", FieldUnit::DEGREE))
35 , m_xFL_PlotOptions(m_xBuilder->weld_frame("framePLOT_OPTIONS"))
36 , m_xCB_IncludeHiddenCells(m_xBuilder->weld_check_button("CB_INCLUDE_HIDDEN_CELLS_POLAR"))
37 , m_xAngleDial(new svx::DialControl)
38 , m_xAngleDialWin(new weld::CustomWeld(*m_xBuilder, "CT_ANGLE_DIAL", *m_xAngleDial))
39{
40 m_xAngleDial->SetLinkedField(m_xNF_StartingAngle.get());
41}
42
44{
45 m_xAngleDialWin.reset();
46 m_xAngleDial.reset();
47}
48
49std::unique_ptr<SfxTabPage> PolarOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rOutAttrs)
50{
51 return std::make_unique<PolarOptionsTabPage>(pPage, pController, *rOutAttrs);
52}
53
55{
56 if (m_xAngleDialWin->get_visible())
57 {
58 rOutAttrs->Put(SdrAngleItem(SCHATTR_STARTING_ANGLE, m_xAngleDial->GetRotation()));
59 }
60
61 if( m_xCB_Clockwise->get_visible() )
62 rOutAttrs->Put(SfxBoolItem(SCHATTR_CLOCKWISE,m_xCB_Clockwise->get_active()));
63
64 if (m_xCB_IncludeHiddenCells->get_visible())
66
67 return true;
68}
69
71{
72 if (const SdrAngleItem* pAngleItem = rInAttrs->GetItemIfSet(SCHATTR_STARTING_ANGLE))
73 {
74 Degree100 nTmp = pAngleItem->GetValue();
75 m_xAngleDial->SetRotation( nTmp );
76 }
77 else
78 {
79 m_xFL_StartingAngle->hide();
80 }
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)))
85 {
86 bool bCheck = pClockWiseItem->GetValue();
87 m_xCB_Clockwise->set_active(bCheck);
88 }
89 else
90 {
91 m_xCB_Clockwise->hide();
92 }
93 if (const SfxBoolItem* pHiddenCellsItem = rInAttrs->GetItemIfSet(SCHATTR_INCLUDE_HIDDEN_CELLS))
94 {
95 bool bVal = pHiddenCellsItem->GetValue();
96 m_xCB_IncludeHiddenCells->set_active(bVal);
97 }
98 else
99 {
100 m_xFL_PlotOptions->hide();
101 }
102}
103
104} //namespace chart
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SfxBoolItem > SCHATTR_CLOCKWISE(SCHATTR_CHARTTYPE_START+8)
constexpr TypedWhichId< SdrAngleItem > SCHATTR_STARTING_ANGLE(SCHATTR_CHARTTYPE_START+7)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_INCLUDE_HIDDEN_CELLS(SCHATTR_CHARTTYPE_START+11)
bool GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< svx::DialControl > m_xAngleDial
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rInAttrs)
virtual void Reset(const SfxItemSet *rInAttrs) override
std::unique_ptr< weld::Frame > m_xFL_PlotOptions
PolarOptionsTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
std::unique_ptr< weld::MetricSpinButton > m_xNF_StartingAngle
virtual ~PolarOptionsTabPage() override
std::unique_ptr< weld::CustomWeld > m_xAngleDialWin
virtual bool FillItemSet(SfxItemSet *rOutAttrs) override
std::unique_ptr< weld::Frame > m_xFL_StartingAngle
std::unique_ptr< weld::CheckButton > m_xCB_IncludeHiddenCells
std::unique_ptr< weld::CheckButton > m_xCB_Clockwise
FieldUnit