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 #undef SC_DLLIMPLEMENTATION
22 #include <inscldlg.hxx>
23 #include <viewdata.hxx>
24 #include <strings.hrc>
25 #include <scresid.hxx>
27 static sal_uInt8 nInsItemChecked
= 0;
29 ScInsertCellDlg::ScInsertCellDlg(weld::Window
* pParent
, bool bDisallowCellMove
)
30 : GenericDialogController(pParent
, u
"modules/scalc/ui/insertcells.ui"_ustr
,
31 u
"InsertCellsDialog"_ustr
)
32 , m_xBtnCellsDown(m_xBuilder
->weld_radio_button(u
"down"_ustr
))
33 , m_xBtnCellsRight(m_xBuilder
->weld_radio_button(u
"right"_ustr
))
34 , m_xBtnInsRow(m_xBuilder
->weld_radio_button(u
"rows"_ustr
))
35 , m_xBtnInsCol(m_xBuilder
->weld_radio_button(u
"cols"_ustr
))
36 , m_xNumberOfRows(m_xBuilder
->weld_spin_button(u
"number_of_rows"_ustr
))
37 , m_xNumberOfCols(m_xBuilder
->weld_spin_button(u
"number_of_columns"_ustr
))
39 const ScViewData
* pViewData
= ScDocShell::GetViewData();
40 if (pViewData
&& pViewData
->GetDocument().IsLayoutRTL(pViewData
->GetTabNo()))
41 m_xBtnCellsRight
->set_label(ScResId(SCSTR_INSERT_RTL
));
43 m_xNumberOfRows
->set_range(1, MAX_INS_ROWS
);
44 m_xNumberOfRows
->set_value(1);
45 m_xNumberOfCols
->set_range(1, MAX_INS_COLS
);
46 m_xNumberOfCols
->set_value(1);
48 m_xBtnInsRow
->connect_toggled(LINK(this, ScInsertCellDlg
, RadioButtonsHdl
));
49 m_xBtnInsCol
->connect_toggled(LINK(this, ScInsertCellDlg
, RadioButtonsHdl
));
51 bool bColCount
= false;
52 bool bRowsCount
= false;
53 if (bDisallowCellMove
)
55 m_xBtnCellsDown
->set_sensitive(false);
56 m_xBtnCellsRight
->set_sensitive(false);
57 m_xBtnInsRow
->set_active(true);
60 switch (nInsItemChecked
)
63 m_xBtnInsRow
->set_active(true);
66 m_xBtnInsCol
->set_active(true);
71 m_xBtnInsRow
->set_active(true);
77 switch (nInsItemChecked
)
80 m_xBtnCellsDown
->set_active(true);
83 m_xBtnCellsRight
->set_active(true);
86 m_xBtnInsRow
->set_active(true);
91 m_xBtnInsCol
->set_active(true);
98 // if some cells are selected, then disable the SpinButtons
99 const bool bMarked
= pViewData
&& pViewData
->GetMarkData().IsMarked();
100 m_xNumberOfCols
->set_sensitive(bColCount
&& !bMarked
);
101 m_xNumberOfRows
->set_sensitive(bRowsCount
&& !bMarked
);
104 ScInsertCellDlg::~ScInsertCellDlg() {}
106 InsCellCmd
ScInsertCellDlg::GetInsCellCmd() const
108 InsCellCmd nReturn
= INS_NONE
;
110 if (m_xBtnCellsDown
->get_active())
113 nReturn
= INS_CELLSDOWN
;
115 else if (m_xBtnCellsRight
->get_active())
118 nReturn
= INS_CELLSRIGHT
;
120 else if (m_xBtnInsRow
->get_active())
123 nReturn
= INS_INSROWS_BEFORE
;
125 else if (m_xBtnInsCol
->get_active())
128 nReturn
= INS_INSCOLS_BEFORE
;
134 size_t ScInsertCellDlg::GetCount() const
136 switch (nInsItemChecked
)
139 return m_xNumberOfRows
->get_value() - 1;
141 return m_xNumberOfCols
->get_value() - 1;
147 IMPL_LINK_NOARG(ScInsertCellDlg
, RadioButtonsHdl
, weld::Toggleable
&, void)
149 m_xNumberOfRows
->set_sensitive(m_xBtnInsRow
->get_active());
150 m_xNumberOfCols
->set_sensitive(m_xBtnInsCol
->get_active());
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */