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 
22 SvxSplitTableDlg::SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, long nMaxVertical, 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_clicked(LINK(this, SvxSplitTableDlg, ClickHdl));
32  m_xPropCB->connect_clicked(LINK(this, SvxSplitTableDlg, ClickHdl));
33  m_xVertBox->connect_clicked(LINK(this, SvxSplitTableDlg, ClickHdl));
34 
35  if (mnMaxVertical < 2)
36  {
37  if (!bIsTableVertical)
38  m_xVertBox->set_sensitive(false);
39  else
40  m_xHorzBox->set_sensitive(false);
41  }
42 
43  //exchange the meaning of horizontal and vertical for vertical text
44  if (bIsTableVertical)
45  {
46  int nHorzTopAttach = m_xHorzBox->get_grid_top_attach();
47  int nVertTopAttach = m_xVertBox->get_grid_top_attach();
48  m_xHorzBox->set_grid_top_attach(nVertTopAttach);
49  m_xVertBox->set_grid_top_attach(nHorzTopAttach);
50  m_xHorzBox->set_active(m_xVertBox->get_active());
51  }
52 }
53 
54 IMPL_LINK(SvxSplitTableDlg, ClickHdl, weld::Button&, rButton, void)
55 {
56  const bool bIsVert = &rButton == m_xVertBox.get();
57  long nMax = bIsVert ? mnMaxVertical : mnMaxHorizontal;
58  m_xPropCB->set_sensitive(!bIsVert);
59  m_xCountEdit->set_max(nMax);
60 }
61 
63 {
64  return m_xHorzBox->get_active();
65 }
66 
68 {
69  return m_xPropCB->get_active() && m_xHorzBox->get_active();
70 }
71 
73 {
74  return m_xCountEdit->get_value();
75 }
76 
78 {
79  return run();
80 }
81 
83 {
84  if( mnMaxVertical >= 2 )
85  m_xVertBox->set_active(true); // tdf#60242
86 }
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool IsHorizontal() const override
std::unique_ptr< weld::CheckButton > m_xPropCB
std::unique_ptr< weld::RadioButton > m_xHorzBox
IMPL_LINK(SvxSplitTableDlg, ClickHdl, weld::Button &, rButton, void)
SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, long nMaxVertical, long nMaxHorizontal)
std::unique_ptr< weld::RadioButton > m_xVertBox
virtual bool IsProportional() const override
virtual void SetSplitVerticalByDefault() override
std::unique_ptr< weld::SpinButton > m_xCountEdit
virtual short run()
virtual long GetCount() const override
virtual short Execute() override