Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #undef SC_DLLIMPLEMENTATION
31 : :
32 : :
33 : :
34 : : //------------------------------------------------------------------
35 : :
36 : : #include "inscodlg.hxx"
37 : : #include "scresid.hxx"
38 : : #include "miscdlgs.hrc"
39 : :
40 : :
41 : : //==================================================================
42 : :
43 : : sal_Bool ScInsertContentsDlg::bPreviousAllCheck = sal_True;
44 : : sal_uInt16 ScInsertContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
45 : : IDF_NOTE | IDF_FORMULA |
46 : : IDF_ATTRIB | IDF_OBJECTS);
47 : : sal_uInt16 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
48 : : sal_uInt16 ScInsertContentsDlg::nPreviousChecks2 = 0;
49 : : sal_uInt16 ScInsertContentsDlg::nPreviousMoveMode = INS_NONE; // enum InsCellCmd
50 : :
51 : : //-----------------------------------------------------------------------
52 : :
53 : 0 : ScInsertContentsDlg::ScInsertContentsDlg( Window* pParent,
54 : : sal_uInt16 nCheckDefaults,
55 : : const String* pStrTitle )
56 : :
57 : : : ModalDialog ( pParent, ScResId( RID_SCDLG_INSCONT ) ),
58 : : //
59 : : aFlFrame ( this, ScResId( FL_FRAME ) ),
60 : : aBtnInsAll ( this, ScResId( BTN_INSALL ) ),
61 : : aBtnInsStrings ( this, ScResId( BTN_INSSTRINGS ) ),
62 : : aBtnInsNumbers ( this, ScResId( BTN_INSNUMBERS ) ),
63 : : aBtnInsDateTime ( this, ScResId( BTN_INSDATETIME ) ),
64 : : aBtnInsFormulas ( this, ScResId( BTN_INSFORMULAS ) ),
65 : : aBtnInsNotes ( this, ScResId( BTN_INSNOTES ) ),
66 : : aBtnInsAttrs ( this, ScResId( BTN_INSATTRS ) ),
67 : : aBtnInsObjects ( this, ScResId( BTN_INSOBJECTS ) ),
68 : : aFlSep1 ( this, ScResId( FL_SEP1 ) ),
69 : : aFlOptions ( this, ScResId( FL_OPTIONS ) ),
70 : : aBtnSkipEmptyCells( this, ScResId(BTN_SKIP_EMPTY ) ),
71 : : aBtnTranspose ( this, ScResId( BTN_TRANSPOSE ) ),
72 : : aBtnLink ( this, ScResId( BTN_LINK ) ),
73 : : aFlOperation ( this, ScResId( FL_OPERATION ) ),
74 : : aRbNoOp ( this, ScResId( BTN_OP_NOOP ) ),
75 : : aRbAdd ( this, ScResId( BTN_OP_ADD ) ),
76 : : aRbSub ( this, ScResId( BTN_OP_SUB ) ),
77 : : aRbMul ( this, ScResId( BTN_OP_MUL ) ),
78 : : aRbDiv ( this, ScResId( BTN_OP_DIV ) ),
79 : : aFlSep2 ( this, ScResId( FL_SEP2 ) ),
80 : : aFlMove ( this, ScResId( FL_MOVE ) ),
81 : : aRbMoveNone ( this, ScResId( BTN_MV_NONE ) ),
82 : : aRbMoveDown ( this, ScResId( BTN_MV_DOWN ) ),
83 : : aRbMoveRight ( this, ScResId( BTN_MV_RIGHT ) ),
84 : : aBtnOk ( this, ScResId( BTN_OK ) ),
85 : : aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
86 : : aBtnHelp ( this, ScResId( BTN_HELP ) ),
87 : : bOtherDoc ( false ),
88 : : bFillMode ( false ),
89 : : bChangeTrack ( false ),
90 : : bMoveDownDisabled( false ),
91 : 0 : bMoveRightDisabled( false )
92 : : {
93 : 0 : if ( pStrTitle )
94 : 0 : SetText( *pStrTitle );
95 : :
96 : 0 : if ( nCheckDefaults != 0 )
97 : : {
98 : 0 : ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
99 : 0 : ScInsertContentsDlg::bPreviousAllCheck = false;
100 : 0 : ScInsertContentsDlg::nPreviousChecks2 = 0;
101 : : }
102 : :
103 : 0 : aBtnInsAll.Check ( ScInsertContentsDlg::bPreviousAllCheck );
104 : : aBtnInsStrings.Check ( IS_SET( IDF_STRING,
105 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
106 : : aBtnInsNumbers.Check ( IS_SET( IDF_VALUE,
107 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
108 : : aBtnInsDateTime.Check( IS_SET( IDF_DATETIME,
109 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
110 : : aBtnInsFormulas.Check( IS_SET( IDF_FORMULA,
111 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
112 : : aBtnInsNotes.Check ( IS_SET( IDF_NOTE,
113 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
114 : : aBtnInsAttrs.Check ( IS_SET( IDF_ATTRIB,
115 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
116 : : aBtnInsObjects.Check ( IS_SET( IDF_OBJECTS,
117 : 0 : ScInsertContentsDlg::nPreviousChecks ) );
118 : :
119 : 0 : switch( ScInsertContentsDlg::nPreviousFormulaChecks )
120 : : {
121 : 0 : case PASTE_NOFUNC: aRbNoOp.Check(sal_True); break;
122 : 0 : case PASTE_ADD: aRbAdd.Check(sal_True); break;
123 : 0 : case PASTE_SUB: aRbSub.Check(sal_True); break;
124 : 0 : case PASTE_MUL: aRbMul.Check(sal_True); break;
125 : 0 : case PASTE_DIV: aRbDiv.Check(sal_True); break;
126 : : }
127 : :
128 : 0 : switch( ScInsertContentsDlg::nPreviousMoveMode )
129 : : {
130 : 0 : case INS_NONE: aRbMoveNone.Check(sal_True); break;
131 : 0 : case INS_CELLSDOWN: aRbMoveDown.Check(sal_True); break;
132 : 0 : case INS_CELLSRIGHT: aRbMoveRight.Check(sal_True); break;
133 : : }
134 : :
135 : 0 : aBtnSkipEmptyCells.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
136 : 0 : aBtnTranspose.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_TRANS ) != 0);
137 : 0 : aBtnLink.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_LINK ) != 0);
138 : :
139 : 0 : DisableChecks( aBtnInsAll.IsChecked() );
140 : :
141 : 0 : aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
142 : 0 : aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
143 : :
144 : 0 : aBtnInsAll.SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
145 : 0 : aBtnLink.SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
146 : :
147 : : //-------------
148 : 0 : FreeResource();
149 : 0 : }
150 : :
151 : : //------------------------------------------------------------------------
152 : :
153 : 0 : sal_uInt16 ScInsertContentsDlg::GetInsContentsCmdBits() const
154 : : {
155 : 0 : ScInsertContentsDlg::nPreviousChecks = 0;
156 : :
157 : 0 : if ( aBtnInsStrings.IsChecked() )
158 : 0 : ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
159 : 0 : if ( aBtnInsNumbers.IsChecked() )
160 : 0 : ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
161 : 0 : if ( aBtnInsDateTime.IsChecked())
162 : 0 : ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
163 : 0 : if ( aBtnInsFormulas.IsChecked())
164 : 0 : ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
165 : 0 : if ( aBtnInsNotes.IsChecked() )
166 : 0 : ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
167 : 0 : if ( aBtnInsAttrs.IsChecked() )
168 : 0 : ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
169 : 0 : if ( aBtnInsObjects.IsChecked() )
170 : 0 : ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
171 : :
172 : 0 : ScInsertContentsDlg::bPreviousAllCheck = aBtnInsAll.IsChecked();
173 : :
174 : : return ( (ScInsertContentsDlg::bPreviousAllCheck)
175 : : ? IDF_ALL
176 : 0 : : ScInsertContentsDlg::nPreviousChecks );
177 : : }
178 : :
179 : : //------------------------------------------------------------------------
180 : :
181 : 0 : InsCellCmd ScInsertContentsDlg::GetMoveMode()
182 : : {
183 : 0 : if ( aRbMoveDown.IsChecked() )
184 : 0 : return INS_CELLSDOWN;
185 : 0 : if ( aRbMoveRight.IsChecked() )
186 : 0 : return INS_CELLSRIGHT;
187 : :
188 : 0 : return INS_NONE;
189 : : }
190 : :
191 : : //------------------------------------------------------------------------
192 : :
193 : 0 : void ScInsertContentsDlg::DisableChecks( sal_Bool bInsAllChecked )
194 : : {
195 : 0 : if ( bInsAllChecked )
196 : : {
197 : 0 : aBtnInsStrings.Disable();
198 : 0 : aBtnInsNumbers.Disable();
199 : 0 : aBtnInsDateTime.Disable();
200 : 0 : aBtnInsFormulas.Disable();
201 : 0 : aBtnInsNotes.Disable();
202 : 0 : aBtnInsAttrs.Disable();
203 : 0 : aBtnInsObjects.Disable();
204 : : }
205 : : else
206 : : {
207 : 0 : aBtnInsStrings.Enable();
208 : 0 : aBtnInsNumbers.Enable();
209 : 0 : aBtnInsDateTime.Enable();
210 : 0 : aBtnInsFormulas.Enable();
211 : 0 : aBtnInsNotes.Enable();
212 : 0 : aBtnInsAttrs.Enable();
213 : :
214 : : // "Objects" is disabled for "Fill Tables"
215 : 0 : if ( bFillMode )
216 : 0 : aBtnInsObjects.Disable();
217 : : else
218 : 0 : aBtnInsObjects.Enable();
219 : : }
220 : 0 : }
221 : :
222 : : // Link in anderes Dokument -> alles andere disabled
223 : :
224 : 0 : void ScInsertContentsDlg::TestModes()
225 : : {
226 : 0 : if ( bOtherDoc && aBtnLink.IsChecked() )
227 : : {
228 : 0 : aBtnSkipEmptyCells.Disable();
229 : 0 : aBtnTranspose.Disable();
230 : 0 : aRbNoOp.Disable();
231 : 0 : aRbAdd.Disable();
232 : 0 : aRbSub.Disable();
233 : 0 : aRbMul.Disable();
234 : 0 : aRbDiv.Disable();
235 : 0 : aFlOperation.Disable();
236 : :
237 : 0 : aRbMoveNone.Disable();
238 : 0 : aRbMoveDown.Disable();
239 : 0 : aRbMoveRight.Disable();
240 : 0 : aFlMove.Disable();
241 : :
242 : 0 : aFlFrame.Disable();
243 : 0 : aBtnInsAll.Disable();
244 : 0 : DisableChecks(sal_True);
245 : : }
246 : : else
247 : : {
248 : 0 : aBtnSkipEmptyCells.Enable();
249 : 0 : aBtnTranspose.Enable(!bFillMode);
250 : 0 : aRbNoOp.Enable();
251 : 0 : aRbAdd.Enable();
252 : 0 : aRbSub.Enable();
253 : 0 : aRbMul.Enable();
254 : 0 : aRbDiv.Enable();
255 : 0 : aFlOperation.Enable();
256 : :
257 : 0 : aRbMoveNone.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
258 : 0 : aRbMoveDown.Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
259 : 0 : aRbMoveRight.Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
260 : 0 : aFlMove.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
261 : :
262 : 0 : aFlFrame.Enable();
263 : 0 : aBtnInsAll.Enable();
264 : 0 : DisableChecks( aBtnInsAll.IsChecked() );
265 : : }
266 : 0 : }
267 : :
268 : 0 : void ScInsertContentsDlg::SetOtherDoc( sal_Bool bSet )
269 : : {
270 : 0 : if ( bSet != bOtherDoc )
271 : : {
272 : 0 : bOtherDoc = bSet;
273 : 0 : TestModes();
274 : 0 : if ( bSet )
275 : 0 : aRbMoveNone.Check(sal_True);
276 : : }
277 : 0 : }
278 : :
279 : 0 : void ScInsertContentsDlg::SetFillMode( sal_Bool bSet )
280 : : {
281 : 0 : if ( bSet != bFillMode )
282 : : {
283 : 0 : bFillMode = bSet;
284 : 0 : TestModes();
285 : 0 : if ( bSet )
286 : 0 : aRbMoveNone.Check(sal_True);
287 : : }
288 : 0 : }
289 : :
290 : 0 : void ScInsertContentsDlg::SetChangeTrack( sal_Bool bSet )
291 : : {
292 : 0 : if ( bSet != bChangeTrack )
293 : : {
294 : 0 : bChangeTrack = bSet;
295 : 0 : TestModes();
296 : 0 : if ( bSet )
297 : 0 : aRbMoveNone.Check(sal_True);
298 : : }
299 : 0 : }
300 : :
301 : 0 : void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
302 : : {
303 : 0 : sal_Bool bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
304 : 0 : sal_Bool bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
305 : 0 : if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
306 : : {
307 : 0 : bMoveDownDisabled = bDown;
308 : 0 : bMoveRightDisabled = bRight;
309 : 0 : TestModes();
310 : 0 : if ( bMoveDownDisabled && aRbMoveDown.IsChecked() )
311 : 0 : aRbMoveNone.Check(sal_True);
312 : 0 : if ( bMoveRightDisabled && aRbMoveRight.IsChecked() )
313 : 0 : aRbMoveNone.Check(sal_True);
314 : : }
315 : 0 : }
316 : :
317 : :
318 : : //------------------------------------------------------------------------
319 : :
320 : 0 : IMPL_LINK_NOARG(ScInsertContentsDlg, InsAllHdl)
321 : : {
322 : 0 : DisableChecks( aBtnInsAll.IsChecked() );
323 : :
324 : 0 : return 0;
325 : : }
326 : :
327 : 0 : IMPL_LINK_NOARG(ScInsertContentsDlg, LinkBtnHdl)
328 : : {
329 : 0 : TestModes();
330 : :
331 : 0 : return 0;
332 : : }
333 : :
334 : 0 : ScInsertContentsDlg::~ScInsertContentsDlg()
335 : : {
336 : 0 : ScInsertContentsDlg::nPreviousChecks2 = 0;
337 : 0 : if(aBtnSkipEmptyCells.IsChecked())
338 : 0 : ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
339 : 0 : if( aBtnTranspose.IsChecked())
340 : 0 : ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
341 : 0 : if( aBtnLink.IsChecked() )
342 : 0 : ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
343 : :
344 : 0 : if (!bFillMode) // im FillMode ist None gecheckt und alle 3 disabled
345 : : {
346 : 0 : if ( aRbMoveNone.IsChecked() )
347 : 0 : ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
348 : 0 : else if ( aRbMoveDown.IsChecked() )
349 : 0 : ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
350 : 0 : else if ( aRbMoveRight.IsChecked() )
351 : 0 : ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
352 : : }
353 : 0 : }
354 : :
355 : 0 : sal_uInt16 ScInsertContentsDlg::GetFormulaCmdBits() const
356 : : {
357 : 0 : ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
358 : 0 : if(aRbAdd.IsChecked())
359 : 0 : ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
360 : 0 : else if(aRbSub.IsChecked())
361 : 0 : ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
362 : 0 : else if(aRbMul.IsChecked())
363 : 0 : ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
364 : 0 : else if(aRbDiv.IsChecked())
365 : 0 : ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
366 : : // Bits fuer Checkboxen ausblenden
367 : 0 : return ScInsertContentsDlg::nPreviousFormulaChecks;
368 : : }
369 : :
370 : :
371 : :
372 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|