Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/dialogs/tp_TitleRotation.cxx
Line
Count
Source
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
#include <tools/fldunit.hxx>
29
#include <vcl/weld/Builder.hxx>
30
#include <vcl/weld/CheckButton.hxx>
31
#include <vcl/weld/Label.hxx>
32
33
namespace chart
34
{
35
36
SchAlignmentTabPage::SchAlignmentTabPage(weld::Container* pPage, weld::DialogController* pController,
37
                                         const SfxItemSet& rInAttrs, bool bWithRotation)
38
0
    : SfxTabPage(pPage, pController, u"modules/schart/ui/titlerotationtabpage.ui"_ustr, u"TitleRotationTabPage"_ustr, &rInAttrs)
39
0
    , m_xFtRotate(m_xBuilder->weld_label(u"degreeL"_ustr))
40
0
    , m_xNfRotate(m_xBuilder->weld_metric_spin_button(u"OrientDegree"_ustr, FieldUnit::DEGREE))
41
0
    , m_xCbStacked(m_xBuilder->weld_check_button(u"stackedCB"_ustr))
42
0
    , m_xFtABCD(m_xBuilder->weld_label(u"labelABCD"_ustr))
43
0
    , m_aLbTextDirection(m_xBuilder->weld_combo_box(u"textdirLB"_ustr))
44
0
    , m_xCtrlDial(new svx::DialControl)
45
0
    , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, u"dialCtrl"_ustr, *m_xCtrlDial))
46
0
{
47
0
    m_xCtrlDial->SetLinkedField(m_xNfRotate.get());
48
0
    m_xCtrlDial->SetText(m_xFtABCD->get_label());
49
0
    m_xCbStacked->connect_toggled(LINK(this, SchAlignmentTabPage, StackedToggleHdl));
50
51
0
    m_xCtrlDialWin->set_sensitive(true);
52
0
    m_xNfRotate->set_sensitive(true);
53
0
    m_xCbStacked->set_sensitive(true);
54
0
    m_xFtRotate->set_sensitive(true);
55
56
0
    if( !bWithRotation )
57
0
    {
58
0
        m_xCtrlDialWin->hide();
59
0
        m_xNfRotate->hide();
60
0
        m_xCbStacked->hide();
61
0
        m_xFtRotate->hide();
62
0
    }
63
0
}
64
65
IMPL_LINK_NOARG(SchAlignmentTabPage, StackedToggleHdl, weld::Toggleable&, void)
66
0
{
67
0
    bool bActive = m_xCbStacked->get_active();
68
0
    m_xNfRotate->set_sensitive(!bActive);
69
0
    m_xCtrlDialWin->set_sensitive(!bActive);
70
0
    m_xCtrlDial->StyleUpdated();
71
0
    m_xFtRotate->set_sensitive(!bActive);
72
0
}
73
74
SchAlignmentTabPage::~SchAlignmentTabPage()
75
0
{
76
0
    m_xCtrlDialWin.reset();
77
0
    m_xCtrlDial.reset();
78
0
}
79
80
std::unique_ptr<SfxTabPage> SchAlignmentTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
81
                                               const SfxItemSet* rInAttrs)
82
0
{
83
0
    return std::make_unique<SchAlignmentTabPage>(pPage, pController, *rInAttrs);
84
0
}
85
86
std::unique_ptr<SfxTabPage> SchAlignmentTabPage::CreateWithoutRotation(weld::Container* pPage, weld::DialogController* pController,
87
                                                              const SfxItemSet* rInAttrs)
88
0
{
89
0
    return std::make_unique<SchAlignmentTabPage>(pPage, pController, *rInAttrs, false);
90
0
}
91
92
bool SchAlignmentTabPage::FillItemSet(SfxItemSet* rOutAttrs)
93
0
{
94
    //Since 04/1998 text can be rotated by an arbitrary angle: SCHATTR_TEXT_DEGREES
95
0
    bool bStacked = m_xCbStacked->get_active();
96
0
    rOutAttrs->Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) );
97
98
0
    Degree100 nDegrees = bStacked ? 0_deg100 : m_xCtrlDial->GetRotation();
99
0
    rOutAttrs->Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, nDegrees ) );
100
101
0
    SvxFrameDirection aDirection( m_aLbTextDirection.get_active_id() );
102
0
    rOutAttrs->Put( SvxFrameDirectionItem( aDirection, EE_PARA_WRITINGDIR ) );
103
104
0
    return true;
105
0
}
106
107
void SchAlignmentTabPage::Reset(const SfxItemSet* rInAttrs)
108
0
{
109
0
    const SdrAngleItem* pDegreesItem = GetItem( *rInAttrs, SCHATTR_TEXT_DEGREES );
110
111
0
    Degree100 nDegrees = pDegreesItem ? pDegreesItem->GetValue() : 0_deg100;
112
0
    m_xCtrlDial->SetRotation( nDegrees );
113
114
0
    const SfxBoolItem* pItem = GetItem( *rInAttrs, SCHATTR_TEXT_STACKED );
115
0
    bool bStacked = pItem && pItem->GetValue();
116
0
    m_xCbStacked->set_active(bStacked);
117
0
    StackedToggleHdl(*m_xCbStacked);
118
119
0
    if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet(EE_PARA_WRITINGDIR) )
120
0
        m_aLbTextDirection.set_active_id(pDirectionItem->GetValue());
121
0
}
122
123
} //namespace chart
124
125
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */