xref: /aoo4110/main/sc/source/ui/miscdlgs/delcodlg.cxx (revision b1cdbd2c)
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_sc.hxx"
26 
27 #undef SC_DLLIMPLEMENTATION
28 
29 
30 
31 //------------------------------------------------------------------
32 
33 #include "delcodlg.hxx"
34 #include "scresid.hxx"
35 #include "miscdlgs.hrc"
36 
37 
38 //==================================================================
39 
40 sal_Bool   ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
41 sal_uInt16 ScDeleteContentsDlg::nPreviousChecks   = (IDF_DATETIME | IDF_STRING  |
42 												 IDF_NOTE     | IDF_FORMULA |
43 												 IDF_VALUE);
44 
45 //-----------------------------------------------------------------------
46 
ScDeleteContentsDlg(Window * pParent,sal_uInt16 nCheckDefaults)47 ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent,
48 										  sal_uInt16  nCheckDefaults ) :
49 	ModalDialog     ( pParent, ScResId( RID_SCDLG_DELCONT ) ),
50 	//
51     aFlFrame        ( this, ScResId( FL_FRAME ) ),
52 	aBtnDelAll      ( this, ScResId( BTN_DELALL ) ),
53 	aBtnDelStrings  ( this, ScResId( BTN_DELSTRINGS ) ),
54 	aBtnDelNumbers  ( this, ScResId( BTN_DELNUMBERS ) ),
55 	aBtnDelDateTime ( this, ScResId( BTN_DELDATETIME ) ),
56 	aBtnDelFormulas ( this, ScResId( BTN_DELFORMULAS ) ),
57 	aBtnDelNotes    ( this, ScResId( BTN_DELNOTES ) ),
58 	aBtnDelAttrs    ( this, ScResId( BTN_DELATTRS ) ),
59 	aBtnDelObjects	( this, ScResId( BTN_DELOBJECTS ) ),
60 	aBtnOk          ( this, ScResId( BTN_OK ) ),
61 	aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
62 	aBtnHelp        ( this, ScResId( BTN_HELP ) ),
63 	bObjectsDisabled( sal_False )
64 {
65 	if ( nCheckDefaults != 0 )
66 	{
67 		ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults;
68 		ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
69 	}
70 
71 	aBtnDelAll.Check     ( ScDeleteContentsDlg::bPreviousAllCheck );
72 	aBtnDelStrings.Check ( IS_SET( IDF_STRING,
73 								   ScDeleteContentsDlg::nPreviousChecks ) );
74 	aBtnDelNumbers.Check ( IS_SET( IDF_VALUE,
75 								   ScDeleteContentsDlg::nPreviousChecks ) );
76 	aBtnDelDateTime.Check( IS_SET( IDF_DATETIME,
77 								   ScDeleteContentsDlg::nPreviousChecks ) );
78 	aBtnDelFormulas.Check( IS_SET( IDF_FORMULA,
79 								   ScDeleteContentsDlg::nPreviousChecks ) );
80 	aBtnDelNotes.Check   ( IS_SET( IDF_NOTE,
81 								   ScDeleteContentsDlg::nPreviousChecks ) );
82 	aBtnDelAttrs.Check   ( IS_SET( IDF_ATTRIB,
83 								   ScDeleteContentsDlg::nPreviousChecks ) );
84 	aBtnDelObjects.Check ( IS_SET( IDF_OBJECTS,
85 								   ScDeleteContentsDlg::nPreviousChecks ) );
86 
87 	DisableChecks( aBtnDelAll.IsChecked() );
88 
89 	aBtnDelAll.SetClickHdl( LINK( this, ScDeleteContentsDlg, DelAllHdl ) );
90 
91 	//-------------
92 	FreeResource();
93 }
94 
95 //------------------------------------------------------------------------
96 
GetDelContentsCmdBits() const97 sal_uInt16 ScDeleteContentsDlg::GetDelContentsCmdBits() const
98 {
99 	ScDeleteContentsDlg::nPreviousChecks = 0;
100 
101 	if ( aBtnDelStrings.IsChecked() )
102 		ScDeleteContentsDlg::nPreviousChecks  = IDF_STRING;
103 	if ( aBtnDelNumbers.IsChecked() )
104 		ScDeleteContentsDlg::nPreviousChecks |= IDF_VALUE;
105 	if ( aBtnDelDateTime.IsChecked())
106 		ScDeleteContentsDlg::nPreviousChecks |= IDF_DATETIME;
107 	if ( aBtnDelFormulas.IsChecked())
108 		ScDeleteContentsDlg::nPreviousChecks |= IDF_FORMULA;
109 	if ( aBtnDelNotes.IsChecked()   )
110 		ScDeleteContentsDlg::nPreviousChecks |= IDF_NOTE;
111 	if ( aBtnDelAttrs.IsChecked()   )
112 		ScDeleteContentsDlg::nPreviousChecks |= IDF_ATTRIB;
113 	if ( aBtnDelObjects.IsChecked() )
114 		ScDeleteContentsDlg::nPreviousChecks |= IDF_OBJECTS;
115 
116 	ScDeleteContentsDlg::bPreviousAllCheck = aBtnDelAll.IsChecked();
117 
118 	return ( (ScDeleteContentsDlg::bPreviousAllCheck)
119 				? IDF_ALL
120 				: ScDeleteContentsDlg::nPreviousChecks );
121 }
122 
123 //------------------------------------------------------------------------
124 
DisableChecks(sal_Bool bDelAllChecked)125 void ScDeleteContentsDlg::DisableChecks( sal_Bool bDelAllChecked )
126 {
127 	if ( bDelAllChecked )
128 	{
129 		aBtnDelStrings.Disable();
130 		aBtnDelNumbers.Disable();
131 		aBtnDelDateTime.Disable();
132 		aBtnDelFormulas.Disable();
133 		aBtnDelNotes.Disable();
134 		aBtnDelAttrs.Disable();
135 		aBtnDelObjects.Disable();
136 	}
137 	else
138 	{
139 		aBtnDelStrings.Enable();
140 		aBtnDelNumbers.Enable();
141 		aBtnDelDateTime.Enable();
142 		aBtnDelFormulas.Enable();
143 		aBtnDelNotes.Enable();
144 		aBtnDelAttrs.Enable();
145 		if (bObjectsDisabled)
146 			aBtnDelObjects.Disable();
147 		else
148 			aBtnDelObjects.Enable();
149 	}
150 }
151 
152 //------------------------------------------------------------------------
153 
DisableObjects()154 void ScDeleteContentsDlg::DisableObjects()
155 {
156 	bObjectsDisabled = sal_True;
157 	aBtnDelObjects.Check(sal_False);
158 	aBtnDelObjects.Disable();
159 }
160 
161 //------------------------------------------------------------------------
162 
IMPL_LINK_INLINE_START(ScDeleteContentsDlg,DelAllHdl,void *,EMPTYARG)163 IMPL_LINK_INLINE_START( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
164 {
165 	DisableChecks( aBtnDelAll.IsChecked() );
166 
167 	return 0;
168 }
IMPL_LINK_INLINE_END(ScDeleteContentsDlg,DelAllHdl,void *,EMPTYARG)169 IMPL_LINK_INLINE_END( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
170 
171 __EXPORT ScDeleteContentsDlg::~ScDeleteContentsDlg()
172 {
173 }
174 
175 
176 
177