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