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