xref: /aoo42x/main/sc/source/ui/miscdlgs/delcodlg.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir //------------------------------------------------------------------
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "delcodlg.hxx"
38*cdf0e10cSrcweir #include "scresid.hxx"
39*cdf0e10cSrcweir #include "miscdlgs.hrc"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //==================================================================
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir sal_Bool   ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
45*cdf0e10cSrcweir sal_uInt16 ScDeleteContentsDlg::nPreviousChecks   = (IDF_DATETIME | IDF_STRING  |
46*cdf0e10cSrcweir 												 IDF_NOTE     | IDF_FORMULA |
47*cdf0e10cSrcweir 												 IDF_VALUE);
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //-----------------------------------------------------------------------
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent,
52*cdf0e10cSrcweir 										  sal_uInt16  nCheckDefaults ) :
53*cdf0e10cSrcweir 	ModalDialog     ( pParent, ScResId( RID_SCDLG_DELCONT ) ),
54*cdf0e10cSrcweir 	//
55*cdf0e10cSrcweir     aFlFrame        ( this, ScResId( FL_FRAME ) ),
56*cdf0e10cSrcweir 	aBtnDelAll      ( this, ScResId( BTN_DELALL ) ),
57*cdf0e10cSrcweir 	aBtnDelStrings  ( this, ScResId( BTN_DELSTRINGS ) ),
58*cdf0e10cSrcweir 	aBtnDelNumbers  ( this, ScResId( BTN_DELNUMBERS ) ),
59*cdf0e10cSrcweir 	aBtnDelDateTime ( this, ScResId( BTN_DELDATETIME ) ),
60*cdf0e10cSrcweir 	aBtnDelFormulas ( this, ScResId( BTN_DELFORMULAS ) ),
61*cdf0e10cSrcweir 	aBtnDelNotes    ( this, ScResId( BTN_DELNOTES ) ),
62*cdf0e10cSrcweir 	aBtnDelAttrs    ( this, ScResId( BTN_DELATTRS ) ),
63*cdf0e10cSrcweir 	aBtnDelObjects	( this, ScResId( BTN_DELOBJECTS ) ),
64*cdf0e10cSrcweir 	aBtnOk          ( this, ScResId( BTN_OK ) ),
65*cdf0e10cSrcweir 	aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
66*cdf0e10cSrcweir 	aBtnHelp        ( this, ScResId( BTN_HELP ) ),
67*cdf0e10cSrcweir 	bObjectsDisabled( sal_False )
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	if ( nCheckDefaults != 0 )
70*cdf0e10cSrcweir 	{
71*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults;
72*cdf0e10cSrcweir 		ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
73*cdf0e10cSrcweir 	}
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	aBtnDelAll.Check     ( ScDeleteContentsDlg::bPreviousAllCheck );
76*cdf0e10cSrcweir 	aBtnDelStrings.Check ( IS_SET( IDF_STRING,
77*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
78*cdf0e10cSrcweir 	aBtnDelNumbers.Check ( IS_SET( IDF_VALUE,
79*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
80*cdf0e10cSrcweir 	aBtnDelDateTime.Check( IS_SET( IDF_DATETIME,
81*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
82*cdf0e10cSrcweir 	aBtnDelFormulas.Check( IS_SET( IDF_FORMULA,
83*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
84*cdf0e10cSrcweir 	aBtnDelNotes.Check   ( IS_SET( IDF_NOTE,
85*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
86*cdf0e10cSrcweir 	aBtnDelAttrs.Check   ( IS_SET( IDF_ATTRIB,
87*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
88*cdf0e10cSrcweir 	aBtnDelObjects.Check ( IS_SET( IDF_OBJECTS,
89*cdf0e10cSrcweir 								   ScDeleteContentsDlg::nPreviousChecks ) );
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	DisableChecks( aBtnDelAll.IsChecked() );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	aBtnDelAll.SetClickHdl( LINK( this, ScDeleteContentsDlg, DelAllHdl ) );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	//-------------
96*cdf0e10cSrcweir 	FreeResource();
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir //------------------------------------------------------------------------
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir sal_uInt16 ScDeleteContentsDlg::GetDelContentsCmdBits() const
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	ScDeleteContentsDlg::nPreviousChecks = 0;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	if ( aBtnDelStrings.IsChecked() )
106*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks  = IDF_STRING;
107*cdf0e10cSrcweir 	if ( aBtnDelNumbers.IsChecked() )
108*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks |= IDF_VALUE;
109*cdf0e10cSrcweir 	if ( aBtnDelDateTime.IsChecked())
110*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks |= IDF_DATETIME;
111*cdf0e10cSrcweir 	if ( aBtnDelFormulas.IsChecked())
112*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks |= IDF_FORMULA;
113*cdf0e10cSrcweir 	if ( aBtnDelNotes.IsChecked()   )
114*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks |= IDF_NOTE;
115*cdf0e10cSrcweir 	if ( aBtnDelAttrs.IsChecked()   )
116*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks |= IDF_ATTRIB;
117*cdf0e10cSrcweir 	if ( aBtnDelObjects.IsChecked() )
118*cdf0e10cSrcweir 		ScDeleteContentsDlg::nPreviousChecks |= IDF_OBJECTS;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	ScDeleteContentsDlg::bPreviousAllCheck = aBtnDelAll.IsChecked();
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	return ( (ScDeleteContentsDlg::bPreviousAllCheck)
123*cdf0e10cSrcweir 				? IDF_ALL
124*cdf0e10cSrcweir 				: ScDeleteContentsDlg::nPreviousChecks );
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir //------------------------------------------------------------------------
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir void ScDeleteContentsDlg::DisableChecks( sal_Bool bDelAllChecked )
130*cdf0e10cSrcweir {
131*cdf0e10cSrcweir 	if ( bDelAllChecked )
132*cdf0e10cSrcweir 	{
133*cdf0e10cSrcweir 		aBtnDelStrings.Disable();
134*cdf0e10cSrcweir 		aBtnDelNumbers.Disable();
135*cdf0e10cSrcweir 		aBtnDelDateTime.Disable();
136*cdf0e10cSrcweir 		aBtnDelFormulas.Disable();
137*cdf0e10cSrcweir 		aBtnDelNotes.Disable();
138*cdf0e10cSrcweir 		aBtnDelAttrs.Disable();
139*cdf0e10cSrcweir 		aBtnDelObjects.Disable();
140*cdf0e10cSrcweir 	}
141*cdf0e10cSrcweir 	else
142*cdf0e10cSrcweir 	{
143*cdf0e10cSrcweir 		aBtnDelStrings.Enable();
144*cdf0e10cSrcweir 		aBtnDelNumbers.Enable();
145*cdf0e10cSrcweir 		aBtnDelDateTime.Enable();
146*cdf0e10cSrcweir 		aBtnDelFormulas.Enable();
147*cdf0e10cSrcweir 		aBtnDelNotes.Enable();
148*cdf0e10cSrcweir 		aBtnDelAttrs.Enable();
149*cdf0e10cSrcweir 		if (bObjectsDisabled)
150*cdf0e10cSrcweir 			aBtnDelObjects.Disable();
151*cdf0e10cSrcweir 		else
152*cdf0e10cSrcweir 			aBtnDelObjects.Enable();
153*cdf0e10cSrcweir 	}
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir //------------------------------------------------------------------------
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir void ScDeleteContentsDlg::DisableObjects()
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir 	bObjectsDisabled = sal_True;
161*cdf0e10cSrcweir 	aBtnDelObjects.Check(sal_False);
162*cdf0e10cSrcweir 	aBtnDelObjects.Disable();
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir //------------------------------------------------------------------------
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir IMPL_LINK_INLINE_START( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir 	DisableChecks( aBtnDelAll.IsChecked() );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	return 0;
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir IMPL_LINK_INLINE_END( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir __EXPORT ScDeleteContentsDlg::~ScDeleteContentsDlg()
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 
181