| 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" |
| 21 |
#include <chartview/ChartSfxItemIds.hxx> |
| 22 |
|
| 23 |
#include <svl/eitem.hxx> |
| 24 |
#include <svx/sdangitm.hxx> |
| 25 |
#include <officecfg/Office/Compatibility.hxx> |
| 26 |
|
| 27 |
namespace chart |
| 28 |
{ |
| 29 |
|
| 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)) |
| 39 |
{ |
| 40 |
m_xAngleDial->SetLinkedField(m_xNF_StartingAngle.get()); |
| 41 |
} |
| 42 |
|
| 43 |
PolarOptionsTabPage::~PolarOptionsTabPage() |
| 44 |
{ |
| 45 |
m_xAngleDialWin.reset(); |
| 46 |
m_xAngleDial.reset(); |
| 47 |
} |
| 48 |
|
| 49 |
std::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 |
|
| 54 |
bool PolarOptionsTabPage::FillItemSet( SfxItemSet* rOutAttrs ) |
| 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()) |
| 65 |
rOutAttrs->Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_xCB_IncludeHiddenCells->get_active())); |
| 66 |
|
| 67 |
return true; |
| 68 |
} |
| 69 |
|
| 70 |
void PolarOptionsTabPage::Reset(const SfxItemSet* rInAttrs) |
| 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: */ |