LCOV - code coverage report
Current view: top level - chart2/source/tools - RelativeSizeHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 23 0.0 %
Date: 2014-04-14 Functions: 0 2 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 "RelativeSizeHelper.hxx"
      21             : #include "macros.hxx"
      22             : 
      23             : #include <vector>
      24             : #include <algorithm>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using namespace ::com::sun::star::beans;
      28             : using namespace ::std;
      29             : 
      30             : using ::com::sun::star::uno::Reference;
      31             : using ::com::sun::star::uno::makeAny;
      32             : using ::com::sun::star::uno::Exception;
      33             : 
      34             : namespace chart
      35             : {
      36             : 
      37           0 : double RelativeSizeHelper::calculate(
      38             :     double fValue,
      39             :     const awt::Size & rOldReferenceSize,
      40             :     const awt::Size & rNewReferenceSize )
      41             : {
      42           0 :     if( rOldReferenceSize.Width <= 0 ||
      43           0 :         rOldReferenceSize.Height <= 0 )
      44           0 :         return fValue;
      45             : 
      46             :     return min(
      47           0 :         static_cast< double >( rNewReferenceSize.Width )  / static_cast< double >( rOldReferenceSize.Width ),
      48           0 :         static_cast< double >( rNewReferenceSize.Height ) / static_cast< double >( rOldReferenceSize.Height ))
      49           0 :         * fValue;
      50             : }
      51             : 
      52           0 : void RelativeSizeHelper::adaptFontSizes(
      53             :     const Reference< XPropertySet > & xTargetProperties,
      54             :     const awt::Size & rOldReferenceSize,
      55             :     const awt::Size & rNewReferenceSize )
      56             : {
      57           0 :     if( ! xTargetProperties.is())
      58           0 :         return;
      59             : 
      60           0 :     float fFontHeight = 0;
      61             : 
      62           0 :     vector< OUString > aProperties;
      63           0 :     aProperties.push_back( "CharHeight" );
      64           0 :     aProperties.push_back( "CharHeightAsian" );
      65           0 :     aProperties.push_back( "CharHeightComplex" );
      66             : 
      67           0 :     for( vector< OUString >::const_iterator aIt = aProperties.begin();
      68           0 :          aIt != aProperties.end(); ++aIt )
      69             :     {
      70             :         try
      71             :         {
      72           0 :             if( xTargetProperties->getPropertyValue( *aIt ) >>= fFontHeight )
      73             :             {
      74           0 :                 xTargetProperties->setPropertyValue(
      75           0 :                     *aIt,
      76             :                     makeAny( static_cast< float >(
      77           0 :                                  calculate( fFontHeight, rOldReferenceSize, rNewReferenceSize ))));
      78             :             }
      79             :         }
      80           0 :         catch( const Exception & ex )
      81             :         {
      82             :             ASSERT_EXCEPTION( ex );
      83             :         }
      84           0 :     }
      85             : }
      86             : 
      87             : } //  namespace chart
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10