1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SFX_PICKLIST_HXX_ 29 #define _SFX_PICKLIST_HXX_ 30 31 #include <osl/mutex.hxx> 32 #include <tools/string.hxx> 33 #include <vcl/menu.hxx> 34 #include <svl/lstner.hxx> 35 #include <com/sun/star/util/XStringWidth.hpp> 36 37 #include <vector> 38 39 #define PICKLIST_MAXSIZE 100 40 41 class SfxPickList : public SfxListener 42 { 43 struct PickListEntry 44 { 45 PickListEntry( const String& _aName, const String& _aFilter, const String& _aTitle ) : 46 aName( _aName ), aFilter( _aFilter ), aTitle( _aTitle ) {} 47 48 String aName; 49 String aFilter; 50 String aTitle; 51 String aOptions; 52 }; 53 54 static SfxPickList* pUniqueInstance; 55 static osl::Mutex* pMutex; 56 57 std::vector< PickListEntry* > m_aPicklistVector; 58 sal_uInt32 m_nAllowedMenuSize; 59 ::com::sun::star::uno::Reference< ::com::sun::star::util::XStringWidth > m_xStringLength; 60 61 SfxPickList( sal_uInt32 nMenuSize ); 62 ~SfxPickList(); 63 64 static osl::Mutex* GetOrCreateMutex(); 65 66 void CreatePicklistMenuTitle( Menu* pMenu, sal_uInt16 nItemId, const String& aURL, sal_uInt32 nNo ); 67 PickListEntry* GetPickListEntry( sal_uInt32 nIndex ); 68 void CreatePickListEntries(); 69 void RemovePickListEntries(); 70 71 public: 72 static SfxPickList* GetOrCreate( const sal_uInt32 nMenuSize ); 73 static SfxPickList* Get(); 74 static void Delete(); 75 76 sal_uInt32 GetAllowedMenuSize() { return m_nAllowedMenuSize; } 77 sal_uInt32 GetNumOfEntries() const { return m_aPicklistVector.size(); } 78 void CreateMenuEntries( Menu* pMenu ); 79 void ExecuteMenuEntry( sal_uInt16 nId ); 80 void ExecuteEntry( sal_uInt32 nIndex ); 81 String GetMenuEntryTitle( sal_uInt32 nIndex ); 82 83 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 84 }; 85 86 #endif // _SFX_PICKLIST_HXX_ 87