LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - inpdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 79 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 10 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 : SwFieldInputDlg::SwFieldInputDlg( vcl::Window *pParent, SwWrtShell &rS,
      35             :                               SwField* pField, bool bNextButton )
      36             :     : SvxStandardDialog( pParent, "InputFieldDialog",
      37             :         "modules/swriter/ui/inputfielddialog.ui")
      38             :     , rSh( rS )
      39             :     , pInpField(0)
      40             :     , pSetField(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, SwFieldInputDlg, 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 :         pInpField = static_cast<SwInputField*>(pField);
      65           0 :         m_pLabelED->SetText( pInpField->GetPar2() );
      66           0 :         sal_uInt16 nSubType = pInpField->GetSubType();
      67             : 
      68           0 :         switch(nSubType & 0xff)
      69             :         {
      70             :             case INP_TXT:
      71           0 :                 aStr = pInpField->GetPar1();
      72           0 :                 break;
      73             : 
      74             :             case INP_USR:
      75             :                 // user field
      76           0 :                 if( 0 != ( pUsrType = static_cast<SwUserFieldType*>(rSh.GetFieldType(
      77           0 :                             RES_USERFLD, pInpField->GetPar1() ) )  ) )
      78           0 :                     aStr = pUsrType->GetContent();
      79           0 :                 break;
      80             :         }
      81             :     }
      82             :     else
      83             :     {
      84             :         // it is a SetExpression
      85           0 :         pSetField = static_cast<SwSetExpField*>(pField);
      86           0 :         OUString sFormula(pSetField->GetFormula());
      87             :         //values are formatted - formulas are not
      88           0 :         CharClass aCC( LanguageTag( pSetField->GetLanguage() ));
      89           0 :         if( aCC.isNumeric( sFormula ))
      90             :         {
      91           0 :             aStr = pSetField->ExpandField(true);
      92             :         }
      93             :         else
      94           0 :             aStr = sFormula;
      95           0 :         m_pLabelED->SetText( pSetField->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 : SwFieldInputDlg::~SwFieldInputDlg()
     110             : {
     111           0 :     disposeOnce();
     112           0 : }
     113             : 
     114           0 : void SwFieldInputDlg::dispose()
     115             : {
     116           0 :     m_pLabelED.clear();
     117           0 :     m_pEditED.clear();
     118           0 :     m_pOKBT.clear();
     119           0 :     m_pNextBT.clear();
     120           0 :     SvxStandardDialog::dispose();
     121           0 : }
     122             : 
     123           0 : void SwFieldInputDlg::StateChanged( StateChangedType nType )
     124             : {
     125           0 :     if ( nType == StateChangedType::InitShow )
     126           0 :         m_pEditED->GrabFocus();
     127           0 :     SvxStandardDialog::StateChanged( nType );
     128           0 : }
     129             : 
     130             : // Close
     131           0 : void SwFieldInputDlg::Apply()
     132             : {
     133           0 :     OUString aTmp(comphelper::string::remove(m_pEditED->GetText(), '\r'));
     134           0 :     rSh.StartAllAction();
     135           0 :     bool bModified = false;
     136           0 :     if(pInpField)
     137             :     {
     138           0 :         if(pUsrType)
     139             :         {
     140           0 :             if( !aTmp.equals(pUsrType->GetContent()) )
     141             :             {
     142           0 :                 pUsrType->SetContent(aTmp);
     143           0 :                 pUsrType->UpdateFields();
     144           0 :                 bModified = true;
     145             :             }
     146             :         }
     147           0 :         else if( !aTmp.equals(pInpField->GetPar1()) )
     148             :         {
     149           0 :             pInpField->SetPar1(aTmp);
     150           0 :             rSh.SwEditShell::UpdateFields(*pInpField);
     151           0 :             bModified = true;
     152             :         }
     153             :     }
     154           0 :     else if( !aTmp.equals(pSetField->GetPar2()) )
     155             :     {
     156           0 :         pSetField->SetPar2(aTmp);
     157           0 :         rSh.SwEditShell::UpdateFields(*pSetField);
     158           0 :         bModified = true;
     159             :     }
     160             : 
     161           0 :     if( bModified )
     162           0 :         rSh.SetUndoNoResetModified();
     163             : 
     164           0 :     rSh.EndAllAction();
     165           0 : }
     166             : 
     167           0 : IMPL_LINK_NOARG(SwFieldInputDlg, NextHdl)
     168             : {
     169           0 :     EndDialog(RET_OK);
     170           0 :     return 0;
     171           0 : }
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11