xref: /aoo42x/main/sw/source/ui/fldui/fldfunc.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <sfx2/app.hxx>
32cdf0e10cSrcweir #include <basic/basmgr.hxx>
33cdf0e10cSrcweir #include <basic/sbmod.hxx>
34cdf0e10cSrcweir #include <docsh.hxx>
35cdf0e10cSrcweir #include <swtypes.hxx>
36cdf0e10cSrcweir #ifndef _GLOBALS_HRC
37cdf0e10cSrcweir #include <globals.hrc>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <fldbas.hxx>
40cdf0e10cSrcweir #include <docufld.hxx>
41cdf0e10cSrcweir #ifndef _VIEW_HXX
42cdf0e10cSrcweir #include <view.hxx>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #include <wrtsh.hxx>
45cdf0e10cSrcweir #include <swmodule.hxx>
46cdf0e10cSrcweir #ifndef _FLDFUNC_HXX
47cdf0e10cSrcweir #include <fldfunc.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #include <flddropdown.hxx>
50cdf0e10cSrcweir #ifndef _FLDUI_HRC
51cdf0e10cSrcweir #include <fldui.hrc>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _FLDTDLG_HRC
54cdf0e10cSrcweir #include <fldtdlg.hrc>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #define USER_DATA_VERSION_1 "1"
58cdf0e10cSrcweir #define USER_DATA_VERSION USER_DATA_VERSION_1
59cdf0e10cSrcweir 
60cdf0e10cSrcweir using namespace ::com::sun::star;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir using rtl::OUString;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /*--------------------------------------------------------------------
65cdf0e10cSrcweir 	Beschreibung:
66cdf0e10cSrcweir  --------------------------------------------------------------------*/
67cdf0e10cSrcweir 
SwFldFuncPage(Window * pParent,const SfxItemSet & rCoreSet)68cdf0e10cSrcweir SwFldFuncPage::SwFldFuncPage(Window* pParent, const SfxItemSet& rCoreSet ) :
69cdf0e10cSrcweir 	SwFldPage( pParent, SW_RES( TP_FLD_FUNC ), rCoreSet ),
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	aTypeFT		(this, SW_RES(FT_FUNCTYPE)),
72cdf0e10cSrcweir 	aTypeLB		(this, SW_RES(LB_FUNCTYPE)),
73cdf0e10cSrcweir 	aSelectionFT(this, SW_RES(FT_FUNCSELECTION)),
74cdf0e10cSrcweir 	aSelectionLB(this, SW_RES(LB_FUNCSELECTION)),
75cdf0e10cSrcweir 	aFormatFT	(this, SW_RES(FT_FUNCFORMAT)),
76cdf0e10cSrcweir 	aFormatLB	(this, SW_RES(LB_FUNCFORMAT)),
77cdf0e10cSrcweir 	aNameFT		(this, SW_RES(FT_FUNCNAME)),
78cdf0e10cSrcweir 	aNameED		(this, SW_RES(ED_FUNCNAME)),
79cdf0e10cSrcweir 	aValueFT	(this, SW_RES(FT_FUNCVALUE)),
80cdf0e10cSrcweir 	aValueED	(this, SW_RES(ED_FUNCVALUE)),
81cdf0e10cSrcweir 	aCond1FT	(this, SW_RES(FT_FUNCCOND1)),
82cdf0e10cSrcweir 	aCond1ED	(this, SW_RES(ED_FUNCCOND1)),
83cdf0e10cSrcweir 	aCond2FT	(this, SW_RES(FT_FUNCCOND2)),
84cdf0e10cSrcweir 	aCond2ED	(this, SW_RES(ED_FUNCCOND2)),
85cdf0e10cSrcweir     aMacroBT    (this, SW_RES(BT_FUNCMACRO)),
86cdf0e10cSrcweir     aListItemFT(    this, SW_RES( FT_LISTITEM    )),
87cdf0e10cSrcweir     aListItemED(    this, SW_RES( ED_LISTITEM    )),
88cdf0e10cSrcweir     aListAddPB(     this, SW_RES( PB_LISTADD     )),
89cdf0e10cSrcweir     aListItemsFT(   this, SW_RES( FT_LISTITEMS   )),
90cdf0e10cSrcweir     aListItemsLB(   this, SW_RES( LB_LISTITEMS   )),
91cdf0e10cSrcweir     aListRemovePB(  this, SW_RES( PB_LISTREMOVE  )),
92cdf0e10cSrcweir     aListUpPB(      this, SW_RES( PB_LISTUP      )),
93cdf0e10cSrcweir     aListDownPB(    this, SW_RES( PB_LISTDOWN    )),
94cdf0e10cSrcweir     aListNameFT(    this, SW_RES( FT_LISTNAME    )),
95cdf0e10cSrcweir     aListNameED(    this, SW_RES( ED_LISTNAME    )),
96cdf0e10cSrcweir     bDropDownLBChanged(false)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	FreeResource();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	aNameED.SetPosPixel(Point(aNameED.GetPosPixel().X(), aFormatLB.GetPosPixel().Y()));
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	aNameED.SetModifyHdl(LINK(this, SwFldFuncPage, ModifyHdl));
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	sOldValueFT = aValueFT.GetText();
105cdf0e10cSrcweir 	sOldNameFT = aNameFT.GetText();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	aCond1ED.ShowBrackets(sal_False);
108cdf0e10cSrcweir 	aCond2ED.ShowBrackets(sal_False);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //	SwWrtShell* pSh = (SwWrtShell*)ViewShell::GetCurrShell();
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir /*--------------------------------------------------------------------
114cdf0e10cSrcweir 	Beschreibung:
115cdf0e10cSrcweir  --------------------------------------------------------------------*/
116cdf0e10cSrcweir 
~SwFldFuncPage()117cdf0e10cSrcweir SwFldFuncPage::~SwFldFuncPage()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir /*--------------------------------------------------------------------
122cdf0e10cSrcweir 	Beschreibung:
123cdf0e10cSrcweir  --------------------------------------------------------------------*/
124cdf0e10cSrcweir 
Reset(const SfxItemSet &)125cdf0e10cSrcweir void SwFldFuncPage::Reset(const SfxItemSet& )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	SavePos(&aTypeLB);
128cdf0e10cSrcweir 	Init();	// Allgemeine initialisierung
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	aTypeLB.SetUpdateMode(sal_False);
131cdf0e10cSrcweir 	aTypeLB.Clear();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	sal_uInt16 nPos, nTypeId;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	if (!IsFldEdit())
136cdf0e10cSrcweir 	{
137cdf0e10cSrcweir 		// TypeListBox initialisieren
138cdf0e10cSrcweir 		const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 		// Typ-Listbox fuellen
141cdf0e10cSrcweir 		for(short i = rRg.nStart; i < rRg.nEnd; ++i)
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 			nTypeId = GetFldMgr().GetTypeId(i);
144cdf0e10cSrcweir 			nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
145cdf0e10cSrcweir             aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
146cdf0e10cSrcweir 		}
147cdf0e10cSrcweir 	}
148cdf0e10cSrcweir 	else
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		nTypeId = GetCurField()->GetTypeId();
151cdf0e10cSrcweir 		nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
152cdf0e10cSrcweir         aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		if (nTypeId == TYP_MACROFLD)
155cdf0e10cSrcweir 		{
156cdf0e10cSrcweir 			String sName(GetCurField()->GetPar1());
157cdf0e10cSrcweir 			GetFldMgr().SetMacroPath(sName);
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 	}
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	// alte Pos selektieren
162cdf0e10cSrcweir 	RestorePos(&aTypeLB);
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	aTypeLB.SetDoubleClickHdl		(LINK(this, SwFldFuncPage, InsertHdl));
165cdf0e10cSrcweir 	aTypeLB.SetSelectHdl			(LINK(this, SwFldFuncPage, TypeHdl));
166cdf0e10cSrcweir 	aSelectionLB.SetSelectHdl		(LINK(this, SwFldFuncPage, SelectHdl));
167cdf0e10cSrcweir 	aSelectionLB.SetDoubleClickHdl	(LINK(this, SwFldFuncPage, InsertMacroHdl));
168cdf0e10cSrcweir 	aFormatLB.SetDoubleClickHdl		(LINK(this, SwFldFuncPage, InsertHdl));
169cdf0e10cSrcweir 	aMacroBT.SetClickHdl			(LINK(this, SwFldFuncPage, MacroHdl));
170cdf0e10cSrcweir     Link aListModifyLk( LINK(this, SwFldFuncPage, ListModifyHdl));
171cdf0e10cSrcweir     aListAddPB.SetClickHdl(aListModifyLk);
172cdf0e10cSrcweir     aListRemovePB.SetClickHdl(aListModifyLk);
173cdf0e10cSrcweir     aListUpPB.SetClickHdl(aListModifyLk);
174cdf0e10cSrcweir     aListDownPB.SetClickHdl(aListModifyLk);
175cdf0e10cSrcweir     aListItemED.SetReturnActionLink(aListModifyLk);
176cdf0e10cSrcweir     Link aListEnableLk = LINK(this, SwFldFuncPage, ListEnableHdl);
177cdf0e10cSrcweir     aListItemED.SetModifyHdl(aListEnableLk);
178cdf0e10cSrcweir     aListItemsLB.SetSelectHdl(aListEnableLk);
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	if( !IsRefresh() )
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir 		String sUserData = GetUserData();
183cdf0e10cSrcweir 		if(sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
184cdf0e10cSrcweir 		{
185cdf0e10cSrcweir 			String sVal = sUserData.GetToken(1, ';');
186cdf0e10cSrcweir             sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.ToInt32());
187cdf0e10cSrcweir 			if(nVal != USHRT_MAX)
188cdf0e10cSrcweir 			{
189cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++)
190cdf0e10cSrcweir 					if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
191cdf0e10cSrcweir 					{
192cdf0e10cSrcweir 						aTypeLB.SelectEntryPos(i);
193cdf0e10cSrcweir 						break;
194cdf0e10cSrcweir 					}
195cdf0e10cSrcweir 			}
196cdf0e10cSrcweir 		}
197cdf0e10cSrcweir 	}
198cdf0e10cSrcweir 	TypeHdl(0);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	aTypeLB.SetUpdateMode(sal_True);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	if (IsFldEdit())
203cdf0e10cSrcweir 	{
204cdf0e10cSrcweir 		aNameED.SaveValue();
205cdf0e10cSrcweir 		aValueED.SaveValue();
206cdf0e10cSrcweir 		aCond1ED.SaveValue();
207cdf0e10cSrcweir 		aCond2ED.SaveValue();
208cdf0e10cSrcweir 		nOldFormat = GetCurField()->GetFormat();
209cdf0e10cSrcweir 	}
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir /*--------------------------------------------------------------------
213cdf0e10cSrcweir 	Beschreibung:
214cdf0e10cSrcweir  --------------------------------------------------------------------*/
215cdf0e10cSrcweir 
IMPL_LINK(SwFldFuncPage,TypeHdl,ListBox *,EMPTYARG)216cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, TypeHdl, ListBox *, EMPTYARG )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	// Alte ListBoxPos sichern
219cdf0e10cSrcweir 	const sal_uInt16 nOld = GetTypeSel();
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	// Aktuelle ListBoxPos
222cdf0e10cSrcweir 	SetTypeSel(aTypeLB.GetSelectEntryPos());
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
225cdf0e10cSrcweir 	{
226cdf0e10cSrcweir 		SetTypeSel(0);
227cdf0e10cSrcweir 		aTypeLB.SelectEntryPos(0);
228cdf0e10cSrcweir 	}
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	if (nOld != GetTypeSel())
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir 		sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 		// Auswahl-Listbox fuellen
235cdf0e10cSrcweir 		UpdateSubType();
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 		// Format-Listbox fuellen
238cdf0e10cSrcweir 		aFormatLB.Clear();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 		sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode());
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < nSize; i++)
243cdf0e10cSrcweir 		{
244cdf0e10cSrcweir 			sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
245cdf0e10cSrcweir             aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, i )) );
246cdf0e10cSrcweir 		}
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 		if (nSize)
249cdf0e10cSrcweir 		{
250cdf0e10cSrcweir 			if (IsFldEdit() && nTypeId == TYP_JUMPEDITFLD)
251cdf0e10cSrcweir 				aFormatLB.SelectEntry(SW_RESSTR(FMT_MARK_BEGIN + (sal_uInt16)GetCurField()->GetFormat()));
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 			if (!aFormatLB.GetSelectEntryCount())
254cdf0e10cSrcweir 				aFormatLB.SelectEntryPos(0);
255cdf0e10cSrcweir 		}
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 		sal_Bool bValue = sal_False, bName = sal_False, bMacro = sal_False, bInsert = sal_True;
258cdf0e10cSrcweir 		sal_Bool bShowSelection = sal_False;
259cdf0e10cSrcweir 		sal_Bool bFormat = nSize != 0;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 		// fuer Conditional Text zwei Controls
262cdf0e10cSrcweir         sal_Bool bDropDown = TYP_DROPDOWN == nTypeId;
263cdf0e10cSrcweir         sal_Bool bCondTxtFld = TYP_CONDTXTFLD == nTypeId;
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         aCond1FT.Show(!bDropDown && bCondTxtFld);
266cdf0e10cSrcweir         aCond1ED.Show(!bDropDown && bCondTxtFld);
267cdf0e10cSrcweir         aCond2FT.Show(!bDropDown && bCondTxtFld);
268cdf0e10cSrcweir         aCond2ED.Show(!bDropDown && bCondTxtFld);
269cdf0e10cSrcweir         aValueFT.Show(!bDropDown && !bCondTxtFld);
270cdf0e10cSrcweir         aValueED.Show(!bDropDown && !bCondTxtFld);
271cdf0e10cSrcweir         aMacroBT.Show(!bDropDown);
272cdf0e10cSrcweir 		aNameED.Show(!bDropDown);
273cdf0e10cSrcweir         aNameFT.Show(!bDropDown);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir         aListItemFT.Show(bDropDown);
276cdf0e10cSrcweir         aListItemED.Show(bDropDown);
277cdf0e10cSrcweir         aListAddPB.Show(bDropDown);
278cdf0e10cSrcweir         aListItemsFT.Show(bDropDown);
279cdf0e10cSrcweir         aListItemsLB.Show(bDropDown);
280cdf0e10cSrcweir         aListRemovePB.Show(bDropDown);
281cdf0e10cSrcweir         aListUpPB.Show(bDropDown);
282cdf0e10cSrcweir         aListDownPB.Show(bDropDown);
283cdf0e10cSrcweir         aListNameFT.Show(bDropDown);
284cdf0e10cSrcweir         aListNameED.Show(bDropDown);
285cdf0e10cSrcweir 
286cdf0e10cSrcweir         aNameED.SetDropEnable(sal_False);
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 		if (IsFldEdit())
289cdf0e10cSrcweir 		{
290cdf0e10cSrcweir 			if(bDropDown)
291cdf0e10cSrcweir 			{
292cdf0e10cSrcweir 				const SwDropDownField* pDrop = (const SwDropDownField*)GetCurField();
293cdf0e10cSrcweir                 uno::Sequence<OUString> aItems = pDrop->GetItemSequence();
294cdf0e10cSrcweir 				const OUString* pArray = aItems.getConstArray();
295cdf0e10cSrcweir                 aListItemsLB.Clear();
296cdf0e10cSrcweir                 for(sal_Int32 i = 0; i < aItems.getLength(); i++)
297cdf0e10cSrcweir                     aListItemsLB.InsertEntry(pArray[i]);
298cdf0e10cSrcweir                 aListItemsLB.SelectEntry(pDrop->GetSelectedItem());
299cdf0e10cSrcweir                 aListNameED.SetText(pDrop->GetPar2());
300cdf0e10cSrcweir 				aListNameED.SaveValue();
301cdf0e10cSrcweir                 bDropDownLBChanged = false;
302cdf0e10cSrcweir 			}
303cdf0e10cSrcweir 			else
304cdf0e10cSrcweir 			{
305cdf0e10cSrcweir 				aNameED.SetText(GetCurField()->GetPar1());
306cdf0e10cSrcweir 				aValueED.SetText(GetCurField()->GetPar2());
307cdf0e10cSrcweir 			}
308cdf0e10cSrcweir 		}
309cdf0e10cSrcweir 		else
310cdf0e10cSrcweir 		{
311cdf0e10cSrcweir 			aNameED.SetText(aEmptyStr);
312cdf0e10cSrcweir 			aValueED.SetText(aEmptyStr);
313cdf0e10cSrcweir 		}
314cdf0e10cSrcweir 		if(bDropDown)
315cdf0e10cSrcweir 			ListEnableHdl(0);
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 		if( aNameFT.GetText() != sOldNameFT )
318cdf0e10cSrcweir 			aNameFT.SetText(sOldNameFT);
319cdf0e10cSrcweir 		if (aValueFT.GetText() != sOldValueFT)
320cdf0e10cSrcweir 			aValueFT.SetText(sOldValueFT);
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 		switch (nTypeId)
323cdf0e10cSrcweir 		{
324cdf0e10cSrcweir 			case TYP_MACROFLD:
325cdf0e10cSrcweir 				bMacro = sal_True;
326cdf0e10cSrcweir 				if (GetFldMgr().GetMacroPath().Len())
327cdf0e10cSrcweir 					bValue = sal_True;
328cdf0e10cSrcweir 				else
329cdf0e10cSrcweir 					bInsert = sal_False;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 				aNameFT.SetText(SW_RESSTR(STR_MACNAME));
332cdf0e10cSrcweir 				aValueFT.SetText(SW_RESSTR(STR_PROMPT));
333cdf0e10cSrcweir 				aNameED.SetText(GetFldMgr().GetMacroName());
334cdf0e10cSrcweir 				aNameED.SetAccessibleName(aNameFT.GetText());
335cdf0e10cSrcweir 				aValueED.SetAccessibleName(aValueFT.GetText());
336cdf0e10cSrcweir 				break;
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 			case TYP_HIDDENPARAFLD:
339cdf0e10cSrcweir 				aNameFT.SetText(SW_RESSTR(STR_COND));
340cdf0e10cSrcweir 				aNameED.SetDropEnable(sal_True);
341cdf0e10cSrcweir 				bName = sal_True;
342cdf0e10cSrcweir 				aNameED.SetAccessibleName(aNameFT.GetText());
343cdf0e10cSrcweir 				aValueED.SetAccessibleName(aValueFT.GetText());
344cdf0e10cSrcweir 				break;
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 			case TYP_HIDDENTXTFLD:
347cdf0e10cSrcweir             {
348cdf0e10cSrcweir 				aNameFT.SetText(SW_RESSTR(STR_COND));
349cdf0e10cSrcweir 				aNameED.SetDropEnable(sal_True);
350cdf0e10cSrcweir 				aValueFT.SetText(SW_RESSTR(STR_INSTEXT));
351cdf0e10cSrcweir                 SwWrtShell* pSh = GetActiveWrtShell();
352cdf0e10cSrcweir                 if (!IsFldEdit() && pSh )
353cdf0e10cSrcweir                     aValueED.SetText(pSh->GetSelTxt());
354cdf0e10cSrcweir 				bName = bValue = sal_True;
355cdf0e10cSrcweir 				aNameED.SetAccessibleName(aNameFT.GetText());
356cdf0e10cSrcweir 				aValueED.SetAccessibleName(aValueFT.GetText());
357cdf0e10cSrcweir             }
358cdf0e10cSrcweir             break;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 			case TYP_CONDTXTFLD:
361cdf0e10cSrcweir 				aNameFT.SetText(SW_RESSTR(STR_COND));
362cdf0e10cSrcweir 				aNameED.SetDropEnable(sal_True);
363cdf0e10cSrcweir 				if (IsFldEdit())
364cdf0e10cSrcweir 				{
365cdf0e10cSrcweir 					aCond1ED.SetText(GetCurField()->GetPar2().GetToken(0, '|'));
366cdf0e10cSrcweir 					aCond2ED.SetText(GetCurField()->GetPar2().GetToken(1, '|'));
367cdf0e10cSrcweir 				}
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 				bName = bValue = sal_True;
370cdf0e10cSrcweir 				aNameED.SetAccessibleName(aNameFT.GetText());
371cdf0e10cSrcweir 				aValueED.SetAccessibleName(aValueFT.GetText());
372cdf0e10cSrcweir 				break;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 			case TYP_JUMPEDITFLD:
375cdf0e10cSrcweir 				aNameFT.SetText(SW_RESSTR(STR_JUMPEDITFLD));
376cdf0e10cSrcweir 				aValueFT.SetText(SW_RESSTR(STR_PROMPT));
377cdf0e10cSrcweir 				bName = bValue = sal_True;
378cdf0e10cSrcweir 				aNameED.SetAccessibleName(aNameFT.GetText());
379cdf0e10cSrcweir 				aValueED.SetAccessibleName(aValueFT.GetText());
380cdf0e10cSrcweir 				break;
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 			case TYP_INPUTFLD:
383cdf0e10cSrcweir 				aValueFT.SetText(SW_RESSTR(STR_PROMPT));
384cdf0e10cSrcweir 				bValue = sal_True;
385cdf0e10cSrcweir 				// bShowSelection = TRUE;
386cdf0e10cSrcweir 				aNameED.SetAccessibleName(aNameFT.GetText());
387cdf0e10cSrcweir 				aValueED.SetAccessibleName(aValueFT.GetText());
388cdf0e10cSrcweir 				break;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 			case TYP_COMBINED_CHARS:
391cdf0e10cSrcweir 				{
392cdf0e10cSrcweir 					aNameFT.SetText(SW_RESSTR(STR_COMBCHRS_FT));
393cdf0e10cSrcweir 					aNameED.SetDropEnable(sal_True);
394cdf0e10cSrcweir 					bName = sal_True;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 					const sal_uInt16 nLen = aNameED.GetText().Len();
397cdf0e10cSrcweir 					if( !nLen || nLen > MAX_COMBINED_CHARACTERS )
398cdf0e10cSrcweir 						bInsert = sal_False;
399cdf0e10cSrcweir 					aNameED.SetAccessibleName(aNameFT.GetText());
400cdf0e10cSrcweir 					aValueED.SetAccessibleName(aValueFT.GetText());
401cdf0e10cSrcweir 				}
402cdf0e10cSrcweir 				break;
403cdf0e10cSrcweir             case TYP_DROPDOWN :
404cdf0e10cSrcweir             break;
405cdf0e10cSrcweir 			default:
406cdf0e10cSrcweir 				break;
407cdf0e10cSrcweir 		}
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 		if (bShowSelection)
410cdf0e10cSrcweir 		{
411cdf0e10cSrcweir 			aSelectionLB.Show();
412cdf0e10cSrcweir 			aSelectionFT.Show();
413cdf0e10cSrcweir 			aFormatLB.Hide();
414cdf0e10cSrcweir 			aFormatFT.Hide();
415cdf0e10cSrcweir 		}
416cdf0e10cSrcweir 		else
417cdf0e10cSrcweir 		{
418cdf0e10cSrcweir 			aFormatLB.Show();
419cdf0e10cSrcweir 			aFormatFT.Show();
420cdf0e10cSrcweir 			aSelectionLB.Hide();
421cdf0e10cSrcweir 			aSelectionFT.Hide();
422cdf0e10cSrcweir 		}
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 		aFormatLB.Enable(bFormat);
425cdf0e10cSrcweir 		aFormatFT.Enable(bFormat);
426cdf0e10cSrcweir 		aNameFT.Enable(bName);
427cdf0e10cSrcweir 		aNameED.Enable(bName);
428cdf0e10cSrcweir 		aValueFT.Enable(bValue);
429cdf0e10cSrcweir 		aValueED.Enable(bValue);
430cdf0e10cSrcweir 		aMacroBT.Enable(bMacro);
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 		EnableInsert( bInsert );
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	return 0;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir /*--------------------------------------------------------------------
439cdf0e10cSrcweir 	Beschreibung:
440cdf0e10cSrcweir  --------------------------------------------------------------------*/
441cdf0e10cSrcweir 
IMPL_LINK(SwFldFuncPage,SelectHdl,ListBox *,EMPTYARG)442cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, SelectHdl, ListBox *, EMPTYARG )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 	if( TYP_MACROFLD == nTypeId )
447cdf0e10cSrcweir 		aNameED.SetText( aSelectionLB.GetSelectEntry() );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 	return 0;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
452cdf0e10cSrcweir /*--------------------------------------------------------------------
453cdf0e10cSrcweir 	Beschreibung:
454cdf0e10cSrcweir  --------------------------------------------------------------------*/
455cdf0e10cSrcweir 
IMPL_LINK(SwFldFuncPage,InsertMacroHdl,ListBox *,EMPTYARG)456cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, InsertMacroHdl, ListBox *, EMPTYARG )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir 	SelectHdl();
459cdf0e10cSrcweir 	InsertHdl();
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 	return 0;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir /* -----------------16.06.2003 16:24-----------------
464cdf0e10cSrcweir 
465cdf0e10cSrcweir  --------------------------------------------------*/
IMPL_LINK(SwFldFuncPage,ListModifyHdl,Control *,pControl)466cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, ListModifyHdl, Control*, pControl)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir     aListItemsLB.SetUpdateMode(sal_False);
469cdf0e10cSrcweir     if(pControl == &aListAddPB ||
470cdf0e10cSrcweir             (pControl == &aListItemED && aListAddPB.IsEnabled()))
471cdf0e10cSrcweir     {
472cdf0e10cSrcweir         String sEntry(aListItemED.GetText());
473cdf0e10cSrcweir         aListItemsLB.InsertEntry(sEntry);
474cdf0e10cSrcweir         aListItemsLB.SelectEntry(sEntry);
475cdf0e10cSrcweir     }
476cdf0e10cSrcweir     else if(aListItemsLB.GetSelectEntryCount())
477cdf0e10cSrcweir     {
478cdf0e10cSrcweir         sal_uInt16 nSelPos = aListItemsLB.GetSelectEntryPos();
479cdf0e10cSrcweir         if(pControl == &aListRemovePB)
480cdf0e10cSrcweir         {
481cdf0e10cSrcweir             aListItemsLB.RemoveEntry(nSelPos);
482cdf0e10cSrcweir             aListItemsLB.SelectEntryPos(nSelPos ? nSelPos - 1 : 0);
483cdf0e10cSrcweir         }
484cdf0e10cSrcweir         else if(pControl == &aListUpPB)
485cdf0e10cSrcweir         {
486cdf0e10cSrcweir             if(nSelPos)
487cdf0e10cSrcweir             {
488cdf0e10cSrcweir                 String sEntry = aListItemsLB.GetSelectEntry();
489cdf0e10cSrcweir                 aListItemsLB.RemoveEntry(nSelPos);
490cdf0e10cSrcweir                 nSelPos--;
491cdf0e10cSrcweir                 aListItemsLB.InsertEntry(sEntry, nSelPos);
492cdf0e10cSrcweir                 aListItemsLB.SelectEntryPos(nSelPos);
493cdf0e10cSrcweir             }
494cdf0e10cSrcweir         }
495cdf0e10cSrcweir         else if(pControl == &aListDownPB)
496cdf0e10cSrcweir         {
497cdf0e10cSrcweir             if(nSelPos < aListItemsLB.GetEntryCount() - 1)
498cdf0e10cSrcweir             {
499cdf0e10cSrcweir                 String sEntry = aListItemsLB.GetSelectEntry();
500cdf0e10cSrcweir                 aListItemsLB.RemoveEntry(nSelPos);
501cdf0e10cSrcweir                 nSelPos++;
502cdf0e10cSrcweir                 aListItemsLB.InsertEntry(sEntry, nSelPos);
503cdf0e10cSrcweir                 aListItemsLB.SelectEntryPos(nSelPos);
504cdf0e10cSrcweir             }
505cdf0e10cSrcweir         }
506cdf0e10cSrcweir     }
507cdf0e10cSrcweir     bDropDownLBChanged = true;
508cdf0e10cSrcweir     aListItemsLB.SetUpdateMode(sal_True);
509cdf0e10cSrcweir     ListEnableHdl(0);
510cdf0e10cSrcweir     return 0;
511cdf0e10cSrcweir }
512cdf0e10cSrcweir /* -----------------17.06.2003 08:36-----------------
513cdf0e10cSrcweir 
514cdf0e10cSrcweir  --------------------------------------------------*/
IMPL_LINK(SwFldFuncPage,ListEnableHdl,void *,EMPTYARG)515cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, ListEnableHdl, void*, EMPTYARG)
516cdf0e10cSrcweir {
517cdf0e10cSrcweir     //enable "Add" button when text is in the Edit that's not already member of the box
518cdf0e10cSrcweir     aListAddPB.Enable(aListItemED.GetText().Len() &&
519cdf0e10cSrcweir                 LISTBOX_ENTRY_NOTFOUND == aListItemsLB.GetEntryPos(aListItemED.GetText()));
520cdf0e10cSrcweir     sal_Bool bEnableButtons = aListItemsLB.GetSelectEntryCount() > 0;
521cdf0e10cSrcweir     aListRemovePB.Enable(bEnableButtons);
522cdf0e10cSrcweir     aListUpPB.Enable(bEnableButtons && (aListItemsLB.GetSelectEntryPos() > 0));
523cdf0e10cSrcweir     aListDownPB.Enable(bEnableButtons &&
524cdf0e10cSrcweir                 (aListItemsLB.GetSelectEntryPos() < (aListItemsLB.GetEntryCount() - 1)));
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     return 0;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir /*--------------------------------------------------------------------
530cdf0e10cSrcweir 	 Beschreibung: Typen in der SelectionBox erneuern
531cdf0e10cSrcweir  --------------------------------------------------------------------*/
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 
UpdateSubType()534cdf0e10cSrcweir void SwFldFuncPage::UpdateSubType()
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	// Auswahl-Listbox fuellen
539cdf0e10cSrcweir 	aSelectionLB.SetUpdateMode(sal_False);
540cdf0e10cSrcweir 	aSelectionLB.Clear();
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     SvStringsDtor aLst;
543cdf0e10cSrcweir     GetFldMgr().GetSubTypes(nTypeId, aLst);
544cdf0e10cSrcweir     sal_uInt16 nCount = aLst.Count();
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 	for (sal_uInt16 i = 0; i < nCount; ++i)
547cdf0e10cSrcweir 	{
548cdf0e10cSrcweir         sal_uInt16 nPos = aSelectionLB.InsertEntry(*aLst[i]);
549cdf0e10cSrcweir         aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
550cdf0e10cSrcweir 	}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	sal_Bool bEnable = nCount != 0;
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 	aSelectionLB.Enable( bEnable );
555cdf0e10cSrcweir 	aSelectionFT.Enable( bEnable );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 	if (bEnable)
558cdf0e10cSrcweir 	{
559cdf0e10cSrcweir 			aSelectionLB.SelectEntryPos(0);
560cdf0e10cSrcweir 	}
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 	if (nTypeId == TYP_MACROFLD)
563cdf0e10cSrcweir 	{
564cdf0e10cSrcweir 		sal_Bool bHasMacro = GetFldMgr().GetMacroPath().Len() != 0;
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 		if (bHasMacro)
567cdf0e10cSrcweir 		{
568cdf0e10cSrcweir 			aNameED.SetText(GetFldMgr().GetMacroName());
569cdf0e10cSrcweir 			aValueFT.Enable();
570cdf0e10cSrcweir 			aValueED.Enable();
571cdf0e10cSrcweir 		}
572cdf0e10cSrcweir 		EnableInsert(bHasMacro);
573cdf0e10cSrcweir 	}
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	aSelectionLB.SetUpdateMode(sal_True);
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir /*--------------------------------------------------------------------
579cdf0e10cSrcweir 	Beschreibung: MacroBrowser aufrufen, Listbox mit Macros fuellen
580cdf0e10cSrcweir  --------------------------------------------------------------------*/
581cdf0e10cSrcweir 
IMPL_LINK(SwFldFuncPage,MacroHdl,Button *,pBtn)582cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, MacroHdl, Button *, pBtn )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir 	Window* pDefModalDlgParent = Application::GetDefDialogParent();
585cdf0e10cSrcweir 	Application::SetDefDialogParent( pBtn );
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	String sMacro(TurnMacroString(aNameED.GetText()));
588cdf0e10cSrcweir 	while (sMacro.SearchAndReplace('.', ';') != STRING_NOTFOUND) ;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 	if (GetFldMgr().ChooseMacro(sMacro))
591cdf0e10cSrcweir 		UpdateSubType();
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	Application::SetDefDialogParent( pDefModalDlgParent );
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 	return 0;
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir /*--------------------------------------------------------------------
599cdf0e10cSrcweir 	Beschreibung:
600cdf0e10cSrcweir  --------------------------------------------------------------------*/
601cdf0e10cSrcweir 
FillItemSet(SfxItemSet &)602cdf0e10cSrcweir sal_Bool SwFldFuncPage::FillItemSet(SfxItemSet& )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	sal_uInt16 nSubType = 0;
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 	sal_uLong nFormat = aFormatLB.GetSelectEntryPos();
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 	if(nFormat == LISTBOX_ENTRY_NOTFOUND)
611cdf0e10cSrcweir 		nFormat = 0;
612cdf0e10cSrcweir 	else
613cdf0e10cSrcweir 		nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat);
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 	String aVal(aValueED.GetText());
616cdf0e10cSrcweir 	String aName(aNameED.GetText());
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 	switch(nTypeId)
619cdf0e10cSrcweir 	{
620cdf0e10cSrcweir 		case TYP_INPUTFLD:
621cdf0e10cSrcweir 			nSubType = INP_TXT;
622cdf0e10cSrcweir             // to prevent removal of CR/LF restore old content
623cdf0e10cSrcweir             if(!aNameED.IsModified() && IsFldEdit())
624cdf0e10cSrcweir                 aName = GetCurField()->GetPar1();
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 			break;
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 		case TYP_MACROFLD:
629cdf0e10cSrcweir 			// use the full script URL, not the name in the Edit control
630cdf0e10cSrcweir 			aName = GetFldMgr().GetMacroPath();
631cdf0e10cSrcweir 			break;
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 		case TYP_CONDTXTFLD:
634cdf0e10cSrcweir 			aVal = aCond1ED.GetText();
635cdf0e10cSrcweir 			aVal += '|';
636cdf0e10cSrcweir 			aVal += aCond2ED.GetText();
637cdf0e10cSrcweir 			break;
638cdf0e10cSrcweir         case TYP_DROPDOWN :
639cdf0e10cSrcweir         {
640cdf0e10cSrcweir             aName = aListNameED.GetText();
641cdf0e10cSrcweir             for(sal_uInt16 i = 0; i < aListItemsLB.GetEntryCount(); i++)
642cdf0e10cSrcweir             {
643cdf0e10cSrcweir                 if(i)
644cdf0e10cSrcweir                     aVal += DB_DELIM;
645cdf0e10cSrcweir                 aVal += aListItemsLB.GetEntry(i);
646cdf0e10cSrcweir             }
647cdf0e10cSrcweir         }
648cdf0e10cSrcweir         break;
649cdf0e10cSrcweir 		default:
650cdf0e10cSrcweir 			break;
651cdf0e10cSrcweir 	}
652cdf0e10cSrcweir 
653cdf0e10cSrcweir 	if (!IsFldEdit() ||
654cdf0e10cSrcweir 		aNameED.GetSavedValue() != aNameED.GetText() ||
655cdf0e10cSrcweir 		aValueED.GetSavedValue() != aValueED.GetText() ||
656cdf0e10cSrcweir 		aCond1ED.GetSavedValue() != aCond1ED.GetText() ||
657cdf0e10cSrcweir 		aCond2ED.GetSavedValue() != aCond2ED.GetText() ||
658cdf0e10cSrcweir 		aListNameED.GetSavedValue() != aListNameED.GetText() ||
659cdf0e10cSrcweir         bDropDownLBChanged ||
660cdf0e10cSrcweir 		nOldFormat != nFormat)
661cdf0e10cSrcweir 	{
662cdf0e10cSrcweir 		InsertFld( nTypeId, nSubType, aName, aVal, nFormat );
663cdf0e10cSrcweir 	}
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 	ModifyHdl();	// Insert ggf enablen/disablen
666cdf0e10cSrcweir 
667cdf0e10cSrcweir 	return sal_False;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
670cdf0e10cSrcweir /*--------------------------------------------------------------------
671cdf0e10cSrcweir 	Beschreibung:
672cdf0e10cSrcweir  --------------------------------------------------------------------*/
673cdf0e10cSrcweir 
TurnMacroString(const String & rMacro)674cdf0e10cSrcweir String SwFldFuncPage::TurnMacroString(const String &rMacro)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir 	if (rMacro.Len())
677cdf0e10cSrcweir 	{
678cdf0e10cSrcweir 		// Inhalt von aName umdrehen
679cdf0e10cSrcweir 		String sTmp, sBuf;
680cdf0e10cSrcweir 		sal_uInt16 nPos = 0;
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < 4 && nPos != STRING_NOTFOUND; i++)
683cdf0e10cSrcweir 		{
684cdf0e10cSrcweir 			if (i == 3)
685cdf0e10cSrcweir 				sTmp = rMacro.Copy(nPos);
686cdf0e10cSrcweir 			else
687cdf0e10cSrcweir 				sTmp = rMacro.GetToken(0, '.', nPos);
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 			if( sBuf.Len() )
690cdf0e10cSrcweir 				sTmp += '.';
691cdf0e10cSrcweir 			sBuf.Insert( sTmp, 0 );
692cdf0e10cSrcweir 		}
693cdf0e10cSrcweir 		return sBuf;
694cdf0e10cSrcweir 	}
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 	return rMacro;
697cdf0e10cSrcweir }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir /*--------------------------------------------------------------------
700cdf0e10cSrcweir 	Beschreibung:
701cdf0e10cSrcweir  --------------------------------------------------------------------*/
702cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rAttrSet)703cdf0e10cSrcweir SfxTabPage* SwFldFuncPage::Create( 	Window* pParent,
704cdf0e10cSrcweir 						const SfxItemSet& rAttrSet )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir 	return ( new SwFldFuncPage( pParent, rAttrSet ) );
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir /*--------------------------------------------------------------------
710cdf0e10cSrcweir 	Beschreibung:
711cdf0e10cSrcweir  --------------------------------------------------------------------*/
712cdf0e10cSrcweir 
GetGroup()713cdf0e10cSrcweir sal_uInt16 SwFldFuncPage::GetGroup()
714cdf0e10cSrcweir {
715cdf0e10cSrcweir 	return GRP_FKT;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir /* -----------------12.01.99 10:09-------------------
719cdf0e10cSrcweir  *
720cdf0e10cSrcweir  * --------------------------------------------------*/
FillUserData()721cdf0e10cSrcweir void	SwFldFuncPage::FillUserData()
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	String sData( String::CreateFromAscii(
724cdf0e10cSrcweir 						RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION )));
725cdf0e10cSrcweir 	sData += ';';
726cdf0e10cSrcweir 	sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
727cdf0e10cSrcweir 	if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
728cdf0e10cSrcweir 		nTypeSel = USHRT_MAX;
729cdf0e10cSrcweir 	else
730cdf0e10cSrcweir         nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel )));
731cdf0e10cSrcweir 	sData += String::CreateFromInt32( nTypeSel );
732cdf0e10cSrcweir 	SetUserData(sData);
733cdf0e10cSrcweir }
734cdf0e10cSrcweir 
IMPL_LINK(SwFldFuncPage,ModifyHdl,Edit *,EMPTYARG)735cdf0e10cSrcweir IMPL_LINK( SwFldFuncPage, ModifyHdl, Edit *, EMPTYARG )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir 	String aName(aNameED.GetText());
738cdf0e10cSrcweir 	const sal_uInt16 nLen = aName.Len();
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 	sal_Bool bEnable = sal_True;
741cdf0e10cSrcweir 	sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
742cdf0e10cSrcweir 
743cdf0e10cSrcweir 	if( TYP_COMBINED_CHARS == nTypeId &&
744cdf0e10cSrcweir 		(!nLen || nLen > MAX_COMBINED_CHARACTERS ))
745cdf0e10cSrcweir 		bEnable = sal_False;
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 	EnableInsert( bEnable );
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 	return 0;
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 
755