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