diff options
Diffstat (limited to 'svl/source/config')
-rw-r--r-- | svl/source/config/asiancfg.cxx | 291 | ||||
-rw-r--r-- | svl/source/config/cjkoptions.cxx | 504 | ||||
-rw-r--r-- | svl/source/config/ctloptions.cxx | 492 | ||||
-rw-r--r-- | svl/source/config/itemholder2.cxx | 179 | ||||
-rw-r--r-- | svl/source/config/itemholder2.hxx | 89 | ||||
-rw-r--r-- | svl/source/config/languageoptions.cxx | 276 | ||||
-rw-r--r-- | svl/source/config/makefile.mk | 52 | ||||
-rw-r--r-- | svl/source/config/srchcfg.cxx | 287 |
8 files changed, 2170 insertions, 0 deletions
diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx new file mode 100644 index 000000000000..02da1db70d63 --- /dev/null +++ b/svl/source/config/asiancfg.cxx @@ -0,0 +1,291 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svl.hxx" + +#include <svl/asiancfg.hxx> +#include <svl/svarray.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <tools/debug.hxx> + +//----------------------------------------------------------------------------- +using namespace utl; +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; +using namespace com::sun::star::lang; + +#define C2U(cChar) OUString::createFromAscii(cChar) +const sal_Char sStartEndCharacters[] = "StartEndCharacters"; +const sal_Char sStartCharacters[] = "StartCharacters"; +const sal_Char sEndCharacters[] = "EndCharacters"; + +//----------------------------------------------------------------------------- +struct SvxForbiddenStruct_Impl +{ + Locale aLocale; + OUString sStartChars; + OUString sEndChars; +}; +//----------------------------------------------------------------------------- +typedef SvxForbiddenStruct_Impl* SvxForbiddenStruct_ImplPtr; +SV_DECL_PTRARR_DEL(SvxForbiddenStructArr, SvxForbiddenStruct_ImplPtr, 2, 2) +SV_IMPL_PTRARR(SvxForbiddenStructArr, SvxForbiddenStruct_ImplPtr); +//----------------------------------------------------------------------------- +struct SvxAsianConfig_Impl +{ + sal_Bool bKerningWesternTextOnly; + sal_Int16 nCharDistanceCompression; + + SvxForbiddenStructArr aForbiddenArr; + + SvxAsianConfig_Impl() : + bKerningWesternTextOnly(sal_True), + nCharDistanceCompression(0) {} +}; +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +Sequence<OUString> lcl_GetPropertyNames() +{ + Sequence<OUString> aNames(2); + OUString* pNames = aNames.getArray(); + pNames[0] = C2U("IsKerningWesternTextOnly"); + pNames[1] = C2U("CompressCharacterDistance"); + return aNames;; +} +// --------------------------------------------------------------------------- +SvxAsianConfig::SvxAsianConfig(sal_Bool bEnableNotify) : + utl::ConfigItem(C2U("Office.Common/AsianLayout")), + pImpl(new SvxAsianConfig_Impl) +{ + if(bEnableNotify) + EnableNotification(lcl_GetPropertyNames()); + Load(); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +SvxAsianConfig::~SvxAsianConfig() +{ + delete pImpl; +} +/* -----------------------------17.01.01 09:57-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxAsianConfig::Load() +{ + Sequence<Any> aValues = GetProperties(lcl_GetPropertyNames()); + const Any* pValues = aValues.getConstArray(); + if(pValues[0].hasValue()) + pImpl->bKerningWesternTextOnly = *(sal_Bool*) pValues[0].getValue(); + pValues[1] >>= pImpl->nCharDistanceCompression; + + pImpl->aForbiddenArr.DeleteAndDestroy(0, pImpl->aForbiddenArr.Count()); + OUString sPropPrefix(C2U(sStartEndCharacters)); + Sequence<OUString> aNodes = GetNodeNames(sPropPrefix); + + Sequence<OUString> aPropNames(aNodes.getLength() * 2); + OUString* pNames = aPropNames.getArray(); + sal_Int32 nName = 0; + sPropPrefix += C2U("/"); + sal_Int32 nNode; + const OUString* pNodes = aNodes.getConstArray(); + for(nNode = 0; nNode < aNodes.getLength(); nNode++) + { + OUString sStart(sPropPrefix); + sStart += pNodes[nNode]; + sStart += C2U("/"); + pNames[nName] = sStart; pNames[nName++] += C2U("StartCharacters"); + pNames[nName] = sStart; pNames[nName++] += C2U("EndCharacters"); + } + Sequence<Any> aNodeValues = GetProperties(aPropNames); + const Any* pNodeValues = aNodeValues.getConstArray(); + nName = 0; + for(nNode = 0; nNode < aNodes.getLength(); nNode++) + { + SvxForbiddenStruct_ImplPtr pInsert = new SvxForbiddenStruct_Impl; + pInsert->aLocale.Language = pNodes[nNode].copy(0, 2); + DBG_ASSERT(pInsert->aLocale.Language.getLength(), "illegal language"); + pInsert->aLocale.Country = pNodes[nNode].copy(3, 2); + + pNodeValues[nName++] >>= pInsert->sStartChars; + pNodeValues[nName++] >>= pInsert->sEndChars; + pImpl->aForbiddenArr.Insert(pInsert, pImpl->aForbiddenArr.Count()); + } +} +/* -----------------------------17.01.01 09:57-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxAsianConfig::Notify( const Sequence<OUString>& ) +{ + Load(); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxAsianConfig::Commit() +{ + Sequence<Any> aValues(2); + Any* pValues = aValues.getArray(); + pValues[0].setValue(&pImpl->bKerningWesternTextOnly, ::getBooleanCppuType()); + pValues[1] <<= pImpl->nCharDistanceCompression; + PutProperties(lcl_GetPropertyNames(), aValues); + + + OUString sNode(C2U(sStartEndCharacters)); + if(!pImpl->aForbiddenArr.Count()) + ClearNodeSet(sNode); + else + { + Sequence<PropertyValue> aSetValues(2 * pImpl->aForbiddenArr.Count()); + PropertyValue* pSetValues = aSetValues.getArray(); + sal_Int32 nSetValue = 0; + const OUString sStartChars(C2U(sStartCharacters)); + const OUString sEndChars(C2U(sEndCharacters)); + for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++) + { + OUString sPrefix(sNode); + sPrefix += C2U("/"); + sPrefix += pImpl->aForbiddenArr[i]->aLocale.Language; + DBG_ASSERT(pImpl->aForbiddenArr[i]->aLocale.Language.getLength(), "illegal language"); + sPrefix += C2U("-"); + sPrefix += pImpl->aForbiddenArr[i]->aLocale.Country; + sPrefix += C2U("/"); + pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sStartChars; + pSetValues[nSetValue++].Value <<= pImpl->aForbiddenArr[i]->sStartChars; + pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sEndChars; + pSetValues[nSetValue++].Value <<= pImpl->aForbiddenArr[i]->sEndChars; + } + ReplaceSetProperties(sNode, aSetValues); + } +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SvxAsianConfig::IsKerningWesternTextOnly() const +{ + return pImpl->bKerningWesternTextOnly; +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxAsianConfig::SetKerningWesternTextOnly(sal_Bool bSet) +{ + pImpl->bKerningWesternTextOnly = bSet; + SetModified(); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Int16 SvxAsianConfig::GetCharDistanceCompression() const +{ + return pImpl->nCharDistanceCompression; +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxAsianConfig::SetCharDistanceCompression(sal_Int16 nSet) +{ + DBG_ASSERT(nSet >= 0 && nSet < 3, "compression value illegal"); + SetModified(); + pImpl->nCharDistanceCompression = nSet; +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence<lang::Locale> SvxAsianConfig::GetStartEndCharLocales() +{ + Sequence<Locale> aRet(pImpl->aForbiddenArr.Count()); + Locale* pRet = aRet.getArray(); + for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++) + { + pRet[i] = pImpl->aForbiddenArr[i]->aLocale; + } + return aRet; +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SvxAsianConfig::GetStartEndChars( const Locale& rLocale, + OUString& rStartChars, + OUString& rEndChars ) +{ + for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++) + { + if(rLocale.Language == pImpl->aForbiddenArr[i]->aLocale.Language && + rLocale.Country == pImpl->aForbiddenArr[i]->aLocale.Country) + { + rStartChars = pImpl->aForbiddenArr[i]->sStartChars; + rEndChars = pImpl->aForbiddenArr[i]->sEndChars; + return sal_True; + } + } + return sal_False; +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxAsianConfig::SetStartEndChars( const Locale& rLocale, + const OUString* pStartChars, + const OUString* pEndChars ) +{ + sal_Bool bFound = sal_False; + for(sal_uInt16 i = 0; i < pImpl->aForbiddenArr.Count(); i++) + { + if(rLocale.Language == pImpl->aForbiddenArr[i]->aLocale.Language && + rLocale.Country == pImpl->aForbiddenArr[i]->aLocale.Country) + { + if(pStartChars && pEndChars) + { + pImpl->aForbiddenArr[i]->sStartChars = *pStartChars; + pImpl->aForbiddenArr[i]->sEndChars = *pEndChars; + } + else + pImpl->aForbiddenArr.DeleteAndDestroy(i, 1); + bFound = sal_True; + } + } + if(!bFound && pStartChars && pEndChars) + { + SvxForbiddenStruct_ImplPtr pInsert = new SvxForbiddenStruct_Impl; + pInsert->aLocale = rLocale; + pInsert->sStartChars = *pStartChars; + pInsert->sEndChars = *pEndChars; + pImpl->aForbiddenArr.Insert(pInsert, pImpl->aForbiddenArr.Count()); + } +#ifdef DBG_UTIL + else if(!bFound) + DBG_ERROR("attempt to clear unavailable data"); +#endif + SetModified(); +} diff --git a/svl/source/config/cjkoptions.cxx b/svl/source/config/cjkoptions.cxx new file mode 100644 index 000000000000..cb332ac579f1 --- /dev/null +++ b/svl/source/config/cjkoptions.cxx @@ -0,0 +1,504 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svl.hxx" + +#include <svl/cjkoptions.hxx> + +#include <svl/languageoptions.hxx> +#include <i18npool/lang.h> +#include <unotools/configitem.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <osl/mutex.hxx> +#include <rtl/instance.hxx> + +#include <itemholder2.hxx> + +using namespace ::com::sun::star::uno; +using namespace ::rtl; + +#define C2U(cChar) OUString::createFromAscii(cChar) +#define CFG_READONLY_DEFAULT sal_False +/* -----------------------------10.04.01 12:39-------------------------------- + + ---------------------------------------------------------------------------*/ +class SvtCJKOptions_Impl : public utl::ConfigItem +{ + sal_Bool bIsLoaded; + sal_Bool bCJKFont; + sal_Bool bVerticalText; + sal_Bool bAsianTypography; + sal_Bool bJapaneseFind; + sal_Bool bRuby; + sal_Bool bChangeCaseMap; + sal_Bool bDoubleLines; + sal_Bool bEmphasisMarks; + sal_Bool bVerticalCallOut; + + sal_Bool bROCJKFont; + sal_Bool bROVerticalText; + sal_Bool bROAsianTypography; + sal_Bool bROJapaneseFind; + sal_Bool bRORuby; + sal_Bool bROChangeCaseMap; + sal_Bool bRODoubleLines; + sal_Bool bROEmphasisMarks; + sal_Bool bROVerticalCallOut; + +public: + SvtCJKOptions_Impl(); + ~SvtCJKOptions_Impl(); + + virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames ); + virtual void Commit(); + void Load(); + + sal_Bool IsLoaded() { return bIsLoaded; } + + sal_Bool IsCJKFontEnabled() const { return bCJKFont; } + sal_Bool IsVerticalTextEnabled() const { return bVerticalText; } + sal_Bool IsAsianTypographyEnabled() const { return bAsianTypography; } + sal_Bool IsJapaneseFindEnabled() const { return bJapaneseFind; } + sal_Bool IsRubyEnabled() const { return bRuby; } + sal_Bool IsChangeCaseMapEnabled() const { return bChangeCaseMap; } + sal_Bool IsDoubleLinesEnabled() const { return bDoubleLines; } + sal_Bool IsEmphasisMarksEnabled() const { return bEmphasisMarks; } + sal_Bool IsVerticalCallOutEnabled() const { return bVerticalCallOut; } + + sal_Bool IsAnyEnabled() const { + return bCJKFont||bVerticalText||bAsianTypography||bJapaneseFind|| + bRuby||bChangeCaseMap||bDoubleLines||bEmphasisMarks||bVerticalCallOut; } + void SetAll(sal_Bool bSet); + sal_Bool IsReadOnly(SvtCJKOptions::EOption eOption) const; +}; +/*-- 10.04.01 12:41:57--------------------------------------------------- + + -----------------------------------------------------------------------*/ +namespace +{ + struct PropertyNames + : public rtl::Static< Sequence<OUString>, PropertyNames > {}; +} + +SvtCJKOptions_Impl::SvtCJKOptions_Impl() : + utl::ConfigItem(C2U("Office.Common/I18N/CJK")), + bIsLoaded(sal_False), + bCJKFont(sal_True), + bVerticalText(sal_True), + bAsianTypography(sal_True), + bJapaneseFind(sal_True), + bRuby(sal_True), + bChangeCaseMap(sal_True), + bDoubleLines(sal_True), + bEmphasisMarks(sal_True), + bVerticalCallOut(sal_True), + bROCJKFont(CFG_READONLY_DEFAULT), + bROVerticalText(CFG_READONLY_DEFAULT), + bROAsianTypography(CFG_READONLY_DEFAULT), + bROJapaneseFind(CFG_READONLY_DEFAULT), + bRORuby(CFG_READONLY_DEFAULT), + bROChangeCaseMap(CFG_READONLY_DEFAULT), + bRODoubleLines(CFG_READONLY_DEFAULT), + bROEmphasisMarks(CFG_READONLY_DEFAULT), + bROVerticalCallOut(CFG_READONLY_DEFAULT) +{ +} +/*-- 10.04.01 12:41:57--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SvtCJKOptions_Impl::~SvtCJKOptions_Impl() +{ +} +/* -----------------------------20.04.01 14:34-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvtCJKOptions_Impl::SetAll(sal_Bool bSet) +{ + if ( + !bROCJKFont && + !bROVerticalText && + !bROAsianTypography && + !bROJapaneseFind && + !bRORuby && + !bROChangeCaseMap && + !bRODoubleLines && + !bROEmphasisMarks && + !bROVerticalCallOut + ) + { + bCJKFont=bSet; + bVerticalText=bSet; + bAsianTypography=bSet; + bJapaneseFind=bSet; + bRuby=bSet; + bChangeCaseMap=bSet; + bDoubleLines=bSet; + bEmphasisMarks=bSet; + bVerticalCallOut=bSet; + + SetModified(); + Commit(); + NotifyListeners(0); + } +} +/*-- 10.04.01 12:41:56--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtCJKOptions_Impl::Load() +{ + Sequence<OUString> &rPropertyNames = PropertyNames::get(); + if(!rPropertyNames.getLength()) + { + rPropertyNames.realloc(9); + OUString* pNames = rPropertyNames.getArray(); + + pNames[0] = C2U("CJKFont"); + pNames[1] = C2U("VerticalText"); + pNames[2] = C2U("AsianTypography"); + pNames[3] = C2U("JapaneseFind"); + pNames[4] = C2U("Ruby"); + pNames[5] = C2U("ChangeCaseMap"); + pNames[6] = C2U("DoubleLines"); + pNames[7] = C2U("EmphasisMarks"); + pNames[8] = C2U("VerticalCallOut"); + + EnableNotification( rPropertyNames ); + } + Sequence< Any > aValues = GetProperties(rPropertyNames); + Sequence< sal_Bool > aROStates = GetReadOnlyStates(rPropertyNames); + const Any* pValues = aValues.getConstArray(); + const sal_Bool* pROStates = aROStates.getConstArray(); + DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" ); + DBG_ASSERT( aROStates.getLength() == rPropertyNames.getLength(), "GetReadOnlyStates failed" ); + if ( aValues.getLength() == rPropertyNames.getLength() && aROStates.getLength() == rPropertyNames.getLength() ) + { + for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ ) + { + if( pValues[nProp].hasValue() ) + { + sal_Bool bValue = *(sal_Bool*)pValues[nProp].getValue(); + switch ( nProp ) + { + case 0: { bCJKFont = bValue; bROCJKFont = pROStates[nProp]; } break; + case 1: { bVerticalText = bValue; bROVerticalText = pROStates[nProp]; } break; + case 2: { bAsianTypography = bValue; bROAsianTypography = pROStates[nProp]; } break; + case 3: { bJapaneseFind = bValue; bROJapaneseFind = pROStates[nProp]; } break; + case 4: { bRuby = bValue; bRORuby = pROStates[nProp]; } break; + case 5: { bChangeCaseMap = bValue; bROChangeCaseMap = pROStates[nProp]; } break; + case 6: { bDoubleLines = bValue; bRODoubleLines = pROStates[nProp]; } break; + case 7: { bEmphasisMarks = bValue; bROEmphasisMarks = pROStates[nProp]; } break; + case 8: { bVerticalCallOut = bValue; bROVerticalCallOut = pROStates[nProp]; } break; + } + } + } + } + + SvtSystemLanguageOptions aSystemLocaleSettings; + LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage(); + sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage ); + + sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM); + if ( !bCJKFont && (( nScriptType & SCRIPTTYPE_ASIAN )|| + ((eSystemLanguage != LANGUAGE_SYSTEM) && ( nWinScript & SCRIPTTYPE_ASIAN )))) + { + SetAll(sal_True); + } + bIsLoaded = sal_True; +} +/*-- 10.04.01 12:41:57--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtCJKOptions_Impl::Notify( const Sequence< OUString >& ) +{ + Load(); + NotifyListeners(0); +} +/*-- 10.04.01 12:41:57--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtCJKOptions_Impl::Commit() +{ + Sequence<OUString> &rPropertyNames = PropertyNames::get(); + OUString* pOrgNames = rPropertyNames.getArray(); + sal_Int32 nOrgCount = rPropertyNames.getLength(); + + Sequence< OUString > aNames(nOrgCount); + Sequence< Any > aValues(nOrgCount); + + OUString* pNames = aNames.getArray(); + Any* pValues = aValues.getArray(); + sal_Int32 nRealCount = 0; + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < nOrgCount; nProp++) + { + switch(nProp) + { + case 0: + { + if (!bROCJKFont) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bCJKFont, rType); + ++nRealCount; + } + } + break; + + case 1: + { + if (!bROVerticalText) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bVerticalText, rType); + ++nRealCount; + } + } + break; + + case 2: + { + if (!bROAsianTypography) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bAsianTypography, rType); + ++nRealCount; + } + } + break; + + case 3: + { + if (!bROJapaneseFind) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bJapaneseFind, rType); + ++nRealCount; + } + } + break; + + case 4: + { + if (!bRORuby) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bRuby, rType); + ++nRealCount; + } + } + break; + + case 5: + { + if (!bROChangeCaseMap) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bChangeCaseMap, rType); + ++nRealCount; + } + } + break; + + case 6: + { + if (!bRODoubleLines) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bDoubleLines, rType); + ++nRealCount; + } + } + break; + + case 7: + { + if (!bROEmphasisMarks) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bEmphasisMarks, rType); + ++nRealCount; + } + } + break; + + case 8: + { + if (!bROVerticalCallOut) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue(&bVerticalCallOut, rType); + ++nRealCount; + } + } + break; + } + } + aNames.realloc(nRealCount); + aValues.realloc(nRealCount); + PutProperties(aNames, aValues); +} +/*-- 13.02.2003 12:12--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool SvtCJKOptions_Impl::IsReadOnly(SvtCJKOptions::EOption eOption) const +{ + sal_Bool bReadOnly = CFG_READONLY_DEFAULT; + switch(eOption) + { + case SvtCJKOptions::E_CJKFONT : bReadOnly = bROCJKFont; break; + case SvtCJKOptions::E_VERTICALTEXT : bReadOnly = bROVerticalText; break; + case SvtCJKOptions::E_ASIANTYPOGRAPHY : bReadOnly = bROAsianTypography; break; + case SvtCJKOptions::E_JAPANESEFIND : bReadOnly = bROJapaneseFind; break; + case SvtCJKOptions::E_RUBY : bReadOnly = bRORuby; break; + case SvtCJKOptions::E_CHANGECASEMAP : bReadOnly = bROChangeCaseMap; break; + case SvtCJKOptions::E_DOUBLELINES : bReadOnly = bRODoubleLines; break; + case SvtCJKOptions::E_EMPHASISMARKS : bReadOnly = bROEmphasisMarks; break; + case SvtCJKOptions::E_VERTICALCALLOUT : bReadOnly = bROVerticalCallOut; break; + case SvtCJKOptions::E_ALL : if (bROCJKFont || bROVerticalText || bROAsianTypography || bROJapaneseFind || bRORuby || bROChangeCaseMap || bRODoubleLines || bROEmphasisMarks || bROVerticalCallOut) + bReadOnly = sal_True; + break; + } + return bReadOnly; +} + +// global ---------------------------------------------------------------- + +static SvtCJKOptions_Impl* pCJKOptions = NULL; +static sal_Int32 nCJKRefCount = 0; +namespace { struct CJKMutex : public rtl::Static< ::osl::Mutex , CJKMutex >{}; } + + +// class SvtCJKOptions -------------------------------------------------- + +SvtCJKOptions::SvtCJKOptions(sal_Bool bDontLoad) +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( CJKMutex::get() ); + if ( !pCJKOptions ) + { + pCJKOptions = new SvtCJKOptions_Impl; + ItemHolder2::holdConfigItem(E_CJKOPTIONS); + } + if( !bDontLoad && !pCJKOptions->IsLoaded()) + pCJKOptions->Load(); + + ++nCJKRefCount; + pImp = pCJKOptions; +} + +// ----------------------------------------------------------------------- + +SvtCJKOptions::~SvtCJKOptions() +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( CJKMutex::get() ); + if ( !--nCJKRefCount ) + DELETEZ( pCJKOptions ); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsCJKFontEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsCJKFontEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsVerticalTextEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsVerticalTextEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsAsianTypographyEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsAsianTypographyEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsJapaneseFindEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsJapaneseFindEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsRubyEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsRubyEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsChangeCaseMapEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsChangeCaseMapEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsDoubleLinesEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsDoubleLinesEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsEmphasisMarksEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsEmphasisMarksEnabled(); +} +// ----------------------------------------------------------------------- +sal_Bool SvtCJKOptions::IsVerticalCallOutEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsVerticalCallOutEnabled(); +} +/*-- 20.04.01 14:32:04--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtCJKOptions::SetAll(sal_Bool bSet) +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + pCJKOptions->SetAll(bSet); +} +/*-- 20.04.01 14:32:06--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool SvtCJKOptions::IsAnyEnabled() const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsAnyEnabled(); +} +/*-- 13.02.2003 12:11--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool SvtCJKOptions::IsReadOnly(EOption eOption) const +{ + DBG_ASSERT(pCJKOptions->IsLoaded(), "CJK options not loaded"); + return pCJKOptions->IsReadOnly(eOption); +} + diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx new file mode 100644 index 000000000000..983c202cb709 --- /dev/null +++ b/svl/source/config/ctloptions.cxx @@ -0,0 +1,492 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svl.hxx" + +#include <svl/ctloptions.hxx> + +#include <svl/languageoptions.hxx> +#include <i18npool/mslangid.hxx> +#include <unotools/configitem.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <osl/mutex.hxx> +#include <vos/mutex.hxx> +#include <svl/smplhint.hxx> +#include <rtl/instance.hxx> +#include <unotools/syslocale.hxx> +#include <itemholder2.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +#define ASCII_STR(s) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) +#define CFG_READONLY_DEFAULT sal_False + +// SvtCJKOptions_Impl ---------------------------------------------------------- + +class SvtCTLOptions_Impl : public utl::ConfigItem +{ +private: + sal_Bool m_bIsLoaded; + sal_Bool m_bCTLFontEnabled; + sal_Bool m_bCTLSequenceChecking; + sal_Bool m_bCTLRestricted; + sal_Bool m_bCTLTypeAndReplace; + SvtCTLOptions::CursorMovement m_eCTLCursorMovement; + SvtCTLOptions::TextNumerals m_eCTLTextNumerals; + + sal_Bool m_bROCTLFontEnabled; + sal_Bool m_bROCTLSequenceChecking; + sal_Bool m_bROCTLRestricted; + sal_Bool m_bROCTLTypeAndReplace; + sal_Bool m_bROCTLCursorMovement; + sal_Bool m_bROCTLTextNumerals; + +public: + SvtCTLOptions_Impl(); + ~SvtCTLOptions_Impl(); + + virtual void Notify( const Sequence< rtl::OUString >& _aPropertyNames ); + virtual void Commit(); + void Load(); + + sal_Bool IsLoaded() { return m_bIsLoaded; } + void SetCTLFontEnabled( sal_Bool _bEnabled ); + sal_Bool IsCTLFontEnabled() const { return m_bCTLFontEnabled; } + + void SetCTLSequenceChecking( sal_Bool _bEnabled ); + sal_Bool IsCTLSequenceChecking() const { return m_bCTLSequenceChecking;} + + void SetCTLSequenceCheckingRestricted( sal_Bool _bEnable ); + sal_Bool IsCTLSequenceCheckingRestricted( void ) const { return m_bCTLRestricted; } + + void SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable ); + sal_Bool IsCTLSequenceCheckingTypeAndReplace() const { return m_bCTLTypeAndReplace; } + + void SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement ); + SvtCTLOptions::CursorMovement + GetCTLCursorMovement() const { return m_eCTLCursorMovement; } + + void SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals ); + SvtCTLOptions::TextNumerals + GetCTLTextNumerals() const { return m_eCTLTextNumerals; } + + sal_Bool IsReadOnly(SvtCTLOptions::EOption eOption) const; +}; +//------------------------------------------------------------------------------ +namespace +{ + struct PropertyNames + : public rtl::Static< Sequence< rtl::OUString >, PropertyNames > {}; +} +//------------------------------------------------------------------------------ +sal_Bool SvtCTLOptions_Impl::IsReadOnly(SvtCTLOptions::EOption eOption) const +{ + sal_Bool bReadOnly = CFG_READONLY_DEFAULT; + switch(eOption) + { + case SvtCTLOptions::E_CTLFONT : bReadOnly = m_bROCTLFontEnabled ; break; + case SvtCTLOptions::E_CTLSEQUENCECHECKING : bReadOnly = m_bROCTLSequenceChecking ; break; + case SvtCTLOptions::E_CTLCURSORMOVEMENT : bReadOnly = m_bROCTLCursorMovement ; break; + case SvtCTLOptions::E_CTLTEXTNUMERALS : bReadOnly = m_bROCTLTextNumerals ; break; + case SvtCTLOptions::E_CTLSEQUENCECHECKINGRESTRICTED: bReadOnly = m_bROCTLRestricted ; break; + case SvtCTLOptions::E_CTLSEQUENCECHECKINGTYPEANDREPLACE: bReadOnly = m_bROCTLTypeAndReplace; break; + default: DBG_ERROR( "SvtCTLOptions_Impl::IsReadOnly() - invalid option" ); + } + return bReadOnly; +} +//------------------------------------------------------------------------------ +SvtCTLOptions_Impl::SvtCTLOptions_Impl() : + + utl::ConfigItem( ASCII_STR("Office.Common/I18N/CTL") ), + + m_bIsLoaded ( sal_False ), + m_bCTLFontEnabled ( sal_False ), + m_bCTLSequenceChecking ( sal_False ), + m_bCTLRestricted ( sal_False ), + m_eCTLCursorMovement ( SvtCTLOptions::MOVEMENT_LOGICAL ), + m_eCTLTextNumerals ( SvtCTLOptions::NUMERALS_ARABIC ), + + m_bROCTLFontEnabled ( CFG_READONLY_DEFAULT ), + m_bROCTLSequenceChecking( CFG_READONLY_DEFAULT ), + m_bROCTLRestricted ( CFG_READONLY_DEFAULT ), + m_bROCTLCursorMovement ( CFG_READONLY_DEFAULT ), + m_bROCTLTextNumerals ( CFG_READONLY_DEFAULT ) +{ +} +//------------------------------------------------------------------------------ +SvtCTLOptions_Impl::~SvtCTLOptions_Impl() +{ + if ( IsModified() == sal_True ) + Commit(); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions_Impl::Notify( const Sequence< rtl::OUString >& ) +{ + Load(); + NotifyListeners(SFX_HINT_CTL_SETTINGS_CHANGED); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions_Impl::Commit() +{ + Sequence< rtl::OUString > &rPropertyNames = PropertyNames::get(); + rtl::OUString* pOrgNames = rPropertyNames.getArray(); + sal_Int32 nOrgCount = rPropertyNames.getLength(); + + Sequence< rtl::OUString > aNames( nOrgCount ); + Sequence< Any > aValues( nOrgCount ); + + rtl::OUString* pNames = aNames.getArray(); + Any* pValues = aValues.getArray(); + sal_Int32 nRealCount = 0; + + const uno::Type& rType = ::getBooleanCppuType(); + + for ( int nProp = 0; nProp < nOrgCount; nProp++ ) + { + switch ( nProp ) + { + case 0: + { + if (!m_bROCTLFontEnabled) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue( &m_bCTLFontEnabled, rType ); + ++nRealCount; + } + } + break; + + case 1: + { + if (!m_bROCTLSequenceChecking) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue( &m_bCTLSequenceChecking, rType ); + ++nRealCount; + } + } + break; + + case 2: + { + if (!m_bROCTLCursorMovement) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount] <<= (sal_Int32)m_eCTLCursorMovement; + ++nRealCount; + } + } + break; + + case 3: + { + if (!m_bROCTLTextNumerals) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount] <<= (sal_Int32)m_eCTLTextNumerals; + ++nRealCount; + } + } + break; + + case 4: + { + if (!m_bROCTLRestricted) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue( &m_bCTLRestricted, rType ); + ++nRealCount; + } + } + break; + case 5: + { + if(!m_bROCTLTypeAndReplace) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount].setValue( &m_bCTLTypeAndReplace, rType ); + ++nRealCount; + } + } + break; + } + } + aNames.realloc(nRealCount); + aValues.realloc(nRealCount); + PutProperties( aNames, aValues ); + //broadcast changes + NotifyListeners(SFX_HINT_CTL_SETTINGS_CHANGED); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions_Impl::Load() +{ + Sequence< rtl::OUString >& rPropertyNames = PropertyNames::get(); + if ( !rPropertyNames.getLength() ) + { + rPropertyNames.realloc(6); + rtl::OUString* pNames = rPropertyNames.getArray(); + pNames[0] = ASCII_STR("CTLFont"); + pNames[1] = ASCII_STR("CTLSequenceChecking"); + pNames[2] = ASCII_STR("CTLCursorMovement"); + pNames[3] = ASCII_STR("CTLTextNumerals"); + pNames[4] = ASCII_STR("CTLSequenceCheckingRestricted"); + pNames[5] = ASCII_STR("CTLSequenceCheckingTypeAndReplace"); + EnableNotification( rPropertyNames ); + } + Sequence< Any > aValues = GetProperties( rPropertyNames ); + Sequence< sal_Bool > aROStates = GetReadOnlyStates( rPropertyNames ); + const Any* pValues = aValues.getConstArray(); + const sal_Bool* pROStates = aROStates.getConstArray(); + DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" ); + DBG_ASSERT( aROStates.getLength() == rPropertyNames.getLength(), "GetReadOnlyStates failed" ); + if ( aValues.getLength() == rPropertyNames.getLength() && aROStates.getLength() == rPropertyNames.getLength() ) + { + sal_Bool bValue = sal_False; + sal_Int32 nValue = 0; + + for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ ) + { + if ( pValues[nProp].hasValue() ) + { + if ( pValues[nProp] >>= bValue ) + { + switch ( nProp ) + { + case 0: { m_bCTLFontEnabled = bValue; m_bROCTLFontEnabled = pROStates[nProp]; } break; + case 1: { m_bCTLSequenceChecking = bValue; m_bROCTLSequenceChecking = pROStates[nProp]; } break; + case 4: { m_bCTLRestricted = bValue; m_bROCTLRestricted = pROStates[nProp]; } break; + case 5: { m_bCTLTypeAndReplace = bValue; m_bROCTLTypeAndReplace = pROStates[nProp]; } break; + } + } + else if ( pValues[nProp] >>= nValue ) + { + switch ( nProp ) + { + case 2: { m_eCTLCursorMovement = (SvtCTLOptions::CursorMovement)nValue; m_bROCTLCursorMovement = pROStates[nProp]; } break; + case 3: { m_eCTLTextNumerals = (SvtCTLOptions::TextNumerals)nValue; m_bROCTLTextNumerals = pROStates[nProp]; } break; + } + } + } + } + } + sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM); + SvtSystemLanguageOptions aSystemLocaleSettings; + LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage(); + sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage ); + if( !m_bCTLFontEnabled && (( nType & SCRIPTTYPE_COMPLEX ) || + ((eSystemLanguage != LANGUAGE_SYSTEM) && ( nWinScript & SCRIPTTYPE_COMPLEX ))) ) + { + m_bCTLFontEnabled = sal_True; + sal_uInt16 nLanguage = SvtSysLocale().GetLanguage(); + //enable sequence checking for the appropriate languages + m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace = + (MsLangId::needsSequenceChecking( nLanguage) || + MsLangId::needsSequenceChecking( eSystemLanguage)); + Commit(); + } + m_bIsLoaded = sal_True; +} +//------------------------------------------------------------------------------ +void SvtCTLOptions_Impl::SetCTLFontEnabled( sal_Bool _bEnabled ) +{ + if(!m_bROCTLFontEnabled && m_bCTLFontEnabled != _bEnabled) + { + m_bCTLFontEnabled = _bEnabled; + SetModified(); + NotifyListeners(0); + } +} +//------------------------------------------------------------------------------ +void SvtCTLOptions_Impl::SetCTLSequenceChecking( sal_Bool _bEnabled ) +{ + if(!m_bROCTLSequenceChecking && m_bCTLSequenceChecking != _bEnabled) + { + SetModified(); + m_bCTLSequenceChecking = _bEnabled; + NotifyListeners(0); + } +} +//------------------------------------------------------------------------------ +void SvtCTLOptions_Impl::SetCTLSequenceCheckingRestricted( sal_Bool _bEnabled ) +{ + if(!m_bROCTLRestricted && m_bCTLRestricted != _bEnabled) + { + SetModified(); + m_bCTLRestricted = _bEnabled; + NotifyListeners(0); + } +} +//------------------------------------------------------------------------------ +void SvtCTLOptions_Impl::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnabled ) +{ + if(!m_bROCTLTypeAndReplace && m_bCTLTypeAndReplace != _bEnabled) + { + SetModified(); + m_bCTLTypeAndReplace = _bEnabled; + NotifyListeners(0); + } +} +//------------------------------------------------------------------------------ +void SvtCTLOptions_Impl::SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement ) +{ + if (!m_bROCTLCursorMovement && m_eCTLCursorMovement != _eMovement ) + { + SetModified(); + m_eCTLCursorMovement = _eMovement; + NotifyListeners(0); + } +} +//------------------------------------------------------------------------------ +void SvtCTLOptions_Impl::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals ) +{ + if (!m_bROCTLTextNumerals && m_eCTLTextNumerals != _eNumerals ) + { + SetModified(); + m_eCTLTextNumerals = _eNumerals; + NotifyListeners(0); + } +} +// global ---------------------------------------------------------------- + +static SvtCTLOptions_Impl* pCTLOptions = NULL; +static sal_Int32 nCTLRefCount = 0; +namespace { struct CTLMutex : public rtl::Static< osl::Mutex, CTLMutex > {}; } + +// class SvtCTLOptions -------------------------------------------------- + +SvtCTLOptions::SvtCTLOptions( sal_Bool bDontLoad ) +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( CTLMutex::get() ); + if ( !pCTLOptions ) + { + pCTLOptions = new SvtCTLOptions_Impl; + ItemHolder2::holdConfigItem(E_CTLOPTIONS); + } + if( !bDontLoad && !pCTLOptions->IsLoaded() ) + pCTLOptions->Load(); + + ++nCTLRefCount; + m_pImp = pCTLOptions; + m_pImp->AddListener(this); +} + +// ----------------------------------------------------------------------- + +SvtCTLOptions::~SvtCTLOptions() +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( CTLMutex::get() ); + + m_pImp->RemoveListener(this); + if ( !--nCTLRefCount ) + DELETEZ( pCTLOptions ); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions::SetCTLFontEnabled( sal_Bool _bEnabled ) +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + pCTLOptions->SetCTLFontEnabled( _bEnabled ); +} +// ----------------------------------------------------------------------------- +sal_Bool SvtCTLOptions::IsCTLFontEnabled() const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->IsCTLFontEnabled(); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions::SetCTLSequenceChecking( sal_Bool _bEnabled ) +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + pCTLOptions->SetCTLSequenceChecking(_bEnabled); +} +// ----------------------------------------------------------------------------- +sal_Bool SvtCTLOptions::IsCTLSequenceChecking() const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->IsCTLSequenceChecking(); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable ) +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + pCTLOptions->SetCTLSequenceCheckingRestricted(_bEnable); +} +// ----------------------------------------------------------------------------- +sal_Bool SvtCTLOptions::IsCTLSequenceCheckingRestricted( void ) const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->IsCTLSequenceCheckingRestricted(); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable ) +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + pCTLOptions->SetCTLSequenceCheckingTypeAndReplace(_bEnable); +} +// ----------------------------------------------------------------------------- +sal_Bool SvtCTLOptions::IsCTLSequenceCheckingTypeAndReplace() const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->IsCTLSequenceCheckingTypeAndReplace(); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions::SetCTLCursorMovement( SvtCTLOptions::CursorMovement _eMovement ) +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + pCTLOptions->SetCTLCursorMovement( _eMovement ); +} +// ----------------------------------------------------------------------------- +SvtCTLOptions::CursorMovement SvtCTLOptions::GetCTLCursorMovement() const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->GetCTLCursorMovement(); +} +// ----------------------------------------------------------------------------- +void SvtCTLOptions::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumerals ) +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + pCTLOptions->SetCTLTextNumerals( _eNumerals ); +} +// ----------------------------------------------------------------------------- +SvtCTLOptions::TextNumerals SvtCTLOptions::GetCTLTextNumerals() const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->GetCTLTextNumerals(); +} +// ----------------------------------------------------------------------------- +sal_Bool SvtCTLOptions::IsReadOnly(EOption eOption) const +{ + DBG_ASSERT( pCTLOptions->IsLoaded(), "CTL options not loaded" ); + return pCTLOptions->IsReadOnly(eOption); +} +// ----------------------------------------------------------------------------- + diff --git a/svl/source/config/itemholder2.cxx b/svl/source/config/itemholder2.cxx new file mode 100644 index 000000000000..b0ec824f2b17 --- /dev/null +++ b/svl/source/config/itemholder2.cxx @@ -0,0 +1,179 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svl.hxx" + +#include "itemholder2.hxx" + +//----------------------------------------------- +// includes +#include <comphelper/processfactory.hxx> +#include <com/sun/star/lang/XComponent.hpp> + +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> +#include <svl/languageoptions.hxx> +#include <unotools/options.hxx> + +#include <tools/debug.hxx> + +//----------------------------------------------- +// namespaces + +namespace css = ::com::sun::star; + +//----------------------------------------------- +// declarations + +//----------------------------------------------- +ItemHolder2::ItemHolder2() + : ItemHolderMutexBase() +{ + try + { + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); + css::uno::Reference< css::lang::XComponent > xCfg( + xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), + css::uno::UNO_QUERY); + if (xCfg.is()) + xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this)); + } +// #i37892 got errorhandling from ConfigManager::GetConfigurationProvider() + catch(css::uno::RuntimeException& rREx) + { + throw rREx; + } +#ifdef DBG_UTIL + catch(css::uno::Exception& rEx) + { + static sal_Bool bMessage = sal_True; + if(bMessage) + { + bMessage = sal_False; + ::rtl::OString sMsg("CreateInstance with arguments exception: "); + sMsg += ::rtl::OString(rEx.Message.getStr(), + rEx.Message.getLength(), + RTL_TEXTENCODING_ASCII_US); + DBG_ERROR(sMsg.getStr()); + } + } +#else + catch(css::uno::Exception&){} +#endif +} + +//----------------------------------------------- +ItemHolder2::~ItemHolder2() +{ + impl_releaseAllItems(); +} + +//----------------------------------------------- +void ItemHolder2::holdConfigItem(EItem eItem) +{ + static ItemHolder2* pHolder = new ItemHolder2(); + pHolder->impl_addItem(eItem); +} + +//----------------------------------------------- +void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&) + throw(css::uno::RuntimeException) +{ + impl_releaseAllItems(); +} + +//----------------------------------------------- +void ItemHolder2::impl_addItem(EItem eItem) +{ + ::osl::ResettableMutexGuard aLock(m_aLock); + + TItems::const_iterator pIt; + for ( pIt = m_lItems.begin(); + pIt != m_lItems.end() ; + ++pIt ) + { + const TItemInfo& rInfo = *pIt; + if (rInfo.eItem == eItem) + return; + } + + TItemInfo aNewItem; + aNewItem.eItem = eItem; + impl_newItem(aNewItem); + if (aNewItem.pItem) + m_lItems.push_back(aNewItem); +} + +//----------------------------------------------- +void ItemHolder2::impl_releaseAllItems() +{ + ::osl::ResettableMutexGuard aLock(m_aLock); + + TItems::iterator pIt; + for ( pIt = m_lItems.begin(); + pIt != m_lItems.end() ; + ++pIt ) + { + TItemInfo& rInfo = *pIt; + impl_deleteItem(rInfo); + } + m_lItems.clear(); +} + +//----------------------------------------------- +void ItemHolder2::impl_newItem(TItemInfo& rItem) +{ + switch(rItem.eItem) + { + case E_CJKOPTIONS : + rItem.pItem = new SvtCJKOptions(); + break; + + case E_CTLOPTIONS : + rItem.pItem = new SvtCTLOptions(); + break; + + case E_LANGUAGEOPTIONS : +// capsulate CTL and CJL options ! rItem.pItem = new SvtLanguageOptions(); + break; + + default: + OSL_ASSERT(false); + break; + } +} + +//----------------------------------------------- +void ItemHolder2::impl_deleteItem(TItemInfo& rItem) +{ + if (rItem.pItem) + { + delete rItem.pItem; + rItem.pItem = 0; + } +} diff --git a/svl/source/config/itemholder2.hxx b/svl/source/config/itemholder2.hxx new file mode 100644 index 000000000000..9314021b5750 --- /dev/null +++ b/svl/source/config/itemholder2.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_ +#define INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_ + +//----------------------------------------------- +// includes + +#include <unotools/itemholderbase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/lang/XEventListener.hpp> + +//----------------------------------------------- +// namespaces + +#ifdef css +#error "Cant use css as namespace alias." +#else +#define css ::com::sun::star +#endif + +//----------------------------------------------- +// definitions + +class ItemHolder2 : private ItemHolderMutexBase + , public ::cppu::WeakImplHelper1< css::lang::XEventListener > +{ + //........................................... + // member + private: + + TItems m_lItems; + + //........................................... + // c++ interface + public: + + ItemHolder2(); + virtual ~ItemHolder2(); + static void holdConfigItem(EItem eItem); + + //........................................... + // uno interface + public: + + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) + throw(css::uno::RuntimeException); + + //........................................... + // helper + private: + + void impl_addItem(EItem eItem); + void impl_releaseAllItems(); + void impl_newItem(TItemInfo& rItem); + void impl_deleteItem(TItemInfo& rItem); +}; + +//----------------------------------------------- +// namespaces + +#undef css + +#endif // INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_ diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx new file mode 100644 index 000000000000..8f9aabd59500 --- /dev/null +++ b/svl/source/config/languageoptions.cxx @@ -0,0 +1,276 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svl.hxx" + +#include <svl/languageoptions.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> +#include <i18npool/mslangid.hxx> +#include <vos/mutex.hxx> +#include <osl/mutex.hxx> +#include <rtl/instance.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <unotools/syslocale.hxx> + +using namespace ::com::sun::star; +// global ---------------------------------------------------------------------- + +namespace { struct ALMutex : public rtl::Static< ::osl::Mutex, ALMutex > {}; } + +// class SvtLanguageOptions ---------------------------------------------------- + +SvtLanguageOptions::SvtLanguageOptions( sal_Bool _bDontLoad ) +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( ALMutex::get() ); + + m_pCJKOptions = new SvtCJKOptions( _bDontLoad ); + m_pCTLOptions = new SvtCTLOptions( _bDontLoad ); + m_pCTLOptions->AddListener(this); + m_pCJKOptions->AddListener(this); +} +//------------------------------------------------------------------------------ +SvtLanguageOptions::~SvtLanguageOptions() +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( ALMutex::get() ); + + m_pCTLOptions->RemoveListener(this); + m_pCJKOptions->RemoveListener(this); + + delete m_pCJKOptions; + delete m_pCTLOptions; +} +//------------------------------------------------------------------------------ +// CJK options ----------------------------------------------------------------- +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsCJKFontEnabled() const +{ + return m_pCJKOptions->IsCJKFontEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsVerticalTextEnabled() const +{ + return m_pCJKOptions->IsVerticalTextEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsAsianTypographyEnabled() const +{ + return m_pCJKOptions->IsAsianTypographyEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsJapaneseFindEnabled() const +{ + return m_pCJKOptions->IsJapaneseFindEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsRubyEnabled() const +{ + return m_pCJKOptions->IsRubyEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsChangeCaseMapEnabled() const +{ + return m_pCJKOptions->IsChangeCaseMapEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsDoubleLinesEnabled() const +{ + return m_pCJKOptions->IsDoubleLinesEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsEmphasisMarksEnabled() const +{ + return m_pCJKOptions->IsEmphasisMarksEnabled(); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsVerticalCallOutEnabled() const +{ + return m_pCJKOptions->IsVerticalCallOutEnabled(); +} +//------------------------------------------------------------------------------ +void SvtLanguageOptions::SetAll( sal_Bool _bSet ) +{ + m_pCJKOptions->SetAll( _bSet ); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsAnyEnabled() const +{ + return m_pCJKOptions->IsAnyEnabled(); +} +//------------------------------------------------------------------------------ +// CTL options ----------------------------------------------------------------- +//------------------------------------------------------------------------------ +void SvtLanguageOptions::SetCTLFontEnabled( sal_Bool _bEnabled ) +{ + m_pCTLOptions->SetCTLFontEnabled( _bEnabled ); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsCTLFontEnabled() const +{ + return m_pCTLOptions->IsCTLFontEnabled(); +} +//------------------------------------------------------------------------------ +void SvtLanguageOptions::SetCTLSequenceChecking( sal_Bool _bEnabled ) +{ + m_pCTLOptions->SetCTLSequenceChecking( _bEnabled ); +} +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsCTLSequenceChecking() const +{ + return m_pCTLOptions->IsCTLSequenceChecking(); +} +/*-- 26.09.2005 15:48:23--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtLanguageOptions::SetCTLSequenceCheckingRestricted( sal_Bool _bEnable ) +{ + m_pCTLOptions->SetCTLSequenceCheckingRestricted( _bEnable ); +} +/*-- 26.09.2005 15:48:23--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool SvtLanguageOptions::IsCTLSequenceCheckingRestricted( void ) const +{ + return m_pCTLOptions->IsCTLSequenceCheckingRestricted(); +} +/*-- 26.09.2005 15:48:23--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtLanguageOptions::SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable ) +{ + m_pCTLOptions->SetCTLSequenceCheckingTypeAndReplace( _bEnable ); +} +/*-- 26.09.2005 15:48:24--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool SvtLanguageOptions::IsCTLSequenceCheckingTypeAndReplace() const +{ + return m_pCTLOptions->IsCTLSequenceCheckingTypeAndReplace(); +} + +//------------------------------------------------------------------------------ +sal_Bool SvtLanguageOptions::IsReadOnly(SvtLanguageOptions::EOption eOption) const +{ + sal_Bool bReadOnly = sal_False; + switch(eOption) + { + // cjk options + case SvtLanguageOptions::E_CJKFONT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CJKFONT ); break; + case SvtLanguageOptions::E_VERTICALTEXT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALTEXT ); break; + case SvtLanguageOptions::E_ASIANTYPOGRAPHY : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ASIANTYPOGRAPHY); break; + case SvtLanguageOptions::E_JAPANESEFIND : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_JAPANESEFIND ); break; + case SvtLanguageOptions::E_RUBY : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_RUBY ); break; + case SvtLanguageOptions::E_CHANGECASEMAP : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_CHANGECASEMAP ); break; + case SvtLanguageOptions::E_DOUBLELINES : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_DOUBLELINES ); break; + case SvtLanguageOptions::E_EMPHASISMARKS : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_EMPHASISMARKS ); break; + case SvtLanguageOptions::E_VERTICALCALLOUT : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_VERTICALCALLOUT); break; + case SvtLanguageOptions::E_ALLCJK : bReadOnly = m_pCJKOptions->IsReadOnly(SvtCJKOptions::E_ALL ); break; + // ctl options + case SvtLanguageOptions::E_CTLFONT : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLFONT ); break; + case SvtLanguageOptions::E_CTLSEQUENCECHECKING : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLSEQUENCECHECKING); break; + case SvtLanguageOptions::E_CTLCURSORMOVEMENT : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLCURSORMOVEMENT ); break; + case SvtLanguageOptions::E_CTLTEXTNUMERALS : bReadOnly = m_pCTLOptions->IsReadOnly(SvtCTLOptions::E_CTLTEXTNUMERALS ); break; + } + return bReadOnly; +} +/* -----------------30.04.2003 11:03-----------------*/ + +// returns for a language the scripttype +sal_uInt16 SvtLanguageOptions::GetScriptTypeOfLanguage( sal_uInt16 nLang ) +{ + if( LANGUAGE_DONTKNOW == nLang ) + nLang = LANGUAGE_ENGLISH_US; + else if( LANGUAGE_SYSTEM == nLang ) + nLang = SvtSysLocale().GetLanguage(); + + sal_Int16 nScriptType = MsLangId::getScriptType( nLang ); + USHORT nScript; + switch (nScriptType) + { + case ::com::sun::star::i18n::ScriptType::ASIAN: + nScript = SCRIPTTYPE_ASIAN; + break; + case ::com::sun::star::i18n::ScriptType::COMPLEX: + nScript = SCRIPTTYPE_COMPLEX; + break; + default: + nScript = SCRIPTTYPE_LATIN; + } + return nScript; +} +// ----------------------------------------------------------------------------- + + +/*-- 27.10.2005 08:18:01--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SvtSystemLanguageOptions::SvtSystemLanguageOptions() : + utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("System/L10N") )) +{ + uno::Sequence< rtl::OUString > aPropertyNames(1); + rtl::OUString* pNames = aPropertyNames.getArray(); + pNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SystemLocale")); + uno::Sequence< uno::Any > aValues = GetProperties( aPropertyNames ); + + if ( aValues.getLength() ) + { + aValues[0]>>= m_sWin16SystemLocale; + } +} +/*-- 27.10.2005 08:18:01--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SvtSystemLanguageOptions::~SvtSystemLanguageOptions() +{ +} +/*-- 27.10.2005 08:18:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtSystemLanguageOptions::Commit() +{ + //does nothing +} + +void SvtSystemLanguageOptions::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) +{ + // no listeners supported yet +} + +/*-- 27.10.2005 08:36:14--------------------------------------------------- + + -----------------------------------------------------------------------*/ +LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage() +{ + if( m_sWin16SystemLocale.getLength() == 0 ) + return LANGUAGE_NONE; + return MsLangId::convertIsoStringToLanguage( m_sWin16SystemLocale ); +} + + diff --git a/svl/source/config/makefile.mk b/svl/source/config/makefile.mk new file mode 100644 index 000000000000..beb696c0feaf --- /dev/null +++ b/svl/source/config/makefile.mk @@ -0,0 +1,52 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=svl +TARGET=config + +ENABLE_EXCEPTIONS := TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/svl.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/asiancfg.obj \ + $(SLO)$/cjkoptions.obj \ + $(SLO)$/ctloptions.obj \ + $(SLO)$/srchcfg.obj \ + $(SLO)$/itemholder2.obj \ + $(SLO)$/languageoptions.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/svl/source/config/srchcfg.cxx b/svl/source/config/srchcfg.cxx new file mode 100644 index 000000000000..cf9fd1799650 --- /dev/null +++ b/svl/source/config/srchcfg.cxx @@ -0,0 +1,287 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svl.hxx" + +#include <svl/srchcfg.hxx> +#include <svl/svarray.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <tools/debug.hxx> +#include <unotools/configpathes.hxx> + +//----------------------------------------------------------------------------- +using namespace utl; +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; + +#define C2U(cChar) OUString::createFromAscii(cChar) + +//----------------------------------------------------------------------------- +typedef SvxSearchEngineData* SvxSearchEngineDataPtr; +SV_DECL_PTRARR_DEL(SvxSearchEngineArr, SvxSearchEngineDataPtr, 2, 2) +SV_IMPL_PTRARR(SvxSearchEngineArr, SvxSearchEngineDataPtr); +//----------------------------------------------------------------------------- +struct SvxSearchConfig_Impl +{ + SvxSearchEngineArr aEngineArr; +}; +/* -----------------------------19.03.01 14:00-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SvxSearchEngineData::operator==(const SvxSearchEngineData& rData) +{ + return sEngineName == rData.sEngineName && + sAndPrefix == rData.sAndPrefix && + sAndSuffix == rData.sAndSuffix && + sAndSeparator == rData.sAndSeparator && + nAndCaseMatch == rData.nAndCaseMatch && + sOrPrefix == rData.sOrPrefix && + sOrSuffix == rData.sOrSuffix && + sOrSeparator == rData.sOrSeparator && + nOrCaseMatch == rData.nOrCaseMatch && + sExactPrefix == rData.sExactPrefix && + sExactSuffix == rData.sExactSuffix && + sExactSeparator == rData.sExactSeparator && + nExactCaseMatch == rData.nExactCaseMatch; +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +const Sequence<OUString>& lcl_GetSearchPropertyNames_Impl() +{ + static Sequence<OUString> aNames; + if(!aNames.getLength()) + { + aNames.realloc(12); + OUString* pNames = aNames.getArray(); + pNames[0] = C2U("And/ooInetPrefix"); + pNames[1] = C2U("And/ooInetSuffix"); + pNames[2] = C2U("And/ooInetSeparator"); + pNames[3] = C2U("And/ooInetCaseMatch"); + pNames[4] = C2U("Or/ooInetPrefix"); + pNames[5] = C2U("Or/ooInetSuffix"); + pNames[6] = C2U("Or/ooInetSeparator"); + pNames[7] = C2U("Or/ooInetCaseMatch"); + pNames[8] = C2U("Exact/ooInetPrefix"); + pNames[9] = C2U("Exact/ooInetSuffix"); + pNames[10] = C2U("Exact/ooInetSeparator"); + pNames[11] = C2U("Exact/ooInetCaseMatch"); + } + return aNames; +} +// --------------------------------------------------------------------------- +SvxSearchConfig::SvxSearchConfig(sal_Bool bEnableNotify) : + utl::ConfigItem(C2U("Inet/SearchEngines"), CONFIG_MODE_DELAYED_UPDATE), + pImpl(new SvxSearchConfig_Impl) +{ + if(bEnableNotify) + { + //request notifications from the node + Sequence<OUString> aEnable(1); + EnableNotification(aEnable); + } + Load(); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +SvxSearchConfig::~SvxSearchConfig() +{ + delete pImpl; +} +/* -----------------------------17.01.01 09:57-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxSearchConfig::Load() +{ + pImpl->aEngineArr.DeleteAndDestroy(0, pImpl->aEngineArr.Count()); + Sequence<OUString> aNodeNames = GetNodeNames(OUString()); + const OUString* pNodeNames = aNodeNames.getConstArray(); + for(sal_Int32 nNode = 0; nNode < aNodeNames.getLength(); nNode++) + { + SvxSearchEngineDataPtr pNew = new SvxSearchEngineData; + pNew->sEngineName = pNodeNames[nNode]; + const Sequence<OUString>& rPropNames = lcl_GetSearchPropertyNames_Impl(); + const OUString* pPropNames = rPropNames.getConstArray(); + Sequence<OUString> aPropertyNames(rPropNames.getLength()); + OUString* pPropertyNames = aPropertyNames.getArray(); + const OUString sSlash(C2U("/")); + sal_Int32 nProp; + for(nProp = 0; nProp < rPropNames.getLength(); nProp++) + { + pPropertyNames[nProp] = wrapConfigurationElementName(pNodeNames[nNode]); + pPropertyNames[nProp] += sSlash; + pPropertyNames[nProp] += pPropNames[nProp]; + } + Sequence<Any> aValues = GetProperties(aPropertyNames); + const Any* pValues = aValues.getConstArray(); + for(nProp = 0; nProp < rPropNames.getLength(); nProp++) + { + switch(nProp) + { + case 0 : pValues[nProp] >>= pNew->sAndPrefix; break; + case 1 : pValues[nProp] >>= pNew->sAndSuffix; break; + case 2 : pValues[nProp] >>= pNew->sAndSeparator; break; + case 3 : pValues[nProp] >>= pNew->nAndCaseMatch; break; + + case 4 : pValues[nProp] >>= pNew->sOrPrefix; break; + case 5 : pValues[nProp] >>= pNew->sOrSuffix; break; + case 6 : pValues[nProp] >>= pNew->sOrSeparator; break; + case 7 : pValues[nProp] >>= pNew->nOrCaseMatch; break; + + case 8 : pValues[nProp] >>= pNew->sExactPrefix; break; + case 9 : pValues[nProp] >>= pNew->sExactSuffix; break; + case 10: pValues[nProp] >>= pNew->sExactSeparator; break; + case 11: pValues[nProp] >>= pNew->nExactCaseMatch; break; + } + } + pImpl->aEngineArr.Insert(pNew, pImpl->aEngineArr.Count()); + } +} +/* -----------------------------17.01.01 09:57-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxSearchConfig::Notify( const Sequence<OUString>& ) +{ + Load(); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxSearchConfig::Commit() +{ + OUString sNode; + if(!pImpl->aEngineArr.Count()) + ClearNodeSet(sNode); + else + { + Sequence<PropertyValue> aSetValues(12 * pImpl->aEngineArr.Count()); + PropertyValue* pSetValues = aSetValues.getArray(); + + const Sequence<OUString>& rPropNames = lcl_GetSearchPropertyNames_Impl(); + const OUString* pPropNames = rPropNames.getConstArray(); + const OUString sSlash(C2U("/")); + for(sal_uInt16 i = 0; i < pImpl->aEngineArr.Count(); i++) + { + SvxSearchEngineDataPtr pSave = pImpl->aEngineArr[i]; + for(sal_Int16 nProp = 0; nProp < rPropNames.getLength(); nProp++) + { + OUString sTmpName = sSlash; + sTmpName += wrapConfigurationElementName(pSave->sEngineName); + sTmpName += sSlash; + sTmpName += pPropNames[nProp]; + pSetValues[nProp].Name = sTmpName; + switch(nProp) + { + case 0 : pSetValues[nProp].Value <<= pSave->sAndPrefix; break; + case 1 : pSetValues[nProp].Value <<= pSave->sAndSuffix; break; + case 2 : pSetValues[nProp].Value <<= pSave->sAndSeparator; break; + case 3 : pSetValues[nProp].Value <<= pSave->nAndCaseMatch; break; + + case 4 : pSetValues[nProp].Value <<= pSave->sOrPrefix; break; + case 5 : pSetValues[nProp].Value <<= pSave->sOrSuffix; break; + case 6 : pSetValues[nProp].Value <<= pSave->sOrSeparator; break; + case 7 : pSetValues[nProp].Value <<= pSave->nOrCaseMatch; break; + + case 8 : pSetValues[nProp].Value <<= pSave->sExactPrefix; break; + case 9 : pSetValues[nProp].Value <<= pSave->sExactSuffix; break; + case 10: pSetValues[nProp].Value <<= pSave->sExactSeparator; break; + case 11: pSetValues[nProp].Value <<= pSave->nExactCaseMatch; break; + } + } + pSetValues+= 12; + } + ReplaceSetProperties(sNode, aSetValues); + } +} +/* -----------------------------19.03.01 10:02-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_uInt16 SvxSearchConfig::Count() +{ + return pImpl->aEngineArr.Count(); +} +/* -----------------------------19.03.01 10:02-------------------------------- + + ---------------------------------------------------------------------------*/ +const SvxSearchEngineData& SvxSearchConfig::GetData(sal_uInt16 nPos) +{ + DBG_ASSERT(nPos < pImpl->aEngineArr.Count(), "wrong array index"); + return *pImpl->aEngineArr[nPos]; +} +/* -----------------------------19.03.01 10:38-------------------------------- + + ---------------------------------------------------------------------------*/ +const SvxSearchEngineData* SvxSearchConfig::GetData(const rtl::OUString& rEngineName) +{ + for(sal_uInt16 nPos = 0; nPos < pImpl->aEngineArr.Count(); nPos++) + { + if(pImpl->aEngineArr[nPos]->sEngineName == rEngineName) + return pImpl->aEngineArr[nPos]; + } + return 0; +} +/* -----------------------------19.03.01 10:02-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxSearchConfig::SetData(const SvxSearchEngineData& rData) +{ + for(sal_uInt16 nPos = 0; nPos < pImpl->aEngineArr.Count(); nPos++) + { + if(pImpl->aEngineArr[nPos]->sEngineName == rData.sEngineName) + { + if((*pImpl->aEngineArr[nPos]) == rData) + return; + pImpl->aEngineArr.DeleteAndDestroy(nPos, 1); + break; + } + } + SvxSearchEngineDataPtr pInsert = new SvxSearchEngineData(rData); + pImpl->aEngineArr.Insert(pInsert, pImpl->aEngineArr.Count()); + SetModified(); +} +/* -----------------------------19.03.01 10:38-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvxSearchConfig::RemoveData(const rtl::OUString& rEngineName) +{ + for(sal_uInt16 nPos = 0; nPos < pImpl->aEngineArr.Count(); nPos++) + { + if(pImpl->aEngineArr[nPos]->sEngineName == rEngineName) + { + pImpl->aEngineArr.DeleteAndDestroy(nPos, 1); + SetModified(); + return ; + } + } +} + |