summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-05-02 12:17:45 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-05-02 12:17:45 +0000
commitbd4a119f5a7e8e44e779e33c7b1b2639555aa92b (patch)
tree74275a49d524a16c32b664f86689fbf44e23eab2 /vcl
parente4b58518ef7ab7c416b58444a56d285b7faf1d41 (diff)
more appropriate ConvertXPM
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/source/app/soicon.cxx47
1 files changed, 25 insertions, 22 deletions
diff --git a/vcl/unx/source/app/soicon.cxx b/vcl/unx/source/app/soicon.cxx
index 4034cb742659..a4674ff580de 100644
--- a/vcl/unx/source/app/soicon.cxx
+++ b/vcl/unx/source/app/soicon.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: soicon.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: ssa $ $Date: 2001-04-27 15:25:18 $
+ * last change: $Author: pl $ $Date: 2001-05-02 13:17:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -158,7 +158,7 @@ static void ConvertXpm( SalDisplay* pDisplay, char *xpm[], Pixmap& aPixmap, Pixm
XColor *pColors;
char *pColorAlias;
int nElement = 0,nColor = 0,i,nX,nY;
- char pColorName[16], pComName[16],pColorString[256];
+ char pColorString[256];
BOOL bTransparent = FALSE;
sscanf( xpm[ nElement++ ], "%d%d%d%d", &nWidth, &nHeight,
@@ -171,17 +171,26 @@ static void ConvertXpm( SalDisplay* pDisplay, char *xpm[], Pixmap& aPixmap, Pixm
pColorAlias = new char[ nColors * nCharsPerPixel ];
while( nElement <= nColors )
{
- sscanf( xpm[ nElement++ ],"%s %s %s",
- pColorName, pComName, pColorString);
- if( strncmp( pColorString, "None", 4 ) )
+ char* pLine = xpm[nElement++];
+ char* pStart = pLine + nCharsPerPixel;
+ while( *pStart && ( pStart[0] != 'c' || ! isspace( pStart[1] ) ) )
+ pStart++;
+ if( *pStart )
{
- XAllocNamedColor( pDisplay->GetDisplay(),
- DefaultColormap( pDisplay->GetDisplay(),
- pDisplay->GetScreenNumber() ),
- pColorString, &pColors[nColor], &pColors[nColor] );
- strncpy( &pColorAlias[nColor*nCharsPerPixel],
- pColorName, nCharsPerPixel );
- nColor++;
+ sscanf( pStart,"c %s", pColorString);
+#ifdef DEBUG
+ fprintf(stderr, "pColorString=\"%s\"\n", pColorString );
+#endif
+ if( strncasecmp( pColorString, "None", 4 ) )
+ {
+ XAllocNamedColor( pDisplay->GetDisplay(),
+ DefaultColormap( pDisplay->GetDisplay(),
+ pDisplay->GetScreenNumber() ),
+ pColorString, &pColors[nColor], &pColors[nColor] );
+ strncpy( &pColorAlias[nColor*nCharsPerPixel],
+ pLine, nCharsPerPixel );
+ nColor++;
+ }
}
}
nColors = nColor+1;
@@ -278,13 +287,14 @@ BOOL SelectAppIconPixmap( SalDisplay *pDisplay, USHORT nIcon, USHORT iconSize,
pIcon++;
}
- if( !pIcon->id )
+ if( !pIcon->id || pIcon->id == 1 ) // overwrite default icon
{
// call custom function to read icon
char customIconFn[256];
sprintf( customIconFn, "%s%d", VCL_CUSTOM_ICON_BASE, nIcon );
- if ( ( pCustomIcon = ( VCL_CUSTOM_ICON_FN* ) dlsym( RTLD_DEFAULT, customIconFn ) )
+ static void* pAppHdl = dlopen( NULL, RTLD_LAZY );
+ if ( ( pCustomIcon = ( VCL_CUSTOM_ICON_FN* ) dlsym( pAppHdl, customIconFn ) )
!= NULL )
{
pIcon = new SOICON[2]; // 2nd entry is terminator
@@ -292,13 +302,6 @@ BOOL SelectAppIconPixmap( SalDisplay *pDisplay, USHORT nIcon, USHORT iconSize,
pIcon->id = nIcon;
pCustomIcon( pIcon->xpmdata[0], pIcon->xpmdata[1], pIcon->xpmdata[2], pIcon->xpmdata[3] );
}
- else
- {
-#if defined DBG_UTIL || defined DEBUG
- fprintf( stderr, "SelectAppIconPixmap: custom icon function '%s' not found!\n",
- customIconFn );
-#endif
- }
}
DBG_ASSERT( pIcon->id, "SelectAppIconPixmap: Icon not found!");