LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - DropDownFieldDialog.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 42 0.0 %
Date: 2014-04-11 Functions: 0 4 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             : 
      28             : #include <boost/scoped_ptr.hpp>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32             : /*--------------------------------------------------------------------
      33             :     Description: edit insert-field
      34             :  --------------------------------------------------------------------*/
      35           0 : sw::DropDownFieldDialog::DropDownFieldDialog(Window *pParent, SwWrtShell &rS,
      36             :                               SwField* pField, sal_Bool bNextButton)
      37             :     : SvxStandardDialog(pParent, "DropdownFieldDialog",
      38             :         "modules/swriter/ui/dropdownfielddialog.ui")
      39             :     , rSh( rS )
      40           0 :     , pDropField(0)
      41             : {
      42           0 :     get(m_pListItemsLB, "list");
      43           0 :     m_pListItemsLB->SetDropDownLineCount(12);
      44           0 :     m_pListItemsLB->set_width_request(m_pListItemsLB->approximate_char_width()*32);
      45           0 :     get(m_pOKPB, "ok");
      46           0 :     get(m_pNextPB, "next");
      47           0 :     get(m_pEditPB, "edit");
      48             : 
      49           0 :     Link aButtonLk = LINK(this, DropDownFieldDialog, ButtonHdl);
      50           0 :     m_pEditPB->SetClickHdl(aButtonLk);
      51           0 :     if( bNextButton )
      52             :     {
      53           0 :         m_pNextPB->Show();
      54           0 :         m_pNextPB->SetClickHdl(aButtonLk);
      55             :     }
      56           0 :     if( RES_DROPDOWN == pField->GetTyp()->Which() )
      57             :     {
      58             : 
      59           0 :         pDropField = (SwDropDownField*)pField;
      60           0 :         OUString sTitle = GetText();
      61           0 :         sTitle += pDropField->GetPar2();
      62           0 :         SetText(sTitle);
      63           0 :         uno::Sequence< OUString > aItems = pDropField->GetItemSequence();
      64           0 :         const OUString* pArray = aItems.getConstArray();
      65           0 :         for(sal_Int32 i = 0; i < aItems.getLength(); i++)
      66           0 :             m_pListItemsLB->InsertEntry(pArray[i]);
      67           0 :         m_pListItemsLB->SelectEntry(pDropField->GetSelectedItem());
      68             :     }
      69             : 
      70           0 :     sal_Bool bEnable = !rSh.IsCrsrReadonly();
      71           0 :     m_pOKPB->Enable( bEnable );
      72             : 
      73           0 :     m_pListItemsLB->GrabFocus();
      74           0 : }
      75             : 
      76           0 : void sw::DropDownFieldDialog::Apply()
      77             : {
      78           0 :     if(pDropField)
      79             :     {
      80           0 :         OUString sSelect = m_pListItemsLB->GetSelectEntry();
      81           0 :         if(pDropField->GetPar1() != sSelect)
      82             :         {
      83           0 :             rSh.StartAllAction();
      84             : 
      85             :             boost::scoped_ptr<SwDropDownField> const pCopy(
      86           0 :                 static_cast<SwDropDownField *>( pDropField->CopyField() ) );
      87             : 
      88           0 :             pCopy->SetPar1(sSelect);
      89           0 :             rSh.SwEditShell::UpdateFlds(*pCopy);
      90             : 
      91           0 :             rSh.SetUndoNoResetModified();
      92           0 :             rSh.EndAllAction();
      93           0 :         }
      94             :     }
      95           0 : }
      96             : 
      97           0 : IMPL_LINK(sw::DropDownFieldDialog, ButtonHdl, PushButton*, pButton)
      98             : {
      99           0 :     EndDialog(m_pNextPB == pButton ? RET_OK : RET_YES );
     100           0 :     return 0;
     101             : }
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10