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