LCOV - code coverage report
Current view: top level - sw/source/core/uibase/cctrl - actctrl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 59 0.0 %
Date: 2014-04-11 Functions: 0 11 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/builder.hxx>
      22             : #include "actctrl.hxx"
      23             : 
      24           0 : void NumEditAction::Action()
      25             : {
      26           0 :     aActionLink.Call( this );
      27           0 : }
      28             : 
      29           0 : bool NumEditAction::Notify( NotifyEvent& rNEvt )
      30             : {
      31           0 :     bool nHandled = false;
      32             : 
      33           0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
      34             :     {
      35           0 :         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
      36           0 :         const KeyCode aKeyCode = pKEvt->GetKeyCode();
      37           0 :         const sal_uInt16 nModifier = aKeyCode.GetModifier();
      38           0 :         if( aKeyCode.GetCode() == KEY_RETURN &&
      39             :                 !nModifier)
      40             :         {
      41           0 :             Action();
      42           0 :             nHandled = true;
      43             :         }
      44             : 
      45             :     }
      46           0 :     if(!nHandled)
      47           0 :         NumericField::Notify( rNEvt );
      48           0 :     return nHandled;
      49             : }
      50             : 
      51           0 : NoSpaceEdit::NoSpaceEdit(Window* pParent)
      52             :     : Edit(pParent, WB_BORDER|WB_TABSTOP)
      53           0 :     , sForbiddenChars(OUString(" "))
      54             : {
      55           0 : }
      56             : 
      57           0 : NoSpaceEdit::~NoSpaceEdit()
      58             : {
      59           0 : }
      60             : 
      61           0 : void NoSpaceEdit::KeyInput(const KeyEvent& rEvt)
      62             : {
      63           0 :     bool bCallParent = true;
      64           0 :     if(rEvt.GetCharCode())
      65             :     {
      66           0 :         OUString sKey(rEvt.GetCharCode());
      67           0 :         if( -1 != sForbiddenChars.indexOf(sKey))
      68           0 :             bCallParent = false;
      69             :     }
      70           0 :     if(bCallParent)
      71           0 :         Edit::KeyInput(rEvt);
      72           0 : }
      73             : 
      74           0 : void NoSpaceEdit::Modify()
      75             : {
      76           0 :     Selection aSel = GetSelection();
      77           0 :     OUString sTemp = GetText();
      78           0 :     for(sal_uInt16 i = 0; i < sForbiddenChars.getLength(); i++)
      79             :     {
      80           0 :         sTemp = comphelper::string::remove(sTemp, sForbiddenChars[i]);
      81             :     }
      82           0 :     sal_Int32 nDiff = GetText().getLength() - sTemp.getLength();
      83           0 :     if(nDiff)
      84             :     {
      85           0 :         aSel.setMin(aSel.getMin() - nDiff);
      86           0 :         aSel.setMax(aSel.getMin());
      87           0 :         SetText(sTemp);
      88           0 :         SetSelection(aSel);
      89             :     }
      90           0 :     Edit::Modify();
      91           0 : }
      92             : 
      93           0 : void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
      94             : {
      95           0 :     const KeyCode aKeyCode = rEvt.GetKeyCode();
      96           0 :     const sal_uInt16 nModifier = aKeyCode.GetModifier();
      97           0 :     if( aKeyCode.GetCode() == KEY_RETURN &&
      98             :             !nModifier)
      99             :     {
     100           0 :         if(aReturnActionLink.IsSet())
     101           0 :             aReturnActionLink.Call(this);
     102             :     }
     103             :     else
     104           0 :         Edit::KeyInput(rEvt);
     105           0 : }
     106             : 
     107           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &rMap)
     108             : {
     109           0 :     VclBuilder::ensureDefaultWidthChars(rMap);
     110           0 :     return new TableNameEdit(pParent);
     111             : }
     112             : 
     113           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNoSpaceEdit(Window *pParent, VclBuilder::stringmap &rMap)
     114             : {
     115           0 :     VclBuilder::ensureDefaultWidthChars(rMap);
     116           0 :     return new NoSpaceEdit(pParent);
     117             : }
     118             : 
     119           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeReturnActionEdit(Window *pParent, VclBuilder::stringmap &rMap)
     120             : {
     121           0 :     VclBuilder::ensureDefaultWidthChars(rMap);
     122           0 :     return new ReturnActionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
     123             : }
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10