]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiExternal.cpp
44ffefd58a498fa7384c7af778f4412e32f3c912
[lyx.git] / src / frontends / qt4 / GuiExternal.cpp
1 /**
2  * \file GuiExternal.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "lengthcommon.h"
15 #include "LyXRC.h"
16
17 #include "insets/ExternalTemplate.h"
18 #include "insets/InsetExternal.h"
19
20 #include "support/lstrings.h"
21 #include "support/convert.h"
22 #include "support/os.h"
23 #include "support/lyxlib.h"
24
25 #include "GuiExternal.h"
26
27 #include "LengthCombo.h"
28 #include "qt_helpers.h"
29 #include "Validator.h"
30
31 #include <QLineEdit>
32 #include <QPushButton>
33 #include <QCheckBox>
34 #include <QTabWidget>
35 #include <QTextBrowser>
36
37 namespace external = lyx::external;
38
39 using lyx::support::isStrDbl;
40 using lyx::support::token;
41 using lyx::support::trim;
42 using lyx::support::float_equal;
43
44 using lyx::support::os::internal_path;
45
46 using std::string;
47 using std::vector;
48 using std::find;
49
50
51 namespace lyx {
52 namespace frontend {
53
54 /////////////////////////////////////////////////////////////////////
55 //
56 // GuiExternalDialog
57 //
58 /////////////////////////////////////////////////////////////////////
59
60
61 GuiExternalDialog::GuiExternalDialog(GuiExternal * form)
62         : form_(form)
63 {
64         setupUi(this);
65         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
66         connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
67         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
68
69         connect(displayCB, SIGNAL(toggled(bool)),
70                 showCO, SLOT(setEnabled(bool)));
71         connect(displayCB, SIGNAL(toggled(bool)),
72                 displayscaleED, SLOT(setEnabled(bool)));
73         connect(showCO, SIGNAL(activated(const QString&)),
74                 this, SLOT(change_adaptor()));
75         connect(originCO, SIGNAL(activated(int)),
76                 this, SLOT(change_adaptor()));
77         connect(aspectratioCB, SIGNAL(stateChanged(int)),
78                 this, SLOT(change_adaptor()));
79         connect(browsePB, SIGNAL(clicked()),
80                 this, SLOT(browseClicked()));
81         connect(editPB, SIGNAL(clicked()),
82                 this, SLOT(editClicked()));
83         connect(externalCO, SIGNAL(activated(const QString &)),
84                 this, SLOT(templateChanged()));
85         connect(extraED, SIGNAL(textChanged(const QString &)),
86                 this, SLOT(extraChanged(const QString&)));
87         connect(extraFormatCO, SIGNAL(activated(const QString &)),
88                 this, SLOT(formatChanged(const QString&)));
89         connect(widthUnitCO, SIGNAL(activated(int)),
90                 this, SLOT(widthUnitChanged()));
91         connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
92                 this, SLOT(change_adaptor()));
93         connect(displayCB, SIGNAL(stateChanged(int)),
94                 this, SLOT(change_adaptor()));
95         connect(displayscaleED, SIGNAL(textChanged(const QString &)),
96                 this, SLOT(change_adaptor()));
97         connect(angleED, SIGNAL(textChanged(const QString &)),
98                 this, SLOT(change_adaptor()));
99         connect(widthED, SIGNAL(textChanged(const QString &)),
100                 this, SLOT(sizeChanged()));
101         connect(heightED, SIGNAL(textChanged(const QString &)),
102                 this, SLOT(sizeChanged()));
103         connect(fileED, SIGNAL(textChanged(const QString &)),
104                 this, SLOT(change_adaptor()));
105         connect(clipCB, SIGNAL(stateChanged(int)),
106                 this, SLOT(change_adaptor()));
107         connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
108         connect(xrED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
109         connect(ytED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
110         connect(xlED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
111         connect(ybED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
112         connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
113
114         QIntValidator * validator = new QIntValidator(displayscaleED);
115         validator->setBottom(1);
116         displayscaleED->setValidator(validator);
117
118         angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
119
120         xlED->setValidator(new QIntValidator(xlED));
121         ybED->setValidator(new QIntValidator(ybED));
122         xrED->setValidator(new QIntValidator(xrED));
123         ytED->setValidator(new QIntValidator(ytED));
124
125         widthED->setValidator(unsignedLengthValidator(widthED));
126         heightED->setValidator(unsignedLengthValidator(heightED));
127
128         setFocusProxy(fileED);
129 }
130
131
132 void GuiExternalDialog::show()
133 {
134         QDialog::show();
135 }
136
137
138
139 bool GuiExternalDialog::activateAspectratio() const
140 {
141         if (widthUnitCO->currentIndex() == 0)
142                 return false;
143
144         string const wstr = fromqstr(widthED->text());
145         if (wstr.empty())
146                 return false;
147         bool const wIsDbl = isStrDbl(wstr);
148         if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
149                 return false;
150         Length l;
151         if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
152                 return false;
153
154         string const hstr = fromqstr(heightED->text());
155         if (hstr.empty())
156                 return false;
157         bool const hIsDbl = isStrDbl(hstr);
158         if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
159                 return false;
160         if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
161                 return false;
162
163         return true;
164 }
165
166
167 void GuiExternalDialog::bbChanged()
168 {
169         form_->controller().bbChanged(true);
170         form_->changed();
171 }
172
173
174 void GuiExternalDialog::browseClicked()
175 {
176         int const choice =  externalCO->currentIndex();
177         docstring const template_name =
178                 from_utf8(form_->controller().getTemplate(choice).lyxName);
179         docstring const str =
180                 form_->controller().browse(qstring_to_ucs4(fileED->text()),
181                                            template_name);
182         if (!str.empty()) {
183                 fileED->setText(toqstr(str));
184                 form_->changed();
185         }
186 }
187
188
189 void GuiExternalDialog::change_adaptor()
190 {
191         form_->changed();
192 }
193
194
195 void GuiExternalDialog::closeEvent(QCloseEvent * e)
196 {
197         form_->slotWMHide();
198         e->accept();
199 }
200
201
202 void GuiExternalDialog::editClicked()
203 {
204         form_->controller().editExternal();
205 }
206
207
208
209 void GuiExternalDialog::extraChanged(const QString& text)
210 {
211         std::string const format = fromqstr(extraFormatCO->currentText());
212         form_->extra_[format] = text;
213         form_->changed();
214 }
215
216
217 void GuiExternalDialog::formatChanged(const QString& format)
218 {
219         extraED->setText(form_->extra_[fromqstr(format)]);
220 }
221
222
223 void GuiExternalDialog::getbbClicked()
224 {
225         form_->getBB();
226 }
227
228
229 void GuiExternalDialog::sizeChanged()
230 {
231         aspectratioCB->setEnabled(activateAspectratio());
232         form_->changed();
233 }
234
235
236 void GuiExternalDialog::templateChanged()
237 {
238         form_->updateTemplate();
239         form_->changed();
240 }
241
242
243 void GuiExternalDialog::widthUnitChanged()
244 {
245         bool useHeight = (widthUnitCO->currentIndex() > 0);
246
247         if (useHeight)
248                 widthED->setValidator(unsignedLengthValidator(widthED));
249         else
250                 widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
251
252         heightED->setEnabled(useHeight);
253         heightUnitCO->setEnabled(useHeight);
254         form_->changed();
255 }
256
257
258 /////////////////////////////////////////////////////////////////////
259 //
260 // GuiExternal
261 //
262 /////////////////////////////////////////////////////////////////////
263
264 namespace {
265
266 Length::UNIT defaultUnit()
267 {
268         Length::UNIT default_unit = Length::CM;
269         switch (lyxrc.default_papersize) {
270         case PAPER_USLETTER:
271         case PAPER_USLEGAL:
272         case PAPER_USEXECUTIVE:
273                 default_unit = Length::IN;
274                 break;
275         default:
276                 break;
277         }
278         return default_unit;
279 }
280
281
282 void setDisplay(QCheckBox & displayCB, QComboBox & showCO, QLineEdit & scaleED,
283                 external::DisplayType display, unsigned int scale,
284                 bool read_only)
285 {
286         int item = 0;
287         switch (display) {
288         case external::DefaultDisplay:
289                 item = 0;
290                 break;
291         case external::MonochromeDisplay:
292                 item = 1;
293                 break;
294         case external::GrayscaleDisplay:
295                 item = 2;
296                 break;
297         case external::ColorDisplay:
298                 item = 3;
299                 break;
300         case external::PreviewDisplay:
301                 item = 4;
302                 break;
303         case external::NoDisplay:
304                 item = 0;
305                 break;
306         }
307
308         showCO.setCurrentIndex(item);
309         bool const no_display = display == external::NoDisplay;
310         showCO.setEnabled(!no_display && !read_only);
311         displayCB.setChecked(!no_display);
312         scaleED.setEnabled(!no_display && !read_only);
313         scaleED.setText(toqstr(convert<string>(scale)));
314 }
315
316
317 void getDisplay(external::DisplayType & display,
318                 unsigned int & scale,
319                 QCheckBox const & displayCB,
320                 QComboBox const & showCO,
321                 QLineEdit const & scaleED)
322 {
323         switch (showCO.currentIndex()) {
324         case 0:
325                 display = external::DefaultDisplay;
326                 break;
327         case 1:
328                 display = external::MonochromeDisplay;
329                 break;
330         case 2:
331                 display = external::GrayscaleDisplay;
332                 break;
333         case 3:
334                 display = external::ColorDisplay;
335                 break;
336         case 4:
337                 display = external::PreviewDisplay;
338                 break;
339         }
340
341         if (!displayCB.isChecked())
342                 display = external::NoDisplay;
343
344         scale = convert<int>(fromqstr(scaleED.text()));
345 }
346
347
348 void setRotation(QLineEdit & angleED, QComboBox & originCO,
349                  external::RotationData const & data)
350 {
351         originCO.setCurrentIndex(int(data.origin()));
352         angleED.setText(toqstr(data.angle));
353 }
354
355
356 void getRotation(external::RotationData & data,
357                  QLineEdit const & angleED, QComboBox const & originCO)
358 {
359         typedef external::RotationData::OriginType OriginType;
360
361         data.origin(static_cast<OriginType>(originCO.currentIndex()));
362         data.angle = fromqstr(angleED.text());
363 }
364
365
366 void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
367              QLineEdit & heightED, LengthCombo & heightUnitCO,
368              QCheckBox & aspectratioCB,
369              external::ResizeData const & data)
370 {
371         bool using_scale = data.usingScale();
372         std::string scale = data.scale;
373         if (data.no_resize()) {
374                 // Everything is zero, so default to this!
375                 using_scale = true;
376                 scale = "100";
377         }
378
379         if (using_scale) {
380                 widthED.setText(toqstr(scale));
381                 widthUnitCO.setCurrentIndex(0);
382         } else {
383                 widthED.setText(toqstr(convert<string>(data.width.value())));
384                 // Because 'Scale' is position 0...
385                 // Note also that width cannot be zero here, so
386                 // we don't need to worry about the default unit.
387                 widthUnitCO.setCurrentIndex(data.width.unit() + 1);
388         }
389
390         string const h = data.height.zero() ? string() : data.height.asString();
391         Length::UNIT default_unit = data.width.zero() ?
392                 defaultUnit() : data.width.unit();
393         lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
394
395         heightED.setEnabled(!using_scale);
396         heightUnitCO.setEnabled(!using_scale);
397
398         aspectratioCB.setChecked(data.keepAspectRatio);
399
400         bool const disable_aspectRatio = using_scale ||
401                 data.width.zero() || data.height.zero();
402         aspectratioCB.setEnabled(!disable_aspectRatio);
403 }
404
405
406 void getSize(external::ResizeData & data,
407              QLineEdit const & widthED, QComboBox const & widthUnitCO,
408              QLineEdit const & heightED, LengthCombo const & heightUnitCO,
409              QCheckBox const & aspectratioCB)
410 {
411         string const width = fromqstr(widthED.text());
412
413         if (widthUnitCO.currentIndex() > 0) {
414                 // Subtract one, because scale is 0.
415                 int const unit = widthUnitCO.currentIndex() - 1;
416
417                 Length w;
418                 if (isValidLength(width, &w))
419                         data.width = w;
420                 else if (isStrDbl(width))
421                         data.width = Length(convert<double>(width),
422                                            static_cast<Length::UNIT>(unit));
423                 else
424                         data.width = Length();
425
426                 data.scale = string();
427
428         } else {
429                 // scaling instead of a width
430                 data.scale = width;
431                 data.width = Length();
432         }
433
434         data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
435
436         data.keepAspectRatio = aspectratioCB.isChecked();
437 }
438
439
440 void setCrop(QCheckBox & clipCB,
441              QLineEdit & xlED, QLineEdit & ybED,
442              QLineEdit & xrED, QLineEdit & ytED,
443              external::ClipData const & data)
444 {
445         clipCB.setChecked(data.clip);
446         graphics::BoundingBox const & bbox = data.bbox;
447         xlED.setText(toqstr(convert<string>(bbox.xl)));
448         ybED.setText(toqstr(convert<string>(bbox.yb)));
449         xrED.setText(toqstr(convert<string>(bbox.xr)));
450         ytED.setText(toqstr(convert<string>(bbox.yt)));
451 }
452
453
454 void getCrop(external::ClipData & data,
455              QCheckBox const & clipCB,
456              QLineEdit const & xlED, QLineEdit const & ybED,
457              QLineEdit const & xrED, QLineEdit const & ytED,
458              bool bb_changed)
459 {
460         data.clip = clipCB.isChecked();
461
462         if (!bb_changed)
463                 return;
464
465         data.bbox.xl = convert<int>(fromqstr(xlED.text()));
466         data.bbox.yb = convert<int>(fromqstr(ybED.text()));
467         data.bbox.xr = convert<int>(fromqstr(xrED.text()));
468         data.bbox.yt = convert<int>(fromqstr(ytED.text()));
469 }
470
471
472 void getExtra(external::ExtraData & data,
473               GuiExternal::MapType const & extra)
474 {
475         typedef GuiExternal::MapType MapType;
476         MapType::const_iterator it  = extra.begin();
477         MapType::const_iterator const end = extra.end();
478         for (; it != end; ++it)
479                 data.set(it->first, trim(fromqstr(it->second)));
480 }
481
482 } // namespace anon
483
484
485 GuiExternal::GuiExternal(GuiDialog & parent)
486         : GuiView<GuiExternalDialog>(parent, _("External Material"))
487 {}
488
489
490 void GuiExternal::build_dialog()
491 {
492         dialog_.reset(new GuiExternalDialog(this));
493
494         bc().setOK(dialog_->okPB);
495         bc().setApply(dialog_->applyPB);
496         bc().setCancel(dialog_->closePB);
497
498         bc().addReadOnly(dialog_->fileED);
499         bc().addReadOnly(dialog_->browsePB);
500         bc().addReadOnly(dialog_->editPB);
501         bc().addReadOnly(dialog_->externalCO);
502         bc().addReadOnly(dialog_->draftCB);
503         bc().addReadOnly(dialog_->displayscaleED);
504         bc().addReadOnly(dialog_->showCO);
505         bc().addReadOnly(dialog_->displayCB);
506         bc().addReadOnly(dialog_->angleED);
507         bc().addReadOnly(dialog_->originCO);
508         bc().addReadOnly(dialog_->heightUnitCO);
509         bc().addReadOnly(dialog_->heightED);
510         bc().addReadOnly(dialog_->aspectratioCB);
511         bc().addReadOnly(dialog_->widthUnitCO);
512         bc().addReadOnly(dialog_->widthED);
513         bc().addReadOnly(dialog_->clipCB);
514         bc().addReadOnly(dialog_->getbbPB);
515         bc().addReadOnly(dialog_->ytED);
516         bc().addReadOnly(dialog_->xlED);
517         bc().addReadOnly(dialog_->xrED);
518         bc().addReadOnly(dialog_->ybED);
519         bc().addReadOnly(dialog_->extraFormatCO);
520         bc().addReadOnly(dialog_->extraED);
521
522         bc().addCheckedLineEdit(dialog_->angleED, dialog_->angleLA);
523         bc().addCheckedLineEdit(dialog_->displayscaleED, dialog_->scaleLA);
524         bc().addCheckedLineEdit(dialog_->heightED, dialog_->heightLA);
525         bc().addCheckedLineEdit(dialog_->widthED, dialog_->widthLA);
526         bc().addCheckedLineEdit(dialog_->xlED, dialog_->lbLA);
527         bc().addCheckedLineEdit(dialog_->ybED, dialog_->lbLA);
528         bc().addCheckedLineEdit(dialog_->xrED, dialog_->rtLA);
529         bc().addCheckedLineEdit(dialog_->ytED, dialog_->rtLA);
530         bc().addCheckedLineEdit(dialog_->fileED, dialog_->fileLA);
531
532         std::vector<string> templates(controller().getTemplates());
533
534         for (std::vector<string>::const_iterator cit = templates.begin();
535                 cit != templates.end(); ++cit) {
536                 dialog_->externalCO->addItem(qt_(*cit));
537         }
538
539         // Fill the origins combo
540         typedef vector<external::RotationDataType> Origins;
541         Origins const & all_origins = external::all_origins();
542         for (Origins::size_type i = 0; i != all_origins.size(); ++i)
543                 dialog_->originCO->addItem(toqstr(external::origin_gui_str(i)));
544
545         // Fill the width combo
546         dialog_->widthUnitCO->addItem(qt_("Scale%"));
547         for (int i = 0; i < num_units; i++)
548                 dialog_->widthUnitCO->addItem(qt_(unit_name_gui[i]));
549 }
550
551
552 void GuiExternal::update_contents()
553 {
554         dialog_->tab->setCurrentIndex(0);
555         InsetExternalParams const & params = controller().params();
556
557         string const name =
558                 params.filename.outputFilename(kernel().bufferFilepath());
559         dialog_->fileED->setText(toqstr(name));
560
561         dialog_->externalCO->setCurrentIndex(
562                 controller().getTemplateNumber(params.templatename()));
563         updateTemplate();
564
565         dialog_->draftCB->setChecked(params.draft);
566
567         setDisplay(*dialog_->displayCB, *dialog_->showCO,
568                    *dialog_->displayscaleED,
569                    params.display, params.lyxscale, readOnly());
570
571         setRotation(*dialog_->angleED, *dialog_->originCO, params.rotationdata);
572
573         setSize(*dialog_->widthED, *dialog_->widthUnitCO,
574                 *dialog_->heightED, *dialog_->heightUnitCO,
575                 *dialog_->aspectratioCB,
576                 params.resizedata);
577
578         setCrop(*dialog_->clipCB,
579                 *dialog_->xlED, *dialog_->ybED,
580                 *dialog_->xrED, *dialog_->ytED,
581                 params.clipdata);
582         controller().bbChanged(!params.clipdata.bbox.empty());
583
584         isValid();
585 }
586
587
588 void GuiExternal::updateTemplate()
589 {
590         external::Template templ =
591                 controller().getTemplate(dialog_->externalCO->currentIndex());
592         dialog_->externalTB->setPlainText(qt_(templ.helpText));
593
594         // Ascertain which (if any) transformations the template supports
595         // and disable tabs hosting unsupported transforms.
596         typedef vector<external::TransformID> TransformIDs;
597         TransformIDs const transformIds = templ.transformIds;
598         TransformIDs::const_iterator tr_begin = transformIds.begin();
599         TransformIDs::const_iterator const tr_end = transformIds.end();
600
601         bool found = find(tr_begin, tr_end, external::Rotate) != tr_end;
602         dialog_->tab->setTabEnabled(
603                 dialog_->tab->indexOf(dialog_->rotatetab), found);
604         found = find(tr_begin, tr_end, external::Resize) != tr_end;
605         dialog_->tab->setTabEnabled(
606                 dialog_->tab->indexOf(dialog_->scaletab), found);
607
608         found = find(tr_begin, tr_end, external::Clip) != tr_end;
609         dialog_->tab->setTabEnabled(
610                 dialog_->tab->indexOf(dialog_->croptab), found);
611
612         found = find(tr_begin, tr_end, external::Extra) != tr_end;
613         dialog_->tab->setTabEnabled(
614                 dialog_->tab->indexOf(dialog_->optionstab), found);
615
616         if (!found)
617                 return;
618
619         // Ascertain whether the template has any formats supporting
620         // the 'Extra' option
621         QLineEdit * const extraED = dialog_->extraED;
622         QComboBox * const extraCB = dialog_->extraFormatCO;
623
624         extra_.clear();
625         extraED->clear();
626         extraCB->clear();
627
628         external::Template::Formats::const_iterator it  = templ.formats.begin();
629         external::Template::Formats::const_iterator end = templ.formats.end();
630         for (; it != end; ++it) {
631                 if (it->second.option_transformers.find(external::Extra) ==
632                     it->second.option_transformers.end())
633                         continue;
634                 string const format = it->first;
635                 string const opt = controller().params().extradata.get(format);
636                 extraCB->addItem(toqstr(format));
637                 extra_[format] = toqstr(opt);
638         }
639
640         bool const enabled = extraCB->count()  > 0;
641
642         dialog_->tab->setTabEnabled(
643                 dialog_->tab->indexOf(dialog_->optionstab), enabled);
644         extraED->setEnabled(enabled && !kernel().isBufferReadonly());
645         extraCB->setEnabled(enabled);
646
647         if (enabled) {
648                 extraCB->setCurrentIndex(0);
649                 extraED->setText(extra_[fromqstr(extraCB->currentText())]);
650         }
651 }
652
653
654 void GuiExternal::apply()
655 {
656         InsetExternalParams params = controller().params();
657
658         params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
659                             kernel().bufferFilepath());
660
661         params.settemplate(controller().getTemplate(
662                                    dialog_->externalCO->currentIndex()).lyxName);
663
664         params.draft = dialog_->draftCB->isChecked();
665
666         getDisplay(params.display, params.lyxscale,
667                    *dialog_->displayCB, *dialog_->showCO,
668                    *dialog_->displayscaleED);
669
670         if (dialog_->tab->isTabEnabled(
671                 dialog_->tab->indexOf(dialog_->rotatetab)))
672                 getRotation(params.rotationdata,
673                             *dialog_->angleED, *dialog_->originCO);
674
675         if (dialog_->tab->isTabEnabled(
676                 dialog_->tab->indexOf(dialog_->scaletab)))
677                 getSize(params.resizedata,
678                         *dialog_->widthED, *dialog_->widthUnitCO,
679                         *dialog_->heightED, *dialog_->heightUnitCO,
680                         *dialog_->aspectratioCB);
681
682         if (dialog_->tab->isTabEnabled(
683                 dialog_->tab->indexOf(dialog_->croptab)))
684                 getCrop(params.clipdata,
685                         *dialog_->clipCB,
686                         *dialog_->xlED, *dialog_->ybED,
687                         *dialog_->xrED, *dialog_->ytED,
688                         controller().bbChanged());
689
690         if (dialog_->tab->isTabEnabled(
691                 dialog_->tab->indexOf(dialog_->optionstab)))
692                 getExtra(params.extradata, extra_);
693
694         controller().setParams(params);
695 }
696
697
698 void GuiExternal::getBB()
699 {
700         dialog_->xlED->setText("0");
701         dialog_->ybED->setText("0");
702         dialog_->xrED->setText("0");
703         dialog_->ytED->setText("0");
704
705         string const filename = fromqstr(dialog_->fileED->text());
706         if (filename.empty())
707                 return;
708
709         string const bb = controller().readBB(filename);
710         if (bb.empty())
711                 return;
712
713         dialog_->xlED->setText(toqstr(token(bb, ' ', 0)));
714         dialog_->ybED->setText(toqstr(token(bb, ' ', 1)));
715         dialog_->xrED->setText(toqstr(token(bb, ' ', 2)));
716         dialog_->ytED->setText(toqstr(token(bb, ' ', 3)));
717
718         controller().bbChanged(false);
719 }
720
721 } // namespace frontend
722 } // namespace lyx
723
724 #include "GuiExternal_moc.cpp"