LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - DropDownFieldDialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 43 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <wrtsh.hxx>
      30                 :            : #include <fldbas.hxx>
      31                 :            : #include <fldmgr.hxx>
      32                 :            : #include <vcl/msgbox.hxx>
      33                 :            : #include <DropDownFieldDialog.hxx>
      34                 :            : #include <flddropdown.hxx>
      35                 :            : #include <fldui.hrc>
      36                 :            : #include <DropDownFieldDialog.hrc>
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : 
      40                 :            : 
      41                 :            : /*--------------------------------------------------------------------
      42                 :            :     Description: edit insert-field
      43                 :            :  --------------------------------------------------------------------*/
      44                 :          0 : sw::DropDownFieldDialog::DropDownFieldDialog( Window *pParent, SwWrtShell &rS,
      45                 :            :                               SwField* pField, sal_Bool bNextButton ) :
      46                 :            : 
      47                 :            :     SvxStandardDialog(pParent,  SW_RES(DLG_FLD_DROPDOWN)),
      48                 :            :     aItemsFL(       this, SW_RES( FL_ITEMS       )),
      49                 :            :     aListItemsLB(   this, SW_RES( LB_LISTITEMS   )),
      50                 :            : 
      51                 :            :     aOKPB(          this, SW_RES( PB_OK          )),
      52                 :            :     aCancelPB(      this, SW_RES( PB_CANCEL      )),
      53                 :            :     aNextPB(        this, SW_RES( PB_NEXT        )),
      54                 :            :     aHelpPB(        this, SW_RES( PB_HELP        )),
      55                 :            : 
      56                 :            :     aEditPB(        this, SW_RES( PB_EDIT        )),
      57                 :            : 
      58                 :            :     rSh( rS ),
      59                 :          0 :     pDropField(0)
      60                 :            : {
      61                 :          0 :     Link aButtonLk = LINK(this, DropDownFieldDialog, ButtonHdl);
      62                 :          0 :     aEditPB.SetClickHdl(aButtonLk);
      63                 :          0 :     if( bNextButton )
      64                 :            :     {
      65                 :          0 :         aNextPB.Show();
      66                 :          0 :         aNextPB.SetClickHdl(aButtonLk);
      67                 :            :     }
      68                 :            :     else
      69                 :            :     {
      70                 :          0 :         long nDiff = aCancelPB.GetPosPixel().Y() - aOKPB.GetPosPixel().Y();
      71                 :          0 :         Point aPos = aHelpPB.GetPosPixel();
      72                 :          0 :         aPos.Y() -= nDiff;
      73                 :          0 :         aHelpPB.SetPosPixel(aPos);
      74                 :            :     }
      75                 :          0 :     if( RES_DROPDOWN == pField->GetTyp()->Which() )
      76                 :            :     {
      77                 :            :         //
      78                 :          0 :         pDropField = (SwDropDownField*)pField;
      79                 :          0 :         String sTitle = GetText();
      80                 :          0 :         sTitle += pDropField->GetPar2();
      81                 :          0 :         SetText(sTitle);
      82                 :          0 :         uno::Sequence< rtl::OUString > aItems = pDropField->GetItemSequence();
      83                 :          0 :         const rtl::OUString* pArray = aItems.getConstArray();
      84                 :          0 :         for(sal_Int32 i = 0; i < aItems.getLength(); i++)
      85                 :          0 :             aListItemsLB.InsertEntry(pArray[i]);
      86                 :          0 :         aListItemsLB.SelectEntry(pDropField->GetSelectedItem());
      87                 :            :     }
      88                 :            : 
      89                 :          0 :     sal_Bool bEnable = !rSh.IsCrsrReadonly();
      90                 :          0 :     aOKPB.Enable( bEnable );
      91                 :            : 
      92                 :          0 :     aListItemsLB.GrabFocus();
      93                 :          0 :     FreeResource();
      94                 :          0 : }
      95                 :            : 
      96                 :          0 : sw::DropDownFieldDialog::~DropDownFieldDialog()
      97                 :            : {
      98                 :          0 : }
      99                 :            : 
     100                 :          0 : void sw::DropDownFieldDialog::Apply()
     101                 :            : {
     102                 :          0 :     if(pDropField)
     103                 :            :     {
     104                 :          0 :         rtl::OUString sSelect = aListItemsLB.GetSelectEntry();
     105                 :          0 :         if(pDropField->GetPar1() != sSelect)
     106                 :            :         {
     107                 :          0 :             rSh.StartAllAction();
     108                 :            : 
     109                 :            :             ::std::auto_ptr<SwDropDownField> const pCopy(
     110                 :          0 :                 static_cast<SwDropDownField *>( pDropField->CopyField() ) );
     111                 :            : 
     112                 :          0 :             pCopy->SetPar1(sSelect);
     113                 :          0 :             rSh.SwEditShell::UpdateFlds(*pCopy);
     114                 :            : 
     115                 :          0 :             rSh.SetUndoNoResetModified();
     116                 :          0 :             rSh.EndAllAction();
     117                 :          0 :         }
     118                 :            :     }
     119                 :          0 : }
     120                 :            : 
     121                 :          0 : IMPL_LINK(sw::DropDownFieldDialog, ButtonHdl, PushButton*, pButton)
     122                 :            : {
     123                 :          0 :     EndDialog(&aNextPB == pButton ? RET_OK : RET_YES );
     124                 :          0 :     return 0;
     125                 :            : }
     126                 :            : 
     127                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10