xref: /aoo41x/main/sc/source/ui/attrdlg/condfrmt.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 
32*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33*cdf0e10cSrcweir #include <svl/stritem.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "tabvwsh.hxx"
36*cdf0e10cSrcweir #include "reffact.hxx"
37*cdf0e10cSrcweir #include "conditio.hxx"
38*cdf0e10cSrcweir #include "stlpool.hxx"
39*cdf0e10cSrcweir #include "uiitems.hxx"
40*cdf0e10cSrcweir #include "document.hxx"
41*cdf0e10cSrcweir #include "scresid.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include "condfrmt.hrc"
44*cdf0e10cSrcweir #include "globstr.hrc"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #define _CONDFRMT_CXX
47*cdf0e10cSrcweir #include "condfrmt.hxx"
48*cdf0e10cSrcweir #undef _CONDFRMT_CXX
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //============================================================================
52*cdf0e10cSrcweir //	class ScConditionalFormat
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //----------------------------------------------------------------------------
55*cdf0e10cSrcweir // Konstruktor
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir ScConditionalFormatDlg::ScConditionalFormatDlg(
58*cdf0e10cSrcweir 			SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
59*cdf0e10cSrcweir 			ScDocument* pCurDoc,
60*cdf0e10cSrcweir 			const ScConditionalFormat* pCurrentFormat )
61*cdf0e10cSrcweir 	:	ScAnyRefDlg			( pB, pCW, pParent, RID_SCDLG_CONDFORMAT ),
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 		aCbxCond1			( this, ScResId( CBX_COND1 ) ),
64*cdf0e10cSrcweir 		aLbCond11			( this, ScResId( LB_COND1_1 ) ),
65*cdf0e10cSrcweir 		aLbCond12			( this, ScResId( LB_COND1_2 ) ),
66*cdf0e10cSrcweir         aEdtCond11          ( this, this, ScResId( EDT_COND1_1 ) ),
67*cdf0e10cSrcweir 		aRbCond11			( this, ScResId( RB_COND1_1 ), &aEdtCond11,this ),
68*cdf0e10cSrcweir 		aFtCond1And			( this, ScResId( FT_COND1_AND ) ),
69*cdf0e10cSrcweir         aEdtCond12          ( this, this, ScResId( EDT_COND1_2 ) ),
70*cdf0e10cSrcweir 		aRbCond12			( this, ScResId( RB_COND1_2 ), &aEdtCond12,this ),
71*cdf0e10cSrcweir 		aFtCond1Template	( this, ScResId( FT_COND1_TEMPLATE ) ),
72*cdf0e10cSrcweir 		aLbCond1Template	( this, ScResId( LB_COND1_TEMPLATE ) ),
73*cdf0e10cSrcweir         aBtnNew1            ( this, ScResId( BTN_COND1_NEW ) ),
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 		aCbxCond2			( this, ScResId( CBX_COND2 ) ),
76*cdf0e10cSrcweir 		aLbCond21			( this, ScResId( LB_COND2_1 ) ),
77*cdf0e10cSrcweir 		aLbCond22			( this, ScResId( LB_COND2_2 ) ),
78*cdf0e10cSrcweir         aEdtCond21          ( this, this, ScResId( EDT_COND2_1 ) ),
79*cdf0e10cSrcweir 		aRbCond21			( this, ScResId( RB_COND2_1 ), &aEdtCond21,this ),
80*cdf0e10cSrcweir 		aFtCond2And			( this, ScResId( FT_COND2_AND ) ),
81*cdf0e10cSrcweir         aEdtCond22          ( this, this, ScResId( EDT_COND2_2 ) ),
82*cdf0e10cSrcweir 		aRbCond22			( this, ScResId( RB_COND2_2 ), &aEdtCond22,this ),
83*cdf0e10cSrcweir 		aFtCond2Template	( this, ScResId( FT_COND2_TEMPLATE ) ),
84*cdf0e10cSrcweir 		aLbCond2Template	( this, ScResId( LB_COND2_TEMPLATE ) ),
85*cdf0e10cSrcweir         aBtnNew2            ( this, ScResId( BTN_COND2_NEW ) ),
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 		aCbxCond3			( this, ScResId( CBX_COND3 ) ),
88*cdf0e10cSrcweir 		aLbCond31			( this, ScResId( LB_COND3_1 ) ),
89*cdf0e10cSrcweir 		aLbCond32			( this, ScResId( LB_COND3_2 ) ),
90*cdf0e10cSrcweir         aEdtCond31          ( this, this, ScResId( EDT_COND3_1 ) ),
91*cdf0e10cSrcweir 		aRbCond31			( this, ScResId( RB_COND3_1 ), &aEdtCond31,this ),
92*cdf0e10cSrcweir 		aFtCond3And			( this, ScResId( FT_COND3_AND ) ),
93*cdf0e10cSrcweir         aEdtCond32          ( this, this, ScResId( EDT_COND3_2 ) ),
94*cdf0e10cSrcweir 		aRbCond32			( this, ScResId( RB_COND3_2 ), &aEdtCond32,this ),
95*cdf0e10cSrcweir 		aFtCond3Template	( this, ScResId( FT_COND3_TEMPLATE ) ),
96*cdf0e10cSrcweir 		aLbCond3Template	( this, ScResId( LB_COND3_TEMPLATE ) ),
97*cdf0e10cSrcweir         aBtnNew3            ( this, ScResId( BTN_COND3_NEW ) ),
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 		aBtnOk				( this, ScResId( BTN_OK ) ),
100*cdf0e10cSrcweir 		aBtnCancel			( this, ScResId( BTN_CANCEL ) ),
101*cdf0e10cSrcweir 		aBtnHelp			( this, ScResId( BTN_HELP ) ),
102*cdf0e10cSrcweir         aFlSep2             ( this, ScResId( FL_SEP2 ) ),
103*cdf0e10cSrcweir         aFlSep1             ( this, ScResId( FL_SEP1 ) ),
104*cdf0e10cSrcweir 		pEdActive			( NULL ),
105*cdf0e10cSrcweir 		bDlgLostFocus       ( sal_False ),
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 		pDoc				( pCurDoc )
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir 	Point aPos;
110*cdf0e10cSrcweir 	String aName;
111*cdf0e10cSrcweir 	SfxStyleSheetBase* pStyle;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	FreeResource();
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	// Handler setzen
116*cdf0e10cSrcweir 	aCbxCond1.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond1Hdl ) );
117*cdf0e10cSrcweir 	aLbCond11.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond11Hdl ) );
118*cdf0e10cSrcweir 	aLbCond12.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond12Hdl ) );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	aCbxCond2.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond2Hdl ) );
121*cdf0e10cSrcweir 	aLbCond21.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond21Hdl ) );
122*cdf0e10cSrcweir 	aLbCond22.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond22Hdl ) );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	aCbxCond3.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond3Hdl ) );
125*cdf0e10cSrcweir 	aLbCond31.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond31Hdl ) );
126*cdf0e10cSrcweir 	aLbCond32.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond32Hdl ) );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	aBtnOk.SetClickHdl    ( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
129*cdf0e10cSrcweir //?	aBtnCancel.SetClickHdl( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     Link aLink = LINK( this, ScConditionalFormatDlg, NewBtnHdl );
132*cdf0e10cSrcweir     aBtnNew1.SetClickHdl( aLink );
133*cdf0e10cSrcweir     aBtnNew2.SetClickHdl( aLink );
134*cdf0e10cSrcweir     aBtnNew3.SetClickHdl( aLink );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     aLink = LINK( this, ScConditionalFormatDlg, GetFocusHdl );
137*cdf0e10cSrcweir     aEdtCond11.SetGetFocusHdl( aLink );
138*cdf0e10cSrcweir     aEdtCond12.SetGetFocusHdl( aLink );
139*cdf0e10cSrcweir     aEdtCond21.SetGetFocusHdl( aLink );
140*cdf0e10cSrcweir     aEdtCond22.SetGetFocusHdl( aLink );
141*cdf0e10cSrcweir     aEdtCond31.SetGetFocusHdl( aLink );
142*cdf0e10cSrcweir     aEdtCond32.SetGetFocusHdl( aLink );
143*cdf0e10cSrcweir     aRbCond11.SetGetFocusHdl( aLink );
144*cdf0e10cSrcweir     aRbCond12.SetGetFocusHdl( aLink );
145*cdf0e10cSrcweir     aRbCond21.SetGetFocusHdl( aLink );
146*cdf0e10cSrcweir     aRbCond22.SetGetFocusHdl( aLink );
147*cdf0e10cSrcweir     aRbCond31.SetGetFocusHdl( aLink );
148*cdf0e10cSrcweir     aRbCond32.SetGetFocusHdl( aLink );
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     aLink = LINK( this, ScConditionalFormatDlg, LoseFocusHdl );
151*cdf0e10cSrcweir     aEdtCond11.SetLoseFocusHdl( aLink );
152*cdf0e10cSrcweir     aEdtCond12.SetLoseFocusHdl( aLink );
153*cdf0e10cSrcweir     aEdtCond21.SetLoseFocusHdl( aLink );
154*cdf0e10cSrcweir     aEdtCond22.SetLoseFocusHdl( aLink );
155*cdf0e10cSrcweir     aEdtCond31.SetLoseFocusHdl( aLink );
156*cdf0e10cSrcweir     aEdtCond32.SetLoseFocusHdl( aLink );
157*cdf0e10cSrcweir     aRbCond11.SetLoseFocusHdl( aLink );
158*cdf0e10cSrcweir     aRbCond12.SetLoseFocusHdl( aLink );
159*cdf0e10cSrcweir     aRbCond21.SetLoseFocusHdl( aLink );
160*cdf0e10cSrcweir     aRbCond22.SetLoseFocusHdl( aLink );
161*cdf0e10cSrcweir     aRbCond31.SetLoseFocusHdl( aLink );
162*cdf0e10cSrcweir     aRbCond32.SetLoseFocusHdl( aLink );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 	// Condition 1
165*cdf0e10cSrcweir 	aCond1Pos1 = aLbCond12.GetPosPixel();		// Position Edit ohne Listbox
166*cdf0e10cSrcweir 	aCond1Pos2 = aEdtCond11.GetPosPixel();		// Position Edit mit Listbox
167*cdf0e10cSrcweir 	aRBtn1Pos1 = aRbCond11.GetPosPixel();
168*cdf0e10cSrcweir 	aRBtn1Pos2 = aRbCond12.GetPosPixel();
169*cdf0e10cSrcweir 	aPos = aEdtCond12.GetPosPixel();
170*cdf0e10cSrcweir 	aPos.X() += aEdtCond12.GetSizePixel().Width();	// rechter Rand
171*cdf0e10cSrcweir 	aCond1Size3 = aEdtCond11.GetSizePixel();
172*cdf0e10cSrcweir 	aCond1Size2 = Size( aPos.X() - aCond1Pos2.X(), aCond1Size3.Height() );
173*cdf0e10cSrcweir 	aCond1Size1 = Size( aPos.X() - aCond1Pos1.X(), aCond1Size3.Height() );
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 	aCbxCond1.Check();
176*cdf0e10cSrcweir 	aLbCond11.SelectEntryPos( 0 );
177*cdf0e10cSrcweir 	aLbCond12.SelectEntryPos( 0 );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 	// Condition 2
180*cdf0e10cSrcweir 	aCond2Pos1  = aLbCond22.GetPosPixel();		// Position Edit ohne Listbox
181*cdf0e10cSrcweir 	aCond2Pos2  = aEdtCond21.GetPosPixel();		// Position Edit mit Listbox
182*cdf0e10cSrcweir 	aRBtn2Pos1 = aRbCond21.GetPosPixel();
183*cdf0e10cSrcweir 	aRBtn2Pos2 = aRbCond22.GetPosPixel();
184*cdf0e10cSrcweir 	aPos = aEdtCond22.GetPosPixel();
185*cdf0e10cSrcweir 	aPos.X() += aEdtCond22.GetSizePixel().Width();	// rechter Rand
186*cdf0e10cSrcweir 	aCond2Size3 = aEdtCond21.GetSizePixel();
187*cdf0e10cSrcweir 	aCond2Size2 = Size( aPos.X() - aCond2Pos2.X(), aCond2Size3.Height() );
188*cdf0e10cSrcweir 	aCond2Size1 = Size( aPos.X() - aCond2Pos1.X(), aCond2Size3.Height() );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 	aCbxCond2.Check( sal_False );
191*cdf0e10cSrcweir 	aLbCond21.SelectEntryPos( 0 );
192*cdf0e10cSrcweir 	aLbCond22.SelectEntryPos( 0 );
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	// Condition 3
195*cdf0e10cSrcweir 	aCond3Pos1  = aLbCond32.GetPosPixel();		// Position Edit ohne Listbox
196*cdf0e10cSrcweir 	aCond3Pos2  = aEdtCond31.GetPosPixel();		// Position Edit mit Listbox
197*cdf0e10cSrcweir 	aRBtn3Pos1 = aRbCond31.GetPosPixel();
198*cdf0e10cSrcweir 	aRBtn3Pos2 = aRbCond32.GetPosPixel();
199*cdf0e10cSrcweir 	aPos = aEdtCond32.GetPosPixel();
200*cdf0e10cSrcweir 	aPos.X() += aEdtCond32.GetSizePixel().Width();	// rechter Rand
201*cdf0e10cSrcweir 	aCond3Size3 = aEdtCond31.GetSizePixel();
202*cdf0e10cSrcweir 	aCond3Size2 = Size( aPos.X() - aCond3Pos2.X(), aCond3Size3.Height() );
203*cdf0e10cSrcweir 	aCond3Size1 = Size( aPos.X() - aCond3Pos1.X(), aCond3Size3.Height() );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 	aCbxCond3.Check( sal_False );
206*cdf0e10cSrcweir 	aLbCond31.SelectEntryPos( 0 );
207*cdf0e10cSrcweir 	aLbCond32.SelectEntryPos( 0 );
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	// Vorlagen aus pDoc holen
210*cdf0e10cSrcweir 	SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
211*cdf0e10cSrcweir 	for ( pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
212*cdf0e10cSrcweir 	{
213*cdf0e10cSrcweir 		aName = pStyle->GetName();
214*cdf0e10cSrcweir 		aLbCond1Template.InsertEntry( aName );
215*cdf0e10cSrcweir 		aLbCond2Template.InsertEntry( aName );
216*cdf0e10cSrcweir 		aLbCond3Template.InsertEntry( aName );
217*cdf0e10cSrcweir 	}
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	// Vorlagen eintragen
220*cdf0e10cSrcweir //!	pStyle = pDoc->GetSelectionStyle( /* ??? const ScMarkData& rMark ??? */ );
221*cdf0e10cSrcweir 	pStyle = NULL;	//!
222*cdf0e10cSrcweir 	if (pStyle)
223*cdf0e10cSrcweir 		aName = pStyle->GetName();
224*cdf0e10cSrcweir 	else
225*cdf0e10cSrcweir 		aName = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
226*cdf0e10cSrcweir 	aLbCond1Template.SelectEntry( aName );
227*cdf0e10cSrcweir 	aLbCond2Template.SelectEntry( aName );
228*cdf0e10cSrcweir 	aLbCond3Template.SelectEntry( aName );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 	ScAddress aCurPos;
231*cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
232*cdf0e10cSrcweir 	if (pViewShell)
233*cdf0e10cSrcweir 	{
234*cdf0e10cSrcweir 		ScViewData* pData = pViewShell->GetViewData();
235*cdf0e10cSrcweir 		aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
236*cdf0e10cSrcweir 	}
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 	// Inhalt aus ConditionalFormat holen
239*cdf0e10cSrcweir 	if ( pCurrentFormat )
240*cdf0e10cSrcweir 	{
241*cdf0e10cSrcweir 		const ScCondFormatEntry* pEntry;
242*cdf0e10cSrcweir 		if ( pCurrentFormat->Count() > 0 )
243*cdf0e10cSrcweir 		{
244*cdf0e10cSrcweir 			pEntry= pCurrentFormat->GetEntry( 0 );
245*cdf0e10cSrcweir 			aEdtCond11.SetText( pEntry->GetExpression( aCurPos, 0 ) );
246*cdf0e10cSrcweir 			aLbCond1Template.SelectEntry( pEntry->GetStyle() );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 			ScConditionMode	eMode = pEntry->GetOperation();
249*cdf0e10cSrcweir 			if ( eMode == SC_COND_DIRECT )			// via Formel
250*cdf0e10cSrcweir 			{
251*cdf0e10cSrcweir 				aLbCond11.SelectEntryPos( 1 );
252*cdf0e10cSrcweir 				ChangeCond11Hdl( NULL );
253*cdf0e10cSrcweir 			}
254*cdf0e10cSrcweir 			else if ( eMode == SC_COND_NONE )		// ???
255*cdf0e10cSrcweir 				;
256*cdf0e10cSrcweir 			else									// via Werte
257*cdf0e10cSrcweir 			{
258*cdf0e10cSrcweir                 aLbCond12.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
259*cdf0e10cSrcweir 				if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
260*cdf0e10cSrcweir 					aEdtCond12.SetText( pEntry->GetExpression( aCurPos, 1 ) );
261*cdf0e10cSrcweir 			}
262*cdf0e10cSrcweir 		}
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 		if ( pCurrentFormat->Count() > 1 )
266*cdf0e10cSrcweir 		{
267*cdf0e10cSrcweir 			aCbxCond2.Check( sal_True );
268*cdf0e10cSrcweir 			pEntry= pCurrentFormat->GetEntry( 1 );
269*cdf0e10cSrcweir 			aEdtCond21.SetText( pEntry->GetExpression( aCurPos, 0 ) );
270*cdf0e10cSrcweir 			aLbCond2Template.SelectEntry( pEntry->GetStyle() );
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 			ScConditionMode	eMode = pEntry->GetOperation();
273*cdf0e10cSrcweir 			if ( eMode == SC_COND_DIRECT )			// via Formel
274*cdf0e10cSrcweir 			{
275*cdf0e10cSrcweir 				aLbCond21.SelectEntryPos( 1 );
276*cdf0e10cSrcweir 				ChangeCond21Hdl( NULL );
277*cdf0e10cSrcweir 			}
278*cdf0e10cSrcweir 			else if ( eMode == SC_COND_NONE )		// ???
279*cdf0e10cSrcweir 				;
280*cdf0e10cSrcweir 			else									// via Werte
281*cdf0e10cSrcweir 			{
282*cdf0e10cSrcweir                 aLbCond22.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
283*cdf0e10cSrcweir 				if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
284*cdf0e10cSrcweir 					aEdtCond22.SetText( pEntry->GetExpression( aCurPos, 1 ) );
285*cdf0e10cSrcweir 			}
286*cdf0e10cSrcweir 		}
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 		if ( pCurrentFormat->Count() > 2 )
289*cdf0e10cSrcweir 		{
290*cdf0e10cSrcweir 			aCbxCond3.Check( sal_True );
291*cdf0e10cSrcweir 			pEntry= pCurrentFormat->GetEntry( 2 );
292*cdf0e10cSrcweir 			aEdtCond31.SetText( pEntry->GetExpression( aCurPos, 0 ) );
293*cdf0e10cSrcweir 			aLbCond3Template.SelectEntry( pEntry->GetStyle() );
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 			ScConditionMode	eMode = pEntry->GetOperation();
296*cdf0e10cSrcweir 			if ( eMode == SC_COND_DIRECT )			// via Formel
297*cdf0e10cSrcweir 			{
298*cdf0e10cSrcweir 				aLbCond31.SelectEntryPos( 1 );
299*cdf0e10cSrcweir 				ChangeCond31Hdl( NULL );
300*cdf0e10cSrcweir 			}
301*cdf0e10cSrcweir 			else if ( eMode == SC_COND_NONE )		// ???
302*cdf0e10cSrcweir 				;
303*cdf0e10cSrcweir 			else									// via Werte
304*cdf0e10cSrcweir 			{
305*cdf0e10cSrcweir                 aLbCond32.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
306*cdf0e10cSrcweir 				if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
307*cdf0e10cSrcweir 					aEdtCond32.SetText( pEntry->GetExpression( aCurPos, 1 ) );
308*cdf0e10cSrcweir 			}
309*cdf0e10cSrcweir 		}
310*cdf0e10cSrcweir 	}
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 	ClickCond1Hdl( NULL );
313*cdf0e10cSrcweir 	ClickCond2Hdl( NULL );
314*cdf0e10cSrcweir 	ClickCond3Hdl( NULL );
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	ChangeCond12Hdl( NULL );
317*cdf0e10cSrcweir 	ChangeCond22Hdl( NULL );
318*cdf0e10cSrcweir 	ChangeCond32Hdl( NULL );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	aEdtCond11.GrabFocus();
321*cdf0e10cSrcweir 	pEdActive = &aEdtCond11;
322*cdf0e10cSrcweir 	//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
323*cdf0e10cSrcweir 	//SFX_APPWINDOW->Enable();		// Ref-Feld hat Focus
324*cdf0e10cSrcweir //	SFX_APPWINDOW->Disable();
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	aLbCond11.SetAccessibleRelationLabeledBy( &aCbxCond1 );
327*cdf0e10cSrcweir 	aLbCond12.SetAccessibleRelationLabeledBy( &aCbxCond1 );
328*cdf0e10cSrcweir 	aEdtCond11.SetAccessibleRelationLabeledBy( &aCbxCond1 );
329*cdf0e10cSrcweir 	aRbCond11.SetAccessibleRelationLabeledBy( &aCbxCond1 );
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 	aLbCond21.SetAccessibleRelationLabeledBy( &aCbxCond2 );
332*cdf0e10cSrcweir 	aLbCond22.SetAccessibleRelationLabeledBy( &aCbxCond2 );
333*cdf0e10cSrcweir 	aEdtCond21.SetAccessibleRelationLabeledBy( &aCbxCond2 );
334*cdf0e10cSrcweir 	aRbCond21.SetAccessibleRelationLabeledBy( &aCbxCond2 );
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 	aLbCond31.SetAccessibleRelationLabeledBy( &aCbxCond3 );
337*cdf0e10cSrcweir 	aLbCond32.SetAccessibleRelationLabeledBy( &aCbxCond3 );
338*cdf0e10cSrcweir 	aEdtCond31.SetAccessibleRelationLabeledBy( &aCbxCond3 );
339*cdf0e10cSrcweir 	aRbCond31.SetAccessibleRelationLabeledBy( &aCbxCond3 );
340*cdf0e10cSrcweir 	aLbCond11.SetAccessibleName( ScResId(LABEL_FORMARTTING_CONDITIONS) );
341*cdf0e10cSrcweir 	aLbCond12.SetAccessibleName( ScResId(LABEL_CONDITIONS) );
342*cdf0e10cSrcweir 	aEdtCond11.SetAccessibleName( ScResId(LABEL_CONDITION_VALUE) );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	aLbCond21.SetAccessibleName( ScResId(LABEL_FORMARTTING_CONDITIONS) );
345*cdf0e10cSrcweir 	aLbCond22.SetAccessibleName( ScResId(LABEL_CONDITIONS) );
346*cdf0e10cSrcweir 	aEdtCond21.SetAccessibleName( ScResId(LABEL_CONDITION_VALUE) );
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 	aLbCond31.SetAccessibleName( ScResId(LABEL_FORMARTTING_CONDITIONS) );
349*cdf0e10cSrcweir 	aLbCond32.SetAccessibleName( ScResId(LABEL_CONDITIONS) );
350*cdf0e10cSrcweir 	aEdtCond31.SetAccessibleName( ScResId(LABEL_CONDITION_VALUE) );
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir //----------------------------------------------------------------------------
355*cdf0e10cSrcweir // Destruktor
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir __EXPORT ScConditionalFormatDlg::~ScConditionalFormatDlg()
358*cdf0e10cSrcweir {
359*cdf0e10cSrcweir }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir //----------------------------------------------------------------------------
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir void ScConditionalFormatDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
365*cdf0e10cSrcweir {
366*cdf0e10cSrcweir 	if ( pEdActive )
367*cdf0e10cSrcweir 	{
368*cdf0e10cSrcweir 		if ( rRef.aStart != rRef.aEnd )
369*cdf0e10cSrcweir 			RefInputStart(pEdActive);
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 		String aStr;
372*cdf0e10cSrcweir 		rRef.Format( aStr, SCR_ABS_3D, pDocP, pDocP->GetAddressConvention () );
373*cdf0e10cSrcweir 		String aVal( pEdActive->GetText() );
374*cdf0e10cSrcweir 		Selection aSel( pEdActive->GetSelection() );
375*cdf0e10cSrcweir         aSel.Justify();
376*cdf0e10cSrcweir 		aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
377*cdf0e10cSrcweir 		aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
378*cdf0e10cSrcweir 		Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
379*cdf0e10cSrcweir 		pEdActive->SetRefString( aVal );
380*cdf0e10cSrcweir 		pEdActive->SetSelection( aNewSel );
381*cdf0e10cSrcweir //		pEdActive->SetModifyFlag();
382*cdf0e10cSrcweir 	}
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir //----------------------------------------------------------------------------
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir void ScConditionalFormatDlg::AddRefEntry()
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 	if ( pEdActive )
390*cdf0e10cSrcweir 	{
391*cdf0e10cSrcweir 		String aVal = pEdActive->GetText();
392*cdf0e10cSrcweir 		aVal += ';';
393*cdf0e10cSrcweir 		pEdActive->SetText(aVal);
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 		xub_StrLen nLen = aVal.Len();
396*cdf0e10cSrcweir 		pEdActive->SetSelection( Selection( nLen, nLen ) );
397*cdf0e10cSrcweir //		pEdActive->SetModifyFlag();
398*cdf0e10cSrcweir 	}
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir //----------------------------------------------------------------------------
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir sal_Bool ScConditionalFormatDlg::IsRefInputMode() const
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir 	return (pEdActive != NULL);
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir //----------------------------------------------------------------------------
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir void ScConditionalFormatDlg::SetActive()
412*cdf0e10cSrcweir {
413*cdf0e10cSrcweir 	if ( bDlgLostFocus )
414*cdf0e10cSrcweir 	{
415*cdf0e10cSrcweir 		bDlgLostFocus = sal_False;
416*cdf0e10cSrcweir         if( pEdActive )
417*cdf0e10cSrcweir             pEdActive->GrabFocus();
418*cdf0e10cSrcweir 	}
419*cdf0e10cSrcweir 	else
420*cdf0e10cSrcweir 		GrabFocus();
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 	RefInputDone();
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir //----------------------------------------------------------------------------
427*cdf0e10cSrcweir // Holt die ausgewaehlte bedingte Formatierung ab
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir void ScConditionalFormatDlg::GetConditionalFormat( ScConditionalFormat& rCndFmt )
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir 	ScConditionMode eOper;
432*cdf0e10cSrcweir 	String sExpr1;
433*cdf0e10cSrcweir 	String sExpr2;
434*cdf0e10cSrcweir 	String sStyle;
435*cdf0e10cSrcweir 	ScAddress aCurPos;
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
438*cdf0e10cSrcweir 	if (pViewShell)
439*cdf0e10cSrcweir 	{
440*cdf0e10cSrcweir 		ScViewData* pData = pViewShell->GetViewData();
441*cdf0e10cSrcweir 		aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
442*cdf0e10cSrcweir 	}
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 	if ( aCbxCond1.IsChecked() )
445*cdf0e10cSrcweir 	{
446*cdf0e10cSrcweir 		if ( aLbCond11.GetSelectEntryPos() == 1 )	// via Formel
447*cdf0e10cSrcweir 			eOper = SC_COND_DIRECT;
448*cdf0e10cSrcweir 		else
449*cdf0e10cSrcweir 			eOper = (ScConditionMode)aLbCond12.GetSelectEntryPos();
450*cdf0e10cSrcweir 		sExpr1 = aEdtCond11.GetText();
451*cdf0e10cSrcweir 		sExpr2 = aEdtCond12.GetText();
452*cdf0e10cSrcweir 		sStyle = aLbCond1Template.GetSelectEntry();
453*cdf0e10cSrcweir 		ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
454*cdf0e10cSrcweir 		rCndFmt.AddEntry( aNewEntry );
455*cdf0e10cSrcweir 	}
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	if ( aCbxCond2.IsChecked() )
458*cdf0e10cSrcweir 	{
459*cdf0e10cSrcweir 		if ( aLbCond21.GetSelectEntryPos() == 1 )	// via Formel???
460*cdf0e10cSrcweir 			eOper = SC_COND_DIRECT;
461*cdf0e10cSrcweir 		else
462*cdf0e10cSrcweir 			eOper = (ScConditionMode)aLbCond22.GetSelectEntryPos();
463*cdf0e10cSrcweir 		sExpr1 = aEdtCond21.GetText();
464*cdf0e10cSrcweir 		sExpr2 = aEdtCond22.GetText();
465*cdf0e10cSrcweir 		sStyle = aLbCond2Template.GetSelectEntry();
466*cdf0e10cSrcweir 		ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
467*cdf0e10cSrcweir 		rCndFmt.AddEntry( aNewEntry );
468*cdf0e10cSrcweir 	}
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 	if ( aCbxCond3.IsChecked() )
471*cdf0e10cSrcweir 	{
472*cdf0e10cSrcweir 		if ( aLbCond31.GetSelectEntryPos() == 1 )	// via Formel???
473*cdf0e10cSrcweir 			eOper = SC_COND_DIRECT;
474*cdf0e10cSrcweir 		else
475*cdf0e10cSrcweir 			eOper = (ScConditionMode)aLbCond32.GetSelectEntryPos();
476*cdf0e10cSrcweir 		sExpr1 = aEdtCond31.GetText();
477*cdf0e10cSrcweir 		sExpr2 = aEdtCond32.GetText();
478*cdf0e10cSrcweir 		sStyle = aLbCond3Template.GetSelectEntry();
479*cdf0e10cSrcweir 		ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
480*cdf0e10cSrcweir 		rCndFmt.AddEntry( aNewEntry );
481*cdf0e10cSrcweir 	}
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir //----------------------------------------------------------------------------
486*cdf0e10cSrcweir // Zerstoert den Dialog
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir sal_Bool ScConditionalFormatDlg::Close()
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir 	return DoClose( ScCondFormatDlgWrapper::GetChildWindowId() );
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir //----------------------------------------------------------------------------
495*cdf0e10cSrcweir // Handler:
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir //----------------------------------------------------------------------------
498*cdf0e10cSrcweir // Enabled/Disabled Condition1-Controls
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ClickCond1Hdl, void *, EMPTYARG )
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir 	sal_Bool bChecked = aCbxCond1.IsChecked();
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 	aLbCond11.Enable( bChecked );
505*cdf0e10cSrcweir 	aLbCond12.Enable( bChecked );
506*cdf0e10cSrcweir 	aEdtCond11.Enable( bChecked );
507*cdf0e10cSrcweir 	aRbCond11.Enable( bChecked );
508*cdf0e10cSrcweir 	aFtCond1And.Enable( bChecked );
509*cdf0e10cSrcweir 	aEdtCond12.Enable( bChecked );
510*cdf0e10cSrcweir 	aRbCond12.Enable( bChecked );
511*cdf0e10cSrcweir 	aFtCond1Template.Enable( bChecked );
512*cdf0e10cSrcweir 	aLbCond1Template.Enable( bChecked );
513*cdf0e10cSrcweir     aBtnNew1.Enable( bChecked );
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 	return( 0L );
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir //----------------------------------------------------------------------------
520*cdf0e10cSrcweir // Zellwert/Formel
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ChangeCond11Hdl, void *, EMPTYARG )
523*cdf0e10cSrcweir {
524*cdf0e10cSrcweir 	sal_uInt16 nPos = aLbCond11.GetSelectEntryPos();
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 	if( nPos == 0 ) // Zellwert
527*cdf0e10cSrcweir 	{
528*cdf0e10cSrcweir 		aLbCond12.Show();
529*cdf0e10cSrcweir 		aEdtCond11.SetPosPixel( aCond1Pos2 );
530*cdf0e10cSrcweir 	}
531*cdf0e10cSrcweir 	else // Formel
532*cdf0e10cSrcweir 	{
533*cdf0e10cSrcweir 		aLbCond12.Hide();
534*cdf0e10cSrcweir 		aFtCond1And.Hide();
535*cdf0e10cSrcweir 		aEdtCond12.Hide();
536*cdf0e10cSrcweir 		aRbCond12.Hide();
537*cdf0e10cSrcweir 		aRbCond11.SetPosPixel( aRBtn1Pos2 );
538*cdf0e10cSrcweir 		aEdtCond11.SetPosSizePixel( aCond1Pos1, aCond1Size1 );
539*cdf0e10cSrcweir 	}
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 	ChangeCond12Hdl( NULL );
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 	return( 0L );
544*cdf0e10cSrcweir }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir //----------------------------------------------------------------------------
548*cdf0e10cSrcweir // zwischen, gleich, groesser, ...
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ChangeCond12Hdl, void *, EMPTYARG )
551*cdf0e10cSrcweir {
552*cdf0e10cSrcweir 	if( aLbCond12.IsVisible() )
553*cdf0e10cSrcweir 	{
554*cdf0e10cSrcweir 		sal_uInt16 nPos = aLbCond12.GetSelectEntryPos();
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 		if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
557*cdf0e10cSrcweir 		{
558*cdf0e10cSrcweir 			aEdtCond11.SetSizePixel( aCond1Size3 );
559*cdf0e10cSrcweir 			aRbCond11.SetPosPixel( aRBtn1Pos1 );
560*cdf0e10cSrcweir 			aFtCond1And.Show();
561*cdf0e10cSrcweir 			aEdtCond12.Show();
562*cdf0e10cSrcweir 			aRbCond12.Show();
563*cdf0e10cSrcweir 		}
564*cdf0e10cSrcweir 		else // gleich, n. gleich ...
565*cdf0e10cSrcweir 		{
566*cdf0e10cSrcweir 			aEdtCond12.Hide();
567*cdf0e10cSrcweir 			aRbCond12.Hide();
568*cdf0e10cSrcweir 			aFtCond1And.Hide();
569*cdf0e10cSrcweir 			aRbCond11.SetPosPixel( aRBtn1Pos2 );
570*cdf0e10cSrcweir 			aEdtCond11.SetSizePixel( aCond1Size2 );
571*cdf0e10cSrcweir 		}
572*cdf0e10cSrcweir 	}
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir 	return( 0L );
575*cdf0e10cSrcweir }
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir //----------------------------------------------------------------------------
579*cdf0e10cSrcweir // Enabled/Disabled Condition2-Controls
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ClickCond2Hdl, void *, EMPTYARG )
582*cdf0e10cSrcweir {
583*cdf0e10cSrcweir 	sal_Bool bChecked = aCbxCond2.IsChecked();
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 	aLbCond21.Enable( bChecked );
586*cdf0e10cSrcweir 	aLbCond22.Enable( bChecked );
587*cdf0e10cSrcweir 	aEdtCond21.Enable( bChecked );
588*cdf0e10cSrcweir 	aRbCond21.Enable( bChecked );
589*cdf0e10cSrcweir 	aFtCond2And.Enable( bChecked );
590*cdf0e10cSrcweir 	aEdtCond22.Enable( bChecked );
591*cdf0e10cSrcweir 	aRbCond22.Enable( bChecked );
592*cdf0e10cSrcweir 	aFtCond2Template.Enable( bChecked );
593*cdf0e10cSrcweir 	aLbCond2Template.Enable( bChecked );
594*cdf0e10cSrcweir     aBtnNew2.Enable( bChecked );
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 	return( 0L );
597*cdf0e10cSrcweir }
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir //----------------------------------------------------------------------------
601*cdf0e10cSrcweir // Zellwert/Formel
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ChangeCond21Hdl, void *, EMPTYARG )
604*cdf0e10cSrcweir {
605*cdf0e10cSrcweir 	sal_uInt16 nPos = aLbCond21.GetSelectEntryPos();
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 	if( nPos == 0 ) // Zellwert
608*cdf0e10cSrcweir 	{
609*cdf0e10cSrcweir 		aLbCond22.Show();
610*cdf0e10cSrcweir 		aEdtCond21.SetPosPixel( aCond2Pos2 );
611*cdf0e10cSrcweir 	}
612*cdf0e10cSrcweir 	else // Formel
613*cdf0e10cSrcweir 	{
614*cdf0e10cSrcweir 		aLbCond22.Hide();
615*cdf0e10cSrcweir 		aFtCond2And.Hide();
616*cdf0e10cSrcweir 		aEdtCond22.Hide();
617*cdf0e10cSrcweir 		aRbCond22.Hide();
618*cdf0e10cSrcweir 		aRbCond21.SetPosPixel( aRBtn2Pos2 );
619*cdf0e10cSrcweir 		aEdtCond21.SetPosSizePixel( aCond2Pos1, aCond2Size1 );
620*cdf0e10cSrcweir 	}
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 	ChangeCond22Hdl( NULL );
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir 	return( 0L );
625*cdf0e10cSrcweir }
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir //----------------------------------------------------------------------------
629*cdf0e10cSrcweir // zwischen, gleich, groesser, ...
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ChangeCond22Hdl, void *, EMPTYARG )
632*cdf0e10cSrcweir {
633*cdf0e10cSrcweir 	if( aLbCond22.IsVisible() )
634*cdf0e10cSrcweir 	{
635*cdf0e10cSrcweir 		sal_uInt16 nPos = aLbCond22.GetSelectEntryPos();
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 		if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
638*cdf0e10cSrcweir 		{
639*cdf0e10cSrcweir 			aEdtCond21.SetSizePixel( aCond2Size3 );
640*cdf0e10cSrcweir 			aRbCond21.SetPosPixel( aRBtn2Pos1 );
641*cdf0e10cSrcweir 			aFtCond2And.Show();
642*cdf0e10cSrcweir 			aEdtCond22.Show();
643*cdf0e10cSrcweir 			aRbCond22.Show();
644*cdf0e10cSrcweir 		}
645*cdf0e10cSrcweir 		else // gleich, n. gleich ...
646*cdf0e10cSrcweir 		{
647*cdf0e10cSrcweir 			aEdtCond22.Hide();
648*cdf0e10cSrcweir 			aRbCond22.Hide();
649*cdf0e10cSrcweir 			aFtCond2And.Hide();
650*cdf0e10cSrcweir 			aRbCond21.SetPosPixel( aRBtn2Pos2 );
651*cdf0e10cSrcweir 			aEdtCond21.SetSizePixel( aCond2Size2 );
652*cdf0e10cSrcweir 		}
653*cdf0e10cSrcweir 	}
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	return( 0L );
656*cdf0e10cSrcweir }
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir //----------------------------------------------------------------------------
660*cdf0e10cSrcweir // Enabled/Disabled Condition3-Controls
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ClickCond3Hdl, void *, EMPTYARG )
663*cdf0e10cSrcweir {
664*cdf0e10cSrcweir 	sal_Bool bChecked = aCbxCond3.IsChecked();
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 	aLbCond31.Enable( bChecked );
667*cdf0e10cSrcweir 	aLbCond32.Enable( bChecked );
668*cdf0e10cSrcweir 	aEdtCond31.Enable( bChecked );
669*cdf0e10cSrcweir 	aRbCond31.Enable( bChecked );
670*cdf0e10cSrcweir 	aFtCond3And.Enable( bChecked );
671*cdf0e10cSrcweir 	aEdtCond32.Enable( bChecked );
672*cdf0e10cSrcweir 	aRbCond32.Enable( bChecked );
673*cdf0e10cSrcweir 	aFtCond3Template.Enable( bChecked );
674*cdf0e10cSrcweir 	aLbCond3Template.Enable( bChecked );
675*cdf0e10cSrcweir     aBtnNew3.Enable( bChecked );
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	return( 0L );
678*cdf0e10cSrcweir }
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir //----------------------------------------------------------------------------
682*cdf0e10cSrcweir // Zellwert/Formel
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ChangeCond31Hdl, void *, EMPTYARG )
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir 	sal_uInt16 nPos = aLbCond31.GetSelectEntryPos();
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	if( nPos == 0 ) // Zellwert
689*cdf0e10cSrcweir 	{
690*cdf0e10cSrcweir 		aLbCond32.Show();
691*cdf0e10cSrcweir 		aEdtCond31.SetPosPixel( aCond3Pos2 );
692*cdf0e10cSrcweir 	}
693*cdf0e10cSrcweir 	else // Formel
694*cdf0e10cSrcweir 	{
695*cdf0e10cSrcweir 		aLbCond32.Hide();
696*cdf0e10cSrcweir 		aFtCond3And.Hide();
697*cdf0e10cSrcweir 		aEdtCond32.Hide();
698*cdf0e10cSrcweir 		aRbCond32.Hide();
699*cdf0e10cSrcweir 		aRbCond31.SetPosPixel( aRBtn3Pos2 );
700*cdf0e10cSrcweir 		aEdtCond31.SetPosSizePixel( aCond3Pos1, aCond3Size1 );
701*cdf0e10cSrcweir 	}
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 	ChangeCond32Hdl( NULL );
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 	return( 0L );
706*cdf0e10cSrcweir }
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir //----------------------------------------------------------------------------
710*cdf0e10cSrcweir // zwischen, gleich, groesser, ...
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, ChangeCond32Hdl, void *, EMPTYARG )
713*cdf0e10cSrcweir {
714*cdf0e10cSrcweir 	if( aLbCond32.IsVisible() )
715*cdf0e10cSrcweir 	{
716*cdf0e10cSrcweir 		sal_uInt16 nPos = aLbCond32.GetSelectEntryPos();
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir 		if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
719*cdf0e10cSrcweir 		{
720*cdf0e10cSrcweir 			aEdtCond31.SetSizePixel( aCond3Size3 );
721*cdf0e10cSrcweir 			aRbCond31.SetPosPixel( aRBtn3Pos1 );
722*cdf0e10cSrcweir 			aFtCond3And.Show();
723*cdf0e10cSrcweir 			aEdtCond32.Show();
724*cdf0e10cSrcweir 			aRbCond32.Show();
725*cdf0e10cSrcweir 		}
726*cdf0e10cSrcweir 		else // gleich, n. gleich ...
727*cdf0e10cSrcweir 		{
728*cdf0e10cSrcweir 			aEdtCond32.Hide();
729*cdf0e10cSrcweir 			aRbCond32.Hide();
730*cdf0e10cSrcweir 			aFtCond3And.Hide();
731*cdf0e10cSrcweir 			aRbCond31.SetPosPixel( aRBtn3Pos2 );
732*cdf0e10cSrcweir 			aEdtCond31.SetSizePixel( aCond3Size2 );
733*cdf0e10cSrcweir 		}
734*cdf0e10cSrcweir 	}
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir 	return( 0L );
737*cdf0e10cSrcweir }
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir //----------------------------------------------------------------------------
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, GetFocusHdl, Control*, pCtrl )
743*cdf0e10cSrcweir {
744*cdf0e10cSrcweir     if( (pCtrl == (Control*)&aEdtCond11) || (pCtrl == (Control*)&aRbCond11) )
745*cdf0e10cSrcweir         pEdActive = &aEdtCond11;
746*cdf0e10cSrcweir     else if( (pCtrl == (Control*)&aEdtCond12) || (pCtrl == (Control*)&aRbCond12) )
747*cdf0e10cSrcweir         pEdActive = &aEdtCond12;
748*cdf0e10cSrcweir     else if( (pCtrl == (Control*)&aEdtCond21) || (pCtrl == (Control*)&aRbCond21) )
749*cdf0e10cSrcweir         pEdActive = &aEdtCond21;
750*cdf0e10cSrcweir     else if( (pCtrl == (Control*)&aEdtCond22) || (pCtrl == (Control*)&aRbCond22) )
751*cdf0e10cSrcweir         pEdActive = &aEdtCond22;
752*cdf0e10cSrcweir     else if( (pCtrl == (Control*)&aEdtCond31) || (pCtrl == (Control*)&aRbCond31) )
753*cdf0e10cSrcweir         pEdActive = &aEdtCond31;
754*cdf0e10cSrcweir     else if( (pCtrl == (Control*)&aEdtCond32) || (pCtrl == (Control*)&aRbCond32) )
755*cdf0e10cSrcweir         pEdActive = &aEdtCond32;
756*cdf0e10cSrcweir     else
757*cdf0e10cSrcweir         pEdActive = NULL;
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir     if( pEdActive )
760*cdf0e10cSrcweir         pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir     return 0;
763*cdf0e10cSrcweir }
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir //----------------------------------------------------------------------------
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, LoseFocusHdl, Control*, EMPTYARG )
769*cdf0e10cSrcweir {
770*cdf0e10cSrcweir     bDlgLostFocus = !IsActive();
771*cdf0e10cSrcweir     return 0;
772*cdf0e10cSrcweir }
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir //----------------------------------------------------------------------------
776*cdf0e10cSrcweir //	[OK], [Cancel]
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, BtnHdl, PushButton*, pBtn )
779*cdf0e10cSrcweir {
780*cdf0e10cSrcweir 	if ( pBtn == &aBtnOk )
781*cdf0e10cSrcweir 	{
782*cdf0e10cSrcweir 		ScConditionalFormat aCondFrmt( 0, pDoc );
783*cdf0e10cSrcweir 		GetConditionalFormat( aCondFrmt );
784*cdf0e10cSrcweir 		ScCondFrmtItem aOutItem( FID_CONDITIONAL_FORMAT, aCondFrmt );
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 		SetDispatcherLock( sal_False );
787*cdf0e10cSrcweir 		SwitchToDocument();
788*cdf0e10cSrcweir 		GetBindings().GetDispatcher()->Execute( FID_CONDITIONAL_FORMAT,
789*cdf0e10cSrcweir 								  SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
790*cdf0e10cSrcweir 								  &aOutItem, 0L, 0L );
791*cdf0e10cSrcweir 		Close();
792*cdf0e10cSrcweir 	}
793*cdf0e10cSrcweir 	else if ( pBtn == &aBtnCancel )
794*cdf0e10cSrcweir 		Close();
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir 	return( 0L );
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir //----------------------------------------------------------------------------
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir IMPL_LINK( ScConditionalFormatDlg, NewBtnHdl, PushButton*, pBtn )
803*cdf0e10cSrcweir {
804*cdf0e10cSrcweir     SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
805*cdf0e10cSrcweir     SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir     // unlock the dispatcher so SID_STYLE_NEW can be executed
808*cdf0e10cSrcweir     // (SetDispatcherLock would affect all Calc documents)
809*cdf0e10cSrcweir     SfxDispatcher* pDisp = GetBindings().GetDispatcher();
810*cdf0e10cSrcweir     sal_Bool bLocked = pDisp->IsLocked();
811*cdf0e10cSrcweir     if (bLocked)
812*cdf0e10cSrcweir         pDisp->Lock(sal_False);
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir     // Execute the "new style" slot, complete with undo and all necessary updates.
815*cdf0e10cSrcweir     // The return value (SfxUInt16Item) is ignored, look for new styles instead.
816*cdf0e10cSrcweir     pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
817*cdf0e10cSrcweir                     &aFamilyItem,
818*cdf0e10cSrcweir                     &aRefItem,
819*cdf0e10cSrcweir                     0L );
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir     if (bLocked)
822*cdf0e10cSrcweir         pDisp->Lock(sal_True);
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir     // Find the new style and add it into the style list boxes
825*cdf0e10cSrcweir     String aNewStyle;
826*cdf0e10cSrcweir     SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
827*cdf0e10cSrcweir     for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
828*cdf0e10cSrcweir     {
829*cdf0e10cSrcweir         String aName = pStyle->GetName();
830*cdf0e10cSrcweir         if ( aLbCond1Template.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND )    // all lists contain the same entries
831*cdf0e10cSrcweir         {
832*cdf0e10cSrcweir             aLbCond1Template.InsertEntry( aName );
833*cdf0e10cSrcweir             aLbCond2Template.InsertEntry( aName );
834*cdf0e10cSrcweir             aLbCond3Template.InsertEntry( aName );
835*cdf0e10cSrcweir             // if there are several new styles (from API or a different view),
836*cdf0e10cSrcweir             // assume the last one is the result of the dialog
837*cdf0e10cSrcweir             aNewStyle = aName;
838*cdf0e10cSrcweir         }
839*cdf0e10cSrcweir     }
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir     // select the new style in the list box for which the button was pressed
842*cdf0e10cSrcweir     if ( aNewStyle.Len() )
843*cdf0e10cSrcweir     {
844*cdf0e10cSrcweir         ListBox* pListBox = &aLbCond1Template;
845*cdf0e10cSrcweir         if ( pBtn == &aBtnNew2 )
846*cdf0e10cSrcweir             pListBox = &aLbCond2Template;
847*cdf0e10cSrcweir         else if ( pBtn == &aBtnNew3 )
848*cdf0e10cSrcweir             pListBox = &aLbCond3Template;
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir         pListBox->SelectEntry( aNewStyle );
851*cdf0e10cSrcweir     }
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir     return 0;
854*cdf0e10cSrcweir }
855*cdf0e10cSrcweir 
856