merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / source / inc / sfxpicklist.hxx
blob5097112f6af35b5239280661bb41a55f36065e0c
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: sfxpicklist.hxx,v $
10 * $Revision: 1.6 $
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 #ifndef _SFX_PICKLIST_HXX_
32 #define _SFX_PICKLIST_HXX_
34 #include <osl/mutex.hxx>
35 #include <tools/string.hxx>
36 #include <vcl/menu.hxx>
37 #include <svtools/lstner.hxx>
38 #include <com/sun/star/util/XStringWidth.hpp>
40 #include <vector>
42 #define PICKLIST_MAXSIZE 100
44 class SfxPickList : public SfxListener
46 struct PickListEntry
48 PickListEntry( const String& _aName, const String& _aFilter, const String& _aTitle ) :
49 aName( _aName ), aFilter( _aFilter ), aTitle( _aTitle ) {}
51 String aName;
52 String aFilter;
53 String aTitle;
54 String aOptions;
57 static SfxPickList* pUniqueInstance;
58 static osl::Mutex* pMutex;
60 std::vector< PickListEntry* > m_aPicklistVector;
61 sal_uInt32 m_nAllowedMenuSize;
62 ::com::sun::star::uno::Reference< ::com::sun::star::util::XStringWidth > m_xStringLength;
64 SfxPickList( sal_uInt32 nMenuSize );
65 ~SfxPickList();
67 static osl::Mutex* GetOrCreateMutex();
69 void CreatePicklistMenuTitle( Menu* pMenu, USHORT nItemId, const String& aURL, sal_uInt32 nNo );
70 PickListEntry* GetPickListEntry( sal_uInt32 nIndex );
71 void CreatePickListEntries();
72 void RemovePickListEntries();
74 public:
75 static SfxPickList* GetOrCreate( const sal_uInt32 nMenuSize );
76 static SfxPickList* Get();
77 static void Delete();
79 sal_uInt32 GetAllowedMenuSize() { return m_nAllowedMenuSize; }
80 sal_uInt32 GetNumOfEntries() const { return m_aPicklistVector.size(); }
81 void CreateMenuEntries( Menu* pMenu );
82 void ExecuteMenuEntry( USHORT nId );
83 void ExecuteEntry( sal_uInt32 nIndex );
84 String GetMenuEntryTitle( sal_uInt32 nIndex );
86 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
89 #endif // _SFX_PICKLIST_HXX_