update dev300-m58
[ooovba.git] / sc / source / ui / miscdlgs / inscodlg.cxx
blobfff4ed7cb7def686f7521be6f512797b03077e79
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: inscodlg.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
38 //------------------------------------------------------------------
40 #include "inscodlg.hxx"
41 #include "scresid.hxx"
42 #include "miscdlgs.hrc"
45 //==================================================================
47 BOOL ScInsertContentsDlg::bPreviousAllCheck = TRUE;
48 USHORT ScInsertContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
49 IDF_NOTE | IDF_FORMULA |
50 IDF_ATTRIB | IDF_OBJECTS);
51 USHORT ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
52 USHORT ScInsertContentsDlg::nPreviousChecks2 = 0;
53 USHORT ScInsertContentsDlg::nPreviousMoveMode = INS_NONE; // enum InsCellCmd
55 //-----------------------------------------------------------------------
57 ScInsertContentsDlg::ScInsertContentsDlg( Window* pParent,
58 USHORT nCheckDefaults,
59 const String* pStrTitle )
61 : ModalDialog ( pParent, ScResId( RID_SCDLG_INSCONT ) ),
63 aFlFrame ( this, ScResId( FL_FRAME ) ),
64 aBtnInsAll ( this, ScResId( BTN_INSALL ) ),
65 aBtnInsStrings ( this, ScResId( BTN_INSSTRINGS ) ),
66 aBtnInsNumbers ( this, ScResId( BTN_INSNUMBERS ) ),
67 aBtnInsDateTime ( this, ScResId( BTN_INSDATETIME ) ),
68 aBtnInsFormulas ( this, ScResId( BTN_INSFORMULAS ) ),
69 aBtnInsNotes ( this, ScResId( BTN_INSNOTES ) ),
70 aBtnInsAttrs ( this, ScResId( BTN_INSATTRS ) ),
71 aBtnInsObjects ( this, ScResId( BTN_INSOBJECTS ) ),
72 aFlSep1 ( this, ScResId( FL_SEP1 ) ),
73 aFlOptions ( this, ScResId( FL_OPTIONS ) ),
74 aBtnSkipEmptyCells( this, ScResId(BTN_SKIP_EMPTY ) ),
75 aBtnTranspose ( this, ScResId( BTN_TRANSPOSE ) ),
76 aBtnLink ( this, ScResId( BTN_LINK ) ),
77 aFlOperation ( this, ScResId( FL_OPERATION ) ),
78 aRbNoOp ( this, ScResId( BTN_OP_NOOP ) ),
79 aRbAdd ( this, ScResId( BTN_OP_ADD ) ),
80 aRbSub ( this, ScResId( BTN_OP_SUB ) ),
81 aRbMul ( this, ScResId( BTN_OP_MUL ) ),
82 aRbDiv ( this, ScResId( BTN_OP_DIV ) ),
83 aFlSep2 ( this, ScResId( FL_SEP2 ) ),
84 aFlMove ( this, ScResId( FL_MOVE ) ),
85 aRbMoveNone ( this, ScResId( BTN_MV_NONE ) ),
86 aRbMoveDown ( this, ScResId( BTN_MV_DOWN ) ),
87 aRbMoveRight ( this, ScResId( BTN_MV_RIGHT ) ),
88 aBtnOk ( this, ScResId( BTN_OK ) ),
89 aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
90 aBtnHelp ( this, ScResId( BTN_HELP ) ),
91 bOtherDoc ( FALSE ),
92 bFillMode ( FALSE ),
93 bChangeTrack ( FALSE ),
94 bMoveDownDisabled( FALSE ),
95 bMoveRightDisabled( FALSE )
97 if ( pStrTitle )
98 SetText( *pStrTitle );
100 if ( nCheckDefaults != 0 )
102 ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
103 ScInsertContentsDlg::bPreviousAllCheck = FALSE;
104 ScInsertContentsDlg::nPreviousChecks2 = 0;
107 aBtnInsAll.Check ( ScInsertContentsDlg::bPreviousAllCheck );
108 aBtnInsStrings.Check ( IS_SET( IDF_STRING,
109 ScInsertContentsDlg::nPreviousChecks ) );
110 aBtnInsNumbers.Check ( IS_SET( IDF_VALUE,
111 ScInsertContentsDlg::nPreviousChecks ) );
112 aBtnInsDateTime.Check( IS_SET( IDF_DATETIME,
113 ScInsertContentsDlg::nPreviousChecks ) );
114 aBtnInsFormulas.Check( IS_SET( IDF_FORMULA,
115 ScInsertContentsDlg::nPreviousChecks ) );
116 aBtnInsNotes.Check ( IS_SET( IDF_NOTE,
117 ScInsertContentsDlg::nPreviousChecks ) );
118 aBtnInsAttrs.Check ( IS_SET( IDF_ATTRIB,
119 ScInsertContentsDlg::nPreviousChecks ) );
120 aBtnInsObjects.Check ( IS_SET( IDF_OBJECTS,
121 ScInsertContentsDlg::nPreviousChecks ) );
123 switch( ScInsertContentsDlg::nPreviousFormulaChecks )
125 case PASTE_NOFUNC: aRbNoOp.Check(TRUE); break;
126 case PASTE_ADD: aRbAdd.Check(TRUE); break;
127 case PASTE_SUB: aRbSub.Check(TRUE); break;
128 case PASTE_MUL: aRbMul.Check(TRUE); break;
129 case PASTE_DIV: aRbDiv.Check(TRUE); break;
132 switch( ScInsertContentsDlg::nPreviousMoveMode )
134 case INS_NONE: aRbMoveNone.Check(TRUE); break;
135 case INS_CELLSDOWN: aRbMoveDown.Check(TRUE); break;
136 case INS_CELLSRIGHT: aRbMoveRight.Check(TRUE); break;
139 aBtnSkipEmptyCells.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
140 aBtnTranspose.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_TRANS ) != 0);
141 aBtnLink.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_LINK ) != 0);
143 DisableChecks( aBtnInsAll.IsChecked() );
145 aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
146 aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
148 aBtnInsAll.SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
149 aBtnLink.SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
151 //-------------
152 FreeResource();
155 //------------------------------------------------------------------------
157 USHORT ScInsertContentsDlg::GetInsContentsCmdBits() const
159 ScInsertContentsDlg::nPreviousChecks = 0;
161 if ( aBtnInsStrings.IsChecked() )
162 ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
163 if ( aBtnInsNumbers.IsChecked() )
164 ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
165 if ( aBtnInsDateTime.IsChecked())
166 ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
167 if ( aBtnInsFormulas.IsChecked())
168 ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
169 if ( aBtnInsNotes.IsChecked() )
170 ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
171 if ( aBtnInsAttrs.IsChecked() )
172 ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
173 if ( aBtnInsObjects.IsChecked() )
174 ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
176 ScInsertContentsDlg::bPreviousAllCheck = aBtnInsAll.IsChecked();
178 return ( (ScInsertContentsDlg::bPreviousAllCheck)
179 ? IDF_ALL
180 : ScInsertContentsDlg::nPreviousChecks );
183 //------------------------------------------------------------------------
185 InsCellCmd ScInsertContentsDlg::GetMoveMode()
187 if ( aRbMoveDown.IsChecked() )
188 return INS_CELLSDOWN;
189 if ( aRbMoveRight.IsChecked() )
190 return INS_CELLSRIGHT;
192 return INS_NONE;
195 //------------------------------------------------------------------------
197 void ScInsertContentsDlg::DisableChecks( BOOL bInsAllChecked )
199 if ( bInsAllChecked )
201 aBtnInsStrings.Disable();
202 aBtnInsNumbers.Disable();
203 aBtnInsDateTime.Disable();
204 aBtnInsFormulas.Disable();
205 aBtnInsNotes.Disable();
206 aBtnInsAttrs.Disable();
207 aBtnInsObjects.Disable();
209 else
211 aBtnInsStrings.Enable();
212 aBtnInsNumbers.Enable();
213 aBtnInsDateTime.Enable();
214 aBtnInsFormulas.Enable();
215 aBtnInsNotes.Enable();
216 aBtnInsAttrs.Enable();
218 // "Objects" is disabled for "Fill Tables"
219 if ( bFillMode )
220 aBtnInsObjects.Disable();
221 else
222 aBtnInsObjects.Enable();
226 // Link in anderes Dokument -> alles andere disabled
228 void ScInsertContentsDlg::TestModes()
230 if ( bOtherDoc && aBtnLink.IsChecked() )
232 aBtnSkipEmptyCells.Disable();
233 aBtnTranspose.Disable();
234 aRbNoOp.Disable();
235 aRbAdd.Disable();
236 aRbSub.Disable();
237 aRbMul.Disable();
238 aRbDiv.Disable();
239 aFlOperation.Disable();
241 aRbMoveNone.Disable();
242 aRbMoveDown.Disable();
243 aRbMoveRight.Disable();
244 aFlMove.Disable();
246 aFlFrame.Disable();
247 aBtnInsAll.Disable();
248 DisableChecks(TRUE);
250 else
252 aBtnSkipEmptyCells.Enable();
253 aBtnTranspose.Enable(!bFillMode);
254 aRbNoOp.Enable();
255 aRbAdd.Enable();
256 aRbSub.Enable();
257 aRbMul.Enable();
258 aRbDiv.Enable();
259 aFlOperation.Enable();
261 aRbMoveNone.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
262 aRbMoveDown.Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
263 aRbMoveRight.Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
264 aFlMove.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
266 aFlFrame.Enable();
267 aBtnInsAll.Enable();
268 DisableChecks( aBtnInsAll.IsChecked() );
272 void ScInsertContentsDlg::SetOtherDoc( BOOL bSet )
274 if ( bSet != bOtherDoc )
276 bOtherDoc = bSet;
277 TestModes();
278 if ( bSet )
279 aRbMoveNone.Check(TRUE);
283 void ScInsertContentsDlg::SetFillMode( BOOL bSet )
285 if ( bSet != bFillMode )
287 bFillMode = bSet;
288 TestModes();
289 if ( bSet )
290 aRbMoveNone.Check(TRUE);
294 void ScInsertContentsDlg::SetChangeTrack( BOOL bSet )
296 if ( bSet != bChangeTrack )
298 bChangeTrack = bSet;
299 TestModes();
300 if ( bSet )
301 aRbMoveNone.Check(TRUE);
305 void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
307 BOOL bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
308 BOOL bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
309 if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
311 bMoveDownDisabled = bDown;
312 bMoveRightDisabled = bRight;
313 TestModes();
314 if ( bMoveDownDisabled && aRbMoveDown.IsChecked() )
315 aRbMoveNone.Check(TRUE);
316 if ( bMoveRightDisabled && aRbMoveRight.IsChecked() )
317 aRbMoveNone.Check(TRUE);
322 //------------------------------------------------------------------------
324 IMPL_LINK( ScInsertContentsDlg, InsAllHdl, void*, EMPTYARG )
326 DisableChecks( aBtnInsAll.IsChecked() );
328 return 0;
331 IMPL_LINK( ScInsertContentsDlg, LinkBtnHdl, void*, EMPTYARG )
333 TestModes();
335 return 0;
338 __EXPORT ScInsertContentsDlg::~ScInsertContentsDlg()
340 ScInsertContentsDlg::nPreviousChecks2 = 0;
341 if(aBtnSkipEmptyCells.IsChecked())
342 ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
343 if( aBtnTranspose.IsChecked())
344 ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
345 if( aBtnLink.IsChecked() )
346 ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
348 if (!bFillMode) // im FillMode ist None gecheckt und alle 3 disabled
350 if ( aRbMoveNone.IsChecked() )
351 ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
352 else if ( aRbMoveDown.IsChecked() )
353 ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
354 else if ( aRbMoveRight.IsChecked() )
355 ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
359 USHORT ScInsertContentsDlg::GetFormulaCmdBits() const
361 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
362 if(aRbAdd.IsChecked())
363 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
364 else if(aRbSub.IsChecked())
365 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
366 else if(aRbMul.IsChecked())
367 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
368 else if(aRbDiv.IsChecked())
369 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
370 // Bits fuer Checkboxen ausblenden
371 return ScInsertContentsDlg::nPreviousFormulaChecks;