xref: /AOO41X/main/svtools/source/config/menuoptions.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir #ifndef GCC
31*cdf0e10cSrcweir #endif
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir //	includes
35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
38*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
39*cdf0e10cSrcweir #include <unotools/configitem.hxx>
40*cdf0e10cSrcweir #include <tools/debug.hxx>
41*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
42*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
43*cdf0e10cSrcweir #include <vcl/svapp.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <rtl/logfile.hxx>
46*cdf0e10cSrcweir #include "itemholder2.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49*cdf0e10cSrcweir //	namespaces
50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir using namespace ::utl					;
53*cdf0e10cSrcweir using namespace ::rtl					;
54*cdf0e10cSrcweir using namespace ::osl					;
55*cdf0e10cSrcweir using namespace ::com::sun::star::uno	;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
58*cdf0e10cSrcweir //	const
59*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #define	ROOTNODE_MENU							OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View/Menu"	))
62*cdf0e10cSrcweir #define	DEFAULT_DONTHIDEDISABLEDENTRIES			sal_False
63*cdf0e10cSrcweir #define	DEFAULT_FOLLOWMOUSE						sal_True
64*cdf0e10cSrcweir #define	DEFAULT_MENUICONS						2
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #define	PROPERTYNAME_DONTHIDEDISABLEDENTRIES	OUString(RTL_CONSTASCII_USTRINGPARAM("DontHideDisabledEntry"	))
67*cdf0e10cSrcweir #define	PROPERTYNAME_FOLLOWMOUSE				OUString(RTL_CONSTASCII_USTRINGPARAM("FollowMouse"				))
68*cdf0e10cSrcweir #define PROPERTYNAME_SHOWICONSINMENUES          OUString(RTL_CONSTASCII_USTRINGPARAM("ShowIconsInMenues"        ))
69*cdf0e10cSrcweir #define PROPERTYNAME_SYSTEMICONSINMENUES        OUString(RTL_CONSTASCII_USTRINGPARAM("IsSystemIconsInMenus"     ))
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir #define	PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES	0
72*cdf0e10cSrcweir #define	PROPERTYHANDLE_FOLLOWMOUSE				1
73*cdf0e10cSrcweir #define PROPERTYHANDLE_SHOWICONSINMENUES        2
74*cdf0e10cSrcweir #define PROPERTYHANDLE_SYSTEMICONSINMENUES      3
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #define PROPERTYCOUNT                           4
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir #include <tools/link.hxx>
79*cdf0e10cSrcweir #include <tools/list.hxx>
80*cdf0e10cSrcweir DECLARE_LIST( LinkList, Link * )
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
83*cdf0e10cSrcweir //	private declarations!
84*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir class SvtMenuOptions_Impl : public ConfigItem
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
89*cdf0e10cSrcweir 	//	private member
90*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	private:
93*cdf0e10cSrcweir         LinkList    aList;
94*cdf0e10cSrcweir 		sal_Bool	m_bDontHideDisabledEntries			;	/// cache "DontHideDisabledEntries" of Menu section
95*cdf0e10cSrcweir 		sal_Bool	m_bFollowMouse						;	/// cache "FollowMouse" of Menu section
96*cdf0e10cSrcweir 		sal_Int16	m_nMenuIcons						;	/// cache "MenuIcons" of Menu section
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
99*cdf0e10cSrcweir 	//	public methods
100*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	public:
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
105*cdf0e10cSrcweir 		//	constructor / destructor
106*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 		 SvtMenuOptions_Impl();
109*cdf0e10cSrcweir 		~SvtMenuOptions_Impl();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir         void AddListenerLink( const Link& rLink );
112*cdf0e10cSrcweir         void RemoveListenerLink( const Link& rLink );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
115*cdf0e10cSrcweir 		//	overloaded methods of baseclass
116*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
119*cdf0e10cSrcweir 			@short		called for notify of configmanager
120*cdf0e10cSrcweir 			@descr		These method is called from the ConfigManager before application ends or from the
121*cdf0e10cSrcweir 			 			PropertyChangeListener if the sub tree broadcasts changes. You must update your
122*cdf0e10cSrcweir 						internal values.
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 			@param		"seqPropertyNames" is the list of properties which should be updated.
127*cdf0e10cSrcweir 			@return		-
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 			@onerror	-
130*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     	virtual void Notify( const Sequence< OUString >& seqPropertyNames );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
135*cdf0e10cSrcweir 			@short		write changes to configuration
136*cdf0e10cSrcweir 			@descr		These method writes the changed values into the sub tree
137*cdf0e10cSrcweir 						and should always called in our destructor to guarantee consistency of config data.
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 			@param		-
142*cdf0e10cSrcweir 			@return		-
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 			@onerror	-
145*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     	virtual void Commit();
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
150*cdf0e10cSrcweir 		//	public interface
151*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
154*cdf0e10cSrcweir 			@short		access method to get internal values
155*cdf0e10cSrcweir 			@descr		These method give us a chance to regulate acces to ouer internal values.
156*cdf0e10cSrcweir 						It's not used in the moment - but it's possible for the feature!
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 			@seealso	-
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 			@param		-
161*cdf0e10cSrcweir 			@return		-
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 			@onerror	-
164*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 		sal_Bool	IsEntryHidingEnabled() const
167*cdf0e10cSrcweir 					{ return m_bDontHideDisabledEntries; }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 		sal_Bool	IsFollowMouseEnabled() const
170*cdf0e10cSrcweir 					{ return m_bFollowMouse; }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 		sal_Int16	GetMenuIconsState() const
173*cdf0e10cSrcweir 					{ return m_nMenuIcons; }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 		void		SetEntryHidingState	( sal_Bool bState )
176*cdf0e10cSrcweir                     {
177*cdf0e10cSrcweir                         m_bDontHideDisabledEntries = bState;
178*cdf0e10cSrcweir                         SetModified();
179*cdf0e10cSrcweir                         for ( sal_uInt16 n=0; n<aList.Count(); n++ )
180*cdf0e10cSrcweir                             aList.GetObject(n)->Call( this );
181*cdf0e10cSrcweir 						Commit();
182*cdf0e10cSrcweir                     }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 		void		SetFollowMouseState	( sal_Bool bState )
185*cdf0e10cSrcweir                     {
186*cdf0e10cSrcweir                         m_bFollowMouse = bState;
187*cdf0e10cSrcweir                         SetModified();
188*cdf0e10cSrcweir                         for ( sal_uInt16 n=0; n<aList.Count(); n++ )
189*cdf0e10cSrcweir                             aList.GetObject(n)->Call( this );
190*cdf0e10cSrcweir 						Commit();
191*cdf0e10cSrcweir                     }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 		void		SetMenuIconsState ( sal_Int16 bState	)
194*cdf0e10cSrcweir                     {
195*cdf0e10cSrcweir                         m_nMenuIcons = bState;
196*cdf0e10cSrcweir                         SetModified();
197*cdf0e10cSrcweir                         for ( sal_uInt16 n=0; n<aList.Count(); n++ )
198*cdf0e10cSrcweir                             aList.GetObject(n)->Call( this );
199*cdf0e10cSrcweir 						Commit();
200*cdf0e10cSrcweir                     }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
203*cdf0e10cSrcweir 	//	private methods
204*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	private:
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
209*cdf0e10cSrcweir 			@short		return list of fix key names of ouer configuration management which represent oue module tree
210*cdf0e10cSrcweir 			@descr		These methods return a static const list of key names. We need it to get needed values from our
211*cdf0e10cSrcweir 						configuration management.
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 			@seealso	-
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 			@param		-
216*cdf0e10cSrcweir 			@return		A list of needed configuration keys is returned.
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 			@onerror	-
219*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 		static Sequence< OUString > impl_GetPropertyNames();
222*cdf0e10cSrcweir };
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
225*cdf0e10cSrcweir //	definitions
226*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir //*****************************************************************************************************************
229*cdf0e10cSrcweir //	constructor
230*cdf0e10cSrcweir //*****************************************************************************************************************
231*cdf0e10cSrcweir SvtMenuOptions_Impl::SvtMenuOptions_Impl()
232*cdf0e10cSrcweir 	// Init baseclasses first
233*cdf0e10cSrcweir     :	ConfigItem					( ROOTNODE_MENU						)
234*cdf0e10cSrcweir 	// Init member then.
235*cdf0e10cSrcweir 	,	m_bDontHideDisabledEntries	( DEFAULT_DONTHIDEDISABLEDENTRIES	)
236*cdf0e10cSrcweir 	,	m_bFollowMouse				( DEFAULT_FOLLOWMOUSE				)
237*cdf0e10cSrcweir 	,   m_nMenuIcons				( DEFAULT_MENUICONS 				)
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir 	// Use our static list of configuration keys to get his values.
240*cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= impl_GetPropertyNames();
241*cdf0e10cSrcweir 	Sequence< Any >			seqValues	= GetProperties( seqNames )	;
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	// Safe impossible cases.
244*cdf0e10cSrcweir 	// We need values from ALL configuration keys.
245*cdf0e10cSrcweir 	// Follow assignment use order of values in relation to our list of key names!
246*cdf0e10cSrcweir 	DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nI miss some values of configuration keys!\n" );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     sal_Bool bMenuIcons = true;
249*cdf0e10cSrcweir     sal_Bool bSystemMenuIcons = true;
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 	// Copy values from list in right order to ouer internal member.
252*cdf0e10cSrcweir 	sal_Int32 nPropertyCount	=	seqValues.getLength()	;
253*cdf0e10cSrcweir 	sal_Int32 nProperty			=	0						;
254*cdf0e10cSrcweir 	for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
255*cdf0e10cSrcweir 	{
256*cdf0e10cSrcweir 		// Safe impossible cases.
257*cdf0e10cSrcweir 		// Check any for valid value.
258*cdf0e10cSrcweir 		DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nInvalid property value for property detected!\n" );
259*cdf0e10cSrcweir         switch( nProperty )
260*cdf0e10cSrcweir         {
261*cdf0e10cSrcweir             case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES	:	{
262*cdf0e10cSrcweir 																DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
263*cdf0e10cSrcweir 																seqValues[nProperty] >>= m_bDontHideDisabledEntries;
264*cdf0e10cSrcweir 															}
265*cdf0e10cSrcweir 															break;
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir             case PROPERTYHANDLE_FOLLOWMOUSE				:	{
268*cdf0e10cSrcweir 																DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
269*cdf0e10cSrcweir 																seqValues[nProperty] >>= m_bFollowMouse;
270*cdf0e10cSrcweir 															}
271*cdf0e10cSrcweir 															break;
272*cdf0e10cSrcweir             case PROPERTYHANDLE_SHOWICONSINMENUES       :   {
273*cdf0e10cSrcweir                                                                 DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
274*cdf0e10cSrcweir                                                                 seqValues[nProperty] >>= bMenuIcons;
275*cdf0e10cSrcweir 															}
276*cdf0e10cSrcweir 															break;
277*cdf0e10cSrcweir             case PROPERTYHANDLE_SYSTEMICONSINMENUES		:   {
278*cdf0e10cSrcweir                                                                 DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" );
279*cdf0e10cSrcweir                                                                 seqValues[nProperty] >>= bSystemMenuIcons;
280*cdf0e10cSrcweir 															}
281*cdf0e10cSrcweir 															break;
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir 	}
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 	m_nMenuIcons = bSystemMenuIcons ? 2 : bMenuIcons;
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	EnableNotification( seqNames );
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir //*****************************************************************************************************************
291*cdf0e10cSrcweir //	destructor
292*cdf0e10cSrcweir //*****************************************************************************************************************
293*cdf0e10cSrcweir SvtMenuOptions_Impl::~SvtMenuOptions_Impl()
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir 	// Flush data to configuration!
296*cdf0e10cSrcweir 	// User has no chance to do that.
297*cdf0e10cSrcweir 	if( IsModified() == sal_True )
298*cdf0e10cSrcweir 	{
299*cdf0e10cSrcweir 		Commit();
300*cdf0e10cSrcweir 	}
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<aList.Count(); )
303*cdf0e10cSrcweir         delete aList.Remove(n);
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir //*****************************************************************************************************************
307*cdf0e10cSrcweir //	public method
308*cdf0e10cSrcweir //*****************************************************************************************************************
309*cdf0e10cSrcweir void SvtMenuOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir 	// Use given list of updated properties to get his values from configuration directly!
312*cdf0e10cSrcweir 	Sequence< Any > seqValues = GetProperties( seqPropertyNames );
313*cdf0e10cSrcweir 	// Safe impossible cases.
314*cdf0e10cSrcweir 	// We need values from ALL notified configuration keys.
315*cdf0e10cSrcweir 	DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 	sal_Bool bMenuSettingsChanged = sal_False;
318*cdf0e10cSrcweir     sal_Bool bMenuIcons = sal_True;
319*cdf0e10cSrcweir     sal_Bool bSystemMenuIcons = sal_True;
320*cdf0e10cSrcweir     if (m_nMenuIcons == 2)
321*cdf0e10cSrcweir         bMenuIcons = (sal_Bool)(Application::GetSettings().GetStyleSettings().GetUseImagesInMenus());
322*cdf0e10cSrcweir     else
323*cdf0e10cSrcweir     {
324*cdf0e10cSrcweir         bSystemMenuIcons = sal_False;
325*cdf0e10cSrcweir         bMenuIcons = m_nMenuIcons ? sal_True : sal_False;
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 	// Step over list of property names and get right value from coreesponding value list to set it on internal members!
329*cdf0e10cSrcweir 	sal_Int32 nCount = seqPropertyNames.getLength();
330*cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
331*cdf0e10cSrcweir 	{
332*cdf0e10cSrcweir 		if( seqPropertyNames[nProperty] == PROPERTYNAME_DONTHIDEDISABLEDENTRIES )
333*cdf0e10cSrcweir 		{
334*cdf0e10cSrcweir 			DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" );
335*cdf0e10cSrcweir 			seqValues[nProperty] >>= m_bDontHideDisabledEntries;
336*cdf0e10cSrcweir 		}
337*cdf0e10cSrcweir 		else if( seqPropertyNames[nProperty] == PROPERTYNAME_FOLLOWMOUSE )
338*cdf0e10cSrcweir 		{
339*cdf0e10cSrcweir 			DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" );
340*cdf0e10cSrcweir 			seqValues[nProperty] >>= m_bFollowMouse;
341*cdf0e10cSrcweir 		}
342*cdf0e10cSrcweir         else if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWICONSINMENUES )
343*cdf0e10cSrcweir 		{
344*cdf0e10cSrcweir             DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" );
345*cdf0e10cSrcweir             bMenuSettingsChanged = seqValues[nProperty] >>= bMenuIcons;
346*cdf0e10cSrcweir         }
347*cdf0e10cSrcweir         else if( seqPropertyNames[nProperty] == PROPERTYNAME_SYSTEMICONSINMENUES )
348*cdf0e10cSrcweir 		{
349*cdf0e10cSrcweir             DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" );
350*cdf0e10cSrcweir             bMenuSettingsChanged = seqValues[nProperty] >>= bSystemMenuIcons;
351*cdf0e10cSrcweir         }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 1
354*cdf0e10cSrcweir 		else DBG_ASSERT( sal_False, "SvtMenuOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
355*cdf0e10cSrcweir 		#endif
356*cdf0e10cSrcweir 	}
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 	if ( bMenuSettingsChanged )
359*cdf0e10cSrcweir 		m_nMenuIcons = bSystemMenuIcons ? 2 : bMenuIcons;
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<aList.Count(); n++ )
362*cdf0e10cSrcweir         aList.GetObject(n)->Call( this );
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir //*****************************************************************************************************************
366*cdf0e10cSrcweir //	public method
367*cdf0e10cSrcweir //*****************************************************************************************************************
368*cdf0e10cSrcweir void SvtMenuOptions_Impl::Commit()
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	// Get names of supported properties, create a list for values and copy current values to it.
371*cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= impl_GetPropertyNames();
372*cdf0e10cSrcweir 	sal_Int32				nCount		= seqNames.getLength();
373*cdf0e10cSrcweir 	Sequence< Any >			seqValues	( nCount );
374*cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
375*cdf0e10cSrcweir 	{
376*cdf0e10cSrcweir         switch( nProperty )
377*cdf0e10cSrcweir         {
378*cdf0e10cSrcweir             case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES	:	{
379*cdf0e10cSrcweir                 												seqValues[nProperty] <<= m_bDontHideDisabledEntries;
380*cdf0e10cSrcweir 															}
381*cdf0e10cSrcweir                 											break;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir             case PROPERTYHANDLE_FOLLOWMOUSE				:	{
384*cdf0e10cSrcweir                 												seqValues[nProperty] <<= m_bFollowMouse;
385*cdf0e10cSrcweir 															}
386*cdf0e10cSrcweir                 											break;
387*cdf0e10cSrcweir 			//Output cache of current setting as possibly modified by System Theme for older version
388*cdf0e10cSrcweir             case PROPERTYHANDLE_SHOWICONSINMENUES       :   {
389*cdf0e10cSrcweir                                                                 sal_Bool bValue = (sal_Bool)(Application::GetSettings().GetStyleSettings().GetUseImagesInMenus());
390*cdf0e10cSrcweir 																seqValues[nProperty] <<= bValue;
391*cdf0e10cSrcweir 															}
392*cdf0e10cSrcweir                 											break;
393*cdf0e10cSrcweir             case PROPERTYHANDLE_SYSTEMICONSINMENUES		:   {
394*cdf0e10cSrcweir 																sal_Bool bValue = (m_nMenuIcons == 2 ? sal_True : sal_False) ;
395*cdf0e10cSrcweir                                                                 seqValues[nProperty] <<= bValue;
396*cdf0e10cSrcweir 															}
397*cdf0e10cSrcweir                 											break;
398*cdf0e10cSrcweir         }
399*cdf0e10cSrcweir 	}
400*cdf0e10cSrcweir 	// Set properties in configuration.
401*cdf0e10cSrcweir 	PutProperties( seqNames, seqValues );
402*cdf0e10cSrcweir }
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir //*****************************************************************************************************************
405*cdf0e10cSrcweir //	private method
406*cdf0e10cSrcweir //*****************************************************************************************************************
407*cdf0e10cSrcweir Sequence< OUString > SvtMenuOptions_Impl::impl_GetPropertyNames()
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir 	// Build static list of configuration key names.
410*cdf0e10cSrcweir 	static const OUString pProperties[] =
411*cdf0e10cSrcweir 	{
412*cdf0e10cSrcweir 		PROPERTYNAME_DONTHIDEDISABLEDENTRIES	,
413*cdf0e10cSrcweir 		PROPERTYNAME_FOLLOWMOUSE				,
414*cdf0e10cSrcweir         PROPERTYNAME_SHOWICONSINMENUES			,
415*cdf0e10cSrcweir         PROPERTYNAME_SYSTEMICONSINMENUES
416*cdf0e10cSrcweir 	};
417*cdf0e10cSrcweir 	// Initialize return sequence with these list ...
418*cdf0e10cSrcweir 	static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
419*cdf0e10cSrcweir 	// ... and return it.
420*cdf0e10cSrcweir 	return seqPropertyNames;
421*cdf0e10cSrcweir }
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir void SvtMenuOptions_Impl::AddListenerLink( const Link& rLink )
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir     aList.Insert( new Link( rLink ) );
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir void SvtMenuOptions_Impl::RemoveListenerLink( const Link& rLink )
429*cdf0e10cSrcweir {
430*cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<aList.Count(); n++ )
431*cdf0e10cSrcweir     {
432*cdf0e10cSrcweir         if ( (*aList.GetObject(n) ) == rLink )
433*cdf0e10cSrcweir         {
434*cdf0e10cSrcweir             delete aList.Remove(n);
435*cdf0e10cSrcweir             break;
436*cdf0e10cSrcweir         }
437*cdf0e10cSrcweir     }
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir //*****************************************************************************************************************
441*cdf0e10cSrcweir //	initialize static member
442*cdf0e10cSrcweir //	DON'T DO IT IN YOUR HEADER!
443*cdf0e10cSrcweir //	see definition for further informations
444*cdf0e10cSrcweir //*****************************************************************************************************************
445*cdf0e10cSrcweir SvtMenuOptions_Impl*	SvtMenuOptions::m_pDataContainer	= NULL	;
446*cdf0e10cSrcweir sal_Int32				SvtMenuOptions::m_nRefCount			= 0		;
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir //*****************************************************************************************************************
449*cdf0e10cSrcweir //	constructor
450*cdf0e10cSrcweir //*****************************************************************************************************************
451*cdf0e10cSrcweir SvtMenuOptions::SvtMenuOptions()
452*cdf0e10cSrcweir {
453*cdf0e10cSrcweir     // Global access, must be guarded (multithreading!).
454*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
455*cdf0e10cSrcweir 	// Increase ouer refcount ...
456*cdf0e10cSrcweir 	++m_nRefCount;
457*cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already!
458*cdf0e10cSrcweir     if( m_pDataContainer == NULL )
459*cdf0e10cSrcweir 	{
460*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMenuOptions_Impl::ctor()");
461*cdf0e10cSrcweir         m_pDataContainer = new SvtMenuOptions_Impl();
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir         ItemHolder2::holdConfigItem(E_MENUOPTIONS);
464*cdf0e10cSrcweir 	}
465*cdf0e10cSrcweir }
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir //*****************************************************************************************************************
468*cdf0e10cSrcweir //	destructor
469*cdf0e10cSrcweir //*****************************************************************************************************************
470*cdf0e10cSrcweir SvtMenuOptions::~SvtMenuOptions()
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir     // Global access, must be guarded (multithreading!)
473*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
474*cdf0e10cSrcweir 	// Decrease ouer refcount.
475*cdf0e10cSrcweir 	--m_nRefCount;
476*cdf0e10cSrcweir 	// If last instance was deleted ...
477*cdf0e10cSrcweir 	// we must destroy ouer static data container!
478*cdf0e10cSrcweir     if( m_nRefCount <= 0 )
479*cdf0e10cSrcweir 	{
480*cdf0e10cSrcweir 		delete m_pDataContainer;
481*cdf0e10cSrcweir 		m_pDataContainer = NULL;
482*cdf0e10cSrcweir 	}
483*cdf0e10cSrcweir }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir //*****************************************************************************************************************
486*cdf0e10cSrcweir //	public method
487*cdf0e10cSrcweir //*****************************************************************************************************************
488*cdf0e10cSrcweir sal_Bool SvtMenuOptions::IsEntryHidingEnabled() const
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
491*cdf0e10cSrcweir 	return m_pDataContainer->IsEntryHidingEnabled();
492*cdf0e10cSrcweir }
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir //*****************************************************************************************************************
495*cdf0e10cSrcweir //	public method
496*cdf0e10cSrcweir //*****************************************************************************************************************
497*cdf0e10cSrcweir sal_Bool SvtMenuOptions::IsFollowMouseEnabled() const
498*cdf0e10cSrcweir {
499*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
500*cdf0e10cSrcweir 	return m_pDataContainer->IsFollowMouseEnabled();
501*cdf0e10cSrcweir }
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir //*****************************************************************************************************************
504*cdf0e10cSrcweir //	public method
505*cdf0e10cSrcweir //*****************************************************************************************************************
506*cdf0e10cSrcweir void SvtMenuOptions::SetEntryHidingState( sal_Bool bState )
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
509*cdf0e10cSrcweir 	m_pDataContainer->SetEntryHidingState( bState );
510*cdf0e10cSrcweir }
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir //*****************************************************************************************************************
513*cdf0e10cSrcweir //	public method
514*cdf0e10cSrcweir //*****************************************************************************************************************
515*cdf0e10cSrcweir void SvtMenuOptions::SetFollowMouseState( sal_Bool bState )
516*cdf0e10cSrcweir {
517*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
518*cdf0e10cSrcweir 	m_pDataContainer->SetFollowMouseState( bState );
519*cdf0e10cSrcweir }
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir //*****************************************************************************************************************
522*cdf0e10cSrcweir //	public method
523*cdf0e10cSrcweir //*****************************************************************************************************************
524*cdf0e10cSrcweir sal_Int16 SvtMenuOptions::GetMenuIconsState() const
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
527*cdf0e10cSrcweir 	return m_pDataContainer->GetMenuIconsState();
528*cdf0e10cSrcweir }
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir //*****************************************************************************************************************
531*cdf0e10cSrcweir //	public method
532*cdf0e10cSrcweir //*****************************************************************************************************************
533*cdf0e10cSrcweir void SvtMenuOptions::SetMenuIconsState( sal_Int16 bState )
534*cdf0e10cSrcweir {
535*cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
536*cdf0e10cSrcweir 	m_pDataContainer->SetMenuIconsState( bState );
537*cdf0e10cSrcweir }
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir //*****************************************************************************************************************
540*cdf0e10cSrcweir //	private method
541*cdf0e10cSrcweir //*****************************************************************************************************************
542*cdf0e10cSrcweir Mutex& SvtMenuOptions::GetOwnStaticMutex()
543*cdf0e10cSrcweir {
544*cdf0e10cSrcweir 	// Initialize static mutex only for one time!
545*cdf0e10cSrcweir     static Mutex* pMutex = NULL;
546*cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
547*cdf0e10cSrcweir     if( pMutex == NULL )
548*cdf0e10cSrcweir     {
549*cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
550*cdf0e10cSrcweir 		// It must be - we create a static variable!
551*cdf0e10cSrcweir         MutexGuard aGuard( Mutex::getGlobalMutex() );
552*cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
553*cdf0e10cSrcweir         if( pMutex == NULL )
554*cdf0e10cSrcweir         {
555*cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
556*cdf0e10cSrcweir             static Mutex aMutex;
557*cdf0e10cSrcweir             pMutex = &aMutex;
558*cdf0e10cSrcweir         }
559*cdf0e10cSrcweir     }
560*cdf0e10cSrcweir 	// Return new created or already existing mutex object.
561*cdf0e10cSrcweir     return *pMutex;
562*cdf0e10cSrcweir }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir void SvtMenuOptions::AddListenerLink( const Link& rLink )
565*cdf0e10cSrcweir {
566*cdf0e10cSrcweir     m_pDataContainer->AddListenerLink( rLink );
567*cdf0e10cSrcweir }
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir void SvtMenuOptions::RemoveListenerLink( const Link& rLink )
570*cdf0e10cSrcweir {
571*cdf0e10cSrcweir     m_pDataContainer->RemoveListenerLink( rLink );
572*cdf0e10cSrcweir }
573