1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_toolkit.hxx" 30*cdf0e10cSrcweir #include <toolkit/helper/imagealign.hxx> 31*cdf0e10cSrcweir #include <com/sun/star/awt/ImagePosition.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/awt/ImageAlign.hpp> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir //........................................................................ 35*cdf0e10cSrcweir namespace toolkit 36*cdf0e10cSrcweir { 37*cdf0e10cSrcweir //........................................................................ 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir using namespace ::com::sun::star::awt::ImagePosition; 40*cdf0e10cSrcweir using namespace ::com::sun::star::awt::ImageAlign; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir sal_Int16 translateImagePosition( ImageAlign _eVCLAlign ) 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir sal_Int16 nReturn = AboveCenter; 45*cdf0e10cSrcweir switch ( _eVCLAlign ) 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir case IMAGEALIGN_LEFT: nReturn = LeftCenter; break; 48*cdf0e10cSrcweir case IMAGEALIGN_TOP: nReturn = AboveCenter; break; 49*cdf0e10cSrcweir case IMAGEALIGN_RIGHT: nReturn = RightCenter; break; 50*cdf0e10cSrcweir case IMAGEALIGN_BOTTOM: nReturn = BelowCenter; break; 51*cdf0e10cSrcweir case IMAGEALIGN_LEFT_TOP: nReturn = LeftTop; break; 52*cdf0e10cSrcweir case IMAGEALIGN_LEFT_BOTTOM: nReturn = LeftBottom; break; 53*cdf0e10cSrcweir case IMAGEALIGN_TOP_LEFT: nReturn = AboveLeft; break; 54*cdf0e10cSrcweir case IMAGEALIGN_TOP_RIGHT: nReturn = AboveRight; break; 55*cdf0e10cSrcweir case IMAGEALIGN_RIGHT_TOP: nReturn = RightTop; break; 56*cdf0e10cSrcweir case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RightBottom; break; 57*cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_LEFT: nReturn = BelowLeft; break; 58*cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BelowRight; break; 59*cdf0e10cSrcweir case IMAGEALIGN_CENTER: nReturn = Centered; break; 60*cdf0e10cSrcweir default: 61*cdf0e10cSrcweir OSL_ENSURE( sal_False, "translateImagePosition: unknown IMAGEALIGN value!" ); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir return nReturn; 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir ImageAlign translateImagePosition( sal_Int16 _eUNOAlign ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir ImageAlign nReturn = IMAGEALIGN_TOP; 69*cdf0e10cSrcweir switch ( _eUNOAlign ) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir case LeftCenter: nReturn = IMAGEALIGN_LEFT; break; 72*cdf0e10cSrcweir case AboveCenter: nReturn = IMAGEALIGN_TOP; break; 73*cdf0e10cSrcweir case RightCenter: nReturn = IMAGEALIGN_RIGHT; break; 74*cdf0e10cSrcweir case BelowCenter: nReturn = IMAGEALIGN_BOTTOM; break; 75*cdf0e10cSrcweir case LeftTop: nReturn = IMAGEALIGN_LEFT_TOP; break; 76*cdf0e10cSrcweir case LeftBottom: nReturn = IMAGEALIGN_LEFT_BOTTOM; break; 77*cdf0e10cSrcweir case AboveLeft: nReturn = IMAGEALIGN_TOP_LEFT; break; 78*cdf0e10cSrcweir case AboveRight: nReturn = IMAGEALIGN_TOP_RIGHT; break; 79*cdf0e10cSrcweir case RightTop: nReturn = IMAGEALIGN_RIGHT_TOP; break; 80*cdf0e10cSrcweir case RightBottom: nReturn = IMAGEALIGN_RIGHT_BOTTOM; break; 81*cdf0e10cSrcweir case BelowLeft: nReturn = IMAGEALIGN_BOTTOM_LEFT; break; 82*cdf0e10cSrcweir case BelowRight: nReturn = IMAGEALIGN_BOTTOM_RIGHT; break; 83*cdf0e10cSrcweir case Centered: nReturn = IMAGEALIGN_CENTER; break; 84*cdf0e10cSrcweir default: 85*cdf0e10cSrcweir OSL_ENSURE( sal_False, "translateImagePosition: unknown css.awt.ImagePosition value!" ); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir return nReturn; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir sal_Int16 nReturn = TOP; 93*cdf0e10cSrcweir switch ( _eAlign ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir case IMAGEALIGN_LEFT_TOP: 96*cdf0e10cSrcweir case IMAGEALIGN_LEFT: 97*cdf0e10cSrcweir case IMAGEALIGN_LEFT_BOTTOM: nReturn = LEFT; break; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir case IMAGEALIGN_TOP_LEFT: 100*cdf0e10cSrcweir case IMAGEALIGN_TOP: 101*cdf0e10cSrcweir case IMAGEALIGN_TOP_RIGHT: nReturn = TOP; break; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir case IMAGEALIGN_RIGHT_TOP: 104*cdf0e10cSrcweir case IMAGEALIGN_RIGHT: 105*cdf0e10cSrcweir case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RIGHT; break; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_LEFT: 108*cdf0e10cSrcweir case IMAGEALIGN_BOTTOM: 109*cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BOTTOM; break; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir case IMAGEALIGN_CENTER: nReturn = TOP; break; 112*cdf0e10cSrcweir default: 113*cdf0e10cSrcweir OSL_ENSURE( sal_False, "getCompatibleImageAlign: unknown IMAGEALIGN value!" ); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir return nReturn; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir sal_Int16 nReturn = AboveCenter; 121*cdf0e10cSrcweir switch ( _nImageAlign ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir case LEFT: nReturn = LeftCenter; break; 124*cdf0e10cSrcweir case TOP: nReturn = AboveCenter; break; 125*cdf0e10cSrcweir case RIGHT: nReturn = RightCenter; break; 126*cdf0e10cSrcweir case BOTTOM: nReturn = BelowCenter; break; 127*cdf0e10cSrcweir default: 128*cdf0e10cSrcweir OSL_ENSURE( sal_False, "getExtendedImagePosition: unknown ImageAlign value!" ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir return nReturn; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //........................................................................ 134*cdf0e10cSrcweir } // namespace toolkit 135*cdf0e10cSrcweir //........................................................................ 136