1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: inpdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
42 #ifndef _MSGBOX_HXX //autogen
43 #include <vcl/msgbox.hxx>
45 #include <unotools/charclass.hxx>
46 #include <svx/unolingu.hxx>
62 /*--------------------------------------------------------------------
63 Beschreibung: Feldeinfuegen bearbeiten
64 --------------------------------------------------------------------*/
66 SwFldInputDlg::SwFldInputDlg( Window
*pParent
, SwWrtShell
&rS
,
67 SwField
* pField
, BOOL bNextButton
) :
69 SvxStandardDialog(pParent
, SW_RES(DLG_FLD_INPUT
)),
76 aLabelED (this, SW_RES(ED_LABEL
)),
77 aEditED (this, SW_RES(ED_EDIT
)),
78 aEditFL (this, SW_RES(FL_EDIT
)),
80 aOKBT (this, SW_RES(BT_OK
)),
81 aCancelBT (this, SW_RES(BT_CANCEL
)),
82 aNextBT (this, SW_RES(PB_NEXT
)),
83 aHelpBT (this, SW_RES(PB_HELP
))
85 // Font fuers Edit umschalten
86 Font
aFont(aEditED
.GetFont());
87 aFont
.SetWeight(WEIGHT_LIGHT
);
88 aEditED
.SetFont(aFont
);
93 aNextBT
.SetClickHdl(LINK(this, SwFldInputDlg
, NextHdl
));
97 long nDiff
= aCancelBT
.GetPosPixel().Y() - aOKBT
.GetPosPixel().Y();
98 Point aPos
= aHelpBT
.GetPosPixel();
100 aHelpBT
.SetPosPixel(aPos
);
105 if( RES_INPUTFLD
== pField
->GetTyp()->Which() )
106 { // Es ist eine Eingabefeld
108 pInpFld
= (SwInputField
*)pField
;
109 aLabelED
.SetText( pInpFld
->GetPar2() );
110 USHORT nSubType
= pInpFld
->GetSubType();
112 switch(nSubType
& 0xff)
115 aStr
= pInpFld
->GetPar1();
120 if( 0 != ( pUsrType
= (SwUserFieldType
*)rSh
.GetFldType(
121 RES_USERFLD
, pInpFld
->GetPar1() ) ) )
122 aStr
= pUsrType
->GetContent();
128 // es ist eine SetExpression
129 pSetFld
= (SwSetExpField
*)pField
;
130 String
sFormula(pSetFld
->GetFormula());
131 //values are formatted - formulas are not
132 CharClass
aCC( SvxCreateLocale( pSetFld
->GetLanguage() ));
133 if( aCC
.isNumeric( sFormula
))
134 aStr
= pSetFld
->Expand();
137 aLabelED
.SetText( pSetFld
->GetPromptText() );
140 // JP 31.3.00: Inputfields in readonly regions must be allowed to
141 // input any content. - 74639
142 BOOL bEnable
= !rSh
.IsCrsrReadonly();
143 /*!rSh.IsReadOnlyAvailable() || !rSh.HasReadonlySel()*/;
144 aOKBT
.Enable( bEnable
);
145 aEditED
.SetReadOnly( !bEnable
);
148 aEditED
.SetText( aStr
.ConvertLineEnd() );
152 SwFldInputDlg::~SwFldInputDlg()
156 void SwFldInputDlg::StateChanged( StateChangedType nType
)
158 if ( nType
== STATE_CHANGE_INITSHOW
)
160 SvxStandardDialog::StateChanged( nType
);
163 /*--------------------------------------------------------------------
164 Beschreibung: Schliessen
165 --------------------------------------------------------------------*/
167 void SwFldInputDlg::Apply()
169 String
aTmp( aEditED
.GetText() );
170 aTmp
.EraseAllChars( '\r' );
172 rSh
.StartAllAction();
173 BOOL bModified
= FALSE
;
178 if( aTmp
!= pUsrType
->GetContent() )
180 pUsrType
->SetContent(aTmp
);
181 pUsrType
->UpdateFlds();
185 else if( aTmp
!= pInpFld
->GetPar1() )
187 pInpFld
->SetPar1(aTmp
);
188 rSh
.SwEditShell::UpdateFlds(*pInpFld
);
192 else if( aTmp
!= pSetFld
->GetPar2() )
194 pSetFld
->SetPar2(aTmp
);
195 rSh
.SwEditShell::UpdateFlds(*pSetFld
);
200 rSh
.SetUndoNoResetModified();
206 IMPL_LINK(SwFldInputDlg
, NextHdl
, PushButton
*, EMPTYARG
)