LibreOffice Module cui (master) 1
splitcelldlg.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 <splitcelldlg.hxx>
21
22SvxSplitTableDlg::SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, tools::Long nMaxVertical, tools::Long nMaxHorizontal)
23 : GenericDialogController(pParent, "cui/ui/splitcellsdialog.ui", "SplitCellsDialog")
24 , m_xCountEdit(m_xBuilder->weld_spin_button("countnf"))
25 , m_xHorzBox(!bIsTableVertical ? m_xBuilder->weld_radio_button("hori") : m_xBuilder->weld_radio_button("vert"))
26 , m_xVertBox(!bIsTableVertical ? m_xBuilder->weld_radio_button("vert") : m_xBuilder->weld_radio_button("hori"))
27 , m_xPropCB(m_xBuilder->weld_check_button("prop"))
28 , mnMaxVertical(nMaxVertical)
29 , mnMaxHorizontal(nMaxHorizontal)
30{
31 m_xHorzBox->connect_toggled(LINK(this, SvxSplitTableDlg, ToggleHdl));
32 m_xVertBox->connect_toggled(LINK(this, SvxSplitTableDlg, ToggleHdl));
33
34 if (mnMaxVertical < 2)
35 {
36 if (!bIsTableVertical)
37 m_xVertBox->set_sensitive(false);
38 else
39 m_xHorzBox->set_sensitive(false);
40 }
41
42 //exchange the meaning of horizontal and vertical for vertical text
43 if (bIsTableVertical)
44 {
45 int nHorzTopAttach = m_xHorzBox->get_grid_top_attach();
46 int nVertTopAttach = m_xVertBox->get_grid_top_attach();
47 m_xHorzBox->set_grid_top_attach(nVertTopAttach);
48 m_xVertBox->set_grid_top_attach(nHorzTopAttach);
49 m_xHorzBox->set_active(m_xVertBox->get_active());
50 }
51}
52
53IMPL_LINK(SvxSplitTableDlg, ToggleHdl, weld::Toggleable&, rButton, void)
54{
55 if (!rButton.get_active())
56 return;
57 const bool bIsVert = m_xVertBox->get_active();
58 tools::Long nMax = bIsVert ? mnMaxVertical : mnMaxHorizontal;
59 m_xPropCB->set_sensitive(!bIsVert);
60 m_xCountEdit->set_max(nMax);
61}
62
64{
65 return m_xHorzBox->get_active();
66}
67
69{
70 return m_xPropCB->get_active() && m_xHorzBox->get_active();
71}
72
74{
75 return m_xCountEdit->get_value();
76}
77
79{
80 if( mnMaxVertical >= 2 )
81 m_xVertBox->set_active(true); // tdf#60242
82}
83
85{
86 return m_xDlg->IsHorizontal();
87}
88
90{
91 return m_xDlg->IsProportional();
92}
93
95{
96 return m_xDlg->GetCount();
97}
98
100{
101 m_xDlg->SetSplitVerticalByDefault();
102}
103
105{
106 return m_xDlg->run();
107}
108
110{
111 return weld::DialogController::runAsync(m_xDlg, rContext.maEndDialogFn);
112}
113
114/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool IsHorizontal() const override
std::shared_ptr< SvxSplitTableDlg > m_xDlg
virtual void SetSplitVerticalByDefault() override
virtual tools::Long GetCount() const override
virtual bool IsProportional() const override
virtual bool StartExecuteAsync(AsyncContext &rContext) override
virtual short Execute() override
std::unique_ptr< weld::CheckButton > m_xPropCB
std::unique_ptr< weld::SpinButton > m_xCountEdit
std::unique_ptr< weld::RadioButton > m_xVertBox
void SetSplitVerticalByDefault()
SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, tools::Long nMaxVertical, tools::Long nMaxHorizontal)
bool IsProportional() const
tools::Long mnMaxVertical
std::unique_ptr< weld::RadioButton > m_xHorzBox
bool IsHorizontal() const
tools::Long GetCount() const
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
long Long
IMPL_LINK(SvxSplitTableDlg, ToggleHdl, weld::Toggleable &, rButton, void)