1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <vcl/msgbox.hxx> 32cdf0e10cSrcweir #include <unotools/charclass.hxx> 33cdf0e10cSrcweir #include <editeng/unolingu.hxx> 34cdf0e10cSrcweir #include <wrtsh.hxx> 35cdf0e10cSrcweir #include <fldbas.hxx> 36cdf0e10cSrcweir #include <expfld.hxx> 37cdf0e10cSrcweir #include <usrfld.hxx> 38cdf0e10cSrcweir #include <inpdlg.hxx> 39cdf0e10cSrcweir #include <fldmgr.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <fldui.hrc> 42cdf0e10cSrcweir #include <inpdlg.hrc> 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir /*-------------------------------------------------------------------- 46cdf0e10cSrcweir Beschreibung: Feldeinfuegen bearbeiten 47cdf0e10cSrcweir --------------------------------------------------------------------*/ 48cdf0e10cSrcweir 49cdf0e10cSrcweir SwFldInputDlg::SwFldInputDlg( Window *pParent, SwWrtShell &rS, 50cdf0e10cSrcweir SwField* pField, sal_Bool bNextButton ) : 51cdf0e10cSrcweir 52cdf0e10cSrcweir SvxStandardDialog(pParent, SW_RES(DLG_FLD_INPUT)), 53cdf0e10cSrcweir 54cdf0e10cSrcweir rSh( rS ), 55cdf0e10cSrcweir pInpFld(0), 56cdf0e10cSrcweir pSetFld(0), 57cdf0e10cSrcweir pUsrType(0), 58cdf0e10cSrcweir 59cdf0e10cSrcweir aLabelED (this, SW_RES(ED_LABEL )), 60cdf0e10cSrcweir aEditED (this, SW_RES(ED_EDIT )), 61cdf0e10cSrcweir aEditFL (this, SW_RES(FL_EDIT )), 62cdf0e10cSrcweir 63cdf0e10cSrcweir aOKBT (this, SW_RES(BT_OK )), 64cdf0e10cSrcweir aCancelBT (this, SW_RES(BT_CANCEL )), 65cdf0e10cSrcweir aNextBT (this, SW_RES(PB_NEXT )), 66cdf0e10cSrcweir aHelpBT (this, SW_RES(PB_HELP )) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir // Font fuers Edit umschalten 69cdf0e10cSrcweir Font aFont(aEditED.GetFont()); 70cdf0e10cSrcweir aFont.SetWeight(WEIGHT_LIGHT); 71cdf0e10cSrcweir aEditED.SetFont(aFont); 72cdf0e10cSrcweir 73cdf0e10cSrcweir if( bNextButton ) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir aNextBT.Show(); 76cdf0e10cSrcweir aNextBT.SetClickHdl(LINK(this, SwFldInputDlg, NextHdl)); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir else 79cdf0e10cSrcweir { 80cdf0e10cSrcweir long nDiff = aCancelBT.GetPosPixel().Y() - aOKBT.GetPosPixel().Y(); 81cdf0e10cSrcweir Point aPos = aHelpBT.GetPosPixel(); 82cdf0e10cSrcweir aPos.Y() -= nDiff; 83cdf0e10cSrcweir aHelpBT.SetPosPixel(aPos); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir // Auswertung hier 87cdf0e10cSrcweir String aStr; 88cdf0e10cSrcweir if( RES_INPUTFLD == pField->GetTyp()->Which() ) 89cdf0e10cSrcweir { // Es ist eine Eingabefeld 90cdf0e10cSrcweir // 91cdf0e10cSrcweir pInpFld = (SwInputField*)pField; 92cdf0e10cSrcweir aLabelED.SetText( pInpFld->GetPar2() ); 93cdf0e10cSrcweir sal_uInt16 nSubType = pInpFld->GetSubType(); 94cdf0e10cSrcweir 95cdf0e10cSrcweir switch(nSubType & 0xff) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir case INP_TXT: 98cdf0e10cSrcweir aStr = pInpFld->GetPar1(); 99cdf0e10cSrcweir break; 100cdf0e10cSrcweir 101cdf0e10cSrcweir case INP_USR: 102cdf0e10cSrcweir // Benutzerfeld 103cdf0e10cSrcweir if( 0 != ( pUsrType = (SwUserFieldType*)rSh.GetFldType( 104cdf0e10cSrcweir RES_USERFLD, pInpFld->GetPar1() ) ) ) 105cdf0e10cSrcweir aStr = pUsrType->GetContent(); 106cdf0e10cSrcweir break; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir else 110cdf0e10cSrcweir { 111cdf0e10cSrcweir // es ist eine SetExpression 112cdf0e10cSrcweir pSetFld = (SwSetExpField*)pField; 113cdf0e10cSrcweir String sFormula(pSetFld->GetFormula()); 114cdf0e10cSrcweir //values are formatted - formulas are not 115cdf0e10cSrcweir CharClass aCC( SvxCreateLocale( pSetFld->GetLanguage() )); 116cdf0e10cSrcweir if( aCC.isNumeric( sFormula )) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir aStr = pSetFld->ExpandField(true); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir else 121cdf0e10cSrcweir aStr = sFormula; 122cdf0e10cSrcweir aLabelED.SetText( pSetFld->GetPromptText() ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir // JP 31.3.00: Inputfields in readonly regions must be allowed to 126cdf0e10cSrcweir // input any content. - 74639 127cdf0e10cSrcweir sal_Bool bEnable = !rSh.IsCrsrReadonly(); 128cdf0e10cSrcweir /*!rSh.IsReadOnlyAvailable() || !rSh.HasReadonlySel()*/; 129cdf0e10cSrcweir aOKBT.Enable( bEnable ); 130cdf0e10cSrcweir aEditED.SetReadOnly( !bEnable ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir if( aStr.Len() ) 133cdf0e10cSrcweir aEditED.SetText( aStr.ConvertLineEnd() ); 134cdf0e10cSrcweir FreeResource(); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir SwFldInputDlg::~SwFldInputDlg() 138cdf0e10cSrcweir { 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir void SwFldInputDlg::StateChanged( StateChangedType nType ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir if ( nType == STATE_CHANGE_INITSHOW ) 144cdf0e10cSrcweir aEditED.GrabFocus(); 145cdf0e10cSrcweir SvxStandardDialog::StateChanged( nType ); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir /*-------------------------------------------------------------------- 149cdf0e10cSrcweir Beschreibung: Schliessen 150cdf0e10cSrcweir --------------------------------------------------------------------*/ 151cdf0e10cSrcweir 152cdf0e10cSrcweir void SwFldInputDlg::Apply() 153cdf0e10cSrcweir { 154cdf0e10cSrcweir String aTmp( aEditED.GetText() ); 155cdf0e10cSrcweir aTmp.EraseAllChars( '\r' ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir rSh.StartAllAction(); 158cdf0e10cSrcweir sal_Bool bModified = sal_False; 159cdf0e10cSrcweir if(pInpFld) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir if(pUsrType) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir if( aTmp != pUsrType->GetContent() ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir pUsrType->SetContent(aTmp); 166cdf0e10cSrcweir pUsrType->UpdateFlds(); 167cdf0e10cSrcweir bModified = sal_True; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir else if( aTmp != pInpFld->GetPar1() ) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir pInpFld->SetPar1(aTmp); 173cdf0e10cSrcweir rSh.SwEditShell::UpdateFlds(*pInpFld); 174cdf0e10cSrcweir bModified = sal_True; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir else if( aTmp != pSetFld->GetPar2() ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir pSetFld->SetPar2(aTmp); 180cdf0e10cSrcweir rSh.SwEditShell::UpdateFlds(*pSetFld); 181cdf0e10cSrcweir bModified = sal_True; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir if( bModified ) 185cdf0e10cSrcweir rSh.SetUndoNoResetModified(); 186cdf0e10cSrcweir 187cdf0e10cSrcweir rSh.EndAllAction(); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir 191cdf0e10cSrcweir IMPL_LINK(SwFldInputDlg, NextHdl, PushButton*, EMPTYARG) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir EndDialog(RET_OK); 194cdf0e10cSrcweir return 0; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir 198