LibreOffice Module vcl (master) 1
unohelp.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 <vcl/svapp.hxx>
21#include <vcl/unohelp.hxx>
22
23#include <osl/diagnose.h>
24
26
27#include <com/sun/star/i18n/BreakIterator.hpp>
28#include <com/sun/star/i18n/CharacterClassification.hpp>
29#include <com/sun/star/awt/FontWeight.hpp>
30#include <com/sun/star/awt/FontWidth.hpp>
31#include <com/sun/star/awt/XExtendedToolkit.hpp>
32#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
33#include <com/sun/star/accessibility/AccessibleStateType.hpp>
34
35using namespace ::com::sun::star;
36
37uno::Reference < i18n::XBreakIterator > vcl::unohelper::CreateBreakIterator()
38{
39 uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
40 return i18n::BreakIterator::create(xContext);
41}
42
43uno::Reference < i18n::XCharacterClassification > vcl::unohelper::CreateCharacterClassification()
44{
45 return i18n::CharacterClassification::create( comphelper::getProcessComponentContext() );
46}
47
49{
50 if( eWidth == WIDTH_DONTKNOW )
51 return css::awt::FontWidth::DONTKNOW;
52 else if( eWidth == WIDTH_ULTRA_CONDENSED )
53 return css::awt::FontWidth::ULTRACONDENSED;
54 else if( eWidth == WIDTH_EXTRA_CONDENSED )
55 return css::awt::FontWidth::EXTRACONDENSED;
56 else if( eWidth == WIDTH_CONDENSED )
57 return css::awt::FontWidth::CONDENSED;
58 else if( eWidth == WIDTH_SEMI_CONDENSED )
59 return css::awt::FontWidth::SEMICONDENSED;
60 else if( eWidth == WIDTH_NORMAL )
61 return css::awt::FontWidth::NORMAL;
62 else if( eWidth == WIDTH_SEMI_EXPANDED )
63 return css::awt::FontWidth::SEMIEXPANDED;
64 else if( eWidth == WIDTH_EXPANDED )
65 return css::awt::FontWidth::EXPANDED;
66 else if( eWidth == WIDTH_EXTRA_EXPANDED )
67 return css::awt::FontWidth::EXTRAEXPANDED;
68 else if( eWidth == WIDTH_ULTRA_EXPANDED )
69 return css::awt::FontWidth::ULTRAEXPANDED;
70
71 OSL_FAIL( "Unknown FontWidth" );
72 return css::awt::FontWidth::DONTKNOW;
73}
74
76{
77 if( f <= css::awt::FontWidth::DONTKNOW )
78 return WIDTH_DONTKNOW;
79 else if( f <= css::awt::FontWidth::ULTRACONDENSED )
81 else if( f <= css::awt::FontWidth::EXTRACONDENSED )
83 else if( f <= css::awt::FontWidth::CONDENSED )
84 return WIDTH_CONDENSED;
85 else if( f <= css::awt::FontWidth::SEMICONDENSED )
87 else if( f <= css::awt::FontWidth::NORMAL )
88 return WIDTH_NORMAL;
89 else if( f <= css::awt::FontWidth::SEMIEXPANDED )
91 else if( f <= css::awt::FontWidth::EXPANDED )
92 return WIDTH_EXPANDED;
93 else if( f <= css::awt::FontWidth::EXTRAEXPANDED )
95 else if( f <= css::awt::FontWidth::ULTRAEXPANDED )
97
98 OSL_FAIL( "Unknown FontWidth" );
99 return WIDTH_DONTKNOW;
100}
101
103{
104 if( eWeight == WEIGHT_DONTKNOW )
105 return css::awt::FontWeight::DONTKNOW;
106 else if( eWeight == WEIGHT_THIN )
107 return css::awt::FontWeight::THIN;
108 else if( eWeight == WEIGHT_ULTRALIGHT )
109 return css::awt::FontWeight::ULTRALIGHT;
110 else if( eWeight == WEIGHT_LIGHT )
111 return css::awt::FontWeight::LIGHT;
112 else if( eWeight == WEIGHT_SEMILIGHT )
113 return css::awt::FontWeight::SEMILIGHT;
114 else if( ( eWeight == WEIGHT_NORMAL ) || ( eWeight == WEIGHT_MEDIUM ) )
115 return css::awt::FontWeight::NORMAL;
116 else if( eWeight == WEIGHT_SEMIBOLD )
117 return css::awt::FontWeight::SEMIBOLD;
118 else if( eWeight == WEIGHT_BOLD )
119 return css::awt::FontWeight::BOLD;
120 else if( eWeight == WEIGHT_ULTRABOLD )
121 return css::awt::FontWeight::ULTRABOLD;
122 else if( eWeight == WEIGHT_BLACK )
123 return css::awt::FontWeight::BLACK;
124
125 OSL_FAIL( "Unknown FontWeight" );
126 return css::awt::FontWeight::DONTKNOW;
127}
128
130{
131 if( f <= css::awt::FontWeight::DONTKNOW )
132 return WEIGHT_DONTKNOW;
133 else if( f <= css::awt::FontWeight::THIN )
134 return WEIGHT_THIN;
135 else if( f <= css::awt::FontWeight::ULTRALIGHT )
136 return WEIGHT_ULTRALIGHT;
137 else if( f <= css::awt::FontWeight::LIGHT )
138 return WEIGHT_LIGHT;
139 else if( f <= css::awt::FontWeight::SEMILIGHT )
140 return WEIGHT_SEMILIGHT;
141 else if( f <= css::awt::FontWeight::NORMAL )
142 return WEIGHT_NORMAL;
143 else if( f <= css::awt::FontWeight::SEMIBOLD )
144 return WEIGHT_SEMIBOLD;
145 else if( f <= css::awt::FontWeight::BOLD )
146 return WEIGHT_BOLD;
147 else if( f <= css::awt::FontWeight::ULTRABOLD )
148 return WEIGHT_ULTRABOLD;
149 else if( f <= css::awt::FontWeight::BLACK )
150 return WEIGHT_BLACK;
151
152 OSL_FAIL( "Unknown FontWeight" );
153 return WEIGHT_DONTKNOW;
154}
155
157{
158 css::awt::FontSlant eRet(css::awt::FontSlant_DONTKNOW);
159 switch (eItalic)
160 {
161 case ITALIC_NONE:
162 eRet = css::awt::FontSlant_NONE;
163 break;
164 case ITALIC_OBLIQUE:
165 eRet = css::awt::FontSlant_OBLIQUE;
166 break;
167 case ITALIC_NORMAL:
168 eRet = css::awt::FontSlant_ITALIC;
169 break;
170 case ITALIC_DONTKNOW:
171 eRet = css::awt::FontSlant_DONTKNOW;
172 break;
174 eRet = css::awt::FontSlant::FontSlant_MAKE_FIXED_SIZE;
175 break;
176 }
177 return eRet;
178}
179
181{
183 switch (eSlant)
184 {
185 case css::awt::FontSlant_NONE:
186 eRet = ITALIC_NONE;
187 break;
188 case css::awt::FontSlant_OBLIQUE:
189 eRet = ITALIC_OBLIQUE;
190 break;
191 case css::awt::FontSlant_ITALIC:
192 eRet = ITALIC_NORMAL;
193 break;
194 case css::awt::FontSlant_DONTKNOW:
195 eRet = ITALIC_DONTKNOW;
196 break;
197 case css::awt::FontSlant_REVERSE_OBLIQUE:
198 //there is no vcl reverse oblique
199 eRet = ITALIC_OBLIQUE;
200 break;
201 case css::awt::FontSlant_REVERSE_ITALIC:
202 //there is no vcl reverse normal
203 eRet = ITALIC_NORMAL;
204 break;
205 case css::awt::FontSlant::FontSlant_MAKE_FIXED_SIZE:
207 break;
208 }
209 return eRet;
210}
211
212
213/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FontItalic
ITALIC_NORMAL
ITALIC_NONE
ITALIC_DONTKNOW
ITALIC_OBLIQUE
FontItalic_FORCE_EQUAL_SIZE
FontWidth
WIDTH_CONDENSED
WIDTH_EXPANDED
WIDTH_EXTRA_CONDENSED
WIDTH_ULTRA_EXPANDED
WIDTH_EXTRA_EXPANDED
WIDTH_SEMI_CONDENSED
WIDTH_ULTRA_CONDENSED
WIDTH_DONTKNOW
WIDTH_SEMI_EXPANDED
WIDTH_NORMAL
WEIGHT_ULTRALIGHT
WEIGHT_ULTRABOLD
WEIGHT_THIN
WEIGHT_BOLD
WEIGHT_NORMAL
WEIGHT_LIGHT
WEIGHT_DONTKNOW
WEIGHT_SEMIBOLD
WEIGHT_SEMILIGHT
WEIGHT_MEDIUM
WEIGHT_BLACK
Reference< XComponentContext > getProcessComponentContext()
FontWeight
VCL_DLLPUBLIC css::awt::FontSlant ConvertFontSlant(FontItalic eWeight)
Definition: unohelp.cxx:156
VCL_DLLPUBLIC float ConvertFontWidth(FontWidth eWidth)
Definition: unohelp.cxx:48
css::uno::Reference< css::i18n::XCharacterClassification > CreateCharacterClassification()
Definition: unohelp.cxx:43
VCL_DLLPUBLIC float ConvertFontWeight(FontWeight eWeight)
Definition: unohelp.cxx:102
VCL_DLLPUBLIC css::uno::Reference< css::i18n::XBreakIterator > CreateBreakIterator()
Definition: unohelp.cxx:37