2 * \file GuiGraphics.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
10 * \author Richard Heck
12 * Full author contact details are available in file CREDITS.
17 #include "GuiGraphics.h"
18 #include "qt_helpers.h"
19 #include "Validator.h"
22 #include "FuncRequest.h"
23 #include "LengthCombo.h"
28 #include "graphics/GraphicsCache.h"
29 #include "graphics/GraphicsCacheItem.h"
30 #include "graphics/GraphicsImage.h"
32 #include "insets/InsetGraphics.h"
34 #include "support/convert.h"
35 #include "support/debug.h"
36 #include "support/filetools.h"
37 #include "support/gettext.h"
38 #include "support/lstrings.h"
39 #include "support/os.h"
40 #include "support/Package.h"
41 #include "support/types.h"
46 #include <QPushButton>
53 using namespace lyx::support;
57 // These are the strings that are stored in the LyX file and which
58 // correspond to the LaTeX identifiers shown in the comments at the
60 char const * const rorigin_lyx_strs[] = {
61 // the LaTeX default is leftBaseline
63 "leftTop", "leftBottom", "leftBaseline", // lt lb lB
64 "center", "centerTop", "centerBottom", "centerBaseline", // c ct cb cB
65 "rightTop", "rightBottom", "rightBaseline" }; // rt rb rB
67 // These are the strings, corresponding to the above, that the GUI should
68 // use. Note that they can/should be translated.
69 char const * const rorigin_gui_strs[] = {
71 N_("Top left"), N_("Bottom left"), N_("Baseline left"),
72 N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
73 N_("Top right"), N_("Bottom right"), N_("Baseline right") };
75 size_t const rorigin_size = sizeof(rorigin_lyx_strs) / sizeof(char *);
83 //FIXME setAutoTextCB should really take an argument, as indicated, that
84 //determines what text is to be written for "auto". But making
85 //that work involves more extensive revisions than we now want
86 //to make, since "auto" also appears in paramsToDialog().
87 //The right way to do this, I think, would be to define a class
88 //checkedLengthSet (and a partnering labeledLengthSete) that encapsulated
89 //the checkbox, line edit, and length combo together, and then made e.g.
90 //lengthToWidgets, widgetsToLength, etc, all public methods of that class.
91 //Perhaps even the validator could be exposed through it.
93 * sets a checkbox-line edit-length combo group, using "text" if the
94 * checkbox is unchecked and clearing the line edit if it previously
97 static void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
98 LengthCombo * lengthCombo/*, string text = "auto"*/)
100 if (!checkBox->isChecked())
101 lengthToWidgets(lineEdit, lengthCombo,
102 "auto", lengthCombo->currentLengthItem());
103 else if (lineEdit->text() == "auto")
104 lengthToWidgets(lineEdit, lengthCombo, string(),
105 lengthCombo->currentLengthItem());
110 vector<typename Pair::first_type> getFirst(vector<Pair> const & pr)
112 size_t const n = pr.size();
113 vector<typename Pair::first_type> tmp(n);
114 for (size_t i = 0; i != n; ++i)
115 tmp[i] = pr[i].first;
122 vector<typename Pair::second_type> getSecond(vector<Pair> const & pr)
124 size_t const n = pr.size();
125 vector<typename Pair::second_type> tmp(n);
126 for (size_t i = 0; i != n; ++i)
127 tmp[i] = pr[i].second;
132 /// The (tranlated) GUI string and it's LaTeX equivalent.
133 typedef pair<docstring, string> RotationOriginPair;
135 vector<RotationOriginPair> getRotationOriginData()
137 static vector<RotationOriginPair> data;
141 data.resize(rorigin_size);
142 for (size_type i = 0; i < rorigin_size; ++i) {
143 data[i] = make_pair(_(rorigin_gui_strs[i]),
144 rorigin_lyx_strs[i]);
152 GuiGraphics::GuiGraphics(GuiView & lv)
153 : GuiDialog(lv, "graphics", qt_("Graphics"))
158 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
159 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
160 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
161 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
164 connect(filename, SIGNAL(textChanged(const QString &)),
165 this, SLOT(change_adaptor()));
166 connect(WidthCB, SIGNAL( clicked()),
167 this, SLOT(change_adaptor()));
168 connect(HeightCB, SIGNAL( clicked()),
169 this, SLOT(change_adaptor()));
170 connect(Width, SIGNAL(textChanged(const QString &)),
171 this, SLOT(change_adaptor()));
172 connect(Height, SIGNAL(textChanged(const QString &)),
173 this, SLOT(change_adaptor()));
174 connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
175 this, SLOT(change_adaptor()));
176 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
177 this, SLOT(change_adaptor()));
178 connect(aspectratio, SIGNAL(stateChanged(int)),
179 this, SLOT(change_adaptor()));
180 connect(angle, SIGNAL(textChanged(const QString &)),
181 this, SLOT(change_adaptor()));
182 connect(origin, SIGNAL(activated(int)),
183 this, SLOT(change_adaptor()));
184 connect(scaleCB, SIGNAL(clicked()),
185 this, SLOT(change_adaptor()));
186 connect(Scale, SIGNAL(textChanged(const QString &)),
187 this, SLOT(change_adaptor()));
188 connect(rotateOrderCB, SIGNAL(clicked()),
189 this, SLOT(change_adaptor()));
191 filename->setValidator(new PathValidator(true, filename));
192 setFocusProxy(filename);
194 QDoubleValidator * scaleValidator = new DoubleAutoValidator(Scale);
195 scaleValidator->setBottom(0);
196 scaleValidator->setDecimals(256); //I guess that will do
197 Scale->setValidator(scaleValidator);
198 Height->setValidator(unsignedLengthAutoValidator(Height));
199 Width->setValidator(unsignedLengthAutoValidator(Width));
200 angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
203 connect(clip, SIGNAL(stateChanged(int)),
204 this, SLOT(change_adaptor()));
205 connect(lbY, SIGNAL(textChanged(const QString&)),
206 this, SLOT(change_bb()));
207 connect(lbYunit, SIGNAL(activated(int)),
208 this, SLOT(change_bb()));
209 connect(rtY, SIGNAL(textChanged(const QString&)),
210 this, SLOT(change_bb()));
211 connect(rtYunit, SIGNAL(activated(int)),
212 this, SLOT(change_bb()));
213 connect(lbX, SIGNAL(textChanged(const QString&)),
214 this, SLOT(change_bb()));
215 connect(lbXunit, SIGNAL(activated(int)),
216 this, SLOT(change_bb()));
217 connect(rtX, SIGNAL(textChanged(const QString&)),
218 this, SLOT(change_bb()));
219 connect(rtXunit, SIGNAL(activated(int)),
220 this, SLOT(change_bb()));
221 connect(getPB, SIGNAL(clicked()),
222 this, SLOT(change_adaptor()));
224 lbX->setValidator(new QDoubleValidator(lbX));
225 lbY->setValidator(new QDoubleValidator(lbY));
226 rtX->setValidator(new QDoubleValidator(rtX));
227 rtY->setValidator(new QDoubleValidator(rtY));
230 connect(latexoptions, SIGNAL(textChanged(const QString&)),
231 this, SLOT(change_adaptor()));
232 connect(draftCB, SIGNAL(stateChanged(int)),
233 this, SLOT(change_adaptor()));
234 connect(unzipCB, SIGNAL(stateChanged(int)),
235 this, SLOT(change_adaptor()));
236 // FIXME: we should connect to clicked() when we move to Qt 4.2 because
237 // the toggled(bool) signal is also trigged when we update the widgets
238 // (rgh-4/07) this isn't as much or a problem as it was, because we're now
239 // using blockSignals() to keep from triggering that signal when we call
240 // setChecked(). Note, too, that clicked() would get called whenever it
241 // is clicked, even right clicked (I think), not just whenever it is
243 connect(displayGB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
244 connect(displayscale, SIGNAL(textChanged(const QString&)),
245 this, SLOT(change_adaptor()));
246 connect(groupId, SIGNAL(textChanged(const QString&)),
247 this, SLOT(change_adaptor()));
248 displayscale->setValidator(new QIntValidator(displayscale));
250 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
252 bc().setApply(applyPB);
253 bc().setRestore(restorePB);
254 bc().setCancel(closePB);
256 bc().addReadOnly(latexoptions);
257 bc().addReadOnly(filenameL);
258 bc().addReadOnly(filename);
259 bc().addReadOnly(browsePB);
260 bc().addReadOnly(unzipCB);
261 bc().addReadOnly(bbFrame);
262 bc().addReadOnly(draftCB);
263 bc().addReadOnly(clip);
264 bc().addReadOnly(unzipCB);
265 bc().addReadOnly(displayGB);
266 bc().addReadOnly(sizeGB);
267 bc().addReadOnly(rotationGB);
268 bc().addReadOnly(latexoptions);
269 bc().addReadOnly(getPB);
270 bc().addReadOnly(rotateOrderCB);
272 // initialize the length validator
273 bc().addCheckedLineEdit(Scale, scaleCB);
274 bc().addCheckedLineEdit(Width, WidthCB);
275 bc().addCheckedLineEdit(Height, HeightCB);
276 bc().addCheckedLineEdit(displayscale, scaleLA);
277 bc().addCheckedLineEdit(angle, angleL);
278 bc().addCheckedLineEdit(lbX, xL);
279 bc().addCheckedLineEdit(lbY, yL);
280 bc().addCheckedLineEdit(rtX, xL_2);
281 bc().addCheckedLineEdit(rtY, yL_2);
282 bc().addCheckedLineEdit(filename, filenameL);
286 void GuiGraphics::change_adaptor()
292 void GuiGraphics::change_bb()
295 LYXERR(Debug::GRAPHICS, "[bb_Changed set to true]");
300 void GuiGraphics::on_browsePB_clicked()
302 QString const str = browse(filename->text());
303 if (!str.isEmpty()) {
304 filename->setText(str);
310 void GuiGraphics::on_getPB_clicked()
316 void GuiGraphics::setAutoText()
318 if (scaleCB->isChecked())
320 if (!Scale->isEnabled() && Scale->text() != "100")
321 Scale->setText(QString("auto"));
323 setAutoTextCB(WidthCB, Width, widthUnit);
324 setAutoTextCB(HeightCB, Height, heightUnit);
328 void GuiGraphics::on_scaleCB_toggled(bool setScale)
330 Scale->setEnabled(setScale);
332 Scale->setText("100");
333 Scale->setFocus(Qt::OtherFocusReason);
336 WidthCB->setDisabled(setScale);
337 WidthCB->blockSignals(true);
338 WidthCB->setChecked(false);
339 WidthCB->blockSignals(false);
340 Width->setEnabled(false);
341 widthUnit->setEnabled(false);
343 HeightCB->setDisabled(setScale);
344 HeightCB->blockSignals(true);
345 HeightCB->setChecked(false);
346 HeightCB->blockSignals(false);
347 Height->setEnabled(false);
348 heightUnit->setEnabled(false);
350 aspectratio->setDisabled(true);
351 aspectratio->setChecked(true);
353 rotateOrderCB->setEnabled((WidthCB->isChecked() ||
354 HeightCB->isChecked() ||
355 scaleCB->isChecked()) &&
356 (angle->text() != "0"));
362 void GuiGraphics::on_WidthCB_toggled(bool setWidth)
364 Width->setEnabled(setWidth);
365 widthUnit->setEnabled(setWidth);
367 Width->setFocus(Qt::OtherFocusReason);
369 bool const setHeight = HeightCB->isChecked();
370 aspectratio->setEnabled(setWidth && setHeight);
371 aspectratio->blockSignals(true);
372 aspectratio->setChecked(!(setWidth && setHeight));
373 aspectratio->blockSignals(false);
375 scaleCB->setEnabled(!setWidth && !setHeight);
376 //already will be unchecked, so don't need to do that
377 Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
378 && scaleCB->isChecked()); //should be false, but let's check
379 rotateOrderCB->setEnabled((setWidth || setHeight ||
380 scaleCB->isChecked()) &&
381 (angle->text() != "0"));
387 void GuiGraphics::on_HeightCB_toggled(bool setHeight)
389 Height->setEnabled(setHeight);
390 heightUnit->setEnabled(setHeight);
392 Height->setFocus(Qt::OtherFocusReason);
394 bool const setWidth = WidthCB->isChecked();
395 aspectratio->setEnabled(setWidth && setHeight);
396 aspectratio->blockSignals(true);
397 aspectratio->setChecked(!(setWidth && setHeight));
398 aspectratio->blockSignals(false);
400 scaleCB->setEnabled(!setWidth && !setHeight);
402 Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
403 && scaleCB->isChecked()); //should be false
404 rotateOrderCB->setEnabled((setWidth || setHeight ||
405 scaleCB->isChecked()) &&
406 (angle->text() != "0"));
412 void GuiGraphics::on_angle_textChanged(const QString & filename)
414 rotateOrderCB->setEnabled((WidthCB->isChecked() ||
415 HeightCB->isChecked() ||
416 scaleCB->isChecked()) &&
420 // returns the number of the string s in the vector v
421 static int itemNumber(const vector<string> & v, string const & s)
423 vector<string>::const_iterator cit =
424 find(v.begin(), v.end(), s);
425 return (cit != v.end()) ? int(cit - v.begin()) : 0;
429 void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
431 static char const * const bb_units[] = { "bp", "cm", "mm", "in" };
432 size_t const bb_size = sizeof(bb_units) / sizeof(bb_units[0]);
434 vector<string> const units = vector<string>(bb_units, bb_units + bb_size);
439 for (vector<string>::const_iterator it = units.begin();
440 it != units.end(); ++it) {
441 lbXunit->addItem(toqstr(*it));
442 lbYunit->addItem(toqstr(*it));
443 rtXunit->addItem(toqstr(*it));
444 rtYunit->addItem(toqstr(*it));
447 // set the right default unit
448 Length::UNIT unitDefault = Length::CM;
449 switch (lyxrc.default_papersize) {
452 case PAPER_USEXECUTIVE:
453 unitDefault = Length::IN;
459 //lyxerr << bufferFilepath();
461 igp.filename.outputFilename(fromqstr(bufferFilepath()));
462 filename->setText(toqstr(name));
464 // set the bounding box values
465 if (igp.bb.empty()) {
466 string const bb = readBoundingBox(igp.filename.absFilename());
467 // the values from the file always have the bigpoint-unit bp
468 lbX->setText(toqstr(token(bb, ' ', 0)));
469 lbY->setText(toqstr(token(bb, ' ', 1)));
470 rtX->setText(toqstr(token(bb, ' ', 2)));
471 rtY->setText(toqstr(token(bb, ' ', 3)));
472 lbXunit->setCurrentIndex(0);
473 lbYunit->setCurrentIndex(0);
474 rtXunit->setCurrentIndex(0);
475 rtYunit->setCurrentIndex(0);
478 // get the values from the inset
480 string const xl = token(igp.bb, ' ', 0);
481 string const yl = token(igp.bb, ' ', 1);
482 string const xr = token(igp.bb, ' ', 2);
483 string const yr = token(igp.bb, ' ', 3);
484 if (isValidLength(xl, &anyLength)) {
485 lbX->setText(toqstr(convert<string>(anyLength.value())));
486 string const unit = unit_name[anyLength.unit()];
487 lbXunit->setCurrentIndex(itemNumber(units, unit));
489 lbX->setText(toqstr(xl));
491 if (isValidLength(yl, &anyLength)) {
492 lbY->setText(toqstr(convert<string>(anyLength.value())));
493 string const unit = unit_name[anyLength.unit()];
494 lbYunit->setCurrentIndex(itemNumber(units, unit));
496 lbY->setText(toqstr(xl));
498 if (isValidLength(xr, &anyLength)) {
499 rtX->setText(toqstr(convert<string>(anyLength.value())));
500 string const unit = unit_name[anyLength.unit()];
501 rtXunit->setCurrentIndex(itemNumber(units, unit));
503 rtX->setText(toqstr(xl));
505 if (isValidLength(yr, &anyLength)) {
506 rtY->setText(toqstr(convert<string>(anyLength.value())));
507 string const unit = unit_name[anyLength.unit()];
508 rtYunit->setCurrentIndex(itemNumber(units, unit));
510 rtY->setText(toqstr(xl));
515 // Update the draft and clip mode
516 draftCB->setChecked(igp.draft);
517 clip->setChecked(igp.clip);
518 unzipCB->setChecked(igp.noUnzip);
519 displayGB->setChecked(igp.display);
520 displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
522 // the output section (width/height)
524 Scale->setText(toqstr(igp.scale));
525 //igp.scale defaults to 100, so we treat it as empty
526 bool const scaleChecked = !igp.scale.empty() && igp.scale != "100";
527 scaleCB->blockSignals(true);
528 scaleCB->setChecked(scaleChecked);
529 scaleCB->blockSignals(false);
530 Scale->setEnabled(scaleChecked);
531 displayGB->setEnabled(lyxrc.display_graphics);
533 groupId->setText(toqstr(igp.groupId));
535 lengthAutoToWidgets(Width, widthUnit, igp.width,
537 bool const widthChecked = !Width->text().isEmpty() &&
538 Width->text() != "auto";
539 WidthCB->blockSignals(true);
540 WidthCB->setChecked(widthChecked);
541 WidthCB->blockSignals(false);
542 Width->setEnabled(widthChecked);
543 widthUnit->setEnabled(widthChecked);
545 lengthAutoToWidgets(Height, heightUnit, igp.height,
547 bool const heightChecked = !Height->text().isEmpty()
548 && Height->text() != "auto";
549 HeightCB->blockSignals(true);
550 HeightCB->setChecked(heightChecked);
551 HeightCB->blockSignals(false);
552 Height->setEnabled(heightChecked);
553 heightUnit->setEnabled(heightChecked);
555 scaleCB->setEnabled(!widthChecked && !heightChecked);
556 WidthCB->setEnabled(!scaleChecked);
557 HeightCB->setEnabled(!scaleChecked);
558 aspectratio->setEnabled(widthChecked && heightChecked);
562 angle->setText(toqstr(igp.rotateAngle));
563 rotateOrderCB->setChecked(igp.scaleBeforeRotation);
565 rotateOrderCB->setEnabled( (widthChecked || heightChecked || scaleChecked)
566 && igp.rotateAngle != "0");
570 vector<RotationOriginPair> origindata = getRotationOriginData();
571 vector<docstring> const origin_lang = getFirst(origindata);
572 origin_ltx = getSecond(origindata);
574 for (vector<docstring>::const_iterator it = origin_lang.begin();
575 it != origin_lang.end(); ++it)
576 origin->addItem(toqstr(*it));
578 if (!igp.rotateOrigin.empty())
579 origin->setCurrentIndex(itemNumber(origin_ltx, igp.rotateOrigin));
581 origin->setCurrentIndex(0);
584 latexoptions->setText(toqstr(igp.special));
588 void GuiGraphics::applyView()
590 InsetGraphicsParams & igp = params_;
592 igp.filename.set(fromqstr(filename->text()), fromqstr(bufferFilepath()));
598 string lbXs = fromqstr(lbX->text());
599 string lbYs = fromqstr(lbY->text());
600 string rtXs = fromqstr(rtX->text());
601 string rtYs = fromqstr(rtY->text());
603 convert<int>(lbXs) + convert<int>(lbYs) +
604 convert<int>(rtXs) + convert<int>(rtXs);
609 bb = lbXs + fromqstr(lbXunit->currentText()) + ' ';
613 bb += (lbYs + fromqstr(lbYunit->currentText()) + ' ');
617 bb += (rtXs + fromqstr(rtXunit->currentText()) + ' ');
621 bb += (rtYs + fromqstr(rtYunit->currentText()));
626 igp.draft = draftCB->isChecked();
627 igp.clip = clip->isChecked();
628 igp.display = displayGB->isChecked();
630 //the graphics section
631 if (scaleCB->isChecked() && !Scale->text().isEmpty()) {
632 igp.scale = fromqstr(Scale->text());
633 igp.width = Length("0pt");
634 igp.height = Length("0pt");
635 igp.keepAspectRatio = false;
637 igp.scale = string();
638 igp.width = WidthCB->isChecked() ?
639 //Note that this works even if Width is "auto", since in
640 //that case we get "0pt".
641 Length(widgetsToLength(Width, widthUnit)):
643 igp.height = HeightCB->isChecked() ?
644 Length(widgetsToLength(Height, heightUnit)) :
646 igp.keepAspectRatio = aspectratio->isEnabled() &&
647 aspectratio->isChecked() &&
648 igp.width.value() > 0 && igp.height.value() > 0;
651 igp.noUnzip = unzipCB->isChecked();
652 igp.lyxscale = displayscale->text().toInt();
653 igp.rotateAngle = fromqstr(angle->text());
655 double rotAngle = convert<double>(igp.rotateAngle);
656 if (abs(rotAngle) > 360.0) {
657 rotAngle -= 360.0 * floor(rotAngle / 360.0);
658 igp.rotateAngle = convert<string>(rotAngle);
661 // save the latex name for the origin. If it is the default
662 // then origin_ltx returns ""
663 igp.rotateOrigin = origin_ltx[origin->currentIndex()];
664 igp.scaleBeforeRotation = rotateOrderCB->isChecked();
666 // more latex options
667 igp.special = fromqstr(latexoptions->text());
669 igp.groupId = fromqstr(groupId->text());
673 void GuiGraphics::getBB()
675 string const fn = fromqstr(filename->text());
678 string const bb = readBoundingBox(fn);
682 lbX->setText(toqstr(token(bb, ' ', 0)));
683 lbY->setText(toqstr(token(bb, ' ', 1)));
684 rtX->setText(toqstr(token(bb, ' ', 2)));
685 rtY->setText(toqstr(token(bb, ' ', 3)));
686 // the default units for the bb values when reading
688 lbXunit->setCurrentIndex(0);
689 lbYunit->setCurrentIndex(0);
690 rtXunit->setCurrentIndex(0);
691 rtYunit->setCurrentIndex(0);
695 bool GuiGraphics::isValid()
697 return !filename->text().isEmpty();
701 bool GuiGraphics::initialiseParams(string const & data)
703 InsetGraphics::string2params(data, buffer(), params_);
704 paramsToDialog(params_);
709 void GuiGraphics::clearParams()
711 params_ = InsetGraphicsParams();
715 void GuiGraphics::dispatchParams()
717 InsetGraphicsParams tmp_params(params_);
718 string const lfun = InsetGraphics::params2string(tmp_params, buffer());
719 buffer().undo().beginUndoGroup();
720 dispatch(FuncRequest(getLfun(), lfun));
721 if (!params_.groupId.empty())
722 dispatch(FuncRequest(LFUN_GRAPHICS_GROUPS_UNIFY,
723 InsetGraphics::params2string(params_, buffer())));
724 buffer().undo().endUndoGroup();
728 QString GuiGraphics::browse(QString const & in_name) const
730 QString const title = qt_("Select graphics file");
732 // Does user clipart directory exist?
733 string clipdir = addName(package().user_support().absFilename(), "clipart");
734 FileName clip(clipdir);
736 // bail out to system clipart directory
737 if (!clip.isDirectory())
738 clipdir = addName(package().system_support().absFilename(), "clipart");
740 return browseRelFile(in_name, bufferFilepath(),
741 title, fileFilters(QString()), false,
742 qt_("Clipart|#C#c"), toqstr(clipdir),
743 qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
747 string GuiGraphics::readBoundingBox(string const & file)
749 FileName const abs_file = support::makeAbsPath(file, fromqstr(bufferFilepath()));
751 // try to get it from the file, if possible. Zipped files are
752 // unzipped in the readBB_from_PSFile-Function
753 string const bb = readBB_from_PSFile(abs_file);
757 // we don't, so ask the Graphics Cache if it has loaded the file
761 graphics::Cache & gc = graphics::Cache::get();
762 if (gc.inCache(abs_file)) {
763 graphics::Image const * image = gc.item(abs_file)->image();
766 width = image->width();
767 height = image->height();
771 return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
775 bool GuiGraphics::isFileNameValid(string const & fname) const
777 // It may be that the filename is relative.
778 return support::makeAbsPath(fname, fromqstr(bufferFilepath())).isReadableFile();
782 Dialog * createGuiGraphics(GuiView & lv) { return new GuiGraphics(lv); }
785 } // namespace frontend
788 #include "GuiGraphics_moc.cpp"