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