1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9f62ea84SAndrew Rist * distributed with this work for additional information
6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
17*9f62ea84SAndrew Rist * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*9f62ea84SAndrew Rist *************************************************************/
21*9f62ea84SAndrew Rist
22*9f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "atktextattributes.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/FontStrikeout.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <com/sun/star/style/CaseMap.hpp>
34cdf0e10cSrcweir #include <com/sun/star/style/LineSpacing.hpp>
35cdf0e10cSrcweir #include <com/sun/star/style/LineSpacingMode.hpp>
36cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>
37cdf0e10cSrcweir #include <com/sun/star/style/TabAlign.hpp>
38cdf0e10cSrcweir #include <com/sun/star/style/TabStop.hpp>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp>
41cdf0e10cSrcweir
42cdf0e10cSrcweir #include "atkwrapper.hxx"
43cdf0e10cSrcweir
44cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include <vcl/svapp.hxx>
47cdf0e10cSrcweir #include <vcl/outdev.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir #include <stdio.h>
50cdf0e10cSrcweir #include <string.h>
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir
54cdf0e10cSrcweir typedef gchar* (* AtkTextAttrFunc) ( const uno::Any& rAny );
55cdf0e10cSrcweir typedef bool (* TextPropertyValueFunc) ( uno::Any& rAny, const gchar * value );
56cdf0e10cSrcweir
57cdf0e10cSrcweir #define STRNCMP_PARAM( s ) s,sizeof( s )-1
58cdf0e10cSrcweir
59cdf0e10cSrcweir
60cdf0e10cSrcweir /*****************************************************************************/
61cdf0e10cSrcweir
62cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_paragraph_style = ATK_TEXT_ATTR_INVALID;
63cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_font_effect = ATK_TEXT_ATTR_INVALID;
64cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_decoration = ATK_TEXT_ATTR_INVALID;
65cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_line_height = ATK_TEXT_ATTR_INVALID;
66cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_rotation = ATK_TEXT_ATTR_INVALID;
67cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_shadow = ATK_TEXT_ATTR_INVALID;
68cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_tab_interval = ATK_TEXT_ATTR_INVALID;
69cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_tab_stops = ATK_TEXT_ATTR_INVALID;
70cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_writing_mode = ATK_TEXT_ATTR_INVALID;
71cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_vertical_align = ATK_TEXT_ATTR_INVALID;
72cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_misspelled = ATK_TEXT_ATTR_INVALID;
73cdf0e10cSrcweir // --> OD 2010-03-01 #i92232#
74cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_tracked_change = ATK_TEXT_ATTR_INVALID;
75cdf0e10cSrcweir // <--
76cdf0e10cSrcweir // --> OD 2010-03-05 #i92233#
77cdf0e10cSrcweir static AtkTextAttribute atk_text_attribute_mm_to_pixel_ratio = ATK_TEXT_ATTR_INVALID;
78cdf0e10cSrcweir // <--
79cdf0e10cSrcweir
80cdf0e10cSrcweir /*****************************************************************************/
81cdf0e10cSrcweir
82cdf0e10cSrcweir /**
83cdf0e10cSrcweir * !! IMPORTANT NOTE !! : when adding items to this list, KEEP THE LIST SORTED
84cdf0e10cSrcweir * and re-arrange the enum values accordingly.
85cdf0e10cSrcweir */
86cdf0e10cSrcweir
87cdf0e10cSrcweir enum ExportedAttribute
88cdf0e10cSrcweir {
89cdf0e10cSrcweir TEXT_ATTRIBUTE_BACKGROUND_COLOR = 0,
90cdf0e10cSrcweir TEXT_ATTRIBUTE_CASEMAP,
91cdf0e10cSrcweir TEXT_ATTRIBUTE_FOREGROUND_COLOR,
92cdf0e10cSrcweir TEXT_ATTRIBUTE_CONTOURED,
93cdf0e10cSrcweir TEXT_ATTRIBUTE_CHAR_ESCAPEMENT,
94cdf0e10cSrcweir TEXT_ATTRIBUTE_BLINKING,
95cdf0e10cSrcweir TEXT_ATTRIBUTE_FONT_NAME,
96cdf0e10cSrcweir TEXT_ATTRIBUTE_HEIGHT,
97cdf0e10cSrcweir TEXT_ATTRIBUTE_HIDDEN,
98cdf0e10cSrcweir TEXT_ATTRIBUTE_KERNING,
99cdf0e10cSrcweir TEXT_ATTRIBUTE_LOCALE,
100cdf0e10cSrcweir TEXT_ATTRIBUTE_POSTURE,
101cdf0e10cSrcweir TEXT_ATTRIBUTE_RELIEF,
102cdf0e10cSrcweir TEXT_ATTRIBUTE_ROTATION,
103cdf0e10cSrcweir TEXT_ATTRIBUTE_SCALE,
104cdf0e10cSrcweir TEXT_ATTRIBUTE_SHADOWED,
105cdf0e10cSrcweir TEXT_ATTRIBUTE_STRIKETHROUGH,
106cdf0e10cSrcweir TEXT_ATTRIBUTE_UNDERLINE,
107cdf0e10cSrcweir TEXT_ATTRIBUTE_WEIGHT,
108cdf0e10cSrcweir // --> OD 2010-03-05 #i92233#
109cdf0e10cSrcweir TEXT_ATTRIBUTE_MM_TO_PIXEL_RATIO,
110cdf0e10cSrcweir // <--
111cdf0e10cSrcweir TEXT_ATTRIBUTE_JUSTIFICATION,
112cdf0e10cSrcweir TEXT_ATTRIBUTE_BOTTOM_MARGIN,
113cdf0e10cSrcweir TEXT_ATTRIBUTE_FIRST_LINE_INDENT,
114cdf0e10cSrcweir TEXT_ATTRIBUTE_LEFT_MARGIN,
115cdf0e10cSrcweir TEXT_ATTRIBUTE_LINE_SPACING,
116cdf0e10cSrcweir TEXT_ATTRIBUTE_RIGHT_MARGIN,
117cdf0e10cSrcweir TEXT_ATTRIBUTE_STYLE_NAME,
118cdf0e10cSrcweir TEXT_ATTRIBUTE_TAB_STOPS,
119cdf0e10cSrcweir TEXT_ATTRIBUTE_TOP_MARGIN,
120cdf0e10cSrcweir TEXT_ATTRIBUTE_WRITING_MODE,
121cdf0e10cSrcweir TEXT_ATTRIBUTE_LAST
122cdf0e10cSrcweir };
123cdf0e10cSrcweir
124cdf0e10cSrcweir static const char * ExportedTextAttributes[TEXT_ATTRIBUTE_LAST] =
125cdf0e10cSrcweir {
126cdf0e10cSrcweir "CharBackColor", // TEXT_ATTRIBUTE_BACKGROUND_COLOR
127cdf0e10cSrcweir "CharCaseMap", // TEXT_ATTRIBUTE_CASEMAP
128cdf0e10cSrcweir "CharColor", // TEXT_ATTRIBUTE_FOREGROUND_COLOR
129cdf0e10cSrcweir "CharContoured", // TEXT_ATTRIBUTE_CONTOURED
130cdf0e10cSrcweir "CharEscapement", // TEXT_ATTRIBUTE_CHAR_ESCAPEMENT
131cdf0e10cSrcweir "CharFlash", // TEXT_ATTRIBUTE_BLINKING
132cdf0e10cSrcweir "CharFontName", // TEXT_ATTRIBUTE_FONT_NAME
133cdf0e10cSrcweir "CharHeight", // TEXT_ATTRIBUTE_HEIGHT
134cdf0e10cSrcweir "CharHidden", // TEXT_ATTRIBUTE_HIDDEN
135cdf0e10cSrcweir "CharKerning", // TEXT_ATTRIBUTE_KERNING
136cdf0e10cSrcweir "CharLocale", // TEXT_ATTRIBUTE_LOCALE
137cdf0e10cSrcweir "CharPosture", // TEXT_ATTRIBUTE_POSTURE
138cdf0e10cSrcweir "CharRelief", // TEXT_ATTRIBUTE_RELIEF
139cdf0e10cSrcweir "CharRotation", // TEXT_ATTRIBUTE_ROTATION
140cdf0e10cSrcweir "CharScaleWidth", // TEXT_ATTRIBUTE_SCALE
141cdf0e10cSrcweir "CharShadowed", // TEXT_ATTRIBUTE_SHADOWED
142cdf0e10cSrcweir "CharStrikeout", // TEXT_ATTRIBUTE_STRIKETHROUGH
143cdf0e10cSrcweir "CharUnderline", // TEXT_ATTRIBUTE_UNDERLINE
144cdf0e10cSrcweir "CharWeight", // TEXT_ATTRIBUTE_WEIGHT
145cdf0e10cSrcweir // --> OD 2010-03-05 #i92233#
146cdf0e10cSrcweir "MMToPixelRatio", // TEXT_ATTRIBUTE_MM_TO_PIXEL_RATIO
147cdf0e10cSrcweir // <--
148cdf0e10cSrcweir "ParaAdjust", // TEXT_ATTRIBUTE_JUSTIFICATION
149cdf0e10cSrcweir "ParaBottomMargin", // TEXT_ATTRIBUTE_BOTTOM_MARGIN
150cdf0e10cSrcweir "ParaFirstLineIndent", // TEXT_ATTRIBUTE_FIRST_LINE_INDENT
151cdf0e10cSrcweir "ParaLeftMargin", // TEXT_ATTRIBUTE_LEFT_MARGIN
152cdf0e10cSrcweir "ParaLineSpacing", // TEXT_ATTRIBUTE_LINE_SPACING
153cdf0e10cSrcweir "ParaRightMargin", // TEXT_ATTRIBUTE_RIGHT_MARGIN
154cdf0e10cSrcweir "ParaStyleName", // TEXT_ATTRIBUTE_STYLE_NAME
155cdf0e10cSrcweir "ParaTabStops", // TEXT_ATTRIBUTE_TAB_STOPS
156cdf0e10cSrcweir "ParaTopMargin", // TEXT_ATTRIBUTE_TOP_MARGIN
157cdf0e10cSrcweir "WritingMode" // TEXT_ATTRIBUTE_WRITING_MODE
158cdf0e10cSrcweir };
159cdf0e10cSrcweir
160cdf0e10cSrcweir
161cdf0e10cSrcweir /*****************************************************************************/
162cdf0e10cSrcweir
163cdf0e10cSrcweir static gchar*
get_value(const uno::Sequence<beans::PropertyValue> & rAttributeList,sal_Int32 nIndex,AtkTextAttrFunc func)164cdf0e10cSrcweir get_value( const uno::Sequence< beans::PropertyValue >& rAttributeList,
165cdf0e10cSrcweir sal_Int32 nIndex, AtkTextAttrFunc func )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir if( nIndex != -1 )
168cdf0e10cSrcweir return func(rAttributeList[nIndex].Value);
169cdf0e10cSrcweir
170cdf0e10cSrcweir return NULL;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir #define get_bool_value( list, index ) get_value( list, index, Bool2String )
174cdf0e10cSrcweir #define get_short_value( list, index ) get_value( list, index, Short2String )
175cdf0e10cSrcweir //#define get_long_value( list, index ) get_value( list, index, Long2String ) pb: not used (warning on linux)
176cdf0e10cSrcweir #define get_height_value( list, index ) get_value( list, index, Float2String )
177cdf0e10cSrcweir #define get_justification_value( list, index ) get_value( list, index, Adjust2Justification )
178cdf0e10cSrcweir #define get_cmm_value( list, index ) get_value( list, index, CMM2UnitString )
179cdf0e10cSrcweir #define get_scale_width( list, index ) get_value( list, index, Scale2String )
180cdf0e10cSrcweir #define get_strikethrough_value( list, index ) get_value( list, index, Strikeout2String )
181cdf0e10cSrcweir #define get_string_value( list, index ) get_value( list, index, GetString )
182cdf0e10cSrcweir #define get_style_value( list, index ) get_value( list, index, FontSlant2Style )
183cdf0e10cSrcweir #define get_underline_value( list, index ) get_value( list, index, Underline2String )
184cdf0e10cSrcweir #define get_variant_value( list, index ) get_value( list, index, CaseMap2String )
185cdf0e10cSrcweir #define get_weight_value( list, index ) get_value( list, index, Weight2String )
186cdf0e10cSrcweir #define get_language_string( list, index ) get_value( list, index, Locale2String )
187cdf0e10cSrcweir
188cdf0e10cSrcweir /*
189cdf0e10cSrcweir static gchar*
190cdf0e10cSrcweir dump_value( const uno::Sequence< beans::PropertyValue >& rAttributeList, sal_Int32 nIndex )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir if( nIndex != -1 )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir rtl::OString aName = rtl::OUStringToOString(rAttributeList[nIndex].Name, RTL_TEXTENCODING_UTF8);
195cdf0e10cSrcweir
196cdf0e10cSrcweir if( rAttributeList[nIndex].Value.has<sal_Int16> () )
197cdf0e10cSrcweir OSL_TRACE( "%s = %d (short value)", aName.getStr(),
198cdf0e10cSrcweir rAttributeList[nIndex].Value.get<sal_Int16> () );
199cdf0e10cSrcweir
200cdf0e10cSrcweir else if( rAttributeList[nIndex].Value.has<sal_Int8> () )
201cdf0e10cSrcweir OSL_TRACE( "%s = %d (byte value)", aName.getStr(),
202cdf0e10cSrcweir rAttributeList[nIndex].Value.get<sal_Int8> () );
203cdf0e10cSrcweir
204cdf0e10cSrcweir else if( rAttributeList[nIndex].Value.has<sal_Bool> () )
205cdf0e10cSrcweir OSL_TRACE( "%s = %s (bool value)", aName.getStr(),
206cdf0e10cSrcweir rAttributeList[nIndex].Value.get<sal_Bool> () ? "true" : "false" );
207cdf0e10cSrcweir
208cdf0e10cSrcweir else if( rAttributeList[nIndex].Value.has<rtl::OUString> () )
209cdf0e10cSrcweir OSL_TRACE( "%s = %s", aName.getStr(),
210cdf0e10cSrcweir rtl::OUStringToOString(rAttributeList[nIndex].Value.get<rtl::OUString> (),
211cdf0e10cSrcweir RTL_TEXTENCODING_UTF8).getStr() );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir return NULL;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir */
217cdf0e10cSrcweir
218cdf0e10cSrcweir static inline
toPoint(sal_Int16 n)219cdf0e10cSrcweir double toPoint(sal_Int16 n)
220cdf0e10cSrcweir {
221cdf0e10cSrcweir // 100th mm -> pt
222cdf0e10cSrcweir return (double) (n * 72) / 2540;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir
225cdf0e10cSrcweir
226cdf0e10cSrcweir /*****************************************************************************/
227cdf0e10cSrcweir
228cdf0e10cSrcweir /*
229cdf0e10cSrcweir static gchar*
230cdf0e10cSrcweir NullString(const uno::Any&)
231cdf0e10cSrcweir {
232cdf0e10cSrcweir return NULL;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir */
235cdf0e10cSrcweir
236cdf0e10cSrcweir static bool
InvalidValue(uno::Any &,const gchar *)237cdf0e10cSrcweir InvalidValue( uno::Any&, const gchar * )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir return false;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir /*****************************************************************************/
243cdf0e10cSrcweir
244cdf0e10cSrcweir static gchar*
Float2String(const uno::Any & rAny)245cdf0e10cSrcweir Float2String(const uno::Any& rAny)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir return g_strdup_printf( "%g", rAny.get<float>() );
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir static bool
String2Float(uno::Any & rAny,const gchar * value)251cdf0e10cSrcweir String2Float( uno::Any& rAny, const gchar * value )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir float fval;
254cdf0e10cSrcweir
255cdf0e10cSrcweir if( 1 != sscanf( value, "%g", &fval ) )
256cdf0e10cSrcweir return false;
257cdf0e10cSrcweir
258cdf0e10cSrcweir rAny = uno::makeAny( fval );
259cdf0e10cSrcweir return true;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir /*****************************************************************************/
263cdf0e10cSrcweir
264cdf0e10cSrcweir /*
265cdf0e10cSrcweir static gchar*
266cdf0e10cSrcweir Short2String(const uno::Any& rAny)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir return g_strdup_printf( "%d", rAny.get<sal_Int16>() );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir static bool
272cdf0e10cSrcweir String2Short( uno::Any& rAny, const gchar * value )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir sal_Int32 lval;
275cdf0e10cSrcweir
276cdf0e10cSrcweir if( 1 != sscanf( value, "%d", &lval ) )
277cdf0e10cSrcweir return false;
278cdf0e10cSrcweir
279cdf0e10cSrcweir rAny = uno::makeAny( (sal_Int16) lval );
280cdf0e10cSrcweir return true;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir */
283cdf0e10cSrcweir
284cdf0e10cSrcweir /*****************************************************************************/
285cdf0e10cSrcweir /* pb: not used (warning on linux)
286cdf0e10cSrcweir static gchar*
287cdf0e10cSrcweir Long2String(const uno::Any& rAny)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir return g_strdup_printf( "%ld", rAny.get<sal_Int32>() );
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
292cdf0e10cSrcweir static bool
293cdf0e10cSrcweir String2Long( uno::Any& rAny, const gchar * value )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir sal_Int32 lval;
296cdf0e10cSrcweir
297cdf0e10cSrcweir if( 1 != sscanf( value, "%ld", &lval ) )
298cdf0e10cSrcweir return false;
299cdf0e10cSrcweir
300cdf0e10cSrcweir rAny = uno::makeAny( lval );
301cdf0e10cSrcweir return true;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir */
304cdf0e10cSrcweir /*****************************************************************************/
305cdf0e10cSrcweir
306cdf0e10cSrcweir static accessibility::XAccessibleComponent*
getComponent(AtkText * pText)307cdf0e10cSrcweir getComponent( AtkText *pText ) throw (uno::RuntimeException)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
310cdf0e10cSrcweir if( pWrap )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir if( !pWrap->mpComponent && pWrap->mpContext )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir uno::Any any = pWrap->mpContext->queryInterface( accessibility::XAccessibleComponent::static_type(NULL) );
315cdf0e10cSrcweir pWrap->mpComponent = reinterpret_cast< accessibility::XAccessibleComponent * > (any.pReserved);
316cdf0e10cSrcweir pWrap->mpComponent->acquire();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir
319cdf0e10cSrcweir return pWrap->mpComponent;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir return NULL;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir
325cdf0e10cSrcweir static gchar*
get_color_value(const uno::Sequence<beans::PropertyValue> & rAttributeList,const sal_Int32 * pIndexArray,ExportedAttribute attr,AtkText * text)326cdf0e10cSrcweir get_color_value(const uno::Sequence< beans::PropertyValue >& rAttributeList,
327cdf0e10cSrcweir const sal_Int32 * pIndexArray,
328cdf0e10cSrcweir ExportedAttribute attr,
329cdf0e10cSrcweir AtkText * text)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir sal_Int32 nColor = -1; // AUTOMATIC
332cdf0e10cSrcweir sal_Int32 nIndex = pIndexArray[attr];
333cdf0e10cSrcweir
334cdf0e10cSrcweir if( nIndex != -1 )
335cdf0e10cSrcweir nColor = rAttributeList[nIndex].Value.get<sal_Int32>();
336cdf0e10cSrcweir
337cdf0e10cSrcweir /*
338cdf0e10cSrcweir * Check for color value for 100% alpha white, which means
339cdf0e10cSrcweir * "automatic". Grab the RGB value from XAccessibleComponent
340cdf0e10cSrcweir * in this case.
341cdf0e10cSrcweir */
342cdf0e10cSrcweir
343cdf0e10cSrcweir if( (nColor == -1) && text )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir try
346cdf0e10cSrcweir {
347cdf0e10cSrcweir accessibility::XAccessibleComponent *pComponent = getComponent( text );
348cdf0e10cSrcweir if( pComponent )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir switch( attr )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir case TEXT_ATTRIBUTE_BACKGROUND_COLOR:
353cdf0e10cSrcweir nColor = pComponent->getBackground();
354cdf0e10cSrcweir break;
355cdf0e10cSrcweir case TEXT_ATTRIBUTE_FOREGROUND_COLOR:
356cdf0e10cSrcweir nColor = pComponent->getForeground();
357cdf0e10cSrcweir break;
358cdf0e10cSrcweir default:
359cdf0e10cSrcweir break;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
364cdf0e10cSrcweir catch(const uno::Exception& e) {
365cdf0e10cSrcweir g_warning( "Exception in get[Fore|Back]groundColor()" );
366cdf0e10cSrcweir }
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir if( nColor != -1 )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir sal_uInt8 blue = nColor & 0xFF;
372cdf0e10cSrcweir sal_uInt8 green = (nColor >> 8) & 0xFF;
373cdf0e10cSrcweir sal_uInt8 red = (nColor >> 16) & 0xFF;
374cdf0e10cSrcweir
375cdf0e10cSrcweir return g_strdup_printf( "%u,%u,%u", red, green, blue );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
378cdf0e10cSrcweir return NULL;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
381cdf0e10cSrcweir static bool
String2Color(uno::Any & rAny,const gchar * value)382cdf0e10cSrcweir String2Color( uno::Any& rAny, const gchar * value )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir int red, green, blue;
385cdf0e10cSrcweir
386cdf0e10cSrcweir if( 3 != sscanf( value, "%d,%d,%d", &red, &green, &blue ) )
387cdf0e10cSrcweir return false;
388cdf0e10cSrcweir
389cdf0e10cSrcweir sal_Int32 nColor = (sal_Int32) blue | ( (sal_Int32) green << 8 ) | ( ( sal_Int32 ) red << 16 );
390cdf0e10cSrcweir rAny = uno::makeAny( nColor );
391cdf0e10cSrcweir return true;
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
394cdf0e10cSrcweir /*****************************************************************************/
395cdf0e10cSrcweir
396cdf0e10cSrcweir static gchar*
FontSlant2Style(const uno::Any & rAny)397cdf0e10cSrcweir FontSlant2Style(const uno::Any& rAny)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir const gchar * value = NULL;
400cdf0e10cSrcweir
401cdf0e10cSrcweir switch( rAny.get<awt::FontSlant>() )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir case awt::FontSlant_NONE:
404cdf0e10cSrcweir value = "normal";
405cdf0e10cSrcweir break;
406cdf0e10cSrcweir
407cdf0e10cSrcweir case awt::FontSlant_OBLIQUE:
408cdf0e10cSrcweir value = "oblique";
409cdf0e10cSrcweir break;
410cdf0e10cSrcweir
411cdf0e10cSrcweir case awt::FontSlant_ITALIC:
412cdf0e10cSrcweir value = "italic";
413cdf0e10cSrcweir break;
414cdf0e10cSrcweir
415cdf0e10cSrcweir case awt::FontSlant_REVERSE_OBLIQUE:
416cdf0e10cSrcweir value = "reverse oblique";
417cdf0e10cSrcweir break;
418cdf0e10cSrcweir
419cdf0e10cSrcweir case awt::FontSlant_REVERSE_ITALIC:
420cdf0e10cSrcweir value = "reverse italic";
421cdf0e10cSrcweir break;
422cdf0e10cSrcweir
423cdf0e10cSrcweir default:
424cdf0e10cSrcweir break;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
427cdf0e10cSrcweir if( value )
428cdf0e10cSrcweir return g_strdup( value );
429cdf0e10cSrcweir
430cdf0e10cSrcweir return NULL;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir static bool
Style2FontSlant(uno::Any & rAny,const gchar * value)434cdf0e10cSrcweir Style2FontSlant( uno::Any& rAny, const gchar * value )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir awt::FontSlant aFontSlant;
437cdf0e10cSrcweir
438cdf0e10cSrcweir if( strncmp( value, STRNCMP_PARAM( "normal" ) ) )
439cdf0e10cSrcweir aFontSlant = awt::FontSlant_NONE;
440cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "oblique" ) ) )
441cdf0e10cSrcweir aFontSlant = awt::FontSlant_OBLIQUE;
442cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "italic" ) ) )
443cdf0e10cSrcweir aFontSlant = awt::FontSlant_ITALIC;
444cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "reverse oblique" ) ) )
445cdf0e10cSrcweir aFontSlant = awt::FontSlant_REVERSE_OBLIQUE;
446cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "reverse italic" ) ) )
447cdf0e10cSrcweir aFontSlant = awt::FontSlant_REVERSE_ITALIC;
448cdf0e10cSrcweir else
449cdf0e10cSrcweir return false;
450cdf0e10cSrcweir
451cdf0e10cSrcweir rAny = uno::makeAny( aFontSlant );
452cdf0e10cSrcweir return true;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir /*****************************************************************************/
456cdf0e10cSrcweir
457cdf0e10cSrcweir static gchar*
Weight2String(const uno::Any & rAny)458cdf0e10cSrcweir Weight2String(const uno::Any& rAny)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir return g_strdup_printf( "%g", rAny.get<float>() * 4 );
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir static bool
String2Weight(uno::Any & rAny,const gchar * value)464cdf0e10cSrcweir String2Weight( uno::Any& rAny, const gchar * value )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir float weight;
467cdf0e10cSrcweir
468cdf0e10cSrcweir if( 1 != sscanf( value, "%g", &weight ) )
469cdf0e10cSrcweir return false;
470cdf0e10cSrcweir
471cdf0e10cSrcweir rAny = uno::makeAny( weight / 4 );
472cdf0e10cSrcweir return true;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir
476cdf0e10cSrcweir /*****************************************************************************/
477cdf0e10cSrcweir
478cdf0e10cSrcweir static gchar*
Adjust2Justification(const uno::Any & rAny)479cdf0e10cSrcweir Adjust2Justification(const uno::Any& rAny)
480cdf0e10cSrcweir {
481cdf0e10cSrcweir const gchar * value = NULL;
482cdf0e10cSrcweir
483cdf0e10cSrcweir switch( rAny.get<short>() )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir case style::ParagraphAdjust_LEFT:
486cdf0e10cSrcweir value = "left";
487cdf0e10cSrcweir break;
488cdf0e10cSrcweir
489cdf0e10cSrcweir case style::ParagraphAdjust_RIGHT:
490cdf0e10cSrcweir value = "right";
491cdf0e10cSrcweir break;
492cdf0e10cSrcweir
493cdf0e10cSrcweir case style::ParagraphAdjust_BLOCK:
494cdf0e10cSrcweir case style::ParagraphAdjust_STRETCH:
495cdf0e10cSrcweir value = "fill";
496cdf0e10cSrcweir break;
497cdf0e10cSrcweir
498cdf0e10cSrcweir case style::ParagraphAdjust_CENTER:
499cdf0e10cSrcweir value = "center";
500cdf0e10cSrcweir break;
501cdf0e10cSrcweir
502cdf0e10cSrcweir default:
503cdf0e10cSrcweir break;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir if( value )
507cdf0e10cSrcweir return g_strdup( value );
508cdf0e10cSrcweir
509cdf0e10cSrcweir return NULL;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir static bool
Justification2Adjust(uno::Any & rAny,const gchar * value)513cdf0e10cSrcweir Justification2Adjust( uno::Any& rAny, const gchar * value )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir short nParagraphAdjust;
516cdf0e10cSrcweir
517cdf0e10cSrcweir if( strncmp( value, STRNCMP_PARAM( "left" ) ) )
518cdf0e10cSrcweir nParagraphAdjust = style::ParagraphAdjust_LEFT;
519cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "right" ) ) )
520cdf0e10cSrcweir nParagraphAdjust = style::ParagraphAdjust_RIGHT;
521cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "fill" ) ) )
522cdf0e10cSrcweir nParagraphAdjust = style::ParagraphAdjust_BLOCK;
523cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "center" ) ) )
524cdf0e10cSrcweir nParagraphAdjust = style::ParagraphAdjust_CENTER;
525cdf0e10cSrcweir else
526cdf0e10cSrcweir return false;
527cdf0e10cSrcweir
528cdf0e10cSrcweir rAny = uno::makeAny( nParagraphAdjust );
529cdf0e10cSrcweir return true;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir /*****************************************************************************/
533cdf0e10cSrcweir
534cdf0e10cSrcweir const gchar * font_strikethrough[] = {
535cdf0e10cSrcweir "none", // FontStrikeout::NONE
536cdf0e10cSrcweir "single", // FontStrikeout::SINGLE
537cdf0e10cSrcweir "double", // FontStrikeout::DOUBLE
538cdf0e10cSrcweir NULL, // FontStrikeout::DONTKNOW
539cdf0e10cSrcweir "bold", // FontStrikeout::BOLD
540cdf0e10cSrcweir "with /", // FontStrikeout::SLASH
541cdf0e10cSrcweir "with X" // FontStrikeout::X
542cdf0e10cSrcweir };
543cdf0e10cSrcweir
544cdf0e10cSrcweir const sal_Int16 n_strikeout_constants = sizeof(font_strikethrough) / sizeof(gchar*);
545cdf0e10cSrcweir
546cdf0e10cSrcweir static gchar*
Strikeout2String(const uno::Any & rAny)547cdf0e10cSrcweir Strikeout2String(const uno::Any& rAny)
548cdf0e10cSrcweir {
549cdf0e10cSrcweir sal_Int16 n = rAny.get<sal_Int16>();
550cdf0e10cSrcweir
551cdf0e10cSrcweir if( n >= 0 && n < n_strikeout_constants )
552cdf0e10cSrcweir return g_strdup( font_strikethrough[n] );
553cdf0e10cSrcweir
554cdf0e10cSrcweir return NULL;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir
557cdf0e10cSrcweir static bool
String2Strikeout(uno::Any & rAny,const gchar * value)558cdf0e10cSrcweir String2Strikeout( uno::Any& rAny, const gchar * value )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir for( sal_Int16 n=0; n < n_strikeout_constants; ++n )
561cdf0e10cSrcweir {
562cdf0e10cSrcweir if( ( NULL != font_strikethrough[n] ) &&
563cdf0e10cSrcweir 0 == strncmp( value, font_strikethrough[n], strlen( font_strikethrough[n] ) ) )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir rAny = uno::makeAny( n );
566cdf0e10cSrcweir return true;
567cdf0e10cSrcweir }
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
570cdf0e10cSrcweir return false;
571cdf0e10cSrcweir }
572cdf0e10cSrcweir
573cdf0e10cSrcweir /*****************************************************************************/
574cdf0e10cSrcweir
575cdf0e10cSrcweir static gchar*
Underline2String(const uno::Any & rAny)576cdf0e10cSrcweir Underline2String(const uno::Any& rAny)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir const gchar * value = NULL;
579cdf0e10cSrcweir
580cdf0e10cSrcweir switch( rAny.get<sal_Int16>() )
581cdf0e10cSrcweir {
582cdf0e10cSrcweir case awt::FontUnderline::NONE:
583cdf0e10cSrcweir value = "none";
584cdf0e10cSrcweir break;
585cdf0e10cSrcweir
586cdf0e10cSrcweir case awt::FontUnderline::SINGLE:
587cdf0e10cSrcweir value = "single";
588cdf0e10cSrcweir break;
589cdf0e10cSrcweir
590cdf0e10cSrcweir case awt::FontUnderline::DOUBLE:
591cdf0e10cSrcweir value = "double";
592cdf0e10cSrcweir break;
593cdf0e10cSrcweir
594cdf0e10cSrcweir default:
595cdf0e10cSrcweir break;
596cdf0e10cSrcweir }
597cdf0e10cSrcweir
598cdf0e10cSrcweir if( value )
599cdf0e10cSrcweir return g_strdup( value );
600cdf0e10cSrcweir
601cdf0e10cSrcweir return NULL;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
604cdf0e10cSrcweir static bool
String2Underline(uno::Any & rAny,const gchar * value)605cdf0e10cSrcweir String2Underline( uno::Any& rAny, const gchar * value )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir short nUnderline;
608cdf0e10cSrcweir
609cdf0e10cSrcweir if( strncmp( value, STRNCMP_PARAM( "none" ) ) )
610cdf0e10cSrcweir nUnderline = awt::FontUnderline::NONE;
611cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "single" ) ) )
612cdf0e10cSrcweir nUnderline = awt::FontUnderline::SINGLE;
613cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "double" ) ) )
614cdf0e10cSrcweir nUnderline = awt::FontUnderline::DOUBLE;
615cdf0e10cSrcweir else
616cdf0e10cSrcweir return false;
617cdf0e10cSrcweir
618cdf0e10cSrcweir rAny = uno::makeAny( nUnderline );
619cdf0e10cSrcweir return true;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir
622cdf0e10cSrcweir /*****************************************************************************/
623cdf0e10cSrcweir
624cdf0e10cSrcweir static gchar*
GetString(const uno::Any & rAny)625cdf0e10cSrcweir GetString(const uno::Any& rAny)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir rtl::OString aFontName = rtl::OUStringToOString( rAny.get< rtl::OUString > (), RTL_TEXTENCODING_UTF8 );
628cdf0e10cSrcweir
629cdf0e10cSrcweir if( aFontName.getLength() )
630cdf0e10cSrcweir return g_strdup( aFontName.getStr() );
631cdf0e10cSrcweir
632cdf0e10cSrcweir return NULL;
633cdf0e10cSrcweir }
634cdf0e10cSrcweir
635cdf0e10cSrcweir static bool
SetString(uno::Any & rAny,const gchar * value)636cdf0e10cSrcweir SetString( uno::Any& rAny, const gchar * value )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir rtl::OString aFontName( value );
639cdf0e10cSrcweir
640cdf0e10cSrcweir if( aFontName.getLength() )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir rAny = uno::makeAny( rtl::OStringToOUString( aFontName, RTL_TEXTENCODING_UTF8 ) );
643cdf0e10cSrcweir return true;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
646cdf0e10cSrcweir return false;
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir /*****************************************************************************/
650cdf0e10cSrcweir
651cdf0e10cSrcweir // @see http://developer.gnome.org/doc/API/2.0/atk/AtkText.html#AtkTextAttribute
652cdf0e10cSrcweir
653cdf0e10cSrcweir // CMM = 100th of mm
654cdf0e10cSrcweir static gchar*
CMM2UnitString(const uno::Any & rAny)655cdf0e10cSrcweir CMM2UnitString(const uno::Any& rAny)
656cdf0e10cSrcweir {
657cdf0e10cSrcweir double fValue = rAny.get<sal_Int32>();
658cdf0e10cSrcweir fValue = fValue * 0.01;
659cdf0e10cSrcweir
660cdf0e10cSrcweir return g_strdup_printf( "%gmm", fValue );
661cdf0e10cSrcweir }
662cdf0e10cSrcweir
663cdf0e10cSrcweir static bool
UnitString2CMM(uno::Any & rAny,const gchar * value)664cdf0e10cSrcweir UnitString2CMM( uno::Any& rAny, const gchar * value )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir float fValue = 0.0; // pb: dont use double here because of warning on linux
667cdf0e10cSrcweir
668cdf0e10cSrcweir if( 1 != sscanf( value, "%gmm", &fValue ) )
669cdf0e10cSrcweir return false;
670cdf0e10cSrcweir
671cdf0e10cSrcweir fValue = fValue * 100;
672cdf0e10cSrcweir
673cdf0e10cSrcweir rAny = uno::makeAny( (sal_Int32) fValue);
674cdf0e10cSrcweir return true;
675cdf0e10cSrcweir }
676cdf0e10cSrcweir
677cdf0e10cSrcweir /*****************************************************************************/
678cdf0e10cSrcweir
679cdf0e10cSrcweir static const gchar * bool_values[] = { "true", "false" };
680cdf0e10cSrcweir
681cdf0e10cSrcweir static gchar *
Bool2String(const uno::Any & rAny)682cdf0e10cSrcweir Bool2String( const uno::Any& rAny )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir int n = 1;
685cdf0e10cSrcweir
686cdf0e10cSrcweir if( rAny.get<sal_Bool>() )
687cdf0e10cSrcweir n = 0;
688cdf0e10cSrcweir
689cdf0e10cSrcweir return g_strdup( bool_values[n] );
690cdf0e10cSrcweir }
691cdf0e10cSrcweir
692cdf0e10cSrcweir static bool
String2Bool(uno::Any & rAny,const gchar * value)693cdf0e10cSrcweir String2Bool( uno::Any& rAny, const gchar * value )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir sal_Bool bValue;
696cdf0e10cSrcweir
697cdf0e10cSrcweir if( strncmp( value, STRNCMP_PARAM( "true" ) ) )
698cdf0e10cSrcweir bValue = sal_True;
699cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "false" ) ) )
700cdf0e10cSrcweir bValue = sal_False;
701cdf0e10cSrcweir else
702cdf0e10cSrcweir return false;
703cdf0e10cSrcweir
704cdf0e10cSrcweir rAny = uno::makeAny(bValue);
705cdf0e10cSrcweir return true;
706cdf0e10cSrcweir }
707cdf0e10cSrcweir
708cdf0e10cSrcweir /*****************************************************************************/
709cdf0e10cSrcweir
710cdf0e10cSrcweir static gchar*
Scale2String(const uno::Any & rAny)711cdf0e10cSrcweir Scale2String( const uno::Any& rAny )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir return g_strdup_printf( "%g", (double) (rAny.get< sal_Int16 > ()) / 100 );
714cdf0e10cSrcweir }
715cdf0e10cSrcweir
716cdf0e10cSrcweir static bool
String2Scale(uno::Any & rAny,const gchar * value)717cdf0e10cSrcweir String2Scale( uno::Any& rAny, const gchar * value )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir double dval;
720cdf0e10cSrcweir
721cdf0e10cSrcweir if( 1 != sscanf( value, "%lg", &dval ) )
722cdf0e10cSrcweir return false;
723cdf0e10cSrcweir
724cdf0e10cSrcweir rAny = uno::makeAny((sal_Int16) (dval * 100));
725cdf0e10cSrcweir return true;
726cdf0e10cSrcweir }
727cdf0e10cSrcweir
728cdf0e10cSrcweir /*****************************************************************************/
729cdf0e10cSrcweir
730cdf0e10cSrcweir static gchar *
CaseMap2String(const uno::Any & rAny)731cdf0e10cSrcweir CaseMap2String( const uno::Any& rAny )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir const gchar * value = NULL;
734cdf0e10cSrcweir
735cdf0e10cSrcweir switch( rAny.get<short>() )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir case style::CaseMap::SMALLCAPS:
738cdf0e10cSrcweir value = "small_caps";
739cdf0e10cSrcweir break;
740cdf0e10cSrcweir
741cdf0e10cSrcweir default:
742cdf0e10cSrcweir value = "normal";
743cdf0e10cSrcweir break;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir
746cdf0e10cSrcweir if( value )
747cdf0e10cSrcweir return g_strdup( value );
748cdf0e10cSrcweir
749cdf0e10cSrcweir return NULL;
750cdf0e10cSrcweir }
751cdf0e10cSrcweir
752cdf0e10cSrcweir static bool
String2CaseMap(uno::Any & rAny,const gchar * value)753cdf0e10cSrcweir String2CaseMap( uno::Any& rAny, const gchar * value )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir short nCaseMap;
756cdf0e10cSrcweir
757cdf0e10cSrcweir if( strncmp( value, STRNCMP_PARAM( "normal" ) ) )
758cdf0e10cSrcweir nCaseMap = style::CaseMap::NONE;
759cdf0e10cSrcweir else if( strncmp( value, STRNCMP_PARAM( "small_caps" ) ) )
760cdf0e10cSrcweir nCaseMap = style::CaseMap::SMALLCAPS;
761cdf0e10cSrcweir else
762cdf0e10cSrcweir return false;
763cdf0e10cSrcweir
764cdf0e10cSrcweir rAny = uno::makeAny( nCaseMap );
765cdf0e10cSrcweir return true;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir
768cdf0e10cSrcweir /*****************************************************************************/
769cdf0e10cSrcweir
770cdf0e10cSrcweir const gchar * font_stretch[] = {
771cdf0e10cSrcweir "ultra_condensed",
772cdf0e10cSrcweir "extra_condensed",
773cdf0e10cSrcweir "condensed",
774cdf0e10cSrcweir "semi_condensed",
775cdf0e10cSrcweir "normal",
776cdf0e10cSrcweir "semi_expanded",
777cdf0e10cSrcweir "expanded",
778cdf0e10cSrcweir "extra_expanded",
779cdf0e10cSrcweir "ultra_expanded"
780cdf0e10cSrcweir };
781cdf0e10cSrcweir
782cdf0e10cSrcweir static gchar*
Kerning2Stretch(const uno::Any & rAny)783cdf0e10cSrcweir Kerning2Stretch(const uno::Any& rAny)
784cdf0e10cSrcweir {
785cdf0e10cSrcweir sal_Int16 n = rAny.get<sal_Int16>();
786cdf0e10cSrcweir int i = 4;
787cdf0e10cSrcweir
788cdf0e10cSrcweir // No good idea for a mapping - just return the basic info
789cdf0e10cSrcweir if( n < 0 )
790cdf0e10cSrcweir i=2;
791cdf0e10cSrcweir else if( n > 0 )
792cdf0e10cSrcweir i=6;
793cdf0e10cSrcweir
794cdf0e10cSrcweir return g_strdup(font_stretch[i]);
795cdf0e10cSrcweir }
796cdf0e10cSrcweir
797cdf0e10cSrcweir /*****************************************************************************/
798cdf0e10cSrcweir
799cdf0e10cSrcweir static gchar*
Locale2String(const uno::Any & rAny)800cdf0e10cSrcweir Locale2String(const uno::Any& rAny)
801cdf0e10cSrcweir {
802cdf0e10cSrcweir lang::Locale aLocale = rAny.get<lang::Locale> ();
803cdf0e10cSrcweir return g_strdup_printf( "%s-%s",
804cdf0e10cSrcweir rtl::OUStringToOString( aLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr(),
805cdf0e10cSrcweir rtl::OUStringToOString( aLocale.Country, RTL_TEXTENCODING_ASCII_US).toAsciiLowerCase().getStr() );
806cdf0e10cSrcweir }
807cdf0e10cSrcweir
808cdf0e10cSrcweir static bool
String2Locale(uno::Any & rAny,const gchar * value)809cdf0e10cSrcweir String2Locale( uno::Any& rAny, const gchar * value )
810cdf0e10cSrcweir {
811cdf0e10cSrcweir bool ret = false;
812cdf0e10cSrcweir
813cdf0e10cSrcweir gchar ** str_array = g_strsplit_set( value, "-.@", -1 );
814cdf0e10cSrcweir if( str_array[0] != NULL )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir ret = true;
817cdf0e10cSrcweir
818cdf0e10cSrcweir lang::Locale aLocale;
819cdf0e10cSrcweir
820cdf0e10cSrcweir aLocale.Language = rtl::OUString::createFromAscii(str_array[0]);
821cdf0e10cSrcweir if( str_array[1] != NULL )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir gchar * country = g_ascii_strup(str_array[1], -1);
824cdf0e10cSrcweir aLocale.Country = rtl::OUString::createFromAscii(country);
825cdf0e10cSrcweir g_free(country);
826cdf0e10cSrcweir }
827cdf0e10cSrcweir
828cdf0e10cSrcweir rAny = uno::makeAny(aLocale);
829cdf0e10cSrcweir }
830cdf0e10cSrcweir
831cdf0e10cSrcweir g_strfreev(str_array);
832cdf0e10cSrcweir return ret;
833cdf0e10cSrcweir }
834cdf0e10cSrcweir
835cdf0e10cSrcweir /*****************************************************************************/
836cdf0e10cSrcweir
837cdf0e10cSrcweir // @see http://www.w3.org/TR/2002/WD-css3-fonts-20020802/#font-effect-prop
838cdf0e10cSrcweir static const gchar * relief[] = { "none", "emboss", "engrave" };
839cdf0e10cSrcweir static const gchar * outline = "outline";
840cdf0e10cSrcweir
841cdf0e10cSrcweir static gchar *
get_font_effect(const uno::Sequence<beans::PropertyValue> & rAttributeList,sal_Int32 nContourIndex,sal_Int32 nReliefIndex)842cdf0e10cSrcweir get_font_effect(const uno::Sequence< beans::PropertyValue >& rAttributeList,
843cdf0e10cSrcweir sal_Int32 nContourIndex, sal_Int32 nReliefIndex)
844cdf0e10cSrcweir {
845cdf0e10cSrcweir if( nContourIndex != -1 )
846cdf0e10cSrcweir {
847cdf0e10cSrcweir if( rAttributeList[nContourIndex].Value.get<sal_Bool>() )
848cdf0e10cSrcweir return g_strdup(outline);
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
851cdf0e10cSrcweir if( nReliefIndex != -1 )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir sal_Int16 n = rAttributeList[nReliefIndex].Value.get<sal_Int16>();
854cdf0e10cSrcweir if( n < 3)
855cdf0e10cSrcweir return g_strdup(relief[n]);
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir return NULL;
859cdf0e10cSrcweir }
860cdf0e10cSrcweir
861cdf0e10cSrcweir /*****************************************************************************/
862cdf0e10cSrcweir
863cdf0e10cSrcweir // @see http://www.w3.org/TR/REC-CSS2/text.html#lining-striking-props
864cdf0e10cSrcweir
865cdf0e10cSrcweir
866cdf0e10cSrcweir enum
867cdf0e10cSrcweir {
868cdf0e10cSrcweir DECORATION_NONE = 0,
869cdf0e10cSrcweir DECORATION_BLINK,
870cdf0e10cSrcweir DECORATION_UNDERLINE,
871cdf0e10cSrcweir DECORATION_LINE_THROUGH
872cdf0e10cSrcweir };
873cdf0e10cSrcweir
874cdf0e10cSrcweir
875cdf0e10cSrcweir static const gchar * decorations[] = { "none", "blink", "underline", "line-through" };
876cdf0e10cSrcweir
877cdf0e10cSrcweir static gchar *
get_text_decoration(const uno::Sequence<beans::PropertyValue> & rAttributeList,sal_Int32 nBlinkIndex,sal_Int32 nUnderlineIndex,sal_Int16 nStrikeoutIndex)878cdf0e10cSrcweir get_text_decoration(const uno::Sequence< beans::PropertyValue >& rAttributeList,
879cdf0e10cSrcweir sal_Int32 nBlinkIndex, sal_Int32 nUnderlineIndex,
880cdf0e10cSrcweir sal_Int16 nStrikeoutIndex)
881cdf0e10cSrcweir {
882cdf0e10cSrcweir gchar * value_list[4] = { NULL, NULL, NULL, NULL };
883cdf0e10cSrcweir gint count = 0;
884cdf0e10cSrcweir
885cdf0e10cSrcweir // no property value found
886cdf0e10cSrcweir if( ( nBlinkIndex == -1 ) && (nUnderlineIndex == -1 ) && (nStrikeoutIndex == -1))
887cdf0e10cSrcweir return NULL;
888cdf0e10cSrcweir
889cdf0e10cSrcweir if( nBlinkIndex != -1 )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir if( rAttributeList[nBlinkIndex].Value.get<sal_Bool>() )
892cdf0e10cSrcweir value_list[count++] = const_cast <gchar *> (decorations[DECORATION_BLINK]);
893cdf0e10cSrcweir }
894cdf0e10cSrcweir if( nUnderlineIndex != -1 )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir sal_Int16 n = rAttributeList[nUnderlineIndex].Value.get<sal_Int16> ();
897cdf0e10cSrcweir if( n != awt::FontUnderline::NONE )
898cdf0e10cSrcweir value_list[count++] = const_cast <gchar *> (decorations[DECORATION_UNDERLINE]);
899cdf0e10cSrcweir }
900cdf0e10cSrcweir if( nStrikeoutIndex != -1 )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir sal_Int16 n = rAttributeList[nStrikeoutIndex].Value.get<sal_Int16> ();
903cdf0e10cSrcweir if( n != awt::FontStrikeout::NONE && n != awt::FontStrikeout::DONTKNOW )
904cdf0e10cSrcweir value_list[count++] = const_cast <gchar *> (decorations[DECORATION_LINE_THROUGH]);
905cdf0e10cSrcweir }
906cdf0e10cSrcweir
907cdf0e10cSrcweir if( count == 0 )
908cdf0e10cSrcweir value_list[count++] = const_cast <gchar *> (decorations[DECORATION_NONE]);
909cdf0e10cSrcweir
910cdf0e10cSrcweir return g_strjoinv(" ", value_list);
911cdf0e10cSrcweir }
912cdf0e10cSrcweir
913cdf0e10cSrcweir
914cdf0e10cSrcweir /*****************************************************************************/
915cdf0e10cSrcweir
916cdf0e10cSrcweir // @see http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-shadow
917cdf0e10cSrcweir
918cdf0e10cSrcweir static const gchar * shadow_values[] = { "none", "black" };
919cdf0e10cSrcweir
920cdf0e10cSrcweir static gchar *
Bool2Shadow(const uno::Any & rAny)921cdf0e10cSrcweir Bool2Shadow( const uno::Any& rAny )
922cdf0e10cSrcweir {
923cdf0e10cSrcweir int n = 0;
924cdf0e10cSrcweir
925cdf0e10cSrcweir if( rAny.get<sal_Bool>() )
926cdf0e10cSrcweir n = 1;
927cdf0e10cSrcweir
928cdf0e10cSrcweir return g_strdup( shadow_values[n] );
929cdf0e10cSrcweir }
930cdf0e10cSrcweir
931cdf0e10cSrcweir /*****************************************************************************/
932cdf0e10cSrcweir
933cdf0e10cSrcweir static gchar *
Short2Degree(const uno::Any & rAny)934cdf0e10cSrcweir Short2Degree( const uno::Any& rAny )
935cdf0e10cSrcweir {
936cdf0e10cSrcweir float f = rAny.get<sal_Int16>() / 10;
937cdf0e10cSrcweir return g_strdup_printf( "%g", f );
938cdf0e10cSrcweir }
939cdf0e10cSrcweir
940cdf0e10cSrcweir /*****************************************************************************/
941cdf0e10cSrcweir
942cdf0e10cSrcweir const gchar * directions[] = { "ltr", "rtl", "rtl", "ltr", "none" };
943cdf0e10cSrcweir
944cdf0e10cSrcweir static gchar *
WritingMode2Direction(const uno::Any & rAny)945cdf0e10cSrcweir WritingMode2Direction( const uno::Any& rAny )
946cdf0e10cSrcweir {
947cdf0e10cSrcweir sal_Int16 n = rAny.get<sal_Int16>();
948cdf0e10cSrcweir
949cdf0e10cSrcweir if( 0 <= n && n <= text::WritingMode2::PAGE )
950cdf0e10cSrcweir return g_strdup(directions[n]);
951cdf0e10cSrcweir
952cdf0e10cSrcweir return NULL;
953cdf0e10cSrcweir }
954cdf0e10cSrcweir
955cdf0e10cSrcweir // @see http://www.w3.org/TR/2001/WD-css3-text-20010517/#PrimaryTextAdvanceDirection
956cdf0e10cSrcweir
957cdf0e10cSrcweir const gchar * writing_modes[] = { "lr-tb", "rl-tb", "tb-rl", "tb-lr", "none" };
958cdf0e10cSrcweir static gchar *
WritingMode2String(const uno::Any & rAny)959cdf0e10cSrcweir WritingMode2String( const uno::Any& rAny )
960cdf0e10cSrcweir {
961cdf0e10cSrcweir sal_Int16 n = rAny.get<sal_Int16>();
962cdf0e10cSrcweir
963cdf0e10cSrcweir if( 0 <= n && n <= text::WritingMode2::PAGE )
964cdf0e10cSrcweir return g_strdup(writing_modes[n]);
965cdf0e10cSrcweir
966cdf0e10cSrcweir return NULL;
967cdf0e10cSrcweir }
968cdf0e10cSrcweir
969cdf0e10cSrcweir /*****************************************************************************/
970cdf0e10cSrcweir
971cdf0e10cSrcweir const char * baseline_values[] = { "baseline", "sub", "super" };
972cdf0e10cSrcweir
973cdf0e10cSrcweir // @see http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-vertical-align
974cdf0e10cSrcweir static gchar *
Escapement2VerticalAlign(const uno::Any & rAny)975cdf0e10cSrcweir Escapement2VerticalAlign( const uno::Any& rAny )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir sal_Int16 n = rAny.get<sal_Int16>();
978cdf0e10cSrcweir gchar * ret = NULL;
979cdf0e10cSrcweir
980cdf0e10cSrcweir // Values are in %, 101% means "automatic"
981cdf0e10cSrcweir if( n == 0 )
982cdf0e10cSrcweir ret = g_strdup(baseline_values[0]);
983cdf0e10cSrcweir else if( n == 101 )
984cdf0e10cSrcweir ret = g_strdup(baseline_values[2]);
985cdf0e10cSrcweir else if( n == -101 )
986cdf0e10cSrcweir ret = g_strdup(baseline_values[1]);
987cdf0e10cSrcweir else
988cdf0e10cSrcweir ret = g_strdup_printf( "%d%%", n );
989cdf0e10cSrcweir
990cdf0e10cSrcweir return ret;
991cdf0e10cSrcweir }
992cdf0e10cSrcweir
993cdf0e10cSrcweir /*****************************************************************************/
994cdf0e10cSrcweir
995cdf0e10cSrcweir // @see http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-line-height
996cdf0e10cSrcweir static gchar *
LineSpacing2LineHeight(const uno::Any & rAny)997cdf0e10cSrcweir LineSpacing2LineHeight( const uno::Any& rAny )
998cdf0e10cSrcweir {
999cdf0e10cSrcweir style::LineSpacing ls;
1000cdf0e10cSrcweir gchar * ret = NULL;
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir if( rAny >>= ls )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir if( ls.Mode == style::LineSpacingMode::PROP )
1005cdf0e10cSrcweir ret = g_strdup_printf( "%d%%", ls.Height );
1006cdf0e10cSrcweir else if( ls.Mode == style::LineSpacingMode::FIX )
1007cdf0e10cSrcweir ret = g_strdup_printf( "%.3gpt", toPoint(ls.Height) );
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir return ret;
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir /*****************************************************************************/
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir // @see http://www.w3.org/People/howcome/t/970224HTMLERB-CSS/WD-tabs-970117.html
1016cdf0e10cSrcweir static gchar *
TabStopList2String(const uno::Any & rAny,bool default_tabs)1017cdf0e10cSrcweir TabStopList2String( const uno::Any& rAny, bool default_tabs )
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir uno::Sequence< style::TabStop > theTabStops;
1020cdf0e10cSrcweir gchar * ret = NULL;
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir if( rAny >>= theTabStops)
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir sal_Int32 indexOfTab = 0;
1025cdf0e10cSrcweir sal_Int32 numberOfTabs = theTabStops.getLength();
1026cdf0e10cSrcweir sal_Unicode lastFillChar = (sal_Unicode) ' ';
1027cdf0e10cSrcweir
1028cdf0e10cSrcweir for( ; indexOfTab < numberOfTabs; ++indexOfTab )
1029cdf0e10cSrcweir {
1030cdf0e10cSrcweir bool is_default_tab = (style::TabAlign_DEFAULT == theTabStops[indexOfTab].Alignment);
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir if( is_default_tab != default_tabs )
1033cdf0e10cSrcweir continue;
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir double fValue = theTabStops[indexOfTab].Position;
1036cdf0e10cSrcweir fValue = fValue * 0.01;
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir const gchar * tab_align = "";
1039cdf0e10cSrcweir switch( theTabStops[indexOfTab].Alignment )
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir case style::TabAlign_LEFT :
1042cdf0e10cSrcweir tab_align = "left ";
1043cdf0e10cSrcweir break;
1044cdf0e10cSrcweir case style::TabAlign_CENTER :
1045cdf0e10cSrcweir tab_align = "center ";
1046cdf0e10cSrcweir break;
1047cdf0e10cSrcweir case style::TabAlign_RIGHT :
1048cdf0e10cSrcweir tab_align = "right ";
1049cdf0e10cSrcweir break;
1050cdf0e10cSrcweir case style::TabAlign_DECIMAL :
1051cdf0e10cSrcweir tab_align = "decimal ";
1052cdf0e10cSrcweir break;
1053cdf0e10cSrcweir default:
1054cdf0e10cSrcweir break;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir const gchar * lead_char = "";
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir if( theTabStops[indexOfTab].FillChar != lastFillChar )
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir lastFillChar = theTabStops[indexOfTab].FillChar;
1062cdf0e10cSrcweir switch (lastFillChar)
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir case (sal_Unicode) ' ':
1065cdf0e10cSrcweir lead_char = "blank ";
1066cdf0e10cSrcweir break;
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir case (sal_Unicode) '.':
1069cdf0e10cSrcweir lead_char = "dotted ";
1070cdf0e10cSrcweir break;
1071cdf0e10cSrcweir
1072cdf0e10cSrcweir case (sal_Unicode) '-':
1073cdf0e10cSrcweir lead_char = "dashed ";
1074cdf0e10cSrcweir break;
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir case (sal_Unicode) '_':
1077cdf0e10cSrcweir lead_char = "lined ";
1078cdf0e10cSrcweir break;
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir default:
1081cdf0e10cSrcweir lead_char = "custom ";
1082cdf0e10cSrcweir break;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir gchar * tab_str = g_strdup_printf( "%s%s%gmm", lead_char, tab_align, fValue );
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir if( ret )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir gchar * old_tab_str = ret;
1091cdf0e10cSrcweir ret = g_strconcat(old_tab_str, " ", tab_str, NULL /* terminated */);
1092cdf0e10cSrcweir g_free( old_tab_str );
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir else
1095cdf0e10cSrcweir ret = tab_str;
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir
1099cdf0e10cSrcweir return ret;
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir static gchar *
TabStops2String(const uno::Any & rAny)1103cdf0e10cSrcweir TabStops2String( const uno::Any& rAny )
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir return TabStopList2String(rAny, false);
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir static gchar *
DefaultTabStops2String(const uno::Any & rAny)1109cdf0e10cSrcweir DefaultTabStops2String( const uno::Any& rAny )
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir return TabStopList2String(rAny, true);
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir /*****************************************************************************/
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir extern "C" int
attr_compare(const void * p1,const void * p2)1117cdf0e10cSrcweir attr_compare(const void *p1,const void *p2)
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir const rtl_uString * pustr = (const rtl_uString *) p1;
1120cdf0e10cSrcweir const char * pc = *((const char **) p2);
1121cdf0e10cSrcweir
1122cdf0e10cSrcweir return rtl_ustr_ascii_compare_WithLength(pustr->buffer, pustr->length, pc);
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir static void
find_exported_attributes(sal_Int32 * pArray,const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & rAttributeList)1126cdf0e10cSrcweir find_exported_attributes( sal_Int32 *pArray,
1127cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAttributeList )
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir for( sal_Int32 i = 0; i < rAttributeList.getLength(); i++ )
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir const char ** pAttr = (const char **) bsearch(rAttributeList[i].Name.pData,
1132cdf0e10cSrcweir ExportedTextAttributes, TEXT_ATTRIBUTE_LAST, sizeof(const char *),
1133cdf0e10cSrcweir attr_compare);
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir if( pAttr )
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir sal_Int32 nIndex = pAttr - ExportedTextAttributes;
1138cdf0e10cSrcweir pArray[nIndex] = i;
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir /*****************************************************************************/
1144cdf0e10cSrcweir
1145cdf0e10cSrcweir static AtkAttributeSet*
attribute_set_prepend(AtkAttributeSet * attribute_set,AtkTextAttribute attribute,gchar * value)1146cdf0e10cSrcweir attribute_set_prepend( AtkAttributeSet* attribute_set,
1147cdf0e10cSrcweir AtkTextAttribute attribute,
1148cdf0e10cSrcweir gchar * value )
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir if( value )
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir AtkAttribute *at = (AtkAttribute *) g_malloc( sizeof (AtkAttribute) );
1153cdf0e10cSrcweir at->name = g_strdup( atk_text_attribute_get_name( attribute ) );
1154cdf0e10cSrcweir at->value = value;
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir return g_slist_prepend(attribute_set, at);
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir return attribute_set;
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir /*****************************************************************************/
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir AtkAttributeSet*
attribute_set_new_from_property_values(const uno::Sequence<beans::PropertyValue> & rAttributeList,bool run_attributes_only,AtkText * text)1165cdf0e10cSrcweir attribute_set_new_from_property_values(
1166cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rAttributeList,
1167cdf0e10cSrcweir bool run_attributes_only,
1168cdf0e10cSrcweir AtkText *text)
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir AtkAttributeSet* attribute_set = NULL;
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir sal_Int32 aIndexList[TEXT_ATTRIBUTE_LAST] = { -1 };
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir // Initialize index array with -1
1175cdf0e10cSrcweir for( sal_Int32 attr = 0; attr < TEXT_ATTRIBUTE_LAST; ++attr )
1176cdf0e10cSrcweir aIndexList[attr] = -1;
1177cdf0e10cSrcweir
1178cdf0e10cSrcweir find_exported_attributes(aIndexList, rAttributeList);
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_BG_COLOR,
1181cdf0e10cSrcweir get_color_value(rAttributeList, aIndexList, TEXT_ATTRIBUTE_BACKGROUND_COLOR, run_attributes_only ? NULL : text ) );
1182cdf0e10cSrcweir
1183cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_FG_COLOR,
1184cdf0e10cSrcweir get_color_value(rAttributeList, aIndexList, TEXT_ATTRIBUTE_FOREGROUND_COLOR, run_attributes_only ? NULL : text) );
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_INVISIBLE,
1187cdf0e10cSrcweir get_bool_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_HIDDEN]));
1188cdf0e10cSrcweir
1189cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_UNDERLINE,
1190cdf0e10cSrcweir get_underline_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_UNDERLINE]));
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_STRIKETHROUGH,
1193cdf0e10cSrcweir get_strikethrough_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_STRIKETHROUGH]));
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_SIZE,
1196cdf0e10cSrcweir get_height_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_HEIGHT]));
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_WEIGHT,
1199cdf0e10cSrcweir get_weight_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_WEIGHT]));
1200cdf0e10cSrcweir
1201cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_FAMILY_NAME,
1202cdf0e10cSrcweir get_string_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_FONT_NAME]));
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_VARIANT,
1205cdf0e10cSrcweir get_variant_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_CASEMAP]));
1206cdf0e10cSrcweir
1207cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_STYLE,
1208cdf0e10cSrcweir get_style_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_POSTURE]));
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_SCALE,
1211cdf0e10cSrcweir get_scale_width(rAttributeList, aIndexList[TEXT_ATTRIBUTE_SCALE]));
1212cdf0e10cSrcweir
1213cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_LANGUAGE,
1214cdf0e10cSrcweir get_language_string(rAttributeList, aIndexList[TEXT_ATTRIBUTE_LOCALE]));
1215cdf0e10cSrcweir
1216cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_DIRECTION,
1217cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_WRITING_MODE], WritingMode2Direction));
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_STRETCH,
1220cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_KERNING], Kerning2Stretch));
1221cdf0e10cSrcweir
1222cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_font_effect )
1223cdf0e10cSrcweir atk_text_attribute_font_effect = atk_text_attribute_register("font-effect");
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_font_effect,
1226cdf0e10cSrcweir get_font_effect(rAttributeList, aIndexList[TEXT_ATTRIBUTE_CONTOURED], aIndexList[TEXT_ATTRIBUTE_RELIEF]));
1227cdf0e10cSrcweir
1228cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_decoration )
1229cdf0e10cSrcweir atk_text_attribute_decoration = atk_text_attribute_register("text-decoration");
1230cdf0e10cSrcweir
1231cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_decoration,
1232cdf0e10cSrcweir get_text_decoration(rAttributeList, aIndexList[TEXT_ATTRIBUTE_BLINKING],
1233cdf0e10cSrcweir aIndexList[TEXT_ATTRIBUTE_UNDERLINE], aIndexList[TEXT_ATTRIBUTE_STRIKETHROUGH]));
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_rotation )
1236cdf0e10cSrcweir atk_text_attribute_rotation = atk_text_attribute_register("text-rotation");
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_rotation,
1239cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_ROTATION], Short2Degree));
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_shadow )
1242cdf0e10cSrcweir atk_text_attribute_shadow = atk_text_attribute_register("text-shadow");
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_shadow,
1245cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_SHADOWED], Bool2Shadow));
1246cdf0e10cSrcweir
1247cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_writing_mode )
1248cdf0e10cSrcweir atk_text_attribute_writing_mode = atk_text_attribute_register("writing-mode");
1249cdf0e10cSrcweir
1250cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_writing_mode,
1251cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_WRITING_MODE], WritingMode2String));
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_vertical_align )
1254cdf0e10cSrcweir atk_text_attribute_vertical_align = atk_text_attribute_register("vertical-align");
1255cdf0e10cSrcweir
1256cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_vertical_align,
1257cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_CHAR_ESCAPEMENT], Escapement2VerticalAlign));
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir if( run_attributes_only )
1260cdf0e10cSrcweir return attribute_set;
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_LEFT_MARGIN,
1263cdf0e10cSrcweir get_cmm_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_LEFT_MARGIN]));
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_RIGHT_MARGIN,
1266cdf0e10cSrcweir get_cmm_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_RIGHT_MARGIN]));
1267cdf0e10cSrcweir
1268cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_INDENT,
1269cdf0e10cSrcweir get_cmm_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_FIRST_LINE_INDENT]));
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
1272cdf0e10cSrcweir get_cmm_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_TOP_MARGIN]));
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
1275cdf0e10cSrcweir get_cmm_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_BOTTOM_MARGIN]));
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, ATK_TEXT_ATTR_JUSTIFICATION,
1278cdf0e10cSrcweir get_justification_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_JUSTIFICATION]));
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_paragraph_style )
1281cdf0e10cSrcweir atk_text_attribute_paragraph_style = atk_text_attribute_register("paragraph-style");
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_paragraph_style,
1284cdf0e10cSrcweir get_string_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_STYLE_NAME]));
1285cdf0e10cSrcweir
1286cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_line_height )
1287cdf0e10cSrcweir atk_text_attribute_line_height = atk_text_attribute_register("line-height");
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_line_height,
1290cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_LINE_SPACING], LineSpacing2LineHeight));
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tab_interval )
1293cdf0e10cSrcweir atk_text_attribute_tab_interval = atk_text_attribute_register("tab-interval");
1294cdf0e10cSrcweir
1295cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_tab_interval,
1296cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_TAB_STOPS], DefaultTabStops2String));
1297cdf0e10cSrcweir
1298cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tab_stops )
1299cdf0e10cSrcweir atk_text_attribute_tab_stops = atk_text_attribute_register("tab-stops");
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_tab_stops,
1302cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_TAB_STOPS], TabStops2String));
1303cdf0e10cSrcweir
1304cdf0e10cSrcweir // --> OD 2010-03-05 #i92233#
1305cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_mm_to_pixel_ratio )
1306cdf0e10cSrcweir atk_text_attribute_mm_to_pixel_ratio = atk_text_attribute_register("mm-to-pixel-ratio");
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir attribute_set = attribute_set_prepend( attribute_set, atk_text_attribute_mm_to_pixel_ratio,
1309cdf0e10cSrcweir get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_MM_TO_PIXEL_RATIO], Float2String));
1310cdf0e10cSrcweir // <--
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir return attribute_set;
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir
1315cdf0e10cSrcweir
attribute_set_prepend_misspelled(AtkAttributeSet * attribute_set)1316cdf0e10cSrcweir AtkAttributeSet* attribute_set_prepend_misspelled( AtkAttributeSet* attribute_set )
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_misspelled )
1319cdf0e10cSrcweir atk_text_attribute_misspelled = atk_text_attribute_register( "text-spelling" );
1320cdf0e10cSrcweir
1321cdf0e10cSrcweir attribute_set = attribute_set_prepend( attribute_set, atk_text_attribute_misspelled,
1322cdf0e10cSrcweir g_strdup_printf( "misspelled" ) );
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir return attribute_set;
1325cdf0e10cSrcweir }
1326cdf0e10cSrcweir
1327cdf0e10cSrcweir // --> OD 2010-03-01 #i92232#
attribute_set_prepend_tracked_change_insertion(AtkAttributeSet * attribute_set)1328cdf0e10cSrcweir AtkAttributeSet* attribute_set_prepend_tracked_change_insertion( AtkAttributeSet* attribute_set )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir if ( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tracked_change )
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir atk_text_attribute_tracked_change = atk_text_attribute_register( "text-tracked-change" );
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir attribute_set = attribute_set_prepend( attribute_set,
1336cdf0e10cSrcweir atk_text_attribute_tracked_change,
1337cdf0e10cSrcweir g_strdup_printf( "insertion" ) );
1338cdf0e10cSrcweir
1339cdf0e10cSrcweir return attribute_set;
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir
attribute_set_prepend_tracked_change_deletion(AtkAttributeSet * attribute_set)1342cdf0e10cSrcweir AtkAttributeSet* attribute_set_prepend_tracked_change_deletion( AtkAttributeSet* attribute_set )
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir if ( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tracked_change )
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir atk_text_attribute_tracked_change = atk_text_attribute_register( "text-tracked-change" );
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir
1349cdf0e10cSrcweir attribute_set = attribute_set_prepend( attribute_set,
1350cdf0e10cSrcweir atk_text_attribute_tracked_change,
1351cdf0e10cSrcweir g_strdup_printf( "deletion" ) );
1352cdf0e10cSrcweir
1353cdf0e10cSrcweir return attribute_set;
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir
attribute_set_prepend_tracked_change_formatchange(AtkAttributeSet * attribute_set)1356cdf0e10cSrcweir AtkAttributeSet* attribute_set_prepend_tracked_change_formatchange( AtkAttributeSet* attribute_set )
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir if ( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tracked_change )
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir atk_text_attribute_tracked_change = atk_text_attribute_register( "text-tracked-change" );
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir
1363cdf0e10cSrcweir attribute_set = attribute_set_prepend( attribute_set,
1364cdf0e10cSrcweir atk_text_attribute_tracked_change,
1365cdf0e10cSrcweir g_strdup_printf( "attribute-change" ) );
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir return attribute_set;
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir // <--
1370cdf0e10cSrcweir
1371cdf0e10cSrcweir /*****************************************************************************/
1372cdf0e10cSrcweir
1373cdf0e10cSrcweir struct AtkTextAttrMapping
1374cdf0e10cSrcweir {
1375cdf0e10cSrcweir const char * name;
1376cdf0e10cSrcweir TextPropertyValueFunc toPropertyValue;
1377cdf0e10cSrcweir };
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir const AtkTextAttrMapping g_TextAttrMap[] =
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_INVALID = 0
1382cdf0e10cSrcweir { "ParaLeftMargin", UnitString2CMM }, // ATK_TEXT_ATTR_LEFT_MARGIN
1383cdf0e10cSrcweir { "ParaRightMargin", UnitString2CMM }, // ATK_TEXT_ATTR_RIGHT_MARGIN
1384cdf0e10cSrcweir { "ParaFirstLineIndent", UnitString2CMM }, // ATK_TEXT_ATTR_INDENT
1385cdf0e10cSrcweir { "CharHidden", String2Bool }, // ATK_TEXT_ATTR_INVISIBLE
1386cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_EDITABLE
1387cdf0e10cSrcweir { "ParaTopMargin", UnitString2CMM }, // ATK_TEXT_ATTR_PIXELS_ABOVE_LINES
1388cdf0e10cSrcweir { "ParaBottomMargin", UnitString2CMM }, // ATK_TEXT_ATTR_PIXELS_BELOW_LINES
1389cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP
1390cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_BG_FULL_HEIGHT
1391cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_RISE
1392cdf0e10cSrcweir { "CharUnderline", String2Underline }, // ATK_TEXT_ATTR_UNDERLINE
1393cdf0e10cSrcweir { "CharStrikeout", String2Strikeout }, // ATK_TEXT_ATTR_STRIKETHROUGH
1394cdf0e10cSrcweir { "CharHeight", String2Float }, // ATK_TEXT_ATTR_SIZE
1395cdf0e10cSrcweir { "CharScaleWidth", String2Scale }, // ATK_TEXT_ATTR_SCALE
1396cdf0e10cSrcweir { "CharWeight", String2Weight }, // ATK_TEXT_ATTR_WEIGHT
1397cdf0e10cSrcweir { "CharLocale", String2Locale }, // ATK_TEXT_ATTR_LANGUAGE
1398cdf0e10cSrcweir { "CharFontName", SetString }, // ATK_TEXT_ATTR_FAMILY_NAME
1399cdf0e10cSrcweir { "CharBackColor", String2Color }, // ATK_TEXT_ATTR_BG_COLOR
1400cdf0e10cSrcweir { "CharColor", String2Color }, // ATK_TEXT_ATTR_FG_COLOR
1401cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_BG_STIPPLE
1402cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_FG_STIPPLE
1403cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_WRAP_MODE
1404cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_DIRECTION
1405cdf0e10cSrcweir { "ParaAdjust", Justification2Adjust }, // ATK_TEXT_ATTR_JUSTIFICATION
1406cdf0e10cSrcweir { "", InvalidValue }, // ATK_TEXT_ATTR_STRETCH
1407cdf0e10cSrcweir { "CharCaseMap", String2CaseMap }, // ATK_TEXT_ATTR_VARIANT
1408cdf0e10cSrcweir { "CharPosture", Style2FontSlant } // ATK_TEXT_ATTR_STYLE
1409cdf0e10cSrcweir };
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir static const sal_Int32 g_TextAttrMapSize = sizeof( g_TextAttrMap ) / sizeof( AtkTextAttrMapping );
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir /*****************************************************************************/
1414cdf0e10cSrcweir
1415cdf0e10cSrcweir bool
attribute_set_map_to_property_values(AtkAttributeSet * attribute_set,uno::Sequence<beans::PropertyValue> & rValueList)1416cdf0e10cSrcweir attribute_set_map_to_property_values(
1417cdf0e10cSrcweir AtkAttributeSet* attribute_set,
1418cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >& rValueList )
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir // Ensure enough space ..
1421cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aAttributeList (g_TextAttrMapSize);
1422cdf0e10cSrcweir
1423cdf0e10cSrcweir sal_Int32 nIndex = 0;
1424cdf0e10cSrcweir for( GSList * item = attribute_set; item != NULL; item = g_slist_next( item ) )
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir AtkAttribute* attribute = (AtkAttribute *) item;
1427cdf0e10cSrcweir
1428cdf0e10cSrcweir AtkTextAttribute text_attr = atk_text_attribute_for_name( attribute->name );
1429cdf0e10cSrcweir if( text_attr < g_TextAttrMapSize )
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir if( g_TextAttrMap[text_attr].name[0] != '\0' )
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir if( ! g_TextAttrMap[text_attr].toPropertyValue( aAttributeList[nIndex].Value, attribute->value) )
1434cdf0e10cSrcweir return false;
1435cdf0e10cSrcweir
1436cdf0e10cSrcweir aAttributeList[nIndex].Name = rtl::OUString::createFromAscii( g_TextAttrMap[text_attr].name );
1437cdf0e10cSrcweir aAttributeList[nIndex].State = beans::PropertyState_DIRECT_VALUE;
1438cdf0e10cSrcweir ++nIndex;
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir }
1441cdf0e10cSrcweir else
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir // Unsupported text attribute
1444cdf0e10cSrcweir return false;
1445cdf0e10cSrcweir }
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir
1448cdf0e10cSrcweir aAttributeList.realloc( nIndex );
1449cdf0e10cSrcweir rValueList = aAttributeList;
1450cdf0e10cSrcweir return true;
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir
1453