Update ooo320-m1
[ooovba.git] / svx / source / dialog / frmdirlbox.cxx
blob69d5149758ed06ec40976e7cc0c2c7e3b9aa0b77
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmdirlbox.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/frmdirlbox.hxx>
35 namespace svx {
37 // ============================================================================
39 namespace {
41 inline void* lclEnumToVoid( SvxFrameDirection eDirection )
43 return reinterpret_cast< void* >( static_cast< sal_uInt32 >( eDirection ) );
46 inline SvxFrameDirection lclVoidToEnum( void* pDirection )
48 return static_cast< SvxFrameDirection >( reinterpret_cast< sal_IntPtr >( pDirection ) );
51 } // namespace
53 // ============================================================================
55 FrameDirectionListBox::FrameDirectionListBox( Window* pParent, WinBits nStyle ) :
56 ListBox( pParent, nStyle )
60 FrameDirectionListBox::FrameDirectionListBox( Window* pParent, const ResId& rResId ) :
61 ListBox( pParent, rResId )
65 FrameDirectionListBox::~FrameDirectionListBox()
69 void FrameDirectionListBox::InsertEntryValue( const String& rString, SvxFrameDirection eDirection, sal_uInt16 nPos )
71 sal_uInt16 nRealPos = InsertEntry( rString, nPos );
72 SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
75 void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
77 sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
78 if( nPos != LISTBOX_ENTRY_NOTFOUND )
79 RemoveEntry( nPos );
82 void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
84 sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
85 if( nPos == LISTBOX_ENTRY_NOTFOUND )
86 SetNoSelection();
87 else
88 SelectEntryPos( nPos );
91 SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
93 sal_uInt16 nPos = GetSelectEntryPos();
94 if( nPos == LISTBOX_ENTRY_NOTFOUND )
95 return static_cast< SvxFrameDirection >( 0xFFFF );
96 return lclVoidToEnum( GetEntryData( nPos ) );
99 // ============================================================================
101 FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
102 SingleControlWrapperType( rListBox )
106 bool FrameDirListBoxWrapper::IsControlDontKnow() const
108 return GetControl().GetSelectEntryCount() == 0;
111 void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
113 if( bSet )
114 GetControl().SetNoSelection();
117 SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
119 return GetControl().GetSelectEntryValue();
122 void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
124 GetControl().SelectEntryValue( eValue );
127 // ============================================================================
129 } // namespace svx