LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - inpdlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 68 0.0 %
Date: 2014-04-14 Functions: 0 5 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 <comphelper/string.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <unotools/charclass.hxx>
      23             : #include <editeng/unolingu.hxx>
      24             : #include <wrtsh.hxx>
      25             : #include <fldbas.hxx>
      26             : #include <expfld.hxx>
      27             : #include <usrfld.hxx>
      28             : #include <inpdlg.hxx>
      29             : #include <fldmgr.hxx>
      30             : 
      31             : #include <fldui.hrc>
      32             : 
      33             : /*--------------------------------------------------------------------
      34             :     Description: edit field-insert
      35             :  --------------------------------------------------------------------*/
      36             : 
      37           0 : SwFldInputDlg::SwFldInputDlg( Window *pParent, SwWrtShell &rS,
      38             :                               SwField* pField, sal_Bool bNextButton )
      39             :     : SvxStandardDialog( pParent, "InputFieldDialog",
      40             :         "modules/swriter/ui/inputfielddialog.ui")
      41             :     , rSh( rS )
      42             :     , pInpFld(0)
      43             :     , pSetFld(0)
      44           0 :     , pUsrType(0)
      45             : {
      46           0 :     get(m_pLabelED, "name");
      47           0 :     get(m_pEditED, "text");
      48           0 :     m_pEditED->set_height_request(m_pEditED->GetTextHeight() * 9);
      49           0 :     get(m_pNextBT, "next");
      50           0 :     get(m_pOKBT, "ok");
      51             :     // switch font for Edit
      52           0 :     Font aFont(m_pEditED->GetFont());
      53           0 :     aFont.SetWeight(WEIGHT_LIGHT);
      54           0 :     m_pEditED->SetFont(aFont);
      55             : 
      56           0 :     if( bNextButton )
      57             :     {
      58           0 :         m_pNextBT->Show();
      59           0 :         m_pNextBT->SetClickHdl(LINK(this, SwFldInputDlg, NextHdl));
      60             :     }
      61             : 
      62             :     // evaluation here
      63           0 :     OUString aStr;
      64           0 :     if( RES_INPUTFLD == pField->GetTyp()->Which() )
      65             :     {   // it is an input field
      66             : 
      67           0 :         pInpFld = (SwInputField*)pField;
      68           0 :         m_pLabelED->SetText( pInpFld->GetPar2() );
      69           0 :         sal_uInt16 nSubType = pInpFld->GetSubType();
      70             : 
      71           0 :         switch(nSubType & 0xff)
      72             :         {
      73             :             case INP_TXT:
      74           0 :                 aStr = pInpFld->GetPar1();
      75           0 :                 break;
      76             : 
      77             :             case INP_USR:
      78             :                 // user field
      79           0 :                 if( 0 != ( pUsrType = (SwUserFieldType*)rSh.GetFldType(
      80           0 :                             RES_USERFLD, pInpFld->GetPar1() ) ) )
      81           0 :                     aStr = pUsrType->GetContent();
      82           0 :                 break;
      83             :         }
      84             :     }
      85             :     else
      86             :     {
      87             :         // it is a SetExpression
      88           0 :         pSetFld = (SwSetExpField*)pField;
      89           0 :         OUString sFormula(pSetFld->GetFormula());
      90             :         //values are formatted - formulas are not
      91           0 :         CharClass aCC( LanguageTag( pSetFld->GetLanguage() ));
      92           0 :         if( aCC.isNumeric( sFormula ))
      93             :         {
      94           0 :             aStr = pSetFld->ExpandField(true);
      95             :         }
      96             :         else
      97           0 :             aStr = sFormula;
      98           0 :         m_pLabelED->SetText( pSetFld->GetPromptText() );
      99             :     }
     100             : 
     101             :     // JP 31.3.00: Inputfields in readonly regions must be allowed to
     102             :     //              input any content. - 74639
     103           0 :     sal_Bool bEnable = !rSh.IsCrsrReadonly();
     104             : 
     105           0 :     m_pOKBT->Enable( bEnable );
     106           0 :     m_pEditED->SetReadOnly( !bEnable );
     107             : 
     108           0 :     if( !aStr.isEmpty() )
     109           0 :         m_pEditED->SetText(convertLineEnd(aStr, GetSystemLineEnd()));
     110           0 : }
     111             : 
     112           0 : void SwFldInputDlg::StateChanged( StateChangedType nType )
     113             : {
     114           0 :     if ( nType == STATE_CHANGE_INITSHOW )
     115           0 :         m_pEditED->GrabFocus();
     116           0 :     SvxStandardDialog::StateChanged( nType );
     117           0 : }
     118             : 
     119             : /*--------------------------------------------------------------------
     120             :      Description:   Close
     121             :  --------------------------------------------------------------------*/
     122             : 
     123           0 : void SwFldInputDlg::Apply()
     124             : {
     125           0 :     OUString aTmp(comphelper::string::remove(m_pEditED->GetText(), '\r'));
     126             : 
     127           0 :     rSh.StartAllAction();
     128           0 :     bool bModified = false;
     129           0 :     if(pInpFld)
     130             :     {
     131           0 :         if(pUsrType)
     132             :         {
     133           0 :             if( !aTmp.equals(pUsrType->GetContent()) )
     134             :             {
     135           0 :                 pUsrType->SetContent(aTmp);
     136           0 :                 pUsrType->UpdateFlds();
     137           0 :                 bModified = true;
     138             :             }
     139             :         }
     140           0 :         else if( !aTmp.equals(pInpFld->GetPar1()) )
     141             :         {
     142           0 :             pInpFld->SetPar1(aTmp);
     143           0 :             rSh.SwEditShell::UpdateFlds(*pInpFld);
     144           0 :             bModified = true;
     145             :         }
     146             :     }
     147           0 :     else if( !aTmp.equals(pSetFld->GetPar2()) )
     148             :     {
     149           0 :         pSetFld->SetPar2(aTmp);
     150           0 :         rSh.SwEditShell::UpdateFlds(*pSetFld);
     151           0 :         bModified = true;
     152             :     }
     153             : 
     154           0 :     if( bModified )
     155           0 :         rSh.SetUndoNoResetModified();
     156             : 
     157           0 :     rSh.EndAllAction();
     158           0 : }
     159             : 
     160           0 : IMPL_LINK_NOARG(SwFldInputDlg, NextHdl)
     161             : {
     162           0 :     EndDialog(RET_OK);
     163           0 :     return 0;
     164             : }
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10