xref: /aoo41x/main/sfx2/source/inc/sfxpicklist.hxx (revision 353d8f4d)
1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*353d8f4dSAndrew Rist  * distributed with this work for additional information
6*353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*353d8f4dSAndrew Rist  *
11*353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist  *
13*353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist  * under the License.
19*353d8f4dSAndrew Rist  *
20*353d8f4dSAndrew Rist  *************************************************************/
21*353d8f4dSAndrew Rist 
22*353d8f4dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SFX_PICKLIST_HXX_
25cdf0e10cSrcweir #define _SFX_PICKLIST_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <osl/mutex.hxx>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir #include <vcl/menu.hxx>
30cdf0e10cSrcweir #include <svl/lstner.hxx>
31cdf0e10cSrcweir #include <com/sun/star/util/XStringWidth.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <vector>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #define PICKLIST_MAXSIZE  100
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class SfxPickList : public SfxListener
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	struct PickListEntry
40cdf0e10cSrcweir 	{
PickListEntrySfxPickList::PickListEntry41cdf0e10cSrcweir 		PickListEntry( const String& _aName, const String& _aFilter, const String& _aTitle ) :
42cdf0e10cSrcweir 			aName( _aName ), aFilter( _aFilter ), aTitle( _aTitle ) {}
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 		String		aName;
45cdf0e10cSrcweir 		String		aFilter;
46cdf0e10cSrcweir 		String		aTitle;
47cdf0e10cSrcweir 		String		aOptions;
48cdf0e10cSrcweir 	};
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 	static SfxPickList*				pUniqueInstance;
51cdf0e10cSrcweir 	static osl::Mutex*				pMutex;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	std::vector< PickListEntry* >	m_aPicklistVector;
54cdf0e10cSrcweir 	sal_uInt32						m_nAllowedMenuSize;
55cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::util::XStringWidth > m_xStringLength;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 							SfxPickList( sal_uInt32 nMenuSize );
58cdf0e10cSrcweir 							~SfxPickList();
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	static osl::Mutex*		GetOrCreateMutex();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	void					CreatePicklistMenuTitle( Menu* pMenu, sal_uInt16 nItemId, const String& aURL, sal_uInt32 nNo );
63cdf0e10cSrcweir 	PickListEntry*			GetPickListEntry( sal_uInt32 nIndex );
64cdf0e10cSrcweir 	void					CreatePickListEntries();
65cdf0e10cSrcweir 	void					RemovePickListEntries();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	public:
68cdf0e10cSrcweir 		static SfxPickList*	GetOrCreate( const sal_uInt32 nMenuSize );
69cdf0e10cSrcweir 		static SfxPickList*	Get();
70cdf0e10cSrcweir 		static void			Delete();
71cdf0e10cSrcweir 
GetAllowedMenuSize()72cdf0e10cSrcweir 		sal_uInt32			GetAllowedMenuSize() { return m_nAllowedMenuSize; }
GetNumOfEntries() const73cdf0e10cSrcweir 		sal_uInt32			GetNumOfEntries() const { return m_aPicklistVector.size(); }
74cdf0e10cSrcweir 		void				CreateMenuEntries( Menu* pMenu );
75cdf0e10cSrcweir 		void				ExecuteMenuEntry( sal_uInt16 nId );
76cdf0e10cSrcweir 		void				ExecuteEntry( sal_uInt32 nIndex );
77cdf0e10cSrcweir 		String				GetMenuEntryTitle( sal_uInt32 nIndex );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 		virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #endif // _SFX_PICKLIST_HXX_
83