update dev300-m58
[ooovba.git] / sw / source / ui / fldui / DropDownFieldDialog.cxx
blobbaa268b27490b02c9f95af96afcbbba8c8a2fb0f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DropDownFieldDialog.cxx,v $
10 * $Revision: 1.9 $
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
36 #endif
39 #include <wrtsh.hxx>
40 #include <fldbas.hxx>
41 #include <fldmgr.hxx>
42 #ifndef _MSGBOX_HXX
43 #include <vcl/msgbox.hxx>
44 #endif
45 #include <DropDownFieldDialog.hxx>
46 #include <flddropdown.hxx>
47 #ifndef _FLDUI_HRC
48 #include <fldui.hrc>
49 #endif
50 #ifndef _SW_DROPDOWNFIELDDIALOG_HRC
51 #include <DropDownFieldDialog.hrc>
52 #endif
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 )),
75 rSh( rS ),
76 pDropField(0)
78 Link aButtonLk = LINK(this, DropDownFieldDialog, ButtonHdl);
79 aEditPB.SetClickHdl(aButtonLk);
80 if( bNextButton )
82 aNextPB.Show();
83 aNextPB.SetClickHdl(aButtonLk);
85 else
87 long nDiff = aCancelPB.GetPosPixel().Y() - aOKPB.GetPosPixel().Y();
88 Point aPos = aHelpPB.GetPosPixel();
89 aPos.Y() -= nDiff;
90 aHelpPB.SetPosPixel(aPos);
92 if( RES_DROPDOWN == pField->GetTyp()->Which() )
95 pDropField = (SwDropDownField*)pField;
96 String sTitle = GetText();
97 sTitle += pDropField->GetPar2();
98 SetText(sTitle);
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();
110 FreeResource();
113 sw::DropDownFieldDialog::~DropDownFieldDialog()
117 /*--------------------------------------------------------------------
119 --------------------------------------------------------------------*/
121 void sw::DropDownFieldDialog::Apply()
123 if(pDropField)
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);
135 delete pCopy;
137 rSh.SetUndoNoResetModified();
138 rSh.EndAllAction();
142 /* -----------------17.06.2003 10:50-----------------
144 --------------------------------------------------*/
145 IMPL_LINK(sw::DropDownFieldDialog, ButtonHdl, PushButton*, pButton)
147 EndDialog(&aNextPB == pButton ? RET_OK : RET_YES );
148 return 0;