xref: /aoo41x/main/formula/source/ui/dlg/parawin.cxx (revision 1b1b70fb)
1c25918c1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c25918c1SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c25918c1SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c25918c1SAndrew Rist  * distributed with this work for additional information
6c25918c1SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c25918c1SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c25918c1SAndrew Rist  * "License"); you may not use this file except in compliance
9c25918c1SAndrew Rist  * with the License.  You may obtain a copy of the License at
10c25918c1SAndrew Rist  *
11c25918c1SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c25918c1SAndrew Rist  *
13c25918c1SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c25918c1SAndrew Rist  * software distributed under the License is distributed on an
15c25918c1SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c25918c1SAndrew Rist  * KIND, either express or implied.  See the License for the
17c25918c1SAndrew Rist  * specific language governing permissions and limitations
18c25918c1SAndrew Rist  * under the License.
19c25918c1SAndrew Rist  *
20c25918c1SAndrew Rist  *************************************************************/
21c25918c1SAndrew Rist 
22c25918c1SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_formula.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //----------------------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <svl/zforlist.hxx>
32cdf0e10cSrcweir #include <svl/stritem.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "parawin.hxx"
35cdf0e10cSrcweir #include "parawin.hrc"
36cdf0e10cSrcweir #include "helpids.hrc"
37cdf0e10cSrcweir #include "formula/formdata.hxx"
38cdf0e10cSrcweir #include "formula/IFunctionDescription.hxx"
39cdf0e10cSrcweir #include "ModuleHelper.hxx"
40cdf0e10cSrcweir #include "ForResId.hrc"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define VAR_ARGS 30
43*1b1b70fbSAndrew Rist #define PAIRED_VAR_ARGS (VAR_ARGS + VAR_ARGS)
44cdf0e10cSrcweir namespace formula
45cdf0e10cSrcweir {
46cdf0e10cSrcweir //============================================================================
47cdf0e10cSrcweir 
ParaWin(Window * pParent,IControlReferenceHandler * _pDlg,Point aPos)48cdf0e10cSrcweir ParaWin::ParaWin(Window* pParent,IControlReferenceHandler* _pDlg,Point aPos):
49cdf0e10cSrcweir 	TabPage			(pParent,ModuleRes(RID_FORMULATAB_PARAMETER)),
50cdf0e10cSrcweir 	pFuncDesc		( NULL ),
51cdf0e10cSrcweir     pMyParent       (_pDlg),
52cdf0e10cSrcweir 	aFtEditDesc 	( this, ModuleRes( FT_EDITDESC ) ),
53cdf0e10cSrcweir 	aFtArgName		( this, ModuleRes( FT_PARNAME ) ),
54cdf0e10cSrcweir 	aFtArgDesc		( this, ModuleRes( FT_PARDESC ) ),
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     aBtnFx1 		( this, ModuleRes( BTN_FX1 ) ),
57cdf0e10cSrcweir 	aFtArg1 		( this, ModuleRes( FT_ARG1 ) ),
58cdf0e10cSrcweir     aEdArg1 		( this, ModuleRes( ED_ARG1 ) ),
59cdf0e10cSrcweir 	aRefBtn1		( this, ModuleRes( RB_ARG1 ) ),
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	aBtnFx2 		( this, ModuleRes( BTN_FX2 ) ),
62cdf0e10cSrcweir     aFtArg2 		( this, ModuleRes( FT_ARG2 ) ),
63cdf0e10cSrcweir     aEdArg2 		( this, ModuleRes( ED_ARG2 ) ),
64cdf0e10cSrcweir     aRefBtn2		( this, ModuleRes( RB_ARG2 ) ),
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	aBtnFx3 		( this, ModuleRes( BTN_FX3 ) ),
67cdf0e10cSrcweir     aFtArg3 		( this, ModuleRes( FT_ARG3 ) ),
68cdf0e10cSrcweir     aEdArg3 		( this, ModuleRes( ED_ARG3 ) ),
69cdf0e10cSrcweir 	aRefBtn3		( this, ModuleRes( RB_ARG3 ) ),
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     aBtnFx4 		( this, ModuleRes( BTN_FX4 ) ),
72cdf0e10cSrcweir     aFtArg4 		( this, ModuleRes( FT_ARG4 ) ),
73cdf0e10cSrcweir     aEdArg4 		( this, ModuleRes( ED_ARG4 ) ),
74cdf0e10cSrcweir 	aRefBtn4		( this, ModuleRes( RB_ARG4 ) ),
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	aSlider 		( this, ModuleRes( WND_SLIDER ) ),
77cdf0e10cSrcweir     m_sOptional     ( ModuleRes( STR_OPTIONAL ) ),
78cdf0e10cSrcweir     m_sRequired     ( ModuleRes( STR_REQUIRED ) ),
79cdf0e10cSrcweir 	bRefMode		(sal_False)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir     Image aFxHC( ModuleRes( IMG_FX_H ) );
82cdf0e10cSrcweir 	FreeResource();
83cdf0e10cSrcweir 	aDefaultString=aFtEditDesc.GetText();
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	SetPosPixel(aPos);
86cdf0e10cSrcweir 	nEdFocus=NOT_FOUND;
87cdf0e10cSrcweir 	nActiveLine=0;
88cdf0e10cSrcweir     Size aSize = aSlider.GetSizePixel();
89cdf0e10cSrcweir     aSize.Width() = GetSettings().GetStyleSettings().GetScrollBarSize();
90cdf0e10cSrcweir     aSlider.SetSizePixel( aSize );
91cdf0e10cSrcweir 	aSlider.SetEndScrollHdl( LINK( this, ParaWin, ScrollHdl ) );
92cdf0e10cSrcweir 	aSlider.SetScrollHdl( LINK( this, ParaWin, ScrollHdl ) );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     aBtnFx1.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
95cdf0e10cSrcweir     aBtnFx2.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
96cdf0e10cSrcweir     aBtnFx3.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
97cdf0e10cSrcweir     aBtnFx4.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	InitArgInput( 0, aFtArg1, aBtnFx1, aEdArg1, aRefBtn1);
100cdf0e10cSrcweir 	InitArgInput( 1, aFtArg2, aBtnFx2, aEdArg2, aRefBtn2);
101cdf0e10cSrcweir 	InitArgInput( 2, aFtArg3, aBtnFx3, aEdArg3, aRefBtn3);
102cdf0e10cSrcweir 	InitArgInput( 3, aFtArg4, aBtnFx4, aEdArg4, aRefBtn4);
103cdf0e10cSrcweir 	ClearAll();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
UpdateArgDesc(sal_uInt16 nArg)106cdf0e10cSrcweir void ParaWin::UpdateArgDesc( sal_uInt16 nArg )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	if (nArg==NOT_FOUND) return;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	if ( nArgs > 4 )
111cdf0e10cSrcweir         nArg = sal::static_int_cast<sal_uInt16>( nArg + GetSliderPos() );
112cdf0e10cSrcweir 		//@ nArg += (sal_uInt16)aSlider.GetThumbPos();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	if ( (nArgs > 0) && (nArg<nArgs) )
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		String	aArgDesc;
117cdf0e10cSrcweir 		String	aArgName;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 		SetArgumentDesc( String() );
120cdf0e10cSrcweir 		SetArgumentText( String() );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		if ( nArgs < VAR_ARGS )
123cdf0e10cSrcweir 		{
124cdf0e10cSrcweir             sal_uInt16 nRealArg = (aVisibleArgMapping.size() < nArg) ? aVisibleArgMapping[nArg] : nArg;
125cdf0e10cSrcweir 			aArgDesc  = pFuncDesc->getParameterDescription(nRealArg);
126cdf0e10cSrcweir 			aArgName  = pFuncDesc->getParameterName(nRealArg);
127cdf0e10cSrcweir             aArgName += ' ';
128cdf0e10cSrcweir 			aArgName += (pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ;
129cdf0e10cSrcweir 		}
130*1b1b70fbSAndrew Rist 		else if ( nArgs < PAIRED_VAR_ARGS )
131cdf0e10cSrcweir 		{
132cdf0e10cSrcweir 			sal_uInt16 nFix = nArgs - VAR_ARGS;
133cdf0e10cSrcweir 			sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix );
134cdf0e10cSrcweir             sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
135cdf0e10cSrcweir                     aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
136cdf0e10cSrcweir 			aArgDesc  = pFuncDesc->getParameterDescription(nRealArg);
137cdf0e10cSrcweir 			aArgName  = pFuncDesc->getParameterName(nRealArg);
138cdf0e10cSrcweir 			if ( nArg >= nFix )
139cdf0e10cSrcweir 				aArgName += String::CreateFromInt32(nArg-nFix+1);
140cdf0e10cSrcweir             aArgName += ' ';
141cdf0e10cSrcweir 
142cdf0e10cSrcweir             aArgName += (nArg > nFix || pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ;
143cdf0e10cSrcweir 		}
144*1b1b70fbSAndrew Rist 		else
145*1b1b70fbSAndrew Rist 		{
146*1b1b70fbSAndrew Rist 		    sal_uInt16 nFix = nArgs - PAIRED_VAR_ARGS;
147*1b1b70fbSAndrew Rist 			sal_uInt16 nPos;
148*1b1b70fbSAndrew Rist 			if ( nArg < nFix )
149*1b1b70fbSAndrew Rist 			    nPos = nArg;
150*1b1b70fbSAndrew Rist 			else
151*1b1b70fbSAndrew Rist 			    nPos = nFix + ( (nArg-nFix) % 2);
152*1b1b70fbSAndrew Rist             sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
153*1b1b70fbSAndrew Rist                     aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
154*1b1b70fbSAndrew Rist 			aArgDesc  = pFuncDesc->getParameterDescription(nRealArg);
155*1b1b70fbSAndrew Rist 			aArgName  = pFuncDesc->getParameterName(nRealArg);
156*1b1b70fbSAndrew Rist 			if ( nArg >= nFix )
157*1b1b70fbSAndrew Rist 				aArgName += String::CreateFromInt32((nArg-nFix)/2 + 1);
158*1b1b70fbSAndrew Rist             aArgName += ' ';
159*1b1b70fbSAndrew Rist 
160*1b1b70fbSAndrew Rist             aArgName += (nArg > (nFix+1) || pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ;
161*1b1b70fbSAndrew Rist 		}
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 		SetArgumentDesc(aArgDesc);
164cdf0e10cSrcweir 		SetArgumentText(aArgName);
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
UpdateArgInput(sal_uInt16 nOffset,sal_uInt16 i)168cdf0e10cSrcweir void ParaWin::UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	sal_uInt16 nArg = nOffset + i;
171cdf0e10cSrcweir 	if ( nArgs < VAR_ARGS)
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir 		if(nArg<nArgs)
174cdf0e10cSrcweir 		{
175cdf0e10cSrcweir             sal_uInt16 nRealArg = aVisibleArgMapping[nArg];
176cdf0e10cSrcweir 			SetArgNameFont	(i,(pFuncDesc->isParameterOptional(nRealArg))
177cdf0e10cSrcweir 											? aFntLight : aFntBold );
178cdf0e10cSrcweir 			SetArgName		(i,pFuncDesc->getParameterName(nRealArg));
179cdf0e10cSrcweir 		}
180cdf0e10cSrcweir 	}
181*1b1b70fbSAndrew Rist 	else if ( nArgs < PAIRED_VAR_ARGS)
182cdf0e10cSrcweir 	{
183cdf0e10cSrcweir 		sal_uInt16 nFix = nArgs - VAR_ARGS;
184cdf0e10cSrcweir 		sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix );
185cdf0e10cSrcweir         sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
186cdf0e10cSrcweir                 aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
187cdf0e10cSrcweir 		SetArgNameFont( i,
188cdf0e10cSrcweir                 (nArg > nFix || pFuncDesc->isParameterOptional(nRealArg)) ?
189cdf0e10cSrcweir                 aFntLight : aFntBold );
190cdf0e10cSrcweir 		if ( nArg >= nFix )
191cdf0e10cSrcweir 		{
192cdf0e10cSrcweir 			String aArgName( pFuncDesc->getParameterName(nRealArg) );
193cdf0e10cSrcweir 			aArgName += String::CreateFromInt32(nArg-nFix+1);
194cdf0e10cSrcweir 			SetArgName( i, aArgName );
195cdf0e10cSrcweir 		}
196cdf0e10cSrcweir 		else
197cdf0e10cSrcweir 			SetArgName( i, pFuncDesc->getParameterName(nRealArg) );
198cdf0e10cSrcweir 	}
199*1b1b70fbSAndrew Rist 	else
200*1b1b70fbSAndrew Rist 	{
201*1b1b70fbSAndrew Rist 	    sal_uInt16 nFix = nArgs - PAIRED_VAR_ARGS;
202*1b1b70fbSAndrew Rist 	    sal_uInt16 nPos;
203*1b1b70fbSAndrew Rist 			if ( nArg < nFix )
204*1b1b70fbSAndrew Rist 			    nPos = nArg;
205*1b1b70fbSAndrew Rist 			else
206*1b1b70fbSAndrew Rist 			    nPos = nFix + ( (nArg-nFix) % 2);
207*1b1b70fbSAndrew Rist         sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
208*1b1b70fbSAndrew Rist                 aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
209*1b1b70fbSAndrew Rist 		SetArgNameFont( i,
210*1b1b70fbSAndrew Rist                 (nArg > (nFix+1) || pFuncDesc->isParameterOptional(nRealArg)) ?
211*1b1b70fbSAndrew Rist                 aFntLight : aFntBold );
212*1b1b70fbSAndrew Rist 		if ( nArg >= nFix )
213*1b1b70fbSAndrew Rist 		{
214*1b1b70fbSAndrew Rist 			String aArgName( pFuncDesc->getParameterName(nRealArg) );
215*1b1b70fbSAndrew Rist 			aArgName += String::CreateFromInt32((nArg-nFix)/2 + 1);
216*1b1b70fbSAndrew Rist 			SetArgName( i, aArgName );
217*1b1b70fbSAndrew Rist 		}
218*1b1b70fbSAndrew Rist 		else
219*1b1b70fbSAndrew Rist 			SetArgName( i, pFuncDesc->getParameterName(nRealArg) );
220*1b1b70fbSAndrew Rist 	}
221cdf0e10cSrcweir 	if(nArg<nArgs) SetArgVal(i,aParaArray[nArg]);
222cdf0e10cSrcweir 	//@ aArgInput[i].SetArgVal( *(pArgArr[nOffset+i]) );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
~ParaWin()226cdf0e10cSrcweir ParaWin::~ParaWin()
227cdf0e10cSrcweir {
228cdf0e10cSrcweir     // #i66422# if the focus changes during destruction of the controls,
229cdf0e10cSrcweir     // don't call the focus handlers
230cdf0e10cSrcweir     Link aEmptyLink;
231cdf0e10cSrcweir     aBtnFx1.SetGetFocusHdl( aEmptyLink );
232cdf0e10cSrcweir     aBtnFx2.SetGetFocusHdl( aEmptyLink );
233cdf0e10cSrcweir     aBtnFx3.SetGetFocusHdl( aEmptyLink );
234cdf0e10cSrcweir     aBtnFx4.SetGetFocusHdl( aEmptyLink );
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
GetActiveLine()237cdf0e10cSrcweir sal_uInt16 ParaWin::GetActiveLine()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir 	return nActiveLine;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
SetActiveLine(sal_uInt16 no)242cdf0e10cSrcweir void ParaWin::SetActiveLine(sal_uInt16 no)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	if(no<nArgs)
245cdf0e10cSrcweir 	{
246cdf0e10cSrcweir 		long nOffset = GetSliderPos();
247cdf0e10cSrcweir 		nActiveLine=no;
248cdf0e10cSrcweir 		long nNewEdPos=(long)nActiveLine-nOffset;
249cdf0e10cSrcweir 		if(nNewEdPos<0 || nNewEdPos>3)
250cdf0e10cSrcweir 		{
251cdf0e10cSrcweir 			nOffset+=nNewEdPos;
252cdf0e10cSrcweir 			SetSliderPos((sal_uInt16) nOffset);
253cdf0e10cSrcweir 			nOffset=GetSliderPos();
254cdf0e10cSrcweir 		}
255cdf0e10cSrcweir 		nEdFocus=no-(sal_uInt16)nOffset;
256cdf0e10cSrcweir 		UpdateArgDesc( nEdFocus );
257cdf0e10cSrcweir 	}
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
GetActiveEdit()260cdf0e10cSrcweir RefEdit* ParaWin::GetActiveEdit()
261cdf0e10cSrcweir {
262cdf0e10cSrcweir 	if(nArgs>0 && nEdFocus!=NOT_FOUND)
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 		return aArgInput[nEdFocus].GetArgEdPtr();
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir 	else
267cdf0e10cSrcweir 	{
268cdf0e10cSrcweir 		return NULL;
269cdf0e10cSrcweir 	}
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 
GetArgument(sal_uInt16 no)273cdf0e10cSrcweir String ParaWin::GetArgument(sal_uInt16 no)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	String aStr;
276cdf0e10cSrcweir 	if(no<aParaArray.size())
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir 		aStr=aParaArray[no];
279cdf0e10cSrcweir 		if(no==nActiveLine && aStr.Len()==0)
280cdf0e10cSrcweir 			aStr+=' ';
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir 	return aStr;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
GetActiveArgName()285cdf0e10cSrcweir String	ParaWin::GetActiveArgName()
286cdf0e10cSrcweir {
287cdf0e10cSrcweir 	String aStr;
288cdf0e10cSrcweir 	if(nArgs>0 && nEdFocus!=NOT_FOUND)
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		aStr=aArgInput[nEdFocus].GetArgName();
291cdf0e10cSrcweir 	}
292cdf0e10cSrcweir 	return aStr;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 
SetArgument(sal_uInt16 no,const String & aString)296cdf0e10cSrcweir void ParaWin::SetArgument(sal_uInt16 no, const String& aString)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir 	if(no<aParaArray.size())
299cdf0e10cSrcweir 	{
300cdf0e10cSrcweir 		aParaArray[no] = aString;
301cdf0e10cSrcweir 		aParaArray[no].EraseLeadingChars();
302cdf0e10cSrcweir 	}
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
DelParaArray()305cdf0e10cSrcweir void ParaWin::DelParaArray()
306cdf0e10cSrcweir {
307cdf0e10cSrcweir     ::std::vector<String>().swap(aParaArray);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
SetArgumentFonts(const Font & aBoldFont,const Font & aLightFont)310cdf0e10cSrcweir void ParaWin::SetArgumentFonts(const Font&aBoldFont,const Font&aLightFont)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir 	aFntBold=aBoldFont;
313cdf0e10cSrcweir 	aFntLight=aLightFont;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
SetFunctionDesc(const IFunctionDescription * pFDesc)316cdf0e10cSrcweir void ParaWin::SetFunctionDesc(const IFunctionDescription* pFDesc)
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 	pFuncDesc=pFDesc;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	SetArgumentDesc( String() );
321cdf0e10cSrcweir 	SetArgumentText( String() );
322cdf0e10cSrcweir 	SetEditDesc( String() );
323cdf0e10cSrcweir 	nArgs = 0;
324cdf0e10cSrcweir 	if ( pFuncDesc!=NULL)
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		if ( pFuncDesc->getDescription().getLength() )
327cdf0e10cSrcweir 		{
328cdf0e10cSrcweir 			SetEditDesc(pFuncDesc->getDescription());
329cdf0e10cSrcweir 		}
330cdf0e10cSrcweir 		else
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir 			SetEditDesc(aDefaultString);
333cdf0e10cSrcweir 		}
334cdf0e10cSrcweir 		nArgs = pFuncDesc->getSuppressedArgumentCount();
335cdf0e10cSrcweir         pFuncDesc->fillVisibleArgumentMapping(aVisibleArgMapping);
336cdf0e10cSrcweir 		aSlider.Hide();
337cdf0e10cSrcweir 		rtl::OString sHelpId = pFuncDesc->getHelpId();
338cdf0e10cSrcweir 		SetHelpId( sHelpId );
339cdf0e10cSrcweir 		aEdArg1.SetHelpId( sHelpId );
340cdf0e10cSrcweir 		aEdArg2.SetHelpId( sHelpId );
341cdf0e10cSrcweir 		aEdArg3.SetHelpId( sHelpId );
342cdf0e10cSrcweir 		aEdArg4.SetHelpId( sHelpId );
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 		//	Unique-IDs muessen gleich bleiben fuer Automatisierung
345cdf0e10cSrcweir 		SetUniqueId( HID_FORMULA_FAP_PAGE );
346cdf0e10cSrcweir 		aEdArg1.SetUniqueId( HID_FORMULA_FAP_EDIT1 );
347cdf0e10cSrcweir 		aEdArg2.SetUniqueId( HID_FORMULA_FAP_EDIT2 );
348cdf0e10cSrcweir 		aEdArg3.SetUniqueId( HID_FORMULA_FAP_EDIT3 );
349cdf0e10cSrcweir 		aEdArg4.SetUniqueId( HID_FORMULA_FAP_EDIT4 );
350cdf0e10cSrcweir 		SetActiveLine(0);
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir 	else
353cdf0e10cSrcweir 	{
354cdf0e10cSrcweir 		nActiveLine=0;
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
SetArgumentText(const String & aText)359cdf0e10cSrcweir void ParaWin::SetArgumentText(const String& aText)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	aFtArgName.SetText(aText);
362cdf0e10cSrcweir }
363cdf0e10cSrcweir 
SetArgumentDesc(const String & aText)364cdf0e10cSrcweir void ParaWin::SetArgumentDesc(const String& aText)
365cdf0e10cSrcweir {
366cdf0e10cSrcweir 	aFtArgDesc.SetText(aText);
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
SetEditDesc(const String & aText)369cdf0e10cSrcweir void ParaWin::SetEditDesc(const String& aText)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir 	aFtEditDesc.SetText(aText);
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
SetArgName(sal_uInt16 no,const String & aText)374cdf0e10cSrcweir void ParaWin::SetArgName(sal_uInt16 no,const String& aText)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir 	aArgInput[no].SetArgName(aText);
377cdf0e10cSrcweir 	aArgInput[no].UpdateAccessibleNames();
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
SetArgNameFont(sal_uInt16 no,const Font & aFont)380cdf0e10cSrcweir void ParaWin::SetArgNameFont(sal_uInt16 no,const Font& aFont)
381cdf0e10cSrcweir {
382cdf0e10cSrcweir 	aArgInput[no].SetArgNameFont(aFont);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
SetArgVal(sal_uInt16 no,const String & aText)385cdf0e10cSrcweir void ParaWin::SetArgVal(sal_uInt16 no,const String& aText)
386cdf0e10cSrcweir {
387cdf0e10cSrcweir 	aArgInput[no].SetArgVal(aText);
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
HideParaLine(sal_uInt16 no)390cdf0e10cSrcweir void ParaWin::HideParaLine(sal_uInt16 no)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	aArgInput[no].Hide();
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
ShowParaLine(sal_uInt16 no)395cdf0e10cSrcweir void ParaWin::ShowParaLine(sal_uInt16 no)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir 	aArgInput[no].Show();
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
SetEdFocus(sal_uInt16 no)400cdf0e10cSrcweir void ParaWin::SetEdFocus(sal_uInt16 no)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir 	UpdateArgDesc(no);
403cdf0e10cSrcweir 	if(no<4 && no<aParaArray.size())
404cdf0e10cSrcweir 		aArgInput[no].GetArgEdPtr()->GrabFocus();
405cdf0e10cSrcweir }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 
InitArgInput(sal_uInt16 nPos,FixedText & rFtArg,ImageButton & rBtnFx,ArgEdit & rEdArg,RefButton & rRefBtn)408cdf0e10cSrcweir void ParaWin::InitArgInput( sal_uInt16 nPos, FixedText& rFtArg, ImageButton& rBtnFx,
409cdf0e10cSrcweir 						ArgEdit& rEdArg, RefButton& rRefBtn)
410cdf0e10cSrcweir {
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	rRefBtn.SetReferences(pMyParent,&rEdArg);
413cdf0e10cSrcweir 	rEdArg.SetRefDialog(pMyParent);
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	aArgInput[nPos].InitArgInput (&rFtArg,&rBtnFx,&rEdArg,&rRefBtn);
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 	aArgInput[nPos].Hide();
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	aArgInput[nPos].SetFxClickHdl	( LINK( this, ParaWin, GetFxHdl ) );
420cdf0e10cSrcweir 	aArgInput[nPos].SetFxFocusHdl	( LINK( this, ParaWin, GetFxFocusHdl ) );
421cdf0e10cSrcweir 	aArgInput[nPos].SetEdFocusHdl	( LINK( this, ParaWin, GetEdFocusHdl ) );
422cdf0e10cSrcweir 	aArgInput[nPos].SetEdModifyHdl	( LINK( this, ParaWin, ModifyHdl ) );
423cdf0e10cSrcweir 	aArgInput[nPos].UpdateAccessibleNames();
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
ClearAll()426cdf0e10cSrcweir void ParaWin::ClearAll()
427cdf0e10cSrcweir {
428cdf0e10cSrcweir 	SetFunctionDesc(NULL);
429cdf0e10cSrcweir 	SetArgumentOffset(0);
430cdf0e10cSrcweir }
431cdf0e10cSrcweir 
SetArgumentOffset(sal_uInt16 nOffset)432cdf0e10cSrcweir void ParaWin::SetArgumentOffset(sal_uInt16 nOffset)
433cdf0e10cSrcweir {
434cdf0e10cSrcweir 	DelParaArray();
435cdf0e10cSrcweir 	aSlider.SetThumbPos(0);
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     aParaArray.resize(nArgs);
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	if ( nArgs > 0 )
440cdf0e10cSrcweir 	{
441cdf0e10cSrcweir 		for ( int i=0; i<4 && i<nArgs; i++ )
442cdf0e10cSrcweir 		{
443cdf0e10cSrcweir 			String aString;
444cdf0e10cSrcweir 			aArgInput[i].SetArgVal(aString);
445cdf0e10cSrcweir 			aArgInput[i].GetArgEdPtr()->Init(
446cdf0e10cSrcweir 				(i==0)			  	 ? (ArgEdit *)NULL : aArgInput[i-1].GetArgEdPtr(),
447cdf0e10cSrcweir 				(i==3 || i==nArgs-1) ? (ArgEdit *)NULL : aArgInput[i+1].GetArgEdPtr(),
448cdf0e10cSrcweir 									   aSlider, nArgs );
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	if ( nArgs < 5 )
453cdf0e10cSrcweir 	{
454cdf0e10cSrcweir 		aSlider.Hide();
455cdf0e10cSrcweir 	}
456cdf0e10cSrcweir 	else
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir 		//aSlider.SetEndScrollHdl( LINK( this, ScFormulaDlg, ScrollHdl ) );
459cdf0e10cSrcweir 		aSlider.SetPageSize( 4 );
460cdf0e10cSrcweir 		aSlider.SetVisibleSize( 4 );
461cdf0e10cSrcweir 		aSlider.SetLineSize( 1 );
462cdf0e10cSrcweir 		aSlider.SetRange( Range( 0, nArgs ) );
463cdf0e10cSrcweir 		aSlider.SetThumbPos( nOffset );
464cdf0e10cSrcweir 		aSlider.Show();
465cdf0e10cSrcweir 	}
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 	UpdateParas();
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
UpdateParas()470cdf0e10cSrcweir void ParaWin::UpdateParas()
471cdf0e10cSrcweir {
472cdf0e10cSrcweir 	sal_uInt16 i;
473cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	if ( nArgs > 0 )
476cdf0e10cSrcweir 	{
477cdf0e10cSrcweir 		for ( i=0; (i<nArgs) && (i<4); i++ )
478cdf0e10cSrcweir 		{
479cdf0e10cSrcweir 			UpdateArgInput( nOffset, i );
480cdf0e10cSrcweir 			ShowParaLine(i);
481cdf0e10cSrcweir 		}
482cdf0e10cSrcweir 	}
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	for ( i=nArgs; i<4; i++ ) HideParaLine(i);
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 
GetSliderPos()488cdf0e10cSrcweir sal_uInt16 ParaWin::GetSliderPos()
489cdf0e10cSrcweir {
490cdf0e10cSrcweir 	return (sal_uInt16) aSlider.GetThumbPos();
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
SetSliderPos(sal_uInt16 nSliderPos)493cdf0e10cSrcweir void ParaWin::SetSliderPos(sal_uInt16 nSliderPos)
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 	if(aSlider.IsVisible() && nOffset!=nSliderPos)
498cdf0e10cSrcweir 	{
499cdf0e10cSrcweir 		aSlider.SetThumbPos(nSliderPos);
500cdf0e10cSrcweir         for ( sal_uInt16 i=0; i<4; i++ )
501cdf0e10cSrcweir 		{
502cdf0e10cSrcweir 			UpdateArgInput( nSliderPos, i );
503cdf0e10cSrcweir 		}
504cdf0e10cSrcweir 	}
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
SliderMoved()507cdf0e10cSrcweir void ParaWin::SliderMoved()
508cdf0e10cSrcweir {
509cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     for ( sal_uInt16 i=0; i<4; i++ )
512cdf0e10cSrcweir 	{
513cdf0e10cSrcweir 		UpdateArgInput( nOffset, i );
514cdf0e10cSrcweir 	}
515cdf0e10cSrcweir 	if(nEdFocus!=NOT_FOUND)
516cdf0e10cSrcweir 	{
517cdf0e10cSrcweir 		UpdateArgDesc( nEdFocus );
518cdf0e10cSrcweir 		aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
519cdf0e10cSrcweir 		nActiveLine=nEdFocus+nOffset;
520cdf0e10cSrcweir 		ArgumentModified();
521cdf0e10cSrcweir 		aArgInput[nEdFocus].UpdateAccessibleNames();
522cdf0e10cSrcweir 	}
523cdf0e10cSrcweir 	aScrollLink.Call(this);
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
ArgumentModified()526cdf0e10cSrcweir void ParaWin::ArgumentModified()
527cdf0e10cSrcweir {
528cdf0e10cSrcweir 	aArgModifiedLink.Call(this);
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
FxClick()531cdf0e10cSrcweir void ParaWin::FxClick()
532cdf0e10cSrcweir {
533cdf0e10cSrcweir 	aFxLink.Call(this);
534cdf0e10cSrcweir }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 
IMPL_LINK(ParaWin,GetFxHdl,ArgInput *,pPtr)537cdf0e10cSrcweir IMPL_LINK( ParaWin, GetFxHdl, ArgInput*, pPtr )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
540cdf0e10cSrcweir 	nEdFocus=NOT_FOUND;
541cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos<5;nPos++)
542cdf0e10cSrcweir 	{
543cdf0e10cSrcweir 		if(pPtr == &aArgInput[nPos])
544cdf0e10cSrcweir 		{
545cdf0e10cSrcweir 			nEdFocus=nPos;
546cdf0e10cSrcweir 			break;
547cdf0e10cSrcweir 		}
548cdf0e10cSrcweir 	}
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 	if(nEdFocus!=NOT_FOUND)
551cdf0e10cSrcweir 	{
552cdf0e10cSrcweir 		aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
553cdf0e10cSrcweir 		nActiveLine=nEdFocus+nOffset;
554cdf0e10cSrcweir 		FxClick();
555cdf0e10cSrcweir 	}
556cdf0e10cSrcweir 	return 0;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
IMPL_LINK(ParaWin,GetFxFocusHdl,ArgInput *,pPtr)559cdf0e10cSrcweir IMPL_LINK( ParaWin, GetFxFocusHdl, ArgInput*, pPtr )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
562cdf0e10cSrcweir 	nEdFocus=NOT_FOUND;
563cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos<5;nPos++)
564cdf0e10cSrcweir 	{
565cdf0e10cSrcweir 		if(pPtr == &aArgInput[nPos])
566cdf0e10cSrcweir 		{
567cdf0e10cSrcweir 			nEdFocus=nPos;
568cdf0e10cSrcweir 			break;
569cdf0e10cSrcweir 		}
570cdf0e10cSrcweir 	}
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 	if(nEdFocus!=NOT_FOUND)
573cdf0e10cSrcweir 	{
574cdf0e10cSrcweir 		aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
575cdf0e10cSrcweir 		UpdateArgDesc( nEdFocus );
576cdf0e10cSrcweir 		nActiveLine=nEdFocus+nOffset;
577cdf0e10cSrcweir 	}
578cdf0e10cSrcweir 	return 0;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 
IMPL_LINK(ParaWin,GetEdFocusHdl,ArgInput *,pPtr)583cdf0e10cSrcweir IMPL_LINK( ParaWin, GetEdFocusHdl, ArgInput*, pPtr )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
586cdf0e10cSrcweir 	nEdFocus=NOT_FOUND;
587cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos<5;nPos++)
588cdf0e10cSrcweir 	{
589cdf0e10cSrcweir 		if(pPtr == &aArgInput[nPos])
590cdf0e10cSrcweir 		{
591cdf0e10cSrcweir 			nEdFocus=nPos;
592cdf0e10cSrcweir 			break;
593cdf0e10cSrcweir 		}
594cdf0e10cSrcweir 	}
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	if(nEdFocus!=NOT_FOUND)
597cdf0e10cSrcweir 	{
598cdf0e10cSrcweir 		aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
599cdf0e10cSrcweir 		UpdateArgDesc( nEdFocus );
600cdf0e10cSrcweir 		nActiveLine=nEdFocus+nOffset;
601cdf0e10cSrcweir 		ArgumentModified();
602cdf0e10cSrcweir 		aArgInput[nEdFocus].UpdateAccessibleNames();
603cdf0e10cSrcweir 	}
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	return 0;
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
IMPL_LINK(ParaWin,ScrollHdl,ScrollBar *,EMPTYARG)609cdf0e10cSrcweir IMPL_LINK( ParaWin, ScrollHdl, ScrollBar*, EMPTYARG )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	SliderMoved();
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 	return 0;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
IMPL_LINK(ParaWin,ModifyHdl,ArgInput *,pPtr)616cdf0e10cSrcweir IMPL_LINK( ParaWin, ModifyHdl, ArgInput*, pPtr )
617cdf0e10cSrcweir {
618cdf0e10cSrcweir 	sal_uInt16 nOffset = GetSliderPos();
619cdf0e10cSrcweir 	nEdFocus=NOT_FOUND;
620cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos<5;nPos++)
621cdf0e10cSrcweir 	{
622cdf0e10cSrcweir 		if(pPtr == &aArgInput[nPos])
623cdf0e10cSrcweir 		{
624cdf0e10cSrcweir 			nEdFocus=nPos;
625cdf0e10cSrcweir 			break;
626cdf0e10cSrcweir 		}
627cdf0e10cSrcweir 	}
628cdf0e10cSrcweir 	if(nEdFocus!=NOT_FOUND)
629cdf0e10cSrcweir 	{
630cdf0e10cSrcweir 		aParaArray[nEdFocus+nOffset] = aArgInput[nEdFocus].GetArgVal();
631cdf0e10cSrcweir 		UpdateArgDesc( nEdFocus);
632cdf0e10cSrcweir 		nActiveLine=nEdFocus+nOffset;
633cdf0e10cSrcweir 	}
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 	ArgumentModified();
636cdf0e10cSrcweir 	return 0;
637cdf0e10cSrcweir }
638 
639 
640 
641 } // formula
642