summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-09-30 16:33:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2010-09-30 16:33:23 +0100
commit5175ae0f49b98c8d93a85b6b3ec5f5ea1bfe743e (patch)
treea174d961dae4db83cfd8e6aa8247f34a67b849ac /svx
parentdb5f20a39371edfb77c4524ea2200a046c709ae6 (diff)
#i110142# make search/replace of colour names with translations safer
Diffstat (limited to 'svx')
-rw-r--r--svx/source/unodraw/unoprov.cxx18
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 );