LibreOffice Module toolkit (master) 1
imagealign.cxx
Go to the documentation of this file.
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
26namespace 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 {
35 sal_Int16 nReturn = AboveCenter;
36 switch ( _eVCLAlign )
37 {
38 case ImageAlign::Left: nReturn = LeftCenter; break;
39 case ImageAlign::Top: nReturn = AboveCenter; break;
40 case ImageAlign::Right: nReturn = RightCenter; break;
41 case ImageAlign::Bottom: nReturn = BelowCenter; break;
42 case ImageAlign::LeftTop: nReturn = LeftTop; break;
43 case ImageAlign::LeftBottom: nReturn = LeftBottom; break;
44 case ImageAlign::TopLeft: nReturn = AboveLeft; break;
45 case ImageAlign::TopRight: nReturn = AboveRight; break;
46 case ImageAlign::RightTop: nReturn = RightTop; break;
47 case ImageAlign::RightBottom: nReturn = RightBottom; break;
48 case ImageAlign::BottomLeft: nReturn = BelowLeft; break;
49 case ImageAlign::BottomRight: nReturn = BelowRight; break;
50 case ImageAlign::Center: nReturn = Centered; break;
51 default:
52 OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" );
53 }
54 return nReturn;
55 }
56
57 ImageAlign translateImagePosition( sal_Int16 _eUNOAlign )
58 {
59 ImageAlign nReturn = ImageAlign::Top;
60 switch ( _eUNOAlign )
61 {
62 case LeftCenter: nReturn = ImageAlign::Left; break;
63 case AboveCenter: nReturn = ImageAlign::Top; break;
64 case RightCenter: nReturn = ImageAlign::Right; break;
65 case BelowCenter: nReturn = ImageAlign::Bottom; break;
66 case LeftTop: nReturn = ImageAlign::LeftTop; break;
67 case LeftBottom: nReturn = ImageAlign::LeftBottom; break;
68 case AboveLeft: nReturn = ImageAlign::TopLeft; break;
69 case AboveRight: nReturn = ImageAlign::TopRight; break;
70 case RightTop: nReturn = ImageAlign::RightTop; break;
71 case RightBottom: nReturn = ImageAlign::RightBottom; break;
72 case BelowLeft: nReturn = ImageAlign::BottomLeft; break;
73 case BelowRight: nReturn = ImageAlign::BottomRight; break;
74 case Centered: nReturn = ImageAlign::Center; break;
75 default:
76 OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" );
77 }
78 return nReturn;
79 }
80
81 sal_Int16 getCompatibleImageAlign( ImageAlign _eAlign )
82 {
83 sal_Int16 nReturn = TOP;
84 switch ( _eAlign )
85 {
86 case ImageAlign::LeftTop:
87 case ImageAlign::Left:
88 case ImageAlign::LeftBottom: nReturn = LEFT; break;
89
90 case ImageAlign::TopLeft:
91 case ImageAlign::Top:
92 case ImageAlign::TopRight: nReturn = TOP; break;
93
94 case ImageAlign::RightTop:
95 case ImageAlign::Right:
96 case ImageAlign::RightBottom: nReturn = RIGHT; break;
97
98 case ImageAlign::BottomLeft:
99 case ImageAlign::Bottom:
100 case ImageAlign::BottomRight: nReturn = BOTTOM; break;
101
102 case ImageAlign::Center: nReturn = TOP; break;
103 default:
104 OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" );
105 }
106 return nReturn;
107 }
108
109 sal_Int16 getExtendedImagePosition( sal_Int16 _nImageAlign )
110 {
111 sal_Int16 nReturn = AboveCenter;
112 switch ( _nImageAlign )
113 {
114 case LEFT: nReturn = LeftCenter; break;
115 case TOP: nReturn = AboveCenter; break;
116 case RIGHT: nReturn = RightCenter; break;
117 case BOTTOM: nReturn = BelowCenter; break;
118 default:
119 OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" );
120 }
121 return nReturn;
122 }
123
124
125} // namespace toolkit
126
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt32 LEFT
const sal_uInt32 TOP
const sal_uInt32 BOTTOM
const sal_uInt32 RIGHT
sal_Int16 translateImagePosition(ImageAlign _eVCLAlign)
translates a VCL ImageAlign value into a css.awt.ImagePosition value
Definition: imagealign.cxx:33
sal_Int16 getExtendedImagePosition(sal_Int16 _nImageAlign)
translates a css.awt.ImageAlign value into a css.awt.ImagePosition value
Definition: imagealign.cxx:109
sal_Int16 getCompatibleImageAlign(ImageAlign _eAlign)
translates a VCL ImageAlign value into a compatible css.awt.ImageAlign value
Definition: imagealign.cxx:81
ImageAlign