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

Generated by: LCOV version 1.10