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 <unotools/fontoptions.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 
40cdf0e10cSrcweir #include <rtl/logfile.hxx>
41cdf0e10cSrcweir #include "itemholder1.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44cdf0e10cSrcweir //	namespaces
45cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46cdf0e10cSrcweir 
47cdf0e10cSrcweir using namespace ::utl					;
48cdf0e10cSrcweir using namespace ::rtl					;
49cdf0e10cSrcweir using namespace ::osl					;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno	;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53cdf0e10cSrcweir //	const
54cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #define	ROOTNODE_FONT						OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Font"			))
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #define	PROPERTYNAME_REPLACEMENTTABLE		OUString(RTL_CONSTASCII_USTRINGPARAM("Substitution/Replacement"		))
59cdf0e10cSrcweir #define	PROPERTYNAME_FONTHISTORY			OUString(RTL_CONSTASCII_USTRINGPARAM("View/History"					))
60cdf0e10cSrcweir #define	PROPERTYNAME_FONTWYSIWYG			OUString(RTL_CONSTASCII_USTRINGPARAM("View/ShowFontBoxWYSIWYG"		))
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #define	PROPERTYHANDLE_REPLACEMENTTABLE		0
63cdf0e10cSrcweir #define	PROPERTYHANDLE_FONTHISTORY			1
64cdf0e10cSrcweir #define	PROPERTYHANDLE_FONTWYSIWYG			2
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #define	PROPERTYCOUNT						3
67cdf0e10cSrcweir 
68cdf0e10cSrcweir //_________________________________________________________________________________________________________________
69cdf0e10cSrcweir //	private declarations!
70cdf0e10cSrcweir //_________________________________________________________________________________________________________________
71cdf0e10cSrcweir 
72cdf0e10cSrcweir class SvtFontOptions_Impl : public ConfigItem
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
75cdf0e10cSrcweir 	//	public methods
76cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	public:
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
81cdf0e10cSrcweir 		//	constructor / destructor
82cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		 SvtFontOptions_Impl();
85cdf0e10cSrcweir 		~SvtFontOptions_Impl();
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
88cdf0e10cSrcweir 		//	overloaded methods of baseclass
89cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 		/*-****************************************************************************************************//**
92cdf0e10cSrcweir 			@short		called for notify of configmanager
93cdf0e10cSrcweir 			@descr		These method is called from the ConfigManager before application ends or from the
94cdf0e10cSrcweir 			 			PropertyChangeListener if the sub tree broadcasts changes. You must update your
95cdf0e10cSrcweir 						internal values.
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 			@param		"seqPropertyNames" is the list of properties which should be updated.
100cdf0e10cSrcweir 			@return		-
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 			@onerror	-
103cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     	virtual void Notify( const Sequence< OUString >& seqPropertyNames );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 		/*-****************************************************************************************************//**
108cdf0e10cSrcweir 			@short		write changes to configuration
109cdf0e10cSrcweir 			@descr		These method writes the changed values into the sub tree
110cdf0e10cSrcweir 						and should always called in our destructor to guarantee consistency of config data.
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 			@seealso	baseclass ConfigItem
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 			@param		-
115cdf0e10cSrcweir 			@return		-
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 			@onerror	-
118cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     	virtual void Commit();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
123cdf0e10cSrcweir 		//	public interface
124cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		/*-****************************************************************************************************//**
127cdf0e10cSrcweir 			@short		access method to get internal values
128cdf0e10cSrcweir 			@descr		These method give us a chance to regulate acces to ouer internal values.
129cdf0e10cSrcweir 						It's not used in the moment - but it's possible for the feature!
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			@seealso	-
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 			@param		-
134cdf0e10cSrcweir 			@return		-
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 			@onerror	-
137cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		sal_Bool	IsReplacementTableEnabled	(					) const	;
140cdf0e10cSrcweir 		void		EnableReplacementTable		( sal_Bool bState	)		;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 		sal_Bool	IsFontHistoryEnabled		(					) const	;
143cdf0e10cSrcweir 		void		EnableFontHistory			( sal_Bool bState	)		;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		sal_Bool	IsFontWYSIWYGEnabled		(					) const	;
146cdf0e10cSrcweir 		void		EnableFontWYSIWYG			( sal_Bool bState	)		;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
149cdf0e10cSrcweir 	//	private methods
150cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	private:
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		/*-****************************************************************************************************//**
155cdf0e10cSrcweir 			@short		return list of key names of ouer configuration management which represent oue module tree
156cdf0e10cSrcweir 			@descr		These methods return a static const list of key names. We need it to get needed values from our
157cdf0e10cSrcweir 						configuration management.
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 			@seealso	-
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 			@param		-
162cdf0e10cSrcweir 			@return		A list of needed configuration keys is returned.
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 			@onerror	-
165cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 		static Sequence< OUString > impl_GetPropertyNames();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
170cdf0e10cSrcweir 	//	private member
171cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	private:
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 		sal_Bool		m_bReplacementTable		;
176cdf0e10cSrcweir 		sal_Bool		m_bFontHistory			;
177cdf0e10cSrcweir 		sal_Bool		m_bFontWYSIWYG			;
178cdf0e10cSrcweir };
179cdf0e10cSrcweir 
180cdf0e10cSrcweir //_________________________________________________________________________________________________________________
181cdf0e10cSrcweir //	definitions
182cdf0e10cSrcweir //_________________________________________________________________________________________________________________
183cdf0e10cSrcweir 
184cdf0e10cSrcweir //*****************************************************************************************************************
185cdf0e10cSrcweir //	constructor
186cdf0e10cSrcweir //*****************************************************************************************************************
SvtFontOptions_Impl()187cdf0e10cSrcweir SvtFontOptions_Impl::SvtFontOptions_Impl()
188cdf0e10cSrcweir 	// Init baseclasses first
189cdf0e10cSrcweir     :	ConfigItem			( ROOTNODE_FONT	)
190cdf0e10cSrcweir 	// Init member then.
191cdf0e10cSrcweir 	,	m_bReplacementTable	( sal_False		)
192cdf0e10cSrcweir 	,	m_bFontHistory		( sal_False		)
193cdf0e10cSrcweir 	,	m_bFontWYSIWYG		( sal_False		)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	// Use our static list of configuration keys to get his values.
196cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= impl_GetPropertyNames	(			);
197cdf0e10cSrcweir 	Sequence< Any >			seqValues	= GetProperties			( seqNames	);
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	// Safe impossible cases.
200cdf0e10cSrcweir 	// We need values from ALL configuration keys.
201cdf0e10cSrcweir 	// Follow assignment use order of values in relation to our list of key names!
202cdf0e10cSrcweir 	DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nI miss some values of configuration keys!\n" );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	// Copy values from list in right order to ouer internal member.
205cdf0e10cSrcweir 	sal_Int32 nPropertyCount = seqValues.getLength();
206cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
207cdf0e10cSrcweir 	{
208cdf0e10cSrcweir 		// Safe impossible cases.
209cdf0e10cSrcweir 		// Check any for valid value.
210cdf0e10cSrcweir 		DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nInvalid property value detected!\n" );
211cdf0e10cSrcweir         switch( nProperty )
212cdf0e10cSrcweir         {
213cdf0e10cSrcweir             case PROPERTYHANDLE_REPLACEMENTTABLE	:	{
214cdf0e10cSrcweir 															DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\Substitution\\Replacement\"?" );
215cdf0e10cSrcweir 															seqValues[nProperty] >>= m_bReplacementTable;
216cdf0e10cSrcweir 														}
217cdf0e10cSrcweir 														break;
218cdf0e10cSrcweir             case PROPERTYHANDLE_FONTHISTORY			:	{
219cdf0e10cSrcweir 															DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\View\\History\"?" );
220cdf0e10cSrcweir 															seqValues[nProperty] >>= m_bFontHistory;
221cdf0e10cSrcweir 														}
222cdf0e10cSrcweir 														break;
223cdf0e10cSrcweir             case PROPERTYHANDLE_FONTWYSIWYG			:	{
224cdf0e10cSrcweir 															DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::SvtFontOptions_Impl()\nWho has changed the value type of \"Office.Common\\Font\\View\\ShowFontBoxWYSIWYG\"?" );
225cdf0e10cSrcweir 															seqValues[nProperty] >>= m_bFontWYSIWYG;
226cdf0e10cSrcweir 														}
227cdf0e10cSrcweir 														break;
228cdf0e10cSrcweir         }
229cdf0e10cSrcweir 	}
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	// Enable notification mechanism of ouer baseclass.
232cdf0e10cSrcweir 	// We need it to get information about changes outside these class on ouer used configuration keys!
233cdf0e10cSrcweir 	EnableNotification( seqNames );
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir //*****************************************************************************************************************
237cdf0e10cSrcweir //	destructor
238cdf0e10cSrcweir //*****************************************************************************************************************
~SvtFontOptions_Impl()239cdf0e10cSrcweir SvtFontOptions_Impl::~SvtFontOptions_Impl()
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	// We must save our current values .. if user forget it!
242cdf0e10cSrcweir 	if( IsModified() == sal_True )
243cdf0e10cSrcweir 	{
244cdf0e10cSrcweir 		Commit();
245cdf0e10cSrcweir 	}
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //*****************************************************************************************************************
249cdf0e10cSrcweir //	public method
250cdf0e10cSrcweir //*****************************************************************************************************************
Notify(const Sequence<OUString> & seqPropertyNames)251cdf0e10cSrcweir void SvtFontOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir 	// Use given list of updated properties to get his values from configuration directly!
254cdf0e10cSrcweir 	Sequence< Any > seqValues = GetProperties( seqPropertyNames );
255cdf0e10cSrcweir 	// Safe impossible cases.
256cdf0e10cSrcweir 	// We need values from ALL notified configuration keys.
257cdf0e10cSrcweir 	DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtFontOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
258cdf0e10cSrcweir 	// Step over list of property names and get right value from coreesponding value list to set it on internal members!
259cdf0e10cSrcweir 	sal_Int32 nCount = seqPropertyNames.getLength();
260cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
261cdf0e10cSrcweir 	{
262cdf0e10cSrcweir 		if( seqPropertyNames[nProperty] == PROPERTYNAME_REPLACEMENTTABLE )
263cdf0e10cSrcweir 		{
264cdf0e10cSrcweir 			DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\Substitution\\Replacement\"?" );
265cdf0e10cSrcweir 			seqValues[nProperty] >>= m_bReplacementTable;
266cdf0e10cSrcweir 		}
267cdf0e10cSrcweir 		else
268cdf0e10cSrcweir 		if( seqPropertyNames[nProperty] == PROPERTYNAME_FONTHISTORY )
269cdf0e10cSrcweir 		{
270cdf0e10cSrcweir 			DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\View\\History\"?" );
271cdf0e10cSrcweir 			seqValues[nProperty] >>= m_bFontHistory;
272cdf0e10cSrcweir 		}
273cdf0e10cSrcweir 		else
274cdf0e10cSrcweir 		if( seqPropertyNames[nProperty] == PROPERTYNAME_FONTWYSIWYG )
275cdf0e10cSrcweir 		{
276cdf0e10cSrcweir 			DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtFontOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Font\\View\\ShowFontBoxWYSIWYG\"?" );
277cdf0e10cSrcweir 			seqValues[nProperty] >>= m_bFontWYSIWYG;
278cdf0e10cSrcweir 		}
279cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 1
280cdf0e10cSrcweir 		else DBG_ASSERT( sal_False, "SvtFontOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" );
281cdf0e10cSrcweir 		#endif
282cdf0e10cSrcweir 	}
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir //*****************************************************************************************************************
286cdf0e10cSrcweir //	public method
287cdf0e10cSrcweir //*****************************************************************************************************************
Commit()288cdf0e10cSrcweir void SvtFontOptions_Impl::Commit()
289cdf0e10cSrcweir {
290cdf0e10cSrcweir 	// Get names of supported properties, create a list for values and copy current values to it.
291cdf0e10cSrcweir 	Sequence< OUString >	seqNames	= impl_GetPropertyNames();
292cdf0e10cSrcweir 	sal_Int32				nCount		= seqNames.getLength();
293cdf0e10cSrcweir 	Sequence< Any >			seqValues	( nCount );
294cdf0e10cSrcweir 	for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir         switch( nProperty )
297cdf0e10cSrcweir         {
298cdf0e10cSrcweir             case PROPERTYHANDLE_REPLACEMENTTABLE	:	{
299cdf0e10cSrcweir                 											seqValues[nProperty] <<= m_bReplacementTable;
300cdf0e10cSrcweir 														}
301cdf0e10cSrcweir                 										break;
302cdf0e10cSrcweir             case PROPERTYHANDLE_FONTHISTORY			:	{
303cdf0e10cSrcweir                 											seqValues[nProperty] <<= m_bFontHistory;
304cdf0e10cSrcweir 														}
305cdf0e10cSrcweir                 										break;
306cdf0e10cSrcweir             case PROPERTYHANDLE_FONTWYSIWYG			:	{
307cdf0e10cSrcweir                 											seqValues[nProperty] <<= m_bFontWYSIWYG;
308cdf0e10cSrcweir 														}
309cdf0e10cSrcweir                 										break;
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir 	}
312cdf0e10cSrcweir 	// Set properties in configuration.
313cdf0e10cSrcweir 	PutProperties( seqNames, seqValues );
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir //*****************************************************************************************************************
317cdf0e10cSrcweir //	public method
318cdf0e10cSrcweir //*****************************************************************************************************************
IsReplacementTableEnabled() const319cdf0e10cSrcweir sal_Bool SvtFontOptions_Impl::IsReplacementTableEnabled() const
320cdf0e10cSrcweir {
321cdf0e10cSrcweir 	return m_bReplacementTable;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir //*****************************************************************************************************************
325cdf0e10cSrcweir //	public method
326cdf0e10cSrcweir //*****************************************************************************************************************
EnableReplacementTable(sal_Bool bState)327cdf0e10cSrcweir void SvtFontOptions_Impl::EnableReplacementTable( sal_Bool bState )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	m_bReplacementTable = bState;
330cdf0e10cSrcweir 	SetModified();
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir //*****************************************************************************************************************
334cdf0e10cSrcweir //	public method
335cdf0e10cSrcweir //*****************************************************************************************************************
IsFontHistoryEnabled() const336cdf0e10cSrcweir sal_Bool SvtFontOptions_Impl::IsFontHistoryEnabled() const
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 	return m_bFontHistory;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir //*****************************************************************************************************************
342cdf0e10cSrcweir //	public method
343cdf0e10cSrcweir //*****************************************************************************************************************
EnableFontHistory(sal_Bool bState)344cdf0e10cSrcweir void SvtFontOptions_Impl::EnableFontHistory( sal_Bool bState )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	m_bFontHistory = bState;
347cdf0e10cSrcweir 	SetModified();
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir //*****************************************************************************************************************
351cdf0e10cSrcweir //	public method
352cdf0e10cSrcweir //*****************************************************************************************************************
IsFontWYSIWYGEnabled() const353cdf0e10cSrcweir sal_Bool SvtFontOptions_Impl::IsFontWYSIWYGEnabled() const
354cdf0e10cSrcweir {
355cdf0e10cSrcweir 	return m_bFontWYSIWYG;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir //*****************************************************************************************************************
359cdf0e10cSrcweir //	public method
360cdf0e10cSrcweir //*****************************************************************************************************************
EnableFontWYSIWYG(sal_Bool bState)361cdf0e10cSrcweir void SvtFontOptions_Impl::EnableFontWYSIWYG( sal_Bool bState )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	m_bFontWYSIWYG = bState;
364cdf0e10cSrcweir 	SetModified();
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir //*****************************************************************************************************************
368cdf0e10cSrcweir //	private method
369cdf0e10cSrcweir //*****************************************************************************************************************
impl_GetPropertyNames()370cdf0e10cSrcweir Sequence< OUString > SvtFontOptions_Impl::impl_GetPropertyNames()
371cdf0e10cSrcweir {
372cdf0e10cSrcweir 	// Build static list of configuration key names.
373cdf0e10cSrcweir 	static const OUString pProperties[] =
374cdf0e10cSrcweir 	{
375cdf0e10cSrcweir 		PROPERTYNAME_REPLACEMENTTABLE	,
376cdf0e10cSrcweir 		PROPERTYNAME_FONTHISTORY		,
377cdf0e10cSrcweir 		PROPERTYNAME_FONTWYSIWYG		,
378cdf0e10cSrcweir 	};
379cdf0e10cSrcweir 	// Initialize return sequence with these list ...
380cdf0e10cSrcweir 	static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
381cdf0e10cSrcweir 	// ... and return it.
382cdf0e10cSrcweir 	return seqPropertyNames;
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir //*****************************************************************************************************************
386cdf0e10cSrcweir //	initialize static member
387cdf0e10cSrcweir //	DON'T DO IT IN YOUR HEADER!
388cdf0e10cSrcweir //	see definition for further informations
389cdf0e10cSrcweir //*****************************************************************************************************************
390cdf0e10cSrcweir SvtFontOptions_Impl*	SvtFontOptions::m_pDataContainer	= NULL	;
391cdf0e10cSrcweir sal_Int32				SvtFontOptions::m_nRefCount			= 0		;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir //*****************************************************************************************************************
394cdf0e10cSrcweir //	constructor
395cdf0e10cSrcweir //*****************************************************************************************************************
SvtFontOptions()396cdf0e10cSrcweir SvtFontOptions::SvtFontOptions()
397cdf0e10cSrcweir {
398cdf0e10cSrcweir     // Global access, must be guarded (multithreading!).
399cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
400cdf0e10cSrcweir 	// Increase ouer refcount ...
401cdf0e10cSrcweir 	++m_nRefCount;
402cdf0e10cSrcweir 	// ... and initialize ouer data container only if it not already exist!
403cdf0e10cSrcweir     if( m_pDataContainer == NULL )
404cdf0e10cSrcweir 	{
405cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtFontOptions_Impl::ctor()");
406cdf0e10cSrcweir         m_pDataContainer = new SvtFontOptions_Impl;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir         ItemHolder1::holdConfigItem(E_FONTOPTIONS);
409cdf0e10cSrcweir 	}
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir //*****************************************************************************************************************
413cdf0e10cSrcweir //	destructor
414cdf0e10cSrcweir //*****************************************************************************************************************
~SvtFontOptions()415cdf0e10cSrcweir SvtFontOptions::~SvtFontOptions()
416cdf0e10cSrcweir {
417cdf0e10cSrcweir     // Global access, must be guarded (multithreading!)
418cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
419cdf0e10cSrcweir 	// Decrease ouer refcount.
420cdf0e10cSrcweir 	--m_nRefCount;
421cdf0e10cSrcweir 	// If last instance was deleted ...
422cdf0e10cSrcweir 	// we must destroy ouer static data container!
423cdf0e10cSrcweir     if( m_nRefCount <= 0 )
424cdf0e10cSrcweir 	{
425cdf0e10cSrcweir 		delete m_pDataContainer;
426cdf0e10cSrcweir 		m_pDataContainer = NULL;
427cdf0e10cSrcweir 	}
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir //*****************************************************************************************************************
431cdf0e10cSrcweir //	public method
432cdf0e10cSrcweir //*****************************************************************************************************************
IsReplacementTableEnabled() const433cdf0e10cSrcweir sal_Bool SvtFontOptions::IsReplacementTableEnabled() const
434cdf0e10cSrcweir {
435cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
436cdf0e10cSrcweir 	return m_pDataContainer->IsReplacementTableEnabled();
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
439cdf0e10cSrcweir //*****************************************************************************************************************
440cdf0e10cSrcweir //	public method
441cdf0e10cSrcweir //*****************************************************************************************************************
EnableReplacementTable(sal_Bool bState)442cdf0e10cSrcweir void SvtFontOptions::EnableReplacementTable( sal_Bool bState )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
445cdf0e10cSrcweir 	m_pDataContainer->EnableReplacementTable( bState );
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir //*****************************************************************************************************************
449cdf0e10cSrcweir //	public method
450cdf0e10cSrcweir //*****************************************************************************************************************
IsFontHistoryEnabled() const451cdf0e10cSrcweir sal_Bool SvtFontOptions::IsFontHistoryEnabled() const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
454cdf0e10cSrcweir 	return m_pDataContainer->IsFontHistoryEnabled();
455cdf0e10cSrcweir }
456cdf0e10cSrcweir 
457cdf0e10cSrcweir //*****************************************************************************************************************
458cdf0e10cSrcweir //	public method
459cdf0e10cSrcweir //*****************************************************************************************************************
EnableFontHistory(sal_Bool bState)460cdf0e10cSrcweir void SvtFontOptions::EnableFontHistory( sal_Bool bState )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
463cdf0e10cSrcweir 	m_pDataContainer->EnableFontHistory( bState );
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir //*****************************************************************************************************************
467cdf0e10cSrcweir //	public method
468cdf0e10cSrcweir //*****************************************************************************************************************
IsFontWYSIWYGEnabled() const469cdf0e10cSrcweir sal_Bool SvtFontOptions::IsFontWYSIWYGEnabled() const
470cdf0e10cSrcweir {
471cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
472cdf0e10cSrcweir 	return m_pDataContainer->IsFontWYSIWYGEnabled();
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir //*****************************************************************************************************************
476cdf0e10cSrcweir //	public method
477cdf0e10cSrcweir //*****************************************************************************************************************
EnableFontWYSIWYG(sal_Bool bState)478cdf0e10cSrcweir void SvtFontOptions::EnableFontWYSIWYG( sal_Bool bState )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir     MutexGuard aGuard( impl_GetOwnStaticMutex() );
481cdf0e10cSrcweir 	m_pDataContainer->EnableFontWYSIWYG( bState );
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir //*****************************************************************************************************************
485cdf0e10cSrcweir //	private method
486cdf0e10cSrcweir //*****************************************************************************************************************
impl_GetOwnStaticMutex()487cdf0e10cSrcweir Mutex& SvtFontOptions::impl_GetOwnStaticMutex()
488cdf0e10cSrcweir {
489cdf0e10cSrcweir 	// Initialize static mutex only for one time!
490cdf0e10cSrcweir     static Mutex* pMutex = NULL;
491cdf0e10cSrcweir 	// If these method first called (Mutex not already exist!) ...
492cdf0e10cSrcweir     if( pMutex == NULL )
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir 		// ... we must create a new one. Protect follow code with the global mutex -
495cdf0e10cSrcweir 		// It must be - we create a static variable!
496cdf0e10cSrcweir         MutexGuard aGuard( Mutex::getGlobalMutex() );
497cdf0e10cSrcweir 		// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
498cdf0e10cSrcweir         if( pMutex == NULL )
499cdf0e10cSrcweir         {
500cdf0e10cSrcweir 			// Create the new mutex and set it for return on static variable.
501cdf0e10cSrcweir             static Mutex aMutex;
502cdf0e10cSrcweir             pMutex = &aMutex;
503cdf0e10cSrcweir         }
504cdf0e10cSrcweir     }
505cdf0e10cSrcweir 	// Return new created or already existing mutex object.
506cdf0e10cSrcweir     return *pMutex;
507cdf0e10cSrcweir }
508