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