summaryrefslogtreecommitdiff
path: root/sfx2/inc/sfx2/controlwrapper.hxx
blob: ac772d3940caec15f2ea02178765e05c8800d009 (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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef SFX_CONTROLWRAPPER_HXX
#define SFX_CONTROLWRAPPER_HXX

#include <tools/debug.hxx>
#include "sal/config.h"
#include "sfx2/dllapi.h"

#include <memory>

#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <vcl/field.hxx>
#include <vcl/lstbox.hxx>
#include <svtools/valueset.hxx>
#include <svtools/ctrlbox.hxx>

// ============================================================================

namespace sfx {

// ============================================================================

/** List position type of VCL ListBox. */
typedef USHORT ListBoxPosType;
/** List position type of SVTOOLS ValueSet. */
typedef USHORT ValueSetPosType;

// ============================================================================
// Helpers
// ============================================================================

/** A helper class for mapping list positions from/to represented values.

    Deriving from this helper class adds the two functions GetValueFromPos()
    and GetPosFromValue(). The constructor receives an array of MapEntryType
    structures that represents the table of positions and values. It is
    possible to pass a null pointer, this results in a direct mapping between
    list positions and values. If the map exists, it MUST be terminated with an
    entry containing the special "not found" list position passed to the
    constructor. The value contained in this last entry is used as default
    value in case of an error.
 */
template< typename PosT, typename ValueT >
class PosValueMapper
{
public:
    typedef PosT                            PosType;
    typedef ValueT                          ValueType;
    typedef PosValueMapper< PosT, ValueT >  MapperType;

    /** A helper struct that contains a list position - value pair. */
    struct MapEntryType
    {
        PosT                mnPos;      /// Position in the list.
        ValueT              mnValue;    /// Corresponding value.
    };

    /** Constructs the map helper with the passed map.
        @param nNFPos  This list position is used to represent the
        "not found" or "not existing" state.
        @param pMap  The map of list positions/values. If 0, a direct mapping
        is used (simply casting between list position and values). If the map
        exists, it *MUST* be terminated by an entry containing the special
        "not found" list position. */
    inline explicit     PosValueMapper( PosT nNFPos, const MapEntryType* pMap = 0 ) :
                            mpMap( pMap ), mnNFPos( nNFPos ) {}

    /** Returns the value at the specified list position.
        @return  The found value, or the value of the last map entry on error. */
    ValueT              GetValueFromPos( PosT nPos ) const;
    /** Returns the list position of the specified value.
        @return  The position, or the special "not found" position on error. */
    PosT                GetPosFromValue( ValueT nValue ) const;

    /** Returns the special "not found" list position. */
    inline PosT         GetNotFoundPos() const { return mnNFPos; }

private:
    const MapEntryType* mpMap;      /// The list position/value map.
    PosT                mnNFPos;    /// Special "not found" list position.
};

// ============================================================================
// Base control wrapper classes
// ============================================================================

/** Base class for all control wrappers.

    Control wrappers are used to have an equal interface for various functions
    used in connections for different types of controls.

    The current tree of base classes/templates and standard control wrappers:

    ControlWrapperBase
     |
     +- SingleControlWrapper< ControlT, ValueT >
     |   |
     |   +- DummyWindowWrapper   [1]
     |   +- CheckBoxWrapper   [1]
     |   +- EditWrapper   [1]
     |   +- ColorListBoxWrapper   [1]
     |   |
     |   +- NumericFieldWrapper< ValueT >   [1]
     |   |   |
     |   |   +- [ValueType]NumericFieldWrapper   [1] [2]
     |   |
     |   +- MetricFieldWrapper< ValueT >   [1]
     |   |   |
     |   |   +- [ValueType]MetricFieldWrapper   [1] [2]
     |   |
     |   +- ListBoxWrapper< ValueT >   [1]
     |   |   |
     |   |   +- [ValueType]ListBoxWrapper   [1] [2]
     |   |
     |   +- ValueSetWrapper< ValueT >   [1]
     |       |
     |       +- [ValueType]ValueSetWrapper   [1] [2]
     |
     +- MultiControlWrapperHelper
         |
         +- MultiControlWrapper< ValueT >

    Notes:
    [1] Standard wrappers ready to use.
    [2] [ValueType] is one of Int16, UInt16, Int32, UInt32, UShort, ULong.

    See documentation of class ItemConnectionBase (itemconnect.hxx) for more
    details.
 */
class SFX2_DLLPUBLIC ControlWrapperBase
{
public:
    inline explicit     ControlWrapperBase() {}
    virtual             ~ControlWrapperBase();

    /** Derived classes enable, disable, show, or hide control(s).
        @descr  Will do nothing, if the corresponding parameter is STATE_DONTKNOW. */
    virtual void        ModifyControl( TriState eEnable, TriState eShow ) = 0;

    /** Derived classes return true if the control is in "don't know" state. */
    virtual bool        IsControlDontKnow() const = 0;
    /** Derived classes set the control to "don't know" state. */
    virtual void        SetControlDontKnow( bool bSet ) = 0;

private:
    /* Disable copy c'tor and assignment. */
                        ControlWrapperBase( const ControlWrapperBase& );
    ControlWrapperBase& operator=( const ControlWrapperBase& );
};

// ============================================================================
// Single control wrappers
// ============================================================================

/** Base class template for control wrappers containing one single control.

    Classes created from this template store the reference to a single control
    object. It is not required that the control is derived from VCL's Window
    class. Derived classes have to implement the abstract functions
    ShowControl(), EnableControl(), IsControlDontKnow(), SetControlDontKnow(),
    GetControlValue(), and SetControlValue().

    As already stated, it is not required for ControlT to be a VCL Window.
    Anyway, ControlT must support the following functions:
    - void ControlT::Enable( bool )
    - void ControlT::Show( bool )
 */
template< typename ControlT, typename ValueT >
class SingleControlWrapper : public ControlWrapperBase
{
public:
    typedef ControlT                                 ControlType;
    typedef ValueT                                   ControlValueType;
    typedef SingleControlWrapper< ControlT, ValueT > SingleControlWrapperType;

    inline explicit     SingleControlWrapper( ControlT& rControl ) : mrControl( rControl ) {}

    /** Returns a reference to the control this connection works on. */
    inline const ControlT& GetControl() const { return mrControl; }
    /** Returns a reference to the control this connection works on. */
    inline ControlT&    GetControl() { return mrControl; }

    /** Enables, disables, shows, or hides the control.
        @descr  Does nothing, if the corresponding parameter is STATE_DONTKNOW. */
    virtual void        ModifyControl( TriState eEnable, TriState eShow );

    /** Derived classes return the value the control contains. */
    virtual ValueT      GetControlValue() const = 0;
    /** Derived classes set the contents of the control to the passed value. */
    virtual void        SetControlValue( ValueT aValue ) = 0;

private:
    ControlT&           mrControl;  /// The control of this wrapper.
};

// ============================================================================

/** A dummy wrapper for a VCL Window that does nothing special.

    This wrapper is used to implement the DummyItemConnection. It does not
    connect an item to a control, but handles the special flags to disable or
    hide a control, if an item is unknown.
 */
class SFX2_DLLPUBLIC DummyWindowWrapper:
    public SingleControlWrapper< Window, void* >
{
public:
    explicit            DummyWindowWrapper( Window& rWindow );

    virtual bool        IsControlDontKnow() const;
    virtual void        SetControlDontKnow( bool );

    virtual void*       GetControlValue() const;
    virtual void        SetControlValue( void* );
};

// ----------------------------------------------------------------------------

/** A wrapper for the VCL CheckBox. */
class SFX2_DLLPUBLIC CheckBoxWrapper:
    public SingleControlWrapper< CheckBox, BOOL >
{
public:
    explicit            CheckBoxWrapper( CheckBox& rCheckBox );

    virtual bool        IsControlDontKnow() const;
    virtual void        SetControlDontKnow( bool bSet );

    virtual BOOL        GetControlValue() const;
    virtual void        SetControlValue( BOOL bValue );
};

// ----------------------------------------------------------------------------

/** A wrapper for the VCL Edit. */
class EditWrapper : public SingleControlWrapper< Edit, String >
{
    /*  Note: cannot use 'const String&' as template argument, because VCL's
        Edit control returns the string by value and not by reference,
        therefore GetControlValue() must return a temporary object too. */
public:
    explicit            EditWrapper( Edit& rEdit );

    virtual bool        IsControlDontKnow() const;
    virtual void        SetControlDontKnow( bool bSet );

    virtual String      GetControlValue() const;
    virtual void        SetControlValue( String aValue );
};

// ----------------------------------------------------------------------------

/** A wrapper for the SVTOOLS ColorListBox. */
class SFX2_DLLPUBLIC ColorListBoxWrapper:
    public SingleControlWrapper< ColorListBox, Color >
{
    /*  Note: cannot use 'const Color&' as template argument, because the
        SVTOOLS ColorListBox returns the color by value and not by reference,
        therefore GetControlValue() must return a temporary object too. */
public:
    explicit ColorListBoxWrapper(ColorListBox & rListBox);

    virtual ~ColorListBoxWrapper();

    virtual bool        IsControlDontKnow() const;
    virtual void        SetControlDontKnow( bool bSet );

    virtual Color       GetControlValue() const;
    virtual void        SetControlValue( Color aColor );
};

// ============================================================================

/** A wrapper for the VCL NumericField. */
template< typename ValueT >
class NumericFieldWrapper : public SingleControlWrapper< NumericField, ValueT >
{
public:
    inline explicit     NumericFieldWrapper( NumericField& rField ) :
                            SingleControlWrapper< NumericField, ValueT >( rField ) {}

    virtual bool        IsControlDontKnow() const;
    virtual void        SetControlDontKnow( bool bSet );

    virtual ValueT      GetControlValue() const;
    virtual void        SetControlValue( ValueT nValue );
};

// ----------------------------------------------------------------------------

typedef NumericFieldWrapper< INT16 >  Int16NumericFieldWrapper;
typedef NumericFieldWrapper< UINT16 > UInt16NumericFieldWrapper;
typedef NumericFieldWrapper< INT32 >  Int32NumericFieldWrapper;
typedef NumericFieldWrapper< UINT32 > UInt32NumericFieldWrapper;

typedef NumericFieldWrapper< USHORT > UShortNumericFieldWrapper;
typedef NumericFieldWrapper< ULONG >  ULongNumericFieldWrapper;

// ============================================================================

/** A wrapper for the VCL MetricField.

    Adds support for field units during accessing the control value. The
    wrapper respects the field unit set at the control itself and converts it
    from/to the field unit passed to the constructor.
 */
template< typename ValueT >
class MetricFieldWrapper : public SingleControlWrapper< MetricField, ValueT >
{
public:
    inline explicit     MetricFieldWrapper( MetricField& rField, FieldUnit eUnit = FUNIT_NONE ) :
                            SingleControlWrapper< MetricField, ValueT >( rField ), meUnit( eUnit ) {}

    virtual bool        IsControlDontKnow() const;
    virtual void        SetControlDontKnow( bool bSet );

    virtual ValueT      GetControlValue() const;
    virtual void        SetControlValue( ValueT nValue );

private:
    FieldUnit           meUnit;
};

// ----------------------------------------------------------------------------

typedef MetricFieldWrapper< INT16 >  Int16MetricFieldWrapper;
typedef MetricFieldWrapper< UINT16 > UInt16MetricFieldWrapper;
typedef MetricFieldWrapper< INT32 >  Int32MetricFieldWrapper;
typedef MetricFieldWrapper< UINT32 > UInt32MetricFieldWrapper;

typedef MetricFieldWrapper< USHORT > UShortMetricFieldWrapper;
typedef MetricFieldWrapper< ULONG >  ULongMetricFieldWrapper;

// ============================================================================

/** A wrapper for the VCL ListBox.

    If a position<->value map is passed to the constructor, it MUST be
    terminated with an entry containing LISTBOX_ENTRY_NOTFOUND as list
    position. See documentation of the PosValueMapper template for details.
 */
template< typename ValueT >
class ListBoxWrapper :
        public SingleControlWrapper< ListBox, ValueT >,
        public PosValueMapper< ListBoxPosType, ValueT >
{
    typedef PosValueMapper< ListBoxPosType, ValueT > MapperType;

public:
    typedef typename MapperType::MapEntryType MapEntryType;

    /** @param pMap  Optional list position <-> value map.
        See PosValueMapper documentation for details. */
    inline explicit     ListBoxWrapper( ListBox& rListBox, const MapEntryType* pMap = 0 ) :
                            SingleControlWrapper< ListBox, ValueT >( rListBox ), MapperType( LISTBOX_ENTRY_NOTFOUND, pMap ) {}

    virtual bool        IsControlDontKnow() const
                            { return this->GetControl().GetSelectEntryCount() == 0; }
    virtual void        SetControlDontKnow( bool bSet )
                            { if( bSet ) this->GetControl().SetNoSelection(); }

    virtual ValueT      GetControlValue() const;
    virtual void        SetControlValue( ValueT nValue );
};

// ----------------------------------------------------------------------------

typedef ListBoxWrapper< INT16 >  Int16ListBoxWrapper;
typedef ListBoxWrapper< UINT16 > UInt16ListBoxWrapper;
typedef ListBoxWrapper< INT32 >  Int32ListBoxWrapper;
typedef ListBoxWrapper< UINT32 > UInt32ListBoxWrapper;

typedef ListBoxWrapper< USHORT > UShortListBoxWrapper;
typedef ListBoxWrapper< ULONG >  ULongListBoxWrapper;

// ============================================================================

/** A wrapper for the SVTOOLS ValueSet.

    If a position<->value map is passed to the constructor, it MUST be
    terminated with an entry containing VALUESET_ITEM_NOTFOUND as list
    position. See documentation of the PosValueMapper template for details.
 */
template< typename ValueT >
class ValueSetWrapper :
        public SingleControlWrapper< ValueSet, ValueT >,
        public PosValueMapper< ValueSetPosType, ValueT >
{
    typedef PosValueMapper< ValueSetPosType, ValueT > MapperType;

public:
    typedef typename MapperType::MapEntryType MapEntryType;

    /** @param pMap  Optional position <-> value map.
        See PosValueMapper documentation for details. */
    inline explicit     ValueSetWrapper( ValueSet& rValueSet, const MapEntryType* pMap = 0 ) :
                            SingleControlWrapper< ValueSet, ValueT >( rValueSet ), MapperType( VALUESET_ITEM_NOTFOUND, pMap ) {}

    virtual bool        IsControlDontKnow() const
                            { return this->GetControl().IsNoSelection(); }
    virtual void        SetControlDontKnow( bool bSet )
                            { if( bSet ) this->GetControl().SetNoSelection(); }

    virtual ValueT      GetControlValue() const;
    virtual void        SetControlValue( ValueT nValue );
};

// ----------------------------------------------------------------------------

typedef ValueSetWrapper< INT16 >  Int16ValueSetWrapper;
typedef ValueSetWrapper< UINT16 > UInt16ValueSetWrapper;
typedef ValueSetWrapper< INT32 >  Int32ValueSetWrapper;
typedef ValueSetWrapper< UINT32 > UInt32ValueSetWrapper;

typedef ValueSetWrapper< USHORT > UShortValueSetWrapper;
typedef ValueSetWrapper< ULONG >  ULongValueSetWrapper;

// ============================================================================
// Multi control wrappers
// ============================================================================

struct MultiControlWrapperHelper_Impl;

/** A container of control wrappers.

    Derived classes should define control wrapper members and register them in
    their constructor, using the function RegisterControlWrapper().

    This wrapper implements the abstract functions of the ControlWrapperBase
    base class by calling the functions of all registered wrappers.
 */
class SFX2_DLLPUBLIC MultiControlWrapperHelper : public ControlWrapperBase
{
public:
    explicit            MultiControlWrapperHelper();
    virtual             ~MultiControlWrapperHelper();

    /** Registers a control wrapper (should be a member of a derived class). */
    void                RegisterControlWrapper( ControlWrapperBase& rWrapper );

    /** Enables, disables, shows, or hides the registered controls. */
    virtual void        ModifyControl( TriState eEnable, TriState eShow );

    /** Returns true if all registered controls are in "don't know" state. */
    virtual bool        IsControlDontKnow() const;
    /** Sets all registered controls to "don't know" state. */
    virtual void        SetControlDontKnow( bool bSet );

private:
    std::auto_ptr< MultiControlWrapperHelper_Impl > mxImpl;
};

// ----------------------------------------------------------------------------

/** A multi control wrapper with extended interface.

    This template class extends the MultiControlWrapperHelper class by the
    functions GetControlValue() and SetControlValue(), known from the
    SingleControlWrapper template. This makes it possible to use this template
    in item connections expecting a single control wrapper. The type ValueT
    should be able to contain the values of all controls handled in this
    wrapper. In most cases, the easiest way to achieve this is to use the
    related item type directly, using the IdentItemWrapper template
    (itemwrapper.hxx).
 */
template< typename ValueT >
class MultiControlWrapper : public MultiControlWrapperHelper
{
public:
    typedef MultiControlWrapperHelper       ControlType;
    typedef ValueT                          ControlValueType;
    typedef MultiControlWrapper< ValueT >   MultiControlWrapperType;

    MultiControlWrapper() : maDefValue( 0 ){}

    /** Returns the default value that can be used in GetControlValue(). */
    inline const ValueT& GetDefaultValue() const { return maDefValue; }
    /** Sets a default value that can be used in GetControlValue(). */
    inline void         SetDefaultValue( const ValueT& rDefValue ) { maDefValue = rDefValue; }

    /** Derived classes return the value the control contains. */
    virtual ValueT      GetControlValue() const = 0;
    /** Derived classes set the contents of the control to the passed value. */
    virtual void        SetControlValue( ValueT aValue ) = 0;

private:
    ValueT              maDefValue;
};

// ============================================================================


// ============================================================================
//               ***  Implementation of template functions  ***
// ============================================================================

// ============================================================================
// Helpers
// ============================================================================

template< typename PosT, typename ValueT >
ValueT PosValueMapper< PosT, ValueT >::GetValueFromPos( PosT nPos ) const
{
    ValueT nValue;
    if( mpMap )
    {
        const MapEntryType* pEntry = mpMap;
        while( (pEntry->mnPos != nPos) && (pEntry->mnPos != mnNFPos) )
            ++pEntry;
        nValue = pEntry->mnValue;
    }
    else /* if( nPos != mnNFPos ) */
    {
        DBG_ASSERT( nPos != mnNFPos, "sfx2::PosValueMapper< PosT, ValueT >::GetValueFromPos(), previously uninitialized value found!" );
        nValue = static_cast< ValueT >( nPos );
    }

    return nValue;
}

template< typename PosT, typename ValueT >
PosT PosValueMapper< PosT, ValueT >::GetPosFromValue( ValueT nValue ) const
{
    PosT nPos = mnNFPos;
    if( mpMap )
    {
        const MapEntryType* pEntry = mpMap;
        while( (pEntry->mnValue != nValue) && (pEntry->mnPos != mnNFPos) )
            ++pEntry;
        nPos = pEntry->mnPos;
    }
    else if( nValue >= 0 )
        nPos = static_cast< PosT >( nValue );
    return nPos;
}

// ============================================================================
// Single control wrappers
// ============================================================================

template< typename ControlT, typename ValueT >
inline void SingleControlWrapper< ControlT, ValueT >::ModifyControl( TriState eEnable, TriState eShow )
{
    if( eEnable != STATE_DONTKNOW )
        mrControl.Enable( eEnable == STATE_CHECK );
    if( eShow != STATE_DONTKNOW )
        mrControl.Show( eShow == STATE_CHECK );
}

// ============================================================================

template< typename ValueT >
bool NumericFieldWrapper< ValueT >::IsControlDontKnow() const
{
    return this->GetControl().GetText().Len() == 0;
}

template< typename ValueT >
void NumericFieldWrapper< ValueT >::SetControlDontKnow( bool bSet )
{
    if( bSet )
        this->GetControl().SetText( String() );
}

template< typename ValueT >
ValueT NumericFieldWrapper< ValueT >::GetControlValue() const
{
    return static_cast< ValueT >( this->GetControl().Denormalize( this->GetControl().GetValue() ) );
}

template< typename ValueT >
void NumericFieldWrapper< ValueT >::SetControlValue( ValueT nValue )
{
    this->GetControl().SetValue( this->GetControl().Normalize( static_cast< sal_Int64 >( nValue ) ) );
}

// ============================================================================

template< typename ValueT >
bool MetricFieldWrapper< ValueT >::IsControlDontKnow() const
{
    return this->GetControl().GetText().Len() == 0;
}

template< typename ValueT >
void MetricFieldWrapper< ValueT >::SetControlDontKnow( bool bSet )
{
    if( bSet )
        this->GetControl().SetText( String() );
}

template< typename ValueT >
ValueT MetricFieldWrapper< ValueT >::GetControlValue() const
{
    return static_cast< ValueT >( this->GetControl().Denormalize( this->GetControl().GetValue( meUnit ) ) );
}

template< typename ValueT >
void MetricFieldWrapper< ValueT >::SetControlValue( ValueT nValue )
{
    this->GetControl().SetValue( this->GetControl().Normalize( static_cast< sal_Int64 >( nValue ) ), meUnit );
}

// ============================================================================

template< typename ValueT >
ValueT ListBoxWrapper< ValueT >::GetControlValue() const
{
    return GetValueFromPos( this->GetControl().GetSelectEntryPos() );
}

template< typename ValueT >
void ListBoxWrapper< ValueT >::SetControlValue( ValueT nValue )
{
    USHORT nPos = GetPosFromValue( nValue );
    if( nPos != this->GetNotFoundPos() )
        this->GetControl().SelectEntryPos( nPos );
}

// ----------------------------------------------------------------------------

template< typename ValueT >
ValueT ValueSetWrapper< ValueT >::GetControlValue() const
{
    return GetValueFromPos( this->GetControl().GetSelectItemId() );
}

template< typename ValueT >
void ValueSetWrapper< ValueT >::SetControlValue( ValueT nValue )
{
    USHORT nPos = GetPosFromValue( nValue );
    if( nPos != this->GetNotFoundPos() )
        this->GetControl().SelectItem( nPos );
}

// ============================================================================


} // namespace sfx

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */