1*b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b0724fc6SAndrew Rist * distributed with this work for additional information 6*b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9*b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10*b0724fc6SAndrew Rist * 11*b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b0724fc6SAndrew Rist * 13*b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15*b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17*b0724fc6SAndrew Rist * specific language governing permissions and limitations 18*b0724fc6SAndrew Rist * under the License. 19*b0724fc6SAndrew Rist * 20*b0724fc6SAndrew Rist *************************************************************/ 21*b0724fc6SAndrew Rist 22*b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_toolkit.hxx" 26cdf0e10cSrcweir #include <toolkit/helper/imagealign.hxx> 27cdf0e10cSrcweir #include <com/sun/star/awt/ImagePosition.hpp> 28cdf0e10cSrcweir #include <com/sun/star/awt/ImageAlign.hpp> 29cdf0e10cSrcweir 30cdf0e10cSrcweir //........................................................................ 31cdf0e10cSrcweir namespace toolkit 32cdf0e10cSrcweir { 33cdf0e10cSrcweir //........................................................................ 34cdf0e10cSrcweir 35cdf0e10cSrcweir using namespace ::com::sun::star::awt::ImagePosition; 36cdf0e10cSrcweir using namespace ::com::sun::star::awt::ImageAlign; 37cdf0e10cSrcweir translateImagePosition(ImageAlign _eVCLAlign)38cdf0e10cSrcweir sal_Int16 translateImagePosition( ImageAlign _eVCLAlign ) 39cdf0e10cSrcweir { 40cdf0e10cSrcweir sal_Int16 nReturn = AboveCenter; 41cdf0e10cSrcweir switch ( _eVCLAlign ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir case IMAGEALIGN_LEFT: nReturn = LeftCenter; break; 44cdf0e10cSrcweir case IMAGEALIGN_TOP: nReturn = AboveCenter; break; 45cdf0e10cSrcweir case IMAGEALIGN_RIGHT: nReturn = RightCenter; break; 46cdf0e10cSrcweir case IMAGEALIGN_BOTTOM: nReturn = BelowCenter; break; 47cdf0e10cSrcweir case IMAGEALIGN_LEFT_TOP: nReturn = LeftTop; break; 48cdf0e10cSrcweir case IMAGEALIGN_LEFT_BOTTOM: nReturn = LeftBottom; break; 49cdf0e10cSrcweir case IMAGEALIGN_TOP_LEFT: nReturn = AboveLeft; break; 50cdf0e10cSrcweir case IMAGEALIGN_TOP_RIGHT: nReturn = AboveRight; break; 51cdf0e10cSrcweir case IMAGEALIGN_RIGHT_TOP: nReturn = RightTop; break; 52cdf0e10cSrcweir case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RightBottom; break; 53cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_LEFT: nReturn = BelowLeft; break; 54cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BelowRight; break; 55cdf0e10cSrcweir case IMAGEALIGN_CENTER: nReturn = Centered; break; 56cdf0e10cSrcweir default: 57cdf0e10cSrcweir OSL_ENSURE( sal_False, "translateImagePosition: unknown IMAGEALIGN value!" ); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir return nReturn; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir translateImagePosition(sal_Int16 _eUNOAlign)62cdf0e10cSrcweir ImageAlign translateImagePosition( sal_Int16 _eUNOAlign ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir ImageAlign nReturn = IMAGEALIGN_TOP; 65cdf0e10cSrcweir switch ( _eUNOAlign ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir case LeftCenter: nReturn = IMAGEALIGN_LEFT; break; 68cdf0e10cSrcweir case AboveCenter: nReturn = IMAGEALIGN_TOP; break; 69cdf0e10cSrcweir case RightCenter: nReturn = IMAGEALIGN_RIGHT; break; 70cdf0e10cSrcweir case BelowCenter: nReturn = IMAGEALIGN_BOTTOM; break; 71cdf0e10cSrcweir case LeftTop: nReturn = IMAGEALIGN_LEFT_TOP; break; 72cdf0e10cSrcweir case LeftBottom: nReturn = IMAGEALIGN_LEFT_BOTTOM; break; 73cdf0e10cSrcweir case AboveLeft: nReturn = IMAGEALIGN_TOP_LEFT; break; 74cdf0e10cSrcweir case AboveRight: nReturn = IMAGEALIGN_TOP_RIGHT; break; 75cdf0e10cSrcweir case RightTop: nReturn = IMAGEALIGN_RIGHT_TOP; break; 76cdf0e10cSrcweir case RightBottom: nReturn = IMAGEALIGN_RIGHT_BOTTOM; break; 77cdf0e10cSrcweir case BelowLeft: nReturn = IMAGEALIGN_BOTTOM_LEFT; break; 78cdf0e10cSrcweir case BelowRight: nReturn = IMAGEALIGN_BOTTOM_RIGHT; break; 79cdf0e10cSrcweir case Centered: nReturn = IMAGEALIGN_CENTER; break; 80cdf0e10cSrcweir default: 81cdf0e10cSrcweir OSL_ENSURE( sal_False, "translateImagePosition: unknown css.awt.ImagePosition value!" ); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir return nReturn; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir getCompatibleImageAlign(ImageAlign _eAlign)86cdf0e10cSrcweir sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir sal_Int16 nReturn = TOP; 89cdf0e10cSrcweir switch ( _eAlign ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir case IMAGEALIGN_LEFT_TOP: 92cdf0e10cSrcweir case IMAGEALIGN_LEFT: 93cdf0e10cSrcweir case IMAGEALIGN_LEFT_BOTTOM: nReturn = LEFT; break; 94cdf0e10cSrcweir 95cdf0e10cSrcweir case IMAGEALIGN_TOP_LEFT: 96cdf0e10cSrcweir case IMAGEALIGN_TOP: 97cdf0e10cSrcweir case IMAGEALIGN_TOP_RIGHT: nReturn = TOP; break; 98cdf0e10cSrcweir 99cdf0e10cSrcweir case IMAGEALIGN_RIGHT_TOP: 100cdf0e10cSrcweir case IMAGEALIGN_RIGHT: 101cdf0e10cSrcweir case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RIGHT; break; 102cdf0e10cSrcweir 103cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_LEFT: 104cdf0e10cSrcweir case IMAGEALIGN_BOTTOM: 105cdf0e10cSrcweir case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BOTTOM; break; 106cdf0e10cSrcweir 107cdf0e10cSrcweir case IMAGEALIGN_CENTER: nReturn = TOP; break; 108cdf0e10cSrcweir default: 109cdf0e10cSrcweir OSL_ENSURE( sal_False, "getCompatibleImageAlign: unknown IMAGEALIGN value!" ); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir return nReturn; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir getExtendedImagePosition(sal_Int16 _nImageAlign)114cdf0e10cSrcweir sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir sal_Int16 nReturn = AboveCenter; 117cdf0e10cSrcweir switch ( _nImageAlign ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir case LEFT: nReturn = LeftCenter; break; 120cdf0e10cSrcweir case TOP: nReturn = AboveCenter; break; 121cdf0e10cSrcweir case RIGHT: nReturn = RightCenter; break; 122cdf0e10cSrcweir case BOTTOM: nReturn = BelowCenter; break; 123cdf0e10cSrcweir default: 124cdf0e10cSrcweir OSL_ENSURE( sal_False, "getExtendedImagePosition: unknown ImageAlign value!" ); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir return nReturn; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //........................................................................ 130cdf0e10cSrcweir } // namespace toolkit 131cdf0e10cSrcweir //........................................................................ 132