]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.C
Don't collapse InsetERT on close() if inlined (fix #293).
[lyx.git] / src / insets / insetgraphics.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995-2002 the LyX Team.
7  *
8  * \author Baruch Even
9  * \author Herbert Voss <voss@lyx.org>
10  * ====================================================== */
11
12 /*
13 Known BUGS:
14
15     * If the image is from the clipart, and the document is moved to another
16       directory, the user is screwed. Need a way to handle it.
17       This amounts to a problem of when to use relative or absolute file paths
18       We should probably use what the user asks to use... but when he chooses
19       by the file dialog we normally get an absolute path and this may not be
20       what the user meant.
21
22       Note that browseRelFile in helper_funcs.* provides a file name
23       which is relative if it is at reference path (here puffer path)
24       level or below, and an absolute path if the file name is not a
25       `natural' relative file name. In any case,
26               MakeAbsPath(filename, buf->filePath())
27       is guaranteed to provide the correct absolute path. This is what is
28       done know for include insets. Feel free to ask me -- JMarc
29       14/01/2002
30
31 TODO Before initial production release:
32
33     * What advanced features the users want to do?
34       Implement them in a non latex dependent way, but a logical way.
35       LyX should translate it to latex or any other fitting format.
36     * Add a way to roll the image file into the file format.
37     * When loading, if the image is not found in the expected place, try
38       to find it in the clipart, or in the same directory with the image.
39     * Keep a tab on the image file, if it changes, update the lyx view.
40     * The image choosing dialog could show thumbnails of the image formats
41       it knows of, thus selection based on the image instead of based on
42       filename.
43     * Add support for the 'picins' package.
44     * Add support for the 'picinpar' package.
45     * Improve support for 'subfigure' - Allow to set the various options
46       that are possible.
47 */
48
49 /* NOTES:
50  * Fileformat:
51  * Current version is 1 (inset file format version), when changing it
52  * it should be changed in the Write() function when writing in one place
53  * and when reading one should change the version check and the error message.
54  * The filename is kept in  the lyx file in a relative way, so as to allow
55  * moving the document file and its images with no problem.
56  *
57  *
58  * Conversions:
59  *   Postscript output means EPS figures.
60  *
61  *   PDF output is best done with PDF figures if it's a direct conversion
62  *   or PNG figures otherwise.
63  *      Image format
64  *      from        to
65  *      EPS         epstopdf
66  *      PS          ps2pdf
67  *      JPG/PNG     direct
68  *      PDF         direct
69  *      others      PNG
70  */
71
72 #include <config.h>
73
74 #ifdef __GNUG__
75 #pragma implementation
76 #endif
77
78 #include "insets/insetgraphics.h"
79 #include "insets/insetgraphicsParams.h"
80
81 #include "graphics/GraphicsCache.h"
82 #include "graphics/GraphicsImage.h"
83
84 #include "LyXView.h"
85 #include "lyxtext.h"
86 #include "buffer.h"
87 #include "BufferView.h"
88 #include "converter.h"
89 #include "Painter.h"
90 #include "lyxrc.h"
91 #include "font.h"    // For the lyxfont class.
92 #include "debug.h"
93 #include "gettext.h"
94 #include "LaTeXFeatures.h"
95
96 #include "frontends/Dialogs.h"
97 #include "frontends/controllers/helper_funcs.h" // getVectorFromString
98
99 #include "support/LAssert.h"
100 #include "support/filetools.h"
101 #include "support/lyxalgo.h" // lyx::count
102
103 #include <algorithm> // For the std::max
104
105 extern string system_tempdir;
106
107 using std::ostream;
108 using std::endl;
109
110 ///////////////////////////////////////////////////////////////////////////
111 int const VersionNumber = 1;
112 ///////////////////////////////////////////////////////////////////////////
113
114 namespace {
115
116 // This function is a utility function
117 // ... that should be with ChangeExtension ...
118 inline
119 string const RemoveExtension(string const & filename)
120 {
121         return ChangeExtension(filename, string());
122 }
123
124 } // namespace anon
125
126
127 namespace {
128
129 string const unique_id()
130 {
131         static unsigned int seed = 1000;
132
133         ostringstream ost;
134         ost << "graph" << ++seed;
135
136         // Needed if we use lyxstring.
137         return ost.str().c_str();
138 }
139
140 } // namespace anon
141
142
143 InsetGraphics::InsetGraphics()
144         : graphic_label(unique_id()),
145           cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0)
146
147 {}
148
149
150 InsetGraphics::InsetGraphics(InsetGraphics const & ig,
151                              string const & filepath,
152                              bool same_id)
153         : Inset(ig, same_id),
154           SigC::Object(),
155           graphic_label(unique_id()),
156           cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0)
157 {
158         setParams(ig.params(), filepath);
159 }
160
161
162 InsetGraphics::~InsetGraphics()
163 {
164         cached_image_.reset(0);
165         grfx::GCache & gc = grfx::GCache::get();
166         gc.remove(*this);
167
168         // Emits the hide signal to the dialog connected (if any)
169         hideDialog();
170 }
171
172
173 string const InsetGraphics::statusMessage() const
174 {
175         string msg;
176
177         switch (cached_status_) {
178         case grfx::WaitingToLoad:
179                 msg = _("Waiting for draw request to start loading...");
180                 break;
181         case grfx::Loading:
182                 msg = _("Loading...");
183                 break;
184         case grfx::Converting:
185                 msg = _("Converting to loadable format...");
186                 break;
187         case grfx::ScalingEtc:
188                 msg = _("Loaded. Scaling etc...");
189                 break;
190         case grfx::ErrorNoFile:
191                 msg = _("No file found!");
192                 break;
193         case grfx::ErrorLoading:
194                 msg = _("Error loading file into memory");
195                 break;
196         case grfx::ErrorConverting:
197                 msg = _("Error converting to loadable format");
198                 break;
199         case grfx::ErrorScalingEtc:
200                 msg = _("Error scaling etc");
201                 break;
202         case grfx::ErrorUnknown:
203                 msg = _("No image");
204                 break;
205         case grfx::Loaded:
206                 msg = _("Loaded but not displaying");
207                 break;
208         }
209
210         return msg;
211 }
212
213
214 void InsetGraphics::setCache() const
215 {
216         if (cache_filled_)
217                 return;
218
219         grfx::GCache & gc = grfx::GCache::get();
220         cached_status_ = gc.status(*this);
221         cached_image_  = gc.image(*this);
222 }
223
224
225 bool InsetGraphics::drawImage() const
226 {
227         setCache();
228         Pixmap const pixmap =
229                 (cached_status_ == grfx::Loaded && cached_image_.get() != 0) ?
230                 cached_image_->getPixmap() : 0;
231
232         return pixmap != 0;
233 }
234
235
236 int InsetGraphics::ascent(BufferView *, LyXFont const &) const
237 {
238         old_asc = 50;
239         if (drawImage())
240                 old_asc = cached_image_->getHeight();
241         return old_asc;
242 }
243
244
245 int InsetGraphics::descent(BufferView *, LyXFont const &) const
246 {
247         return 0;
248 }
249
250
251 int InsetGraphics::width(BufferView *, LyXFont const & font) const
252 {
253         if (drawImage())
254                 return cached_image_->getWidth();
255         else {
256                 int font_width = 0;
257
258                 LyXFont msgFont(font);
259                 msgFont.setFamily(LyXFont::SANS_FAMILY);
260
261                 string const justname = OnlyFilename (params().filename);
262                 if (!justname.empty()) {
263                         msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
264                         font_width = lyxfont::width(justname, msgFont);
265                 }
266
267                 string const msg = statusMessage();
268                 if (!msg.empty()) {
269                         msgFont.setSize(LyXFont::SIZE_TINY);
270                         int const msg_width = lyxfont::width(msg, msgFont);
271                         font_width = std::max(font_width, msg_width);
272                 }
273
274                 return std::max(50, font_width + 15);
275         }
276 }
277
278
279 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
280                          int baseline, float & x, bool) const
281 {
282         int oasc = old_asc;
283         grfx::ImageStatus old_status_ = cached_status_;
284
285         int ldescent = descent(bv, font);
286         int lascent  = ascent(bv, font);
287         int lwidth   = width(bv, font);
288
289         // we may have changed while someone other was drawing us so better
290         // to not draw anything as we surely call to redraw ourself soon.
291         // This is not a nice thing to do and should be fixed properly somehow.
292         // But I still don't know the best way to go. So let's do this like this
293         // for now (Jug 20020311)
294         if (lascent != oasc) {
295 //              lyxerr << "IG(" << this << "): " << x << endl;
296                 return;
297         }
298
299         // Make sure now that x is updated upon exit from this routine
300         int old_x = int(x);
301         x += lwidth;
302
303         // Initiate the loading of the graphics file
304         if (cached_status_ == grfx::WaitingToLoad) {
305                 grfx::GCache & gc = grfx::GCache::get();
306                 gc.startLoading(*this);
307         }
308
309         // This will draw the graphics. If the graphics has not been loaded yet,
310         // we draw just a rectangle.
311         Painter & paint = bv->painter();
312
313         if (drawImage()) {
314 //              lyxerr << "IG(" << this << "): " << old_x << endl;
315                 paint.image(old_x + 2, baseline - lascent,
316                             lwidth - 4, lascent + ldescent,
317                             *cached_image_.get());
318
319         } else {
320
321                 paint.rectangle(old_x + 2, baseline - lascent,
322                                 lwidth - 4,
323                                 lascent + ldescent);
324
325                 // Print the file name.
326                 LyXFont msgFont(font);
327                 msgFont.setFamily(LyXFont::SANS_FAMILY);
328                 string const justname = OnlyFilename (params().filename);
329                 if (!justname.empty()) {
330                         msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
331                         paint.text(old_x + 8,
332                                    baseline - lyxfont::maxAscent(msgFont) - 4,
333                                    justname, msgFont);
334                 }
335
336                 // Print the message.
337                 string const msg = statusMessage();
338                 if (!msg.empty()) {
339                         msgFont.setSize(LyXFont::SIZE_TINY);
340                         paint.text(old_x + 8, baseline - 4, msg, msgFont);
341                 }
342         }
343
344         // the status message may mean we changed size, so indicate
345         // we need a row redraw
346         if (old_status_ != grfx::ErrorUnknown && old_status_ != cached_status_) {
347                 bv->getLyXText()->status(bv, LyXText::CHANGED_IN_DRAW);
348         }
349
350         // Reset the cache, ready for the next draw request
351         cached_status_ = grfx::ErrorUnknown;
352         cached_image_.reset(0);
353         cache_filled_ = false;
354 }
355
356
357 // Update the inset after parameters changed (read from file or changed in
358 // dialog. The grfx::GCache makes the decisions about whether or not to draw
359 // (interogates lyxrc, ascertains whether file exists etc)
360 void InsetGraphics::updateInset(string const & filepath) const
361 {
362         grfx::GCache & gc = grfx::GCache::get();
363         gc.update(*this, filepath);
364 }
365
366
367 void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
368 {
369         bv->owner()->getDialogs()->showGraphics(this);
370 }
371
372
373 void InsetGraphics::edit(BufferView * bv, bool)
374 {
375         edit(bv, 0, 0, 0);
376 }
377
378
379 Inset::EDITABLE InsetGraphics::editable() const
380 {
381         return IS_EDITABLE;
382 }
383
384
385 void InsetGraphics::write(Buffer const *, ostream & os) const
386 {
387         os << "Graphics FormatVersion " << VersionNumber << '\n';
388         params().Write(os);
389 }
390
391
392 void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
393 {
394         string const token = lex.getString();
395
396         if (token == "Graphics")
397                 readInsetGraphics(lex);
398         else if (token == "Figure") // Compatibility reading of FigInset figures.
399                 readFigInset(lex);
400         else
401                 lyxerr[Debug::GRAPHICS] << "Not a Graphics or Figure inset!\n";
402
403         updateInset(buf->filePath());
404 }
405
406
407 void InsetGraphics::readInsetGraphics(LyXLex & lex)
408 {
409         bool finished = false;
410
411         while (lex.isOK() && !finished) {
412                 lex.next();
413
414                 string const token = lex.getString();
415                 lyxerr[Debug::GRAPHICS] << "Token: '" << token << '\''
416                                     << std::endl;
417
418                 if (token.empty()) {
419                         continue;
420                 } else if (token == "\\end_inset") {
421                         finished = true;
422                 } else if (token == "FormatVersion") {
423                         lex.next();
424                         int version = lex.getInteger();
425                         if (version > VersionNumber)
426                                 lyxerr
427                                 << "This document was created with a newer Graphics widget"
428                                 ", You should use a newer version of LyX to read this"
429                                 " file."
430                                 << std::endl;
431                         // TODO: Possibly open up a dialog?
432                 }
433                 else {
434                         if (! params_.Read(lex, token))
435                                 lyxerr << "Unknown token, " << token << ", skipping."
436                                         << std::endl;
437                 }
438         }
439 }
440
441 // FormatVersion < 1.0  (LyX < 1.2)
442 void InsetGraphics::readFigInset(LyXLex & lex)
443 {
444         std::vector<string> const oldUnits =
445                 getVectorFromString("pt,cm,in,p%,c%");
446         bool finished = false;
447         // set the display default
448         if (lyxrc.display_graphics == "mono")
449             params_.display = InsetGraphicsParams::MONOCHROME;
450         else if (lyxrc.display_graphics == "gray")
451             params_.display = InsetGraphicsParams::GRAYSCALE;
452         else if (lyxrc.display_graphics == "color")
453             params_.display = InsetGraphicsParams::COLOR;
454         else
455             params_.display = InsetGraphicsParams::NONE;
456         while (lex.isOK() && !finished) {
457                 lex.next();
458
459                 string const token = lex.getString();
460                 lyxerr[Debug::GRAPHICS] << "Token: " << token << endl;
461
462                 if (token.empty())
463                         continue;
464                 else if (token == "\\end_inset") {
465                         finished = true;
466                 } else if (token == "file") {
467                         if (lex.next()) {
468                                 params_.filename = lex.getString();
469                         }
470                 } else if (token == "extra") {
471                         if (lex.next());
472                         // kept for backwards compability. Delete in 0.13.x
473                 } else if (token == "subcaption") {
474                         if (lex.eatLine())
475                                 params_.subcaptionText = lex.getString();
476                         params_.subcaption = true;
477                 } else if (token == "label") {
478                         if (lex.next());
479                         // kept for backwards compability. Delete in 0.13.x
480                 } else if (token == "angle") {
481                         if (lex.next())
482                                 params_.rotate = true;
483                                 params_.rotateAngle = lex.getFloat();
484                 } else if (token == "size") {
485                         if (lex.next())
486                                 params_.lyxwidth = LyXLength(lex.getString()+"pt");
487                         if (lex.next())
488                                 params_.lyxheight = LyXLength(lex.getString()+"pt");
489                 } else if (token == "flags") {
490                         if (lex.next())
491                                 switch (lex.getInteger()) {
492                                 case 1: params_.display = InsetGraphicsParams::MONOCHROME;
493                                     break;
494                                 case 2: params_.display = InsetGraphicsParams::GRAYSCALE;
495                                     break;
496                                 case 3: params_.display = InsetGraphicsParams::COLOR;
497                                     break;
498                                 }
499                 } else if (token == "subfigure") {
500                         params_.subcaption = true;
501                 } else if (token == "width") {
502                     if (lex.next()) {
503                         int i = lex.getInteger();
504                         if (lex.next()) {
505                             if (i == 5) {
506                                 params_.scale = lex.getInteger();
507                                 params_.size_type = InsetGraphicsParams::SCALE;
508                             } else {
509                                 params_.width = LyXLength(lex.getString()+oldUnits[i]);
510                                 params_.size_type = InsetGraphicsParams::WH;
511                             }
512                         }
513                     }
514                 } else if (token == "height") {
515                     if (lex.next()) {
516                         int i = lex.getInteger();
517                         if (lex.next()) {
518                             params_.height = LyXLength(lex.getString()+oldUnits[i]);
519                             params_.size_type = InsetGraphicsParams::WH;
520                         }
521                     }
522                 }
523         }
524 }
525
526 string const InsetGraphics::createLatexOptions() const
527 {
528         // Calculate the options part of the command, we must do it to a string
529         // stream since we might have a trailing comma that we would like to remove
530         // before writing it to the output stream.
531         ostringstream options;
532         if (!params().bb.empty())
533             options << "  bb=" << strip(params().bb) << ",\n";
534         if (params().draft)
535             options << "  draft,\n";
536         if (params().clip)
537             options << "  clip,\n";
538         if (params().size_type == InsetGraphicsParams::WH) {
539             if (!params().width.zero())
540                 options << "  width=" << params().width.asLatexString() << ",\n";
541             if (!params().height.zero())
542                 options << "  height=" << params().height.asLatexString() << ",\n";
543         } else if (params().size_type == InsetGraphicsParams::SCALE) {
544             if (params().scale > 0)
545                 options << "  scale=" << double(params().scale)/100.0 << ",\n";
546         }
547         if (params().keepAspectRatio)
548             options << "  keepaspectratio,\n";
549         // Make sure it's not very close to zero, a float can be effectively
550         // zero but not exactly zero.
551         if (!lyx::float_equal(params().rotateAngle, 0, 0.001) && params().rotate) {
552             options << "  angle=" << params().rotateAngle << ",\n";
553             if (!params().rotateOrigin.empty()) {
554                 options << "  origin=" << params().rotateOrigin[0];
555                 if (contains(params().rotateOrigin,"Top"))
556                     options << 't';
557                 else if (contains(params().rotateOrigin,"Bottom"))
558                     options << 'b';
559                 else if (contains(params().rotateOrigin,"Baseline"))
560                     options << 'B';
561                 options << ",\n";
562             }
563         }
564         if (!params().special.empty())
565             options << params().special << ",\n";
566         string opts = options.str().c_str();
567         return opts.substr(0,opts.size()-2);    // delete last ",\n"
568 }
569
570 namespace {
571 string findTargetFormat(string const & suffix)
572 {
573         // lyxrc.pdf_mode means:
574         // Are we creating a PDF or a PS file?
575         // (Should actually mean, are we using latex or pdflatex).
576         lyxerr[Debug::GRAPHICS] << "decideOutput: lyxrc.pdf_mode = "
577                             << lyxrc.pdf_mode << std::endl;
578         if (lyxrc.pdf_mode) {
579                 if (contains(suffix,"ps") || suffix == "pdf")
580                         return "pdf";
581                 else if (suffix == "jpg")
582                         return suffix;
583                 else
584                         return "png";
585         }
586         // If it's postscript, we always do eps.
587         lyxerr[Debug::GRAPHICS] << "decideOutput: we have PostScript mode\n";
588         if (suffix != "ps")
589             return "eps";
590         else
591             return "ps";
592 }
593
594 } // Anon. namespace
595
596
597 string const InsetGraphics::prepareFile(Buffer const *buf) const
598 {
599         // do_convert = Do we need to convert the file?
600         // nice = Do we create a nice version?
601         //        This is used when exporting the latex file only.
602         // if (!do_convert)
603         //   return original filename
604         // if (!nice)
605         //   convert_place = temp directory
606         //   return new filename in temp directory
607         // else
608         //   convert_place = original file directory
609         //   return original filename without the extension
610         //
611         // if it's a zipped one, than let LaTeX do the rest!!!
612         string filename_  = MakeAbsPath(params().filename, buf->filePath());
613         bool const zipped = zippedFile(filename_);
614
615         if ((zipped && params().noUnzip) || buf->niceFile) {
616                 lyxerr[Debug::GRAPHICS] << "don't unzip file or export latex"
617                                     << filename_ << endl;
618                 return filename_;
619         }
620
621         if (zipped)
622                 filename_ = unzipFile(filename_);
623
624         string const from = getExtFromContents(filename_);
625         string const to   = findTargetFormat(from);
626
627         if (from == to) {
628                 // No conversion needed!
629                 return filename_;
630         }
631
632         string const temp = AddName(buf->tmppath, filename_);
633         string const outfile_base = RemoveExtension(temp);
634
635         lyxerr[Debug::GRAPHICS] << "tempname = " << temp << "\n";
636         lyxerr[Debug::GRAPHICS] << "buf::tmppath = " << buf->tmppath << "\n";
637         lyxerr[Debug::GRAPHICS] << "filename_ = " << filename_ << "\n";
638         lyxerr[Debug::GRAPHICS] << "outfile_base = " << outfile_base << endl;
639
640         converters.convert(buf, filename_, outfile_base, from, to);
641         return outfile_base;
642 }
643
644
645 int InsetGraphics::latex(Buffer const *buf, ostream & os,
646                          bool /*fragile*/, bool/*fs*/) const
647 {
648         // If there is no file specified, just output a message about it in
649         // the latex output.
650         if (params().filename.empty()) {
651                 os  << "\\fbox{\\rule[-0.5in]{0pt}{1in}"
652                         << _("empty figure path") << "}\n";
653                 return 1; // One end of line marker added to the stream.
654         }
655         // These variables collect all the latex code that should be before and
656         // after the actual includegraphics command.
657         string before;
658         string after;
659         // Do we want subcaptions?
660         if (params().subcaption) {
661                 before += "\\subfigure[" + params().subcaptionText + "]{";
662                 after = '}';
663         }
664         // We never use the starred form, we use the "clip" option instead.
665         before += "\\includegraphics";
666         // Write the options if there are any.
667         string const opts = createLatexOptions();
668         if (!opts.empty()) {
669                 before += ("[%\n" + opts +']');
670         }
671         // Make the filename relative to the lyx file
672         // and remove the extension so the LaTeX will use whatever is
673         // appropriate (when there are several versions in different formats)
674         string const latex_str = before + '{' + prepareFile(buf) + '}' + after;
675         os << latex_str;
676
677         // Return how many newlines we issued.
678         int const newlines =
679                 int(lyx::count(latex_str.begin(), latex_str.end(),'\n') + 1);
680
681         // lyxerr << "includegraphics: " << newlines << " lines of text"
682         //        << endl;
683         return newlines;
684 }
685
686
687 int InsetGraphics::ascii(Buffer const *, ostream & os, int) const
688 {
689         // No graphics in ascii output. Possible to use gifscii to convert
690         // images to ascii approximation.
691         // 1. Convert file to ascii using gifscii
692         // 2. Read ascii output file and add it to the output stream.
693         // at least we send the filename
694         os << '<' << _("Graphic file:") << params().filename << ">\n";
695         return 0;
696 }
697
698
699 int InsetGraphics::linuxdoc(Buffer const *, ostream &) const
700 {
701         // No graphics in LinuxDoc output. Should check how/what to add.
702         return 0;
703 }
704
705
706 // For explanation on inserting graphics into DocBook checkout:
707 // http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html
708 // See also the docbook guide at http://www.docbook.org/
709 int InsetGraphics::docbook(Buffer const *, ostream & os) const
710 {
711         // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
712         // need to switch to MediaObject. However, for now this is sufficient and
713         // easier to use.
714         os << "<graphic fileref=\"&" << graphic_label << ";\">";
715         return 0;
716 }
717
718
719 void InsetGraphics::validate(LaTeXFeatures & features) const
720 {
721         // If we have no image, we should not require anything.
722         if (params().filename.empty())
723                 return ;
724
725         features.includeFile(graphic_label, RemoveExtension(params_.filename));
726
727         features.require("graphicx");
728
729         if (params().subcaption)
730                 features.require("subfigure");
731 }
732
733
734 bool InsetGraphics::setParams(InsetGraphicsParams const & p,
735                               string const & filepath)
736 {
737         // If nothing is changed, just return and say so.
738         if (params() == p && !p.filename.empty()) {
739                 return false;
740         }
741
742         // Copy the new parameters.
743         params_ = p;
744
745         // Update the inset with the new parameters.
746         updateInset(filepath);
747
748         // We have changed data, report it.
749         return true;
750 }
751
752
753 InsetGraphicsParams const & InsetGraphics::params() const
754 {
755         return params_;
756 }
757
758
759 Inset * InsetGraphics::clone(Buffer const & buffer, bool same_id) const
760 {
761         return new InsetGraphics(*this, buffer.filePath(), same_id);
762 }