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_TitleRotation.hxx"
22 #include <chartview/ChartSfxItemIds.hxx>
23 #include <TextDirectionListBox.hxx>
25 #include <editeng/eeitem.hxx>
26 #include <editeng/frmdiritem.hxx>
27 #include <svx/sdangitm.hxx>
32 SchAlignmentTabPage::SchAlignmentTabPage(weld::Container
* pPage
, weld::DialogController
* pController
,
33 const SfxItemSet
& rInAttrs
, bool bWithRotation
)
34 : SfxTabPage(pPage
, pController
, u
"modules/schart/ui/titlerotationtabpage.ui"_ustr
, u
"TitleRotationTabPage"_ustr
, &rInAttrs
)
35 , m_xFtRotate(m_xBuilder
->weld_label(u
"degreeL"_ustr
))
36 , m_xNfRotate(m_xBuilder
->weld_metric_spin_button(u
"OrientDegree"_ustr
, FieldUnit::DEGREE
))
37 , m_xCbStacked(m_xBuilder
->weld_check_button(u
"stackedCB"_ustr
))
38 , m_xFtABCD(m_xBuilder
->weld_label(u
"labelABCD"_ustr
))
39 , m_aLbTextDirection(m_xBuilder
->weld_combo_box(u
"textdirLB"_ustr
))
40 , m_xCtrlDial(new svx::DialControl
)
41 , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder
, u
"dialCtrl"_ustr
, *m_xCtrlDial
))
43 m_xCtrlDial
->SetLinkedField(m_xNfRotate
.get());
44 m_xCtrlDial
->SetText(m_xFtABCD
->get_label());
45 m_xCbStacked
->connect_toggled(LINK(this, SchAlignmentTabPage
, StackedToggleHdl
));
47 m_xCtrlDialWin
->set_sensitive(true);
48 m_xNfRotate
->set_sensitive(true);
49 m_xCbStacked
->set_sensitive(true);
50 m_xFtRotate
->set_sensitive(true);
54 m_xCtrlDialWin
->hide();
61 IMPL_LINK_NOARG(SchAlignmentTabPage
, StackedToggleHdl
, weld::Toggleable
&, void)
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
);
70 SchAlignmentTabPage::~SchAlignmentTabPage()
72 m_xCtrlDialWin
.reset();
76 std::unique_ptr
<SfxTabPage
> SchAlignmentTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
77 const SfxItemSet
* rInAttrs
)
79 return std::make_unique
<SchAlignmentTabPage
>(pPage
, pController
, *rInAttrs
);
82 std::unique_ptr
<SfxTabPage
> SchAlignmentTabPage::CreateWithoutRotation(weld::Container
* pPage
, weld::DialogController
* pController
,
83 const SfxItemSet
* rInAttrs
)
85 return std::make_unique
<SchAlignmentTabPage
>(pPage
, pController
, *rInAttrs
, false);
88 bool SchAlignmentTabPage::FillItemSet(SfxItemSet
* rOutAttrs
)
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
) );
94 Degree100 nDegrees
= bStacked
? 0_deg100
: m_xCtrlDial
->GetRotation();
95 rOutAttrs
->Put( SdrAngleItem( SCHATTR_TEXT_DEGREES
, nDegrees
) );
97 SvxFrameDirection
aDirection( m_aLbTextDirection
.get_active_id() );
98 rOutAttrs
->Put( SvxFrameDirectionItem( aDirection
, EE_PARA_WRITINGDIR
) );
103 void SchAlignmentTabPage::Reset(const SfxItemSet
* rInAttrs
)
105 const SfxPoolItem
* pItem
= GetItem( *rInAttrs
, SCHATTR_TEXT_DEGREES
);
107 Degree100 nDegrees
= pItem
? static_cast<const SdrAngleItem
*>(pItem
)->GetValue() : 0_deg100
;
108 m_xCtrlDial
->SetRotation( nDegrees
);
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
);
115 if( const SvxFrameDirectionItem
* pDirectionItem
= rInAttrs
->GetItemIfSet(EE_PARA_WRITINGDIR
) )
116 m_aLbTextDirection
.set_active_id(pDirectionItem
->GetValue());
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */