LibreOffice Module sc (master)  1
inscodlg.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 #undef SC_DLLIMPLEMENTATION
21 
22 #include <inscodlg.hxx>
23 
28 
30  const OUString* pStrTitle )
31  : GenericDialogController(pParent, "modules/scalc/ui/pastespecial.ui", "PasteSpecial")
32  , bOtherDoc(false)
33  , bFillMode(false)
34  , bChangeTrack(false)
35  , bMoveDownDisabled(false)
36  , bMoveRightDisabled(false)
37  , mxBtnInsAll(m_xBuilder->weld_check_button("paste_all"))
38  , mxBtnInsStrings(m_xBuilder->weld_check_button("text"))
39  , mxBtnInsNumbers(m_xBuilder->weld_check_button("numbers"))
40  , mxBtnInsDateTime(m_xBuilder->weld_check_button("datetime"))
41  , mxBtnInsFormulas(m_xBuilder->weld_check_button("formulas"))
42  , mxBtnInsNotes(m_xBuilder->weld_check_button("comments"))
43  , mxBtnInsAttrs(m_xBuilder->weld_check_button("formats"))
44  , mxBtnInsObjects(m_xBuilder->weld_check_button("objects"))
45  , mxBtnSkipEmptyCells(m_xBuilder->weld_check_button("skip_empty"))
46  , mxBtnTranspose(m_xBuilder->weld_check_button("transpose"))
47  , mxBtnLink(m_xBuilder->weld_check_button("link"))
48  , mxRbNoOp(m_xBuilder->weld_radio_button("none"))
49  , mxRbAdd(m_xBuilder->weld_radio_button("add"))
50  , mxRbSub(m_xBuilder->weld_radio_button("subtract"))
51  , mxRbMul(m_xBuilder->weld_radio_button("multiply"))
52  , mxRbDiv(m_xBuilder->weld_radio_button("divide"))
53  , mxRbMoveNone(m_xBuilder->weld_radio_button("no_shift"))
54  , mxRbMoveDown(m_xBuilder->weld_radio_button("move_down"))
55  , mxRbMoveRight(m_xBuilder->weld_radio_button("move_right"))
56  , mxBtnShortCutPasteValuesOnly(m_xBuilder->weld_button("paste_values_only"))
57  , mxBtnShortCutPasteValuesFormats(m_xBuilder->weld_button("paste_values_formats"))
58  , mxBtnShortCutPasteTranspose(m_xBuilder->weld_button("paste_transpose"))
59  , mxBtnShortCutPasteFormats(m_xBuilder->weld_button("paste_formats"))
60  , mxImmediately(m_xBuilder->weld_check_button("cbImmediately"))
61 {
62  if (pStrTitle)
63  m_xDialog->set_title(*pStrTitle);
64 
69  DisableChecks( mxBtnInsAll->get_active() );
70 
71  mxBtnInsAll->connect_toggled( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
72  mxBtnLink->connect_toggled( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
73  mxBtnShortCutPasteValuesOnly->connect_clicked( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );
74  mxBtnShortCutPasteValuesFormats->connect_clicked( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );
75  mxBtnShortCutPasteTranspose->connect_clicked( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );
76  mxBtnShortCutPasteFormats->connect_clicked( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );
77 }
78 
80 {
82 
83  if ( mxBtnInsStrings->get_active() )
85  if ( mxBtnInsNumbers->get_active() )
87  if ( mxBtnInsDateTime->get_active())
89  if ( mxBtnInsFormulas->get_active())
91  if ( mxBtnInsNotes->get_active() )
93  if ( mxBtnInsAttrs->get_active() )
95  if ( mxBtnInsObjects->get_active() )
97 
98  return ( mxBtnInsAll->get_active()
101 }
102 
104 {
112  mxBtnInsAll->set_active((InsertDeleteFlags::ALL & eFlags) == InsertDeleteFlags::ALL);
113  DisableChecks( mxBtnInsAll->get_active() );
114 }
115 
117 {
118  switch( eFlags )
119  {
120  case ScPasteFunc::NONE: mxRbNoOp->set_active(true); break;
121  case ScPasteFunc::ADD: mxRbAdd->set_active(true); break;
122  case ScPasteFunc::SUB: mxRbSub->set_active(true); break;
123  case ScPasteFunc::MUL: mxRbMul->set_active(true); break;
124  case ScPasteFunc::DIV: mxRbDiv->set_active(true); break;
125  }
126 }
127 
129 {
130  switch( eFlags )
131  {
132  case INS_NONE: mxRbMoveNone->set_active(true); break;
133  case INS_CELLSDOWN: mxRbMoveDown->set_active(true); break;
134  case INS_CELLSRIGHT: mxRbMoveRight->set_active(true); break;
135  case INS_INSROWS_BEFORE:
136  case INS_INSCOLS_BEFORE:
137  case INS_INSROWS_AFTER:
138  case INS_INSCOLS_AFTER: break;
139  }
140 }
141 
143 {
144  mxBtnSkipEmptyCells->set_active(bool(InsertContentsFlags::NoEmpty & eFlags));
145  mxBtnTranspose->set_active(bool(InsertContentsFlags::Trans & eFlags));
146  mxBtnLink->set_active(bool(InsertContentsFlags::Link & eFlags));
147 }
148 
150 {
151  if ( mxRbMoveDown->get_active() )
152  return INS_CELLSDOWN;
153  if ( mxRbMoveRight->get_active() )
154  return INS_CELLSRIGHT;
155 
156  return INS_NONE;
157 }
158 
160 {
161  return mxBtnSkipEmptyCells->get_active();
162 }
163 
165 {
166  return mxBtnTranspose->get_active();
167 }
168 
170 {
171  return mxBtnLink->get_active();
172 }
173 
174 void ScInsertContentsDlg::DisableChecks( bool bInsAllChecked )
175 {
176  if ( bInsAllChecked )
177  {
178  mxBtnInsStrings->set_sensitive(false);
179  mxBtnInsNumbers->set_sensitive(false);
180  mxBtnInsDateTime->set_sensitive(false);
181  mxBtnInsFormulas->set_sensitive(false);
182  mxBtnInsNotes->set_sensitive(false);
183  mxBtnInsAttrs->set_sensitive(false);
184  mxBtnInsObjects->set_sensitive(false);
185  }
186  else
187  {
188  mxBtnInsStrings->set_sensitive(true);
189  mxBtnInsNumbers->set_sensitive(true);
190  mxBtnInsDateTime->set_sensitive(true);
191  mxBtnInsFormulas->set_sensitive(true);
192  mxBtnInsNotes->set_sensitive(true);
193  mxBtnInsAttrs->set_sensitive(true);
194 
195  // "Objects" is disabled for "Fill Tables"
196  if ( bFillMode )
197  mxBtnInsObjects->set_sensitive(false);
198  else
199  mxBtnInsObjects->set_sensitive(true);
200  }
201 }
202 
203 // Link to other document -> everything else is disabled
204 
206 {
207  if ( bOtherDoc && mxBtnLink->get_active() )
208  {
209  mxBtnSkipEmptyCells->set_sensitive(false);
210  mxBtnTranspose->set_sensitive(false);
211  mxRbNoOp->set_sensitive(false);
212  mxRbAdd->set_sensitive(false);
213  mxRbSub->set_sensitive(false);
214  mxRbMul->set_sensitive(false);
215  mxRbDiv->set_sensitive(false);
216 
217  mxRbMoveNone->set_sensitive(false);
218  mxRbMoveDown->set_sensitive(false);
219  mxRbMoveRight->set_sensitive(false);
220 
221  mxBtnInsAll->set_sensitive(false);
222  DisableChecks(true);
223  }
224  else
225  {
226  mxBtnSkipEmptyCells->set_sensitive(true);
227  mxBtnTranspose->set_sensitive(!bFillMode);
228  mxRbNoOp->set_sensitive(true);
229  mxRbAdd->set_sensitive(true);
230  mxRbSub->set_sensitive(true);
231  mxRbMul->set_sensitive(true);
232  mxRbDiv->set_sensitive(true);
233 
235  mxRbMoveDown->set_sensitive(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
236  mxRbMoveRight->set_sensitive(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
237 
238  mxBtnInsAll->set_sensitive(true);
239  DisableChecks( mxBtnInsAll->get_active() );
240  }
241 }
242 
244 {
245  if ( bSet != bOtherDoc )
246  {
247  bOtherDoc = bSet;
248  TestModes();
249  if ( bSet )
250  mxRbMoveNone->set_active(true);
251  }
252 }
253 
255 {
256  if ( bSet != bFillMode )
257  {
258  bFillMode = bSet;
259  TestModes();
260  if ( bSet )
261  mxRbMoveNone->set_active(true);
262  }
263 }
264 
266 {
267  if ( bSet != bChangeTrack )
268  {
269  bChangeTrack = bSet;
270  TestModes();
271  if ( bSet )
272  mxRbMoveNone->set_active(true);
273  }
274 }
275 
277 {
278  bool bDown(nDisable & CellShiftDisabledFlags::Down);
279  bool bRight(nDisable & CellShiftDisabledFlags::Right);
280  if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
281  {
282  bMoveDownDisabled = bDown;
283  bMoveRightDisabled = bRight;
284  TestModes();
285  if ( bMoveDownDisabled && mxRbMoveDown->get_active() )
286  mxRbMoveNone->set_active(true);
287  if ( bMoveRightDisabled && mxRbMoveRight->get_active() )
288  mxRbMoveNone->set_active(true);
289  }
290 }
291 
292 IMPL_LINK(ScInsertContentsDlg, ShortCutHdl, weld::Button&, rBtn, void)
293 {
294  if (&rBtn == mxBtnShortCutPasteValuesOnly.get())
295  {
297  SetContentsFlags( InsertContentsFlags::NONE );
298  }
299  else if (&rBtn == mxBtnShortCutPasteValuesFormats.get())
300  {
302  SetContentsFlags( InsertContentsFlags::NONE );
303  }
304  else if (&rBtn == mxBtnShortCutPasteTranspose.get())
305  {
306  SetInsContentsCmdBits( InsertDeleteFlags::ALL );
307  SetContentsFlags( InsertContentsFlags::Trans );
308  }
309  else if (&rBtn == mxBtnShortCutPasteFormats.get())
310  {
311  SetInsContentsCmdBits( InsertDeleteFlags::ATTRIB );
312  SetContentsFlags( InsertContentsFlags::NONE );
313  }
314  else
315  return;
316 
317  SetCellCmdFlags( InsCellCmd::INS_NONE );
318  SetFormulaCmdBits(ScPasteFunc::NONE);
319  if (mxImmediately->get_active()) m_xDialog->response(RET_OK);
320 }
321 
323 {
324  DisableChecks( mxBtnInsAll->get_active() );
325 }
326 
328 {
329  TestModes();
330 }
331 
333 {
335  if(mxBtnSkipEmptyCells->get_active())
337  if( mxBtnTranspose->get_active())
339  if( mxBtnLink->get_active() )
341 
342  if (!bFillMode) // in FillMode, None is checked and all three options are disabled
343  {
344  if ( mxRbMoveNone->get_active() )
346  else if ( mxRbMoveDown->get_active() )
348  else if ( mxRbMoveRight->get_active() )
350  }
351 }
352 
354 {
356  if(mxRbAdd->get_active())
358  else if(mxRbSub->get_active())
360  else if(mxRbMul->get_active())
362  else if(mxRbDiv->get_active())
365 }
366 
367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ScPasteFunc nPreviousFormulaChecks
Definition: inscodlg.hxx:90
std::shared_ptr< weld::Dialog > m_xDialog
Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
InsertDeleteFlags GetInsContentsCmdBits() const
Definition: inscodlg.cxx:79
InsertContentsFlags
Definition: scui_def.hxx:31
std::unique_ptr< weld::CheckButton > mxBtnTranspose
Definition: inscodlg.hxx:68
std::unique_ptr< weld::CheckButton > mxBtnLink
Definition: inscodlg.hxx:69
void SetChangeTrack(bool bSet)
Definition: inscodlg.cxx:265
ScInsertContentsDlg(weld::Window *pParent, const OUString *pStrTitle)
Definition: inscodlg.cxx:29
void SetCellShiftDisabled(CellShiftDisabledFlags nDisable)
Definition: inscodlg.cxx:276
static InsCellCmd nPreviousMoveMode
Definition: inscodlg.hxx:91
std::unique_ptr< weld::Button > mxBtnShortCutPasteValuesFormats
Definition: inscodlg.hxx:82
bool IsSkipEmptyCells() const
Definition: inscodlg.cxx:159
Internal use only (d&d undo): do not delete caption objects of cell notes.
std::unique_ptr< weld::CheckButton > mxBtnSkipEmptyCells
Definition: inscodlg.hxx:67
static InsertContentsFlags nPreviousChecks2
Definition: inscodlg.hxx:89
bool IsTranspose() const
Definition: inscodlg.cxx:164
InsCellCmd GetMoveMode() const
Definition: inscodlg.cxx:149
ScPasteFunc
Definition: global.hxx:178
void SetFillMode(bool bSet)
Definition: inscodlg.cxx:254
bool IsLink() const
Definition: inscodlg.cxx:169
void SetOtherDoc(bool bSet)
Definition: inscodlg.cxx:243
ScPasteFunc GetFormulaCmdBits() const
Definition: inscodlg.cxx:353
std::unique_ptr< weld::RadioButton > mxRbMul
Definition: inscodlg.hxx:74
std::unique_ptr< weld::CheckButton > mxBtnInsAttrs
Definition: inscodlg.hxx:64
InsertDeleteFlags
Definition: global.hxx:147
std::unique_ptr< weld::RadioButton > mxRbMoveNone
Definition: inscodlg.hxx:77
std::unique_ptr< weld::RadioButton > mxRbMoveDown
Definition: inscodlg.hxx:78
void SetInsContentsCmdBits(const InsertDeleteFlags eFlags)
Definition: inscodlg.cxx:103
std::unique_ptr< weld::CheckButton > mxBtnInsObjects
Definition: inscodlg.hxx:65
IMPL_LINK_NOARG(ScInsertContentsDlg, InsAllHdl, weld::Toggleable &, void)
Definition: inscodlg.cxx:322
std::unique_ptr< weld::RadioButton > mxRbAdd
Definition: inscodlg.hxx:72
std::unique_ptr< weld::CheckButton > mxBtnInsDateTime
Definition: inscodlg.hxx:61
std::unique_ptr< weld::RadioButton > mxRbSub
Definition: inscodlg.hxx:73
std::unique_ptr< weld::Button > mxBtnShortCutPasteValuesOnly
Definition: inscodlg.hxx:81
static InsertDeleteFlags nPreviousChecks
Definition: inscodlg.hxx:88
void SetFormulaCmdBits(const ScPasteFunc eFlags)
Definition: inscodlg.cxx:116
IMPL_LINK(ScInsertContentsDlg, ShortCutHdl, weld::Button &, rBtn, void)
Definition: inscodlg.cxx:292
void SetContentsFlags(const InsertContentsFlags eFlags)
Definition: inscodlg.cxx:142
RET_OK
Dates, times, datetime values.
InsCellCmd
Definition: global.hxx:286
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::CheckButton > mxBtnInsNumbers
Definition: inscodlg.hxx:60
std::unique_ptr< weld::CheckButton > mxBtnInsNotes
Definition: inscodlg.hxx:63
std::unique_ptr< weld::CheckButton > mxBtnInsFormulas
Definition: inscodlg.hxx:62
std::unique_ptr< weld::Button > mxBtnShortCutPasteFormats
Definition: inscodlg.hxx:84
std::unique_ptr< weld::CheckButton > mxBtnInsStrings
Definition: inscodlg.hxx:59
std::unique_ptr< weld::CheckButton > mxBtnInsAll
Definition: inscodlg.hxx:58
std::unique_ptr< weld::RadioButton > mxRbDiv
Definition: inscodlg.hxx:75
std::unique_ptr< weld::RadioButton > mxRbMoveRight
Definition: inscodlg.hxx:79
std::unique_ptr< weld::Button > mxBtnShortCutPasteTranspose
Definition: inscodlg.hxx:83
virtual ~ScInsertContentsDlg() override
Definition: inscodlg.cxx:332
void DisableChecks(bool bInsAllChecked)
Definition: inscodlg.cxx:174
void SetCellCmdFlags(const InsCellCmd eFlags)
Definition: inscodlg.cxx:128
std::unique_ptr< weld::RadioButton > mxRbNoOp
Definition: inscodlg.hxx:71
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
CellShiftDisabledFlags
Definition: scui_def.hxx:41