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
10cdf0e10cSrcweir *
11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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/cjkoptions.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <svl/languageoptions.hxx>
30cdf0e10cSrcweir #include <i18npool/lang.h>
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 <rtl/instance.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <itemholder2.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir using namespace ::com::sun::star::uno;
41cdf0e10cSrcweir using namespace ::rtl;
42cdf0e10cSrcweir
43cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar)
44cdf0e10cSrcweir #define CFG_READONLY_DEFAULT sal_False
45cdf0e10cSrcweir /* -----------------------------10.04.01 12:39--------------------------------
46cdf0e10cSrcweir
47cdf0e10cSrcweir ---------------------------------------------------------------------------*/
48cdf0e10cSrcweir class SvtCJKOptions_Impl : public utl::ConfigItem
49cdf0e10cSrcweir {
50cdf0e10cSrcweir sal_Bool bIsLoaded;
51cdf0e10cSrcweir sal_Bool bCJKFont;
52cdf0e10cSrcweir sal_Bool bVerticalText;
53cdf0e10cSrcweir sal_Bool bAsianTypography;
54cdf0e10cSrcweir sal_Bool bJapaneseFind;
55cdf0e10cSrcweir sal_Bool bRuby;
56cdf0e10cSrcweir sal_Bool bChangeCaseMap;
57cdf0e10cSrcweir sal_Bool bDoubleLines;
58cdf0e10cSrcweir sal_Bool bEmphasisMarks;
59cdf0e10cSrcweir sal_Bool bVerticalCallOut;
60cdf0e10cSrcweir
61cdf0e10cSrcweir sal_Bool bROCJKFont;
62cdf0e10cSrcweir sal_Bool bROVerticalText;
63cdf0e10cSrcweir sal_Bool bROAsianTypography;
64cdf0e10cSrcweir sal_Bool bROJapaneseFind;
65cdf0e10cSrcweir sal_Bool bRORuby;
66cdf0e10cSrcweir sal_Bool bROChangeCaseMap;
67cdf0e10cSrcweir sal_Bool bRODoubleLines;
68cdf0e10cSrcweir sal_Bool bROEmphasisMarks;
69cdf0e10cSrcweir sal_Bool bROVerticalCallOut;
70cdf0e10cSrcweir
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir SvtCJKOptions_Impl();
73cdf0e10cSrcweir ~SvtCJKOptions_Impl();
74cdf0e10cSrcweir
75cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames );
76cdf0e10cSrcweir virtual void Commit();
77cdf0e10cSrcweir void Load();
78cdf0e10cSrcweir
IsLoaded()79cdf0e10cSrcweir sal_Bool IsLoaded() { return bIsLoaded; }
80cdf0e10cSrcweir
IsCJKFontEnabled() const81cdf0e10cSrcweir sal_Bool IsCJKFontEnabled() const { return bCJKFont; }
IsVerticalTextEnabled() const82cdf0e10cSrcweir sal_Bool IsVerticalTextEnabled() const { return bVerticalText; }
IsAsianTypographyEnabled() const83cdf0e10cSrcweir sal_Bool IsAsianTypographyEnabled() const { return bAsianTypography; }
IsJapaneseFindEnabled() const84cdf0e10cSrcweir sal_Bool IsJapaneseFindEnabled() const { return bJapaneseFind; }
IsRubyEnabled() const85cdf0e10cSrcweir sal_Bool IsRubyEnabled() const { return bRuby; }
IsChangeCaseMapEnabled() const86cdf0e10cSrcweir sal_Bool IsChangeCaseMapEnabled() const { return bChangeCaseMap; }
IsDoubleLinesEnabled() const87cdf0e10cSrcweir sal_Bool IsDoubleLinesEnabled() const { return bDoubleLines; }
IsEmphasisMarksEnabled() const88cdf0e10cSrcweir sal_Bool IsEmphasisMarksEnabled() const { return bEmphasisMarks; }
IsVerticalCallOutEnabled() const89cdf0e10cSrcweir sal_Bool IsVerticalCallOutEnabled() const { return bVerticalCallOut; }
90cdf0e10cSrcweir
IsAnyEnabled() const91cdf0e10cSrcweir sal_Bool IsAnyEnabled() const {
92cdf0e10cSrcweir return bCJKFont||bVerticalText||bAsianTypography||bJapaneseFind||
93cdf0e10cSrcweir bRuby||bChangeCaseMap||bDoubleLines||bEmphasisMarks||bVerticalCallOut; }
94cdf0e10cSrcweir void SetAll(sal_Bool bSet);
95cdf0e10cSrcweir sal_Bool IsReadOnly(SvtCJKOptions::EOption eOption) const;
96cdf0e10cSrcweir };
97cdf0e10cSrcweir /*-- 10.04.01 12:41:57---------------------------------------------------
98cdf0e10cSrcweir
99cdf0e10cSrcweir -----------------------------------------------------------------------*/
100cdf0e10cSrcweir namespace
101cdf0e10cSrcweir {
102cdf0e10cSrcweir struct PropertyNames
103cdf0e10cSrcweir : public rtl::Static< Sequence<OUString>, PropertyNames > {};
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
SvtCJKOptions_Impl()106cdf0e10cSrcweir SvtCJKOptions_Impl::SvtCJKOptions_Impl() :
107cdf0e10cSrcweir utl::ConfigItem(C2U("Office.Common/I18N/CJK")),
108cdf0e10cSrcweir bIsLoaded(sal_False),
109cdf0e10cSrcweir bCJKFont(sal_True),
110cdf0e10cSrcweir bVerticalText(sal_True),
111cdf0e10cSrcweir bAsianTypography(sal_True),
112cdf0e10cSrcweir bJapaneseFind(sal_True),
113cdf0e10cSrcweir bRuby(sal_True),
114cdf0e10cSrcweir bChangeCaseMap(sal_True),
115cdf0e10cSrcweir bDoubleLines(sal_True),
116cdf0e10cSrcweir bEmphasisMarks(sal_True),
117cdf0e10cSrcweir bVerticalCallOut(sal_True),
118cdf0e10cSrcweir bROCJKFont(CFG_READONLY_DEFAULT),
119cdf0e10cSrcweir bROVerticalText(CFG_READONLY_DEFAULT),
120cdf0e10cSrcweir bROAsianTypography(CFG_READONLY_DEFAULT),
121cdf0e10cSrcweir bROJapaneseFind(CFG_READONLY_DEFAULT),
122cdf0e10cSrcweir bRORuby(CFG_READONLY_DEFAULT),
123cdf0e10cSrcweir bROChangeCaseMap(CFG_READONLY_DEFAULT),
124cdf0e10cSrcweir bRODoubleLines(CFG_READONLY_DEFAULT),
125cdf0e10cSrcweir bROEmphasisMarks(CFG_READONLY_DEFAULT),
126cdf0e10cSrcweir bROVerticalCallOut(CFG_READONLY_DEFAULT)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir }
129cdf0e10cSrcweir /*-- 10.04.01 12:41:57---------------------------------------------------
130cdf0e10cSrcweir
131cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SvtCJKOptions_Impl()132cdf0e10cSrcweir SvtCJKOptions_Impl::~SvtCJKOptions_Impl()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir }
135cdf0e10cSrcweir /* -----------------------------20.04.01 14:34--------------------------------
136cdf0e10cSrcweir
137cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SetAll(sal_Bool bSet)138cdf0e10cSrcweir void SvtCJKOptions_Impl::SetAll(sal_Bool bSet)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir if (
141cdf0e10cSrcweir !bROCJKFont &&
142cdf0e10cSrcweir !bROVerticalText &&
143cdf0e10cSrcweir !bROAsianTypography &&
144cdf0e10cSrcweir !bROJapaneseFind &&
145cdf0e10cSrcweir !bRORuby &&
146cdf0e10cSrcweir !bROChangeCaseMap &&
147cdf0e10cSrcweir !bRODoubleLines &&
148cdf0e10cSrcweir !bROEmphasisMarks &&
149cdf0e10cSrcweir !bROVerticalCallOut
150cdf0e10cSrcweir )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir bCJKFont=bSet;
153cdf0e10cSrcweir bVerticalText=bSet;
154cdf0e10cSrcweir bAsianTypography=bSet;
155cdf0e10cSrcweir bJapaneseFind=bSet;
156cdf0e10cSrcweir bRuby=bSet;
157cdf0e10cSrcweir bChangeCaseMap=bSet;
158cdf0e10cSrcweir bDoubleLines=bSet;
159cdf0e10cSrcweir bEmphasisMarks=bSet;
160cdf0e10cSrcweir bVerticalCallOut=bSet;
161cdf0e10cSrcweir
162cdf0e10cSrcweir SetModified();
163cdf0e10cSrcweir Commit();
164cdf0e10cSrcweir NotifyListeners(0);
165cdf0e10cSrcweir }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir /*-- 10.04.01 12:41:56---------------------------------------------------
168cdf0e10cSrcweir
169cdf0e10cSrcweir -----------------------------------------------------------------------*/
Load()170cdf0e10cSrcweir void SvtCJKOptions_Impl::Load()
171cdf0e10cSrcweir {
172cdf0e10cSrcweir Sequence<OUString> &rPropertyNames = PropertyNames::get();
173cdf0e10cSrcweir if(!rPropertyNames.getLength())
174cdf0e10cSrcweir {
175cdf0e10cSrcweir rPropertyNames.realloc(9);
176cdf0e10cSrcweir OUString* pNames = rPropertyNames.getArray();
177cdf0e10cSrcweir
178cdf0e10cSrcweir pNames[0] = C2U("CJKFont");
179cdf0e10cSrcweir pNames[1] = C2U("VerticalText");
180cdf0e10cSrcweir pNames[2] = C2U("AsianTypography");
181cdf0e10cSrcweir pNames[3] = C2U("JapaneseFind");
182cdf0e10cSrcweir pNames[4] = C2U("Ruby");
183cdf0e10cSrcweir pNames[5] = C2U("ChangeCaseMap");
184cdf0e10cSrcweir pNames[6] = C2U("DoubleLines");
185cdf0e10cSrcweir pNames[7] = C2U("EmphasisMarks");
186cdf0e10cSrcweir pNames[8] = C2U("VerticalCallOut");
187cdf0e10cSrcweir
188cdf0e10cSrcweir EnableNotification( rPropertyNames );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir Sequence< Any > aValues = GetProperties(rPropertyNames);
191cdf0e10cSrcweir Sequence< sal_Bool > aROStates = GetReadOnlyStates(rPropertyNames);
192cdf0e10cSrcweir const Any* pValues = aValues.getConstArray();
193cdf0e10cSrcweir const sal_Bool* pROStates = aROStates.getConstArray();
194cdf0e10cSrcweir DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" );
195cdf0e10cSrcweir DBG_ASSERT( aROStates.getLength() == rPropertyNames.getLength(), "GetReadOnlyStates failed" );
196cdf0e10cSrcweir if ( aValues.getLength() == rPropertyNames.getLength() && aROStates.getLength() == rPropertyNames.getLength() )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir if( pValues[nProp].hasValue() )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir sal_Bool bValue = *(sal_Bool*)pValues[nProp].getValue();
203cdf0e10cSrcweir switch ( nProp )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir case 0: { bCJKFont = bValue; bROCJKFont = pROStates[nProp]; } break;
206cdf0e10cSrcweir case 1: { bVerticalText = bValue; bROVerticalText = pROStates[nProp]; } break;
207cdf0e10cSrcweir case 2: { bAsianTypography = bValue; bROAsianTypography = pROStates[nProp]; } break;
208cdf0e10cSrcweir case 3: { bJapaneseFind = bValue; bROJapaneseFind = pROStates[nProp]; } break;
209cdf0e10cSrcweir case 4: { bRuby = bValue; bRORuby = pROStates[nProp]; } break;
210cdf0e10cSrcweir case 5: { bChangeCaseMap = bValue; bROChangeCaseMap = pROStates[nProp]; } break;
211cdf0e10cSrcweir case 6: { bDoubleLines = bValue; bRODoubleLines = pROStates[nProp]; } break;
212cdf0e10cSrcweir case 7: { bEmphasisMarks = bValue; bROEmphasisMarks = pROStates[nProp]; } break;
213cdf0e10cSrcweir case 8: { bVerticalCallOut = bValue; bROVerticalCallOut = pROStates[nProp]; } break;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir }
216cdf0e10cSrcweir }
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
219cdf0e10cSrcweir SvtSystemLanguageOptions aSystemLocaleSettings;
220cdf0e10cSrcweir LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
221cdf0e10cSrcweir sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
222cdf0e10cSrcweir
223cdf0e10cSrcweir sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
224cdf0e10cSrcweir if ( !bCJKFont && (( nScriptType & SCRIPTTYPE_ASIAN )||
225cdf0e10cSrcweir ((eSystemLanguage != LANGUAGE_SYSTEM) && ( nWinScript & SCRIPTTYPE_ASIAN ))))
226cdf0e10cSrcweir {
227cdf0e10cSrcweir SetAll(sal_True);
228cdf0e10cSrcweir }
229cdf0e10cSrcweir bIsLoaded = sal_True;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir /*-- 10.04.01 12:41:57---------------------------------------------------
232cdf0e10cSrcweir
233cdf0e10cSrcweir -----------------------------------------------------------------------*/
Notify(const Sequence<OUString> &)234cdf0e10cSrcweir void SvtCJKOptions_Impl::Notify( const Sequence< OUString >& )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir Load();
237cdf0e10cSrcweir NotifyListeners(0);
238cdf0e10cSrcweir }
239cdf0e10cSrcweir /*-- 10.04.01 12:41:57---------------------------------------------------
240cdf0e10cSrcweir
241cdf0e10cSrcweir -----------------------------------------------------------------------*/
Commit()242cdf0e10cSrcweir void SvtCJKOptions_Impl::Commit()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir Sequence<OUString> &rPropertyNames = PropertyNames::get();
245cdf0e10cSrcweir OUString* pOrgNames = rPropertyNames.getArray();
246cdf0e10cSrcweir sal_Int32 nOrgCount = rPropertyNames.getLength();
247cdf0e10cSrcweir
248cdf0e10cSrcweir Sequence< OUString > aNames(nOrgCount);
249cdf0e10cSrcweir Sequence< Any > aValues(nOrgCount);
250cdf0e10cSrcweir
251cdf0e10cSrcweir OUString* pNames = aNames.getArray();
252cdf0e10cSrcweir Any* pValues = aValues.getArray();
253cdf0e10cSrcweir sal_Int32 nRealCount = 0;
254cdf0e10cSrcweir
255cdf0e10cSrcweir const Type& rType = ::getBooleanCppuType();
256cdf0e10cSrcweir for(int nProp = 0; nProp < nOrgCount; nProp++)
257cdf0e10cSrcweir {
258cdf0e10cSrcweir switch(nProp)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir case 0:
261cdf0e10cSrcweir {
262cdf0e10cSrcweir if (!bROCJKFont)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
265cdf0e10cSrcweir pValues[nRealCount].setValue(&bCJKFont, rType);
266cdf0e10cSrcweir ++nRealCount;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir }
269cdf0e10cSrcweir break;
270cdf0e10cSrcweir
271cdf0e10cSrcweir case 1:
272cdf0e10cSrcweir {
273cdf0e10cSrcweir if (!bROVerticalText)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
276cdf0e10cSrcweir pValues[nRealCount].setValue(&bVerticalText, rType);
277cdf0e10cSrcweir ++nRealCount;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir break;
281cdf0e10cSrcweir
282cdf0e10cSrcweir case 2:
283cdf0e10cSrcweir {
284cdf0e10cSrcweir if (!bROAsianTypography)
285cdf0e10cSrcweir {
286cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
287cdf0e10cSrcweir pValues[nRealCount].setValue(&bAsianTypography, rType);
288cdf0e10cSrcweir ++nRealCount;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir }
291cdf0e10cSrcweir break;
292cdf0e10cSrcweir
293cdf0e10cSrcweir case 3:
294cdf0e10cSrcweir {
295cdf0e10cSrcweir if (!bROJapaneseFind)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
298cdf0e10cSrcweir pValues[nRealCount].setValue(&bJapaneseFind, rType);
299cdf0e10cSrcweir ++nRealCount;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir }
302cdf0e10cSrcweir break;
303cdf0e10cSrcweir
304cdf0e10cSrcweir case 4:
305cdf0e10cSrcweir {
306cdf0e10cSrcweir if (!bRORuby)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
309cdf0e10cSrcweir pValues[nRealCount].setValue(&bRuby, rType);
310cdf0e10cSrcweir ++nRealCount;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir }
313cdf0e10cSrcweir break;
314cdf0e10cSrcweir
315cdf0e10cSrcweir case 5:
316cdf0e10cSrcweir {
317cdf0e10cSrcweir if (!bROChangeCaseMap)
318cdf0e10cSrcweir {
319cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
320cdf0e10cSrcweir pValues[nRealCount].setValue(&bChangeCaseMap, rType);
321cdf0e10cSrcweir ++nRealCount;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir }
324cdf0e10cSrcweir break;
325cdf0e10cSrcweir
326cdf0e10cSrcweir case 6:
327cdf0e10cSrcweir {
328cdf0e10cSrcweir if (!bRODoubleLines)
329cdf0e10cSrcweir {
330cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
331cdf0e10cSrcweir pValues[nRealCount].setValue(&bDoubleLines, rType);
332cdf0e10cSrcweir ++nRealCount;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir }
335cdf0e10cSrcweir break;
336cdf0e10cSrcweir
337cdf0e10cSrcweir case 7:
338cdf0e10cSrcweir {
339cdf0e10cSrcweir if (!bROEmphasisMarks)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
342cdf0e10cSrcweir pValues[nRealCount].setValue(&bEmphasisMarks, rType);
343cdf0e10cSrcweir ++nRealCount;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir }
346cdf0e10cSrcweir break;
347cdf0e10cSrcweir
348cdf0e10cSrcweir case 8:
349cdf0e10cSrcweir {
350cdf0e10cSrcweir if (!bROVerticalCallOut)
351cdf0e10cSrcweir {
352cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[nProp];
353cdf0e10cSrcweir pValues[nRealCount].setValue(&bVerticalCallOut, rType);
354cdf0e10cSrcweir ++nRealCount;
355cdf0e10cSrcweir }
356cdf0e10cSrcweir }
357cdf0e10cSrcweir break;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir }
360cdf0e10cSrcweir aNames.realloc(nRealCount);
361cdf0e10cSrcweir aValues.realloc(nRealCount);
362cdf0e10cSrcweir PutProperties(aNames, aValues);
363cdf0e10cSrcweir }
364cdf0e10cSrcweir /*-- 13.02.2003 12:12---------------------------------------------------
365cdf0e10cSrcweir
366cdf0e10cSrcweir -----------------------------------------------------------------------*/
IsReadOnly(SvtCJKOptions::EOption eOption) const367cdf0e10cSrcweir sal_Bool SvtCJKOptions_Impl::IsReadOnly(SvtCJKOptions::EOption eOption) const
368cdf0e10cSrcweir {
369cdf0e10cSrcweir sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
370cdf0e10cSrcweir switch(eOption)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir case SvtCJKOptions::E_CJKFONT : bReadOnly = bROCJKFont; break;
373cdf0e10cSrcweir case SvtCJKOptions::E_VERTICALTEXT : bReadOnly = bROVerticalText; break;
374cdf0e10cSrcweir case SvtCJKOptions::E_ASIANTYPOGRAPHY : bReadOnly = bROAsianTypography; break;
375cdf0e10cSrcweir case SvtCJKOptions::E_JAPANESEFIND : bReadOnly = bROJapaneseFind; break;
376cdf0e10cSrcweir case SvtCJKOptions::E_RUBY : bReadOnly = bRORuby; break;
377cdf0e10cSrcweir case SvtCJKOptions::E_CHANGECASEMAP : bReadOnly = bROChangeCaseMap; break;
378cdf0e10cSrcweir case SvtCJKOptions::E_DOUBLELINES : bReadOnly = bRODoubleLines; break;
379cdf0e10cSrcweir case SvtCJKOptions::E_EMPHASISMARKS : bReadOnly = bROEmphasisMarks; break;
380cdf0e10cSrcweir case SvtCJKOptions::E_VERTICALCALLOUT : bReadOnly = bROVerticalCallOut; break;
381cdf0e10cSrcweir case SvtCJKOptions::E_ALL : if (bROCJKFont || bROVerticalText || bROAsianTypography || bROJapaneseFind || bRORuby || bROChangeCaseMap || bRODoubleLines || bROEmphasisMarks || bROVerticalCallOut)
382cdf0e10cSrcweir bReadOnly = sal_True;
383cdf0e10cSrcweir break;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir return bReadOnly;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir // global ----------------------------------------------------------------
389cdf0e10cSrcweir
390cdf0e10cSrcweir static SvtCJKOptions_Impl* pCJKOptions = NULL;
391cdf0e10cSrcweir static sal_Int32 nCJKRefCount = 0;
392cdf0e10cSrcweir namespace { struct CJKMutex : public rtl::Static< ::osl::Mutex , CJKMutex >{}; }
393cdf0e10cSrcweir
394cdf0e10cSrcweir
395cdf0e10cSrcweir // class SvtCJKOptions --------------------------------------------------
396cdf0e10cSrcweir
SvtCJKOptions(sal_Bool bDontLoad)397cdf0e10cSrcweir SvtCJKOptions::SvtCJKOptions(sal_Bool bDontLoad)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir // Global access, must be guarded (multithreading)
400cdf0e10cSrcweir ::osl::MutexGuard aGuard( CJKMutex::get() );
401cdf0e10cSrcweir if ( !pCJKOptions )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir pCJKOptions = new SvtCJKOptions_Impl;
404cdf0e10cSrcweir ItemHolder2::holdConfigItem(E_CJKOPTIONS);
405cdf0e10cSrcweir }
406cdf0e10cSrcweir if( !bDontLoad && !pCJKOptions->IsLoaded())
407cdf0e10cSrcweir pCJKOptions->Load();
408cdf0e10cSrcweir
409cdf0e10cSrcweir ++nCJKRefCount;
410cdf0e10cSrcweir pImp = pCJKOptions;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir // -----------------------------------------------------------------------
414cdf0e10cSrcweir
~SvtCJKOptions()415cdf0e10cSrcweir SvtCJKOptions::~SvtCJKOptions()
416cdf0e10cSrcweir {
417cdf0e10cSrcweir // Global access, must be guarded (multithreading)
418cdf0e10cSrcweir ::osl::MutexGuard aGuard( CJKMutex::get() );
419cdf0e10cSrcweir if ( !--nCJKRefCount )
420cdf0e10cSrcweir DELETEZ( pCJKOptions );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir // -----------------------------------------------------------------------
IsCJKFontEnabled() const423cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsCJKFontEnabled() const
424cdf0e10cSrcweir {
425cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
426cdf0e10cSrcweir return pCJKOptions->IsCJKFontEnabled();
427cdf0e10cSrcweir }
428cdf0e10cSrcweir // -----------------------------------------------------------------------
IsVerticalTextEnabled() const429cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsVerticalTextEnabled() const
430cdf0e10cSrcweir {
431cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
432cdf0e10cSrcweir return pCJKOptions->IsVerticalTextEnabled();
433cdf0e10cSrcweir }
434cdf0e10cSrcweir // -----------------------------------------------------------------------
IsAsianTypographyEnabled() const435cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsAsianTypographyEnabled() const
436cdf0e10cSrcweir {
437cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
438cdf0e10cSrcweir return pCJKOptions->IsAsianTypographyEnabled();
439cdf0e10cSrcweir }
440cdf0e10cSrcweir // -----------------------------------------------------------------------
IsJapaneseFindEnabled() const441cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsJapaneseFindEnabled() const
442cdf0e10cSrcweir {
443cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
444cdf0e10cSrcweir return pCJKOptions->IsJapaneseFindEnabled();
445cdf0e10cSrcweir }
446cdf0e10cSrcweir // -----------------------------------------------------------------------
IsRubyEnabled() const447cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsRubyEnabled() const
448cdf0e10cSrcweir {
449cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
450cdf0e10cSrcweir return pCJKOptions->IsRubyEnabled();
451cdf0e10cSrcweir }
452cdf0e10cSrcweir // -----------------------------------------------------------------------
IsChangeCaseMapEnabled() const453cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsChangeCaseMapEnabled() const
454cdf0e10cSrcweir {
455cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
456cdf0e10cSrcweir return pCJKOptions->IsChangeCaseMapEnabled();
457cdf0e10cSrcweir }
458cdf0e10cSrcweir // -----------------------------------------------------------------------
IsDoubleLinesEnabled() const459cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsDoubleLinesEnabled() const
460cdf0e10cSrcweir {
461cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
462cdf0e10cSrcweir return pCJKOptions->IsDoubleLinesEnabled();
463cdf0e10cSrcweir }
464cdf0e10cSrcweir // -----------------------------------------------------------------------
IsEmphasisMarksEnabled() const465cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsEmphasisMarksEnabled() const
466cdf0e10cSrcweir {
467cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
468cdf0e10cSrcweir return pCJKOptions->IsEmphasisMarksEnabled();
469cdf0e10cSrcweir }
470cdf0e10cSrcweir // -----------------------------------------------------------------------
IsVerticalCallOutEnabled() const471cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsVerticalCallOutEnabled() const
472cdf0e10cSrcweir {
473cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
474cdf0e10cSrcweir return pCJKOptions->IsVerticalCallOutEnabled();
475cdf0e10cSrcweir }
476cdf0e10cSrcweir /*-- 20.04.01 14:32:04---------------------------------------------------
477cdf0e10cSrcweir
478cdf0e10cSrcweir -----------------------------------------------------------------------*/
SetAll(sal_Bool bSet)479cdf0e10cSrcweir void SvtCJKOptions::SetAll(sal_Bool bSet)
480cdf0e10cSrcweir {
481cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
482cdf0e10cSrcweir pCJKOptions->SetAll(bSet);
483cdf0e10cSrcweir }
484cdf0e10cSrcweir /*-- 20.04.01 14:32:06---------------------------------------------------
485cdf0e10cSrcweir
486cdf0e10cSrcweir -----------------------------------------------------------------------*/
IsAnyEnabled() const487cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsAnyEnabled() const
488cdf0e10cSrcweir {
489cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
490cdf0e10cSrcweir return pCJKOptions->IsAnyEnabled();
491cdf0e10cSrcweir }
492cdf0e10cSrcweir /*-- 13.02.2003 12:11---------------------------------------------------
493cdf0e10cSrcweir
494cdf0e10cSrcweir -----------------------------------------------------------------------*/
IsReadOnly(EOption eOption) const495cdf0e10cSrcweir sal_Bool SvtCJKOptions::IsReadOnly(EOption eOption) const
496cdf0e10cSrcweir {
497cdf0e10cSrcweir DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded");
498cdf0e10cSrcweir return pCJKOptions->IsReadOnly(eOption);
499cdf0e10cSrcweir }
500cdf0e10cSrcweir
501