summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-06 23:00:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-01-09 13:28:37 +0000
commit45b19123a63f23fe37b11b063d7567bf79ef09aa (patch)
treebefd8c637ac6fbdf94c05bb80c500fb781dd2bb4 /unotools
parentbcd9122715c7b708a65bee05a90dba3a38624ecb (diff)
simplify CharClass
multiple variants of toUpper (etc) some that take a non-const OUString or String and modify it some that take a const OUString or String and return a new one some that take part of a const OUString or String and return a new one
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/charclass.hxx50
-rw-r--r--unotools/source/i18n/charclass.cxx35
2 files changed, 23 insertions, 62 deletions
diff --git a/unotools/inc/unotools/charclass.hxx b/unotools/inc/unotools/charclass.hxx
index e7253f6c397d..9dafaec767d5 100644
--- a/unotools/inc/unotools/charclass.hxx
+++ b/unotools/inc/unotools/charclass.hxx
@@ -170,14 +170,22 @@ public:
// Wrapper implementations of class CharacterClassification
- String toUpper( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const;
- String toLower( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const;
- String toTitle( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const;
+ ::rtl::OUString uppercase( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const;
+ ::rtl::OUString lowercase( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const;
+ ::rtl::OUString titlecase( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const;
- ::rtl::OUString toUpper_rtl( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const;
- ::rtl::OUString toLower_rtl( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const;
- // use the postfix because compilers could get confused by the both similar versions
- // (me thinks they shouldn't, but in fact MSCV 6 does)
+ ::rtl::OUString uppercase( const ::rtl::OUString& _rStr ) const
+ {
+ return uppercase(_rStr, 0, _rStr.getLength());
+ }
+ ::rtl::OUString lowercase( const ::rtl::OUString& _rStr ) const
+ {
+ return lowercase(_rStr, 0, _rStr.getLength());
+ }
+ ::rtl::OUString titlecase( const ::rtl::OUString& _rStr ) const
+ {
+ return titlecase(_rStr, 0, _rStr.getLength());
+ }
sal_Int16 getType( const String& rStr, xub_StrLen nPos ) const;
sal_Int16 getCharacterDirection( const String& rStr, xub_StrLen nPos ) const;
@@ -215,34 +223,6 @@ public:
sal_Bool isNumeric( const String& rStr ) const;
sal_Bool isAlphaNumeric( const String& rStr ) const;
sal_Bool isLetterNumeric( const String& rStr ) const;
-
- void toUpper( rtl::OUString& rStr ) const;
- void toUpper( String& rStr ) const
- {
- rStr = toUpper( rStr, 0, rStr.Len() );
- }
- void toLower( rtl::OUString& rStr ) const;
- void toLower( String& rStr ) const
- {
- rStr = toLower( rStr, 0, rStr.Len() );
- }
- inline String upper( const String& rStr ) const
- {
- return toUpper( rStr, 0, rStr.Len() );
- }
- inline String lower( const String& rStr ) const
- {
- return toLower( rStr, 0, rStr.Len() );
- }
-
- const ::rtl::OUString& toUpper_rtl( ::rtl::OUString& _rStr ) const
- {
- return _rStr = toUpper_rtl( _rStr, 0, _rStr.getLength() );
- }
- const ::rtl::OUString& toLower_rtl( ::rtl::OUString& _rStr ) const
- {
- return _rStr = toLower_rtl( _rStr, 0, _rStr.getLength() );
- }
};
#endif // _UNOTOOLS_CHARCLASS_HXX
diff --git a/unotools/source/i18n/charclass.cxx b/unotools/source/i18n/charclass.cxx
index f3c1d416f34a..c169a6614b6a 100644
--- a/unotools/source/i18n/charclass.cxx
+++ b/unotools/source/i18n/charclass.cxx
@@ -276,40 +276,23 @@ sal_Bool CharClass::isLetterNumeric( const String& rStr ) const
}
}
-void CharClass::toUpper( rtl::OUString& rStr ) const
-{
- rStr = toUpper_rtl(rStr, 0, rStr.getLength());
-}
-
-String CharClass::toUpper( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const
-{
- return toUpper_rtl(rStr, nPos, nCount);
-}
-
-String CharClass::toLower( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const
-{
- return toLower_rtl(::rtl::OUString(rStr), nPos, nCount);
-}
-
-
-String CharClass::toTitle( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const
+rtl::OUString CharClass::titlecase(const rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount) const
{
try
{
if ( xCC.is() )
return xCC->toTitle( rStr, nPos, nCount, getLocale() );
else
- return rStr.Copy( nPos, nCount );
+ return rStr.copy( nPos, nCount );
}
catch ( const Exception& )
{
- DBG_ERRORFILE( "toTitle: Exception caught!" );
- return rStr.Copy( nPos, nCount );
+ DBG_ERRORFILE( "titlecase: Exception caught!" );
+ return rStr.copy( nPos, nCount );
}
}
-
-::rtl::OUString CharClass::toUpper_rtl( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const
+::rtl::OUString CharClass::uppercase( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const
{
try
{
@@ -320,13 +303,12 @@ String CharClass::toTitle( const String& rStr, xub_StrLen nPos, xub_StrLen nCoun
}
catch ( const Exception& )
{
- DBG_ERRORFILE( "toUpper: Exception caught!" );
+ DBG_ERRORFILE( "uppercase: Exception caught!" );
return rStr.copy( nPos, nCount );
}
}
-
-::rtl::OUString CharClass::toLower_rtl( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const
+::rtl::OUString CharClass::lowercase( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const
{
try
{
@@ -337,12 +319,11 @@ String CharClass::toTitle( const String& rStr, xub_StrLen nPos, xub_StrLen nCoun
}
catch ( const Exception& )
{
- DBG_ERRORFILE( "toLower: Exception caught!" );
+ DBG_ERRORFILE( "lowercase: Exception caught!" );
return rStr.copy( nPos, nCount );
}
}
-
sal_Int16 CharClass::getType( const String& rStr, xub_StrLen nPos ) const
{
try