cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24334 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-04-18 20:14:20 +00:00
parent acd3ef6cae
commit 4e8bc3adf1
2 changed files with 56 additions and 100 deletions

View File

@ -54,7 +54,7 @@ using namespace external;
namespace {
RotationDataType origins_array[] = {
RotationDataType origins[] = {
RotationData::DEFAULT,
RotationData::TOPLEFT,
RotationData::BOTTOMLEFT,
@ -69,12 +69,6 @@ RotationDataType origins_array[] = {
};
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[] = {
@ -92,8 +86,6 @@ external::Template getTemplate(int i)
return i1->second;
}
} // namespace anon
@ -214,7 +206,7 @@ GuiExternal::GuiExternal(GuiView & lv)
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
@ -298,7 +290,42 @@ void GuiExternal::formatChanged(const QString & format)
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;
}
@ -382,34 +409,24 @@ static void setDisplay(
}
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)
{
switch (showCO.currentIndex()) {
case 0:
display = external::DefaultDisplay;
break;
case 1:
display = external::MonochromeDisplay;
break;
case 2:
display = external::GrayscaleDisplay;
break;
case 3:
display = external::ColorDisplay;
break;
case 4:
display = external::PreviewDisplay;
break;
}
if (!displayCB.isChecked())
display = external::NoDisplay;
scale = scaleED.text().toInt();
return external::NoDisplay;
switch (showCO.currentIndex()) {
default:
case 0:
return external::DefaultDisplay;
case 1:
return external::MonochromeDisplay;
case 2:
return external::GrayscaleDisplay;
case 3:
return external::ColorDisplay;
case 4:
return external::PreviewDisplay;
}
}
@ -639,9 +656,8 @@ void GuiExternal::applyView()
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);
@ -663,30 +679,6 @@ void GuiExternal::applyView()
}
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_);
@ -741,34 +733,6 @@ QString GuiExternal::browse(QString const & input,
}
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); }

View File

@ -17,8 +17,6 @@
#include "GuiDialog.h"
#include "ui_ExternalUi.h"
#include "support/types.h"
#include "insets/InsetExternal.h"
#include <QHash>
@ -57,8 +55,6 @@ private:
void updateContents();
/// Helper function called when the template is changed.
void updateTemplate();
/// get bounding box from file
void getBB();
///
MapType extra_;
@ -76,10 +72,6 @@ private:
///
QString browse(QString const & input_file,
QString const & template_name) const;
/// Read the Bounding Box from a eps or ps-file
std::string const readBB(std::string const & file);
///
private:
///
InsetExternalParams params_;