bump product version to 4.1.6.2
[LibreOffice.git] / toolkit / source / helper / imagealign.cxx
blobfa5297f5eebcaa483a926f954b80e941873a3198
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <toolkit/helper/imagealign.hxx>
21 #include <com/sun/star/awt/ImagePosition.hpp>
22 #include <com/sun/star/awt/ImageAlign.hpp>
24 //........................................................................
25 namespace toolkit
27 //........................................................................
29 using namespace ::com::sun::star::awt::ImagePosition;
30 using namespace ::com::sun::star::awt::ImageAlign;
32 sal_Int16 translateImagePosition( ImageAlign _eVCLAlign )
34 sal_Int16 nReturn = AboveCenter;
35 switch ( _eVCLAlign )
37 case IMAGEALIGN_LEFT: nReturn = LeftCenter; break;
38 case IMAGEALIGN_TOP: nReturn = AboveCenter; break;
39 case IMAGEALIGN_RIGHT: nReturn = RightCenter; break;
40 case IMAGEALIGN_BOTTOM: nReturn = BelowCenter; break;
41 case IMAGEALIGN_LEFT_TOP: nReturn = LeftTop; break;
42 case IMAGEALIGN_LEFT_BOTTOM: nReturn = LeftBottom; break;
43 case IMAGEALIGN_TOP_LEFT: nReturn = AboveLeft; break;
44 case IMAGEALIGN_TOP_RIGHT: nReturn = AboveRight; break;
45 case IMAGEALIGN_RIGHT_TOP: nReturn = RightTop; break;
46 case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RightBottom; break;
47 case IMAGEALIGN_BOTTOM_LEFT: nReturn = BelowLeft; break;
48 case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BelowRight; break;
49 case IMAGEALIGN_CENTER: nReturn = Centered; break;
50 default:
51 OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" );
53 return nReturn;
56 ImageAlign translateImagePosition( sal_Int16 _eUNOAlign )
58 ImageAlign nReturn = IMAGEALIGN_TOP;
59 switch ( _eUNOAlign )
61 case LeftCenter: nReturn = IMAGEALIGN_LEFT; break;
62 case AboveCenter: nReturn = IMAGEALIGN_TOP; break;
63 case RightCenter: nReturn = IMAGEALIGN_RIGHT; break;
64 case BelowCenter: nReturn = IMAGEALIGN_BOTTOM; break;
65 case LeftTop: nReturn = IMAGEALIGN_LEFT_TOP; break;
66 case LeftBottom: nReturn = IMAGEALIGN_LEFT_BOTTOM; break;
67 case AboveLeft: nReturn = IMAGEALIGN_TOP_LEFT; break;
68 case AboveRight: nReturn = IMAGEALIGN_TOP_RIGHT; break;
69 case RightTop: nReturn = IMAGEALIGN_RIGHT_TOP; break;
70 case RightBottom: nReturn = IMAGEALIGN_RIGHT_BOTTOM; break;
71 case BelowLeft: nReturn = IMAGEALIGN_BOTTOM_LEFT; break;
72 case BelowRight: nReturn = IMAGEALIGN_BOTTOM_RIGHT; break;
73 case Centered: nReturn = IMAGEALIGN_CENTER; break;
74 default:
75 OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" );
77 return nReturn;
80 sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign )
82 sal_Int16 nReturn = TOP;
83 switch ( _eAlign )
85 case IMAGEALIGN_LEFT_TOP:
86 case IMAGEALIGN_LEFT:
87 case IMAGEALIGN_LEFT_BOTTOM: nReturn = LEFT; break;
89 case IMAGEALIGN_TOP_LEFT:
90 case IMAGEALIGN_TOP:
91 case IMAGEALIGN_TOP_RIGHT: nReturn = TOP; break;
93 case IMAGEALIGN_RIGHT_TOP:
94 case IMAGEALIGN_RIGHT:
95 case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RIGHT; break;
97 case IMAGEALIGN_BOTTOM_LEFT:
98 case IMAGEALIGN_BOTTOM:
99 case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BOTTOM; break;
101 case IMAGEALIGN_CENTER: nReturn = TOP; break;
102 default:
103 OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" );
105 return nReturn;
108 sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign )
110 sal_Int16 nReturn = AboveCenter;
111 switch ( _nImageAlign )
113 case LEFT: nReturn = LeftCenter; break;
114 case TOP: nReturn = AboveCenter; break;
115 case RIGHT: nReturn = RightCenter; break;
116 case BOTTOM: nReturn = BelowCenter; break;
117 default:
118 OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" );
120 return nReturn;
123 //........................................................................
124 } // namespace toolkit
125 //........................................................................
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */