diff options
author | Caolán McNamara <caolanm@redhat.com> | 2010-09-30 16:33:23 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2010-09-30 16:33:23 +0100 |
commit | 5175ae0f49b98c8d93a85b6b3ec5f5ea1bfe743e (patch) | |
tree | a174d961dae4db83cfd8e6aa8247f34a67b849ac | |
parent | db5f20a39371edfb77c4524ea2200a046c709ae6 (diff) |
#i110142# make search/replace of colour names with translations safer
-rw-r--r-- | svx/source/unodraw/unoprov.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index ea875d8d9427..a69aadd65634 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -1295,12 +1295,24 @@ static USHORT __READONLY_DATA SvxUnoColorNameResId[] = bool SvxUnoConvertResourceString( USHORT* pSourceResIds, USHORT* pDestResIds, int nCount, String& rString ) throw() { - int i = 0; + //We replace e.g. "Gray 10%" with the translation of Gray, but we shouldn't + //replace "Red Hat 1" with the translation of Red :-) + rtl::OUString sStr(rString); + const sal_Unicode *pStr = sStr.getStr(); + sal_Int32 nLength = sStr.getLength(); + while( nLength > 0 ) + { + const sal_Unicode nChar = pStr[nLength-1]; + if (nChar != '%' && (nChar < '0' || nChar > '9')) + break; + nLength--; + } + sStr = rtl::OUString(pStr, nLength).trim(); - for( i = 0; i < nCount; i++ ) + for(int i = 0; i < nCount; ++i ) { String aStrDefName = SVX_RESSTR( pSourceResIds[i] ); - if( rString.Search( aStrDefName ) == 0 ) + if( sStr.equals( aStrDefName ) ) { String aReplace = SVX_RESSTR( pDestResIds[i] ); rString.Replace( 0, aStrDefName.Len(), aReplace ); |