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