| 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 |
|
| 22 |
#include <chartview/ChartSfxItemIds.hxx> |
| 23 |
#include <TextDirectionListBox.hxx> |
| 24 |
|
| 25 |
#include <editeng/eeitem.hxx> |
| 26 |
#include <editeng/frmdiritem.hxx> |
| 27 |
#include <svx/sdangitm.hxx> |
| 28 |
|
| 29 |
namespace chart |
| 30 |
{ |
| 31 |
|
| 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)) |
| 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 |
|
| 61 |
IMPL_LINK_NOARG(SchAlignmentTabPage, StackedToggleHdl, weld::Toggleable&, void) |
| 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 |
|
| 70 |
SchAlignmentTabPage::~SchAlignmentTabPage() |
| 71 |
{ |
| 72 |
m_xCtrlDialWin.reset(); |
| 73 |
m_xCtrlDial.reset(); |
| 74 |
} |
| 75 |
|
| 76 |
std::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 |
|
| 82 |
std::unique_ptr<SfxTabPage> SchAlignmentTabPage::CreateWithoutRotation(weld::Container* pPage, weld::DialogController* pController, |
| 83 |
const SfxItemSet* rInAttrs) |
| 84 |
{ |
| 85 |
return std::make_unique<SchAlignmentTabPage>(pPage, pController, *rInAttrs, false); |
| 86 |
} |
| 87 |
|
| 88 |
bool SchAlignmentTabPage::FillItemSet(SfxItemSet* rOutAttrs) |
| 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 |
|
| 97 |
SvxFrameDirection aDirection( m_aLbTextDirection.get_active_id() ); |
| 98 |
rOutAttrs->Put( SvxFrameDirectionItem( aDirection, EE_PARA_WRITINGDIR ) ); |
| 99 |
|
| 100 |
return true; |
| 101 |
} |
| 102 |
|
| 103 |
void SchAlignmentTabPage::Reset(const SfxItemSet* rInAttrs) |
| 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: */ |