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