summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/dialogs/res_Titles.cxx
blob: 59b0f00b9b377030fc2c5976bb0587e7e2108843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <res_Titles.hxx>
#include <TitleDialogData.hxx>
#include <vcl/weld.hxx>

namespace chart
{
TitleResources::TitleResources(weld::Builder& rBuilder, bool bShowSecondaryAxesTitle)
    : m_xFT_Main(rBuilder.weld_label("labelMainTitle"))
    , m_xFT_Sub(rBuilder.weld_label("labelSubTitle"))
    , m_xEd_Main(rBuilder.weld_entry("maintitle"))
    , m_xEd_Sub(rBuilder.weld_entry("subtitle"))
    , m_xFT_XAxis(rBuilder.weld_label("labelPrimaryXaxis"))
    , m_xFT_YAxis(rBuilder.weld_label("labelPrimaryYaxis"))
    , m_xFT_ZAxis(rBuilder.weld_label("labelPrimaryZaxis"))
    , m_xEd_XAxis(rBuilder.weld_entry("primaryXaxis"))
    , m_xEd_YAxis(rBuilder.weld_entry("primaryYaxis"))
    , m_xEd_ZAxis(rBuilder.weld_entry("primaryZaxis"))
    , m_xFT_SecondaryXAxis(rBuilder.weld_label("labelSecondaryXAxis"))
    , m_xFT_SecondaryYAxis(rBuilder.weld_label("labelSecondaryYAxis"))
    , m_xEd_SecondaryXAxis(rBuilder.weld_entry("secondaryXaxis"))
    , m_xEd_SecondaryYAxis(rBuilder.weld_entry("secondaryYaxis"))
{
    m_xFT_SecondaryXAxis->set_visible(bShowSecondaryAxesTitle);
    m_xFT_SecondaryYAxis->set_visible(bShowSecondaryAxesTitle);
    m_xEd_SecondaryXAxis->set_visible(bShowSecondaryAxesTitle);
    m_xEd_SecondaryYAxis->set_visible(bShowSecondaryAxesTitle);
}

TitleResources::~TitleResources() {}

void TitleResources::connect_changed(const Link<weld::Entry&, void>& rLink)
{
    m_xEd_Main->connect_changed(rLink);
    m_xEd_Sub->connect_changed(rLink);
    m_xEd_XAxis->connect_changed(rLink);
    m_xEd_YAxis->connect_changed(rLink);
    m_xEd_ZAxis->connect_changed(rLink);
    m_xEd_SecondaryXAxis->connect_changed(rLink);
    m_xEd_SecondaryYAxis->connect_changed(rLink);
}

bool TitleResources::get_value_changed_from_saved() const
{
    return m_xEd_Main->get_value_changed_from_saved() || m_xEd_Sub->get_value_changed_from_saved()
           || m_xEd_XAxis->get_value_changed_from_saved()
           || m_xEd_YAxis->get_value_changed_from_saved()
           || m_xEd_ZAxis->get_value_changed_from_saved()
           || m_xEd_SecondaryXAxis->get_value_changed_from_saved()
           || m_xEd_SecondaryYAxis->get_value_changed_from_saved();
}

void TitleResources::save_value()
{
    m_xEd_Main->save_value();
    m_xEd_Sub->save_value();
    m_xEd_XAxis->save_value();
    m_xEd_YAxis->save_value();
    m_xEd_ZAxis->save_value();
    m_xEd_SecondaryXAxis->save_value();
    m_xEd_SecondaryYAxis->save_value();
}

void TitleResources::writeToResources(const TitleDialogData& rInput)
{
    m_xFT_Main->set_sensitive(rInput.aPossibilityList[0]);
    m_xFT_Sub->set_sensitive(rInput.aPossibilityList[1]);
    m_xFT_XAxis->set_sensitive(rInput.aPossibilityList[2]);
    m_xFT_YAxis->set_sensitive(rInput.aPossibilityList[3]);
    m_xFT_ZAxis->set_sensitive(rInput.aPossibilityList[4]);
    m_xFT_SecondaryXAxis->set_sensitive(rInput.aPossibilityList[5]);
    m_xFT_SecondaryYAxis->set_sensitive(rInput.aPossibilityList[6]);

    m_xEd_Main->set_sensitive(rInput.aPossibilityList[0]);
    m_xEd_Sub->set_sensitive(rInput.aPossibilityList[1]);
    m_xEd_XAxis->set_sensitive(rInput.aPossibilityList[2]);
    m_xEd_YAxis->set_sensitive(rInput.aPossibilityList[3]);
    m_xEd_ZAxis->set_sensitive(rInput.aPossibilityList[4]);
    m_xEd_SecondaryXAxis->set_sensitive(rInput.aPossibilityList[5]);
    m_xEd_SecondaryYAxis->set_sensitive(rInput.aPossibilityList[6]);

    m_xEd_Main->set_text(rInput.aTextList[0]);
    m_xEd_Sub->set_text(rInput.aTextList[1]);
    m_xEd_XAxis->set_text(rInput.aTextList[2]);
    m_xEd_YAxis->set_text(rInput.aTextList[3]);
    m_xEd_ZAxis->set_text(rInput.aTextList[4]);
    m_xEd_SecondaryXAxis->set_text(rInput.aTextList[5]);
    m_xEd_SecondaryYAxis->set_text(rInput.aTextList[6]);
}

void TitleResources::readFromResources(TitleDialogData& rOutput)
{
    sal_Bool* pExistenceList = rOutput.aExistenceList.getArray();
    pExistenceList[0] = !m_xEd_Main->get_text().isEmpty();
    pExistenceList[1] = !m_xEd_Sub->get_text().isEmpty();
    pExistenceList[2] = !m_xEd_XAxis->get_text().isEmpty();
    pExistenceList[3] = !m_xEd_YAxis->get_text().isEmpty();
    pExistenceList[4] = !m_xEd_ZAxis->get_text().isEmpty();
    pExistenceList[5] = !m_xEd_SecondaryXAxis->get_text().isEmpty();
    pExistenceList[6] = !m_xEd_SecondaryYAxis->get_text().isEmpty();

    auto pTextList = rOutput.aTextList.getArray();
    pTextList[0] = m_xEd_Main->get_text();
    pTextList[1] = m_xEd_Sub->get_text();
    pTextList[2] = m_xEd_XAxis->get_text();
    pTextList[3] = m_xEd_YAxis->get_text();
    pTextList[4] = m_xEd_ZAxis->get_text();
    pTextList[5] = m_xEd_SecondaryXAxis->get_text();
    pTextList[6] = m_xEd_SecondaryYAxis->get_text();
}

} //namespace chart

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */