LCOV - code coverage report
Current view: top level - svx/source/dialog - measctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 142 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/svdomeas.hxx>
      30                 :            : #include <svx/svdmodel.hxx>
      31                 :            : 
      32                 :            : #include "svx/measctrl.hxx"
      33                 :            : #include <svx/dialmgr.hxx>
      34                 :            : #include "svx/dlgutil.hxx"
      35                 :            : 
      36                 :          0 : SvxXMeasurePreview::SvxXMeasurePreview
      37                 :            : (
      38                 :            :     Window* pParent,
      39                 :            :     const ResId& rResId,
      40                 :            :     const SfxItemSet& rInAttrs
      41                 :            : ) :
      42                 :            : 
      43                 :            :     Control ( pParent, rResId ),
      44                 :          0 :     rAttrs  ( rInAttrs )
      45                 :            : 
      46                 :            : {
      47 [ #  # ][ #  # ]:          0 :     SetMapMode( MAP_100TH_MM );
                 [ #  # ]
      48                 :            : 
      49         [ #  # ]:          0 :     Size aSize = GetOutputSize();
      50                 :            : 
      51                 :            :     // Scale: 1:2
      52         [ #  # ]:          0 :     MapMode aMapMode = GetMapMode();
      53 [ #  # ][ #  # ]:          0 :     aMapMode.SetScaleX( Fraction( 1, 2 ) );
      54 [ #  # ][ #  # ]:          0 :     aMapMode.SetScaleY( Fraction( 1, 2 ) );
      55         [ #  # ]:          0 :     SetMapMode( aMapMode );
      56                 :            : 
      57         [ #  # ]:          0 :     aSize = GetOutputSize();
      58                 :          0 :     Point aPt1 = Point( aSize.Width() / 5, (long) ( aSize.Height() / 2 ) );
      59                 :          0 :     Point aPt2 = Point( aSize.Width() * 4 / 5, (long) ( aSize.Height() / 2 ) );
      60                 :            : 
      61 [ #  # ][ #  # ]:          0 :     pMeasureObj = new SdrMeasureObj( aPt1, aPt2 );
      62 [ #  # ][ #  # ]:          0 :     pModel = new SdrModel();
      63         [ #  # ]:          0 :     pMeasureObj->SetModel( pModel );
      64                 :            : 
      65         [ #  # ]:          0 :     pMeasureObj->SetMergedItemSetAndBroadcast(rInAttrs);
      66                 :            : 
      67 [ #  # ][ #  # ]:          0 :     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
      68                 :            : 
      69 [ #  # ][ #  # ]:          0 :     Invalidate();
      70                 :          0 : }
      71                 :            : 
      72                 :          0 : SvxXMeasurePreview::~SvxXMeasurePreview()
      73                 :            : {
      74                 :            :     // No one is deleting the MeasureObj? This is not only an error but also
      75                 :            :     // a memory leak (!). Main problem is that this object is still listening to
      76                 :            :     // a StyleSheet of the model which was set. Thus, if You want to keep the obnject,
      77                 :            :     // set the modfel to 0L, if object is not needed (seems to be the case here),
      78                 :            :     // delete it.
      79 [ #  # ][ #  # ]:          0 :     delete pMeasureObj;
      80                 :            : 
      81 [ #  # ][ #  # ]:          0 :     delete pModel;
      82         [ #  # ]:          0 : }
      83                 :            : 
      84                 :          0 : void SvxXMeasurePreview::Paint( const Rectangle&  )
      85                 :            : {
      86                 :          0 :     pMeasureObj->SingleObjectPainter(*this);
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : void SvxXMeasurePreview::SetAttributes( const SfxItemSet& rInAttrs )
      90                 :            : {
      91                 :          0 :     pMeasureObj->SetMergedItemSetAndBroadcast(rInAttrs);
      92                 :            : 
      93                 :          0 :     Invalidate();
      94                 :          0 : }
      95                 :            : 
      96                 :          0 : void SvxXMeasurePreview::MouseButtonDown( const MouseEvent& rMEvt )
      97                 :            : {
      98 [ #  # ][ #  # ]:          0 :     sal_Bool bZoomIn  = rMEvt.IsLeft() && !rMEvt.IsShift();
      99 [ #  # ][ #  # ]:          0 :     sal_Bool bZoomOut = rMEvt.IsRight() || rMEvt.IsShift();
     100                 :          0 :     sal_Bool bCtrl    = rMEvt.IsMod1();
     101                 :            : 
     102 [ #  # ][ #  # ]:          0 :     if( bZoomIn || bZoomOut )
     103                 :            :     {
     104         [ #  # ]:          0 :         MapMode aMapMode = GetMapMode();
     105         [ #  # ]:          0 :         Fraction aXFrac = aMapMode.GetScaleX();
     106         [ #  # ]:          0 :         Fraction aYFrac = aMapMode.GetScaleY();
     107                 :            :         Fraction* pMultFrac;
     108                 :            : 
     109         [ #  # ]:          0 :         if( bZoomIn )
     110                 :            :         {
     111         [ #  # ]:          0 :             if( bCtrl )
     112 [ #  # ][ #  # ]:          0 :                 pMultFrac = new Fraction( 3, 2 );
     113                 :            :             else
     114 [ #  # ][ #  # ]:          0 :                 pMultFrac = new Fraction( 11, 10 );
     115                 :            :         }
     116                 :            :         else
     117                 :            :         {
     118         [ #  # ]:          0 :             if( bCtrl )
     119 [ #  # ][ #  # ]:          0 :                 pMultFrac = new Fraction( 2, 3 );
     120                 :            :             else
     121 [ #  # ][ #  # ]:          0 :                 pMultFrac = new Fraction( 10, 11 );
     122                 :            :         }
     123                 :            : 
     124         [ #  # ]:          0 :         aXFrac *= *pMultFrac;
     125         [ #  # ]:          0 :         aYFrac *= *pMultFrac;
     126 [ #  # ][ #  # ]:          0 :         if( (double)aXFrac > 0.001 && (double)aXFrac < 1000.0 &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     127 [ #  # ][ #  # ]:          0 :             (double)aYFrac > 0.001 && (double)aYFrac < 1000.0 )
     128                 :            :         {
     129         [ #  # ]:          0 :             aMapMode.SetScaleX( aXFrac );
     130         [ #  # ]:          0 :             aMapMode.SetScaleY( aYFrac );
     131         [ #  # ]:          0 :             SetMapMode( aMapMode );
     132                 :            : 
     133         [ #  # ]:          0 :             Size aOutSize( GetOutputSize() );
     134                 :            : 
     135                 :          0 :             Point aPt( aMapMode.GetOrigin() );
     136         [ #  # ]:          0 :             long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * (double)*pMultFrac  ) ) / 2.0 + 0.5 );
     137         [ #  # ]:          0 :             long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * (double)*pMultFrac  ) ) / 2.0 + 0.5 );
     138                 :          0 :             aPt.X() +=  nX;
     139                 :          0 :             aPt.Y() +=  nY;
     140                 :            : 
     141         [ #  # ]:          0 :             aMapMode.SetOrigin( aPt );
     142         [ #  # ]:          0 :             SetMapMode( aMapMode );
     143                 :            : 
     144         [ #  # ]:          0 :             Invalidate();
     145                 :            :         }
     146         [ #  # ]:          0 :         delete pMultFrac;
     147                 :            :     }
     148                 :          0 : }
     149                 :            : 
     150                 :            : // -----------------------------------------------------------------------
     151                 :            : 
     152                 :          0 : void SvxXMeasurePreview::DataChanged( const DataChangedEvent& rDCEvt )
     153                 :            : {
     154                 :          0 :     Control::DataChanged( rDCEvt );
     155                 :            : 
     156 [ #  # ][ #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
                 [ #  # ]
     157                 :            :     {
     158         [ #  # ]:          0 :         SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
     159                 :            :     }
     160                 :          0 : }
     161                 :            : 
     162                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10