Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svx/frmdirlbox.hxx>
30 : :
31 : : namespace svx {
32 : :
33 : : // ============================================================================
34 : :
35 : : namespace {
36 : :
37 : 0 : inline void* lclEnumToVoid( SvxFrameDirection eDirection )
38 : : {
39 : 0 : return reinterpret_cast< void* >( static_cast< sal_uInt32 >( eDirection ) );
40 : : }
41 : :
42 : 0 : inline SvxFrameDirection lclVoidToEnum( void* pDirection )
43 : : {
44 : 0 : return static_cast< SvxFrameDirection >( reinterpret_cast< sal_IntPtr >( pDirection ) );
45 : : }
46 : :
47 : : } // namespace
48 : :
49 : : // ============================================================================
50 : :
51 : 0 : FrameDirectionListBox::FrameDirectionListBox( Window* pParent, const ResId& rResId ) :
52 : 0 : ListBox( pParent, rResId )
53 : : {
54 : 0 : }
55 : :
56 : 0 : FrameDirectionListBox::~FrameDirectionListBox()
57 : : {
58 [ # # ]: 0 : }
59 : :
60 : 0 : void FrameDirectionListBox::InsertEntryValue( const String& rString, SvxFrameDirection eDirection, sal_uInt16 nPos )
61 : : {
62 : 0 : sal_uInt16 nRealPos = InsertEntry( rString, nPos );
63 : 0 : SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
64 : 0 : }
65 : :
66 : 0 : void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
67 : : {
68 : 0 : sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
69 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
70 : 0 : RemoveEntry( nPos );
71 : 0 : }
72 : :
73 : 0 : void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
74 : : {
75 : 0 : sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
76 [ # # ]: 0 : if( nPos == LISTBOX_ENTRY_NOTFOUND )
77 : 0 : SetNoSelection();
78 : : else
79 : 0 : SelectEntryPos( nPos );
80 : 0 : }
81 : :
82 : 0 : SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
83 : : {
84 : 0 : sal_uInt16 nPos = GetSelectEntryPos();
85 [ # # ]: 0 : if( nPos == LISTBOX_ENTRY_NOTFOUND )
86 : 0 : return static_cast< SvxFrameDirection >( 0xFFFF );
87 : 0 : return lclVoidToEnum( GetEntryData( nPos ) );
88 : : }
89 : :
90 : : // ============================================================================
91 : :
92 : 0 : FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
93 : 0 : SingleControlWrapperType( rListBox )
94 : : {
95 : 0 : }
96 : :
97 : 0 : bool FrameDirListBoxWrapper::IsControlDontKnow() const
98 : : {
99 : 0 : return GetControl().GetSelectEntryCount() == 0;
100 : : }
101 : :
102 : 0 : void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
103 : : {
104 [ # # ]: 0 : if( bSet )
105 : 0 : GetControl().SetNoSelection();
106 : 0 : }
107 : :
108 : 0 : SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
109 : : {
110 : 0 : return GetControl().GetSelectEntryValue();
111 : : }
112 : :
113 : 0 : void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
114 : : {
115 : 0 : GetControl().SelectEntryValue( eValue );
116 : 0 : }
117 : :
118 : : // ============================================================================
119 : :
120 : : } // namespace svx
121 : :
122 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|