namespace {
-RotationDataType origins_array[] = {
+RotationDataType origins[] = {
RotationData::DEFAULT,
RotationData::TOPLEFT,
RotationData::BOTTOMLEFT,
};
-size_type const origins_array_size =
-sizeof(origins_array) / sizeof(origins_array[0]);
-
-vector<external::RotationDataType> const
-all_origins(origins_array, origins_array + origins_array_size);
-
// These are the strings, corresponding to the above, that the GUI should
// use. Note that they can/should be translated.
char const * const origin_gui_strs[] = {
return i1->second;
}
-
-
} // namespace anon
externalCO->addItem(qt_(i1->second.lyxName));
// Fill the origins combo
- for (size_t i = 0; i != all_origins.size(); ++i)
+ for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
originCO->addItem(qt_(origin_gui_strs[i]));
// Fill the width combo
void GuiExternal::getbbClicked()
{
- getBB();
+ xlED->setText("0");
+ ybED->setText("0");
+ xrED->setText("0");
+ ytED->setText("0");
+
+ string const filename = fromqstr(fileED->text());
+ if (filename.empty())
+ return;
+
+ FileName const abs_file(makeAbsPath(filename, fromqstr(bufferFilepath())));
+
+ // try to get it from the file, if possible
+ string bb = readBB_from_PSFile(abs_file);
+ if (bb.empty()) {
+ // we don't, so ask the Graphics Cache if it has loaded the file
+ int width = 0;
+ int height = 0;
+
+ graphics::Cache & gc = graphics::Cache::get();
+ if (gc.inCache(abs_file)) {
+ graphics::Image const * image = gc.item(abs_file)->image();
+
+ if (image) {
+ width = image->width();
+ height = image->height();
+ }
+ }
+ bb = "0 0 " + convert<string>(width) + ' ' + convert<string>(height);
+ }
+
+ xlED->setText(toqstr(token(bb, ' ', 0)));
+ ybED->setText(toqstr(token(bb, ' ', 1)));
+ xrED->setText(toqstr(token(bb, ' ', 2)));
+ ytED->setText(toqstr(token(bb, ' ', 3)));
+
+ bbChanged_ = false;
}
}
-static void getDisplay(external::DisplayType & display,
- unsigned int & scale,
- QCheckBox const & displayCB,
- QComboBox const & showCO,
- QLineEdit const & scaleED)
+static external::DisplayType display(QCheckBox const & displayCB,
+ QComboBox const & showCO)
{
+ if (!displayCB.isChecked())
+ return external::NoDisplay;
switch (showCO.currentIndex()) {
+ default:
case 0:
- display = external::DefaultDisplay;
- break;
+ return external::DefaultDisplay;
case 1:
- display = external::MonochromeDisplay;
- break;
+ return external::MonochromeDisplay;
case 2:
- display = external::GrayscaleDisplay;
- break;
+ return external::GrayscaleDisplay;
case 3:
- display = external::ColorDisplay;
- break;
+ return external::ColorDisplay;
case 4:
- display = external::PreviewDisplay;
- break;
+ return external::PreviewDisplay;
}
-
- if (!displayCB.isChecked())
- display = external::NoDisplay;
-
- scale = scaleED.text().toInt();
}
params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
params_.draft = draftCB->isChecked();
-
- getDisplay(params_.display, params_.lyxscale,
- *displayCB, *showCO, *displayscaleED);
+ params_.lyxscale = displayscaleED->text().toInt();
+ params_.display = display(*displayCB, *showCO);
if (tab->isTabEnabled(tab->indexOf(rotatetab)))
getRotation(params_.rotationdata, *angleED, *originCO);
}
-void GuiExternal::getBB()
-{
- xlED->setText("0");
- ybED->setText("0");
- xrED->setText("0");
- ytED->setText("0");
-
- string const filename = fromqstr(fileED->text());
- if (filename.empty())
- return;
-
- string const bb = readBB(filename);
- if (bb.empty())
- return;
-
- xlED->setText(toqstr(token(bb, ' ', 0)));
- ybED->setText(toqstr(token(bb, ' ', 1)));
- xrED->setText(toqstr(token(bb, ' ', 2)));
- ytED->setText(toqstr(token(bb, ' ', 3)));
-
- bbChanged_ = false;
-}
-
-
bool GuiExternal::initialiseParams(string const & data)
{
InsetExternal::string2params(data, buffer(), params_);
}
-string const GuiExternal::readBB(string const & file)
-{
- FileName const abs_file(makeAbsPath(file, fromqstr(bufferFilepath())));
-
- // try to get it from the file, if possible. Zipped files are
- // unzipped in the readBB_from_PSFile-Function
- string const bb = readBB_from_PSFile(abs_file);
- if (!bb.empty())
- return bb;
-
- // we don't, so ask the Graphics Cache if it has loaded the file
- int width = 0;
- int height = 0;
-
- graphics::Cache & gc = graphics::Cache::get();
- if (gc.inCache(abs_file)) {
- graphics::Image const * image = gc.item(abs_file)->image();
-
- if (image) {
- width = image->width();
- height = image->height();
- }
- }
-
- return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
-}
-
-
Dialog * createGuiExternal(GuiView & lv) { return new GuiExternal(lv); }