LibreOffice Module chart2 (master) 1
tp_TitleRotation.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_TitleRotation.hxx"
21
24
25#include <editeng/eeitem.hxx>
27#include <svx/sdangitm.hxx>
28
29namespace chart
30{
31
33 const SfxItemSet& rInAttrs, bool bWithRotation)
34 : SfxTabPage(pPage, pController, "modules/schart/ui/titlerotationtabpage.ui", "TitleRotationTabPage", &rInAttrs)
35 , m_xFtRotate(m_xBuilder->weld_label("degreeL"))
36 , m_xNfRotate(m_xBuilder->weld_metric_spin_button("OrientDegree", FieldUnit::DEGREE))
37 , m_xCbStacked(m_xBuilder->weld_check_button("stackedCB"))
38 , m_xFtABCD(m_xBuilder->weld_label("labelABCD"))
39 , m_aLbTextDirection(m_xBuilder->weld_combo_box("textdirLB"))
40 , m_xCtrlDial(new svx::DialControl)
41 , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, "dialCtrl", *m_xCtrlDial))
42{
43 m_xCtrlDial->SetLinkedField(m_xNfRotate.get());
44 m_xCtrlDial->SetText(m_xFtABCD->get_label());
45 m_xCbStacked->connect_toggled(LINK(this, SchAlignmentTabPage, StackedToggleHdl));
46
47 m_xCtrlDialWin->set_sensitive(true);
48 m_xNfRotate->set_sensitive(true);
49 m_xCbStacked->set_sensitive(true);
50 m_xFtRotate->set_sensitive(true);
51
52 if( !bWithRotation )
53 {
54 m_xCtrlDialWin->hide();
55 m_xNfRotate->hide();
56 m_xCbStacked->hide();
57 m_xFtRotate->hide();
58 }
59}
60
62{
63 bool bActive = m_xCbStacked->get_active();
64 m_xNfRotate->set_sensitive(!bActive);
65 m_xCtrlDialWin->set_sensitive(!bActive);
66 m_xCtrlDial->StyleUpdated();
67 m_xFtRotate->set_sensitive(!bActive);
68}
69
71{
72 m_xCtrlDialWin.reset();
73 m_xCtrlDial.reset();
74}
75
76std::unique_ptr<SfxTabPage> SchAlignmentTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
77 const SfxItemSet* rInAttrs)
78{
79 return std::make_unique<SchAlignmentTabPage>(pPage, pController, *rInAttrs);
80}
81
83 const SfxItemSet* rInAttrs)
84{
85 return std::make_unique<SchAlignmentTabPage>(pPage, pController, *rInAttrs, false);
86}
87
89{
90 //Since 04/1998 text can be rotated by an arbitrary angle: SCHATTR_TEXT_DEGREES
91 bool bStacked = m_xCbStacked->get_active();
92 rOutAttrs->Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
93
94 Degree100 nDegrees = bStacked ? 0_deg100 : m_xCtrlDial->GetRotation();
95 rOutAttrs->Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, nDegrees ) );
96
99
100 return true;
101}
102
104{
105 const SfxPoolItem* pItem = GetItem( *rInAttrs, SCHATTR_TEXT_DEGREES );
106
107 Degree100 nDegrees = pItem ? static_cast<const SdrAngleItem*>(pItem)->GetValue() : 0_deg100;
108 m_xCtrlDial->SetRotation( nDegrees );
109
110 pItem = GetItem( *rInAttrs, SCHATTR_TEXT_STACKED );
111 bool bStacked = pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue();
112 m_xCbStacked->set_active(bStacked);
113 StackedToggleHdl(*m_xCbStacked);
114
115 if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet(EE_PARA_WRITINGDIR) )
116 m_aLbTextDirection.set_active_id(pDirectionItem->GetValue());
117}
118
119} //namespace chart
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SfxBoolItem > SCHATTR_TEXT_STACKED(SCHATTR_TEXT_START+1)
constexpr TypedWhichId< SdrAngleItem > SCHATTR_TEXT_DEGREES(SCHATTR_TEXT_START)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
std::unique_ptr< weld::MetricSpinButton > m_xNfRotate
std::unique_ptr< weld::CheckButton > m_xCbStacked
static std::unique_ptr< SfxTabPage > CreateWithoutRotation(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rInAttrs)
TextDirectionListBox m_aLbTextDirection
std::unique_ptr< weld::CustomWeld > m_xCtrlDialWin
virtual bool FillItemSet(SfxItemSet *rOutAttrs) override
std::unique_ptr< weld::Label > m_xFtRotate
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rInAttrs)
SchAlignmentTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs, bool bWithRotation=true)
std::unique_ptr< weld::Label > m_xFtABCD
virtual void Reset(const SfxItemSet *rInAttrs) override
virtual ~SchAlignmentTabPage() override
std::unique_ptr< svx::DialControl > m_xCtrlDial
SvxFrameDirection get_active_id() const
void set_active_id(SvxFrameDirection eDir)
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
FieldUnit
SvxFrameDirection
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
const char GetValue[]
css::drawing::Direction3D aDirection