summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-07 13:35:24 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-11 16:17:27 -0500
commit6122a6c272436f0f1959f160406d2e4ecdd1a733 (patch)
tree04eab77c0c87fd2e033b7691994b97a0dbdd498d /i18npool
parent94934248e73defcf96d2e58089b0a731b191f015 (diff)
Guard CharacterClassificationImpl with mutex.
They are accessed from multiple threads frequently. Change-Id: I3f9720ede076109efe0b7eaa4a05dd50f2e38102
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/characterclassificationImpl.hxx14
-rw-r--r--i18npool/source/characterclassification/characterclassificationImpl.cxx10
2 files changed, 19 insertions, 5 deletions
diff --git a/i18npool/inc/characterclassificationImpl.hxx b/i18npool/inc/characterclassificationImpl.hxx
index e220968640b0..24221d10f7b4 100644
--- a/i18npool/inc/characterclassificationImpl.hxx
+++ b/i18npool/inc/characterclassificationImpl.hxx
@@ -26,6 +26,8 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include "osl/mutex.hxx"
+
namespace com { namespace sun { namespace star { namespace i18n {
class CharacterClassificationImpl : public cppu::WeakImplHelper2
@@ -93,17 +95,19 @@ private:
aLocale.Variant == rLocale.Variant;
};
};
- std::vector<lookupTableItem*> lookupTable;
- lookupTableItem *cachedItem;
-
- com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
- com::sun::star::uno::Reference < XCharacterClassification > xUCI;
com::sun::star::uno::Reference < XCharacterClassification > SAL_CALL
getLocaleSpecificCharacterClassification(const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException);
sal_Bool SAL_CALL
createLocaleSpecificCharacterClassification(const OUString& serviceName, const com::sun::star::lang::Locale& rLocale);
+private:
+ std::vector<lookupTableItem*> lookupTable;
+ lookupTableItem *cachedItem;
+
+ com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
+ com::sun::star::uno::Reference < XCharacterClassification > xUCI;
+ osl::Mutex maMtx;
};
} } } }
diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx
index d65b5a5e8018..edcf9dbbbf25 100644
--- a/i18npool/source/characterclassification/characterclassificationImpl.cxx
+++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx
@@ -47,6 +47,7 @@ OUString SAL_CALL
CharacterClassificationImpl::toUpper( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->toUpper(Text, nPos, nCount, rLocale);
}
@@ -54,6 +55,7 @@ OUString SAL_CALL
CharacterClassificationImpl::toLower( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->toLower(Text, nPos, nCount, rLocale);
}
@@ -61,6 +63,7 @@ OUString SAL_CALL
CharacterClassificationImpl::toTitle( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->toTitle(Text, nPos, nCount, rLocale);
}
@@ -68,6 +71,7 @@ sal_Int16 SAL_CALL
CharacterClassificationImpl::getType( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
if (xUCI.is())
return xUCI->getType(Text, nPos);
throw RuntimeException();
@@ -77,6 +81,7 @@ sal_Int16 SAL_CALL
CharacterClassificationImpl::getCharacterDirection( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
if (xUCI.is())
return xUCI->getCharacterDirection(Text, nPos);
throw RuntimeException();
@@ -86,6 +91,7 @@ sal_Int16 SAL_CALL
CharacterClassificationImpl::getScript( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
if (xUCI.is())
return xUCI->getScript(Text, nPos);
throw RuntimeException();
@@ -95,6 +101,7 @@ sal_Int32 SAL_CALL
CharacterClassificationImpl::getCharacterType( const OUString& Text, sal_Int32 nPos,
const Locale& rLocale ) throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->getCharacterType(Text, nPos, rLocale);
}
@@ -102,6 +109,7 @@ sal_Int32 SAL_CALL
CharacterClassificationImpl::getStringType( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->getStringType(Text, nPos, nCount, rLocale);
}
@@ -111,6 +119,7 @@ ParseResult SAL_CALL CharacterClassificationImpl::parseAnyToken(
sal_Int32 contCharTokenType, const OUString& userDefinedCharactersCont )
throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->parseAnyToken(Text, nPos, rLocale,
startCharTokenType,userDefinedCharactersStart,
contCharTokenType, userDefinedCharactersCont);
@@ -123,6 +132,7 @@ ParseResult SAL_CALL CharacterClassificationImpl::parsePredefinedToken(
const OUString& userDefinedCharactersStart, sal_Int32 contCharTokenType,
const OUString& userDefinedCharactersCont ) throw(RuntimeException)
{
+ osl::MutexGuard aGuard(&maMtx);
return getLocaleSpecificCharacterClassification(rLocale)->parsePredefinedToken(
nTokenType, Text, nPos, rLocale, startCharTokenType, userDefinedCharactersStart,
contCharTokenType, userDefinedCharactersCont);