tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / cui / source / dialogs / splitcelldlg.cxx
bloba734b69e732a173b8f0922d184326e4704e7f7ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <splitcelldlg.hxx>
22 SvxSplitTableDlg::SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, tools::Long nMaxVertical, tools::Long nMaxHorizontal)
23 : GenericDialogController(pParent, u"cui/ui/splitcellsdialog.ui"_ustr, u"SplitCellsDialog"_ustr)
24 , m_xCountEdit(m_xBuilder->weld_spin_button(u"countnf"_ustr))
25 , m_xHorzBox(!bIsTableVertical ? m_xBuilder->weld_radio_button(u"hori"_ustr) : m_xBuilder->weld_radio_button(u"vert"_ustr))
26 , m_xVertBox(!bIsTableVertical ? m_xBuilder->weld_radio_button(u"vert"_ustr) : m_xBuilder->weld_radio_button(u"hori"_ustr))
27 , m_xPropCB(m_xBuilder->weld_check_button(u"prop"_ustr))
28 , mnMaxVertical(nMaxVertical)
29 , mnMaxHorizontal(nMaxHorizontal)
31 m_xHorzBox->connect_toggled(LINK(this, SvxSplitTableDlg, ToggleHdl));
32 m_xVertBox->connect_toggled(LINK(this, SvxSplitTableDlg, ToggleHdl));
34 if (mnMaxVertical < 2)
36 if (!bIsTableVertical)
37 m_xVertBox->set_sensitive(false);
38 else
39 m_xHorzBox->set_sensitive(false);
42 //exchange the meaning of horizontal and vertical for vertical text
43 if (bIsTableVertical)
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());
53 IMPL_LINK(SvxSplitTableDlg, ToggleHdl, weld::Toggleable&, rButton, void)
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);
63 bool SvxSplitTableDlg::IsHorizontal() const
65 return m_xHorzBox->get_active();
68 bool SvxSplitTableDlg::IsProportional() const
70 return m_xPropCB->get_active() && m_xHorzBox->get_active();
73 tools::Long SvxSplitTableDlg::GetCount() const
75 return m_xCountEdit->get_value();
78 void SvxSplitTableDlg::SetSplitVerticalByDefault()
80 if( mnMaxVertical >= 2 )
81 m_xVertBox->set_active(true); // tdf#60242
84 bool SvxAbstractSplitTableDialog_Impl::IsHorizontal() const
86 return m_xDlg->IsHorizontal();
89 bool SvxAbstractSplitTableDialog_Impl::IsProportional() const
91 return m_xDlg->IsProportional();
94 tools::Long SvxAbstractSplitTableDialog_Impl::GetCount() const
96 return m_xDlg->GetCount();
99 void SvxAbstractSplitTableDialog_Impl::SetSplitVerticalByDefault()
101 m_xDlg->SetSplitVerticalByDefault();
104 short SvxAbstractSplitTableDialog_Impl::Execute()
106 return m_xDlg->run();
109 bool SvxAbstractSplitTableDialog_Impl::StartExecuteAsync(AsyncContext& rContext)
111 return weld::DialogController::runAsync(m_xDlg, rContext.maEndDialogFn);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */