LCOV - code coverage report
Current view: top level - toolkit/source/helper - imagealign.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 24 52 46.2 %
Date: 2014-11-03 Functions: 5 6 83.3 %
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 <com/sun/star/awt/ImagePosition.hpp>
      21             : #include <com/sun/star/awt/ImageAlign.hpp>
      22             : 
      23             : #include "helper/imagealign.hxx"
      24             : 
      25             : namespace toolkit
      26             : {
      27             : 
      28             : 
      29             :     using namespace ::com::sun::star::awt::ImagePosition;
      30             :     using namespace ::com::sun::star::awt::ImageAlign;
      31             : 
      32           0 :     sal_Int16 translateImagePosition( ImageAlign _eVCLAlign )
      33             :     {
      34           0 :         sal_Int16 nReturn = AboveCenter;
      35           0 :         switch ( _eVCLAlign )
      36             :         {
      37           0 :         case IMAGEALIGN_LEFT:           nReturn = LeftCenter; break;
      38           0 :         case IMAGEALIGN_TOP:            nReturn = AboveCenter;  break;
      39           0 :         case IMAGEALIGN_RIGHT:          nReturn = RightCenter; break;
      40           0 :         case IMAGEALIGN_BOTTOM:         nReturn = BelowCenter; break;
      41           0 :         case IMAGEALIGN_LEFT_TOP:       nReturn = LeftTop; break;
      42           0 :         case IMAGEALIGN_LEFT_BOTTOM:    nReturn = LeftBottom; break;
      43           0 :         case IMAGEALIGN_TOP_LEFT:       nReturn = AboveLeft; break;
      44           0 :         case IMAGEALIGN_TOP_RIGHT:      nReturn = AboveRight; break;
      45           0 :         case IMAGEALIGN_RIGHT_TOP:      nReturn = RightTop; break;
      46           0 :         case IMAGEALIGN_RIGHT_BOTTOM:   nReturn = RightBottom; break;
      47           0 :         case IMAGEALIGN_BOTTOM_LEFT:    nReturn = BelowLeft; break;
      48           0 :         case IMAGEALIGN_BOTTOM_RIGHT:   nReturn = BelowRight; break;
      49           0 :         case IMAGEALIGN_CENTER:         nReturn = Centered; break;
      50             :         default:
      51             :             OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" );
      52             :         }
      53           0 :         return nReturn;
      54             :     }
      55             : 
      56         381 :     ImageAlign translateImagePosition( sal_Int16 _eUNOAlign )
      57             :     {
      58         381 :         ImageAlign nReturn = IMAGEALIGN_TOP;
      59         381 :         switch ( _eUNOAlign )
      60             :         {
      61           0 :         case LeftCenter:  nReturn = IMAGEALIGN_LEFT; break;
      62         106 :         case AboveCenter: nReturn = IMAGEALIGN_TOP;  break;
      63           0 :         case RightCenter: nReturn = IMAGEALIGN_RIGHT; break;
      64           0 :         case BelowCenter: nReturn = IMAGEALIGN_BOTTOM; break;
      65           0 :         case LeftTop:     nReturn = IMAGEALIGN_LEFT_TOP; break;
      66           0 :         case LeftBottom:  nReturn = IMAGEALIGN_LEFT_BOTTOM; break;
      67           0 :         case AboveLeft:   nReturn = IMAGEALIGN_TOP_LEFT; break;
      68           2 :         case AboveRight:  nReturn = IMAGEALIGN_TOP_RIGHT; break;
      69           0 :         case RightTop:    nReturn = IMAGEALIGN_RIGHT_TOP; break;
      70           6 :         case RightBottom: nReturn = IMAGEALIGN_RIGHT_BOTTOM; break;
      71           0 :         case BelowLeft:   nReturn = IMAGEALIGN_BOTTOM_LEFT; break;
      72           2 :         case BelowRight:  nReturn = IMAGEALIGN_BOTTOM_RIGHT; break;
      73         195 :         case Centered:    nReturn = IMAGEALIGN_CENTER; break;
      74             :         default:
      75             :             OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" );
      76             :         }
      77         381 :         return nReturn;
      78             :     }
      79             : 
      80         178 :     sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign )
      81             :     {
      82         178 :         sal_Int16 nReturn = TOP;
      83         178 :         switch ( _eAlign )
      84             :         {
      85             :         case IMAGEALIGN_LEFT_TOP:
      86             :         case IMAGEALIGN_LEFT:
      87           0 :         case IMAGEALIGN_LEFT_BOTTOM:    nReturn = LEFT; break;
      88             : 
      89             :         case IMAGEALIGN_TOP_LEFT:
      90             :         case IMAGEALIGN_TOP:
      91          52 :         case IMAGEALIGN_TOP_RIGHT:      nReturn = TOP; break;
      92             : 
      93             :         case IMAGEALIGN_RIGHT_TOP:
      94             :         case IMAGEALIGN_RIGHT:
      95           6 :         case IMAGEALIGN_RIGHT_BOTTOM:   nReturn = RIGHT; break;
      96             : 
      97             :         case IMAGEALIGN_BOTTOM_LEFT:
      98             :         case IMAGEALIGN_BOTTOM:
      99           2 :         case IMAGEALIGN_BOTTOM_RIGHT:   nReturn = BOTTOM; break;
     100             : 
     101         118 :         case IMAGEALIGN_CENTER:         nReturn = TOP; break;
     102             :         default:
     103             :             OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" );
     104             :         }
     105         178 :         return nReturn;
     106             :     }
     107             : 
     108          12 :     sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign )
     109             :     {
     110          12 :         sal_Int16 nReturn = AboveCenter;
     111          12 :         switch ( _nImageAlign )
     112             :         {
     113           0 :         case LEFT:   nReturn = LeftCenter; break;
     114           0 :         case TOP:    nReturn = AboveCenter; break;
     115           8 :         case RIGHT:  nReturn = RightCenter; break;
     116           2 :         case BOTTOM: nReturn = BelowCenter; break;
     117             :         default:
     118             :             OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" );
     119             :         }
     120          12 :         return nReturn;
     121             :     }
     122             : 
     123             : 
     124        1227 : }   // namespace toolkit
     125             : 
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10