cURL: follow redirects
[LibreOffice.git] / toolkit / source / helper / imagealign.cxx
blob8f97ec496859b1b629ebe120e5d266b464ca3846
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 <com/sun/star/awt/ImagePosition.hpp>
21 #include <com/sun/star/awt/ImageAlign.hpp>
23 #include "helper/imagealign.hxx"
25 namespace toolkit
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::LeftTop: nReturn = LeftTop; break;
42 case ImageAlign::LeftBottom: nReturn = LeftBottom; break;
43 case ImageAlign::TopLeft: nReturn = AboveLeft; break;
44 case ImageAlign::TopRight: nReturn = AboveRight; break;
45 case ImageAlign::RightTop: nReturn = RightTop; break;
46 case ImageAlign::RightBottom: nReturn = RightBottom; break;
47 case ImageAlign::BottomLeft: nReturn = BelowLeft; break;
48 case ImageAlign::BottomRight: 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::LeftTop; break;
66 case LeftBottom: nReturn = ImageAlign::LeftBottom; break;
67 case AboveLeft: nReturn = ImageAlign::TopLeft; break;
68 case AboveRight: nReturn = ImageAlign::TopRight; break;
69 case RightTop: nReturn = ImageAlign::RightTop; break;
70 case RightBottom: nReturn = ImageAlign::RightBottom; break;
71 case BelowLeft: nReturn = ImageAlign::BottomLeft; break;
72 case BelowRight: nReturn = ImageAlign::BottomRight; 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::LeftTop:
86 case ImageAlign::Left:
87 case ImageAlign::LeftBottom: nReturn = LEFT; break;
89 case ImageAlign::TopLeft:
90 case ImageAlign::Top:
91 case ImageAlign::TopRight: nReturn = TOP; break;
93 case ImageAlign::RightTop:
94 case ImageAlign::Right:
95 case ImageAlign::RightBottom: nReturn = RIGHT; break;
97 case ImageAlign::BottomLeft:
98 case ImageAlign::Bottom:
99 case ImageAlign::BottomRight: 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;
124 } // namespace toolkit
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */