1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sfx2/dispatch.hxx>
21 #include <svl/intitem.hxx>
22 #include <svl/eitem.hxx>
23 #include <vcl/svapp.hxx>
24 #include <splitcelldlg.hxx>
26 SvxSplitTableDlg::SvxSplitTableDlg(weld::Window
*pParent
, bool bIsTableVertical
, long nMaxVertical
, long nMaxHorizontal
)
27 : GenericDialogController(pParent
, "cui/ui/splitcellsdialog.ui", "SplitCellsDialog")
28 , m_xCountEdit(m_xBuilder
->weld_spin_button("countnf"))
29 , m_xHorzBox(!bIsTableVertical
? m_xBuilder
->weld_radio_button("hori") : m_xBuilder
->weld_radio_button("vert"))
30 , m_xVertBox(!bIsTableVertical
? m_xBuilder
->weld_radio_button("vert") : m_xBuilder
->weld_radio_button("hori"))
31 , m_xPropCB(m_xBuilder
->weld_check_button("prop"))
32 , mnMaxVertical(nMaxVertical
)
33 , mnMaxHorizontal(nMaxHorizontal
)
35 m_xHorzBox
->connect_clicked(LINK(this, SvxSplitTableDlg
, ClickHdl
));
36 m_xPropCB
->connect_clicked(LINK(this, SvxSplitTableDlg
, ClickHdl
));
37 m_xVertBox
->connect_clicked(LINK(this, SvxSplitTableDlg
, ClickHdl
));
39 if (mnMaxVertical
< 2)
41 if (!bIsTableVertical
)
42 m_xVertBox
->set_sensitive(false);
44 m_xHorzBox
->set_sensitive(false);
47 //exchange the meaning of horizontal and vertical for vertical text
50 int nHorzTopAttach
= m_xHorzBox
->get_grid_top_attach();
51 int nVertTopAttach
= m_xVertBox
->get_grid_top_attach();
52 m_xHorzBox
->set_grid_top_attach(nVertTopAttach
);
53 m_xVertBox
->set_grid_top_attach(nHorzTopAttach
);
54 m_xHorzBox
->set_active(m_xVertBox
->get_active());
58 IMPL_LINK(SvxSplitTableDlg
, ClickHdl
, weld::Button
&, rButton
, void)
60 const bool bIsVert
= &rButton
== m_xVertBox
.get();
61 long nMax
= bIsVert
? mnMaxVertical
: mnMaxHorizontal
;
62 m_xPropCB
->set_sensitive(!bIsVert
);
63 m_xCountEdit
->set_max(nMax
);
66 bool SvxSplitTableDlg::IsHorizontal() const
68 return m_xHorzBox
->get_active();
71 bool SvxSplitTableDlg::IsProportional() const
73 return m_xPropCB
->get_active() && m_xHorzBox
->get_active();
76 long SvxSplitTableDlg::GetCount() const
78 return m_xCountEdit
->get_value();
81 short SvxSplitTableDlg::Execute()
86 void SvxSplitTableDlg::SetSplitVerticalByDefault()
88 if( mnMaxVertical
>= 2 )
89 m_xVertBox
->set_active(true); // tdf#60242
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */