diff options
author | Noel Grandin <noel@peralex.com> | 2013-07-30 15:38:52 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-07-31 13:36:52 +0200 |
commit | 93257759580e6df10cc9eddbf1800a17d61cfc48 (patch) | |
tree | e8006965e5db2f73c9032d2769b767cfa5eb0c61 | |
parent | c9bb2e3d2c39638eabd24656a9642fa56464700e (diff) |
convert vcl/mnemonic.hxx from XubString to OUString
Change-Id: I2df7a6b29aa30ad5ad936b524061aeaef837ca9d
-rw-r--r-- | include/vcl/mnemonic.hxx | 8 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/GroupsSorting.cxx | 7 | ||||
-rw-r--r-- | svtools/source/contnr/imivctl1.cxx | 7 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 7 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/mnemonic.cxx | 94 | ||||
-rw-r--r-- | vcl/source/window/msgbox.cxx | 4 |
7 files changed, 65 insertions, 64 deletions
diff --git a/include/vcl/mnemonic.hxx b/include/vcl/mnemonic.hxx index 4ec22b5522a2..f6447254ed60 100644 --- a/include/vcl/mnemonic.hxx +++ b/include/vcl/mnemonic.hxx @@ -64,17 +64,17 @@ private: protected: SAL_DLLPRIVATE sal_uInt16 ImplGetMnemonicIndex( sal_Unicode c ); - SAL_DLLPRIVATE sal_Unicode ImplFindMnemonic( const XubString& rKey ); + SAL_DLLPRIVATE sal_Unicode ImplFindMnemonic( const OUString& rKey ); public: MnemonicGenerator(); - void RegisterMnemonic( const XubString& rKey ); - sal_Bool CreateMnemonic( XubString& rKey ); + void RegisterMnemonic( const OUString& rKey ); + OUString CreateMnemonic( const OUString& rKey ); ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > GetCharClass(); // returns a string where all '~'-characters and CJK mnemonics of the form (~A) are completely removed - static String EraseAllMnemonicChars( const String& rStr ); + static OUString EraseAllMnemonicChars( const OUString& rStr ); }; #endif // _SV_MNEMONIC_HXX diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index 4db90b4ab878..4d4f9fd078f1 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -985,9 +985,10 @@ OGroupsSortingDialog::OGroupsSortingDialog( Window* _pParent { pControls[i]->Show(sal_True); String sText = pControls[i]->GetText(); - if ( aMnemonicGenerator.CreateMnemonic(sText) ) - pControls[i]->SetText(sText); - sal_Int32 nTextWidth = GetTextWidth(sText); + OUString sNewText = aMnemonicGenerator.CreateMnemonic(sText); + if ( sText != sNewText ) + pControls[i]->SetText(sNewText); + sal_Int32 nTextWidth = GetTextWidth(sNewText); nMaxTextWidth = ::std::max<sal_Int32>(nTextWidth,nMaxTextWidth); } diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 805ce6fb45c6..f1e5084e06c9 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -341,10 +341,11 @@ void SvxIconChoiceCtrl_Impl::CreateAutoMnemonics( MnemonicGenerator* _pGenerator for( i = 0; i < nEntryCount; ++i ) { SvxIconChoiceCtrlEntry* pEntry = GetEntry( i ); - String aTxt = pEntry->GetText(); + OUString aTxt = pEntry->GetText(); - if( _pGenerator->CreateMnemonic( aTxt ) ) - pEntry->SetText( aTxt ); + OUString aNewText = _pGenerator->CreateMnemonic( aTxt ); + if( aNewText != aTxt ) + pEntry->SetText( aNewText ); } } diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 4f6d45860c99..eeb70a3c5648 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -221,9 +221,10 @@ void ImplWindowAutoMnemonic( Window* pWindow ) pChild = pGetChild->ImplGetWindow(); if ( ImplIsMnemonicCtrl( pChild ) ) { - XubString aText = pChild->GetText(); - if ( aMnemonicGenerator.CreateMnemonic( aText ) ) - pChild->SetText( aText ); + OUString aText = pChild->GetText(); + OUString aNewText = aMnemonicGenerator.CreateMnemonic( aText ); + if ( aText != aNewText ) + pChild->SetText( aNewText ); } pGetChild = nextLogicalChildOfParent(pWindow, pGetChild); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index ae45891b33ad..8d915154f77b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1023,7 +1023,7 @@ void Menu::CreateAutoMnemonics() { MenuItemData* pData = pItemList->GetDataFromPos( n ); if ( ! (pData->nBits & MIB_NOSELECT ) ) - aMnemonicGenerator.CreateMnemonic( pData->aText ); + pData->aText = aMnemonicGenerator.CreateMnemonic( pData->aText ); } } diff --git a/vcl/source/window/mnemonic.cxx b/vcl/source/window/mnemonic.cxx index 676bd562d852..0b55245d146b 100644 --- a/vcl/source/window/mnemonic.cxx +++ b/vcl/source/window/mnemonic.cxx @@ -64,12 +64,12 @@ sal_uInt16 MnemonicGenerator::ImplGetMnemonicIndex( sal_Unicode c ) // ----------------------------------------------------------------------- -sal_Unicode MnemonicGenerator::ImplFindMnemonic( const XubString& rKey ) +sal_Unicode MnemonicGenerator::ImplFindMnemonic( const OUString& rKey ) { - xub_StrLen nIndex = 0; - while ( (nIndex = rKey.Search( MNEMONIC_CHAR, nIndex )) != STRING_NOTFOUND ) + sal_Int32 nIndex = 0; + while ( (nIndex = rKey.indexOf( MNEMONIC_CHAR, nIndex )) != -1 ) { - sal_Unicode cMnemonic = rKey.GetChar( nIndex+1 ); + sal_Unicode cMnemonic = rKey[ nIndex+1 ]; if ( cMnemonic != MNEMONIC_CHAR ) return cMnemonic; nIndex += 2; @@ -80,7 +80,7 @@ sal_Unicode MnemonicGenerator::ImplFindMnemonic( const XubString& rKey ) // ----------------------------------------------------------------------- -void MnemonicGenerator::RegisterMnemonic( const XubString& rKey ) +void MnemonicGenerator::RegisterMnemonic( const OUString& rKey ) { const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetUILanguageTag().getLocale(); uno::Reference < i18n::XCharacterClassification > xCharClass = GetCharClass(); @@ -89,7 +89,7 @@ void MnemonicGenerator::RegisterMnemonic( const XubString& rKey ) if ( !xCharClass.is() ) return; - XubString aKey = xCharClass->toUpper( rKey, 0, rKey.Len(), rLocale ); + OUString aKey = xCharClass->toUpper( rKey, 0, rKey.getLength(), rLocale ); // If we find a Mnemonic, set the flag. In other case count the // characters, because we need this to set most as possible @@ -103,11 +103,11 @@ void MnemonicGenerator::RegisterMnemonic( const XubString& rKey ) } else { - xub_StrLen nIndex = 0; - xub_StrLen nLen = aKey.Len(); + sal_Int32 nIndex = 0; + sal_Int32 nLen = aKey.getLength(); while ( nIndex < nLen ) { - sal_Unicode c = aKey.GetChar( nIndex ); + sal_Unicode c = aKey[ nIndex ]; sal_uInt16 nMnemonicIndex = ImplGetMnemonicIndex( c ); if ( nMnemonicIndex != MNEMONIC_INDEX_NOTFOUND ) @@ -123,22 +123,22 @@ void MnemonicGenerator::RegisterMnemonic( const XubString& rKey ) // ----------------------------------------------------------------------- -sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) +OUString MnemonicGenerator::CreateMnemonic( const OUString& _rKey ) { - if ( !rKey.Len() || ImplFindMnemonic( rKey ) ) - return sal_False; + if ( _rKey.isEmpty() || ImplFindMnemonic( _rKey ) ) + return _rKey; const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetUILanguageTag().getLocale(); uno::Reference < i18n::XCharacterClassification > xCharClass = GetCharClass(); // Don't crash even when we don't have access to i18n service if ( !xCharClass.is() ) - return sal_False; + return _rKey; - XubString aKey = xCharClass->toUpper( rKey, 0, rKey.Len(), rLocale ); + OUString aKey = xCharClass->toUpper( _rKey, 0, _rKey.getLength(), rLocale ); sal_Bool bChanged = sal_False; - xub_StrLen nLen = aKey.Len(); + sal_Int32 nLen = aKey.getLength(); bool bCJK = MsLangId::isCJK(Application::GetSettings().GetUILanguageTag().getLanguageType()); @@ -152,11 +152,11 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) bool bLatinOnly = true; bool bMnemonicIndexFound = false; sal_Unicode c; - xub_StrLen nIndex; + sal_Int32 nIndex; for( nIndex=0; nIndex < nLen; nIndex++ ) { - c = aKey.GetChar( nIndex ); + c = aKey[ nIndex ]; if ( ((c >= 0x3000) && (c <= 0xD7FF)) || // cjk ((c >= 0xFF61) && (c <= 0xFFDC)) ) // halfwidth forms { @@ -167,20 +167,20 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) bMnemonicIndexFound = true; } if( bLatinOnly && !bMnemonicIndexFound ) - return sal_False; + return _rKey; } - + OUString rKey(_rKey); int nCJK = 0; - sal_uInt16 nMnemonicIndex; + sal_uInt16 nMnemonicIndex; sal_Unicode c; - xub_StrLen nIndex = 0; + sal_Int32 nIndex = 0; if( !bCJK ) { // 1) first try the first character of a word do { - c = aKey.GetChar( nIndex ); + c = aKey[ nIndex ]; if ( nCJK != 2 ) { @@ -201,7 +201,7 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) if ( maMnemonics[nMnemonicIndex] ) { maMnemonics[nMnemonicIndex] = 0; - rKey.Insert( MNEMONIC_CHAR, nIndex ); + rKey = rKey.replaceAt( nIndex, 0, OUString(MNEMONIC_CHAR) ); bChanged = sal_True; break; } @@ -211,7 +211,7 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) do { nIndex++; - c = aKey.GetChar( nIndex ); + c = aKey[ nIndex ]; if ( c == ' ' ) break; } @@ -225,11 +225,11 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) { sal_uInt16 nBestCount = 0xFFFF; sal_uInt16 nBestMnemonicIndex = 0; - xub_StrLen nBestIndex = 0; + sal_Int32 nBestIndex = 0; nIndex = 0; do { - c = aKey.GetChar( nIndex ); + c = aKey[ nIndex ]; nMnemonicIndex = ImplGetMnemonicIndex( c ); if ( nMnemonicIndex != MNEMONIC_INDEX_NOTFOUND ) { @@ -253,7 +253,7 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) if ( nBestCount != 0xFFFF ) { maMnemonics[nBestMnemonicIndex] = 0; - rKey.Insert( MNEMONIC_CHAR, nBestIndex ); + rKey = rKey.replaceAt( nBestIndex, 0, OUString(MNEMONIC_CHAR) ); bChanged = sal_True; } } @@ -262,7 +262,7 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) nCJK = 1; // 3) Add English Mnemonic for CJK Text - if ( !bChanged && (nCJK == 1) && rKey.Len() ) + if ( !bChanged && (nCJK == 1) && !rKey.isEmpty() ) { // Append Ascii Mnemonic for ( c = MNEMONIC_RANGE_2_START; c <= MNEMONIC_RANGE_2_END; c++ ) @@ -276,31 +276,29 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) OUString aStr = OUStringBuffer(). append('(').append(MNEMONIC_CHAR).append(c). append(')').makeStringAndClear(); - nIndex = rKey.Len(); + nIndex = rKey.getLength(); if( nIndex >= 2 ) { - static const sal_Unicode cGreaterGreater[] = { 0xFF1E, 0xFF1E }; - if ( rKey.EqualsAscii( ">>", nIndex-2, 2 ) || - rKey.Equals( cGreaterGreater, nIndex-2, 2 ) ) + if ( ( rKey[nIndex-2] == '>' && rKey[nIndex-1] == '>' ) || + ( rKey[nIndex-2] == 0xFF1E && rKey[nIndex-1] == 0xFF1E ) ) nIndex -= 2; } if( nIndex >= 3 ) { - static const sal_Unicode cDotDotDot[] = { 0xFF0E, 0xFF0E, 0xFF0E }; - if ( rKey.EqualsAscii( "...", nIndex-3, 3 ) || - rKey.Equals( cDotDotDot, nIndex-3, 3 ) ) + if ( ( rKey[nIndex-3] == '.' && rKey[nIndex-2] == '.' && rKey[nIndex-1] == '.' ) || + ( rKey[nIndex-3] == 0xFF0E && rKey[nIndex-2] == 0xFF0E && rKey[nIndex-1] == 0xFF0E ) ) nIndex -= 3; } if( nIndex >= 1) { - sal_Unicode cLastChar = rKey.GetChar( nIndex-1 ); + sal_Unicode cLastChar = rKey[ nIndex-1 ]; if ( (cLastChar == ':') || (cLastChar == 0xFF1A) || (cLastChar == '.') || (cLastChar == 0xFF0E) || (cLastChar == '?') || (cLastChar == 0xFF1F) || (cLastChar == ' ') ) nIndex--; } - rKey.Insert( aStr, nIndex ); + rKey = rKey.replaceAt( nIndex, 0, aStr ); bChanged = sal_True; break; } @@ -344,7 +342,7 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) // while ( nIndex < nLen ); // } - return bChanged; + return rKey; } // ----------------------------------------------------------------------- @@ -358,25 +356,25 @@ uno::Reference< i18n::XCharacterClassification > MnemonicGenerator::GetCharClass // ----------------------------------------------------------------------- -String MnemonicGenerator::EraseAllMnemonicChars( const String& rStr ) +OUString MnemonicGenerator::EraseAllMnemonicChars( const OUString& rStr ) { - String aStr = rStr; - xub_StrLen nLen = aStr.Len(); - xub_StrLen i = 0; + OUString aStr = rStr; + sal_Int32 nLen = aStr.getLength(); + sal_Int32 i = 0; while ( i < nLen ) { - if ( aStr.GetChar( i ) == '~' ) + if ( aStr[ i ] == '~' ) { // check for CJK-style mnemonic if( i > 0 && (i+2) < nLen ) { - sal_Unicode c = aStr.GetChar(i+1); - if( aStr.GetChar( i-1 ) == '(' && - aStr.GetChar( i+2 ) == ')' && + sal_Unicode c = aStr[i+1]; + if( aStr[ i-1 ] == '(' && + aStr[ i+2 ] == ')' && c >= MNEMONIC_RANGE_2_START && c <= MNEMONIC_RANGE_2_END ) { - aStr.Erase( i-1, 4 ); + aStr = aStr.replaceAt( i-1, 4, "" ); nLen -= 4; i--; continue; @@ -384,7 +382,7 @@ String MnemonicGenerator::EraseAllMnemonicChars( const String& rStr ) } // remove standard mnemonics - aStr.Erase( i, 1 ); + aStr = aStr.replaceAt( i, 1, "" ); nLen--; } else diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index ab5131b97baf..83ab1ae135af 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -351,14 +351,14 @@ void MessBox::ImplPosControls() // checkbox length including a temporary mnemonic, the correct auto mnemonic will be // generated later in the dialog (see init_show) - String aMnemonicString( maCheckBoxText ); + OUString aMnemonicString( maCheckBoxText ); if( GetSettings().GetStyleSettings().GetAutoMnemonic() ) { if( aMnemonicString == GetNonMnemonicString( maCheckBoxText ) ) { // no mnemonic found -> create one MnemonicGenerator aMnemonicGenerator; - aMnemonicGenerator.CreateMnemonic( aMnemonicString ); + aMnemonicString = aMnemonicGenerator.CreateMnemonic( aMnemonicString ); } } |