update dev300-m58
[ooovba.git] / sw / source / ui / fldui / fldfunc.cxx
blob871049660b256bee7d83c37198cd28104f90c5a6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fldfunc.cxx,v $
10 * $Revision: 1.22.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
35 #endif
38 #include <sfx2/app.hxx>
39 #include <basic/basmgr.hxx>
40 #include <basic/sbmod.hxx>
41 #include <docsh.hxx>
42 #include <swtypes.hxx>
43 #ifndef _GLOBALS_HRC
44 #include <globals.hrc>
45 #endif
46 #include <fldbas.hxx>
47 #include <docufld.hxx>
48 #ifndef _VIEW_HXX
49 #include <view.hxx>
50 #endif
51 #include <wrtsh.hxx>
52 #include <swmodule.hxx>
53 #ifndef _FLDFUNC_HXX
54 #include <fldfunc.hxx>
55 #endif
56 #include <flddropdown.hxx>
57 #ifndef _FLDUI_HRC
58 #include <fldui.hrc>
59 #endif
60 #ifndef _FLDTDLG_HRC
61 #include <fldtdlg.hrc>
62 #endif
64 #define USER_DATA_VERSION_1 "1"
65 #define USER_DATA_VERSION USER_DATA_VERSION_1
67 using namespace ::com::sun::star;
69 using rtl::OUString;
71 /*--------------------------------------------------------------------
72 Beschreibung:
73 --------------------------------------------------------------------*/
75 SwFldFuncPage::SwFldFuncPage(Window* pParent, const SfxItemSet& rCoreSet ) :
76 SwFldPage( pParent, SW_RES( TP_FLD_FUNC ), rCoreSet ),
78 aTypeFT (this, SW_RES(FT_FUNCTYPE)),
79 aTypeLB (this, SW_RES(LB_FUNCTYPE)),
80 aSelectionFT(this, SW_RES(FT_FUNCSELECTION)),
81 aSelectionLB(this, SW_RES(LB_FUNCSELECTION)),
82 aFormatFT (this, SW_RES(FT_FUNCFORMAT)),
83 aFormatLB (this, SW_RES(LB_FUNCFORMAT)),
84 aNameFT (this, SW_RES(FT_FUNCNAME)),
85 aNameED (this, SW_RES(ED_FUNCNAME)),
86 aValueFT (this, SW_RES(FT_FUNCVALUE)),
87 aValueED (this, SW_RES(ED_FUNCVALUE)),
88 aCond1FT (this, SW_RES(FT_FUNCCOND1)),
89 aCond1ED (this, SW_RES(ED_FUNCCOND1)),
90 aCond2FT (this, SW_RES(FT_FUNCCOND2)),
91 aCond2ED (this, SW_RES(ED_FUNCCOND2)),
92 aMacroBT (this, SW_RES(BT_FUNCMACRO)),
93 aListItemFT( this, SW_RES( FT_LISTITEM )),
94 aListItemED( this, SW_RES( ED_LISTITEM )),
95 aListAddPB( this, SW_RES( PB_LISTADD )),
96 aListItemsFT( this, SW_RES( FT_LISTITEMS )),
97 aListItemsLB( this, SW_RES( LB_LISTITEMS )),
98 aListRemovePB( this, SW_RES( PB_LISTREMOVE )),
99 aListUpPB( this, SW_RES( PB_LISTUP )),
100 aListDownPB( this, SW_RES( PB_LISTDOWN )),
101 aListNameFT( this, SW_RES( FT_LISTNAME )),
102 aListNameED( this, SW_RES( ED_LISTNAME )),
103 bDropDownLBChanged(false)
105 FreeResource();
107 aNameED.SetPosPixel(Point(aNameED.GetPosPixel().X(), aFormatLB.GetPosPixel().Y()));
109 aNameED.SetModifyHdl(LINK(this, SwFldFuncPage, ModifyHdl));
111 sOldValueFT = aValueFT.GetText();
112 sOldNameFT = aNameFT.GetText();
114 aCond1ED.ShowBrackets(FALSE);
115 aCond2ED.ShowBrackets(FALSE);
117 // SwWrtShell* pSh = (SwWrtShell*)ViewShell::GetCurrShell();
120 /*--------------------------------------------------------------------
121 Beschreibung:
122 --------------------------------------------------------------------*/
124 SwFldFuncPage::~SwFldFuncPage()
128 /*--------------------------------------------------------------------
129 Beschreibung:
130 --------------------------------------------------------------------*/
132 void SwFldFuncPage::Reset(const SfxItemSet& )
134 SavePos(&aTypeLB);
135 Init(); // Allgemeine initialisierung
137 aTypeLB.SetUpdateMode(FALSE);
138 aTypeLB.Clear();
140 USHORT nPos, nTypeId;
142 if (!IsFldEdit())
144 // TypeListBox initialisieren
145 const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
147 // Typ-Listbox fuellen
148 for(short i = rRg.nStart; i < rRg.nEnd; ++i)
150 nTypeId = GetFldMgr().GetTypeId(i);
151 nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
152 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
155 else
157 nTypeId = GetCurField()->GetTypeId();
158 nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
159 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
161 if (nTypeId == TYP_MACROFLD)
163 String sName(GetCurField()->GetPar1());
164 GetFldMgr().SetMacroPath(sName);
168 // alte Pos selektieren
169 RestorePos(&aTypeLB);
171 aTypeLB.SetDoubleClickHdl (LINK(this, SwFldFuncPage, InsertHdl));
172 aTypeLB.SetSelectHdl (LINK(this, SwFldFuncPage, TypeHdl));
173 aSelectionLB.SetSelectHdl (LINK(this, SwFldFuncPage, SelectHdl));
174 aSelectionLB.SetDoubleClickHdl (LINK(this, SwFldFuncPage, InsertMacroHdl));
175 aFormatLB.SetDoubleClickHdl (LINK(this, SwFldFuncPage, InsertHdl));
176 aMacroBT.SetClickHdl (LINK(this, SwFldFuncPage, MacroHdl));
177 Link aListModifyLk( LINK(this, SwFldFuncPage, ListModifyHdl));
178 aListAddPB.SetClickHdl(aListModifyLk);
179 aListRemovePB.SetClickHdl(aListModifyLk);
180 aListUpPB.SetClickHdl(aListModifyLk);
181 aListDownPB.SetClickHdl(aListModifyLk);
182 aListItemED.SetReturnActionLink(aListModifyLk);
183 Link aListEnableLk = LINK(this, SwFldFuncPage, ListEnableHdl);
184 aListItemED.SetModifyHdl(aListEnableLk);
185 aListItemsLB.SetSelectHdl(aListEnableLk);
187 if( !IsRefresh() )
189 String sUserData = GetUserData();
190 if(sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
192 String sVal = sUserData.GetToken(1, ';');
193 USHORT nVal = static_cast< USHORT >(sVal.ToInt32());
194 if(nVal != USHRT_MAX)
196 for(USHORT i = 0; i < aTypeLB.GetEntryCount(); i++)
197 if(nVal == (USHORT)(ULONG)aTypeLB.GetEntryData(i))
199 aTypeLB.SelectEntryPos(i);
200 break;
205 TypeHdl(0);
207 aTypeLB.SetUpdateMode(TRUE);
209 if (IsFldEdit())
211 aNameED.SaveValue();
212 aValueED.SaveValue();
213 aCond1ED.SaveValue();
214 aCond2ED.SaveValue();
215 nOldFormat = GetCurField()->GetFormat();
219 /*--------------------------------------------------------------------
220 Beschreibung:
221 --------------------------------------------------------------------*/
223 IMPL_LINK( SwFldFuncPage, TypeHdl, ListBox *, EMPTYARG )
225 // Alte ListBoxPos sichern
226 const USHORT nOld = GetTypeSel();
228 // Aktuelle ListBoxPos
229 SetTypeSel(aTypeLB.GetSelectEntryPos());
231 if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
233 SetTypeSel(0);
234 aTypeLB.SelectEntryPos(0);
237 if (nOld != GetTypeSel())
239 USHORT nTypeId = (USHORT)(ULONG)aTypeLB.GetEntryData(GetTypeSel());
241 // Auswahl-Listbox fuellen
242 UpdateSubType();
244 // Format-Listbox fuellen
245 aFormatLB.Clear();
247 USHORT nSize = GetFldMgr().GetFormatCount(nTypeId, FALSE, IsFldDlgHtmlMode());
249 for (USHORT i = 0; i < nSize; i++)
251 USHORT nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
252 aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, i )) );
255 if (nSize)
257 if (IsFldEdit() && nTypeId == TYP_JUMPEDITFLD)
258 aFormatLB.SelectEntry(SW_RESSTR(FMT_MARK_BEGIN + (USHORT)GetCurField()->GetFormat()));
260 if (!aFormatLB.GetSelectEntryCount())
261 aFormatLB.SelectEntryPos(0);
264 BOOL bValue = FALSE, bName = FALSE, bMacro = FALSE, bInsert = TRUE;
265 BOOL bShowSelection = FALSE;
266 BOOL bFormat = nSize != 0;
268 // fuer Conditional Text zwei Controls
269 BOOL bDropDown = TYP_DROPDOWN == nTypeId;
270 BOOL bCondTxtFld = TYP_CONDTXTFLD == nTypeId;
272 aCond1FT.Show(!bDropDown && bCondTxtFld);
273 aCond1ED.Show(!bDropDown && bCondTxtFld);
274 aCond2FT.Show(!bDropDown && bCondTxtFld);
275 aCond2ED.Show(!bDropDown && bCondTxtFld);
276 aValueFT.Show(!bDropDown && !bCondTxtFld);
277 aValueED.Show(!bDropDown && !bCondTxtFld);
278 aMacroBT.Show(!bDropDown);
279 aNameED.Show(!bDropDown);
280 aNameFT.Show(!bDropDown);
282 aListItemFT.Show(bDropDown);
283 aListItemED.Show(bDropDown);
284 aListAddPB.Show(bDropDown);
285 aListItemsFT.Show(bDropDown);
286 aListItemsLB.Show(bDropDown);
287 aListRemovePB.Show(bDropDown);
288 aListUpPB.Show(bDropDown);
289 aListDownPB.Show(bDropDown);
290 aListNameFT.Show(bDropDown);
291 aListNameED.Show(bDropDown);
293 aNameED.SetDropEnable(FALSE);
295 if (IsFldEdit())
297 if(bDropDown)
299 const SwDropDownField* pDrop = (const SwDropDownField*)GetCurField();
300 uno::Sequence<OUString> aItems = pDrop->GetItemSequence();
301 const OUString* pArray = aItems.getConstArray();
302 aListItemsLB.Clear();
303 for(sal_Int32 i = 0; i < aItems.getLength(); i++)
304 aListItemsLB.InsertEntry(pArray[i]);
305 aListItemsLB.SelectEntry(pDrop->GetSelectedItem());
306 aListNameED.SetText(pDrop->GetPar2());
307 aListNameED.SaveValue();
308 bDropDownLBChanged = false;
310 else
312 aNameED.SetText(GetCurField()->GetPar1());
313 aValueED.SetText(GetCurField()->GetPar2());
316 else
318 aNameED.SetText(aEmptyStr);
319 aValueED.SetText(aEmptyStr);
321 if(bDropDown)
322 ListEnableHdl(0);
324 if( aNameFT.GetText() != sOldNameFT )
325 aNameFT.SetText(sOldNameFT);
326 if (aValueFT.GetText() != sOldValueFT)
327 aValueFT.SetText(sOldValueFT);
329 switch (nTypeId)
331 case TYP_MACROFLD:
332 bMacro = TRUE;
333 if (GetFldMgr().GetMacroPath().Len())
334 bValue = TRUE;
335 else
336 bInsert = FALSE;
338 aNameFT.SetText(SW_RESSTR(STR_MACNAME));
339 aValueFT.SetText(SW_RESSTR(STR_PROMPT));
340 aNameED.SetText(GetFldMgr().GetMacroName());
341 break;
343 case TYP_HIDDENPARAFLD:
344 aNameFT.SetText(SW_RESSTR(STR_COND));
345 aNameED.SetDropEnable(TRUE);
346 bName = TRUE;
347 break;
349 case TYP_HIDDENTXTFLD:
351 aNameFT.SetText(SW_RESSTR(STR_COND));
352 aNameED.SetDropEnable(TRUE);
353 aValueFT.SetText(SW_RESSTR(STR_INSTEXT));
354 SwWrtShell* pSh = GetActiveWrtShell();
355 if (!IsFldEdit() && pSh )
356 aValueED.SetText(pSh->GetSelTxt());
357 bName = bValue = TRUE;
359 break;
361 case TYP_CONDTXTFLD:
362 aNameFT.SetText(SW_RESSTR(STR_COND));
363 aNameED.SetDropEnable(TRUE);
364 if (IsFldEdit())
366 aCond1ED.SetText(GetCurField()->GetPar2().GetToken(0, '|'));
367 aCond2ED.SetText(GetCurField()->GetPar2().GetToken(1, '|'));
370 bName = bValue = TRUE;
371 break;
373 case TYP_JUMPEDITFLD:
374 aNameFT.SetText(SW_RESSTR(STR_JUMPEDITFLD));
375 aValueFT.SetText(SW_RESSTR(STR_PROMPT));
376 bName = bValue = TRUE;
377 break;
379 case TYP_INPUTFLD:
380 aValueFT.SetText(SW_RESSTR(STR_PROMPT));
381 bValue = TRUE;
382 // bShowSelection = TRUE;
383 break;
385 case TYP_COMBINED_CHARS:
387 aNameFT.SetText(SW_RESSTR(STR_COMBCHRS_FT));
388 aNameED.SetDropEnable(TRUE);
389 bName = TRUE;
391 const USHORT nLen = aNameED.GetText().Len();
392 if( !nLen || nLen > MAX_COMBINED_CHARACTERS )
393 bInsert = FALSE;
395 break;
396 case TYP_DROPDOWN :
397 break;
398 default:
399 break;
402 if (bShowSelection)
404 aSelectionLB.Show();
405 aSelectionFT.Show();
406 aFormatLB.Hide();
407 aFormatFT.Hide();
409 else
411 aFormatLB.Show();
412 aFormatFT.Show();
413 aSelectionLB.Hide();
414 aSelectionFT.Hide();
417 aFormatLB.Enable(bFormat);
418 aFormatFT.Enable(bFormat);
419 aNameFT.Enable(bName);
420 aNameED.Enable(bName);
421 aValueFT.Enable(bValue);
422 aValueED.Enable(bValue);
423 aMacroBT.Enable(bMacro);
425 EnableInsert( bInsert );
428 return 0;
431 /*--------------------------------------------------------------------
432 Beschreibung:
433 --------------------------------------------------------------------*/
435 IMPL_LINK( SwFldFuncPage, SelectHdl, ListBox *, EMPTYARG )
437 USHORT nTypeId = (USHORT)(ULONG)aTypeLB.GetEntryData(GetTypeSel());
439 if( TYP_MACROFLD == nTypeId )
440 aNameED.SetText( aSelectionLB.GetSelectEntry() );
442 return 0;
445 /*--------------------------------------------------------------------
446 Beschreibung:
447 --------------------------------------------------------------------*/
449 IMPL_LINK( SwFldFuncPage, InsertMacroHdl, ListBox *, EMPTYARG )
451 SelectHdl();
452 InsertHdl();
454 return 0;
456 /* -----------------16.06.2003 16:24-----------------
458 --------------------------------------------------*/
459 IMPL_LINK( SwFldFuncPage, ListModifyHdl, Control*, pControl)
461 aListItemsLB.SetUpdateMode(FALSE);
462 if(pControl == &aListAddPB ||
463 pControl == &aListItemED && aListAddPB.IsEnabled())
465 String sEntry(aListItemED.GetText());
466 aListItemsLB.InsertEntry(sEntry);
467 aListItemsLB.SelectEntry(sEntry);
469 else if(aListItemsLB.GetSelectEntryCount())
471 USHORT nSelPos = aListItemsLB.GetSelectEntryPos();
472 if(pControl == &aListRemovePB)
474 aListItemsLB.RemoveEntry(nSelPos);
475 aListItemsLB.SelectEntryPos(nSelPos ? nSelPos - 1 : 0);
477 else if(pControl == &aListUpPB)
479 if(nSelPos)
481 String sEntry = aListItemsLB.GetSelectEntry();
482 aListItemsLB.RemoveEntry(nSelPos);
483 nSelPos--;
484 aListItemsLB.InsertEntry(sEntry, nSelPos);
485 aListItemsLB.SelectEntryPos(nSelPos);
488 else if(pControl == &aListDownPB)
490 if(nSelPos < aListItemsLB.GetEntryCount() - 1)
492 String sEntry = aListItemsLB.GetSelectEntry();
493 aListItemsLB.RemoveEntry(nSelPos);
494 nSelPos++;
495 aListItemsLB.InsertEntry(sEntry, nSelPos);
496 aListItemsLB.SelectEntryPos(nSelPos);
500 bDropDownLBChanged = true;
501 aListItemsLB.SetUpdateMode(TRUE);
502 ListEnableHdl(0);
503 return 0;
505 /* -----------------17.06.2003 08:36-----------------
507 --------------------------------------------------*/
508 IMPL_LINK( SwFldFuncPage, ListEnableHdl, void*, EMPTYARG)
510 //enable "Add" button when text is in the Edit that's not already member of the box
511 aListAddPB.Enable(aListItemED.GetText().Len() &&
512 LISTBOX_ENTRY_NOTFOUND == aListItemsLB.GetEntryPos(aListItemED.GetText()));
513 BOOL bEnableButtons = aListItemsLB.GetSelectEntryCount() > 0;
514 aListRemovePB.Enable(bEnableButtons);
515 aListUpPB.Enable(bEnableButtons && (aListItemsLB.GetSelectEntryPos() > 0));
516 aListDownPB.Enable(bEnableButtons &&
517 (aListItemsLB.GetSelectEntryPos() < (aListItemsLB.GetEntryCount() - 1)));
519 return 0;
522 /*--------------------------------------------------------------------
523 Beschreibung: Typen in der SelectionBox erneuern
524 --------------------------------------------------------------------*/
527 void SwFldFuncPage::UpdateSubType()
529 USHORT nTypeId = (USHORT)(ULONG)aTypeLB.GetEntryData(GetTypeSel());
531 // Auswahl-Listbox fuellen
532 aSelectionLB.SetUpdateMode(FALSE);
533 aSelectionLB.Clear();
535 SvStringsDtor aLst;
536 GetFldMgr().GetSubTypes(nTypeId, aLst);
537 USHORT nCount = aLst.Count();
539 for (USHORT i = 0; i < nCount; ++i)
541 USHORT nPos = aSelectionLB.InsertEntry(*aLst[i]);
542 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
545 BOOL bEnable = nCount != 0;
547 aSelectionLB.Enable( bEnable );
548 aSelectionFT.Enable( bEnable );
550 if (bEnable)
552 aSelectionLB.SelectEntryPos(0);
555 if (nTypeId == TYP_MACROFLD)
557 BOOL bHasMacro = GetFldMgr().GetMacroPath().Len() != 0;
559 if (bHasMacro)
561 aNameED.SetText(GetFldMgr().GetMacroName());
562 aValueFT.Enable();
563 aValueED.Enable();
565 EnableInsert(bHasMacro);
568 aSelectionLB.SetUpdateMode(TRUE);
571 /*--------------------------------------------------------------------
572 Beschreibung: MacroBrowser aufrufen, Listbox mit Macros fuellen
573 --------------------------------------------------------------------*/
575 IMPL_LINK( SwFldFuncPage, MacroHdl, Button *, pBtn )
577 Window* pDefModalDlgParent = Application::GetDefDialogParent();
578 Application::SetDefDialogParent( pBtn );
580 String sMacro(TurnMacroString(aNameED.GetText()));
581 while (sMacro.SearchAndReplace('.', ';') != STRING_NOTFOUND) ;
583 if (GetFldMgr().ChooseMacro(sMacro))
584 UpdateSubType();
586 Application::SetDefDialogParent( pDefModalDlgParent );
588 return 0;
591 /*--------------------------------------------------------------------
592 Beschreibung:
593 --------------------------------------------------------------------*/
595 BOOL SwFldFuncPage::FillItemSet(SfxItemSet& )
597 USHORT nTypeId = (USHORT)(ULONG)aTypeLB.GetEntryData(GetTypeSel());
599 USHORT nSubType = 0;
601 ULONG nFormat = aFormatLB.GetSelectEntryPos();
603 if(nFormat == LISTBOX_ENTRY_NOTFOUND)
604 nFormat = 0;
605 else
606 nFormat = (ULONG)aFormatLB.GetEntryData((USHORT)nFormat);
608 String aVal(aValueED.GetText());
609 String aName(aNameED.GetText());
611 switch(nTypeId)
613 case TYP_INPUTFLD:
614 nSubType = INP_TXT;
615 // to prevent removal of CR/LF restore old content
616 if(!aNameED.IsModified() && IsFldEdit())
617 aName = GetCurField()->GetPar1();
619 break;
621 case TYP_MACROFLD:
622 // use the full script URL, not the name in the Edit control
623 aName = GetFldMgr().GetMacroPath();
624 break;
626 case TYP_CONDTXTFLD:
627 aVal = aCond1ED.GetText();
628 aVal += '|';
629 aVal += aCond2ED.GetText();
630 break;
631 case TYP_DROPDOWN :
633 aName = aListNameED.GetText();
634 for(USHORT i = 0; i < aListItemsLB.GetEntryCount(); i++)
636 if(i)
637 aVal += DB_DELIM;
638 aVal += aListItemsLB.GetEntry(i);
641 break;
642 default:
643 break;
646 if (!IsFldEdit() ||
647 aNameED.GetSavedValue() != aNameED.GetText() ||
648 aValueED.GetSavedValue() != aValueED.GetText() ||
649 aCond1ED.GetSavedValue() != aCond1ED.GetText() ||
650 aCond2ED.GetSavedValue() != aCond2ED.GetText() ||
651 aListNameED.GetSavedValue() != aListNameED.GetText() ||
652 bDropDownLBChanged ||
653 nOldFormat != nFormat)
655 InsertFld( nTypeId, nSubType, aName, aVal, nFormat );
658 ModifyHdl(); // Insert ggf enablen/disablen
660 return FALSE;
663 /*--------------------------------------------------------------------
664 Beschreibung:
665 --------------------------------------------------------------------*/
667 String SwFldFuncPage::TurnMacroString(const String &rMacro)
669 if (rMacro.Len())
671 // Inhalt von aName umdrehen
672 String sTmp, sBuf;
673 USHORT nPos = 0;
675 for (USHORT i = 0; i < 4 && nPos != STRING_NOTFOUND; i++)
677 if (i == 3)
678 sTmp = rMacro.Copy(nPos);
679 else
680 sTmp = rMacro.GetToken(0, '.', nPos);
682 if( sBuf.Len() )
683 sTmp += '.';
684 sBuf.Insert( sTmp, 0 );
686 return sBuf;
689 return rMacro;
692 /*--------------------------------------------------------------------
693 Beschreibung:
694 --------------------------------------------------------------------*/
696 SfxTabPage* SwFldFuncPage::Create( Window* pParent,
697 const SfxItemSet& rAttrSet )
699 return ( new SwFldFuncPage( pParent, rAttrSet ) );
702 /*--------------------------------------------------------------------
703 Beschreibung:
704 --------------------------------------------------------------------*/
706 USHORT SwFldFuncPage::GetGroup()
708 return GRP_FKT;
711 /* -----------------12.01.99 10:09-------------------
713 * --------------------------------------------------*/
714 void SwFldFuncPage::FillUserData()
716 String sData( String::CreateFromAscii(
717 RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION )));
718 sData += ';';
719 USHORT nTypeSel = aTypeLB.GetSelectEntryPos();
720 if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
721 nTypeSel = USHRT_MAX;
722 else
723 nTypeSel = sal::static_int_cast< USHORT >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel )));
724 sData += String::CreateFromInt32( nTypeSel );
725 SetUserData(sData);
728 IMPL_LINK( SwFldFuncPage, ModifyHdl, Edit *, EMPTYARG )
730 String aName(aNameED.GetText());
731 const USHORT nLen = aName.Len();
733 BOOL bEnable = TRUE;
734 USHORT nTypeId = (USHORT)(ULONG)aTypeLB.GetEntryData(GetTypeSel());
736 if( TYP_COMBINED_CHARS == nTypeId &&
737 (!nLen || nLen > MAX_COMBINED_CHARACTERS ))
738 bEnable = FALSE;
740 EnableInsert( bEnable );
742 return 0;