LCOV - code coverage report
Current view: top level - svx/source/dialog - relfld.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 51 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 "svx/relfld.hxx"
      21             : #include "vcl/builder.hxx"
      22             : 
      23             : 
      24             : 
      25           0 : SvxRelativeField::SvxRelativeField( Window* pParent, WinBits nBits)
      26             :     : MetricField( pParent, nBits)
      27             :     , nRelMin(0)
      28             :     , nRelMax(0)
      29             :     , nRelStep(0)
      30             :     , bRelativeMode(false)
      31             :     , bRelative(false)
      32           0 :     , bNegativeEnabled(false)
      33             : 
      34             : {
      35             : 
      36           0 :     SetDecimalDigits( 2 );
      37           0 :     SetMin( 0 );
      38           0 :     SetMax( 9999 );
      39           0 : }
      40             : 
      41           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxRelativeField(Window *pParent, VclBuilder::stringmap &)
      42             : {
      43           0 :     return new SvxRelativeField(pParent, WB_BORDER | WB_SPIN | WB_REPEAT | WB_LEFT | WB_GROUP);
      44             : }
      45             : 
      46             : 
      47           0 : void SvxRelativeField::Modify()
      48             : {
      49           0 :     MetricField::Modify();
      50             : 
      51           0 :     if ( bRelativeMode )
      52             :     {
      53           0 :         OUString  aStr = GetText();
      54           0 :         bool      bNewMode = bRelative;
      55             : 
      56           0 :         if ( bRelative )
      57             :         {
      58           0 :             const sal_Unicode* pStr = aStr.getStr();
      59             : 
      60           0 :             while ( *pStr )
      61             :             {
      62           0 :                 if( ( ( *pStr < '0' ) || ( *pStr > '9' ) ) &&
      63           0 :                     ( *pStr != '%' ) )
      64             :                 {
      65           0 :                     bNewMode = false;
      66           0 :                     break;
      67             :                 }
      68           0 :                 pStr++;
      69             :             }
      70             :         }
      71             :         else
      72             :         {
      73           0 :             if ( aStr.indexOf( "%" ) != -1 )
      74           0 :                 bNewMode = true;
      75             :         }
      76             : 
      77           0 :         if ( bNewMode != bRelative )
      78           0 :             SetRelative( bNewMode );
      79             : 
      80           0 :         MetricField::Modify();
      81             :     }
      82           0 : }
      83             : 
      84             : 
      85             : 
      86           0 : void SvxRelativeField::EnableRelativeMode( sal_uInt16 nMin,
      87             :                                            sal_uInt16 nMax, sal_uInt16 nStep )
      88             : {
      89           0 :     bRelativeMode = true;
      90           0 :     nRelMin       = nMin;
      91           0 :     nRelMax       = nMax;
      92           0 :     nRelStep      = nStep;
      93           0 :     SetUnit( FUNIT_CM );
      94           0 : }
      95             : 
      96             : 
      97             : 
      98           0 : void SvxRelativeField::SetRelative( bool bNewRelative )
      99             : {
     100           0 :     Selection aSelection = GetSelection();
     101           0 :     OUString aStr = GetText();
     102             : 
     103           0 :     if ( bNewRelative )
     104             :     {
     105           0 :         bRelative = true;
     106           0 :         SetDecimalDigits( 0 );
     107           0 :         SetMin( nRelMin );
     108           0 :         SetMax( nRelMax );
     109           0 :         SetUnit( FUNIT_PERCENT );
     110             :     }
     111             :     else
     112             :     {
     113           0 :         bRelative = false;
     114           0 :         SetDecimalDigits( 2 );
     115           0 :         SetMin( bNegativeEnabled ? -9999 : 0 );
     116           0 :         SetMax( 9999 );
     117           0 :         SetUnit( FUNIT_CM );
     118             :     }
     119             : 
     120           0 :     SetText( aStr );
     121           0 :     SetSelection( aSelection );
     122           0 : }
     123             : 
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10