summaryrefslogtreecommitdiff
path: root/extensions/source/propctrlr/stringrepresentation.cxx
blob: b87576d575962a06da61694a1aeb7628a3af9ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
/*************************************************************************
 *
 *  $RCSfile: stringrepresentation.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: obo $ $Date: 2004-11-16 12:12:56 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef EXTENSIONS_SOURCE_PROPCTRLR_STRINGREPRESENTATION_HXX
#include "stringrepresentation.hxx"
#endif

/** === begin UNO includes === **/
#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
#include <com/sun/star/util/DateTime.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
#include <com/sun/star/util/Date.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
#include <com/sun/star/util/Time.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
#endif
/** === end UNO includes === **/

#ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
#include "modulepcr.hxx"
#endif
#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
#include "formresid.hrc"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
#include "propertyinfo.hxx"
#endif
#ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
#include "formmetadata.hxx"
#endif

#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _DATE_HXX
#include <tools/date.hxx>
#endif
#ifndef _TOOLS_TIME_HXX
#include <tools/time.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif

#ifndef _COMPHELPER_EXTRACT_HXX_
#include <cppuhelper/extract.hxx>
#endif

#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif

#ifndef _UNOTOOLS_DATETIME_HXX_
#include <unotools/datetime.hxx>
#endif

#include <functional>

//........................................................................
namespace pcr
{
//........................................................................

    using namespace ::com::sun::star;
    using namespace ::com::sun::star::uno;
    using namespace ::com::sun::star::lang;
    using namespace ::com::sun::star::script;

    //====================================================================
    //= StringRepresentation
    //====================================================================
    //------------------------------------------------------------------------
    StringRepresentation::StringRepresentation( const Reference< XTypeConverter >& _rxConverter )
        :m_xTypeConverter( _rxConverter )
    {
    }

    //------------------------------------------------------------------------
    ::rtl::OUString StringRepresentation::convertSimpleToString( const Any& _rValue )
    {
        ::rtl::OUString sReturn;
        if ( m_xTypeConverter.is() && _rValue.hasValue() )
        {
            try
            {
                Any aConvertedToString;
                aConvertedToString = m_xTypeConverter->convertToSimpleType( _rValue, TypeClass_STRING );
                aConvertedToString >>= sReturn;
            }
            catch( CannotConvertException& ) { }
            catch( IllegalArgumentException& ) { }
        }
        return sReturn;
    }

    //--------------------------------------------------------------------
    namespace
    {
        struct ConvertIntegerToString : public ::std::unary_function< sal_Int32, String >
        {
            String operator()( sal_Int32 _rIntValue ) const
            {
                return String::CreateFromInt32( _rIntValue );
            }
        };

        struct StringIdentity : public ::std::unary_function< ::rtl::OUString, String >
        {
            String operator()( ::rtl::OUString _rValue ) const
            {
                return _rValue;
            }
        };

        template < class ElementType, class Translator >
        ::rtl::OUString composeSequenceElements( const Sequence< ElementType >& _rElements, const Translator& _rTranslator )
        {
            String sCompose;

            // loop through the elements and concatenate the string representations of the integers
            // (separated by a line break)
            const ElementType* pElements = _rElements.getConstArray();
            const ElementType* pElementsEnd = pElements + _rElements.getLength();
            for ( ; pElements != pElementsEnd; ++pElements )
            {
                sCompose += _rTranslator( *pElements );
                if ( pElements != pElementsEnd )
                    sCompose += '\n';
            }

            return sCompose;
        }
    }

    //--------------------------------------------------------------------
    bool StringRepresentation::convertGenericValueToString( const Any& _rValue, ::rtl::OUString& _rStringRep )
    {
        bool bCanConvert = true;

        switch ( _rValue.getValueTypeClass() )
        {
        case TypeClass_STRING:
            _rValue >>= _rStringRep;
            break;

        case TypeClass_BOOLEAN:
        {
            String aEntries( ModuleRes( RID_STR_BOOL ) );
            sal_Bool bValue = sal_False;
            _rValue >>= bValue;
            _rStringRep = bValue ? aEntries.GetToken( 1 ) : aEntries.GetToken( 0 );
        }
        break;

        // some sequence types
        case TypeClass_SEQUENCE:
        {
            Sequence< ::rtl::OUString> aStringValues;
            Sequence< sal_uInt16 > aUInt16Values;
            Sequence< sal_Int16 > aInt16Values;
            Sequence< sal_uInt32 > aUInt32Values;
            Sequence< sal_Int32 > aInt32Values;

            // string sequences
            if ( _rValue >>= aStringValues )
            {
                _rStringRep = composeSequenceElements( aStringValues, StringIdentity() );
            }
            // uInt16 sequences
            else if ( _rValue >>= aUInt16Values )
            {
                _rStringRep = composeSequenceElements( aUInt16Values, ConvertIntegerToString() );
            }
            // Int16 sequences
            else if ( _rValue >>= aInt16Values )
            {
                _rStringRep = composeSequenceElements( aInt16Values, ConvertIntegerToString() );
            }
            // uInt32 sequences
            else if ( _rValue >>= aUInt32Values )
            {
                _rStringRep = composeSequenceElements( aUInt32Values, ConvertIntegerToString() );
            }
            // Int32 sequences
            else if ( _rValue >>= aInt32Values )
            {
                _rStringRep = composeSequenceElements( aInt32Values, ConvertIntegerToString() );
            }
            else
                bCanConvert = false;
        }
        break;

        // some structs
        case TypeClass_STRUCT:
            if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::Date* >( NULL ) ) ) )
            {
                // weird enough, the string representation of dates, as used
                // by the control displaying dates, and thus as passed through the layers,
                // is YYYYMMDD.
                util::Date aUnoDate;
                _rValue >>= aUnoDate;

                ::Date aDate;
                ::utl::typeConvert( aUnoDate, aDate );

                _rStringRep = String::CreateFromInt32( aDate.GetDate() );
            }
            else if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::Time* >( NULL ) ) ) )
            {
                // similar for time (HHMMSSHH)
                util::Time aUnoTime;
                _rValue >>= aUnoTime;

                ::Time aTime;
                ::utl::typeConvert( aUnoTime, aTime );

                _rStringRep = String::CreateFromInt32( aTime.GetTime() );
            }
            else if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::DateTime* >( NULL ) ) ) )
            {
                util::DateTime aUnoDateTime;
                _rValue >>= aUnoDateTime;

                ::rtl::OUStringBuffer aBuffer;
                aBuffer.append( (sal_Int32)aUnoDateTime.Year );
                aBuffer.appendAscii( "-" );
                aBuffer.append( (sal_Int32)aUnoDateTime.Month );
                aBuffer.appendAscii( "-" );
                aBuffer.append( (sal_Int32)aUnoDateTime.Day );

                aBuffer.appendAscii( " " );

                aBuffer.append( (sal_Int32)aUnoDateTime.Hours );
                aBuffer.appendAscii( ":" );
                aBuffer.append( (sal_Int32)aUnoDateTime.Minutes );
                aBuffer.appendAscii( ":" );
                aBuffer.append( (sal_Int32)aUnoDateTime.Seconds );
                aBuffer.appendAscii( ":" );
                aBuffer.append( (sal_Int32)aUnoDateTime.HundredthSeconds );

                _rStringRep = aBuffer.makeStringAndClear();
            }
            else
                bCanConvert = false;
            break;

        default:
            bCanConvert = false;
            break;
        }

        return bCanConvert;
    }

    //--------------------------------------------------------------------
    ::rtl::OUString StringRepresentation::getStringRepFromPropertyValue( const Any& _rValue, sal_Int32 _nPropertyId, const IPropertyInfoService* _pMetaData )
    {
        // try the most basic types
        ::rtl::OUString sReturn = convertSimpleToString( _rValue );

        // try enum properties
        if ( _pMetaData )
        {
            sal_uInt32  nPropertyUIFlags = _pMetaData->getPropertyUIFlags( _nPropertyId );
            if ( ( nPropertyUIFlags & PROP_FLAG_ENUM ) != 0 )
            {
                sal_Int32 nIntValue = -1;
                if ( ::cppu::enum2int( nIntValue, _rValue ) )
                {
                    if ( ( nPropertyUIFlags & PROP_FLAG_ENUM_ONE ) == PROP_FLAG_ENUM_ONE )
                        // enum value starting with 1
                        --nIntValue;

                    ::std::vector< String > aEnumStrings = _pMetaData->getPropertyEnumRepresentations( _nPropertyId );
                    if ( ( nIntValue >= 0 ) && ( nIntValue < (sal_Int32)aEnumStrings.size() ) )
                    {
                        sReturn = aEnumStrings[ nIntValue ];
                    }
                    else
                        DBG_ERROR( "StringRepresentation::getStringRepFromPropertyValue: could not translate an enum value" );
                }
            }
        }

        if ( ( !sReturn.getLength() && _rValue.hasValue() ) || ( _rValue.getValueTypeClass() == TypeClass_BOOLEAN ) )
        {
        #if OSL_DEBUG_LEVEL > 0
            bool bCanConvert =
        #endif
            convertGenericValueToString( _rValue, sReturn );

        #if OSL_DEBUG_LEVEL > 0
            if ( !bCanConvert )
            {
                ::rtl::OString sMessage( "StringRepresentation::getStringRepFromPropertyValue: cannot convert values of type '" );
                sMessage += ::rtl::OString( _rValue.getValueType().getTypeName().getStr(), _rValue.getValueType().getTypeName().getLength(), RTL_TEXTENCODING_ASCII_US );
                sMessage += ::rtl::OString( "'!" );
                DBG_ERROR( sMessage.getStr() );
            }
        #endif

        }

        return sReturn;
    }

    //------------------------------------------------------------------------
    namespace
    {
        sal_Int32 getStringPos( const String& _rEntry, const ::std::vector< String >& _rEntries)
        {
            ::std::vector< String >::const_iterator pStart = _rEntries.begin();
            ::std::vector< String >::const_iterator pEnd = _rEntries.end();
            for ( ::std::vector< String >::const_iterator pEntries = pStart; pEntries != pEnd; ++pEntries )
            {
                if ( _rEntry == *pEntries )
                    return pEntries - pStart;
            }
            return -1;
        }
    }

    //--------------------------------------------------------------------
    bool StringRepresentation::convertStringToGenericValue( const ::rtl::OUString& _rStringRep, Any& _rValue, const Type& _rTargetType )
    {
        bool bCanConvert = true;

        switch ( _rTargetType.getTypeClass() )
        {
        case TypeClass_STRING:
            _rValue <<= _rStringRep;
            break;

        case TypeClass_BOOLEAN:
        {
            String sBooleanValues( ModuleRes( RID_STR_BOOL ) );
            if ( sBooleanValues.GetToken(0) == String( _rStringRep ) )
                _rValue <<= (sal_Bool)sal_False;
            else
                _rValue <<= (sal_Bool)sal_True;
        }
        break;

        case TypeClass_SEQUENCE:
        {
            Type aElementType = ::comphelper::getSequenceElementType( _rTargetType );

            String aStr( _rStringRep );
            switch ( aElementType.getTypeClass() )
            {
                case TypeClass_STRING:
                {
                    sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                    Sequence< ::rtl::OUString> aStringSeq( nEntryCount );
                    ::rtl::OUString* pStringArray = aStringSeq.getArray();

                    for (sal_Int32 i=0; i<aStringSeq.getLength(); ++i, ++pStringArray)
                        *pStringArray = aStr.GetToken((sal_uInt16)i, '\n');
                    _rValue <<= aStringSeq;
                }
                break;
                case TypeClass_UNSIGNED_SHORT:
                {
                    sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                    Sequence<sal_uInt16> aSeq( nEntryCount );

                    sal_uInt16* pArray = aSeq.getArray();

                    for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                        *pArray = (sal_uInt16)aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                    _rValue <<= aSeq;

                }
                break;
                case TypeClass_SHORT:
                {
                    sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                    Sequence<sal_Int16> aSeq( nEntryCount );

                    sal_Int16* pArray = aSeq.getArray();

                    for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                        *pArray = (sal_Int16)aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                    _rValue <<= aSeq;

                }
                break;
                case TypeClass_LONG:
                {
                    sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                    Sequence<sal_Int32> aSeq( nEntryCount );

                    sal_Int32* pArray = aSeq.getArray();

                    for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                        *pArray = aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                    _rValue <<= aSeq;

                }
                break;
                case TypeClass_UNSIGNED_LONG:
                {
                    sal_uInt32 nEntryCount = aStr.GetTokenCount('\n');
                    Sequence<sal_uInt32> aSeq( nEntryCount );

                    sal_uInt32* pArray = aSeq.getArray();

                    for (sal_Int32 i=0; i<aSeq.getLength(); ++i, ++pArray)
                        *pArray = aStr.GetToken((sal_uInt16)i, '\n').ToInt32();

                    _rValue <<= aSeq;

                }
                break;
                default:
                    bCanConvert = false;
                    break;
            }
        }
        break;

        case TypeClass_STRUCT:
            if ( _rTargetType.equals( ::getCppuType( static_cast< util::Date* >( NULL ) ) ) )
            {
                // weird enough, the string representation of dates, as used
                // by the control displaying dates, and thus as passed through the layers,
                // is YYYYMMDD.
                ::Date aDate( _rStringRep.toInt32() );

                util::Date aUnoDate;
                ::utl::typeConvert( aDate, aUnoDate );

                _rValue <<= aUnoDate;
            }
            else if ( _rTargetType.equals( ::getCppuType( static_cast< util::Time* >( NULL ) ) ) )
            {
                // similar for time (HHMMSSHH)
                ::Time aTime( _rStringRep.toInt32() );

                util::Time aUnoTime;
                ::utl::typeConvert( aTime, aUnoTime );

                _rValue <<= aUnoTime;
            }
            else if ( _rTargetType.equals( ::getCppuType( static_cast< util::DateTime* >( NULL ) ) ) )
            {
                util::DateTime aUnoDateTime;

                sal_Int32 nSepPos = -1, nPrevSepPos = 0;

                nSepPos = _rStringRep.indexOf( '-', nPrevSepPos = nSepPos + 1 );
                aUnoDateTime.Year = (sal_Int16)_rStringRep.copy( nPrevSepPos, nSepPos - nPrevSepPos ).toInt32();

                nSepPos = _rStringRep.indexOf( '-', nPrevSepPos = nSepPos + 1 );
                aUnoDateTime.Month = (sal_Int16)_rStringRep.copy( nPrevSepPos, nSepPos - nPrevSepPos ).toInt32();

                nSepPos = _rStringRep.indexOf( ' ', nPrevSepPos = nSepPos + 1 );
                aUnoDateTime.Day = (sal_Int16)_rStringRep.copy( nPrevSepPos, nSepPos - nPrevSepPos ).toInt32();

                nSepPos = _rStringRep.indexOf( ':', nPrevSepPos = nSepPos + 1 );
                aUnoDateTime.Hours = (sal_Int16)_rStringRep.copy( nPrevSepPos, nSepPos - nPrevSepPos ).toInt32();

                nSepPos = _rStringRep.indexOf( ':', nPrevSepPos = nSepPos + 1 );
                aUnoDateTime.Minutes = (sal_Int16)_rStringRep.copy( nPrevSepPos, nSepPos - nPrevSepPos ).toInt32();

                nSepPos = _rStringRep.indexOf( ':', nPrevSepPos = nSepPos + 1 );
                aUnoDateTime.Seconds = (sal_Int16)_rStringRep.copy( nPrevSepPos, nSepPos - nPrevSepPos ).toInt32();

                aUnoDateTime.Seconds = (sal_Int16)_rStringRep.copy( nSepPos + 1 ).toInt32();

                _rValue <<= aUnoDateTime;
            }
            else
                bCanConvert = false;
            break;

        default:
            bCanConvert = false;
            break;
        }

        return bCanConvert;
    }

    //--------------------------------------------------------------------
    Any StringRepresentation::getPropertyValueFromStringRep( const ::rtl::OUString& _rStringRep, const Type& _rTargetType,
            sal_Int32 _nPropertyId, const IPropertyInfoService* _pMetaData )
    {
        Any aReturn;

        // enum properties
        if ( _pMetaData )
        {
            sal_uInt32  nPropertyUIFlags = _pMetaData->getPropertyUIFlags( _nPropertyId );
            if ( ( nPropertyUIFlags & PROP_FLAG_ENUM ) != 0 )
            {
                ::std::vector< String > aEnumStrings = _pMetaData->getPropertyEnumRepresentations( _nPropertyId );
                sal_Int32 nPos = getStringPos( _rStringRep, aEnumStrings );
                if ( -1 != nPos )
                {
                    if ( ( nPropertyUIFlags & PROP_FLAG_ENUM_ONE ) == PROP_FLAG_ENUM_ONE )
                        // enum value starting with 1
                        ++nPos;

                    switch ( _rTargetType.getTypeClass() )
                    {
                        case TypeClass_ENUM:
                            aReturn = ::cppu::int2enum( nPos, _rTargetType );
                            break;

                        case TypeClass_SHORT:
                            aReturn <<= (sal_Int16)nPos;
                            break;

                        case TypeClass_UNSIGNED_SHORT:
                            aReturn <<= (sal_uInt16)nPos;
                            break;

                        case TypeClass_UNSIGNED_LONG:
                            aReturn <<= (sal_uInt32)nPos;
                            break;

                        default:
                            aReturn <<= (sal_Int32)nPos;
                            break;
                    }
                }
                else
                    DBG_ERROR("OPropertyBrowserController::getPropertyValueFromStringRep: could not translate the enum string!");

                return aReturn;
            }
        }

        TypeClass ePropertyType = _rTargetType.getTypeClass();
        switch ( ePropertyType )
        {
        case TypeClass_FLOAT:
        case TypeClass_DOUBLE:
        case TypeClass_BYTE:
        case TypeClass_SHORT:
        case TypeClass_LONG:
        case TypeClass_HYPER:
        case TypeClass_UNSIGNED_SHORT:
        case TypeClass_UNSIGNED_LONG:
        case TypeClass_UNSIGNED_HYPER:
            try
            {
                if ( m_xTypeConverter.is() )
                    aReturn = m_xTypeConverter->convertToSimpleType( makeAny( _rStringRep ), ePropertyType );
            }
            catch( const CannotConvertException& ) { }
            catch( const IllegalArgumentException& ) { }
            break;

        default:
        #if OSL_DEBUG_LEVEL > 0
            bool bCanConvert =
        #endif
            convertStringToGenericValue( _rStringRep, aReturn, _rTargetType );

        #if OSL_DEBUG_LEVEL > 0
            // could not convert ...
            if ( !bCanConvert && _rStringRep.getLength() )
            {
                ::rtl::OString sMessage( "StringRepresentation::getPropertyValueFromStringRep: cannot convert into values of type '" );
                sMessage += ::rtl::OString( _rTargetType.getTypeName().getStr(), _rTargetType.getTypeName().getLength(), RTL_TEXTENCODING_ASCII_US );
                sMessage += ::rtl::OString( "'!" );
                DBG_ERROR( sMessage.getStr() );
            }
        #endif
        }

        return aReturn;
    }

//........................................................................
}   // namespace pcr
//........................................................................