Пример #1
0
static bool WREHandleClipDataNames( WREResInfo *info, WResID *type,
                                    WResID **name, bool *replace )
{
    WRECurrentResInfo   curr;
    WREResRenameInfo    ren_info;
    uint_16             t;
    WResLangType        lang;
    bool                exists;
    bool                ok;

    lang.lang = DEF_LANG;
    lang.sublang = DEF_SUBLANG;
    ok = (info != NULL && info->info != NULL && type != NULL && name != NULL &&
          *name != NULL && replace != NULL);

    if( ok ) {
        t = 0;
        if( !type->IsName ) {
            t = type->ID.Num;
        }
        ok = (t != 0);
    }

    if( ok ) {
        exists = WRDoesNameExist( info->info->dir, type, *name );
        while( exists ) {
            ok = WREQueryPasteReplace( *name, t, replace );
            if( !ok ) {
                break;
            }
            if( *replace ) {
                curr.info = info;
                curr.type = WREFindTypeNodeFromWResID( info->info->dir, type );
                curr.res = WREFindResNodeFromWResID( curr.type, *name );
                curr.lang = WREFindLangNodeFromLangType( curr.res, &lang );
                ok = WREDeleteResource( &curr, TRUE );
                if( !ok ) {
                    break;
                }
            } else {
                ren_info.old_name = *name;
                ren_info.new_name = NULL;
                ok = (WREGetNewName( &ren_info ) && ren_info.new_name != NULL);
                if( ok ) {
                    WRMemFree( *name );
                    *name = ren_info.new_name;
                }
            }
            exists = WRDoesNameExist( info->info->dir, type, *name );
            if( exists && *replace ) {
                ok = false;
                break;
            }
        }
    }

    return( ok );
}
Пример #2
0
bool WRENewResource( WRECurrentResInfo *curr, WResID *tname, WResID *rname,
                     uint_16 memflags, uint_32 offset, uint_32 length,
                     WResLangType *lang, bool *dup, uint_16 type,
                     bool new_type )
{
    bool   ok;

    ok = (curr != NULL && curr->info != NULL && tname != NULL && rname != NULL &&
          lang != NULL);

    if( ok && ( curr->info->info->dir == NULL ) ) {
        ok = ((curr->info->info->dir = WResInitDir()) != NULL);
    }

    if( ok ) {
        ok = !WResAddResource( tname, rname, memflags, offset, length,
                               curr->info->info->dir, lang, dup );
    }

    if( ok ) {
        ok = (dup == NULL || (dup != NULL && !*dup));
    }

    if( ok ) {
        if( new_type ) {
            curr->info->current_type = 0;
            ok = WREInitResourceWindow( curr->info, type );
        } else {
            WRESetResNamesFromType( curr->info, type, TRUE, rname, 0 );
        }
    }

    if( ok && new_type ) {
        curr->type = WREFindTypeNodeFromWResID( curr->info->info->dir, tname );
        ok = (curr->type != NULL);
    }

    if( ok ) {
        curr->res = WREFindResNodeFromWResID( curr->type, rname );
        ok = (curr->res != NULL);
    }

    if( ok ) {
        curr->lang = WREFindLangNodeFromLangType( curr->res, lang );
        ok = (curr->lang != NULL);
    }

    return( ok );
}
Пример #3
0
static bool WREGetAndPasteBitmap( WREClipFormat *fmt, void *data, uint_32 dsize )
{
    WRECurrentResInfo   curr;
    WResLangType        lang;
    WResID              *ctype;
    WResID              *cname;
    bool                dup;
    bool                new_type;
    bool                replace;
    bool                ok;

    cname = NULL;
    ctype = NULL;
    new_type = TRUE;
    lang.lang = DEF_LANG;
    lang.sublang = DEF_SUBLANG;

    ok = (fmt != NULL && data != NULL && dsize != 0);

    if( ok ) {
        ctype = WResIDFromNum( fmt->type );
        ok = (ctype != NULL);
    }

    if( ok ) {
        cname = WRRecallBitmapName();
        if( cname == NULL ) {
            cname = WRECreateImageTitle( RESOURCE2INT( RT_BITMAP ) );
        }
        ok = (cname != NULL);
    }

    if( ok ) {
        WREGetCurrentResource( &curr );
        if( curr.info == NULL ) {
            curr.info = WRECreateNewResource( NULL );
            ok = (curr.info != NULL);
        }
    }

    if( ok ) {
        ok = WREHandleClipDataNames( curr.info, ctype, &cname, &replace );
    }

    if( ok ) {
        if( curr.info != NULL ) {
            if( curr.info->info->dir ) {
                new_type = (WREFindTypeNodeFromWResID( curr.info->info->dir,
                                                       ctype ) == NULL );
            }
        }
        ok = WRENewResource( &curr, ctype, cname, DEF_MEMFLAGS, 0,
                             dsize, &lang, &dup, RESOURCE2INT( RT_BITMAP ),
                             new_type ) && !dup;
    }

    if( ok ) {
        curr.lang->data = data;
        WRESetResModified( curr.info, TRUE );
    }

    if( cname != NULL ) {
        WRMemFree( cname );
    }

    if( ctype != NULL ) {
        WRMemFree( ctype );
    }

    return( ok );
}
Пример #4
0
static bool WREGetAndPasteIconOrCursor( WREClipFormat *fmt )
{
    WRECurrentResInfo   curr;
    WREClipData         *cdata;
    WResLangType        lang;
    WResID              *ctype;
    WResID              *cname;
    void                *data;
    uint_32             dsize;
    bool                dup;
    bool                new_type;
    bool                replace;
    bool                ok;

    cdata = NULL;
    cname = NULL;
    ctype = NULL;
    new_type = TRUE;
    lang.lang = DEF_LANG;
    lang.sublang = DEF_SUBLANG;

    ok = (fmt != NULL);

    if( ok ) {
        ctype = WResIDFromNum( fmt->type );
        ok = (ctype != NULL);
    }

    if( ok ) {
        ok = WREGetClipData( fmt, &data, &dsize );
    }

    if( ok ) {
        cdata = (WREClipData *)data;
        data = NULL;
        ok = (cdata != NULL);
    }

    if( ok ) {
        data = WRMemAlloc( cdata->data_size );
        ok = (data != NULL);
    }

    if( ok ) {
        memcpy( data, (BYTE *)cdata + cdata->data_offset, cdata->data_size );
        cname = WREGetClipDataName( cdata );
        ok = (cname != NULL);
    }

    if( ok ) {
        WREGetCurrentResource( &curr );
        if( curr.info == NULL ) {
            curr.info = WRECreateNewResource( NULL );
            ok = (curr.info != NULL);
        }
    }

    if( ok ) {
        ok = WREHandleClipDataNames( curr.info, ctype, &cname, &replace );
    }

    if( ok ) {
        if( curr.info != NULL ) {
            if( curr.info->info->dir ) {
                new_type = (WREFindTypeNodeFromWResID( curr.info->info->dir,
                                                       ctype ) == NULL );
            }
        }
        ok = WRENewResource( &curr, ctype, cname, cdata->memflags, 0,
                             (uint_32)cdata->data_size, &lang, &dup, fmt->type,
                             new_type ) && !dup;
    }

    if( ok ) {
        if( fmt->type == RESOURCE2INT( RT_GROUP_ICON ) ) {
            ok = WRECreateIconEntries( &curr, data, dsize );
        } else if( fmt->type == RESOURCE2INT( RT_GROUP_CURSOR ) ) {
            ok = WRECreateCursorEntries( &curr, data, dsize );
        } else {
            ok = false;
        }
    }

    if( ok ) {
        WRESetResModified( curr.info, TRUE );
    }

    if( data != NULL ) {
        WRMemFree( data );
    }

    if( cdata != NULL ) {
        WRMemFree( cdata );
    }

    if( cname != NULL ) {
        WRMemFree( cname );
    }

    if( ctype != NULL ) {
        WRMemFree( ctype );
    }

    if( !ok ) {
        if( data != NULL ) {
            WRMemFree( data );
        }
    }

    return( ok );
}