Files
libreoffice/sw/source/ui/fldui/DropDownFieldDialog.cxx
Rüdiger Timm fd965b6613 INTEGRATION: CWS residcleanup (1.6.240); FILE MERGED
2007/03/04 17:03:02 pl 1.6.240.1: #i73635# ResId cleanup
2007-04-26 08:09:08 +00:00

163 lines
4.8 KiB
C++

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: DropDownFieldDialog.cxx,v $
*
* $Revision: 1.7 $
*
* last change: $Author: rt $ $Date: 2007-04-26 09:09:08 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>
#endif
#ifndef _FLDBAS_HXX
#include <fldbas.hxx>
#endif
#ifndef _FLDMGR_HXX
#include <fldmgr.hxx>
#endif
#ifndef _MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _SW_DROPDOWNFIELDDIALOG_HXX
#include <DropDownFieldDialog.hxx>
#endif
#ifndef _FLDDROPDOWN_HXX
#include <flddropdown.hxx>
#endif
#ifndef _FLDUI_HRC
#include <fldui.hrc>
#endif
#ifndef _SW_DROPDOWNFIELDDIALOG_HRC
#include <DropDownFieldDialog.hrc>
#endif
using com::sun::star::uno::Sequence;
/*--------------------------------------------------------------------
Beschreibung: Feldeinfuegen bearbeiten
--------------------------------------------------------------------*/
sw::DropDownFieldDialog::DropDownFieldDialog( Window *pParent, SwWrtShell &rS,
SwField* pField, BOOL bNextButton ) :
SvxStandardDialog(pParent, SW_RES(DLG_FLD_DROPDOWN)),
aItemsFL( this, SW_RES( FL_ITEMS )),
aListItemsLB( this, SW_RES( LB_LISTITEMS )),
aOKPB( this, SW_RES( PB_OK )),
aCancelPB( this, SW_RES( PB_CANCEL )),
aNextPB( this, SW_RES( PB_NEXT )),
aHelpPB( this, SW_RES( PB_HELP )),
aEditPB( this, SW_RES( PB_EDIT )),
pDropField(0),
rSh( rS )
{
Link aButtonLk = LINK(this, DropDownFieldDialog, ButtonHdl);
aEditPB.SetClickHdl(aButtonLk);
if( bNextButton )
{
aNextPB.Show();
aNextPB.SetClickHdl(aButtonLk);
}
else
{
long nDiff = aCancelPB.GetPosPixel().Y() - aOKPB.GetPosPixel().Y();
Point aPos = aHelpPB.GetPosPixel();
aPos.Y() -= nDiff;
aHelpPB.SetPosPixel(aPos);
}
if( RES_DROPDOWN == pField->GetTyp()->Which() )
{
//
pDropField = (SwDropDownField*)pField;
String sTitle = GetText();
sTitle += pDropField->GetPar2();
SetText(sTitle);
Sequence<rtl::OUString> aItems = pDropField->GetItemSequence();
const rtl::OUString* pArray = aItems.getConstArray();
for(sal_Int32 i = 0; i < aItems.getLength(); i++)
aListItemsLB.InsertEntry(pArray[i]);
aListItemsLB.SelectEntry(pDropField->GetSelectedItem());
}
BOOL bEnable = !rSh.IsCrsrReadonly();
aOKPB.Enable( bEnable );
aListItemsLB.GrabFocus();
FreeResource();
}
sw::DropDownFieldDialog::~DropDownFieldDialog()
{
}
/*--------------------------------------------------------------------
--------------------------------------------------------------------*/
void sw::DropDownFieldDialog::Apply()
{
if(pDropField)
{
String sSelect = aListItemsLB.GetSelectEntry();
if(pDropField->GetPar1() != sSelect)
{
rSh.StartAllAction();
SwDropDownField * pCopy = (SwDropDownField *) pDropField->Copy();
pCopy->SetPar1(sSelect);
rSh.SwEditShell::UpdateFlds(*pCopy);
delete pCopy;
rSh.SetUndoNoResetModified();
rSh.EndAllAction();
}
}
}
/* -----------------17.06.2003 10:50-----------------
--------------------------------------------------*/
IMPL_LINK(sw::DropDownFieldDialog, ButtonHdl, PushButton*, pButton)
{
EndDialog(&aNextPB == pButton ? RET_OK : RET_YES );
return 0;
}