/src/libreoffice/toolkit/source/helper/imagealign.cxx
Line | Count | Source (jump to first uncovered line) |
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 <com/sun/star/awt/ImagePosition.hpp> |
21 | | #include <com/sun/star/awt/ImageAlign.hpp> |
22 | | |
23 | | #include <helper/imagealign.hxx> |
24 | | #include <osl/diagnose.h> |
25 | | |
26 | | namespace toolkit |
27 | | { |
28 | | |
29 | | |
30 | | using namespace ::com::sun::star::awt::ImagePosition; |
31 | | using namespace ::com::sun::star::awt::ImageAlign; |
32 | | |
33 | | sal_Int16 translateImagePosition( ImageAlign _eVCLAlign ) |
34 | 0 | { |
35 | 0 | sal_Int16 nReturn = AboveCenter; |
36 | 0 | switch ( _eVCLAlign ) |
37 | 0 | { |
38 | 0 | case ImageAlign::Left: nReturn = LeftCenter; break; |
39 | 0 | case ImageAlign::Top: nReturn = AboveCenter; break; |
40 | 0 | case ImageAlign::Right: nReturn = RightCenter; break; |
41 | 0 | case ImageAlign::Bottom: nReturn = BelowCenter; break; |
42 | 0 | case ImageAlign::LeftTop: nReturn = LeftTop; break; |
43 | 0 | case ImageAlign::LeftBottom: nReturn = LeftBottom; break; |
44 | 0 | case ImageAlign::TopLeft: nReturn = AboveLeft; break; |
45 | 0 | case ImageAlign::TopRight: nReturn = AboveRight; break; |
46 | 0 | case ImageAlign::RightTop: nReturn = RightTop; break; |
47 | 0 | case ImageAlign::RightBottom: nReturn = RightBottom; break; |
48 | 0 | case ImageAlign::BottomLeft: nReturn = BelowLeft; break; |
49 | 0 | case ImageAlign::BottomRight: nReturn = BelowRight; break; |
50 | 0 | case ImageAlign::Center: nReturn = Centered; break; |
51 | 0 | default: |
52 | 0 | OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" ); |
53 | 0 | } |
54 | 0 | return nReturn; |
55 | 0 | } |
56 | | |
57 | | ImageAlign translateImagePosition( sal_Int16 _eUNOAlign ) |
58 | 0 | { |
59 | 0 | ImageAlign nReturn = ImageAlign::Top; |
60 | 0 | switch ( _eUNOAlign ) |
61 | 0 | { |
62 | 0 | case LeftCenter: nReturn = ImageAlign::Left; break; |
63 | 0 | case AboveCenter: nReturn = ImageAlign::Top; break; |
64 | 0 | case RightCenter: nReturn = ImageAlign::Right; break; |
65 | 0 | case BelowCenter: nReturn = ImageAlign::Bottom; break; |
66 | 0 | case LeftTop: nReturn = ImageAlign::LeftTop; break; |
67 | 0 | case LeftBottom: nReturn = ImageAlign::LeftBottom; break; |
68 | 0 | case AboveLeft: nReturn = ImageAlign::TopLeft; break; |
69 | 0 | case AboveRight: nReturn = ImageAlign::TopRight; break; |
70 | 0 | case RightTop: nReturn = ImageAlign::RightTop; break; |
71 | 0 | case RightBottom: nReturn = ImageAlign::RightBottom; break; |
72 | 0 | case BelowLeft: nReturn = ImageAlign::BottomLeft; break; |
73 | 0 | case BelowRight: nReturn = ImageAlign::BottomRight; break; |
74 | 0 | case Centered: nReturn = ImageAlign::Center; break; |
75 | 0 | default: |
76 | 0 | OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" ); |
77 | 0 | } |
78 | 0 | return nReturn; |
79 | 0 | } |
80 | | |
81 | | sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign ) |
82 | 0 | { |
83 | 0 | sal_Int16 nReturn = TOP; |
84 | 0 | switch ( _eAlign ) |
85 | 0 | { |
86 | 0 | case ImageAlign::LeftTop: |
87 | 0 | case ImageAlign::Left: |
88 | 0 | case ImageAlign::LeftBottom: nReturn = LEFT; break; |
89 | | |
90 | 0 | case ImageAlign::TopLeft: |
91 | 0 | case ImageAlign::Top: |
92 | 0 | case ImageAlign::TopRight: nReturn = TOP; break; |
93 | | |
94 | 0 | case ImageAlign::RightTop: |
95 | 0 | case ImageAlign::Right: |
96 | 0 | case ImageAlign::RightBottom: nReturn = RIGHT; break; |
97 | | |
98 | 0 | case ImageAlign::BottomLeft: |
99 | 0 | case ImageAlign::Bottom: |
100 | 0 | case ImageAlign::BottomRight: nReturn = BOTTOM; break; |
101 | | |
102 | 0 | case ImageAlign::Center: nReturn = TOP; break; |
103 | 0 | default: |
104 | 0 | OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" ); |
105 | 0 | } |
106 | 0 | return nReturn; |
107 | 0 | } |
108 | | |
109 | | sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign ) |
110 | 0 | { |
111 | 0 | sal_Int16 nReturn = AboveCenter; |
112 | 0 | switch ( _nImageAlign ) |
113 | 0 | { |
114 | 0 | case LEFT: nReturn = LeftCenter; break; |
115 | 0 | case TOP: nReturn = AboveCenter; break; |
116 | 0 | case RIGHT: nReturn = RightCenter; break; |
117 | 0 | case BOTTOM: nReturn = BelowCenter; break; |
118 | 0 | default: |
119 | 0 | OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" ); |
120 | 0 | } |
121 | 0 | return nReturn; |
122 | 0 | } |
123 | | |
124 | | |
125 | | } // namespace toolkit |
126 | | |
127 | | |
128 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |