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: DropDownFieldDialog.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
43 #include <vcl/msgbox.hxx>
45 #include <DropDownFieldDialog.hxx>
46 #include <flddropdown.hxx>
50 #ifndef _SW_DROPDOWNFIELDDIALOG_HRC
51 #include <DropDownFieldDialog.hrc>
54 using namespace ::com::sun::star
;
57 /*--------------------------------------------------------------------
58 Beschreibung: Feldeinfuegen bearbeiten
59 --------------------------------------------------------------------*/
61 sw::DropDownFieldDialog::DropDownFieldDialog( Window
*pParent
, SwWrtShell
&rS
,
62 SwField
* pField
, BOOL bNextButton
) :
64 SvxStandardDialog(pParent
, SW_RES(DLG_FLD_DROPDOWN
)),
65 aItemsFL( this, SW_RES( FL_ITEMS
)),
66 aListItemsLB( this, SW_RES( LB_LISTITEMS
)),
68 aOKPB( this, SW_RES( PB_OK
)),
69 aCancelPB( this, SW_RES( PB_CANCEL
)),
70 aNextPB( this, SW_RES( PB_NEXT
)),
71 aHelpPB( this, SW_RES( PB_HELP
)),
73 aEditPB( this, SW_RES( PB_EDIT
)),
78 Link aButtonLk
= LINK(this, DropDownFieldDialog
, ButtonHdl
);
79 aEditPB
.SetClickHdl(aButtonLk
);
83 aNextPB
.SetClickHdl(aButtonLk
);
87 long nDiff
= aCancelPB
.GetPosPixel().Y() - aOKPB
.GetPosPixel().Y();
88 Point aPos
= aHelpPB
.GetPosPixel();
90 aHelpPB
.SetPosPixel(aPos
);
92 if( RES_DROPDOWN
== pField
->GetTyp()->Which() )
95 pDropField
= (SwDropDownField
*)pField
;
96 String sTitle
= GetText();
97 sTitle
+= pDropField
->GetPar2();
99 uno::Sequence
< rtl::OUString
> aItems
= pDropField
->GetItemSequence();
100 const rtl::OUString
* pArray
= aItems
.getConstArray();
101 for(sal_Int32 i
= 0; i
< aItems
.getLength(); i
++)
102 aListItemsLB
.InsertEntry(pArray
[i
]);
103 aListItemsLB
.SelectEntry(pDropField
->GetSelectedItem());
106 BOOL bEnable
= !rSh
.IsCrsrReadonly();
107 aOKPB
.Enable( bEnable
);
109 aListItemsLB
.GrabFocus();
113 sw::DropDownFieldDialog::~DropDownFieldDialog()
117 /*--------------------------------------------------------------------
119 --------------------------------------------------------------------*/
121 void sw::DropDownFieldDialog::Apply()
125 String sSelect
= aListItemsLB
.GetSelectEntry();
126 if(pDropField
->GetPar1() != sSelect
)
128 rSh
.StartAllAction();
130 SwDropDownField
* pCopy
= (SwDropDownField
*) pDropField
->Copy();
132 pCopy
->SetPar1(sSelect
);
133 rSh
.SwEditShell::UpdateFlds(*pCopy
);
137 rSh
.SetUndoNoResetModified();
142 /* -----------------17.06.2003 10:50-----------------
144 --------------------------------------------------*/
145 IMPL_LINK(sw::DropDownFieldDialog
, ButtonHdl
, PushButton
*, pButton
)
147 EndDialog(&aNextPB
== pButton
? RET_OK
: RET_YES
);