bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / fldui / DropDownFieldDialog.cxx
blobfdebcbb6aa6a7287ac8f521a689aaadcdfe73c3d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <wrtsh.hxx>
21 #include <fldbas.hxx>
22 #include <fldmgr.hxx>
23 #include <vcl/msgbox.hxx>
24 #include <DropDownFieldDialog.hxx>
25 #include <flddropdown.hxx>
26 #include <fldui.hrc>
28 using namespace ::com::sun::star;
31 /*--------------------------------------------------------------------
32 Description: edit insert-field
33 --------------------------------------------------------------------*/
34 sw::DropDownFieldDialog::DropDownFieldDialog(Window *pParent, SwWrtShell &rS,
35 SwField* pField, sal_Bool bNextButton)
36 : SvxStandardDialog(pParent, "DropdownFieldDialog",
37 "modules/swriter/ui/dropdownfielddialog.ui")
38 , rSh( rS )
39 , pDropField(0)
41 get(m_pListItemsLB, "list");
42 m_pListItemsLB->SetDropDownLineCount(12);
43 m_pListItemsLB->set_width_request(m_pListItemsLB->approximate_char_width()*32);
44 get(m_pOKPB, "ok");
45 get(m_pNextPB, "next");
46 get(m_pEditPB, "edit");
48 Link aButtonLk = LINK(this, DropDownFieldDialog, ButtonHdl);
49 m_pEditPB->SetClickHdl(aButtonLk);
50 if( bNextButton )
52 m_pNextPB->Show();
53 m_pNextPB->SetClickHdl(aButtonLk);
55 if( RES_DROPDOWN == pField->GetTyp()->Which() )
58 pDropField = (SwDropDownField*)pField;
59 String sTitle = GetText();
60 sTitle += pDropField->GetPar2();
61 SetText(sTitle);
62 uno::Sequence< OUString > aItems = pDropField->GetItemSequence();
63 const OUString* pArray = aItems.getConstArray();
64 for(sal_Int32 i = 0; i < aItems.getLength(); i++)
65 m_pListItemsLB->InsertEntry(pArray[i]);
66 m_pListItemsLB->SelectEntry(pDropField->GetSelectedItem());
69 sal_Bool bEnable = !rSh.IsCrsrReadonly();
70 m_pOKPB->Enable( bEnable );
72 m_pListItemsLB->GrabFocus();
75 void sw::DropDownFieldDialog::Apply()
77 if(pDropField)
79 OUString sSelect = m_pListItemsLB->GetSelectEntry();
80 if(pDropField->GetPar1() != sSelect)
82 rSh.StartAllAction();
84 ::std::auto_ptr<SwDropDownField> const pCopy(
85 static_cast<SwDropDownField *>( pDropField->CopyField() ) );
87 pCopy->SetPar1(sSelect);
88 rSh.SwEditShell::UpdateFlds(*pCopy);
90 rSh.SetUndoNoResetModified();
91 rSh.EndAllAction();
96 IMPL_LINK(sw::DropDownFieldDialog, ButtonHdl, PushButton*, pButton)
98 EndDialog(m_pNextPB == pButton ? RET_OK : RET_YES );
99 return 0;
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */