]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetExternal.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[features.git] / src / insets / InsetExternal.cpp
index daddd7134ad53a15791ea5aff46167d6c945e08c..643e1e2abbc333318c7c925ca8dcff13e5f6c4cf 100644 (file)
@@ -188,10 +188,9 @@ void InsetExternalParams::write(Buffer const & buf, ostream & os) const
        os << "External\n"
           << "\ttemplate " << templatename() << '\n';
 
-       if (!filename.empty()) {
+       if (!filename.empty())
                os << "\tfilename " << filename.outputFilename(buf.filePath()) << '\n';
-               os << "\tembed " << (filename.embedded() ? filename.inzipName() : "\"\"") << '\n';
-       }
+
        if (display != defaultDisplayType)
                os << "\tdisplay "
                   << external::displayTranslator().find(display)
@@ -245,10 +244,9 @@ void InsetExternalParams::write(Buffer const & buf, ostream & os) const
 
 bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
 {
-       enum ExternalTags {
+       enum {
                EX_TEMPLATE = 1,
                EX_FILENAME,
-               EX_EMBED,
                EX_DISPLAY,
                EX_LYXSCALE,
                EX_DRAFT,
@@ -264,13 +262,12 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
                EX_END
        };
 
-       keyword_item external_tags[] = {
+       LexerKeyword external_tags[] = {
                { "\\end_inset",     EX_END },
                { "boundingBox",     EX_BOUNDINGBOX },
                { "clip",            EX_CLIP },
                { "display",         EX_DISPLAY},
                { "draft",           EX_DRAFT},
-               { "embed",           EX_EMBED},
                { "extra",           EX_EXTRA },
                { "filename",        EX_FILENAME},
                { "height",          EX_HEIGHT },
@@ -283,7 +280,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
                { "width",           EX_WIDTH }
        };
 
-       PushPopHelper pph(lex, external_tags, EX_END);
+       PushPopHelper pph(lex, external_tags);
 
        bool found_end  = false;
        bool read_error = false;
@@ -302,14 +299,6 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
                        break;
                }
                
-               case EX_EMBED: {
-                       lex.next();
-                       string const name = lex.getString();
-                       filename.setInzipName(name);
-                       filename.setEmbed(!name.empty());
-                       break;
-               }
-
                case EX_DISPLAY: {
                        lex.next();
                        string const name = lex.getString();
@@ -428,23 +417,6 @@ InsetExternal::~InsetExternal()
 }
 
 
-void InsetExternal::setBuffer(Buffer & buffer)
-{
-       if (buffer_) {
-               try {
-                       // a file may not be copied successfully when, e.g. buffer_
-                       // has already been closed.
-                       params_.filename = params_.filename.copyTo(buffer);
-               } catch (ExceptionMessage const & message) {
-                       Alert::error(message.title_, message.details_);
-                       // failed to embed
-                       params_.filename.setEmbed(false);
-               }
-       }
-       Inset::setBuffer(buffer);
-}
-
-
 void InsetExternal::statusChanged() const
 {
        updateFrontend();
@@ -505,18 +477,6 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-void InsetExternal::registerEmbeddedFiles(EmbeddedFileList & files) const
-{
-       files.registerFile(params_.filename, this, buffer());
-}
-
-
-void InsetExternal::updateEmbeddedFile(EmbeddedFile const & file)
-{
-       params_.filename = file;
-}
-
-
 void InsetExternal::edit(Cursor & cur, bool, EntryDirection)
 {
        cur.bv().showDialog("external",
@@ -570,8 +530,7 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
 {
        graphics::Params gparams;
 
-       gparams.filename = eparams.filename.availableFile();
-       gparams.icon = eparams.filename.embedded() ? "pin.png" : "";
+       gparams.filename = eparams.filename;
        gparams.scale = eparams.lyxscale;
        if (eparams.clipdata.clip)
                gparams.bb = eparams.clipdata.bbox;
@@ -594,7 +553,7 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
                gparams.display = graphics::NoDisplay;
                break;
        default:
-               BOOST_ASSERT(false);
+               LASSERT(false, /**/);
        }
        if (gparams.display == graphics::DefaultDisplay)
                gparams.display = graphics::DisplayType(lyxrc.display_graphics);
@@ -724,7 +683,7 @@ void InsetExternal::fileChanged() const
                return;
 
        RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
-       BOOST_ASSERT(ptr);
+       LASSERT(ptr, /**/);
 
        ptr->removePreview(*buffer);
        add_preview_and_start_loading(*ptr, *this, *buffer);
@@ -740,11 +699,8 @@ void InsetExternal::write(ostream & os) const
 void InsetExternal::read(Lexer & lex)
 {
        InsetExternalParams params;
-       if (params.read(buffer(), lex)) {
-               // exception handling is not needed as long as embedded files are in place.
-               params.filename.enable(buffer().embedded(), buffer(), false);
+       if (params.read(buffer(), lex))
                setParams(params);
-       }
 }
 
 
@@ -838,8 +794,17 @@ void InsetExternal::validate(LaTeXFeatures & features) const
        }
        external::Template::Formats::const_iterator cit =
                et.formats.find(format);
-       if (cit == et.formats.end())
-               return;
+
+       if (cit == et.formats.end()) {
+               // If the template has not specified a PDFLaTeX output,
+               // we try the LaTeX format.
+               if (format == "PDFLaTeX") {
+                       cit = et.formats.find("LaTeX");
+                       if (cit == et.formats.end())
+                               return;
+               } else
+                       return;
+       }
 
        // FIXME: We don't need that always
        features.require("lyxdot");
@@ -883,7 +848,7 @@ void InsetExternal::string2params(string const & in, Buffer const & buffer,
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
 
        string name;