xref: /trunk/main/sc/source/ui/miscdlgs/delcodlg.cxx (revision a479921a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_scui.hxx"
26 
27 
28 
29 
30 //------------------------------------------------------------------
31 
32 #include "delcodlg.hxx"
33 #include "scresid.hxx"
34 #include "miscdlgs.hrc"
35 
36 
37 //==================================================================
38 
39 sal_Bool   ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
40 sal_uInt16 ScDeleteContentsDlg::nPreviousChecks   = (IDF_DATETIME | IDF_STRING  |
41 												 IDF_NOTE     | IDF_FORMULA |
42 												 IDF_VALUE);
43 
44 //-----------------------------------------------------------------------
45 
ScDeleteContentsDlg(Window * pParent,sal_uInt16 nCheckDefaults)46 ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent,
47 										  sal_uInt16  nCheckDefaults ) :
48 	ModalDialog     ( pParent, ScResId( RID_SCDLG_DELCONT ) ),
49 	//
50     aFlFrame        ( this, ScResId( FL_FRAME ) ),
51 	aBtnDelAll      ( this, ScResId( BTN_DELALL ) ),
52 	aBtnDelStrings  ( this, ScResId( BTN_DELSTRINGS ) ),
53 	aBtnDelNumbers  ( this, ScResId( BTN_DELNUMBERS ) ),
54 	aBtnDelDateTime ( this, ScResId( BTN_DELDATETIME ) ),
55 	aBtnDelFormulas ( this, ScResId( BTN_DELFORMULAS ) ),
56 	aBtnDelNotes    ( this, ScResId( BTN_DELNOTES ) ),
57 	aBtnDelAttrs    ( this, ScResId( BTN_DELATTRS ) ),
58 	aBtnDelObjects	( this, ScResId( BTN_DELOBJECTS ) ),
59 	aBtnOk          ( this, ScResId( BTN_OK ) ),
60 	aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
61 	aBtnHelp        ( this, ScResId( BTN_HELP ) ),
62 	bObjectsDisabled( sal_False )
63 {
64 	if ( nCheckDefaults != 0 )
65 	{
66 		ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults;
67 		ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
68 	}
69 
70 	aBtnDelAll.Check     ( ScDeleteContentsDlg::bPreviousAllCheck );
71 	aBtnDelStrings.Check ( IS_SET( IDF_STRING,
72 								   ScDeleteContentsDlg::nPreviousChecks ) );
73 	aBtnDelNumbers.Check ( IS_SET( IDF_VALUE,
74 								   ScDeleteContentsDlg::nPreviousChecks ) );
75 	aBtnDelDateTime.Check( IS_SET( IDF_DATETIME,
76 								   ScDeleteContentsDlg::nPreviousChecks ) );
77 	aBtnDelFormulas.Check( IS_SET( IDF_FORMULA,
78 								   ScDeleteContentsDlg::nPreviousChecks ) );
79 	aBtnDelNotes.Check   ( IS_SET( IDF_NOTE,
80 								   ScDeleteContentsDlg::nPreviousChecks ) );
81 	aBtnDelAttrs.Check   ( IS_SET( IDF_ATTRIB,
82 								   ScDeleteContentsDlg::nPreviousChecks ) );
83 	aBtnDelObjects.Check ( IS_SET( IDF_OBJECTS,
84 								   ScDeleteContentsDlg::nPreviousChecks ) );
85 
86 	DisableChecks( aBtnDelAll.IsChecked() );
87 
88 	aBtnDelAll.SetClickHdl( LINK( this, ScDeleteContentsDlg, DelAllHdl ) );
89 
90 	//-------------
91 	FreeResource();
92 }
93 
94 //------------------------------------------------------------------------
95 
GetDelContentsCmdBits() const96 sal_uInt16 ScDeleteContentsDlg::GetDelContentsCmdBits() const
97 {
98 	ScDeleteContentsDlg::nPreviousChecks = 0;
99 
100 	if ( aBtnDelStrings.IsChecked() )
101 		ScDeleteContentsDlg::nPreviousChecks  = IDF_STRING;
102 	if ( aBtnDelNumbers.IsChecked() )
103 		ScDeleteContentsDlg::nPreviousChecks |= IDF_VALUE;
104 	if ( aBtnDelDateTime.IsChecked())
105 		ScDeleteContentsDlg::nPreviousChecks |= IDF_DATETIME;
106 	if ( aBtnDelFormulas.IsChecked())
107 		ScDeleteContentsDlg::nPreviousChecks |= IDF_FORMULA;
108 	if ( aBtnDelNotes.IsChecked()   )
109 		ScDeleteContentsDlg::nPreviousChecks |= IDF_NOTE;
110 	if ( aBtnDelAttrs.IsChecked()   )
111 		ScDeleteContentsDlg::nPreviousChecks |= IDF_ATTRIB;
112 	if ( aBtnDelObjects.IsChecked() )
113 		ScDeleteContentsDlg::nPreviousChecks |= IDF_OBJECTS;
114 
115 	ScDeleteContentsDlg::bPreviousAllCheck = aBtnDelAll.IsChecked();
116 
117 	return ( (ScDeleteContentsDlg::bPreviousAllCheck)
118 				? IDF_ALL
119 				: ScDeleteContentsDlg::nPreviousChecks );
120 }
121 
122 //------------------------------------------------------------------------
123 
DisableChecks(sal_Bool bDelAllChecked)124 void ScDeleteContentsDlg::DisableChecks( sal_Bool bDelAllChecked )
125 {
126 	if ( bDelAllChecked )
127 	{
128 		aBtnDelStrings.Disable();
129 		aBtnDelNumbers.Disable();
130 		aBtnDelDateTime.Disable();
131 		aBtnDelFormulas.Disable();
132 		aBtnDelNotes.Disable();
133 		aBtnDelAttrs.Disable();
134 		aBtnDelObjects.Disable();
135 	}
136 	else
137 	{
138 		aBtnDelStrings.Enable();
139 		aBtnDelNumbers.Enable();
140 		aBtnDelDateTime.Enable();
141 		aBtnDelFormulas.Enable();
142 		aBtnDelNotes.Enable();
143 		aBtnDelAttrs.Enable();
144 		if (bObjectsDisabled)
145 			aBtnDelObjects.Disable();
146 		else
147 			aBtnDelObjects.Enable();
148 	}
149 }
150 
151 //------------------------------------------------------------------------
152 
DisableObjects()153 void ScDeleteContentsDlg::DisableObjects()
154 {
155 	bObjectsDisabled = sal_True;
156 	aBtnDelObjects.Check(sal_False);
157 	aBtnDelObjects.Disable();
158 }
159 
160 //------------------------------------------------------------------------
161 
IMPL_LINK_INLINE_START(ScDeleteContentsDlg,DelAllHdl,void *,EMPTYARG)162 IMPL_LINK_INLINE_START( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
163 {
164 	DisableChecks( aBtnDelAll.IsChecked() );
165 
166 	return 0;
167 }
IMPL_LINK_INLINE_END(ScDeleteContentsDlg,DelAllHdl,void *,EMPTYARG)168 IMPL_LINK_INLINE_END( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
169 
170 __EXPORT ScDeleteContentsDlg::~ScDeleteContentsDlg()
171 {
172 }
173 
174 
175 
176