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 31*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 36*cdf0e10cSrcweir #include <unotools/charclass.hxx> 37*cdf0e10cSrcweir #include <editeng/unolingu.hxx> 38*cdf0e10cSrcweir #include <wrtsh.hxx> 39*cdf0e10cSrcweir #include <fldbas.hxx> 40*cdf0e10cSrcweir #include <expfld.hxx> 41*cdf0e10cSrcweir #include <usrfld.hxx> 42*cdf0e10cSrcweir #include <inpdlg.hxx> 43*cdf0e10cSrcweir #include <fldmgr.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <fldui.hrc> 46*cdf0e10cSrcweir #include <inpdlg.hrc> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir /*-------------------------------------------------------------------- 50*cdf0e10cSrcweir Beschreibung: Feldeinfuegen bearbeiten 51*cdf0e10cSrcweir --------------------------------------------------------------------*/ 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir SwFldInputDlg::SwFldInputDlg( Window *pParent, SwWrtShell &rS, 54*cdf0e10cSrcweir SwField* pField, sal_Bool bNextButton ) : 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir SvxStandardDialog(pParent, SW_RES(DLG_FLD_INPUT)), 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir rSh( rS ), 59*cdf0e10cSrcweir pInpFld(0), 60*cdf0e10cSrcweir pSetFld(0), 61*cdf0e10cSrcweir pUsrType(0), 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir aLabelED (this, SW_RES(ED_LABEL )), 64*cdf0e10cSrcweir aEditED (this, SW_RES(ED_EDIT )), 65*cdf0e10cSrcweir aEditFL (this, SW_RES(FL_EDIT )), 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir aOKBT (this, SW_RES(BT_OK )), 68*cdf0e10cSrcweir aCancelBT (this, SW_RES(BT_CANCEL )), 69*cdf0e10cSrcweir aNextBT (this, SW_RES(PB_NEXT )), 70*cdf0e10cSrcweir aHelpBT (this, SW_RES(PB_HELP )) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir // Font fuers Edit umschalten 73*cdf0e10cSrcweir Font aFont(aEditED.GetFont()); 74*cdf0e10cSrcweir aFont.SetWeight(WEIGHT_LIGHT); 75*cdf0e10cSrcweir aEditED.SetFont(aFont); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir if( bNextButton ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir aNextBT.Show(); 80*cdf0e10cSrcweir aNextBT.SetClickHdl(LINK(this, SwFldInputDlg, NextHdl)); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir else 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir long nDiff = aCancelBT.GetPosPixel().Y() - aOKBT.GetPosPixel().Y(); 85*cdf0e10cSrcweir Point aPos = aHelpBT.GetPosPixel(); 86*cdf0e10cSrcweir aPos.Y() -= nDiff; 87*cdf0e10cSrcweir aHelpBT.SetPosPixel(aPos); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // Auswertung hier 91*cdf0e10cSrcweir String aStr; 92*cdf0e10cSrcweir if( RES_INPUTFLD == pField->GetTyp()->Which() ) 93*cdf0e10cSrcweir { // Es ist eine Eingabefeld 94*cdf0e10cSrcweir // 95*cdf0e10cSrcweir pInpFld = (SwInputField*)pField; 96*cdf0e10cSrcweir aLabelED.SetText( pInpFld->GetPar2() ); 97*cdf0e10cSrcweir sal_uInt16 nSubType = pInpFld->GetSubType(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir switch(nSubType & 0xff) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir case INP_TXT: 102*cdf0e10cSrcweir aStr = pInpFld->GetPar1(); 103*cdf0e10cSrcweir break; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir case INP_USR: 106*cdf0e10cSrcweir // Benutzerfeld 107*cdf0e10cSrcweir if( 0 != ( pUsrType = (SwUserFieldType*)rSh.GetFldType( 108*cdf0e10cSrcweir RES_USERFLD, pInpFld->GetPar1() ) ) ) 109*cdf0e10cSrcweir aStr = pUsrType->GetContent(); 110*cdf0e10cSrcweir break; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir else 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir // es ist eine SetExpression 116*cdf0e10cSrcweir pSetFld = (SwSetExpField*)pField; 117*cdf0e10cSrcweir String sFormula(pSetFld->GetFormula()); 118*cdf0e10cSrcweir //values are formatted - formulas are not 119*cdf0e10cSrcweir CharClass aCC( SvxCreateLocale( pSetFld->GetLanguage() )); 120*cdf0e10cSrcweir if( aCC.isNumeric( sFormula )) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir aStr = pSetFld->ExpandField(true); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir else 125*cdf0e10cSrcweir aStr = sFormula; 126*cdf0e10cSrcweir aLabelED.SetText( pSetFld->GetPromptText() ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // JP 31.3.00: Inputfields in readonly regions must be allowed to 130*cdf0e10cSrcweir // input any content. - 74639 131*cdf0e10cSrcweir sal_Bool bEnable = !rSh.IsCrsrReadonly(); 132*cdf0e10cSrcweir /*!rSh.IsReadOnlyAvailable() || !rSh.HasReadonlySel()*/; 133*cdf0e10cSrcweir aOKBT.Enable( bEnable ); 134*cdf0e10cSrcweir aEditED.SetReadOnly( !bEnable ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if( aStr.Len() ) 137*cdf0e10cSrcweir aEditED.SetText( aStr.ConvertLineEnd() ); 138*cdf0e10cSrcweir FreeResource(); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir SwFldInputDlg::~SwFldInputDlg() 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir void SwFldInputDlg::StateChanged( StateChangedType nType ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir if ( nType == STATE_CHANGE_INITSHOW ) 148*cdf0e10cSrcweir aEditED.GrabFocus(); 149*cdf0e10cSrcweir SvxStandardDialog::StateChanged( nType ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir /*-------------------------------------------------------------------- 153*cdf0e10cSrcweir Beschreibung: Schliessen 154*cdf0e10cSrcweir --------------------------------------------------------------------*/ 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir void SwFldInputDlg::Apply() 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir String aTmp( aEditED.GetText() ); 159*cdf0e10cSrcweir aTmp.EraseAllChars( '\r' ); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir rSh.StartAllAction(); 162*cdf0e10cSrcweir sal_Bool bModified = sal_False; 163*cdf0e10cSrcweir if(pInpFld) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir if(pUsrType) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir if( aTmp != pUsrType->GetContent() ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir pUsrType->SetContent(aTmp); 170*cdf0e10cSrcweir pUsrType->UpdateFlds(); 171*cdf0e10cSrcweir bModified = sal_True; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir else if( aTmp != pInpFld->GetPar1() ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir pInpFld->SetPar1(aTmp); 177*cdf0e10cSrcweir rSh.SwEditShell::UpdateFlds(*pInpFld); 178*cdf0e10cSrcweir bModified = sal_True; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir else if( aTmp != pSetFld->GetPar2() ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir pSetFld->SetPar2(aTmp); 184*cdf0e10cSrcweir rSh.SwEditShell::UpdateFlds(*pSetFld); 185*cdf0e10cSrcweir bModified = sal_True; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir if( bModified ) 189*cdf0e10cSrcweir rSh.SetUndoNoResetModified(); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir rSh.EndAllAction(); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir IMPL_LINK(SwFldInputDlg, NextHdl, PushButton*, EMPTYARG) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir EndDialog(RET_OK); 198*cdf0e10cSrcweir return 0; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir 202