xref: /AOO41X/main/svl/source/config/ctloptions.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <svl/ctloptions.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <svl/languageoptions.hxx>
34*cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
35*cdf0e10cSrcweir #include <unotools/configitem.hxx>
36*cdf0e10cSrcweir #include <tools/debug.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
38*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
39*cdf0e10cSrcweir #include <osl/mutex.hxx>
40*cdf0e10cSrcweir #include <vos/mutex.hxx>
41*cdf0e10cSrcweir #include <svl/smplhint.hxx>
42*cdf0e10cSrcweir #include <rtl/instance.hxx>
43*cdf0e10cSrcweir #include <unotools/syslocale.hxx>
44*cdf0e10cSrcweir #include <itemholder2.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir using namespace ::com::sun::star;
47*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #define ASCII_STR(s)	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
50*cdf0e10cSrcweir #define CFG_READONLY_DEFAULT    sal_False
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir // SvtCJKOptions_Impl ----------------------------------------------------------
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir class SvtCTLOptions_Impl : public utl::ConfigItem
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir private:
57*cdf0e10cSrcweir     sal_Bool						m_bIsLoaded;
58*cdf0e10cSrcweir     sal_Bool						m_bCTLFontEnabled;
59*cdf0e10cSrcweir     sal_Bool						m_bCTLSequenceChecking;
60*cdf0e10cSrcweir 	sal_Bool						m_bCTLRestricted;
61*cdf0e10cSrcweir     sal_Bool                        m_bCTLTypeAndReplace;
62*cdf0e10cSrcweir     SvtCTLOptions::CursorMovement   m_eCTLCursorMovement;
63*cdf0e10cSrcweir 	SvtCTLOptions::TextNumerals		m_eCTLTextNumerals;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     sal_Bool                        m_bROCTLFontEnabled;
66*cdf0e10cSrcweir     sal_Bool                        m_bROCTLSequenceChecking;
67*cdf0e10cSrcweir 	sal_Bool						m_bROCTLRestricted;
68*cdf0e10cSrcweir     sal_Bool                        m_bROCTLTypeAndReplace;
69*cdf0e10cSrcweir     sal_Bool                        m_bROCTLCursorMovement;
70*cdf0e10cSrcweir     sal_Bool                        m_bROCTLTextNumerals;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir public:
73*cdf0e10cSrcweir     SvtCTLOptions_Impl();
74*cdf0e10cSrcweir     ~SvtCTLOptions_Impl();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	virtual void 	Notify( const Sequence< rtl::OUString >& _aPropertyNames );
77*cdf0e10cSrcweir 	virtual void	Commit();
78*cdf0e10cSrcweir     void            Load();
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     sal_Bool 		IsLoaded() { return m_bIsLoaded; }
81*cdf0e10cSrcweir     void			SetCTLFontEnabled( sal_Bool _bEnabled );
82*cdf0e10cSrcweir     sal_Bool		IsCTLFontEnabled() const { return m_bCTLFontEnabled; }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     void            SetCTLSequenceChecking( sal_Bool _bEnabled );
85*cdf0e10cSrcweir     sal_Bool        IsCTLSequenceChecking() const { return m_bCTLSequenceChecking;}
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 	void			SetCTLSequenceCheckingRestricted( sal_Bool _bEnable );
88*cdf0e10cSrcweir 	sal_Bool		IsCTLSequenceCheckingRestricted( void ) const	{ return m_bCTLRestricted; }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     void            SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable );
91*cdf0e10cSrcweir     sal_Bool        IsCTLSequenceCheckingTypeAndReplace() const { return m_bCTLTypeAndReplace; }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     void            SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement );
94*cdf0e10cSrcweir     SvtCTLOptions::CursorMovement
95*cdf0e10cSrcweir 					GetCTLCursorMovement() const { return m_eCTLCursorMovement; }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	void        	SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals );
98*cdf0e10cSrcweir     SvtCTLOptions::TextNumerals
99*cdf0e10cSrcweir 					GetCTLTextNumerals() const { return m_eCTLTextNumerals; }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     sal_Bool        IsReadOnly(SvtCTLOptions::EOption eOption) const;
102*cdf0e10cSrcweir };
103*cdf0e10cSrcweir //------------------------------------------------------------------------------
104*cdf0e10cSrcweir namespace
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir     struct PropertyNames
107*cdf0e10cSrcweir         : public rtl::Static< Sequence< rtl::OUString >, PropertyNames > {};
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir //------------------------------------------------------------------------------
110*cdf0e10cSrcweir sal_Bool SvtCTLOptions_Impl::IsReadOnly(SvtCTLOptions::EOption eOption) const
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir     sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
113*cdf0e10cSrcweir     switch(eOption)
114*cdf0e10cSrcweir     {
115*cdf0e10cSrcweir         case SvtCTLOptions::E_CTLFONT             : bReadOnly = m_bROCTLFontEnabled       ; break;
116*cdf0e10cSrcweir         case SvtCTLOptions::E_CTLSEQUENCECHECKING : bReadOnly = m_bROCTLSequenceChecking  ; break;
117*cdf0e10cSrcweir         case SvtCTLOptions::E_CTLCURSORMOVEMENT   : bReadOnly = m_bROCTLCursorMovement    ; break;
118*cdf0e10cSrcweir         case SvtCTLOptions::E_CTLTEXTNUMERALS     : bReadOnly = m_bROCTLTextNumerals      ; break;
119*cdf0e10cSrcweir 		case SvtCTLOptions::E_CTLSEQUENCECHECKINGRESTRICTED: bReadOnly = m_bROCTLRestricted  ; break;
120*cdf0e10cSrcweir         case SvtCTLOptions::E_CTLSEQUENCECHECKINGTYPEANDREPLACE: bReadOnly = m_bROCTLTypeAndReplace; break;
121*cdf0e10cSrcweir         default: DBG_ERROR(  "SvtCTLOptions_Impl::IsReadOnly() - invalid option" );
122*cdf0e10cSrcweir     }
123*cdf0e10cSrcweir     return bReadOnly;
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir //------------------------------------------------------------------------------
126*cdf0e10cSrcweir SvtCTLOptions_Impl::SvtCTLOptions_Impl() :
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     utl::ConfigItem( ASCII_STR("Office.Common/I18N/CTL") ),
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	m_bIsLoaded				( sal_False ),
131*cdf0e10cSrcweir     m_bCTLFontEnabled		( sal_False ),
132*cdf0e10cSrcweir     m_bCTLSequenceChecking	( sal_False ),
133*cdf0e10cSrcweir 	m_bCTLRestricted		( sal_False ),
134*cdf0e10cSrcweir 	m_eCTLCursorMovement	( SvtCTLOptions::MOVEMENT_LOGICAL ),
135*cdf0e10cSrcweir     m_eCTLTextNumerals      ( SvtCTLOptions::NUMERALS_ARABIC ),
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     m_bROCTLFontEnabled     ( CFG_READONLY_DEFAULT ),
138*cdf0e10cSrcweir     m_bROCTLSequenceChecking( CFG_READONLY_DEFAULT ),
139*cdf0e10cSrcweir 	m_bROCTLRestricted		( CFG_READONLY_DEFAULT ),
140*cdf0e10cSrcweir     m_bROCTLCursorMovement  ( CFG_READONLY_DEFAULT ),
141*cdf0e10cSrcweir     m_bROCTLTextNumerals    ( CFG_READONLY_DEFAULT )
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir //------------------------------------------------------------------------------
145*cdf0e10cSrcweir SvtCTLOptions_Impl::~SvtCTLOptions_Impl()
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir     if ( IsModified() == sal_True )
148*cdf0e10cSrcweir 		Commit();
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir // -----------------------------------------------------------------------------
151*cdf0e10cSrcweir void SvtCTLOptions_Impl::Notify( const Sequence< rtl::OUString >& )
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir     Load();
154*cdf0e10cSrcweir     NotifyListeners(SFX_HINT_CTL_SETTINGS_CHANGED);
155*cdf0e10cSrcweir }
156*cdf0e10cSrcweir // -----------------------------------------------------------------------------
157*cdf0e10cSrcweir void SvtCTLOptions_Impl::Commit()
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     Sequence< rtl::OUString > &rPropertyNames = PropertyNames::get();
160*cdf0e10cSrcweir     rtl::OUString* pOrgNames = rPropertyNames.getArray();
161*cdf0e10cSrcweir     sal_Int32 nOrgCount = rPropertyNames.getLength();
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     Sequence< rtl::OUString > aNames( nOrgCount );
164*cdf0e10cSrcweir     Sequence< Any > aValues( nOrgCount );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     rtl::OUString* pNames = aNames.getArray();
167*cdf0e10cSrcweir     Any* pValues = aValues.getArray();
168*cdf0e10cSrcweir     sal_Int32 nRealCount = 0;
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     const uno::Type& rType = ::getBooleanCppuType();
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     for ( int nProp = 0; nProp < nOrgCount; nProp++ )
173*cdf0e10cSrcweir 	{
174*cdf0e10cSrcweir 		switch ( nProp )
175*cdf0e10cSrcweir 		{
176*cdf0e10cSrcweir             case  0:
177*cdf0e10cSrcweir             {
178*cdf0e10cSrcweir                 if (!m_bROCTLFontEnabled)
179*cdf0e10cSrcweir                 {
180*cdf0e10cSrcweir                     pNames[nRealCount] = pOrgNames[nProp];
181*cdf0e10cSrcweir                     pValues[nRealCount].setValue( &m_bCTLFontEnabled, rType );
182*cdf0e10cSrcweir                     ++nRealCount;
183*cdf0e10cSrcweir                 }
184*cdf0e10cSrcweir             }
185*cdf0e10cSrcweir             break;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir             case  1:
188*cdf0e10cSrcweir             {
189*cdf0e10cSrcweir                 if (!m_bROCTLSequenceChecking)
190*cdf0e10cSrcweir                 {
191*cdf0e10cSrcweir                     pNames[nRealCount] = pOrgNames[nProp];
192*cdf0e10cSrcweir                     pValues[nRealCount].setValue( &m_bCTLSequenceChecking, rType );
193*cdf0e10cSrcweir                     ++nRealCount;
194*cdf0e10cSrcweir                 }
195*cdf0e10cSrcweir             }
196*cdf0e10cSrcweir             break;
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir             case  2:
199*cdf0e10cSrcweir             {
200*cdf0e10cSrcweir                 if (!m_bROCTLCursorMovement)
201*cdf0e10cSrcweir                 {
202*cdf0e10cSrcweir                     pNames[nRealCount] = pOrgNames[nProp];
203*cdf0e10cSrcweir                     pValues[nRealCount] <<= (sal_Int32)m_eCTLCursorMovement;
204*cdf0e10cSrcweir                     ++nRealCount;
205*cdf0e10cSrcweir                 }
206*cdf0e10cSrcweir             }
207*cdf0e10cSrcweir             break;
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir             case  3:
210*cdf0e10cSrcweir             {
211*cdf0e10cSrcweir                 if (!m_bROCTLTextNumerals)
212*cdf0e10cSrcweir                 {
213*cdf0e10cSrcweir                     pNames[nRealCount] = pOrgNames[nProp];
214*cdf0e10cSrcweir                     pValues[nRealCount] <<= (sal_Int32)m_eCTLTextNumerals;
215*cdf0e10cSrcweir                     ++nRealCount;
216*cdf0e10cSrcweir                 }
217*cdf0e10cSrcweir             }
218*cdf0e10cSrcweir 			break;
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 			case  4:
221*cdf0e10cSrcweir 			{
222*cdf0e10cSrcweir 				if (!m_bROCTLRestricted)
223*cdf0e10cSrcweir 				{
224*cdf0e10cSrcweir 					pNames[nRealCount] = pOrgNames[nProp];
225*cdf0e10cSrcweir 					pValues[nRealCount].setValue( &m_bCTLRestricted, rType );
226*cdf0e10cSrcweir 					++nRealCount;
227*cdf0e10cSrcweir 				}
228*cdf0e10cSrcweir 			}
229*cdf0e10cSrcweir             break;
230*cdf0e10cSrcweir             case 5:
231*cdf0e10cSrcweir             {
232*cdf0e10cSrcweir                 if(!m_bROCTLTypeAndReplace)
233*cdf0e10cSrcweir                 {
234*cdf0e10cSrcweir                     pNames[nRealCount] = pOrgNames[nProp];
235*cdf0e10cSrcweir                     pValues[nRealCount].setValue( &m_bCTLTypeAndReplace, rType );
236*cdf0e10cSrcweir 					++nRealCount;
237*cdf0e10cSrcweir                 }
238*cdf0e10cSrcweir             }
239*cdf0e10cSrcweir             break;
240*cdf0e10cSrcweir         }
241*cdf0e10cSrcweir 	}
242*cdf0e10cSrcweir     aNames.realloc(nRealCount);
243*cdf0e10cSrcweir     aValues.realloc(nRealCount);
244*cdf0e10cSrcweir     PutProperties( aNames, aValues );
245*cdf0e10cSrcweir     //broadcast changes
246*cdf0e10cSrcweir     NotifyListeners(SFX_HINT_CTL_SETTINGS_CHANGED);
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir // -----------------------------------------------------------------------------
249*cdf0e10cSrcweir void SvtCTLOptions_Impl::Load()
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     Sequence< rtl::OUString >& rPropertyNames = PropertyNames::get();
252*cdf0e10cSrcweir     if ( !rPropertyNames.getLength() )
253*cdf0e10cSrcweir     {
254*cdf0e10cSrcweir         rPropertyNames.realloc(6);
255*cdf0e10cSrcweir         rtl::OUString* pNames = rPropertyNames.getArray();
256*cdf0e10cSrcweir 		pNames[0] = ASCII_STR("CTLFont");
257*cdf0e10cSrcweir         pNames[1] = ASCII_STR("CTLSequenceChecking");
258*cdf0e10cSrcweir         pNames[2] = ASCII_STR("CTLCursorMovement");
259*cdf0e10cSrcweir         pNames[3] = ASCII_STR("CTLTextNumerals");
260*cdf0e10cSrcweir         pNames[4] = ASCII_STR("CTLSequenceCheckingRestricted");
261*cdf0e10cSrcweir         pNames[5] = ASCII_STR("CTLSequenceCheckingTypeAndReplace");
262*cdf0e10cSrcweir         EnableNotification( rPropertyNames );
263*cdf0e10cSrcweir     }
264*cdf0e10cSrcweir     Sequence< Any > aValues = GetProperties( rPropertyNames );
265*cdf0e10cSrcweir     Sequence< sal_Bool > aROStates = GetReadOnlyStates( rPropertyNames );
266*cdf0e10cSrcweir     const Any* pValues = aValues.getConstArray();
267*cdf0e10cSrcweir     const sal_Bool* pROStates = aROStates.getConstArray();
268*cdf0e10cSrcweir     DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
269*cdf0e10cSrcweir     DBG_ASSERT( aROStates.getLength() == rPropertyNames.getLength(), "GetReadOnlyStates failed" );
270*cdf0e10cSrcweir     if ( aValues.getLength() == rPropertyNames.getLength() && aROStates.getLength() == rPropertyNames.getLength() )
271*cdf0e10cSrcweir 	{
272*cdf0e10cSrcweir 		sal_Bool bValue = sal_False;
273*cdf0e10cSrcweir 		sal_Int32 nValue = 0;
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir         for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
276*cdf0e10cSrcweir 		{
277*cdf0e10cSrcweir             if ( pValues[nProp].hasValue() )
278*cdf0e10cSrcweir 			{
279*cdf0e10cSrcweir                 if ( pValues[nProp] >>= bValue )
280*cdf0e10cSrcweir 				{
281*cdf0e10cSrcweir                 	switch ( nProp )
282*cdf0e10cSrcweir                 	{
283*cdf0e10cSrcweir                         case 0: { m_bCTLFontEnabled = bValue; m_bROCTLFontEnabled = pROStates[nProp]; } break;
284*cdf0e10cSrcweir                         case 1: { m_bCTLSequenceChecking = bValue; m_bROCTLSequenceChecking = pROStates[nProp]; } break;
285*cdf0e10cSrcweir                         case 4: { m_bCTLRestricted = bValue; m_bROCTLRestricted = pROStates[nProp]; } break;
286*cdf0e10cSrcweir                         case 5: { m_bCTLTypeAndReplace = bValue; m_bROCTLTypeAndReplace = pROStates[nProp]; } break;
287*cdf0e10cSrcweir                     }
288*cdf0e10cSrcweir 				}
289*cdf0e10cSrcweir                 else if ( pValues[nProp] >>= nValue )
290*cdf0e10cSrcweir 				{
291*cdf0e10cSrcweir                 	switch ( nProp )
292*cdf0e10cSrcweir                 	{
293*cdf0e10cSrcweir                         case 2: { m_eCTLCursorMovement = (SvtCTLOptions::CursorMovement)nValue; m_bROCTLCursorMovement = pROStates[nProp]; } break;
294*cdf0e10cSrcweir                         case 3: { m_eCTLTextNumerals = (SvtCTLOptions::TextNumerals)nValue; m_bROCTLTextNumerals = pROStates[nProp]; } break;
295*cdf0e10cSrcweir                 	}
296*cdf0e10cSrcweir 				}
297*cdf0e10cSrcweir             }
298*cdf0e10cSrcweir         }
299*cdf0e10cSrcweir     }
300*cdf0e10cSrcweir 	sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
301*cdf0e10cSrcweir     SvtSystemLanguageOptions aSystemLocaleSettings;
302*cdf0e10cSrcweir     LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
303*cdf0e10cSrcweir     sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
304*cdf0e10cSrcweir     if( !m_bCTLFontEnabled && (( nType & SCRIPTTYPE_COMPLEX ) ||
305*cdf0e10cSrcweir             ((eSystemLanguage != LANGUAGE_SYSTEM)  && ( nWinScript & SCRIPTTYPE_COMPLEX )))  )
306*cdf0e10cSrcweir 	{
307*cdf0e10cSrcweir 		m_bCTLFontEnabled = sal_True;
308*cdf0e10cSrcweir         sal_uInt16 nLanguage = SvtSysLocale().GetLanguage();
309*cdf0e10cSrcweir         //enable sequence checking for the appropriate languages
310*cdf0e10cSrcweir         m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace =
311*cdf0e10cSrcweir             (MsLangId::needsSequenceChecking( nLanguage) ||
312*cdf0e10cSrcweir              MsLangId::needsSequenceChecking( eSystemLanguage));
313*cdf0e10cSrcweir         Commit();
314*cdf0e10cSrcweir 	}
315*cdf0e10cSrcweir     m_bIsLoaded = sal_True;
316*cdf0e10cSrcweir }
317*cdf0e10cSrcweir //------------------------------------------------------------------------------
318*cdf0e10cSrcweir void SvtCTLOptions_Impl::SetCTLFontEnabled( sal_Bool _bEnabled )
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir     if(!m_bROCTLFontEnabled && m_bCTLFontEnabled != _bEnabled)
321*cdf0e10cSrcweir     {
322*cdf0e10cSrcweir         m_bCTLFontEnabled = _bEnabled;
323*cdf0e10cSrcweir         SetModified();
324*cdf0e10cSrcweir 		NotifyListeners(0);
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir //------------------------------------------------------------------------------
328*cdf0e10cSrcweir void SvtCTLOptions_Impl::SetCTLSequenceChecking( sal_Bool _bEnabled )
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir     if(!m_bROCTLSequenceChecking && m_bCTLSequenceChecking != _bEnabled)
331*cdf0e10cSrcweir     {
332*cdf0e10cSrcweir         SetModified();
333*cdf0e10cSrcweir         m_bCTLSequenceChecking = _bEnabled;
334*cdf0e10cSrcweir 		NotifyListeners(0);
335*cdf0e10cSrcweir     }
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir //------------------------------------------------------------------------------
338*cdf0e10cSrcweir void SvtCTLOptions_Impl::SetCTLSequenceCheckingRestricted( sal_Bool _bEnabled )
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir     if(!m_bROCTLRestricted && m_bCTLRestricted != _bEnabled)
341*cdf0e10cSrcweir     {
342*cdf0e10cSrcweir         SetModified();
343*cdf0e10cSrcweir         m_bCTLRestricted = _bEnabled;
344*cdf0e10cSrcweir 		NotifyListeners(0);
345*cdf0e10cSrcweir     }
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir //------------------------------------------------------------------------------
348*cdf0e10cSrcweir void  SvtCTLOptions_Impl::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnabled )
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir     if(!m_bROCTLTypeAndReplace && m_bCTLTypeAndReplace != _bEnabled)
351*cdf0e10cSrcweir     {
352*cdf0e10cSrcweir         SetModified();
353*cdf0e10cSrcweir         m_bCTLTypeAndReplace = _bEnabled;
354*cdf0e10cSrcweir 		NotifyListeners(0);
355*cdf0e10cSrcweir     }
356*cdf0e10cSrcweir }
357*cdf0e10cSrcweir //------------------------------------------------------------------------------
358*cdf0e10cSrcweir void SvtCTLOptions_Impl::SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement )
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir     if (!m_bROCTLCursorMovement && m_eCTLCursorMovement != _eMovement )
361*cdf0e10cSrcweir     {
362*cdf0e10cSrcweir         SetModified();
363*cdf0e10cSrcweir         m_eCTLCursorMovement = _eMovement;
364*cdf0e10cSrcweir 		NotifyListeners(0);
365*cdf0e10cSrcweir     }
366*cdf0e10cSrcweir }
367*cdf0e10cSrcweir //------------------------------------------------------------------------------
368*cdf0e10cSrcweir void SvtCTLOptions_Impl::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     if (!m_bROCTLTextNumerals && m_eCTLTextNumerals != _eNumerals )
371*cdf0e10cSrcweir     {
372*cdf0e10cSrcweir         SetModified();
373*cdf0e10cSrcweir         m_eCTLTextNumerals = _eNumerals;
374*cdf0e10cSrcweir 		NotifyListeners(0);
375*cdf0e10cSrcweir     }
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir // global ----------------------------------------------------------------
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir static SvtCTLOptions_Impl*	pCTLOptions = NULL;
380*cdf0e10cSrcweir static sal_Int32			nCTLRefCount = 0;
381*cdf0e10cSrcweir namespace { struct CTLMutex : public rtl::Static< osl::Mutex, CTLMutex > {}; }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir // class SvtCTLOptions --------------------------------------------------
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir SvtCTLOptions::SvtCTLOptions( sal_Bool bDontLoad )
386*cdf0e10cSrcweir {
387*cdf0e10cSrcweir     // Global access, must be guarded (multithreading)
388*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( CTLMutex::get() );
389*cdf0e10cSrcweir     if ( !pCTLOptions )
390*cdf0e10cSrcweir     {
391*cdf0e10cSrcweir         pCTLOptions = new SvtCTLOptions_Impl;
392*cdf0e10cSrcweir         ItemHolder2::holdConfigItem(E_CTLOPTIONS);
393*cdf0e10cSrcweir     }
394*cdf0e10cSrcweir     if( !bDontLoad && !pCTLOptions->IsLoaded() )
395*cdf0e10cSrcweir         pCTLOptions->Load();
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir     ++nCTLRefCount;
398*cdf0e10cSrcweir     m_pImp = pCTLOptions;
399*cdf0e10cSrcweir     m_pImp->AddListener(this);
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir // -----------------------------------------------------------------------
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir SvtCTLOptions::~SvtCTLOptions()
405*cdf0e10cSrcweir {
406*cdf0e10cSrcweir     // Global access, must be guarded (multithreading)
407*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( CTLMutex::get() );
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     m_pImp->RemoveListener(this);
410*cdf0e10cSrcweir 	if ( !--nCTLRefCount )
411*cdf0e10cSrcweir         DELETEZ( pCTLOptions );
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir // -----------------------------------------------------------------------------
414*cdf0e10cSrcweir void SvtCTLOptions::SetCTLFontEnabled( sal_Bool _bEnabled )
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
417*cdf0e10cSrcweir     pCTLOptions->SetCTLFontEnabled( _bEnabled );
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir // -----------------------------------------------------------------------------
420*cdf0e10cSrcweir sal_Bool SvtCTLOptions::IsCTLFontEnabled() const
421*cdf0e10cSrcweir {
422*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
423*cdf0e10cSrcweir     return pCTLOptions->IsCTLFontEnabled();
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir // -----------------------------------------------------------------------------
426*cdf0e10cSrcweir void SvtCTLOptions::SetCTLSequenceChecking( sal_Bool _bEnabled )
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
429*cdf0e10cSrcweir     pCTLOptions->SetCTLSequenceChecking(_bEnabled);
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir // -----------------------------------------------------------------------------
432*cdf0e10cSrcweir sal_Bool SvtCTLOptions::IsCTLSequenceChecking() const
433*cdf0e10cSrcweir {
434*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
435*cdf0e10cSrcweir     return pCTLOptions->IsCTLSequenceChecking();
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir // -----------------------------------------------------------------------------
438*cdf0e10cSrcweir void SvtCTLOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable )
439*cdf0e10cSrcweir {
440*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
441*cdf0e10cSrcweir 	pCTLOptions->SetCTLSequenceCheckingRestricted(_bEnable);
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir // -----------------------------------------------------------------------------
444*cdf0e10cSrcweir sal_Bool SvtCTLOptions::IsCTLSequenceCheckingRestricted( void ) const
445*cdf0e10cSrcweir {
446*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
447*cdf0e10cSrcweir     return pCTLOptions->IsCTLSequenceCheckingRestricted();
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir // -----------------------------------------------------------------------------
450*cdf0e10cSrcweir void SvtCTLOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable )
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
453*cdf0e10cSrcweir     pCTLOptions->SetCTLSequenceCheckingTypeAndReplace(_bEnable);
454*cdf0e10cSrcweir }
455*cdf0e10cSrcweir // -----------------------------------------------------------------------------
456*cdf0e10cSrcweir sal_Bool SvtCTLOptions::IsCTLSequenceCheckingTypeAndReplace() const
457*cdf0e10cSrcweir {
458*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
459*cdf0e10cSrcweir     return pCTLOptions->IsCTLSequenceCheckingTypeAndReplace();
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir // -----------------------------------------------------------------------------
462*cdf0e10cSrcweir void SvtCTLOptions::SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement )
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
465*cdf0e10cSrcweir     pCTLOptions->SetCTLCursorMovement( _eMovement );
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir // -----------------------------------------------------------------------------
468*cdf0e10cSrcweir SvtCTLOptions::CursorMovement SvtCTLOptions::GetCTLCursorMovement() const
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
471*cdf0e10cSrcweir     return pCTLOptions->GetCTLCursorMovement();
472*cdf0e10cSrcweir }
473*cdf0e10cSrcweir // -----------------------------------------------------------------------------
474*cdf0e10cSrcweir void SvtCTLOptions::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals )
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
477*cdf0e10cSrcweir     pCTLOptions->SetCTLTextNumerals( _eNumerals );
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir // -----------------------------------------------------------------------------
480*cdf0e10cSrcweir SvtCTLOptions::TextNumerals SvtCTLOptions::GetCTLTextNumerals() const
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
483*cdf0e10cSrcweir     return pCTLOptions->GetCTLTextNumerals();
484*cdf0e10cSrcweir }
485*cdf0e10cSrcweir // -----------------------------------------------------------------------------
486*cdf0e10cSrcweir sal_Bool SvtCTLOptions::IsReadOnly(EOption eOption) const
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir     DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" );
489*cdf0e10cSrcweir     return pCTLOptions->IsReadOnly(eOption);
490*cdf0e10cSrcweir }
491*cdf0e10cSrcweir // -----------------------------------------------------------------------------
492*cdf0e10cSrcweir 
493