1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <osl/diagnose.h>
30 using namespace ::com::sun::star::awt::ImagePosition
;
31 using namespace ::com::sun::star::awt::ImageAlign
;
33 sal_Int16
translateImagePosition( ImageAlign _eVCLAlign
)
35 sal_Int16 nReturn
= AboveCenter
;
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;
52 OSL_FAIL( "translateImagePosition: unknown IMAGEALIGN value!" );
57 ImageAlign
translateImagePosition( sal_Int16 _eUNOAlign
)
59 ImageAlign nReturn
= ImageAlign::Top
;
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;
76 OSL_FAIL( "translateImagePosition: unknown css.awt.ImagePosition value!" );
81 sal_Int16
getCompatibleImageAlign( ImageAlign _eAlign
)
83 sal_Int16 nReturn
= TOP
;
86 case ImageAlign::LeftTop
:
87 case ImageAlign::Left
:
88 case ImageAlign::LeftBottom
: nReturn
= LEFT
; break;
90 case ImageAlign::TopLeft
:
92 case ImageAlign::TopRight
: nReturn
= TOP
; break;
94 case ImageAlign::RightTop
:
95 case ImageAlign::Right
:
96 case ImageAlign::RightBottom
: nReturn
= RIGHT
; break;
98 case ImageAlign::BottomLeft
:
99 case ImageAlign::Bottom
:
100 case ImageAlign::BottomRight
: nReturn
= BOTTOM
; break;
102 case ImageAlign::Center
: nReturn
= TOP
; break;
104 OSL_FAIL( "getCompatibleImageAlign: unknown IMAGEALIGN value!" );
109 sal_Int16
getExtendedImagePosition( sal_Int16 _nImageAlign
)
111 sal_Int16 nReturn
= AboveCenter
;
112 switch ( _nImageAlign
)
114 case LEFT
: nReturn
= LeftCenter
; break;
115 case TOP
: nReturn
= AboveCenter
; break;
116 case RIGHT
: nReturn
= RightCenter
; break;
117 case BOTTOM
: nReturn
= BelowCenter
; break;
119 OSL_FAIL( "getExtendedImagePosition: unknown ImageAlign value!" );
125 } // namespace toolkit
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */