Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <toolkit/helper/imagealign.hxx>
21 : #include <com/sun/star/awt/ImagePosition.hpp>
22 : #include <com/sun/star/awt/ImageAlign.hpp>
23 :
24 :
25 : namespace toolkit
26 : {
27 :
28 :
29 : using namespace ::com::sun::star::awt::ImagePosition;
30 : using namespace ::com::sun::star::awt::ImageAlign;
31 :
32 0 : sal_Int16 translateImagePosition( ImageAlign _eVCLAlign )
33 : {
34 0 : sal_Int16 nReturn = AboveCenter;
35 0 : switch ( _eVCLAlign )
36 : {
37 0 : case IMAGEALIGN_LEFT: nReturn = LeftCenter; break;
38 0 : case IMAGEALIGN_TOP: nReturn = AboveCenter; break;
39 0 : case IMAGEALIGN_RIGHT: nReturn = RightCenter; break;
40 0 : case IMAGEALIGN_BOTTOM: nReturn = BelowCenter; break;
41 0 : case IMAGEALIGN_LEFT_TOP: nReturn = LeftTop; break;
42 0 : case IMAGEALIGN_LEFT_BOTTOM: nReturn = LeftBottom; break;
43 0 : case IMAGEALIGN_TOP_LEFT: nReturn = AboveLeft; break;
44 0 : case IMAGEALIGN_TOP_RIGHT: nReturn = AboveRight; break;
45 0 : case IMAGEALIGN_RIGHT_TOP: nReturn = RightTop; break;
46 0 : case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RightBottom; break;
47 0 : case IMAGEALIGN_BOTTOM_LEFT: nReturn = BelowLeft; break;
48 0 : case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BelowRight; break;
49 0 : case IMAGEALIGN_CENTER: nReturn = Centered; break;
50 : default:
51 : OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" );
52 : }
53 0 : return nReturn;
54 : }
55 :
56 0 : ImageAlign translateImagePosition( sal_Int16 _eUNOAlign )
57 : {
58 0 : ImageAlign nReturn = IMAGEALIGN_TOP;
59 0 : switch ( _eUNOAlign )
60 : {
61 0 : case LeftCenter: nReturn = IMAGEALIGN_LEFT; break;
62 0 : case AboveCenter: nReturn = IMAGEALIGN_TOP; break;
63 0 : case RightCenter: nReturn = IMAGEALIGN_RIGHT; break;
64 0 : case BelowCenter: nReturn = IMAGEALIGN_BOTTOM; break;
65 0 : case LeftTop: nReturn = IMAGEALIGN_LEFT_TOP; break;
66 0 : case LeftBottom: nReturn = IMAGEALIGN_LEFT_BOTTOM; break;
67 0 : case AboveLeft: nReturn = IMAGEALIGN_TOP_LEFT; break;
68 0 : case AboveRight: nReturn = IMAGEALIGN_TOP_RIGHT; break;
69 0 : case RightTop: nReturn = IMAGEALIGN_RIGHT_TOP; break;
70 0 : case RightBottom: nReturn = IMAGEALIGN_RIGHT_BOTTOM; break;
71 0 : case BelowLeft: nReturn = IMAGEALIGN_BOTTOM_LEFT; break;
72 0 : case BelowRight: nReturn = IMAGEALIGN_BOTTOM_RIGHT; break;
73 0 : case Centered: nReturn = IMAGEALIGN_CENTER; break;
74 : default:
75 : OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" );
76 : }
77 0 : return nReturn;
78 : }
79 :
80 0 : sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign )
81 : {
82 0 : sal_Int16 nReturn = TOP;
83 0 : switch ( _eAlign )
84 : {
85 : case IMAGEALIGN_LEFT_TOP:
86 : case IMAGEALIGN_LEFT:
87 0 : case IMAGEALIGN_LEFT_BOTTOM: nReturn = LEFT; break;
88 :
89 : case IMAGEALIGN_TOP_LEFT:
90 : case IMAGEALIGN_TOP:
91 0 : case IMAGEALIGN_TOP_RIGHT: nReturn = TOP; break;
92 :
93 : case IMAGEALIGN_RIGHT_TOP:
94 : case IMAGEALIGN_RIGHT:
95 0 : case IMAGEALIGN_RIGHT_BOTTOM: nReturn = RIGHT; break;
96 :
97 : case IMAGEALIGN_BOTTOM_LEFT:
98 : case IMAGEALIGN_BOTTOM:
99 0 : case IMAGEALIGN_BOTTOM_RIGHT: nReturn = BOTTOM; break;
100 :
101 0 : case IMAGEALIGN_CENTER: nReturn = TOP; break;
102 : default:
103 : OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" );
104 : }
105 0 : return nReturn;
106 : }
107 :
108 0 : sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign )
109 : {
110 0 : sal_Int16 nReturn = AboveCenter;
111 0 : switch ( _nImageAlign )
112 : {
113 0 : case LEFT: nReturn = LeftCenter; break;
114 0 : case TOP: nReturn = AboveCenter; break;
115 0 : case RIGHT: nReturn = RightCenter; break;
116 0 : case BOTTOM: nReturn = BelowCenter; break;
117 : default:
118 : OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" );
119 : }
120 0 : return nReturn;
121 : }
122 :
123 :
124 : } // namespace toolkit
125 :
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|