1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 #ifdef SW_DLLIMPLEMENTATION 31 #undef SW_DLLIMPLEMENTATION 32 #endif 33 34 35 #include <swtypes.hxx> 36 #include <sfx2/linkmgr.hxx> 37 #include <usrfld.hxx> 38 #include <docufld.hxx> 39 #include <expfld.hxx> 40 #include <ddefld.hxx> 41 #ifndef _VIEW_HXX 42 #include <view.hxx> 43 #endif 44 #include <wrtsh.hxx> 45 #include <doc.hxx> 46 #include <docary.hxx> 47 #include <swmodule.hxx> 48 #ifndef _FLDVAR_HXX 49 #include <fldvar.hxx> 50 #endif 51 #include <calc.hxx> 52 #include <svl/zformat.hxx> 53 #ifndef _GLOBALS_HRC 54 #include <globals.hrc> 55 #endif 56 #ifndef _FLDUI_HRC 57 #include <fldui.hrc> 58 #endif 59 #ifndef _FLDTDLG_HRC 60 #include <fldtdlg.hrc> 61 #endif 62 63 #define USER_DATA_VERSION_1 "1" 64 #define USER_DATA_VERSION USER_DATA_VERSION_1 65 /*-------------------------------------------------------------------- 66 Beschreibung: 67 --------------------------------------------------------------------*/ 68 69 SwFldVarPage::SwFldVarPage(Window* pParent, const SfxItemSet& rCoreSet ) : 70 SwFldPage ( pParent, SW_RES( TP_FLD_VAR ), rCoreSet ), 71 aTypeFT (this, SW_RES(FT_VARTYPE)), 72 aTypeLB (this, SW_RES(LB_VARTYPE)), 73 aSelectionFT (this, SW_RES(FT_VARSELECTION)), 74 aSelectionLB (this, SW_RES(LB_VARSELECTION)), 75 aNameFT (this, SW_RES(FT_VARNAME)), 76 aNameED (this, SW_RES(ED_VARNAME)), 77 aValueFT (this, SW_RES(FT_VARVALUE)), 78 aValueED (this, SW_RES(ED_VARVALUE)), 79 aFormatFT (this, SW_RES(FT_VARFORMAT)), 80 aNumFormatLB (this, SW_RES(LB_VARNUMFORMAT)), 81 aFormatLB (this, SW_RES(LB_VARFORMAT)), 82 aChapterHeaderFT(this, SW_RES(FT_VARCHAPTERHEADER)), 83 aChapterLevelFT (this, SW_RES(FT_VARCHAPTERLEVEL)), 84 aChapterLevelLB (this, SW_RES(LB_VARCHAPTERLEVEL)), 85 aInvisibleCB (this, SW_RES(CB_VARINVISIBLE)), 86 aSeparatorFT (this, SW_RES(FT_VARSEPARATOR)), 87 aSeparatorED (this, SW_RES(ED_VARSEPARATOR)), 88 aNewDelTBX (this, SW_RES(TBX_VARNEWDEL)), 89 bInit (sal_True) 90 { 91 FreeResource(); 92 93 aNewDelTBX.SetSizePixel( aNewDelTBX.CalcWindowSizePixel() ); 94 95 long nDelta = ( aValueED.GetSizePixel().Height() - 96 aNewDelTBX.GetSizePixel().Height() ) / 2; 97 Point aNewPnt = aNewDelTBX.GetPosPixel(); 98 aNewPnt.Y() += nDelta; 99 aNewDelTBX.SetPosPixel( aNewPnt ); 100 101 sOldValueFT = aValueFT.GetText(); 102 sOldNameFT = aNameFT.GetText(); 103 104 for (sal_uInt16 i = 1; i <= MAXLEVEL; i++) 105 aChapterLevelLB.InsertEntry(String::CreateFromInt32(i)); 106 107 aChapterLevelLB.SelectEntryPos(0); 108 //enable 'active' language selection 109 aNumFormatLB.SetShowLanguageControl(sal_True); 110 } 111 112 /*-------------------------------------------------------------------- 113 Beschreibung: 114 --------------------------------------------------------------------*/ 115 116 SwFldVarPage::~SwFldVarPage() 117 { 118 } 119 120 /*-------------------------------------------------------------------- 121 Beschreibung: 122 --------------------------------------------------------------------*/ 123 124 void SwFldVarPage::Reset(const SfxItemSet& ) 125 { 126 SavePos(&aTypeLB); 127 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 for (short i = rRg.nStart; i < rRg.nEnd; ++i) 141 { 142 nTypeId = GetFldMgr().GetTypeId(i); 143 nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i)); 144 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); 145 } 146 } 147 else 148 { 149 SwField* pCurField = GetCurField(); 150 nTypeId = pCurField->GetTypeId(); 151 if (nTypeId == TYP_SETINPFLD) 152 nTypeId = TYP_INPUTFLD; 153 nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId))); 154 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); 155 aNumFormatLB.SetAutomaticLanguage(pCurField->IsAutomaticLanguage()); 156 SwWrtShell *pSh = GetWrtShell(); 157 if(!pSh) 158 pSh = ::GetActiveWrtShell(); 159 if(pSh) 160 { 161 const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat()); 162 if(pFormat) 163 aNumFormatLB.SetLanguage(pFormat->GetLanguage()); 164 } 165 } 166 167 // alte Pos selektieren 168 RestorePos(&aTypeLB); 169 170 aTypeLB.SetDoubleClickHdl (LINK(this, SwFldVarPage, InsertHdl)); 171 aTypeLB.SetSelectHdl (LINK(this, SwFldVarPage, TypeHdl)); 172 aSelectionLB.SetSelectHdl (LINK(this, SwFldVarPage, SubTypeHdl)); 173 aSelectionLB.SetDoubleClickHdl (LINK(this, SwFldVarPage, InsertHdl)); 174 aFormatLB.SetDoubleClickHdl (LINK(this, SwFldVarPage, InsertHdl)); 175 aNumFormatLB.SetDoubleClickHdl (LINK(this, SwFldVarPage, InsertHdl)); 176 aNameED.SetModifyHdl (LINK(this, SwFldVarPage, ModifyHdl)); 177 aValueED.SetModifyHdl (LINK(this, SwFldVarPage, ModifyHdl)); 178 aNewDelTBX.SetClickHdl (LINK(this, SwFldVarPage, TBClickHdl)); 179 aChapterLevelLB.SetSelectHdl (LINK(this, SwFldVarPage, ChapterHdl)); 180 aSeparatorED.SetModifyHdl (LINK(this, SwFldVarPage, SeparatorHdl)); 181 182 if( !IsRefresh() ) 183 { 184 String sUserData = GetUserData(); 185 if(!IsRefresh() && sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1)) 186 { 187 String sVal = sUserData.GetToken(1, ';'); 188 sal_uInt16 nVal = (sal_uInt16)sVal.ToInt32(); 189 if( USHRT_MAX != nVal ) 190 { 191 for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++) 192 if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i)) 193 { 194 aTypeLB.SelectEntryPos(i); 195 break; 196 } 197 } 198 } 199 } 200 TypeHdl(0); 201 202 aTypeLB.SetUpdateMode(sal_True); 203 204 if (IsFldEdit()) 205 { 206 aSelectionLB.SaveValue(); 207 aFormatLB.SaveValue(); 208 nOldFormat = aNumFormatLB.GetFormat(); 209 aNameED.SaveValue(); 210 aValueED.SaveValue(); 211 aInvisibleCB.SaveValue(); 212 aChapterLevelLB.SaveValue(); 213 aSeparatorED.SaveValue(); 214 } 215 } 216 217 /*-------------------------------------------------------------------- 218 Beschreibung: 219 --------------------------------------------------------------------*/ 220 221 IMPL_LINK( SwFldVarPage, TypeHdl, ListBox *, EMPTYARG ) 222 { 223 // Alte ListBoxPos sichern 224 const sal_uInt16 nOld = GetTypeSel(); 225 226 // Aktuelle ListBoxPos 227 SetTypeSel(aTypeLB.GetSelectEntryPos()); 228 229 if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND) 230 { 231 SetTypeSel(0); 232 aTypeLB.SelectEntryPos(0); 233 } 234 235 if (nOld != GetTypeSel() || nOld == LISTBOX_ENTRY_NOTFOUND) 236 { 237 bInit = sal_True; 238 if (nOld != LISTBOX_ENTRY_NOTFOUND) 239 { 240 aNameED.SetText(aEmptyStr); 241 aValueED.SetText(aEmptyStr); 242 } 243 244 aValueED.SetDropEnable(sal_False); 245 UpdateSubType(); // Auswahl-Listboxen initialisieren 246 } 247 248 bInit = sal_False; 249 250 return 0; 251 } 252 253 /*-------------------------------------------------------------------- 254 Beschreibung: 255 --------------------------------------------------------------------*/ 256 257 IMPL_LINK( SwFldVarPage, SubTypeHdl, ListBox *, pBox ) 258 { 259 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 260 sal_uInt16 nSelPos = aSelectionLB.GetSelectEntryPos(); 261 262 if (nSelPos != LISTBOX_ENTRY_NOTFOUND) 263 nSelPos = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nSelPos); 264 265 if (IsFldEdit() && (!pBox || bInit)) 266 { 267 if (nTypeId != TYP_FORMELFLD) 268 aNameED.SetText(GetFldMgr().GetCurFldPar1()); 269 270 aValueED.SetText(GetFldMgr().GetCurFldPar2()); 271 } 272 273 if (aNameFT.GetText() != sOldNameFT) 274 aNameFT.SetText(sOldNameFT); 275 if (aValueFT.GetText() != sOldValueFT) 276 aValueFT.SetText(sOldValueFT); 277 278 aNumFormatLB.SetUpdateMode(sal_False); 279 aFormatLB.SetUpdateMode(sal_False); 280 FillFormatLB(nTypeId); 281 282 sal_uInt16 nSize = aFormatLB.GetEntryCount(); 283 284 sal_Bool bValue = sal_False, bName = sal_False, bNumFmt = sal_False, 285 bInvisible = sal_False, bSeparator = sal_False, bChapterLevel = sal_False; 286 sal_Bool bFormat = nSize != 0; 287 288 switch (nTypeId) 289 { 290 case TYP_USERFLD: 291 { 292 // Benutzertyp aendern oder anlegen 293 SwUserFieldType* pType = (SwUserFieldType*) 294 GetFldMgr().GetFldType(RES_USERFLD, nSelPos); 295 296 if (pType) 297 { 298 if (!IsFldEdit()) 299 { 300 if (pBox || (bInit && !IsRefresh())) // Nur bei Interaktion mit Maus 301 { 302 aNameED.SetText(pType->GetName()); 303 304 if (pType->GetType() == UF_STRING) 305 { 306 aValueED.SetText(pType->GetContent()); 307 aNumFormatLB.SelectEntryPos(0); 308 } 309 else 310 aValueED.SetText(pType->GetContent()); 311 // aValueED.SetText(pType->GetContent(aNumFormatLB.GetFormat())); 312 } 313 } 314 else 315 aValueED.SetText(pType->GetContent()); 316 } 317 else 318 { 319 if (pBox) // Nur bei Interaktion mit Maus 320 { 321 aNameED.SetText(aEmptyStr); 322 aValueED.SetText(aEmptyStr); 323 } 324 } 325 bValue = bName = bNumFmt = bInvisible = sal_True; 326 327 aValueED.SetDropEnable(sal_True); 328 break; 329 } 330 331 case TYP_SETFLD: 332 bValue = sal_True; 333 334 bNumFmt = bInvisible = sal_True; 335 336 if (!IsFldDlgHtmlMode()) 337 bName = sal_True; 338 else 339 { 340 aNumFormatLB.Clear(); 341 sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_SETVAR_TEXT), 0); 342 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 343 aNumFormatLB.SelectEntryPos(0); 344 } 345 // gibt es ein entprechendes SetField 346 if (IsFldEdit() || pBox) // Nur bei Interaktion mit Maus 347 { 348 if (nSelPos != LISTBOX_ENTRY_NOTFOUND) 349 { 350 String sName(aSelectionLB.GetSelectEntry()); 351 aNameED.SetText(sName); 352 353 if (!IsFldDlgHtmlMode()) 354 { 355 SwWrtShell *pSh = GetWrtShell(); 356 if(!pSh) 357 pSh = ::GetActiveWrtShell(); 358 if(pSh) 359 { 360 SwSetExpFieldType* pSetTyp = (SwSetExpFieldType*) 361 pSh->GetFldType(RES_SETEXPFLD, sName); 362 363 if (pSetTyp && pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING) 364 aNumFormatLB.SelectEntryPos(0); // Textuell 365 } 366 } 367 } 368 } 369 if (IsFldEdit()) 370 { 371 // GetFormula fuehrt bei Datumsformaten zu Problemen, 372 // da nur der numerische Wert ohne Formatierung returned wird. 373 // Muss aber verwendet werden, da sonst bei GetPar2 nur der vom 374 // Kalkulator errechnete Wert angezeigt werden wuerde 375 // (statt test2 = test + 1) 376 aValueED.SetText(((SwSetExpField*)GetCurField())->GetFormula()); 377 } 378 aValueED.SetDropEnable(sal_True); 379 break; 380 381 case TYP_FORMELFLD: 382 { 383 bValue = sal_True; 384 bNumFmt = sal_True; 385 aValueFT.SetText(SW_RESSTR(STR_FORMULA)); 386 aValueED.SetDropEnable(sal_True); 387 } 388 break; 389 390 case TYP_GETFLD: 391 { 392 if (!IsFldEdit()) 393 { 394 aNameED.SetText(aEmptyStr); 395 aValueED.SetText(aEmptyStr); 396 } 397 398 if (nSelPos != LISTBOX_ENTRY_NOTFOUND) 399 { 400 String sName(aSelectionLB.GetSelectEntry()); 401 if (!IsFldEdit()) 402 aNameED.SetText(sName); 403 404 // gibt es ein entprechendes SetField 405 SwWrtShell *pSh = GetWrtShell(); 406 if(!pSh) 407 pSh = ::GetActiveWrtShell(); 408 if(pSh) 409 { 410 SwSetExpFieldType* pSetTyp = (SwSetExpFieldType*) 411 pSh->GetFldType(RES_SETEXPFLD, sName); 412 413 if(pSetTyp) 414 { 415 if (pSetTyp->GetType() & nsSwGetSetExpType::GSE_STRING) // Textuell? 416 bFormat = sal_True; 417 else // Numerisch 418 bNumFmt = sal_True; 419 } 420 } 421 } 422 else 423 bFormat = sal_False; 424 425 EnableInsert(bFormat|bNumFmt); 426 } 427 break; 428 429 case TYP_INPUTFLD: 430 aValueFT.SetText(SW_RESSTR(STR_PROMPT)); 431 432 if (nSelPos != LISTBOX_ENTRY_NOTFOUND) 433 { 434 bValue = bNumFmt = sal_True; 435 436 String sName; 437 438 sName = aSelectionLB.GetSelectEntry(); 439 aNameED.SetText( sName ); 440 441 // User- oder SetField ? 442 sal_uInt16 nInpType = 0; 443 nInpType = static_cast< sal_uInt16 >(GetFldMgr().GetFldType(RES_USERFLD, sName) ? 0 : TYP_SETINPFLD); 444 445 if (nInpType) // SETEXPFLD 446 { 447 // gibt es ein entprechendes SetField 448 SwSetExpFieldType* pSetTyp = (SwSetExpFieldType*) 449 GetFldMgr().GetFldType(RES_SETEXPFLD, sName); 450 451 if(pSetTyp) 452 { 453 if (pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING) // Textuell? 454 { 455 aNumFormatLB.Clear(); 456 457 sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_USERVAR_TEXT), 0); 458 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 459 aNumFormatLB.SelectEntryPos(0); 460 } 461 } 462 if (IsFldEdit() && (!pBox || bInit) ) 463 aValueED.SetText(((SwSetExpField*)GetCurField())->GetPromptText()); 464 } 465 else // USERFLD 466 bFormat = bNumFmt = sal_False; 467 } 468 break; 469 470 case TYP_DDEFLD: 471 aValueFT.SetText(SW_RESSTR(STR_DDE_CMD)); 472 473 if (IsFldEdit() || pBox) // Nur bei Interaktion mit Maus 474 { 475 if (nSelPos != LISTBOX_ENTRY_NOTFOUND) 476 { 477 SwDDEFieldType* pType = 478 (SwDDEFieldType*) GetFldMgr().GetFldType(RES_DDEFLD, nSelPos); 479 480 if(pType) 481 { 482 aNameED.SetText(pType->GetName()); 483 484 //JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren 485 // Namen haben! Wird hier noch nicht beachtet 486 String sCmd( pType->GetCmd() ); 487 sal_uInt16 nTmpPos = sCmd.SearchAndReplace( sfx2::cTokenSeperator, ' ' ); 488 sCmd.SearchAndReplace( sfx2::cTokenSeperator, ' ', nTmpPos ); 489 490 aValueED.SetText( sCmd ); 491 aFormatLB.SelectEntryPos(pType->GetType()); 492 } 493 } 494 } 495 bName = bValue = sal_True; 496 break; 497 498 case TYP_SEQFLD: 499 { 500 // aNumRB.Check(sal_True); 501 bName = bValue = bSeparator = bChapterLevel = sal_True; 502 503 SwFieldType* pFldTyp; 504 if( IsFldEdit() ) 505 pFldTyp = GetCurField()->GetTyp(); 506 else 507 { 508 String sFldTypeName( aSelectionLB.GetEntry( nSelPos )); 509 if( sFldTypeName.Len() ) 510 pFldTyp = GetFldMgr().GetFldType( RES_SETEXPFLD, 511 sFldTypeName ); 512 else 513 pFldTyp = 0; 514 } 515 516 if( IsFldEdit() ) 517 aValueED.SetText( ((SwSetExpField*)GetCurField())-> 518 GetFormula() ); 519 520 if( IsFldEdit() || pBox ) // Nur bei Interaktion mit Maus 521 aNameED.SetText( aSelectionLB.GetSelectEntry() ); 522 523 if( pFldTyp ) 524 { 525 sal_uInt8 nLevel = ((SwSetExpFieldType*)pFldTyp)->GetOutlineLvl(); 526 if( 0x7f == nLevel ) 527 aChapterLevelLB.SelectEntryPos( 0 ); 528 else 529 aChapterLevelLB.SelectEntryPos( nLevel + 1 ); 530 String sDelim = ((SwSetExpFieldType*)pFldTyp)->GetDelimiter(); 531 aSeparatorED.SetText( sDelim ); 532 ChapterHdl(); 533 } 534 } 535 break; 536 537 case TYP_SETREFPAGEFLD: 538 { 539 bValue = sal_False; 540 aValueFT.SetText( SW_RESSTR( STR_OFFSET )); 541 542 if (IsFldEdit() || pBox) // Nur bei Interaktion mit Maus 543 aNameED.SetText(aEmptyStr); 544 545 if (nSelPos != 0 && nSelPos != LISTBOX_ENTRY_NOTFOUND) 546 { 547 bValue = sal_True; // SubType OFF - kennt keinen Offset 548 if (IsFldEdit()) 549 aValueED.SetText(String::CreateFromInt32(((SwRefPageSetField*)GetCurField())->GetOffset())); 550 } 551 } 552 break; 553 554 case TYP_GETREFPAGEFLD: 555 aNameED.SetText(aEmptyStr); 556 aValueED.SetText(aEmptyStr); 557 break; 558 } 559 560 aNumFormatLB.Show(bNumFmt); 561 aFormatLB.Show(!bNumFmt); 562 563 if (IsFldEdit()) 564 bName = sal_False; 565 566 aFormatLB.Enable(bFormat); 567 aFormatFT.Enable(bFormat|bNumFmt); 568 aNameFT.Enable(bName); 569 aNameED.Enable(bName); 570 aValueFT.Enable(bValue); 571 aValueED.Enable(bValue); 572 573 Size aSz(aFormatLB.GetSizePixel()); 574 575 if (bChapterLevel) 576 aSz.Height() = aFormatLB.LogicToPixel(Size(1, 94), MAP_APPFONT).Height(); 577 else 578 aSz.Height() = aFormatLB.LogicToPixel(Size(1, 123), MAP_APPFONT).Height(); 579 580 aFormatLB.SetSizePixel(aSz); 581 582 aInvisibleCB.Show(!bSeparator); 583 aSeparatorFT.Show(bSeparator); 584 aSeparatorED.Show(bSeparator); 585 aChapterHeaderFT.Show(bChapterLevel); 586 aChapterLevelFT.Show(bChapterLevel); 587 aChapterLevelLB.Show(bChapterLevel); 588 aInvisibleCB.Enable(bInvisible); 589 590 ModifyHdl(); // Anwenden/Einfuegen/Loeschen Status update 591 592 aNumFormatLB.SetUpdateMode(sal_True); 593 aFormatLB.SetUpdateMode(sal_True); 594 595 if(aSelectionLB.IsCallAddSelection()) 596 { 597 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 598 599 switch (nTypeId) 600 { 601 case TYP_FORMELFLD: 602 { 603 nSelPos = aSelectionLB.GetSelectEntryPos(); 604 605 if (nSelPos != LISTBOX_ENTRY_NOTFOUND) 606 nSelPos = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nSelPos); 607 608 if (nSelPos != LISTBOX_ENTRY_NOTFOUND && pBox && !bInit) 609 { 610 aValueED.ReplaceSelected(aSelectionLB.GetSelectEntry()); 611 ModifyHdl(); 612 } 613 } 614 break; 615 } 616 aSelectionLB.ResetCallAddSelection(); 617 } 618 return 0; 619 } 620 621 /*-------------------------------------------------------------------- 622 Beschreibung: Typen in der SelectionBox erneuern 623 --------------------------------------------------------------------*/ 624 625 void SwFldVarPage::UpdateSubType() 626 { 627 String sOldSel; 628 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 629 630 SetSelectionSel(aSelectionLB.GetSelectEntryPos()); 631 if(GetSelectionSel() != LISTBOX_ENTRY_NOTFOUND) 632 sOldSel = aSelectionLB.GetEntry(GetSelectionSel()); 633 634 // Auswahl-Listbox fuellen 635 aSelectionLB.SetUpdateMode(sal_False); 636 aSelectionLB.Clear(); 637 638 SvStringsDtor aList; 639 GetFldMgr().GetSubTypes(nTypeId, aList); 640 sal_uInt16 nCount = aList.Count(); 641 sal_uInt16 nPos; 642 643 for (sal_uInt16 i = 0; i < nCount; ++i) 644 { 645 if (nTypeId != TYP_INPUTFLD || i) 646 { 647 if (!IsFldEdit()) 648 { 649 nPos = aSelectionLB.InsertEntry(*aList[i]); 650 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 651 } 652 else 653 { 654 sal_Bool bInsert = sal_False; 655 656 switch (nTypeId) 657 { 658 case TYP_INPUTFLD: 659 if (*aList[i] == GetCurField()->GetPar1()) 660 bInsert = sal_True; 661 break; 662 663 case TYP_FORMELFLD: 664 bInsert = sal_True; 665 break; 666 667 case TYP_GETFLD: 668 if (*aList[i] == ((SwFormulaField*)GetCurField())->GetFormula()) 669 bInsert = sal_True; 670 break; 671 672 case TYP_SETFLD: 673 case TYP_USERFLD: 674 if (*aList[i] == GetCurField()->GetTyp()->GetName()) 675 { 676 bInsert = sal_True; 677 if (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE) 678 aInvisibleCB.Check(); 679 } 680 break; 681 682 case TYP_SETREFPAGEFLD: 683 if ((((SwRefPageSetField*)GetCurField())->IsOn() && i) || 684 (!((SwRefPageSetField*)GetCurField())->IsOn() && !i)) 685 sOldSel = *aList[i]; 686 687 // Alle Eintr?ge zur Auswahl zulassen: 688 nPos = aSelectionLB.InsertEntry(*aList[i]); 689 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 690 break; 691 692 default: 693 if (*aList[i] == GetCurField()->GetPar1()) 694 bInsert = sal_True; 695 break; 696 } 697 if (bInsert) 698 { 699 nPos = aSelectionLB.InsertEntry(*aList[i]); 700 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 701 if (nTypeId != TYP_FORMELFLD) 702 break; 703 } 704 } 705 } 706 } 707 708 sal_Bool bEnable = aSelectionLB.GetEntryCount() != 0; 709 ListBox *pLB = 0; 710 711 if (bEnable) 712 { 713 aSelectionLB.SelectEntry(sOldSel); 714 if (!aSelectionLB.GetSelectEntryCount()) 715 { 716 aSelectionLB.SelectEntryPos(0); 717 pLB = &aSelectionLB; // Alle Controls neu initialisieren 718 } 719 } 720 721 aSelectionLB.Enable( bEnable ); 722 aSelectionFT.Enable( bEnable ); 723 724 SubTypeHdl(pLB); 725 aSelectionLB.SetUpdateMode(sal_True); 726 } 727 728 /*-------------------------------------------------------------------- 729 Beschreibung: 730 --------------------------------------------------------------------*/ 731 732 sal_uInt16 SwFldVarPage::FillFormatLB(sal_uInt16 nTypeId) 733 { 734 String sOldSel, sOldNumSel; 735 sal_uLong nOldNumFormat = 0; 736 737 sal_uInt16 nFormatSel = aFormatLB.GetSelectEntryPos(); 738 if (nFormatSel != LISTBOX_ENTRY_NOTFOUND) 739 sOldSel = aFormatLB.GetEntry(nFormatSel); 740 741 sal_uInt16 nNumFormatSel = aNumFormatLB.GetSelectEntryPos(); 742 if (nNumFormatSel != LISTBOX_ENTRY_NOTFOUND) 743 { 744 sOldNumSel = aNumFormatLB.GetEntry(nNumFormatSel); 745 nOldNumFormat = aNumFormatLB.GetFormat(); 746 } 747 748 // Format-Listbox fuellen 749 aFormatLB.Clear(); 750 aNumFormatLB.Clear(); 751 sal_Bool bSpecialFmt = sal_False; 752 753 if( TYP_GETREFPAGEFLD != nTypeId ) 754 { 755 if (IsFldEdit()) 756 { 757 bSpecialFmt = GetCurField()->GetFormat() == SAL_MAX_UINT32; 758 759 if (!bSpecialFmt) 760 { 761 aNumFormatLB.SetDefFormat(GetCurField()->GetFormat()); 762 sOldNumSel = aEmptyStr; 763 } 764 else 765 if (nTypeId == TYP_GETFLD || nTypeId == TYP_FORMELFLD) 766 aNumFormatLB.SetFormatType(NUMBERFORMAT_NUMBER); 767 } 768 else 769 { 770 if (nOldNumFormat && nOldNumFormat != ULONG_MAX) 771 aNumFormatLB.SetDefFormat(nOldNumFormat); 772 else 773 aNumFormatLB.SetFormatType(NUMBERFORMAT_NUMBER); 774 } 775 } 776 777 switch (nTypeId) 778 { 779 case TYP_USERFLD: 780 { 781 if (!IsFldEdit() || bSpecialFmt) 782 { 783 sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_MARK_TEXT), 0); 784 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 785 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_USERVAR_CMD), 1); 786 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 787 } 788 } 789 break; 790 791 case TYP_SETFLD: 792 { 793 if (!IsFldEdit() || bSpecialFmt) 794 { 795 sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_SETVAR_TEXT), 0); 796 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 797 } 798 } 799 break; 800 801 case TYP_FORMELFLD: 802 { 803 sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_GETVAR_NAME), 0); 804 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 805 } 806 break; 807 808 case TYP_GETFLD: 809 { 810 sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_GETVAR_NAME), 0); 811 aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX); 812 } 813 break; 814 } 815 816 if (IsFldEdit() && bSpecialFmt) 817 { 818 if (nTypeId == TYP_USERFLD && (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_CMD)) 819 aNumFormatLB.SelectEntryPos(1); 820 else 821 aNumFormatLB.SelectEntryPos(0); 822 } 823 else 824 { 825 if (!nOldNumFormat && (nNumFormatSel = aNumFormatLB.GetEntryPos(sOldNumSel)) != LISTBOX_ENTRY_NOTFOUND) 826 aNumFormatLB.SelectEntryPos(nNumFormatSel); 827 else if (nOldNumFormat && nOldNumFormat == ULONG_MAX) 828 aNumFormatLB.SelectEntry(sOldSel); 829 } 830 831 sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode()); 832 833 for (sal_uInt16 i = 0; i < nSize; i++) 834 { 835 sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i)); 836 sal_uInt16 nFldId = GetFldMgr().GetFormatId( nTypeId, i ); 837 aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(nFldId) ); 838 if (IsFldEdit() && nFldId == GetCurField()->GetFormat()) 839 aFormatLB.SelectEntryPos( nPos ); 840 } 841 842 if (nSize && (!IsFldEdit() || !aFormatLB.GetSelectEntryCount())) 843 { 844 aFormatLB.SelectEntry(sOldSel); 845 846 if (!aFormatLB.GetSelectEntryCount()) 847 { 848 aFormatLB.SelectEntry(SW_RESSTR(FMT_NUM_PAGEDESC)); 849 if (!aFormatLB.GetSelectEntryCount()) 850 { 851 aFormatLB.SelectEntry(SW_RESSTR(FMT_NUM_ARABIC)); 852 if (!aFormatLB.GetSelectEntryCount()) 853 aFormatLB.SelectEntryPos(0); 854 } 855 } 856 } 857 858 return nSize; 859 } 860 861 /*-------------------------------------------------------------------- 862 Beschreibung: Modify 863 --------------------------------------------------------------------*/ 864 865 IMPL_LINK( SwFldVarPage, ModifyHdl, Edit *, EMPTYARG ) 866 { 867 String sValue(aValueED.GetText()); 868 sal_Bool bHasValue = sValue.Len() != 0; 869 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 870 sal_Bool bInsert = sal_False, bApply = sal_False, bDelete = sal_False; 871 872 String sName( aNameED.GetText() ); 873 xub_StrLen nLen = sName.Len(); 874 875 switch( nTypeId ) 876 { 877 case TYP_DDEFLD: 878 case TYP_USERFLD: 879 case TYP_SETFLD: 880 case TYP_SEQFLD: 881 SwCalc::IsValidVarName( sName, &sName ); 882 if( sName.Len() != nLen ) 883 { 884 nLen = sName.Len(); 885 Selection aSel(aNameED.GetSelection()); 886 aNameED.SetText( sName ); 887 aNameED.SetSelection( aSel ); // Cursorpos restaurieren 888 } 889 break; 890 } 891 892 893 // Buttons ueberpruefen 894 switch (nTypeId) 895 { 896 case TYP_DDEFLD: 897 if( nLen ) 898 { 899 // Gibts schon einen entsprechenden Type 900 bInsert = bApply = sal_True; 901 902 SwFieldType* pType = GetFldMgr().GetFldType(RES_DDEFLD, sName); 903 904 SwWrtShell *pSh = GetWrtShell(); 905 if(!pSh) 906 pSh = ::GetActiveWrtShell(); 907 if(pSh && pType) 908 bDelete = !pSh->IsUsed( *pType ); 909 } 910 break; 911 912 case TYP_USERFLD: 913 if( nLen ) 914 { 915 // Gibts schon einen entsprechenden Type 916 SwFieldType* pType = GetFldMgr().GetFldType(RES_USERFLD, sName); 917 918 SwWrtShell *pSh = GetWrtShell(); 919 if(!pSh) 920 pSh = ::GetActiveWrtShell(); 921 if(pSh && pType) 922 bDelete = !pSh->IsUsed( *pType ); 923 924 pType = GetFldMgr().GetFldType(RES_SETEXPFLD, sName); 925 if (!pType) // Kein Namenskonflikt mit Variablen 926 { 927 // Benutzerfelder duerfen auch ohne Inhalt eingefuegt werden! 928 // Bug #56845 929 bInsert = bApply = sal_True; 930 } 931 } 932 break; 933 934 default: 935 bInsert = sal_True; 936 937 if (nTypeId == TYP_SETFLD || nTypeId == TYP_SEQFLD) 938 { 939 SwSetExpFieldType* pFldType = (SwSetExpFieldType*) 940 GetFldMgr().GetFldType(RES_SETEXPFLD, sName); 941 942 if (pFldType) 943 { 944 945 SwWrtShell *pSh = GetWrtShell(); 946 if(!pSh) 947 pSh = ::GetActiveWrtShell(); 948 if(pSh) 949 { 950 const SwFldTypes* p = pSh->GetDoc()->GetFldTypes(); 951 sal_uInt16 i; 952 953 for (i = 0; i < INIT_FLDTYPES; i++) 954 { 955 SwFieldType* pType = (*p)[ i ]; 956 if (pType == pFldType) 957 break; 958 } 959 960 if (i >= INIT_FLDTYPES && !pSh->IsUsed(*pFldType)) 961 bDelete = sal_True; 962 963 if (nTypeId == TYP_SEQFLD && !(pFldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) 964 bInsert = sal_False; 965 966 if (nTypeId == TYP_SETFLD && (pFldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) 967 bInsert = sal_False; 968 } 969 } 970 if (GetFldMgr().GetFldType(RES_USERFLD, sName)) 971 bInsert = sal_False; 972 } 973 974 if( !nLen && ( nTypeId == TYP_SETFLD || 975 (!IsFldEdit() && nTypeId == TYP_GETFLD ) ) ) 976 bInsert = sal_False; 977 978 if( (nTypeId == TYP_SETFLD || nTypeId == TYP_FORMELFLD) && 979 !bHasValue ) 980 bInsert = sal_False; 981 break; 982 } 983 984 aNewDelTBX.EnableItem(BT_VARAPPLY, bApply); 985 aNewDelTBX.EnableItem(BT_VARDELETE, bDelete); 986 EnableInsert(bInsert); 987 988 return 0; 989 } 990 991 /*-------------------------------------------------------------------- 992 Beschreibung: 993 --------------------------------------------------------------------*/ 994 995 IMPL_LINK( SwFldVarPage, TBClickHdl, ToolBox *, pBox ) 996 { 997 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 998 999 switch (pBox->GetCurItemId()) 1000 { 1001 case BT_VARDELETE: 1002 { 1003 if( nTypeId == TYP_USERFLD ) 1004 GetFldMgr().RemoveFldType(RES_USERFLD, aSelectionLB.GetSelectEntry()); 1005 else 1006 { 1007 sal_uInt16 nWhich; 1008 1009 switch(nTypeId) 1010 { 1011 case TYP_SETFLD: 1012 case TYP_SEQFLD: 1013 nWhich = RES_SETEXPFLD; 1014 break; 1015 default: 1016 nWhich = RES_DDEFLD; 1017 break; 1018 } 1019 1020 GetFldMgr().RemoveFldType(nWhich, aSelectionLB.GetSelectEntry()); 1021 } 1022 1023 UpdateSubType(); 1024 SwWrtShell *pSh = GetWrtShell(); 1025 if(!pSh) 1026 pSh = ::GetActiveWrtShell(); 1027 if(pSh) 1028 { 1029 pSh->SetModified(); 1030 } 1031 } 1032 break; 1033 1034 case BT_VARAPPLY: 1035 { 1036 String sName(aNameED.GetText()), sValue(aValueED.GetText()); 1037 SwFieldType* pType = 0; 1038 sal_uInt16 nId = 0; 1039 sal_uInt16 nNumFormatPos = aNumFormatLB.GetSelectEntryPos(); 1040 1041 switch (nTypeId) 1042 { 1043 case TYP_USERFLD: nId = RES_USERFLD; break; 1044 case TYP_DDEFLD: nId = RES_DDEFLD; break; 1045 case TYP_SETFLD: nId = RES_SETEXPFLD;break; 1046 } 1047 pType = GetFldMgr().GetFldType(nId, sName); 1048 1049 sal_uLong nFormat = aFormatLB.GetSelectEntryPos(); 1050 if (nFormat != LISTBOX_ENTRY_NOTFOUND) 1051 nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat); 1052 1053 if (pType) // Aendern 1054 { 1055 SwWrtShell *pSh = GetWrtShell(); 1056 if(!pSh) 1057 pSh = ::GetActiveWrtShell(); 1058 if(pSh) 1059 { 1060 pSh->StartAllAction(); 1061 1062 if (nTypeId == TYP_USERFLD) 1063 { 1064 if (nNumFormatPos != LISTBOX_ENTRY_NOTFOUND) 1065 { 1066 sal_uLong nFmt = nNumFormatPos == 0 ? 0 : aNumFormatLB.GetFormat(); 1067 if (nFmt) 1068 { // Sprache auf Office-Sprache umstellen, da String im Office 1069 // Format vom Kalkulator erwartet wird und so in den Dlg 1070 // eingegeben werden sollte 1071 nFmt = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nFmt); 1072 } 1073 ((SwUserFieldType*)pType)->SetContent(aValueED.GetText(), nFmt); 1074 ((SwUserFieldType*)pType)->SetType( 1075 nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR ); 1076 } 1077 } 1078 else 1079 { 1080 if (nFormat != LISTBOX_ENTRY_NOTFOUND) 1081 { 1082 //JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren 1083 // Namen haben! Wird hier noch nicht beachtet. 1084 sal_uInt16 nTmpPos = sValue.SearchAndReplace( ' ', sfx2::cTokenSeperator ); 1085 sValue.SearchAndReplace( ' ', sfx2::cTokenSeperator, nTmpPos ); 1086 ((SwDDEFieldType*)pType)->SetCmd(sValue); 1087 ((SwDDEFieldType*)pType)->SetType((sal_uInt16)nFormat); 1088 } 1089 } 1090 pType->UpdateFlds(); 1091 1092 pSh->EndAllAction(); 1093 } 1094 } 1095 else // Neu 1096 { 1097 if(nTypeId == TYP_USERFLD) 1098 { 1099 SwWrtShell *pSh = GetWrtShell(); 1100 if(!pSh) 1101 pSh = ::GetActiveWrtShell(); 1102 if(pSh) 1103 { 1104 SwUserFieldType aType( pSh->GetDoc(), sName ); 1105 1106 if (nNumFormatPos != LISTBOX_ENTRY_NOTFOUND) 1107 { 1108 aType.SetType(nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR); 1109 aType.SetContent( sValue, nNumFormatPos == 0 ? 0 : aNumFormatLB.GetFormat() ); 1110 aSelectionLB.InsertEntry(sName); 1111 aSelectionLB.SelectEntry(sName); 1112 GetFldMgr().InsertFldType( aType ); // Userfld Neu 1113 } 1114 } 1115 } 1116 else 1117 { 1118 if (nFormat != LISTBOX_ENTRY_NOTFOUND) 1119 { 1120 //JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren 1121 // Namen haben! Wird hier noch nicht beachtet. 1122 sal_uInt16 nTmpPos = sValue.SearchAndReplace( ' ', sfx2::cTokenSeperator ); 1123 sValue.SearchAndReplace( ' ', sfx2::cTokenSeperator, nTmpPos ); 1124 1125 SwDDEFieldType aType(sName, sValue, (sal_uInt16)nFormat); 1126 aSelectionLB.InsertEntry(sName); 1127 aSelectionLB.SelectEntry(sName); 1128 GetFldMgr().InsertFldType(aType); // DDE-Feld Neu 1129 } 1130 } 1131 } 1132 if (IsFldEdit()) 1133 GetFldMgr().GetCurFld(); // FieldManager Updaten 1134 1135 UpdateSubType(); 1136 } 1137 break; 1138 } 1139 1140 return sal_True; 1141 } 1142 1143 /*-------------------------------------------------------------------- 1144 Beschreibung: 1145 --------------------------------------------------------------------*/ 1146 1147 IMPL_LINK( SwFldVarPage, ChapterHdl, ListBox *, EMPTYARG ) 1148 { 1149 sal_Bool bEnable = aChapterLevelLB.GetSelectEntryPos() != 0; 1150 1151 aSeparatorED.Enable(bEnable); 1152 aSeparatorFT.Enable(bEnable); 1153 SeparatorHdl(); 1154 1155 return 0; 1156 } 1157 1158 /*-------------------------------------------------------------------- 1159 Beschreibung: 1160 --------------------------------------------------------------------*/ 1161 1162 IMPL_LINK( SwFldVarPage, SeparatorHdl, Edit *, EMPTYARG ) 1163 { 1164 sal_Bool bEnable = aSeparatorED.GetText().Len() != 0 || 1165 aChapterLevelLB.GetSelectEntryPos() == 0; 1166 EnableInsert(bEnable); 1167 1168 return 0; 1169 } 1170 1171 /*-------------------------------------------------------------------- 1172 Beschreibung: 1173 --------------------------------------------------------------------*/ 1174 1175 sal_Bool SwFldVarPage::FillItemSet(SfxItemSet& ) 1176 { 1177 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 1178 1179 String aVal(aValueED.GetText()); 1180 String aName(aNameED.GetText()); 1181 1182 sal_uInt16 nSubType = aSelectionLB.GetSelectEntryPos(); 1183 if(nSubType == LISTBOX_ENTRY_NOTFOUND) 1184 nSubType = 0; 1185 else 1186 nSubType = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nSubType); 1187 1188 sal_uLong nFormat; 1189 1190 if (!aNumFormatLB.IsVisible()) 1191 { 1192 nFormat = aFormatLB.GetSelectEntryPos(); 1193 1194 if(nFormat == LISTBOX_ENTRY_NOTFOUND) 1195 nFormat = 0; 1196 else 1197 nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat); 1198 } 1199 else 1200 { 1201 nFormat = aNumFormatLB.GetFormat(); 1202 1203 if (nFormat && nFormat != ULONG_MAX && aNumFormatLB.IsAutomaticLanguage()) 1204 { 1205 // Sprache auf Office-Sprache umstellen, da String im Office- 1206 // Format vom Kalkulator erwartet wird und so in den Dlg 1207 // eingegeben werden sollte 1208 SwWrtShell *pSh = GetWrtShell(); 1209 if(!pSh) 1210 pSh = ::GetActiveWrtShell(); 1211 if(pSh) 1212 { 1213 nFormat = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nFormat); 1214 } 1215 } 1216 } 1217 sal_Unicode cSeparator = ' '; 1218 switch (nTypeId) 1219 { 1220 case TYP_USERFLD: 1221 { 1222 nSubType = (nFormat == ULONG_MAX) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR; 1223 1224 if (nFormat == ULONG_MAX && aNumFormatLB.GetSelectEntry() == SW_RESSTR(FMT_USERVAR_CMD)) 1225 nSubType |= nsSwExtendedSubType::SUB_CMD; 1226 1227 if (aInvisibleCB.IsChecked()) 1228 nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; 1229 break; 1230 } 1231 case TYP_FORMELFLD: 1232 { 1233 nSubType = nsSwGetSetExpType::GSE_FORMULA; 1234 if (aNumFormatLB.IsVisible() && nFormat == ULONG_MAX) 1235 nSubType |= nsSwExtendedSubType::SUB_CMD; 1236 break; 1237 } 1238 case TYP_GETFLD: 1239 { 1240 nSubType &= 0xff00; 1241 if (aNumFormatLB.IsVisible() && nFormat == ULONG_MAX) 1242 nSubType |= nsSwExtendedSubType::SUB_CMD; 1243 break; 1244 } 1245 case TYP_INPUTFLD: 1246 { 1247 SwFieldType* pType = GetFldMgr().GetFldType(RES_USERFLD, aName); 1248 nSubType = static_cast< sal_uInt16 >((nSubType & 0xff00) | ((pType) ? INP_USR : INP_VAR)); 1249 break; 1250 } 1251 1252 case TYP_SETFLD: 1253 { 1254 if (IsFldDlgHtmlMode()) 1255 { 1256 nSubType = 0x0100; 1257 nSubType = (nSubType & 0xff00) | nsSwGetSetExpType::GSE_STRING; 1258 } 1259 else 1260 nSubType = (nSubType & 0xff00) | ((nFormat == ULONG_MAX) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR); 1261 1262 if (aInvisibleCB.IsChecked()) 1263 nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; 1264 break; 1265 } 1266 case TYP_SEQFLD: 1267 { 1268 // nSubType = nsSwGetSetExpType::GSE_SEQ; // nsSwGetSetExpType::GSE_SEQ wird im Fldmgr fest gesetzt, kann also entfallen 1269 nSubType = aChapterLevelLB.GetSelectEntryPos(); 1270 if (nSubType == 0) 1271 nSubType = 0x7f; 1272 else 1273 { 1274 nSubType--; 1275 String sSeparator(aSeparatorED.GetText().GetChar(0)); 1276 cSeparator = sSeparator.Len() ? sSeparator.GetChar(0) : ' '; 1277 //nSubType |= (sal_uInt16)(((sal_uInt8)) << 8); 1278 } 1279 break; 1280 } 1281 case TYP_GETREFPAGEFLD: 1282 if( SVX_NUM_CHAR_SPECIAL == nFormat ) 1283 aVal = aValueED.GetText(); 1284 break; 1285 } 1286 1287 if (!IsFldEdit() || 1288 aNameED.GetSavedValue() != aNameED.GetText() || 1289 aValueED.GetSavedValue() != aValueED.GetText() || 1290 aSelectionLB.GetSavedValue() != aSelectionLB.GetSelectEntryPos() || 1291 aFormatLB.GetSavedValue() != aFormatLB.GetSelectEntryPos() || 1292 nOldFormat != aNumFormatLB.GetFormat() || 1293 aInvisibleCB.GetState() != aInvisibleCB.GetSavedValue() || 1294 aChapterLevelLB.GetSavedValue() != aChapterLevelLB.GetSelectEntryPos() || 1295 aSeparatorED.GetSavedValue() != aSeparatorED.GetText()) 1296 { 1297 InsertFld( nTypeId, nSubType, aName, aVal, nFormat, 1298 cSeparator, aNumFormatLB.IsAutomaticLanguage() ); 1299 } 1300 1301 UpdateSubType(); 1302 1303 return sal_False; 1304 } 1305 1306 1307 /*-------------------------------------------------------------------- 1308 Beschreibung: 1309 --------------------------------------------------------------------*/ 1310 1311 SfxTabPage* SwFldVarPage::Create( Window* pParent, 1312 const SfxItemSet& rAttrSet ) 1313 { 1314 return ( new SwFldVarPage( pParent, rAttrSet ) ); 1315 } 1316 1317 /*-------------------------------------------------------------------- 1318 Beschreibung: 1319 --------------------------------------------------------------------*/ 1320 1321 sal_uInt16 SwFldVarPage::GetGroup() 1322 { 1323 return GRP_VAR; 1324 } 1325 1326 /*-------------------------------------------------------------------- 1327 Beschreibung: 1328 --------------------------------------------------------------------*/ 1329 1330 SelectionListBox::SelectionListBox( SwFldVarPage* pDialog, const ResId& rResId ) : 1331 ListBox (pDialog, rResId), 1332 pDlg (pDialog), 1333 bCallAddSelection(sal_False) 1334 { 1335 } 1336 1337 /*-------------------------------------------------------------------- 1338 Beschreibung: 1339 --------------------------------------------------------------------*/ 1340 1341 long SelectionListBox::PreNotify( NotifyEvent& rNEvt ) 1342 { 1343 long nHandled = ListBox::PreNotify( rNEvt ); 1344 //sal_Bool bAddSel = sal_False; 1345 if ( rNEvt.GetType() == EVENT_KEYUP ) 1346 { 1347 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 1348 const KeyCode aKeyCode = pKEvt->GetKeyCode(); 1349 const sal_uInt16 nModifier = aKeyCode.GetModifier(); 1350 if( aKeyCode.GetCode() == KEY_SPACE && !nModifier) 1351 // bAddSel = sal_True; 1352 bCallAddSelection = sal_True; 1353 } 1354 if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) 1355 { 1356 const MouseEvent* pMEvt = rNEvt.GetMouseEvent(); 1357 1358 if (pMEvt && (pMEvt->IsMod1() || pMEvt->IsMod2())) // Alt oder Ctrl 1359 //bAddSel = sal_True; 1360 bCallAddSelection = sal_True; 1361 } 1362 1363 // if (bAddSel) 1364 // pDlg->AddSelection(this); 1365 1366 return nHandled; 1367 } 1368 /* -----------------12.01.99 11:14------------------- 1369 * 1370 * --------------------------------------------------*/ 1371 void SwFldVarPage::FillUserData() 1372 { 1373 String sData(String::CreateFromAscii(USER_DATA_VERSION)); 1374 sData += ';'; 1375 sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos(); 1376 if( LISTBOX_ENTRY_NOTFOUND == nTypeSel ) 1377 nTypeSel = USHRT_MAX; 1378 else 1379 nTypeSel = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData( nTypeSel ); 1380 sData += String::CreateFromInt32( nTypeSel ); 1381 SetUserData(sData); 1382 } 1383 1384