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