LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/fldui - DropDownFieldDialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 43 0.0 %
Date: 2012-12-27 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      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>
      27             : #include <DropDownFieldDialog.hrc>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31             : 
      32             : /*--------------------------------------------------------------------
      33             :     Description: edit insert-field
      34             :  --------------------------------------------------------------------*/
      35           0 : sw::DropDownFieldDialog::DropDownFieldDialog( Window *pParent, SwWrtShell &rS,
      36             :                               SwField* pField, sal_Bool bNextButton ) :
      37             : 
      38             :     SvxStandardDialog(pParent,  SW_RES(DLG_FLD_DROPDOWN)),
      39             :     aItemsFL(       this, SW_RES( FL_ITEMS       )),
      40             :     aListItemsLB(   this, SW_RES( LB_LISTITEMS   )),
      41             : 
      42             :     aOKPB(          this, SW_RES( PB_OK          )),
      43             :     aCancelPB(      this, SW_RES( PB_CANCEL      )),
      44             :     aNextPB(        this, SW_RES( PB_NEXT        )),
      45             :     aHelpPB(        this, SW_RES( PB_HELP        )),
      46             : 
      47             :     aEditPB(        this, SW_RES( PB_EDIT        )),
      48             : 
      49             :     rSh( rS ),
      50           0 :     pDropField(0)
      51             : {
      52           0 :     Link aButtonLk = LINK(this, DropDownFieldDialog, ButtonHdl);
      53           0 :     aEditPB.SetClickHdl(aButtonLk);
      54           0 :     if( bNextButton )
      55             :     {
      56           0 :         aNextPB.Show();
      57           0 :         aNextPB.SetClickHdl(aButtonLk);
      58             :     }
      59             :     else
      60             :     {
      61           0 :         long nDiff = aCancelPB.GetPosPixel().Y() - aOKPB.GetPosPixel().Y();
      62           0 :         Point aPos = aHelpPB.GetPosPixel();
      63           0 :         aPos.Y() -= nDiff;
      64           0 :         aHelpPB.SetPosPixel(aPos);
      65             :     }
      66           0 :     if( RES_DROPDOWN == pField->GetTyp()->Which() )
      67             :     {
      68             :         //
      69           0 :         pDropField = (SwDropDownField*)pField;
      70           0 :         String sTitle = GetText();
      71           0 :         sTitle += pDropField->GetPar2();
      72           0 :         SetText(sTitle);
      73           0 :         uno::Sequence< rtl::OUString > aItems = pDropField->GetItemSequence();
      74           0 :         const rtl::OUString* pArray = aItems.getConstArray();
      75           0 :         for(sal_Int32 i = 0; i < aItems.getLength(); i++)
      76           0 :             aListItemsLB.InsertEntry(pArray[i]);
      77           0 :         aListItemsLB.SelectEntry(pDropField->GetSelectedItem());
      78             :     }
      79             : 
      80           0 :     sal_Bool bEnable = !rSh.IsCrsrReadonly();
      81           0 :     aOKPB.Enable( bEnable );
      82             : 
      83           0 :     aListItemsLB.GrabFocus();
      84           0 :     FreeResource();
      85           0 : }
      86             : 
      87           0 : sw::DropDownFieldDialog::~DropDownFieldDialog()
      88             : {
      89           0 : }
      90             : 
      91           0 : void sw::DropDownFieldDialog::Apply()
      92             : {
      93           0 :     if(pDropField)
      94             :     {
      95           0 :         rtl::OUString sSelect = aListItemsLB.GetSelectEntry();
      96           0 :         if(pDropField->GetPar1() != sSelect)
      97             :         {
      98           0 :             rSh.StartAllAction();
      99             : 
     100             :             ::std::auto_ptr<SwDropDownField> const pCopy(
     101           0 :                 static_cast<SwDropDownField *>( pDropField->CopyField() ) );
     102             : 
     103           0 :             pCopy->SetPar1(sSelect);
     104           0 :             rSh.SwEditShell::UpdateFlds(*pCopy);
     105             : 
     106           0 :             rSh.SetUndoNoResetModified();
     107           0 :             rSh.EndAllAction();
     108           0 :         }
     109             :     }
     110           0 : }
     111             : 
     112           0 : IMPL_LINK(sw::DropDownFieldDialog, ButtonHdl, PushButton*, pButton)
     113             : {
     114           0 :     EndDialog(&aNextPB == pButton ? RET_OK : RET_YES );
     115           0 :     return 0;
     116             : }
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10