On Saturday 16 February 2002 5:31 pm, Herbert Voss wrote:
> I have no problem with
> 
> \converter "user" "eps" "xmgrace -hardcopy -hdevice EPS $$i" ""
> 
> Herbert

Sure, Herbert, but it is still rather ugly, specifying user1, user2 etc. If 
Rob wants to define an agr format, then let's let him. I think that this 
would do it:

In GraphicsCacheItem::convert, the code snippet

        string const from = getExtFromContents(filename_);
        string const to   = findTargetFormat(from);

should be 

        string from = getFormatName(filename_);
                
        if (from.empty() || from == "user") {
                lyxerr << filename_
                         << "\nDon't recognise the file format either from its 
contents\n"
                         <<  "or from the extension (as a user-defined format)"
                         << std::endl;
                return false;
        }

        string const to   = findTargetFormat(from);

where

string getFormatName(string const & filename)
{
        // Note: getExtFromContents should be renamed as 
        // getFormatFromContents as that's what it does.
        string const try1 = getExtFromContents(filename);
        if (!try1.empty() && try1 != "user") {
                // The format is recognised fromt the file's contents
                return try1;
        }

        // Didn't recognise file from it's contents.
        // Is the extension defined by the user? If so, asume that that is correct
        formats::const_iterator it = 
                std::find_if(formats.begin(), formats.end(),
                           FindExt(GetExtension(filename_)));
        
        if (it == formats.end()) {
                // Unable to ascertain anything about this file!
                return string();
        }

        return it->name();
}

Reply via email to