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