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