LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - mtrindlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 63 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : 
      30                 :            : #undef SC_DLLIMPLEMENTATION
      31                 :            : 
      32                 :            : 
      33                 :            : 
      34                 :            : //------------------------------------------------------------------
      35                 :            : 
      36                 :            : #include "mtrindlg.hxx"
      37                 :            : #include "scresid.hxx"
      38                 :            : #include "miscdlgs.hrc"
      39                 :            : 
      40                 :            : 
      41                 :            : //==================================================================
      42                 :            : 
      43                 :          0 : ScMetricInputDlg::ScMetricInputDlg( Window*         pParent,
      44                 :            :                                     sal_uInt16          nResId,
      45                 :            :                                     long            nCurrent,
      46                 :            :                                     long            nDefault,
      47                 :            :                                     FieldUnit       eFUnit,
      48                 :            :                                     sal_uInt16          nDecimals,
      49                 :            :                                     long            nMaximum,
      50                 :            :                                     long            nMinimum,
      51                 :            :                                     long            nFirst,
      52                 :            :                                     long            nLast )
      53                 :            : 
      54                 :            :     :   ModalDialog     ( pParent, ScResId( nResId ) ),
      55                 :            :         //
      56                 :            :         aFtEditTitle    ( this, ScResId( FT_LABEL ) ),
      57                 :            :         aEdValue        ( this, ScResId( ED_VALUE ) ),
      58                 :            :         aBtnDefVal      ( this, ScResId( BTN_DEFVAL ) ),
      59                 :            :         aBtnOk          ( this, ScResId( BTN_OK ) ),
      60                 :            :         aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
      61                 :          0 :         aBtnHelp        ( this, ScResId( BTN_HELP ) )
      62                 :            : {
      63                 :            :     //SetText( rTitle );
      64                 :            :     //
      65                 :            :     //aFtEditTitle.SetText( rEditTitle );
      66                 :          0 :     CalcPositions();
      67                 :          0 :     aBtnDefVal.SetClickHdl ( LINK( this, ScMetricInputDlg, SetDefValHdl ) );
      68                 :          0 :     aEdValue.  SetModifyHdl( LINK( this, ScMetricInputDlg, ModifyHdl    ) );
      69                 :            : 
      70                 :          0 :     aEdValue.SetUnit            ( eFUnit );
      71                 :          0 :     aEdValue.SetDecimalDigits   ( nDecimals );
      72                 :          0 :     aEdValue.SetMax             ( aEdValue.Normalize( nMaximum ), FUNIT_TWIP );
      73                 :          0 :     aEdValue.SetMin             ( aEdValue.Normalize( nMinimum ), FUNIT_TWIP );
      74                 :          0 :     aEdValue.SetLast            ( aEdValue.Normalize( nLast ),    FUNIT_TWIP );
      75                 :          0 :     aEdValue.SetFirst           ( aEdValue.Normalize( nFirst ),   FUNIT_TWIP );
      76                 :          0 :     aEdValue.SetSpinSize        ( aEdValue.Normalize( 1 ) / 10 );
      77                 :          0 :     aEdValue.SetValue           ( aEdValue.Normalize( nDefault ), FUNIT_TWIP );
      78                 :          0 :     nDefaultValue = sal::static_int_cast<long>( aEdValue.GetValue() );
      79                 :          0 :     aEdValue.SetValue           ( aEdValue.Normalize( nCurrent ), FUNIT_TWIP );
      80                 :          0 :     nCurrentValue = sal::static_int_cast<long>( aEdValue.GetValue() );
      81                 :          0 :     aBtnDefVal.Check( nCurrentValue == nDefaultValue );
      82                 :            : 
      83                 :          0 :     FreeResource();
      84                 :          0 : }
      85                 :            : 
      86                 :            : //------------------------------------------------------------------------
      87                 :            : 
      88                 :          0 : ScMetricInputDlg::~ScMetricInputDlg()
      89                 :            : {
      90                 :          0 : }
      91                 :            : 
      92                 :            : //------------------------------------------------------------------------
      93                 :            : 
      94                 :          0 : long ScMetricInputDlg::GetInputValue( FieldUnit eUnit ) const
      95                 :            : {
      96                 :            : /*
      97                 :            :     mit Nachkommastellen:
      98                 :            : 
      99                 :            :     double  nVal    = aEdValue.GetValue( eUnit );
     100                 :            :     sal_uInt16  nDecs   = aEdValue.GetDecimalDigits();
     101                 :            :     double  nFactor = 0.0;
     102                 :            : 
     103                 :            :     // static long ImpPower10( sal_uInt16 nDecs )
     104                 :            :     {
     105                 :            :         nFactor = 1.0;
     106                 :            : 
     107                 :            :         for ( sal_uInt16 i=0; i < nDecs; i++ )
     108                 :            :             nFactor *= 10.0;
     109                 :            :     }
     110                 :            : 
     111                 :            :     return nVal / nFactor;
     112                 :            : */
     113                 :            :     // erstmal Nachkommastellen abschneiden - nich so doll...
     114                 :            : 
     115                 :          0 :     return sal::static_int_cast<long>( aEdValue.Denormalize( aEdValue.GetValue( eUnit ) ) );
     116                 :            : }
     117                 :            : 
     118                 :            : //------------------------------------------------------------------------
     119                 :            : 
     120                 :          0 : void ScMetricInputDlg::CalcPositions()
     121                 :            : {
     122                 :          0 :     MapMode oldMode     = GetMapMode();
     123                 :          0 :     SetMapMode( MAP_APPFONT );
     124                 :            : 
     125                 :          0 :     Size    aDlgSize    = GetOutputSizePixel();
     126                 :          0 :     Size    aFtSize     = aFtEditTitle.GetSizePixel();
     127                 :          0 :     Point   aNewPos;
     128                 :            : 
     129                 :          0 :     aFtSize.Width() = aFtEditTitle.GetTextWidth(aFtEditTitle.GetText());
     130                 :            :     // add mnemonic char width to fixed text width
     131                 :          0 :     aFtSize.Width() += aFtEditTitle.GetTextWidth(rtl::OUString("(W)"));
     132                 :          0 :     aFtEditTitle.SetSizePixel( aFtSize );
     133                 :            : 
     134                 :          0 :     aNewPos.Y()  = aEdValue.GetPosPixel().Y();
     135                 :          0 :     aNewPos.X()  = aFtEditTitle.GetPosPixel().X();
     136                 :          0 :     aNewPos.X() += aFtEditTitle.GetSizePixel().Width();
     137                 :          0 :     aNewPos.X() += LogicToPixel( Point(3,0) ).X();
     138                 :          0 :     aEdValue.SetPosPixel( aNewPos );
     139                 :            : 
     140                 :          0 :     aNewPos.Y()  = aBtnDefVal.GetPosPixel().Y();
     141                 :          0 :     aBtnDefVal.SetPosPixel( aNewPos );
     142                 :            : 
     143                 :          0 :     aNewPos.Y()  = aBtnOk.GetPosPixel().Y();
     144                 :          0 :     aNewPos.X() += aEdValue.GetSizePixel().Width();
     145                 :          0 :     aNewPos.X() += LogicToPixel( Point(6,0) ).X();
     146                 :          0 :     aBtnOk.SetPosPixel( aNewPos );
     147                 :          0 :     aNewPos.Y()  = aBtnCancel.GetPosPixel().Y();
     148                 :          0 :     aBtnCancel.SetPosPixel( aNewPos );
     149                 :          0 :     aNewPos.Y()  = aBtnHelp.GetPosPixel().Y();
     150                 :          0 :     aBtnHelp.SetPosPixel( aNewPos );
     151                 :            : 
     152                 :          0 :     aNewPos.X() += aBtnOk.GetSizePixel().Width();
     153                 :          0 :     aNewPos.X() += LogicToPixel( Point(6,0) ).X();
     154                 :          0 :     aDlgSize.Width() = aNewPos.X();
     155                 :          0 :     SetOutputSizePixel( aDlgSize );
     156                 :            : 
     157                 :          0 :     SetMapMode( oldMode );
     158                 :          0 : }
     159                 :            : 
     160                 :            : //------------------------------------------------------------------------
     161                 :            : // Handler:
     162                 :            : 
     163                 :          0 : IMPL_LINK_NOARG(ScMetricInputDlg, SetDefValHdl)
     164                 :            : {
     165                 :          0 :     if ( aBtnDefVal.IsChecked() )
     166                 :            :     {
     167                 :          0 :         nCurrentValue = sal::static_int_cast<long>( aEdValue.GetValue() );
     168                 :          0 :         aEdValue.SetValue( nDefaultValue );
     169                 :            :     }
     170                 :            :     else
     171                 :          0 :         aEdValue.SetValue( nCurrentValue );
     172                 :          0 :     return 0;
     173                 :            : }
     174                 :            : 
     175                 :            : //------------------------------------------------------------------------
     176                 :            : 
     177                 :          0 : IMPL_LINK_NOARG_INLINE_START(ScMetricInputDlg, ModifyHdl)
     178                 :            : {
     179                 :          0 :     aBtnDefVal.Check( nDefaultValue == aEdValue.GetValue() );
     180                 :          0 :     return 0;
     181                 :            : }
     182                 :          0 : IMPL_LINK_NOARG_INLINE_END(ScMetricInputDlg, ModifyHdl)
     183                 :            : 
     184                 :            : 
     185                 :            : 
     186                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10