LCOV - code coverage report
Current view: top level - svx/source/dialog - relfld.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 68 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "svx/relfld.hxx"
      30                 :            : 
      31                 :            : // -----------------------------------------------------------------------
      32                 :            : 
      33                 :          0 : SvxRelativeField::SvxRelativeField( Window* pParent, const ResId& rResId ) :
      34                 :          0 :     MetricField( pParent, rResId )
      35                 :            : {
      36                 :          0 :     bNegativeEnabled = sal_False;
      37                 :          0 :     bRelativeMode = sal_False;
      38                 :          0 :     bRelative     = sal_False;
      39                 :            : 
      40         [ #  # ]:          0 :     SetDecimalDigits( 2 );
      41         [ #  # ]:          0 :     SetMin( 0 );
      42         [ #  # ]:          0 :     SetMax( 9999 );
      43                 :          0 : }
      44                 :            : 
      45                 :            : // -----------------------------------------------------------------------
      46                 :            : 
      47                 :          0 : void SvxRelativeField::Modify()
      48                 :            : {
      49                 :          0 :     MetricField::Modify();
      50                 :            : 
      51         [ #  # ]:          0 :     if ( bRelativeMode )
      52                 :            :     {
      53         [ #  # ]:          0 :         String  aStr = GetText();
      54                 :          0 :         sal_Bool    bNewMode = bRelative;
      55                 :            : 
      56         [ #  # ]:          0 :         if ( bRelative )
      57                 :            :         {
      58                 :          0 :             const sal_Unicode* pStr = aStr.GetBuffer();
      59                 :            : 
      60         [ #  # ]:          0 :             while ( *pStr )
      61                 :            :             {
      62 [ #  # ][ #  # ]:          0 :                 if( ( ( *pStr < sal_Unicode( '0' ) ) || ( *pStr > sal_Unicode( '9' ) ) ) &&
                 [ #  # ]
      63                 :            :                     ( *pStr != sal_Unicode( '%' ) ) )
      64                 :            :                 {
      65                 :          0 :                     bNewMode = sal_False;
      66                 :          0 :                     break;
      67                 :            :                 }
      68                 :          0 :                 pStr++;
      69                 :            :             }
      70                 :            :         }
      71                 :            :         else
      72                 :            :         {
      73         [ #  # ]:          0 :             xub_StrLen nPos = aStr.Search( sal_Unicode( '%' ) );
      74                 :            : 
      75         [ #  # ]:          0 :             if ( nPos != STRING_NOTFOUND )
      76                 :          0 :                 bNewMode = sal_True;
      77                 :            :         }
      78                 :            : 
      79         [ #  # ]:          0 :         if ( bNewMode != bRelative )
      80         [ #  # ]:          0 :             SetRelative( bNewMode );
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :         MetricField::Modify();
      83                 :            :     }
      84                 :          0 : }
      85                 :            : 
      86                 :            : // -----------------------------------------------------------------------
      87                 :            : 
      88                 :          0 : void SvxRelativeField::EnableRelativeMode( sal_uInt16 nMin,
      89                 :            :                                            sal_uInt16 nMax, sal_uInt16 nStep )
      90                 :            : {
      91                 :          0 :     bRelativeMode = sal_True;
      92                 :          0 :     nRelMin       = nMin;
      93                 :          0 :     nRelMax       = nMax;
      94                 :          0 :     nRelStep      = nStep;
      95                 :          0 :     SetUnit( FUNIT_CM );
      96                 :          0 : }
      97                 :            : 
      98                 :            : // -----------------------------------------------------------------------
      99                 :            : 
     100                 :          0 : void SvxRelativeField::SetRelative( sal_Bool bNewRelative )
     101                 :            : {
     102         [ #  # ]:          0 :     Selection aSelection = GetSelection();
     103         [ #  # ]:          0 :     String aStr = GetText();
     104                 :            : 
     105         [ #  # ]:          0 :     if ( bNewRelative )
     106                 :            :     {
     107                 :          0 :         bRelative = sal_True;
     108         [ #  # ]:          0 :         SetDecimalDigits( 0 );
     109         [ #  # ]:          0 :         SetMin( nRelMin );
     110         [ #  # ]:          0 :         SetMax( nRelMax );
     111 [ #  # ][ #  # ]:          0 :         SetCustomUnitText( rtl::OUString('%') );
                 [ #  # ]
     112         [ #  # ]:          0 :         SetUnit( FUNIT_CUSTOM );
     113                 :            :     }
     114                 :            :     else
     115                 :            :     {
     116                 :          0 :         bRelative = sal_False;
     117         [ #  # ]:          0 :         SetDecimalDigits( 2 );
     118 [ #  # ][ #  # ]:          0 :         SetMin( bNegativeEnabled ? -9999 : 0 );
     119         [ #  # ]:          0 :         SetMax( 9999 );
     120         [ #  # ]:          0 :         SetUnit( FUNIT_CM );
     121                 :            :     }
     122                 :            : 
     123         [ #  # ]:          0 :     SetText( aStr );
     124 [ #  # ][ #  # ]:          0 :     SetSelection( aSelection );
     125                 :          0 : }
     126                 :            : 
     127                 :            : 
     128                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10