1*b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b5088357SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b5088357SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b5088357SAndrew Rist  * distributed with this work for additional information
6*b5088357SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b5088357SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b5088357SAndrew Rist  * "License"); you may not use this file except in compliance
9*b5088357SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b5088357SAndrew Rist  *
11*b5088357SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b5088357SAndrew Rist  *
13*b5088357SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b5088357SAndrew Rist  * software distributed under the License is distributed on an
15*b5088357SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b5088357SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b5088357SAndrew Rist  * specific language governing permissions and limitations
18*b5088357SAndrew Rist  * under the License.
19*b5088357SAndrew Rist  *
20*b5088357SAndrew Rist  *************************************************************/
21*b5088357SAndrew Rist 
22*b5088357SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_unotools.hxx"
26cdf0e10cSrcweir #ifndef GCC
27cdf0e10cSrcweir #endif
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir //	includes
31cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <deque>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <unotools/internaloptions.hxx>
36cdf0e10cSrcweir #include <unotools/configmgr.hxx>
37cdf0e10cSrcweir #include <unotools/configitem.hxx>
38cdf0e10cSrcweir #include <tools/debug.hxx>
39cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
40cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
41cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <rtl/logfile.hxx>
44cdf0e10cSrcweir #include "itemholder1.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47cdf0e10cSrcweir //	namespaces
48cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace ::utl					;
51cdf0e10cSrcweir using namespace ::rtl					;
52cdf0e10cSrcweir using namespace ::osl					;
53cdf0e10cSrcweir using namespace ::std					;
54cdf0e10cSrcweir using namespace ::com::sun::star::uno	;
55cdf0e10cSrcweir using namespace ::com::sun::star::beans	;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //_________________________________________________________________________________________________________________
58cdf0e10cSrcweir //	const
59cdf0e10cSrcweir //_________________________________________________________________________________________________________________
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #define	ROOTNODE_INTERNAL					OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Internal"	))
62cdf0e10cSrcweir #define	DEFAULT_SLOTCFG						sal_False
63cdf0e10cSrcweir #define	DEFAULT_SENDCRASHMAIL				sal_False
64cdf0e10cSrcweir #define DEFAULT_USEMAILUI                   sal_True
65cdf0e10cSrcweir #define DEFAULT_CURRENTTEMPURL				OUString(RTL_CONSTASCII_USTRINGPARAM(""))
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #define	FIXPROPERTYNAME_SLOTCFG				OUString(RTL_CONSTASCII_USTRINGPARAM("Slot"						))
68cdf0e10cSrcweir #define	FIXPROPERTYNAME_SENDCRASHMAIL		OUString(RTL_CONSTASCII_USTRINGPARAM("SendCrashMail"			))
69cdf0e10cSrcweir #define FIXPROPERTYNAME_USEMAILUI           OUString(RTL_CONSTASCII_USTRINGPARAM("UseMailUI"                ))
70cdf0e10cSrcweir #define FIXPROPERTYNAME_CURRENTTEMPURL		OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentTempURL"			))
71cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE           OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryClose"))
72cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP    OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryBackToWebtop"))
73cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP       OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryNewWebtop"))
74cdf0e10cSrcweir //#define FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT          OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveMenuEntryLogout"))
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #define	FIXPROPERTYHANDLE_SLOTCFG			0
77cdf0e10cSrcweir #define	FIXPROPERTYHANDLE_SENDCRASHMAIL		1
78cdf0e10cSrcweir #define FIXPROPERTYHANDLE_USEMAILUI         2
79cdf0e10cSrcweir #define FIXPROPERTYHANDLE_CURRENTTEMPURL	3
80cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE   3
81cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP         4
82cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP         5
83cdf0e10cSrcweir //#define FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT         6
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #define FIXPROPERTYCOUNT                    4
86cdf0e10cSrcweir /*
87cdf0e10cSrcweir #define	PROPERTYNAME_RECOVERYLIST			OUString(RTL_CONSTASCII_USTRINGPARAM("RecoveryList"				))
88cdf0e10cSrcweir #define	PROPERTYNAME_URL					OUString(RTL_CONSTASCII_USTRINGPARAM("OrgURL"					))
89cdf0e10cSrcweir #define	PROPERTYNAME_FILTER					OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName"  			    ))
90cdf0e10cSrcweir #define	PROPERTYNAME_TEMPNAME				OUString(RTL_CONSTASCII_USTRINGPARAM("TempURL"					))
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #define	OFFSET_URL							0
93cdf0e10cSrcweir #define	OFFSET_FILTER						1
94cdf0e10cSrcweir #define	OFFSET_TEMPNAME						2
95cdf0e10cSrcweir */
96cdf0e10cSrcweir #define	PATHDELIMITER						OUString(RTL_CONSTASCII_USTRINGPARAM("/"						))
97cdf0e10cSrcweir #define	FIXR								OUString(RTL_CONSTASCII_USTRINGPARAM("r"						))
98cdf0e10cSrcweir 
99cdf0e10cSrcweir //_________________________________________________________________________________________________________________
100cdf0e10cSrcweir //	private declarations!
101cdf0e10cSrcweir //_________________________________________________________________________________________________________________
102cdf0e10cSrcweir /*
103cdf0e10cSrcweir struct tIMPL_RecoveryEntry
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	OUString	sURL		;
106cdf0e10cSrcweir 	OUString	sFilter		;
107cdf0e10cSrcweir 	OUString	sTempName	;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	tIMPL_RecoveryEntry()
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		sURL		=	OUString();
112cdf0e10cSrcweir 		sFilter		=	OUString();
113cdf0e10cSrcweir 		sTempName	=	OUString();
114cdf0e10cSrcweir 	}
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	tIMPL_RecoveryEntry(	const	OUString&	sNewURL			,
117cdf0e10cSrcweir 							const	OUString&	sNewFilter		,
118cdf0e10cSrcweir 							const	OUString&	sNewTempName	)
119cdf0e10cSrcweir 	{
120cdf0e10cSrcweir 		sURL		=	sNewURL			;
121cdf0e10cSrcweir 		sFilter		=	sNewFilter		;
122cdf0e10cSrcweir 		sTempName	=	sNewTempName	;
123cdf0e10cSrcweir 	}
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir typedef deque< tIMPL_RecoveryEntry > tIMPL_RecoveryStack;
127cdf0e10cSrcweir */
128cdf0e10cSrcweir class SvtInternalOptions_Impl : public ConfigItem
129cdf0e10cSrcweir {
130cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
131cdf0e10cSrcweir 	//	private member
132cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	private:
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         sal_Bool                m_bRemoveMenuEntryClose;
137cdf0e10cSrcweir         sal_Bool                m_bRemoveMenuEntryBackToWebtop;
138cdf0e10cSrcweir         sal_Bool                m_bRemoveMenuEntryNewWebtop;
139cdf0e10cSrcweir         sal_Bool                m_bRemoveMenuEntryLogout;
140cdf0e10cSrcweir         sal_Bool                m_bSlotCFG          ;   /// cache "Slot" of Internal section
141cdf0e10cSrcweir 		sal_Bool				m_bSendCrashMail	;	/// cache "SendCrashMail" of Internal section
142cdf0e10cSrcweir         sal_Bool                m_bUseMailUI;
143cdf0e10cSrcweir 		OUString				m_aCurrentTempURL	;
144cdf0e10cSrcweir 	//	tIMPL_RecoveryStack		m_aRecoveryList		;	/// cache "RecoveryList" of Internal section
145cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
146cdf0e10cSrcweir 	//	public methods
147cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	public:
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
152cdf0e10cSrcweir 		//	constructor / destructor
153cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		 SvtInternalOptions_Impl();
156cdf0e10cSrcweir 		~SvtInternalOptions_Impl();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
159cdf0e10cSrcweir 		//	overloaded methods of baseclass
160cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 		/*-****************************************************************************************************//**
163cdf0e10cSrcweir 			@short		called for notify of configmanager
164cdf0e10cSrcweir 			@descr		These method is called from the ConfigManager before application ends or from the
165cdf0e10cSrcweir 			 			PropertyChangeListener if the sub tree broadcasts changes. You must update your
166cdf0e10cSrcweir 						internal values.
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 			@param		"seqPropertyNames" is the list of properties which should be updated.
171cdf0e10cSrcweir 			@return		-
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			@onerror	-
174cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
175cdf0e10cSrcweir 
Notify(const Sequence<OUString> &)176cdf0e10cSrcweir     	virtual void Notify( const Sequence< OUString >& )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			DBG_ASSERT( sal_False, "SvtInternalOptions::Notify()\nNot used yet ... but called!?\n" );
179cdf0e10cSrcweir 		}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 		/*-****************************************************************************************************//**
182cdf0e10cSrcweir 			@short		write changes to configuration
183cdf0e10cSrcweir 			@descr		These method writes the changed values into the sub tree
184cdf0e10cSrcweir 						and should always called in our destructor to guarantee consistency of config data.
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 			@param		-
189cdf0e10cSrcweir 			@return		-
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 			@onerror	-
192cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     	virtual void Commit();
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
197cdf0e10cSrcweir 		//	public interface
198cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		/*-****************************************************************************************************//**
201cdf0e10cSrcweir 			@short		access method to get internal values
202cdf0e10cSrcweir 			@descr		These method give us a chance to regulate acces to ouer internal values.
203cdf0e10cSrcweir 						It's not used in the moment - but it's possible for the feature!
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 			@seealso	-
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 			@param		-
208cdf0e10cSrcweir 			@return		-
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 			@onerror	-
211cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
212cdf0e10cSrcweir 
IsRemoveMenuEntryClose() const213cdf0e10cSrcweir         sal_Bool    IsRemoveMenuEntryClose() const { return m_bRemoveMenuEntryClose; }
IsRemoveMenuEntryBackToWebtop() const214cdf0e10cSrcweir         sal_Bool    IsRemoveMenuEntryBackToWebtop() const { return m_bRemoveMenuEntryBackToWebtop; }
IsRemoveMenuEntryNewWebtop() const215cdf0e10cSrcweir         sal_Bool    IsRemoveMenuEntryNewWebtop() const { return m_bRemoveMenuEntryNewWebtop; }
IsRemoveMenuEntryLogout() const216cdf0e10cSrcweir         sal_Bool    IsRemoveMenuEntryLogout() const { return m_bRemoveMenuEntryLogout; }
SlotCFGEnabled() const217cdf0e10cSrcweir         sal_Bool    SlotCFGEnabled      () const { return m_bSlotCFG; }
CrashMailEnabled() const218cdf0e10cSrcweir         sal_Bool    CrashMailEnabled    () const { return m_bSendCrashMail; }
MailUIEnabled() const219cdf0e10cSrcweir         sal_Bool    MailUIEnabled       () const { return m_bUseMailUI; }
220cdf0e10cSrcweir 
GetCurrentTempURL() const221cdf0e10cSrcweir 		OUString	GetCurrentTempURL() const { return m_aCurrentTempURL; }
222cdf0e10cSrcweir 		void		SetCurrentTempURL( const OUString& aNewCurrentTempURL );
223cdf0e10cSrcweir /*
224cdf0e10cSrcweir 		void		PushRecoveryItem	(	const	OUString&	sURL		,
225cdf0e10cSrcweir 											const	OUString&	sFilter		,
226cdf0e10cSrcweir 					 						const	OUString&	sTempName	);
227cdf0e10cSrcweir 		void		PopRecoveryItem		(			OUString&	sURL		,
228cdf0e10cSrcweir 													OUString&	sFilter		,
229cdf0e10cSrcweir 													OUString&	sTempName	);
230cdf0e10cSrcweir 		sal_Bool	IsRecoveryListEmpty	(									) const;
231cdf0e10cSrcweir */
232cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
233cdf0e10cSrcweir 	//	private methods
234cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	private:
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		/*-****************************************************************************************************//**
239cdf0e10cSrcweir 			@short		return list of fix key names of ouer configuration management which represent oue module tree
240cdf0e10cSrcweir 			@descr		These methods return a static const list of key names. We need it to get needed values from our
241cdf0e10cSrcweir 						configuration management. We return well known key names only - because the "UserData" node
242cdf0e10cSrcweir 						is handled in a special way!
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 			@seealso	-
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 			@param		-
247cdf0e10cSrcweir 			@return		A list of needed configuration keys is returned.
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 			@onerror	-
250cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		Sequence< OUString > impl_GetPropertyNames();
253cdf0e10cSrcweir };
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //_________________________________________________________________________________________________________________
256cdf0e10cSrcweir //	definitions
257cdf0e10cSrcweir //_________________________________________________________________________________________________________________
258cdf0e10cSrcweir 
259cdf0e10cSrcweir //*****************************************************************************************************************
260cdf0e10cSrcweir //	constructor
261cdf0e10cSrcweir //*****************************************************************************************************************
SvtInternalOptions_Impl()262cdf0e10cSrcweir SvtInternalOptions_Impl::SvtInternalOptions_Impl()
263cdf0e10cSrcweir 	// Init baseclasses first
264cdf0e10cSrcweir     :   ConfigItem          ( ROOTNODE_INTERNAL, CONFIG_MODE_IMMEDIATE_UPDATE )
265cdf0e10cSrcweir 	// Init member then.
266cdf0e10cSrcweir     , m_bRemoveMenuEntryClose ( sal_False )
267cdf0e10cSrcweir     , m_bRemoveMenuEntryBackToWebtop ( sal_False )
268cdf0e10cSrcweir     , m_bRemoveMenuEntryNewWebtop ( sal_False )
269cdf0e10cSrcweir     , m_bRemoveMenuEntryLogout ( sal_False )
270cdf0e10cSrcweir 	,	m_bSlotCFG			( DEFAULT_SLOTCFG			)
271cdf0e10cSrcweir 	,	m_bSendCrashMail	( DEFAULT_SENDCRASHMAIL		)
272cdf0e10cSrcweir     ,   m_bUseMailUI        ( DEFAULT_USEMAILUI			)
273cdf0e10cSrcweir 	,	m_aCurrentTempURL	( DEFAULT_CURRENTTEMPURL	)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	// Use our list of configuration keys to get his values.
276cdf0e10cSrcweir 	// structure of internal section: (first 2 entries are fixed - all other are member of a set!)
277cdf0e10cSrcweir 	//		"Slot"
278cdf0e10cSrcweir 	//		"SendCrashMail"
279cdf0e10cSrcweir 	//		"RecoveryList/r1/URL"
280cdf0e10cSrcweir 	//		"RecoveryList/r1/Filter"
281cdf0e10cSrcweir 	//		"RecoveryList/r1/TempName"
282cdf0e10cSrcweir 	//		"RecoveryList/r2/URL"
283cdf0e10cSrcweir 	//		"RecoveryList/r2/Filter"
284cdf0e10cSrcweir 	//		"RecoveryList/r2/TempName"
285cdf0e10cSrcweir 	//		"RecoveryList/.."
286cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= impl_GetPropertyNames()	;
287cdf0e10cSrcweir 	Sequence< Any >			seqValues	= GetProperties( seqNames )	;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	// Safe impossible cases.
290cdf0e10cSrcweir 	// We need values from ALL configuration keys.
291cdf0e10cSrcweir 	// Follow assignment use order of values in relation to our list of key names!
292cdf0e10cSrcweir 	DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nI miss some values of configuration keys!\n" );
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	// Read fixed values first!
295cdf0e10cSrcweir 	DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SLOTCFG].getValueTypeClass()!=TypeClass_BOOLEAN)		, "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\Slot\"?"			);
296cdf0e10cSrcweir 	DBG_ASSERT(!(seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL].getValueTypeClass()!=TypeClass_BOOLEAN)	, "SvtInternalOptions_Impl::SvtInternalOptions_Impl()\nWho has changed the value type of \"Office.Common\\Internal\\SendCrashMail\"?"	);
297cdf0e10cSrcweir 	seqValues[FIXPROPERTYHANDLE_SLOTCFG			] >>= m_bSlotCFG		;
298cdf0e10cSrcweir 	seqValues[FIXPROPERTYHANDLE_SENDCRASHMAIL	] >>= m_bSendCrashMail	;
299cdf0e10cSrcweir     seqValues[FIXPROPERTYHANDLE_USEMAILUI       ] >>= m_bUseMailUI  ;
300cdf0e10cSrcweir 	seqValues[FIXPROPERTYHANDLE_CURRENTTEMPURL	] >>= m_aCurrentTempURL	;
301cdf0e10cSrcweir //    seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE ] >>= m_bRemoveMenuEntryClose  ;
302cdf0e10cSrcweir //    seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ] >>= m_bRemoveMenuEntryBackToWebtop  ;
303cdf0e10cSrcweir //    seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP ] >>= m_bRemoveMenuEntryNewWebtop  ;
304cdf0e10cSrcweir //    seqValues[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT ] >>= m_bRemoveMenuEntryLogout  ;
305cdf0e10cSrcweir /*
306cdf0e10cSrcweir 	// Read dynamical set "RecoveryList" then.
307cdf0e10cSrcweir 	// 3 subkeys for every item!
308cdf0e10cSrcweir 	// Attention: Start at next element after last fixed entry! We must ignore "Slot" and "SendCrashMail" ...
309cdf0e10cSrcweir 	tIMPL_RecoveryEntry aEntry;
310cdf0e10cSrcweir 	sal_uInt32 nCount		= seqValues.getLength()	;
311cdf0e10cSrcweir 	sal_uInt32 nPosition	= FIXPROPERTYCOUNT		;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	while( nPosition<nCount )
314cdf0e10cSrcweir 	{
315cdf0e10cSrcweir 		seqValues[nPosition] >>= aEntry.sURL		;
316cdf0e10cSrcweir 		++nPosition;
317cdf0e10cSrcweir 		seqValues[nPosition] >>= aEntry.sFilter		;
318cdf0e10cSrcweir 		++nPosition;
319cdf0e10cSrcweir 		seqValues[nPosition] >>= aEntry.sTempName	;
320cdf0e10cSrcweir 		++nPosition;
321cdf0e10cSrcweir 		m_aRecoveryList.push_front( aEntry );
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir */
324cdf0e10cSrcweir 	// We don't need any notifications here.
325cdf0e10cSrcweir 	// "Slot" and "SendCrashMail" are readonly(!) and our recovery list should not modified during runtime - it's used
326cdf0e10cSrcweir 	// by our crash guard only ... otherwise we have a big problem.
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir //*****************************************************************************************************************
330cdf0e10cSrcweir //	destructor
331cdf0e10cSrcweir //*****************************************************************************************************************
~SvtInternalOptions_Impl()332cdf0e10cSrcweir SvtInternalOptions_Impl::~SvtInternalOptions_Impl()
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	if( IsModified() == sal_True )
335cdf0e10cSrcweir 	{
336cdf0e10cSrcweir 		Commit();
337cdf0e10cSrcweir 	}
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir //*****************************************************************************************************************
341cdf0e10cSrcweir //	public method
342cdf0e10cSrcweir //*****************************************************************************************************************
Commit()343cdf0e10cSrcweir void SvtInternalOptions_Impl::Commit()
344cdf0e10cSrcweir {
345cdf0e10cSrcweir 	// We have to write our current temp URL
346cdf0e10cSrcweir 	Sequence< OUString > aNames( 1 );
347cdf0e10cSrcweir 	OUString* pNames = aNames.getArray();
348cdf0e10cSrcweir 	Sequence< Any > aValues( 1 );
349cdf0e10cSrcweir 	Any* pValues = aValues.getArray();
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 	pNames[0] = FIXPROPERTYNAME_CURRENTTEMPURL;
352cdf0e10cSrcweir 	pValues[0] <<= m_aCurrentTempURL;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 	PutProperties( aNames, aValues );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir /*
357cdf0e10cSrcweir 	// Write set of dynamic properties then.
358cdf0e10cSrcweir 	ClearNodeSet( PROPERTYNAME_RECOVERYLIST );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	tIMPL_RecoveryEntry			aItem					;
361cdf0e10cSrcweir 	OUString					sNode					;
362cdf0e10cSrcweir 	Sequence< PropertyValue >	seqPropertyValues( 3 )	;	// Every node in set has 3 sub-nodes!( url, filter, tempname )
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 	// Copy list entries to save-list and write it to configuration.
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	sal_uInt32 nCount = m_aRecoveryList.size();
367cdf0e10cSrcweir 	for( sal_uInt32 nItem=0; nItem<nCount; ++nItem )
368cdf0e10cSrcweir 	{
369cdf0e10cSrcweir 		aItem = m_aRecoveryList.top();
370cdf0e10cSrcweir 		m_aRecoveryList.pop();
371cdf0e10cSrcweir 		sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR + OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
372cdf0e10cSrcweir 		seqPropertyValues[OFFSET_URL		].Name  =	sNode + PROPERTYNAME_URL		;
373cdf0e10cSrcweir 		seqPropertyValues[OFFSET_FILTER		].Name  =	sNode + PROPERTYNAME_FILTER		;
374cdf0e10cSrcweir 		seqPropertyValues[OFFSET_TEMPNAME	].Name  =	sNode + PROPERTYNAME_TEMPNAME	;
375cdf0e10cSrcweir 		seqPropertyValues[OFFSET_URL		].Value <<=	aItem.sURL						;
376cdf0e10cSrcweir 		seqPropertyValues[OFFSET_FILTER		].Value <<=	aItem.sFilter					;
377cdf0e10cSrcweir 		seqPropertyValues[OFFSET_TEMPNAME	].Value <<=	aItem.sTempName					;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 		SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
380cdf0e10cSrcweir 	}
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 	tIMPL_RecoveryStack::iterator iRecovery = m_aRecoveryList.begin();
383cdf0e10cSrcweir 	for ( sal_uInt32 nItem=0; iRecovery != m_aRecoveryList.end(); ++nItem, ++iRecovery)
384cdf0e10cSrcweir 	{
385cdf0e10cSrcweir 		aItem = *iRecovery;
386cdf0e10cSrcweir 		sNode = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + FIXR +
387cdf0e10cSrcweir 			OUString::valueOf( (sal_Int32)nItem ) + PATHDELIMITER;
388cdf0e10cSrcweir 		seqPropertyValues[OFFSET_URL		].Name  =	sNode + PROPERTYNAME_URL		;
389cdf0e10cSrcweir 		seqPropertyValues[OFFSET_FILTER		].Name  =	sNode + PROPERTYNAME_FILTER		;
390cdf0e10cSrcweir 		seqPropertyValues[OFFSET_TEMPNAME	].Name  =	sNode + PROPERTYNAME_TEMPNAME	;
391cdf0e10cSrcweir 		seqPropertyValues[OFFSET_URL		].Value <<=	iRecovery->sURL					;
392cdf0e10cSrcweir 		seqPropertyValues[OFFSET_FILTER		].Value <<=	iRecovery->sFilter				;
393cdf0e10cSrcweir 		seqPropertyValues[OFFSET_TEMPNAME	].Value <<=	iRecovery->sTempName			;
394cdf0e10cSrcweir 		SetSetProperties( PROPERTYNAME_RECOVERYLIST, seqPropertyValues );
395cdf0e10cSrcweir 	}
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     */
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir //*****************************************************************************************************************
401cdf0e10cSrcweir //	public method
402cdf0e10cSrcweir //*****************************************************************************************************************
SetCurrentTempURL(const OUString & aNewCurrentTempURL)403cdf0e10cSrcweir void SvtInternalOptions_Impl::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir 	m_aCurrentTempURL = aNewCurrentTempURL;
406cdf0e10cSrcweir 	SetModified();
407cdf0e10cSrcweir     Commit();
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir #if 0
411cdf0e10cSrcweir //*****************************************************************************************************************
412cdf0e10cSrcweir //	public method
413cdf0e10cSrcweir //*****************************************************************************************************************
414cdf0e10cSrcweir void SvtInternalOptions_Impl::PushRecoveryItem(	const	OUString&	sURL		,
415cdf0e10cSrcweir 												const	OUString&	sFilter		,
416cdf0e10cSrcweir 												const	OUString&	sTempName	)
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	tIMPL_RecoveryEntry aEntry( sURL, sFilter, sTempName );
419cdf0e10cSrcweir 	m_aRecoveryList.push_front( aEntry );
420cdf0e10cSrcweir 	SetModified();
421cdf0e10cSrcweir }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir //*****************************************************************************************************************
424cdf0e10cSrcweir //	public method
425cdf0e10cSrcweir //*****************************************************************************************************************
426cdf0e10cSrcweir void SvtInternalOptions_Impl::PopRecoveryItem(	OUString&	sURL		,
427cdf0e10cSrcweir 												OUString&	sFilter		,
428cdf0e10cSrcweir 												OUString&	sTempName	)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir 	tIMPL_RecoveryEntry aEntry = m_aRecoveryList.front();
431cdf0e10cSrcweir 	m_aRecoveryList.pop_front();
432cdf0e10cSrcweir 	SetModified();	// Don't forget it - we delete an entry here!
433cdf0e10cSrcweir 	sURL		= aEntry.sURL		;
434cdf0e10cSrcweir 	sFilter		= aEntry.sFilter	;
435cdf0e10cSrcweir 	sTempName	= aEntry.sTempName	;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir //*****************************************************************************************************************
439cdf0e10cSrcweir //	public method
440cdf0e10cSrcweir //*****************************************************************************************************************
441cdf0e10cSrcweir sal_Bool SvtInternalOptions_Impl::IsRecoveryListEmpty() const
442cdf0e10cSrcweir {
443cdf0e10cSrcweir 	return ( m_aRecoveryList.empty() );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir #endif
446cdf0e10cSrcweir 
447cdf0e10cSrcweir //*****************************************************************************************************************
448cdf0e10cSrcweir //	private method
449cdf0e10cSrcweir //*****************************************************************************************************************
impl_GetPropertyNames()450cdf0e10cSrcweir Sequence< OUString > SvtInternalOptions_Impl::impl_GetPropertyNames()
451cdf0e10cSrcweir {
452cdf0e10cSrcweir     /*
453cdf0e10cSrcweir 	// First get ALL names of current existing list items in configuration!
454cdf0e10cSrcweir 	Sequence< OUString > seqRecoveryItems = GetNodeNames( PROPERTYNAME_RECOVERYLIST );
455cdf0e10cSrcweir 	// Get information about list counts ...
456cdf0e10cSrcweir 	sal_Int32 nRecoveryCount = seqRecoveryItems.getLength();
457cdf0e10cSrcweir 	// ... and create a property list with right size! (+2...for fix properties!) (*3 ... = sub nodes for every set node!)
458cdf0e10cSrcweir 	Sequence< OUString > seqProperties( FIXPROPERTYCOUNT + (nRecoveryCount*3) );
459cdf0e10cSrcweir     */
460cdf0e10cSrcweir 	Sequence< OUString > seqProperties(4);
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 	// Add names of fix properties to list.
463cdf0e10cSrcweir     seqProperties[FIXPROPERTYHANDLE_SLOTCFG         ]   =   FIXPROPERTYNAME_SLOTCFG         ;
464cdf0e10cSrcweir 	seqProperties[FIXPROPERTYHANDLE_SENDCRASHMAIL	]	=	FIXPROPERTYNAME_SENDCRASHMAIL	;
465cdf0e10cSrcweir     seqProperties[FIXPROPERTYHANDLE_USEMAILUI       ]   =   FIXPROPERTYNAME_USEMAILUI       ;
466cdf0e10cSrcweir 	seqProperties[FIXPROPERTYHANDLE_CURRENTTEMPURL	]	=	FIXPROPERTYNAME_CURRENTTEMPURL	;
467cdf0e10cSrcweir //    seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYCLOSE        ]   =   FIXPROPERTYNAME_REMOVEMENUENTRYCLOSE;
468cdf0e10cSrcweir //    seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYBACKTOWEBTOP ]   =   FIXPROPERTYNAME_REMOVEMENUENTRYBACKTOWEBTOP;
469cdf0e10cSrcweir //    seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYNEWWEBTOP    ]   =   FIXPROPERTYNAME_REMOVEMENUENTRYNEWWEBTOP;
470cdf0e10cSrcweir //    seqProperties[FIXPROPERTYHANDLE_REMOVEMENUENTRYLOGOUT       ]   =   FIXPROPERTYNAME_REMOVEMENUENTRYLOGOUT;
471cdf0e10cSrcweir /*
472cdf0e10cSrcweir 	sal_uInt32 nPosition = FIXPROPERTYCOUNT;
473cdf0e10cSrcweir 	// Add names for recovery list to list.
474cdf0e10cSrcweir 	// 3 subkeys for every item!
475cdf0e10cSrcweir 	// nPosition is the start point of an list item, nItem an index into right list of node names!
476cdf0e10cSrcweir 	for( sal_Int32 nItem=0; nItem<nRecoveryCount; ++nItem )
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_URL		;
479cdf0e10cSrcweir 		++nPosition;
480cdf0e10cSrcweir 		seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_FILTER	;
481cdf0e10cSrcweir 		++nPosition;
482cdf0e10cSrcweir 		seqProperties[nPosition] = PROPERTYNAME_RECOVERYLIST + PATHDELIMITER + seqRecoveryItems[nItem] + PATHDELIMITER + PROPERTYNAME_TEMPNAME	;
483cdf0e10cSrcweir 		++nPosition;
484cdf0e10cSrcweir 	}
485cdf0e10cSrcweir */
486cdf0e10cSrcweir 	// Return result.
487cdf0e10cSrcweir 	return seqProperties;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir //*****************************************************************************************************************
491cdf0e10cSrcweir //	initialize static member
492cdf0e10cSrcweir //	DON'T DO IT IN YOUR HEADER!
493cdf0e10cSrcweir //	see definition for further informations
494cdf0e10cSrcweir //*****************************************************************************************************************
495cdf0e10cSrcweir SvtInternalOptions_Impl*	SvtInternalOptions::m_pDataContainer	= NULL	;
496cdf0e10cSrcweir sal_Int32					SvtInternalOptions::m_nRefCount			= 0		;
497cdf0e10cSrcweir 
498cdf0e10cSrcweir //*****************************************************************************************************************
499cdf0e10cSrcweir //	constructor
500cdf0e10cSrcweir //*****************************************************************************************************************
SvtInternalOptions()501cdf0e10cSrcweir SvtInternalOptions::SvtInternalOptions()
502cdf0e10cSrcweir {
503cdf0e10cSrcweir     // Global access, must be guarded (multithreading!).
504cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
505cdf0e10cSrcweir 	// Increase ouer refcount ...
506cdf0e10cSrcweir 	++m_nRefCount;
507cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already!
508cdf0e10cSrcweir     if( m_pDataContainer == NULL )
509cdf0e10cSrcweir 	{
510cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtInternalOptions_Impl::ctor()");
511cdf0e10cSrcweir         m_pDataContainer = new SvtInternalOptions_Impl();
512cdf0e10cSrcweir 
513cdf0e10cSrcweir         ItemHolder1::holdConfigItem(E_INTERNALOPTIONS);
514cdf0e10cSrcweir  	}
515cdf0e10cSrcweir }
516cdf0e10cSrcweir 
517cdf0e10cSrcweir //*****************************************************************************************************************
518cdf0e10cSrcweir //	destructor
519cdf0e10cSrcweir //*****************************************************************************************************************
~SvtInternalOptions()520cdf0e10cSrcweir SvtInternalOptions::~SvtInternalOptions()
521cdf0e10cSrcweir {
522cdf0e10cSrcweir     // Global access, must be guarded (multithreading!)
523cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
524cdf0e10cSrcweir 	// Decrease ouer refcount.
525cdf0e10cSrcweir 	--m_nRefCount;
526cdf0e10cSrcweir 	// If last instance was deleted ...
527cdf0e10cSrcweir 	// we must destroy ouer static data container!
528cdf0e10cSrcweir     if( m_nRefCount <= 0 )
529cdf0e10cSrcweir 	{
530cdf0e10cSrcweir 		delete m_pDataContainer;
531cdf0e10cSrcweir 		m_pDataContainer = NULL;
532cdf0e10cSrcweir 	}
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir //*****************************************************************************************************************
536cdf0e10cSrcweir //	public method
537cdf0e10cSrcweir //*****************************************************************************************************************
SlotCFGEnabled() const538cdf0e10cSrcweir sal_Bool SvtInternalOptions::SlotCFGEnabled() const
539cdf0e10cSrcweir {
540cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
541cdf0e10cSrcweir 	return m_pDataContainer->SlotCFGEnabled();
542cdf0e10cSrcweir }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir //*****************************************************************************************************************
545cdf0e10cSrcweir //	public method
546cdf0e10cSrcweir //*****************************************************************************************************************
CrashMailEnabled() const547cdf0e10cSrcweir sal_Bool SvtInternalOptions::CrashMailEnabled() const
548cdf0e10cSrcweir {
549cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
550cdf0e10cSrcweir 	return m_pDataContainer->CrashMailEnabled();
551cdf0e10cSrcweir }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir //*****************************************************************************************************************
554cdf0e10cSrcweir //	public method
555cdf0e10cSrcweir //*****************************************************************************************************************
MailUIEnabled() const556cdf0e10cSrcweir sal_Bool SvtInternalOptions::MailUIEnabled() const
557cdf0e10cSrcweir {
558cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
559cdf0e10cSrcweir     return m_pDataContainer->MailUIEnabled();
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir //*****************************************************************************************************************
563cdf0e10cSrcweir //  public methods
564cdf0e10cSrcweir //*****************************************************************************************************************
IsRemoveMenuEntryClose() const565cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryClose() const
566cdf0e10cSrcweir {
567cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
568cdf0e10cSrcweir     return m_pDataContainer->IsRemoveMenuEntryClose();
569cdf0e10cSrcweir }
570cdf0e10cSrcweir 
IsRemoveMenuEntryBackToWebtop() const571cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryBackToWebtop() const
572cdf0e10cSrcweir {
573cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
574cdf0e10cSrcweir     return m_pDataContainer->IsRemoveMenuEntryBackToWebtop();
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
IsRemoveMenuEntryNewWebtop() const577cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryNewWebtop() const
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
580cdf0e10cSrcweir     return m_pDataContainer->IsRemoveMenuEntryNewWebtop();
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
IsRemoveMenuEntryLogout() const583cdf0e10cSrcweir sal_Bool SvtInternalOptions::IsRemoveMenuEntryLogout() const
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
586cdf0e10cSrcweir     return m_pDataContainer->IsRemoveMenuEntryLogout();
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
GetCurrentTempURL() const589cdf0e10cSrcweir OUString SvtInternalOptions::GetCurrentTempURL() const
590cdf0e10cSrcweir {
591cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
592cdf0e10cSrcweir     return m_pDataContainer->GetCurrentTempURL();
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
SetCurrentTempURL(const OUString & aNewCurrentTempURL)595cdf0e10cSrcweir void SvtInternalOptions::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
596cdf0e10cSrcweir {
597cdf0e10cSrcweir     MutexGuard aGuard( GetOwnStaticMutex() );
598cdf0e10cSrcweir 	m_pDataContainer->SetCurrentTempURL( aNewCurrentTempURL );
599cdf0e10cSrcweir }
600cdf0e10cSrcweir 
601cdf0e10cSrcweir //*****************************************************************************************************************
602cdf0e10cSrcweir //	private method
603cdf0e10cSrcweir //*****************************************************************************************************************
GetOwnStaticMutex()604cdf0e10cSrcweir Mutex& SvtInternalOptions::GetOwnStaticMutex()
605cdf0e10cSrcweir {
606cdf0e10cSrcweir 	// Initialize static mutex only for one time!
607cdf0e10cSrcweir     static Mutex* pMutex = NULL;
608cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
609cdf0e10cSrcweir     if( pMutex == NULL )
610cdf0e10cSrcweir     {
611cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
612cdf0e10cSrcweir 		// It must be - we create a static variable!
613cdf0e10cSrcweir         MutexGuard aGuard( Mutex::getGlobalMutex() );
614cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
615cdf0e10cSrcweir         if( pMutex == NULL )
616cdf0e10cSrcweir         {
617cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
618cdf0e10cSrcweir             static Mutex aMutex;
619cdf0e10cSrcweir             pMutex = &aMutex;
620cdf0e10cSrcweir         }
621cdf0e10cSrcweir     }
622cdf0e10cSrcweir 	// Return new created or already existing mutex object.
623cdf0e10cSrcweir     return *pMutex;
624cdf0e10cSrcweir }
625