1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#undef SC_DLLIMPLEMENTATION
#include "inscodlg.hxx"
#include "scresid.hxx"
#include "miscdlgs.hrc"
bool ScInsertContentsDlg::bPreviousAllCheck = false;
InsertDeleteFlags ScInsertContentsDlg::nPreviousChecks = (IDF_VALUE | IDF_DATETIME | IDF_STRING);
sal_uInt16 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
sal_uInt16 ScInsertContentsDlg::nPreviousChecks2 = 0;
sal_uInt16 ScInsertContentsDlg::nPreviousMoveMode = INS_NONE; // enum InsCellCmd
ScInsertContentsDlg::ScInsertContentsDlg( vcl::Window* pParent,
InsertDeleteFlags nCheckDefaults,
const OUString* pStrTitle )
: ModalDialog ( pParent, "PasteSpecial", "modules/scalc/ui/pastespecial.ui" ),
bOtherDoc ( false ),
bFillMode ( false ),
bChangeTrack ( false ),
bMoveDownDisabled( false ),
bMoveRightDisabled( false ),
bUsedShortCut ( false ),
nShortCutInsContentsCmdBits( IDF_NONE ),
nShortCutFormulaCmdBits(0),
bShortCutSkipEmptyCells(false),
bShortCutTranspose(false),
bShortCutIsLink(false),
nShortCutMoveMode(INS_NONE)
{
get( mpBtnInsAll, "paste_all" );
get( mpBtnInsStrings, "text" );
get( mpBtnInsNumbers, "numbers" );
get( mpBtnInsDateTime, "datetime" );
get( mpBtnInsFormulas, "formulas" );
get( mpBtnInsNotes, "comments" );
get( mpBtnInsAttrs, "formats" );
get( mpBtnInsObjects, "objects" );
get( mpBtnSkipEmptyCells, "skip_empty" );
get( mpBtnTranspose, "transpose" );
get( mpBtnLink, "link" );
get( mpRbNoOp, "none" );
get( mpRbAdd, "add" );
get( mpRbSub, "subtract" );
get( mpRbMul, "multiply" );
get( mpRbDiv, "divide" );
get( mpRbMoveNone, "no_shift" );
get( mpRbMoveDown, "move_down" );
get( mpRbMoveRight, "move_right" );
get( mpBtnShortCutPasteValuesOnly, "paste_values_only");
get( mpBtnShortCutPasteValuesFormats, "paste_values_formats");
get( mpBtnShortCutPasteTranspose, "paste_transpose");
if ( pStrTitle )
SetText( *pStrTitle );
if ( nCheckDefaults != IDF_NONE )
{
ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
ScInsertContentsDlg::bPreviousAllCheck = false;
ScInsertContentsDlg::nPreviousChecks2 = 0;
}
mpBtnInsAll->Check ( ScInsertContentsDlg::bPreviousAllCheck );
mpBtnInsStrings->Check ( IS_SET( IDF_STRING,
ScInsertContentsDlg::nPreviousChecks ) );
mpBtnInsNumbers->Check ( IS_SET( IDF_VALUE,
ScInsertContentsDlg::nPreviousChecks ) );
mpBtnInsDateTime->Check( IS_SET( IDF_DATETIME,
ScInsertContentsDlg::nPreviousChecks ) );
mpBtnInsFormulas->Check( IS_SET( IDF_FORMULA,
ScInsertContentsDlg::nPreviousChecks ) );
mpBtnInsNotes->Check ( IS_SET( IDF_NOTE,
ScInsertContentsDlg::nPreviousChecks ) );
mpBtnInsAttrs->Check ( IS_SET( IDF_ATTRIB,
ScInsertContentsDlg::nPreviousChecks ) );
mpBtnInsObjects->Check ( IS_SET( IDF_OBJECTS,
ScInsertContentsDlg::nPreviousChecks ) );
switch( ScInsertContentsDlg::nPreviousFormulaChecks )
{
case PASTE_NOFUNC: mpRbNoOp->Check(); break;
case PASTE_ADD: mpRbAdd->Check(); break;
case PASTE_SUB: mpRbSub->Check(); break;
case PASTE_MUL: mpRbMul->Check(); break;
case PASTE_DIV: mpRbDiv->Check(); break;
}
switch( ScInsertContentsDlg::nPreviousMoveMode )
{
case INS_NONE: mpRbMoveNone->Check(); break;
case INS_CELLSDOWN: mpRbMoveDown->Check(); break;
case INS_CELLSRIGHT: mpRbMoveRight->Check(); break;
}
mpBtnSkipEmptyCells->Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
mpBtnTranspose->Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_TRANS ) != 0);
mpBtnLink->Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_LINK ) != 0);
DisableChecks( mpBtnInsAll->IsChecked() );
mpBtnInsAll->SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
mpBtnLink->SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
mpBtnShortCutPasteValuesOnly->SetClickHdl( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );;
mpBtnShortCutPasteValuesFormats->SetClickHdl( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );;
mpBtnShortCutPasteTranspose->SetClickHdl( LINK( this, ScInsertContentsDlg, ShortCutHdl ) );
}
InsertDeleteFlags ScInsertContentsDlg::GetInsContentsCmdBits() const
{
ScInsertContentsDlg::nPreviousChecks = IDF_NONE;
if ( mpBtnInsStrings->IsChecked() )
ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
if ( mpBtnInsNumbers->IsChecked() )
ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
if ( mpBtnInsDateTime->IsChecked())
ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
if ( mpBtnInsFormulas->IsChecked())
ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
if ( mpBtnInsNotes->IsChecked() )
ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
if ( mpBtnInsAttrs->IsChecked() )
ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
if ( mpBtnInsObjects->IsChecked() )
ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
ScInsertContentsDlg::bPreviousAllCheck = mpBtnInsAll->IsChecked();
if (bUsedShortCut)
return nShortCutInsContentsCmdBits;
return ( (ScInsertContentsDlg::bPreviousAllCheck)
? IDF_ALL
: ScInsertContentsDlg::nPreviousChecks );
}
InsCellCmd ScInsertContentsDlg::GetMoveMode()
{
if (bUsedShortCut)
return nShortCutMoveMode;
if ( mpRbMoveDown->IsChecked() )
return INS_CELLSDOWN;
if ( mpRbMoveRight->IsChecked() )
return INS_CELLSRIGHT;
return INS_NONE;
}
bool ScInsertContentsDlg::IsSkipEmptyCells() const
{
if (bUsedShortCut)
return bShortCutSkipEmptyCells;
return mpBtnSkipEmptyCells->IsChecked();
}
bool ScInsertContentsDlg::IsTranspose() const
{
if (bUsedShortCut)
return bShortCutTranspose;
return mpBtnTranspose->IsChecked();
}
bool ScInsertContentsDlg::IsLink() const
{
if (bUsedShortCut)
return bShortCutIsLink;
return mpBtnLink->IsChecked();
}
void ScInsertContentsDlg::DisableChecks( bool bInsAllChecked )
{
if ( bInsAllChecked )
{
mpBtnInsStrings->Disable();
mpBtnInsNumbers->Disable();
mpBtnInsDateTime->Disable();
mpBtnInsFormulas->Disable();
mpBtnInsNotes->Disable();
mpBtnInsAttrs->Disable();
mpBtnInsObjects->Disable();
}
else
{
mpBtnInsStrings->Enable();
mpBtnInsNumbers->Enable();
mpBtnInsDateTime->Enable();
mpBtnInsFormulas->Enable();
mpBtnInsNotes->Enable();
mpBtnInsAttrs->Enable();
// "Objects" is disabled for "Fill Tables"
if ( bFillMode )
mpBtnInsObjects->Disable();
else
mpBtnInsObjects->Enable();
}
}
// Link to other document -> everything else is disabled
void ScInsertContentsDlg::TestModes()
{
if ( bOtherDoc && mpBtnLink->IsChecked() )
{
mpBtnSkipEmptyCells->Disable();
mpBtnTranspose->Disable();
mpRbNoOp->Disable();
mpRbAdd->Disable();
mpRbSub->Disable();
mpRbMul->Disable();
mpRbDiv->Disable();
mpRbMoveNone->Disable();
mpRbMoveDown->Disable();
mpRbMoveRight->Disable();
mpBtnInsAll->Disable();
DisableChecks();
}
else
{
mpBtnSkipEmptyCells->Enable();
mpBtnTranspose->Enable(!bFillMode);
mpRbNoOp->Enable();
mpRbAdd->Enable();
mpRbSub->Enable();
mpRbMul->Enable();
mpRbDiv->Enable();
mpRbMoveNone->Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
mpRbMoveDown->Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
mpRbMoveRight->Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
mpBtnInsAll->Enable();
DisableChecks( mpBtnInsAll->IsChecked() );
}
}
void ScInsertContentsDlg::SetOtherDoc( bool bSet )
{
if ( bSet != bOtherDoc )
{
bOtherDoc = bSet;
TestModes();
if ( bSet )
mpRbMoveNone->Check();
}
}
void ScInsertContentsDlg::SetFillMode( bool bSet )
{
if ( bSet != bFillMode )
{
bFillMode = bSet;
TestModes();
if ( bSet )
mpRbMoveNone->Check();
}
}
void ScInsertContentsDlg::SetChangeTrack( bool bSet )
{
if ( bSet != bChangeTrack )
{
bChangeTrack = bSet;
TestModes();
if ( bSet )
mpRbMoveNone->Check();
}
}
void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
{
bool bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
bool bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
{
bMoveDownDisabled = bDown;
bMoveRightDisabled = bRight;
TestModes();
if ( bMoveDownDisabled && mpRbMoveDown->IsChecked() )
mpRbMoveNone->Check();
if ( bMoveRightDisabled && mpRbMoveRight->IsChecked() )
mpRbMoveNone->Check();
}
}
IMPL_LINK( ScInsertContentsDlg, ShortCutHdl, PushButton*, pBtn )
{
if ( pBtn == mpBtnShortCutPasteValuesOnly )
{
bUsedShortCut = true;
nShortCutInsContentsCmdBits = IDF_STRING | IDF_VALUE | IDF_DATETIME;
nShortCutFormulaCmdBits = PASTE_NOFUNC;
bShortCutSkipEmptyCells = false;
bShortCutTranspose = false;
bShortCutIsLink = false;
nShortCutMoveMode = INS_NONE;
EndDialog(RET_OK);
}
else if ( pBtn == mpBtnShortCutPasteValuesFormats )
{
bUsedShortCut = true;
nShortCutInsContentsCmdBits = IDF_STRING | IDF_VALUE | IDF_DATETIME | IDF_ATTRIB;
nShortCutFormulaCmdBits = PASTE_NOFUNC;
bShortCutSkipEmptyCells = false;
bShortCutTranspose = false;
bShortCutIsLink = false;
nShortCutMoveMode = INS_NONE;
EndDialog(RET_OK);
}
else if ( pBtn == mpBtnShortCutPasteTranspose )
{
bUsedShortCut = true;
nShortCutInsContentsCmdBits = IDF_ALL;
nShortCutFormulaCmdBits = PASTE_NOFUNC;
bShortCutSkipEmptyCells = false;
bShortCutTranspose = true;
bShortCutIsLink = false;
nShortCutMoveMode = INS_NONE;
EndDialog(RET_OK);
}
return 0;
}
IMPL_LINK_NOARG(ScInsertContentsDlg, InsAllHdl)
{
DisableChecks( mpBtnInsAll->IsChecked() );
return 0;
}
IMPL_LINK_NOARG(ScInsertContentsDlg, LinkBtnHdl)
{
TestModes();
return 0;
}
ScInsertContentsDlg::~ScInsertContentsDlg()
{
disposeOnce();
}
void ScInsertContentsDlg::dispose()
{
ScInsertContentsDlg::nPreviousChecks2 = 0;
if(mpBtnSkipEmptyCells->IsChecked())
ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
if( mpBtnTranspose->IsChecked())
ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
if( mpBtnLink->IsChecked() )
ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
if (!bFillMode) // in FillMode, None is checked and all three options are disabled
{
if ( mpRbMoveNone->IsChecked() )
ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
else if ( mpRbMoveDown->IsChecked() )
ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
else if ( mpRbMoveRight->IsChecked() )
ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
}
mpBtnInsAll.clear();
mpBtnInsStrings.clear();
mpBtnInsNumbers.clear();
mpBtnInsDateTime.clear();
mpBtnInsFormulas.clear();
mpBtnInsNotes.clear();
mpBtnInsAttrs.clear();
mpBtnInsObjects.clear();
mpBtnSkipEmptyCells.clear();
mpBtnTranspose.clear();
mpBtnLink.clear();
mpRbNoOp.clear();
mpRbAdd.clear();
mpRbSub.clear();
mpRbMul.clear();
mpRbDiv.clear();
mpRbMoveNone.clear();
mpRbMoveDown.clear();
mpRbMoveRight.clear();
mpBtnShortCutPasteValuesOnly.clear();
mpBtnShortCutPasteValuesFormats.clear();
mpBtnShortCutPasteTranspose.clear();
ModalDialog::dispose();
}
sal_uInt16 ScInsertContentsDlg::GetFormulaCmdBits() const
{
ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
if(mpRbAdd->IsChecked())
ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
else if(mpRbSub->IsChecked())
ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
else if(mpRbMul->IsChecked())
ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
else if(mpRbDiv->IsChecked())
ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
if (bUsedShortCut)
return nShortCutFormulaCmdBits;
return ScInsertContentsDlg::nPreviousFormulaChecks;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|