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 <vcl/svapp.hxx> 36 #include <flddat.hxx> 37 #include <docufld.hxx> 38 #ifndef _GLOBALS_HRC 39 #include <globals.hrc> 40 #endif 41 #include <chpfld.hxx> 42 #ifndef _FLDTDLG_HRC 43 #include <fldtdlg.hrc> 44 #endif 45 #ifndef _FLDUI_HRC 46 #include <fldui.hrc> 47 #endif 48 #ifndef _FLDDOK_HXX 49 #include <flddok.hxx> 50 #endif 51 #include <swmodule.hxx> 52 #ifndef _VIEW_HXX 53 #include <view.hxx> 54 #endif 55 #include <wrtsh.hxx> 56 #include <svl/zformat.hxx> 57 58 #include <index.hrc> 59 60 #define USER_DATA_VERSION_1 "1" 61 #define USER_DATA_VERSION USER_DATA_VERSION_1 62 63 /*-------------------------------------------------------------------- 64 Beschreibung: 65 --------------------------------------------------------------------*/ 66 67 SwFldDokPage::SwFldDokPage(Window* pWindow, const SfxItemSet& rCoreSet ) : 68 SwFldPage( pWindow, SW_RES( TP_FLD_DOK ), rCoreSet ), 69 70 aTypeFT (this, SW_RES(FT_DOKTYPE)), 71 aTypeLB (this, SW_RES(LB_DOKTYPE)), 72 aSelectionFT (this, SW_RES(FT_DOKSELECTION)), 73 aSelectionLB (this, SW_RES(LB_DOKSELECTION)), 74 aValueFT (this, SW_RES(FT_DOKVALUE)), 75 aValueED (this, SW_RES(ED_DOKVALUE)), 76 aLevelED (this, SW_RES(ED_DOKLEVEL)), 77 aDateOffsetED (this, SW_RES(ED_DOKDATEOFF)), 78 79 aFormatFT (this, SW_RES(FT_DOKFORMAT)), 80 aFormatLB (this, SW_RES(LB_DOKFORMAT)), 81 aNumFormatLB (this, SW_RES(LB_DOKNUMFORMAT)), 82 aFixedCB (this, SW_RES(CB_DOKFIXEDCONTENT)), 83 84 sDateOffset (SW_RES(STR_DOKDATEOFF)), 85 sTimeOffset (SW_RES(STR_DOKTIMEOFF)), 86 aRootOpened (SW_RES(BMP_DOKROOT_OPENED)), 87 aRootClosed (SW_RES(BMP_DOKROOT_CLOSED)) 88 { 89 FreeResource(); 90 91 aSelectionLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl)); 92 aFormatLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl)); 93 aNumFormatLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, NumFormatHdl)); 94 95 aLevelED.SetMax(MAXLEVEL); 96 aDateOffsetED.SetMin(LONG_MIN); 97 aDateOffsetED.SetMax(LONG_MAX); 98 //enable 'active' language selection 99 aNumFormatLB.SetShowLanguageControl(sal_True); 100 } 101 102 /*-------------------------------------------------------------------- 103 Beschreibung: 104 --------------------------------------------------------------------*/ 105 106 __EXPORT SwFldDokPage::~SwFldDokPage() 107 { 108 } 109 110 /*-------------------------------------------------------------------- 111 Beschreibung: 112 --------------------------------------------------------------------*/ 113 114 void __EXPORT SwFldDokPage::Reset(const SfxItemSet& ) 115 { 116 SavePos(&aTypeLB); 117 Init(); // Allgemeine initialisierung 118 119 // TypeListBox initialisieren 120 const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup()); 121 122 aTypeLB.SetUpdateMode(sal_False); 123 aTypeLB.Clear(); 124 125 sal_uInt16 nPos, nTypeId; 126 sal_Bool bPage = sal_False; 127 128 if (!IsFldEdit()) 129 { 130 // Typ-Listbox fuellen 131 for(short i = rRg.nStart; i < rRg.nEnd; ++i) 132 { 133 nTypeId = GetFldMgr().GetTypeId(i); 134 135 switch (nTypeId) 136 { 137 case TYP_PREVPAGEFLD: 138 case TYP_NEXTPAGEFLD: 139 case TYP_PAGENUMBERFLD: 140 if (!bPage) 141 { 142 nPos = aTypeLB.InsertEntry(SW_RESSTR(FMT_REF_PAGE)); 143 aTypeLB.SetEntryData(nPos, (void*)USHRT_MAX); 144 bPage = sal_True; 145 } 146 break; 147 148 default: 149 nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i)); 150 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); 151 break; 152 } 153 } 154 } 155 else 156 { 157 const SwField* pCurField = GetCurField(); 158 nTypeId = pCurField->GetTypeId(); 159 if (nTypeId == TYP_FIXDATEFLD) 160 nTypeId = TYP_DATEFLD; 161 if (nTypeId == TYP_FIXTIMEFLD) 162 nTypeId = TYP_TIMEFLD; 163 nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId))); 164 aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); 165 aNumFormatLB.SetAutomaticLanguage(pCurField->IsAutomaticLanguage()); 166 SwWrtShell *pSh = GetWrtShell(); 167 if(!pSh) 168 pSh = ::GetActiveWrtShell(); 169 if(pSh) 170 { 171 const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat()); 172 if(pFormat) 173 aNumFormatLB.SetLanguage(pFormat->GetLanguage()); 174 } 175 } 176 177 // alte Pos selektieren 178 RestorePos(&aTypeLB); 179 180 aTypeLB.SetUpdateMode(sal_True); 181 aTypeLB.SetDoubleClickHdl(LINK(this, SwFldDokPage, InsertHdl)); 182 aTypeLB.SetSelectHdl(LINK(this, SwFldDokPage, TypeHdl)); 183 aFormatLB.SetSelectHdl(LINK(this, SwFldDokPage, FormatHdl)); 184 185 if( !IsRefresh() ) 186 { 187 String sUserData = GetUserData(); 188 if( sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1 )) 189 { 190 String sVal = sUserData.GetToken(1, ';'); 191 sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.ToInt32()); 192 if(nVal != USHRT_MAX) 193 { 194 for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++) 195 if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i)) 196 { 197 aTypeLB.SelectEntryPos(i); 198 break; 199 } 200 } 201 } 202 } 203 TypeHdl(0); 204 205 if (IsFldEdit()) 206 { 207 nOldSel = aSelectionLB.GetSelectEntryPos(); 208 nOldFormat = GetCurField()->GetFormat(); 209 aFixedCB.SaveValue(); 210 aValueED.SaveValue(); 211 aLevelED.SaveValue(); 212 aDateOffsetED.SaveValue(); 213 } 214 } 215 216 /*-------------------------------------------------------------------- 217 Beschreibung: 218 --------------------------------------------------------------------*/ 219 220 IMPL_LINK( SwFldDokPage, TypeHdl, ListBox *, EMPTYARG ) 221 { 222 // Alte ListBoxPos sichern 223 const sal_uInt16 nOld = GetTypeSel(); 224 225 // Aktuelle ListBoxPos 226 SetTypeSel(aTypeLB.GetSelectEntryPos()); 227 228 if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND) 229 { 230 SetTypeSel(0); 231 aTypeLB.SelectEntryPos(0); 232 } 233 234 sal_uInt16 nCount; 235 236 if (nOld != GetTypeSel()) 237 { 238 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 239 240 // Auswahl-Listbox fuellen 241 aSelectionLB.Clear(); 242 243 if (nTypeId != USHRT_MAX) 244 { 245 SvStringsDtor aLst; 246 GetFldMgr().GetSubTypes(nTypeId, aLst); 247 248 if (nTypeId != TYP_AUTHORFLD) 249 nCount = aLst.Count(); 250 else 251 nCount = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode()); 252 253 sal_uInt16 nPos; 254 255 for (sal_uInt16 i = 0; i < nCount; ++i) 256 { 257 if (!IsFldEdit()) 258 { 259 if (nTypeId != TYP_AUTHORFLD) 260 nPos = aSelectionLB.InsertEntry(*aLst[i]); 261 else 262 nPos = aSelectionLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i)); 263 264 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 265 } 266 else 267 { 268 sal_Bool bInsert = sal_False; 269 270 switch (nTypeId) 271 { 272 case TYP_DATEFLD: 273 case TYP_TIMEFLD: 274 nPos = aSelectionLB.InsertEntry(*aLst[i]); 275 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 276 if (((SwDateTimeField*)GetCurField())->IsFixed() && !i) 277 aSelectionLB.SelectEntryPos(nPos); 278 if (!((SwDateTimeField*)GetCurField())->IsFixed() && i) 279 aSelectionLB.SelectEntryPos(nPos); 280 break; 281 282 case TYP_EXTUSERFLD: 283 case TYP_DOCSTATFLD: 284 nPos = aSelectionLB.InsertEntry(*aLst[i]); 285 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 286 if (GetCurField()->GetSubType() == i) 287 aSelectionLB.SelectEntryPos(nPos); 288 break; 289 290 case TYP_AUTHORFLD: 291 { 292 String sFmt(GetFldMgr().GetFormatStr(nTypeId, i)); 293 nPos = aSelectionLB.InsertEntry(sFmt); 294 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 295 aSelectionLB.SelectEntry(GetFldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat())); 296 break; 297 } 298 299 default: 300 if (*aLst[i] == GetCurField()->GetPar1()) 301 bInsert = sal_True; 302 break; 303 } 304 if (bInsert) 305 { 306 nPos = aSelectionLB.InsertEntry(*aLst[i]); 307 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i)); 308 break; 309 } 310 } 311 } 312 aSelectionLB.SetSelectHdl(Link()); 313 } 314 else 315 { 316 AddSubType(TYP_PAGENUMBERFLD); 317 AddSubType(TYP_PREVPAGEFLD); 318 AddSubType(TYP_NEXTPAGEFLD); 319 nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(0); 320 nCount = 3; 321 aSelectionLB.SetSelectHdl(LINK(this, SwFldDokPage, SubTypeHdl)); 322 } 323 324 sal_Bool bEnable = nCount != 0; 325 326 if (bEnable && !aSelectionLB.GetSelectEntryCount()) 327 aSelectionLB.SelectEntryPos(0); 328 329 aSelectionLB.Enable( bEnable ); 330 aSelectionFT.Enable( bEnable ); 331 332 // Format-Listbox fuellen 333 sal_uInt16 nSize = FillFormatLB(nTypeId); 334 335 sal_Bool bValue = sal_False, bLevel = sal_False, bNumFmt = sal_False, bOffset = sal_False; 336 sal_Bool bFormat = nSize != 0; 337 sal_Bool bOneArea = sal_False; 338 sal_Bool bFixed = sal_False; 339 sal_uInt16 nFmtType = 0; 340 341 switch (nTypeId) 342 { 343 case TYP_DATEFLD: 344 bFormat = bNumFmt = bOneArea = bOffset = sal_True; 345 346 nFmtType = NUMBERFORMAT_DATE; 347 aValueFT.SetText(sDateOffset); 348 aDateOffsetED.SetFirst(-31); // Ein Monat 349 aDateOffsetED.SetLast(31); 350 351 if (IsFldEdit()) 352 aDateOffsetED.SetValue( ((SwDateTimeField*)GetCurField())->GetOffset() / 24 / 60); 353 break; 354 355 case TYP_TIMEFLD: 356 bFormat = bNumFmt = bOneArea = bOffset = sal_True; 357 358 nFmtType = NUMBERFORMAT_TIME; 359 aValueFT.SetText(sTimeOffset); 360 aDateOffsetED.SetFirst(-1440); // Ein Tag 361 aDateOffsetED.SetLast(1440); 362 363 if (IsFldEdit()) 364 aDateOffsetED.SetValue( ((SwDateTimeField*)GetCurField())->GetOffset() ); 365 break; 366 367 case TYP_PREVPAGEFLD: 368 case TYP_NEXTPAGEFLD: 369 if (IsFldEdit()) 370 { 371 sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData( 372 aFormatLB.GetSelectEntryPos() ); 373 String sOldTxt(aValueFT.GetText()); 374 375 if(SVX_NUM_CHAR_SPECIAL != nTmp) 376 { 377 sal_Int32 nOff = GetCurField()->GetPar2().ToInt32(); 378 if( TYP_NEXTPAGEFLD == nTypeId && 1 != nOff ) 379 aValueED.SetText( 380 String::CreateFromInt32(nOff - 1) ); 381 else if( TYP_PREVPAGEFLD == nTypeId && -1 != nOff ) 382 aValueED.SetText( 383 String::CreateFromInt32(nOff + 1) ); 384 else 385 aValueED.SetText(aEmptyStr); 386 } 387 else 388 aValueED.SetText(((SwPageNumberField*)GetCurField())->GetUserString()); 389 } 390 bValue = sal_True; 391 break; 392 393 case TYP_CHAPTERFLD: 394 aValueFT.SetText(SW_RESSTR(STR_LEVEL)); 395 if (IsFldEdit()) 396 aLevelED.SetText(String::CreateFromInt32(((SwChapterField*)GetCurField())->GetLevel() + 1)); 397 bLevel = sal_True; 398 break; 399 400 case TYP_PAGENUMBERFLD: 401 aValueFT.SetText( SW_RESSTR( STR_OFFSET )); 402 if (IsFldEdit()) 403 aValueED.SetText(GetCurField()->GetPar2()); 404 bValue = sal_True; 405 break; 406 407 case TYP_EXTUSERFLD: 408 case TYP_AUTHORFLD: 409 case TYP_FILENAMEFLD: 410 bFixed = sal_True; 411 break; 412 413 default: 414 break; 415 } 416 417 if (bNumFmt) 418 { 419 if (IsFldEdit()) 420 { 421 aNumFormatLB.SetDefFormat(GetCurField()->GetFormat()); 422 423 if (aNumFormatLB.GetFormatType() == (NUMBERFORMAT_DATE|NUMBERFORMAT_TIME)) 424 { 425 // Format-Typ immer einstellen, da sonst bei kombinierten Datum/Zeitformaten 426 // beide Formate gleichzeitig angezeigt werden wuerden 427 aNumFormatLB.SetFormatType(0); 428 aNumFormatLB.SetFormatType(nFmtType); 429 // Nochmal richtiges Format einstellen 430 aNumFormatLB.SetDefFormat(GetCurField()->GetFormat()); 431 } 432 } 433 else 434 aNumFormatLB.SetFormatType(nFmtType); 435 436 aNumFormatLB.SetOneArea(bOneArea); 437 } 438 439 aFormatLB.Show(!bNumFmt); 440 aNumFormatLB.Show(bNumFmt); 441 442 Size aSz(aFormatLB.GetSizePixel()); 443 444 if (bValue | bLevel | bOffset) 445 aSz.Height() = aFormatLB.LogicToPixel(Size(1, 137), MAP_APPFONT).Height(); 446 else 447 aSz.Height() = aFormatLB.LogicToPixel(Size(1, 152), MAP_APPFONT).Height(); 448 449 aValueFT.Show(bValue | bLevel | bOffset); 450 aValueED.Show(bValue); 451 aLevelED.Show(bLevel); 452 aDateOffsetED.Show(bOffset); 453 aFixedCB.Show(!bValue && !bLevel && !bOffset); 454 455 aFormatLB.SetSizePixel(aSz); 456 aNumFormatLB.SetSizePixel(aSz); 457 458 aFormatLB.Enable(bFormat); 459 aFormatFT.Enable(bFormat); 460 aFixedCB.Enable(bFixed); 461 462 if (IsFldEdit()) 463 aFixedCB.Check( static_cast< sal_Bool >(((GetCurField()->GetFormat() & AF_FIXED) != 0) & bFixed)); 464 465 if (aNumFormatLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) 466 aNumFormatLB.SelectEntryPos(0); 467 aValueFT.Enable(bValue | bLevel | bOffset); 468 aValueED.Enable(bValue); 469 } 470 471 return 0; 472 } 473 474 /*-------------------------------------------------------------------- 475 Beschreibung: 476 --------------------------------------------------------------------*/ 477 478 void SwFldDokPage::AddSubType(sal_uInt16 nTypeId) 479 { 480 sal_uInt16 nPos = aSelectionLB.InsertEntry(SwFieldType::GetTypeStr(nTypeId)); 481 aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId)); 482 } 483 484 /*-------------------------------------------------------------------- 485 Beschreibung: 486 --------------------------------------------------------------------*/ 487 488 IMPL_LINK( SwFldDokPage, SubTypeHdl, ListBox *, EMPTYARG ) 489 { 490 sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos(); 491 if(nPos == LISTBOX_ENTRY_NOTFOUND) 492 nPos = 0; 493 494 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos); 495 FillFormatLB(nTypeId); 496 497 sal_uInt16 nTextRes = 0; 498 switch (nTypeId) 499 { 500 case TYP_CHAPTERFLD: 501 nTextRes = STR_LEVEL; 502 break; 503 504 case TYP_PREVPAGEFLD: 505 case TYP_NEXTPAGEFLD: 506 nTextRes = SVX_NUM_CHAR_SPECIAL == (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData( 507 aFormatLB.GetSelectEntryPos() ) 508 ? STR_VALUE : STR_OFFSET; 509 break; 510 511 case TYP_PAGENUMBERFLD: 512 nTextRes = STR_OFFSET; 513 break; 514 } 515 516 if( nTextRes ) 517 aValueFT.SetText( SW_RESSTR( nTextRes )); 518 519 return 0; 520 } 521 522 /*-------------------------------------------------------------------- 523 Beschreibung: 524 --------------------------------------------------------------------*/ 525 526 sal_uInt16 SwFldDokPage::FillFormatLB(sal_uInt16 nTypeId) 527 { 528 // Format-Listbox fuellen 529 aFormatLB.Clear(); 530 531 if (nTypeId == TYP_AUTHORFLD) 532 return aFormatLB.GetEntryCount(); 533 534 sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode()); 535 536 for( sal_uInt16 i = 0; i < nSize; ++i ) 537 { 538 sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i)); 539 sal_uInt16 nFmtId = GetFldMgr().GetFormatId( nTypeId, i ); 540 aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>( nFmtId )); 541 if (IsFldEdit() && nFmtId == (GetCurField()->GetFormat() & ~AF_FIXED)) 542 aFormatLB.SelectEntryPos( nPos ); 543 } 544 545 if( nSize && !aFormatLB.GetSelectEntryCount() ) 546 { 547 aFormatLB.SelectEntry( SW_RESSTR(FMT_NUM_PAGEDESC) ); 548 if( !aFormatLB.GetSelectEntryCount() ) 549 { 550 aFormatLB.SelectEntry( SW_RESSTR(FMT_NUM_ARABIC) ); 551 if( !aFormatLB.GetSelectEntryCount() ) 552 aFormatLB.SelectEntryPos( 0 ); 553 } 554 } 555 556 FormatHdl(); 557 558 return nSize; 559 } 560 561 /*-------------------------------------------------------------------- 562 Beschreibung: 563 --------------------------------------------------------------------*/ 564 565 IMPL_LINK( SwFldDokPage, FormatHdl, ListBox *, EMPTYARG ) 566 { 567 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 568 569 if (nTypeId == USHRT_MAX) 570 { 571 sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos(); 572 if(nPos == LISTBOX_ENTRY_NOTFOUND) 573 nPos = 0; 574 575 nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos); 576 } 577 578 if (nTypeId == TYP_NEXTPAGEFLD || nTypeId == TYP_PREVPAGEFLD) 579 { 580 // Prev/Next - PageNumFelder Sonderbehandlung: 581 sal_uInt16 nTmp = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData( 582 aFormatLB.GetSelectEntryPos() ); 583 String sOldTxt( aValueFT.GetText() ); 584 String sNewTxt( SW_RES( SVX_NUM_CHAR_SPECIAL == nTmp ? STR_VALUE 585 : STR_OFFSET )); 586 587 if( sOldTxt != sNewTxt ) 588 aValueFT.SetText( sNewTxt ); 589 590 if (sOldTxt != aValueFT.GetText()) 591 aValueED.SetText( aEmptyStr ); 592 } 593 594 return 0; 595 } 596 597 /*-------------------------------------------------------------------- 598 Beschreibung: 599 --------------------------------------------------------------------*/ 600 601 sal_Bool __EXPORT SwFldDokPage::FillItemSet(SfxItemSet& ) 602 { 603 sal_Bool bPage = sal_False; 604 sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel()); 605 606 if (nTypeId == USHRT_MAX) 607 { 608 sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos(); 609 if(nPos == LISTBOX_ENTRY_NOTFOUND) 610 nPos = 0; 611 nTypeId = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos); 612 bPage = sal_True; 613 } 614 615 String aVal(aValueED.GetText()); 616 sal_uLong nFormat = 0; 617 sal_uInt16 nSubType = 0; 618 619 if (aFormatLB.IsEnabled()) 620 { 621 sal_uInt16 nPos = aFormatLB.GetSelectEntryPos(); 622 if(nPos != LISTBOX_ENTRY_NOTFOUND) 623 nFormat = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(nPos); 624 } 625 626 if (aSelectionLB.IsEnabled()) 627 { 628 sal_uInt16 nPos = aSelectionLB.GetSelectEntryPos(); 629 if(nPos != LISTBOX_ENTRY_NOTFOUND) 630 nSubType = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nPos); 631 } 632 633 switch (nTypeId) 634 { 635 case TYP_AUTHORFLD: 636 nFormat = nSubType; 637 nSubType = 0; 638 // kein break! 639 case TYP_EXTUSERFLD: 640 nFormat |= aFixedCB.IsChecked() ? AF_FIXED : 0; 641 break; 642 643 case TYP_FILENAMEFLD: 644 nFormat |= aFixedCB.IsChecked() ? FF_FIXED : 0; 645 break; 646 647 case TYP_DATEFLD: 648 case TYP_TIMEFLD: 649 { 650 nFormat = aNumFormatLB.GetFormat(); 651 long nVal = static_cast< long >(aDateOffsetED.GetValue()); 652 if (nTypeId == TYP_DATEFLD) 653 aVal = String::CreateFromInt32(nVal * 60 * 24); 654 else 655 aVal = String::CreateFromInt32(nVal); 656 break; 657 } 658 659 case TYP_NEXTPAGEFLD: 660 case TYP_PREVPAGEFLD: 661 case TYP_PAGENUMBERFLD: 662 case TYP_GETREFPAGEFLD: 663 { 664 if( SVX_NUM_CHAR_SPECIAL != nFormat && 665 (TYP_PREVPAGEFLD == nTypeId || TYP_NEXTPAGEFLD == nTypeId)) 666 { 667 sal_Int32 nVal = aValueED.GetText().ToInt32(); 668 aVal = String::CreateFromInt32(nVal); 669 } 670 break; 671 } 672 673 case TYP_CHAPTERFLD: 674 aVal = aLevelED.GetText(); 675 break; 676 677 default: 678 break; 679 } 680 681 if (!IsFldEdit() || 682 nOldSel != aSelectionLB.GetSelectEntryPos() || 683 nOldFormat != nFormat || 684 aFixedCB.GetState() != aFixedCB.GetSavedValue() || 685 aValueED.GetText() != aValueED.GetSavedValue() || 686 aLevelED.GetText() != aLevelED.GetSavedValue() || 687 aDateOffsetED.GetText() != aDateOffsetED.GetSavedValue()) 688 { 689 InsertFld( nTypeId, nSubType, aEmptyStr, aVal, nFormat, ' ', aNumFormatLB.IsAutomaticLanguage() ); 690 } 691 692 return sal_False; 693 } 694 695 /*-------------------------------------------------------------------- 696 Beschreibung: 697 --------------------------------------------------------------------*/ 698 699 SfxTabPage* __EXPORT SwFldDokPage::Create( Window* pParent, 700 const SfxItemSet& rAttrSet ) 701 { 702 return ( new SwFldDokPage( pParent, rAttrSet ) ); 703 } 704 705 /*-------------------------------------------------------------------- 706 Beschreibung: 707 --------------------------------------------------------------------*/ 708 709 sal_uInt16 SwFldDokPage::GetGroup() 710 { 711 return GRP_DOC; 712 } 713 714 /* -----------------12.01.99 10:09------------------- 715 * 716 * --------------------------------------------------*/ 717 void SwFldDokPage::FillUserData() 718 { 719 String sData( String::CreateFromAscii( 720 RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION ))); 721 sData += ';'; 722 sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos(); 723 if( LISTBOX_ENTRY_NOTFOUND == nTypeSel ) 724 nTypeSel = USHRT_MAX; 725 else 726 nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel ))); 727 sData += String::CreateFromInt32( nTypeSel ); 728 SetUserData(sData); 729 } 730 731 732