]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetExternal.cpp
Embedding: display a pin at the top left corner of embedded figures
[lyx.git] / src / insets / InsetExternal.cpp
index 75aeb66580765af1a703d6058e4400ca5bf26dcf..5e04597b3a8eb355ce315a7bb14d71ee6b6becc8 100644 (file)
 
 #include "Buffer.h"
 #include "Cursor.h"
-#include "debug.h"
+#include "support/debug.h"
 #include "DispatchResult.h"
 #include "Exporter.h"
 #include "FuncStatus.h"
 #include "FuncRequest.h"
-#include "gettext.h"
+#include "support/gettext.h"
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "LyXRC.h"
 
 #include <sstream>
 
-using std::string;
-using std::istringstream;
-using std::ostream;
-using std::ostringstream;
-using std::vector;
-
-using lyx::support::DocFileName;
+using namespace std;
+using namespace lyx::support;
 
 namespace {
 
@@ -70,11 +65,11 @@ namespace external {
 
 TempName::TempName()
 {
-       support::FileName const tempname(support::tempName(support::FileName(), "lyxext"));
+       FileName const tempname = FileName::tempName("lyxext");
        // FIXME: This is unsafe
-       support::unlink(tempname);
+       tempname.removeFile();
        // must have an extension for the converter code to work correctly.
-       tempname_ = support::FileName(tempname.absFilename() + ".tmp");
+       tempname_ = FileName(tempname.absFilename() + ".tmp");
 }
 
 
@@ -86,7 +81,7 @@ TempName::TempName(TempName const &)
 
 TempName::~TempName()
 {
-       support::unlink(tempname_);
+       tempname_.removeFile();
 }
 
 
@@ -153,7 +148,7 @@ void clearIfNotFound(T & data, external::TransformID value,
 
        const_iterator it  = ids.begin();
        const_iterator end = ids.end();
-       it = std::find(it, end, value);
+       it = find(it, end, value);
        if (it == end)
                data = T();
 }
@@ -187,15 +182,8 @@ void InsetExternalParams::write(Buffer const & buffer, ostream & os) const
        os << "External\n"
           << "\ttemplate " << templatename() << '\n';
 
-       if (!filename.empty()) {
-               // when we save, we still use the original filename
-               EmbeddedFiles::EmbeddedFileList::const_iterator it = 
-                       buffer.embeddedFiles().find(filename.toFilesystemEncoding());
-               if (it != buffer.embeddedFiles().end())
-                       os << "\tfilename " << DocFileName(it->absFilename()).outputFilename(buffer.filePath()) << '\n';
-               else
-                       os << "\tfilename " << filename.outputFilename(buffer.filePath()) << '\n';
-       }
+       if (!filename.empty())
+               os << "\tfilename " << filename.outputFilename(buffer.filePath()) << '\n';
 
        if (display != defaultDisplayType)
                os << "\tdisplay "
@@ -229,7 +217,6 @@ void InsetExternalParams::write(Buffer const & buffer, ostream & os) const
        }
 
        if (!resizedata.no_resize()) {
-               using support::float_equal;
                double const scl = convert<double>(resizedata.scale);
                if (!float_equal(scl, 0.0, 0.05)) {
                        if (!float_equal(scl, 100.0, 0.05))
@@ -303,12 +290,6 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
                        lex.eatLine();
                        string const name = lex.getString();
                        filename.set(name, buffer.filePath());
-                       // maybe this file is embedded
-                       EmbeddedFiles::EmbeddedFileList::const_iterator it = buffer.embeddedFiles().find(filename.toFilesystemEncoding());
-                       if (it != buffer.embeddedFiles().end())
-                               // using available file, embedded or external, depending on file availability and
-                               // embedding status.
-                               filename = DocFileName(it->availableFile(&buffer));
                        break;
                }
 
@@ -495,7 +476,8 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd,
 void InsetExternal::registerEmbeddedFiles(Buffer const &,
        EmbeddedFiles & files) const
 {
-       files.registerFile(params_.filename.absFilename(), false, this);
+       // temporarily disable embedding for this inset
+       /* files.registerFile(params_.filename, this); */
 }
 
 
@@ -592,7 +574,7 @@ docstring const getScreenLabel(InsetExternalParams const & params,
                external::getTemplatePtr(params);
        if (!ptr)
                // FIXME UNICODE
-               return support::bformat((_("External template %1$s is not installed")),
+               return bformat((_("External template %1$s is not installed")),
                                        from_utf8(params.templatename()));
        // FIXME UNICODE
        docstring gui = _(ptr->guiName);
@@ -817,7 +799,7 @@ namespace {
 bool preview_wanted(InsetExternalParams const & params)
 {
        return params.display == external::PreviewDisplay &&
-               params.filename.isFileReadable();
+               params.filename.isReadableFile();
 }