LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/controller - SlsAnimationFunction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 65 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 32 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 "controller/SlsAnimationFunction.hxx"
      30                 :            : #include "model/SlsPageDescriptor.hxx"
      31                 :            : #include "view/SlideSorterView.hxx"
      32                 :            : 
      33                 :            : 
      34                 :            : #include <osl/diagnose.hxx>
      35                 :            : #include <rtl/math.hxx>
      36                 :            : 
      37                 :            : namespace sd { namespace slidesorter { namespace controller {
      38                 :            : 
      39                 :            : 
      40                 :          0 : double AnimationFunction::Linear (const double nTime)
      41                 :            : {
      42                 :            :     OSL_ASSERT(nTime>=0.0 && nTime<=1.0);
      43                 :          0 :     return nTime;
      44                 :            : }
      45                 :            : 
      46                 :            : 
      47                 :            : 
      48                 :            : 
      49                 :          0 : double AnimationFunction::Blend (
      50                 :            :     const double nStartValue,
      51                 :            :     const double nEndValue,
      52                 :            :     const double nTime)
      53                 :            : {
      54                 :          0 :     return nStartValue*(1-nTime) + nEndValue*nTime;
      55                 :            : }
      56                 :            : 
      57                 :            : 
      58                 :            : 
      59                 :            : 
      60                 :          0 : void AnimationFunction::ApplyButtonAlphaChange(
      61                 :            :     const model::SharedPageDescriptor& rpDescriptor,
      62                 :            :     view::SlideSorterView& rView,
      63                 :            :     const double nButtonAlpha,
      64                 :            :     const double nButtonBarAlpha)
      65                 :            : {
      66         [ #  # ]:          0 :     if (rpDescriptor)
      67                 :            :     {
      68                 :          0 :         rpDescriptor->GetVisualState().SetButtonAlpha(nButtonAlpha);
      69                 :          0 :         rpDescriptor->GetVisualState().SetButtonBarAlpha(nButtonBarAlpha);
      70                 :          0 :         rView.RequestRepaint(rpDescriptor);
      71                 :            :     }
      72                 :          0 : }
      73                 :            : 
      74                 :            : 
      75                 :            : 
      76                 :            : 
      77                 :            : //===== AnimationBezierFunction ===============================================
      78                 :            : 
      79                 :          0 : AnimationBezierFunction::AnimationBezierFunction (
      80                 :            :     const double nX1,
      81                 :            :     const double nY1)
      82                 :            :     : mnX1(nX1),
      83                 :            :       mnY1(nY1),
      84                 :            :       mnX2(1-nY1),
      85                 :          0 :       mnY2(1-nX1)
      86                 :            : {
      87                 :          0 : }
      88                 :            : 
      89                 :            : 
      90                 :            : 
      91                 :            : 
      92                 :          0 : ::basegfx::B2DPoint AnimationBezierFunction::operator() (const double nT)
      93                 :            : {
      94                 :            :     return ::basegfx::B2DPoint(
      95                 :            :         EvaluateComponent(nT, mnX1, mnX2),
      96                 :          0 :         EvaluateComponent(nT, mnY1, mnY2));
      97                 :            : }
      98                 :            : 
      99                 :            : 
     100                 :            : 
     101                 :            : 
     102                 :          0 : double AnimationBezierFunction::EvaluateComponent (
     103                 :            :     const double nT,
     104                 :            :     const double nV1,
     105                 :            :     const double nV2)
     106                 :            : {
     107                 :          0 :     const double nS (1-nT);
     108                 :            : 
     109                 :            :     // While the control point values 1 and 2 are explicitly given the start
     110                 :            :     // and end values are implicitly given.
     111                 :          0 :     const double nV0 (0);
     112                 :          0 :     const double nV3 (1);
     113                 :            : 
     114                 :          0 :     const double nV01 (nS*nV0 + nT*nV1);
     115                 :          0 :     const double nV12 (nS*nV1 + nT*nV2);
     116                 :          0 :     const double nV23 (nS*nV2 + nT*nV3);
     117                 :            : 
     118                 :          0 :     const double nV012 (nS*nV01 + nT*nV12);
     119                 :          0 :     const double nV123 (nS*nV12 + nT*nV23);
     120                 :            : 
     121                 :          0 :     const double nV0123 (nS*nV012 + nT*nV123);
     122                 :            : 
     123                 :          0 :     return nV0123;
     124                 :            : }
     125                 :            : 
     126                 :            : 
     127                 :            : 
     128                 :            : 
     129                 :            : //===== AnimationParametricFunction ===========================================
     130                 :            : 
     131                 :          0 : AnimationParametricFunction::AnimationParametricFunction (const ParametricFunction& rFunction)
     132                 :          0 :     : maY()
     133                 :            : {
     134                 :          0 :     const sal_Int32 nSampleCount (64);
     135                 :            : 
     136                 :            :     // Sample the given parametric function.
     137         [ #  # ]:          0 :     ::std::vector<basegfx::B2DPoint> aPoints;
     138         [ #  # ]:          0 :     aPoints.reserve(nSampleCount);
     139         [ #  # ]:          0 :     for (sal_Int32 nIndex=0; nIndex<nSampleCount; ++nIndex)
     140                 :            :     {
     141                 :          0 :         const double nT (nIndex/double(nSampleCount-1));
     142 [ #  # ][ #  # ]:          0 :         aPoints.push_back(basegfx::B2DPoint(rFunction(nT)));
     143                 :            :     }
     144                 :            : 
     145                 :            :     // Interpolate at evenly spaced points.
     146                 :          0 :     maY.clear();
     147         [ #  # ]:          0 :     maY.reserve(nSampleCount);
     148                 :          0 :     double nX0 (aPoints[0].getX());
     149                 :          0 :     double nY0 (aPoints[0].getY());
     150                 :          0 :     double nX1 (aPoints[1].getX());
     151                 :          0 :     double nY1 (aPoints[1].getY());
     152                 :          0 :     sal_Int32 nIndex (1);
     153         [ #  # ]:          0 :     for (sal_Int32 nIndex2=0; nIndex2<nSampleCount; ++nIndex2)
     154                 :            :     {
     155                 :          0 :         const double nX (nIndex2 / double(nSampleCount-1));
     156 [ #  # ][ #  # ]:          0 :         while (nX > nX1 && nIndex<nSampleCount)
                 [ #  # ]
     157                 :            :         {
     158                 :          0 :             nX0 = nX1;
     159                 :          0 :             nY0 = nY1;
     160                 :          0 :             nX1 = aPoints[nIndex].getX();
     161                 :          0 :             nY1 = aPoints[nIndex].getY();
     162                 :          0 :             ++nIndex;
     163                 :            :         }
     164                 :          0 :         const double nU ((nX-nX1) / (nX0 - nX1));
     165                 :          0 :         const double nY (nY0*nU + nY1*(1-nU));
     166         [ #  # ]:          0 :         maY.push_back(nY);
     167                 :          0 :     }
     168                 :          0 : }
     169                 :            : 
     170                 :            : 
     171                 :            : 
     172                 :            : 
     173                 :          0 : double AnimationParametricFunction::operator() (const double nX)
     174                 :            : {
     175                 :          0 :     const sal_Int32 nIndex0 (static_cast<sal_Int32>(nX * maY.size()));
     176                 :          0 :     const double nX0 (nIndex0 / double(maY.size()-1));
     177                 :          0 :     const sal_uInt32 nIndex1 (nIndex0 + 1);
     178                 :          0 :     const double nX1 (nIndex1 / double(maY.size()-1));
     179                 :            : 
     180         [ #  # ]:          0 :     if (nIndex0<=0)
     181                 :          0 :         return maY[0];
     182 [ #  # ][ #  # ]:          0 :     else if (sal_uInt32(nIndex0)>=maY.size() || nIndex1>=maY.size())
                 [ #  # ]
     183                 :          0 :         return maY[maY.size()-1];
     184                 :            : 
     185                 :          0 :     const double nU ((nX-nX1) / (nX0 - nX1));
     186                 :          0 :     return maY[nIndex0]*nU + maY[nIndex1]*(1-nU);
     187                 :            : }
     188                 :            : 
     189                 :            : 
     190                 :            : } } } // end of namespace ::sd::slidesorter::controller
     191                 :            : 
     192                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10