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 .
21 #undef SC_DLLIMPLEMENTATION
25 //------------------------------------------------------------------
27 #include "inscodlg.hxx"
28 #include "scresid.hxx"
29 #include "miscdlgs.hrc"
32 //==================================================================
34 sal_Bool
ScInsertContentsDlg::bPreviousAllCheck
= sal_True
;
35 sal_uInt16
ScInsertContentsDlg::nPreviousChecks
= (IDF_DATETIME
| IDF_STRING
|
36 IDF_NOTE
| IDF_FORMULA
|
37 IDF_ATTRIB
| IDF_OBJECTS
);
38 sal_uInt16
ScInsertContentsDlg::nPreviousFormulaChecks
= PASTE_NOFUNC
;
39 sal_uInt16
ScInsertContentsDlg::nPreviousChecks2
= 0;
40 sal_uInt16
ScInsertContentsDlg::nPreviousMoveMode
= INS_NONE
; // enum InsCellCmd
42 //-----------------------------------------------------------------------
44 ScInsertContentsDlg::ScInsertContentsDlg( Window
* pParent
,
45 sal_uInt16 nCheckDefaults
,
46 const OUString
* pStrTitle
)
48 : ModalDialog ( pParent
, ScResId( RID_SCDLG_INSCONT
) ),
50 aFlFrame ( this, ScResId( FL_FRAME
) ),
51 aBtnInsAll ( this, ScResId( BTN_INSALL
) ),
52 aBtnInsStrings ( this, ScResId( BTN_INSSTRINGS
) ),
53 aBtnInsNumbers ( this, ScResId( BTN_INSNUMBERS
) ),
54 aBtnInsDateTime ( this, ScResId( BTN_INSDATETIME
) ),
55 aBtnInsFormulas ( this, ScResId( BTN_INSFORMULAS
) ),
56 aBtnInsNotes ( this, ScResId( BTN_INSNOTES
) ),
57 aBtnInsAttrs ( this, ScResId( BTN_INSATTRS
) ),
58 aBtnInsObjects ( this, ScResId( BTN_INSOBJECTS
) ),
59 aFlSep1 ( this, ScResId( FL_SEP1
) ),
60 aFlOptions ( this, ScResId( FL_OPTIONS
) ),
61 aBtnSkipEmptyCells( this, ScResId(BTN_SKIP_EMPTY
) ),
62 aBtnTranspose ( this, ScResId( BTN_TRANSPOSE
) ),
63 aBtnLink ( this, ScResId( BTN_LINK
) ),
64 aFlOperation ( this, ScResId( FL_OPERATION
) ),
65 aRbNoOp ( this, ScResId( BTN_OP_NOOP
) ),
66 aRbAdd ( this, ScResId( BTN_OP_ADD
) ),
67 aRbSub ( this, ScResId( BTN_OP_SUB
) ),
68 aRbMul ( this, ScResId( BTN_OP_MUL
) ),
69 aRbDiv ( this, ScResId( BTN_OP_DIV
) ),
70 aFlSep2 ( this, ScResId( FL_SEP2
) ),
71 aFlMove ( this, ScResId( FL_MOVE
) ),
72 aRbMoveNone ( this, ScResId( BTN_MV_NONE
) ),
73 aRbMoveDown ( this, ScResId( BTN_MV_DOWN
) ),
74 aRbMoveRight ( this, ScResId( BTN_MV_RIGHT
) ),
75 aBtnOk ( this, ScResId( BTN_OK
) ),
76 aBtnCancel ( this, ScResId( BTN_CANCEL
) ),
77 aBtnHelp ( this, ScResId( BTN_HELP
) ),
80 bChangeTrack ( false ),
81 bMoveDownDisabled( false ),
82 bMoveRightDisabled( false )
85 SetText( *pStrTitle
);
87 if ( nCheckDefaults
!= 0 )
89 ScInsertContentsDlg::nPreviousChecks
= nCheckDefaults
;
90 ScInsertContentsDlg::bPreviousAllCheck
= false;
91 ScInsertContentsDlg::nPreviousChecks2
= 0;
94 aBtnInsAll
.Check ( ScInsertContentsDlg::bPreviousAllCheck
);
95 aBtnInsStrings
.Check ( IS_SET( IDF_STRING
,
96 ScInsertContentsDlg::nPreviousChecks
) );
97 aBtnInsNumbers
.Check ( IS_SET( IDF_VALUE
,
98 ScInsertContentsDlg::nPreviousChecks
) );
99 aBtnInsDateTime
.Check( IS_SET( IDF_DATETIME
,
100 ScInsertContentsDlg::nPreviousChecks
) );
101 aBtnInsFormulas
.Check( IS_SET( IDF_FORMULA
,
102 ScInsertContentsDlg::nPreviousChecks
) );
103 aBtnInsNotes
.Check ( IS_SET( IDF_NOTE
,
104 ScInsertContentsDlg::nPreviousChecks
) );
105 aBtnInsAttrs
.Check ( IS_SET( IDF_ATTRIB
,
106 ScInsertContentsDlg::nPreviousChecks
) );
107 aBtnInsObjects
.Check ( IS_SET( IDF_OBJECTS
,
108 ScInsertContentsDlg::nPreviousChecks
) );
110 switch( ScInsertContentsDlg::nPreviousFormulaChecks
)
112 case PASTE_NOFUNC
: aRbNoOp
.Check(sal_True
); break;
113 case PASTE_ADD
: aRbAdd
.Check(sal_True
); break;
114 case PASTE_SUB
: aRbSub
.Check(sal_True
); break;
115 case PASTE_MUL
: aRbMul
.Check(sal_True
); break;
116 case PASTE_DIV
: aRbDiv
.Check(sal_True
); break;
119 switch( ScInsertContentsDlg::nPreviousMoveMode
)
121 case INS_NONE
: aRbMoveNone
.Check(sal_True
); break;
122 case INS_CELLSDOWN
: aRbMoveDown
.Check(sal_True
); break;
123 case INS_CELLSRIGHT
: aRbMoveRight
.Check(sal_True
); break;
126 aBtnSkipEmptyCells
.Check( ( ScInsertContentsDlg::nPreviousChecks2
& INS_CONT_NOEMPTY
) != 0);
127 aBtnTranspose
.Check( ( ScInsertContentsDlg::nPreviousChecks2
& INS_CONT_TRANS
) != 0);
128 aBtnLink
.Check( ( ScInsertContentsDlg::nPreviousChecks2
& INS_CONT_LINK
) != 0);
130 DisableChecks( aBtnInsAll
.IsChecked() );
132 aFlSep1
.SetStyle( aFlSep1
.GetStyle() | WB_VERT
);
133 aFlSep2
.SetStyle( aFlSep2
.GetStyle() | WB_VERT
);
135 aBtnInsAll
.SetClickHdl( LINK( this, ScInsertContentsDlg
, InsAllHdl
) );
136 aBtnLink
.SetClickHdl( LINK( this, ScInsertContentsDlg
, LinkBtnHdl
) );
142 //------------------------------------------------------------------------
144 sal_uInt16
ScInsertContentsDlg::GetInsContentsCmdBits() const
146 ScInsertContentsDlg::nPreviousChecks
= 0;
148 if ( aBtnInsStrings
.IsChecked() )
149 ScInsertContentsDlg::nPreviousChecks
= IDF_STRING
;
150 if ( aBtnInsNumbers
.IsChecked() )
151 ScInsertContentsDlg::nPreviousChecks
|= IDF_VALUE
;
152 if ( aBtnInsDateTime
.IsChecked())
153 ScInsertContentsDlg::nPreviousChecks
|= IDF_DATETIME
;
154 if ( aBtnInsFormulas
.IsChecked())
155 ScInsertContentsDlg::nPreviousChecks
|= IDF_FORMULA
;
156 if ( aBtnInsNotes
.IsChecked() )
157 ScInsertContentsDlg::nPreviousChecks
|= IDF_NOTE
;
158 if ( aBtnInsAttrs
.IsChecked() )
159 ScInsertContentsDlg::nPreviousChecks
|= IDF_ATTRIB
;
160 if ( aBtnInsObjects
.IsChecked() )
161 ScInsertContentsDlg::nPreviousChecks
|= IDF_OBJECTS
;
163 ScInsertContentsDlg::bPreviousAllCheck
= aBtnInsAll
.IsChecked();
165 return ( (ScInsertContentsDlg::bPreviousAllCheck
)
167 : ScInsertContentsDlg::nPreviousChecks
);
170 //------------------------------------------------------------------------
172 InsCellCmd
ScInsertContentsDlg::GetMoveMode()
174 if ( aRbMoveDown
.IsChecked() )
175 return INS_CELLSDOWN
;
176 if ( aRbMoveRight
.IsChecked() )
177 return INS_CELLSRIGHT
;
182 //------------------------------------------------------------------------
184 void ScInsertContentsDlg::DisableChecks( sal_Bool bInsAllChecked
)
186 if ( bInsAllChecked
)
188 aBtnInsStrings
.Disable();
189 aBtnInsNumbers
.Disable();
190 aBtnInsDateTime
.Disable();
191 aBtnInsFormulas
.Disable();
192 aBtnInsNotes
.Disable();
193 aBtnInsAttrs
.Disable();
194 aBtnInsObjects
.Disable();
198 aBtnInsStrings
.Enable();
199 aBtnInsNumbers
.Enable();
200 aBtnInsDateTime
.Enable();
201 aBtnInsFormulas
.Enable();
202 aBtnInsNotes
.Enable();
203 aBtnInsAttrs
.Enable();
205 // "Objects" is disabled for "Fill Tables"
207 aBtnInsObjects
.Disable();
209 aBtnInsObjects
.Enable();
213 // Link in anderes Dokument -> alles andere disabled
215 void ScInsertContentsDlg::TestModes()
217 if ( bOtherDoc
&& aBtnLink
.IsChecked() )
219 aBtnSkipEmptyCells
.Disable();
220 aBtnTranspose
.Disable();
226 aFlOperation
.Disable();
228 aRbMoveNone
.Disable();
229 aRbMoveDown
.Disable();
230 aRbMoveRight
.Disable();
234 aBtnInsAll
.Disable();
235 DisableChecks(sal_True
);
239 aBtnSkipEmptyCells
.Enable();
240 aBtnTranspose
.Enable(!bFillMode
);
246 aFlOperation
.Enable();
248 aRbMoveNone
.Enable(!bFillMode
&& !bChangeTrack
&& !(bMoveDownDisabled
&& bMoveRightDisabled
));
249 aRbMoveDown
.Enable(!bFillMode
&& !bChangeTrack
&& !bMoveDownDisabled
);
250 aRbMoveRight
.Enable(!bFillMode
&& !bChangeTrack
&& !bMoveRightDisabled
);
251 aFlMove
.Enable(!bFillMode
&& !bChangeTrack
&& !(bMoveDownDisabled
&& bMoveRightDisabled
));
255 DisableChecks( aBtnInsAll
.IsChecked() );
259 void ScInsertContentsDlg::SetOtherDoc( sal_Bool bSet
)
261 if ( bSet
!= bOtherDoc
)
266 aRbMoveNone
.Check(sal_True
);
270 void ScInsertContentsDlg::SetFillMode( sal_Bool bSet
)
272 if ( bSet
!= bFillMode
)
277 aRbMoveNone
.Check(sal_True
);
281 void ScInsertContentsDlg::SetChangeTrack( sal_Bool bSet
)
283 if ( bSet
!= bChangeTrack
)
288 aRbMoveNone
.Check(sal_True
);
292 void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable
)
294 sal_Bool bDown
= ((nDisable
& SC_CELL_SHIFT_DISABLE_DOWN
) != 0);
295 sal_Bool bRight
= ((nDisable
& SC_CELL_SHIFT_DISABLE_RIGHT
) != 0);
296 if ( bDown
!= bMoveDownDisabled
|| bRight
!= bMoveRightDisabled
)
298 bMoveDownDisabled
= bDown
;
299 bMoveRightDisabled
= bRight
;
301 if ( bMoveDownDisabled
&& aRbMoveDown
.IsChecked() )
302 aRbMoveNone
.Check(sal_True
);
303 if ( bMoveRightDisabled
&& aRbMoveRight
.IsChecked() )
304 aRbMoveNone
.Check(sal_True
);
309 //------------------------------------------------------------------------
311 IMPL_LINK_NOARG(ScInsertContentsDlg
, InsAllHdl
)
313 DisableChecks( aBtnInsAll
.IsChecked() );
318 IMPL_LINK_NOARG(ScInsertContentsDlg
, LinkBtnHdl
)
325 ScInsertContentsDlg::~ScInsertContentsDlg()
327 ScInsertContentsDlg::nPreviousChecks2
= 0;
328 if(aBtnSkipEmptyCells
.IsChecked())
329 ScInsertContentsDlg::nPreviousChecks2
|= INS_CONT_NOEMPTY
;
330 if( aBtnTranspose
.IsChecked())
331 ScInsertContentsDlg::nPreviousChecks2
|= INS_CONT_TRANS
;
332 if( aBtnLink
.IsChecked() )
333 ScInsertContentsDlg::nPreviousChecks2
|= INS_CONT_LINK
;
335 if (!bFillMode
) // im FillMode ist None gecheckt und alle 3 disabled
337 if ( aRbMoveNone
.IsChecked() )
338 ScInsertContentsDlg::nPreviousMoveMode
= INS_NONE
;
339 else if ( aRbMoveDown
.IsChecked() )
340 ScInsertContentsDlg::nPreviousMoveMode
= INS_CELLSDOWN
;
341 else if ( aRbMoveRight
.IsChecked() )
342 ScInsertContentsDlg::nPreviousMoveMode
= INS_CELLSRIGHT
;
346 sal_uInt16
ScInsertContentsDlg::GetFormulaCmdBits() const
348 ScInsertContentsDlg::nPreviousFormulaChecks
= PASTE_NOFUNC
;
349 if(aRbAdd
.IsChecked())
350 ScInsertContentsDlg::nPreviousFormulaChecks
= PASTE_ADD
;
351 else if(aRbSub
.IsChecked())
352 ScInsertContentsDlg::nPreviousFormulaChecks
= PASTE_SUB
;
353 else if(aRbMul
.IsChecked())
354 ScInsertContentsDlg::nPreviousFormulaChecks
= PASTE_MUL
;
355 else if(aRbDiv
.IsChecked())
356 ScInsertContentsDlg::nPreviousFormulaChecks
= PASTE_DIV
;
357 // Bits fuer Checkboxen ausblenden
358 return ScInsertContentsDlg::nPreviousFormulaChecks
;
363 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */