LCOV - code coverage report
Current view: top level - toolkit/source/helper - imagealign.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 51 45.1 %
Date: 2012-08-25 Functions: 3 4 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 39 33.3 %

           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 <toolkit/helper/imagealign.hxx>
      30                 :            : #include <com/sun/star/awt/ImagePosition.hpp>
      31                 :            : #include <com/sun/star/awt/ImageAlign.hpp>
      32                 :            : 
      33                 :            : //........................................................................
      34                 :            : namespace toolkit
      35                 :            : {
      36                 :            : //........................................................................
      37                 :            : 
      38                 :            :     using namespace ::com::sun::star::awt::ImagePosition;
      39                 :            :     using namespace ::com::sun::star::awt::ImageAlign;
      40                 :            : 
      41                 :          0 :     sal_Int16 translateImagePosition( ImageAlign _eVCLAlign )
      42                 :            :     {
      43                 :          0 :         sal_Int16 nReturn = AboveCenter;
      44   [ #  #  #  #  :          0 :         switch ( _eVCLAlign )
          #  #  #  #  #  
             #  #  #  #  
                      # ]
      45                 :            :         {
      46                 :          0 :         case IMAGEALIGN_LEFT:           nReturn = LeftCenter; break;
      47                 :          0 :         case IMAGEALIGN_TOP:            nReturn = AboveCenter;  break;
      48                 :          0 :         case IMAGEALIGN_RIGHT:          nReturn = RightCenter; break;
      49                 :          0 :         case IMAGEALIGN_BOTTOM:         nReturn = BelowCenter; break;
      50                 :          0 :         case IMAGEALIGN_LEFT_TOP:       nReturn = LeftTop; break;
      51                 :          0 :         case IMAGEALIGN_LEFT_BOTTOM:    nReturn = LeftBottom; break;
      52                 :          0 :         case IMAGEALIGN_TOP_LEFT:       nReturn = AboveLeft; break;
      53                 :          0 :         case IMAGEALIGN_TOP_RIGHT:      nReturn = AboveRight; break;
      54                 :          0 :         case IMAGEALIGN_RIGHT_TOP:      nReturn = RightTop; break;
      55                 :          0 :         case IMAGEALIGN_RIGHT_BOTTOM:   nReturn = RightBottom; break;
      56                 :          0 :         case IMAGEALIGN_BOTTOM_LEFT:    nReturn = BelowLeft; break;
      57                 :          0 :         case IMAGEALIGN_BOTTOM_RIGHT:   nReturn = BelowRight; break;
      58                 :          0 :         case IMAGEALIGN_CENTER:         nReturn = Centered; break;
      59                 :            :         default:
      60                 :            :             OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" );
      61                 :            :         }
      62                 :          0 :         return nReturn;
      63                 :            :     }
      64                 :            : 
      65                 :        240 :     ImageAlign translateImagePosition( sal_Int16 _eUNOAlign )
      66                 :            :     {
      67                 :        240 :         ImageAlign nReturn = IMAGEALIGN_TOP;
      68   [ -  +  -  -  :        240 :         switch ( _eUNOAlign )
          -  -  -  +  -  
             +  -  +  +  
                      + ]
      69                 :            :         {
      70                 :          0 :         case LeftCenter:  nReturn = IMAGEALIGN_LEFT; break;
      71                 :         13 :         case AboveCenter: nReturn = IMAGEALIGN_TOP;  break;
      72                 :          0 :         case RightCenter: nReturn = IMAGEALIGN_RIGHT; break;
      73                 :          0 :         case BelowCenter: nReturn = IMAGEALIGN_BOTTOM; break;
      74                 :          0 :         case LeftTop:     nReturn = IMAGEALIGN_LEFT_TOP; break;
      75                 :          0 :         case LeftBottom:  nReturn = IMAGEALIGN_LEFT_BOTTOM; break;
      76                 :          0 :         case AboveLeft:   nReturn = IMAGEALIGN_TOP_LEFT; break;
      77                 :          2 :         case AboveRight:  nReturn = IMAGEALIGN_TOP_RIGHT; break;
      78                 :          0 :         case RightTop:    nReturn = IMAGEALIGN_RIGHT_TOP; break;
      79                 :          6 :         case RightBottom: nReturn = IMAGEALIGN_RIGHT_BOTTOM; break;
      80                 :          0 :         case BelowLeft:   nReturn = IMAGEALIGN_BOTTOM_LEFT; break;
      81                 :          2 :         case BelowRight:  nReturn = IMAGEALIGN_BOTTOM_RIGHT; break;
      82                 :        147 :         case Centered:    nReturn = IMAGEALIGN_CENTER; break;
      83                 :            :         default:
      84                 :            :             OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" );
      85                 :            :         }
      86                 :        240 :         return nReturn;
      87                 :            :     }
      88                 :            : 
      89                 :         92 :     sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign )
      90                 :            :     {
      91                 :         92 :         sal_Int16 nReturn = TOP;
      92   [ -  +  +  +  :         92 :         switch ( _eAlign )
                   +  - ]
      93                 :            :         {
      94                 :            :         case IMAGEALIGN_LEFT_TOP:
      95                 :            :         case IMAGEALIGN_LEFT:
      96                 :          0 :         case IMAGEALIGN_LEFT_BOTTOM:    nReturn = LEFT; break;
      97                 :            : 
      98                 :            :         case IMAGEALIGN_TOP_LEFT:
      99                 :            :         case IMAGEALIGN_TOP:
     100                 :         15 :         case IMAGEALIGN_TOP_RIGHT:      nReturn = TOP; break;
     101                 :            : 
     102                 :            :         case IMAGEALIGN_RIGHT_TOP:
     103                 :            :         case IMAGEALIGN_RIGHT:
     104                 :          6 :         case IMAGEALIGN_RIGHT_BOTTOM:   nReturn = RIGHT; break;
     105                 :            : 
     106                 :            :         case IMAGEALIGN_BOTTOM_LEFT:
     107                 :            :         case IMAGEALIGN_BOTTOM:
     108                 :          2 :         case IMAGEALIGN_BOTTOM_RIGHT:   nReturn = BOTTOM; break;
     109                 :            : 
     110                 :         69 :         case IMAGEALIGN_CENTER:         nReturn = TOP; break;
     111                 :            :         default:
     112                 :            :             OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" );
     113                 :            :         }
     114                 :         92 :         return nReturn;
     115                 :            :     }
     116                 :            : 
     117                 :         12 :     sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign )
     118                 :            :     {
     119                 :         12 :         sal_Int16 nReturn = AboveCenter;
     120   [ -  -  +  +  :         12 :         switch ( _nImageAlign )
                      + ]
     121                 :            :         {
     122                 :          0 :         case LEFT:   nReturn = LeftCenter; break;
     123                 :          0 :         case TOP:    nReturn = AboveCenter; break;
     124                 :          8 :         case RIGHT:  nReturn = RightCenter; break;
     125                 :          2 :         case BOTTOM: nReturn = BelowCenter; break;
     126                 :            :         default:
     127                 :            :             OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" );
     128                 :            :         }
     129                 :         12 :         return nReturn;
     130                 :            :     }
     131                 :            : 
     132                 :            : //........................................................................
     133                 :            : }   // namespace toolkit
     134                 :            : //........................................................................
     135                 :            : 
     136                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10