- return browseFile(&lv_, in_name, title, pattern, dir1,
- make_pair(string(), string()));
+ return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
+ title, pattern, dir1, dir2);
+}
+
+
+string const ControlGraphics::readBB(string const & file)
+{
+// in a file it's an entry like %%BoundingBox:23 45 321 345
+// the first number can following without a space, so we have
+// to check a bit more.
+// on the other hand some plot programs write the bb at the
+// end of the file. Than we have in the header a
+// %%BoundingBox: (atend)
+// In this case we must check until the end.
+ string file_ = file;
+ if (zippedFile(file_))
+ file_ = unzipFile(file_);
+ std::ifstream is(file_.c_str());
+ if (!contains(getExtFromContents(file_),"ps")) // bb exists?
+ return string();
+ while (is) {
+ string s;
+ is >> s;
+ if (contains(s,"%%BoundingBox:")) {
+ string a, b, c, d;
+ is >> a >> b >> c >> d;
+ if (is && !contains(a,"atend")) { // bb at the end?
+ if (s != "%%BoundingBox:")
+ return (s.substr(14)+" "+a+" "+b+" "+c+" ");
+ else
+ return (a+" "+b+" "+c+" "+d+" ");
+ }
+ }
+ }
+ return string();
+}
+
+
+bool ControlGraphics::isFilenameValid(string const & fname) const
+{
+ // It may be that the filename is relative.
+ string const name = MakeAbsPath(fname, lv_.buffer()->filePath());
+ return IsFileReadable(name);