2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiExternal.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
* \author Angus Leeming
|
2007-10-07 08:55:20 +00:00
|
|
|
* \author Asger Alstrup
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "GuiExternal.h"
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "gettext.h"
|
2007-10-24 22:55:02 +00:00
|
|
|
#include "Length.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXRC.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
#include "insets/ExternalSupport.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "insets/ExternalTemplate.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetExternal.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
#include "graphics/GraphicsCache.h"
|
|
|
|
#include "graphics/GraphicsCacheItem.h"
|
|
|
|
#include "graphics/GraphicsImage.h"
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "support/convert.h"
|
2007-10-07 08:55:20 +00:00
|
|
|
#include "support/FileFilterList.h"
|
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/lstrings.h"
|
2007-04-25 08:42:22 +00:00
|
|
|
#include "support/lyxlib.h"
|
2007-10-07 08:55:20 +00:00
|
|
|
#include "support/os.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "LengthCombo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "Validator.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QCheckBox>
|
2006-05-03 19:51:15 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTextBrowser>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
using std::advance;
|
2006-03-05 17:24:44 +00:00
|
|
|
using std::vector;
|
2007-10-07 08:55:20 +00:00
|
|
|
using std::string;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
using support::FileFilterList;
|
|
|
|
using support::FileName;
|
|
|
|
using support::float_equal;
|
|
|
|
using support::isStrDbl;
|
|
|
|
using support::makeAbsPath;
|
|
|
|
using support::readBB_from_PSFile;
|
|
|
|
using support::token;
|
|
|
|
using support::trim;
|
|
|
|
using support::os::internal_path;
|
|
|
|
|
|
|
|
using namespace external;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
RotationDataType origins_array[] = {
|
|
|
|
RotationData::DEFAULT,
|
|
|
|
RotationData::TOPLEFT,
|
|
|
|
RotationData::BOTTOMLEFT,
|
|
|
|
RotationData::BASELINELEFT,
|
|
|
|
RotationData::CENTER,
|
|
|
|
RotationData::TOPCENTER,
|
|
|
|
RotationData::BOTTOMCENTER,
|
|
|
|
RotationData::BASELINECENTER,
|
|
|
|
RotationData::TOPRIGHT,
|
|
|
|
RotationData::BOTTOMRIGHT,
|
|
|
|
RotationData::BASELINERIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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[] = {
|
|
|
|
N_("Default"),
|
|
|
|
N_("Top left"), N_("Bottom left"), N_("Baseline left"),
|
|
|
|
N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
|
|
|
|
N_("Top right"), N_("Bottom right"), N_("Baseline right")
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiExternal::GuiExternal(GuiView & lv)
|
2007-10-09 19:34:27 +00:00
|
|
|
: GuiDialog(lv, "external"), bbChanged_(false)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
setViewTitle(_("External Material"));
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-25 16:39:21 +00:00
|
|
|
|
|
|
|
connect(displayCB, SIGNAL(toggled(bool)),
|
|
|
|
showCO, SLOT(setEnabled(bool)));
|
|
|
|
connect(displayCB, SIGNAL(toggled(bool)),
|
|
|
|
displayscaleED, SLOT(setEnabled(bool)));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(showCO, SIGNAL(activated(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(originCO, SIGNAL(activated(int)),
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(aspectratioCB, SIGNAL(stateChanged(int)),
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(browsePB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(browseClicked()));
|
|
|
|
connect(editPB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(editClicked()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(externalCO, SIGNAL(activated(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(templateChanged()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(extraED, SIGNAL(textChanged(QString)),
|
|
|
|
this, SLOT(extraChanged(QString)));
|
|
|
|
connect(extraFormatCO, SIGNAL(activated(QString)),
|
|
|
|
this, SLOT(formatChanged(QString)));
|
2007-04-25 16:39:21 +00:00
|
|
|
connect(widthUnitCO, SIGNAL(activated(int)),
|
|
|
|
this, SLOT(widthUnitChanged()));
|
2007-04-28 12:58:49 +00:00
|
|
|
connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(displayCB, SIGNAL(stateChanged(int)),
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(displayscaleED, SIGNAL(textChanged(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(angleED, SIGNAL(textChanged(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(widthED, SIGNAL(textChanged(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(sizeChanged()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(heightED, SIGNAL(textChanged(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(sizeChanged()));
|
2007-10-09 19:34:27 +00:00
|
|
|
connect(fileED, SIGNAL(textChanged(QString)),
|
2007-04-25 16:39:21 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(clipCB, SIGNAL(stateChanged(int)),
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
|
2007-10-07 08:55:20 +00:00
|
|
|
connect(xrED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
|
|
|
|
connect(ytED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
|
|
|
|
connect(xlED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
|
|
|
|
connect(ybED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
|
2007-04-25 16:39:21 +00:00
|
|
|
connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
|
|
QIntValidator * validator = new QIntValidator(displayscaleED);
|
|
|
|
validator->setBottom(1);
|
|
|
|
displayscaleED->setValidator(validator);
|
|
|
|
|
|
|
|
angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
|
|
|
|
|
|
|
|
xlED->setValidator(new QIntValidator(xlED));
|
|
|
|
ybED->setValidator(new QIntValidator(ybED));
|
|
|
|
xrED->setValidator(new QIntValidator(xrED));
|
|
|
|
ytED->setValidator(new QIntValidator(ytED));
|
|
|
|
|
|
|
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
|
|
|
heightED->setValidator(unsignedLengthValidator(heightED));
|
|
|
|
|
|
|
|
setFocusProxy(fileED);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
|
|
|
|
bc().setOK(okPB);
|
|
|
|
bc().setApply(applyPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
|
|
|
|
bc().addReadOnly(fileED);
|
|
|
|
bc().addReadOnly(browsePB);
|
|
|
|
bc().addReadOnly(editPB);
|
|
|
|
bc().addReadOnly(externalCO);
|
|
|
|
bc().addReadOnly(draftCB);
|
|
|
|
bc().addReadOnly(displayscaleED);
|
|
|
|
bc().addReadOnly(showCO);
|
|
|
|
bc().addReadOnly(displayCB);
|
|
|
|
bc().addReadOnly(angleED);
|
|
|
|
bc().addReadOnly(originCO);
|
|
|
|
bc().addReadOnly(heightUnitCO);
|
|
|
|
bc().addReadOnly(heightED);
|
|
|
|
bc().addReadOnly(aspectratioCB);
|
|
|
|
bc().addReadOnly(widthUnitCO);
|
|
|
|
bc().addReadOnly(widthED);
|
|
|
|
bc().addReadOnly(clipCB);
|
|
|
|
bc().addReadOnly(getbbPB);
|
|
|
|
bc().addReadOnly(ytED);
|
|
|
|
bc().addReadOnly(xlED);
|
|
|
|
bc().addReadOnly(xrED);
|
|
|
|
bc().addReadOnly(ybED);
|
|
|
|
bc().addReadOnly(extraFormatCO);
|
|
|
|
bc().addReadOnly(extraED);
|
|
|
|
|
|
|
|
bc().addCheckedLineEdit(angleED, angleLA);
|
|
|
|
bc().addCheckedLineEdit(displayscaleED, scaleLA);
|
|
|
|
bc().addCheckedLineEdit(heightED, heightLA);
|
|
|
|
bc().addCheckedLineEdit(widthED, widthLA);
|
|
|
|
bc().addCheckedLineEdit(xlED, lbLA);
|
|
|
|
bc().addCheckedLineEdit(ybED, lbLA);
|
|
|
|
bc().addCheckedLineEdit(xrED, rtLA);
|
|
|
|
bc().addCheckedLineEdit(ytED, rtLA);
|
|
|
|
bc().addCheckedLineEdit(fileED, fileLA);
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
std::vector<string> templates = getTemplates();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
for (std::vector<string>::const_iterator cit = templates.begin();
|
|
|
|
cit != templates.end(); ++cit) {
|
|
|
|
externalCO->addItem(qt_(*cit));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fill the origins combo
|
2007-10-07 08:55:20 +00:00
|
|
|
for (size_t i = 0; i != all_origins.size(); ++i)
|
|
|
|
originCO->addItem(qt_(origin_gui_strs[i]));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
// Fill the width combo
|
|
|
|
widthUnitCO->addItem(qt_("Scale%"));
|
|
|
|
for (int i = 0; i < num_units; i++)
|
|
|
|
widthUnitCO->addItem(qt_(unit_name_gui[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
bool GuiExternal::activateAspectratio() const
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
if (widthUnitCO->currentIndex() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
string const wstr = fromqstr(widthED->text());
|
|
|
|
if (wstr.empty())
|
|
|
|
return false;
|
|
|
|
bool const wIsDbl = isStrDbl(wstr);
|
|
|
|
if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
|
|
|
|
return false;
|
2007-04-28 12:58:49 +00:00
|
|
|
Length l;
|
2007-04-25 08:42:22 +00:00
|
|
|
if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
string const hstr = fromqstr(heightED->text());
|
|
|
|
if (hstr.empty())
|
|
|
|
return false;
|
|
|
|
bool const hIsDbl = isStrDbl(hstr);
|
|
|
|
if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
|
|
|
|
return false;
|
|
|
|
if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::bbChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-10-07 08:55:20 +00:00
|
|
|
bbChanged_ = true;
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::browseClicked()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
int const choice = externalCO->currentIndex();
|
2007-10-07 08:55:20 +00:00
|
|
|
docstring const template_name = from_utf8(getTemplate(choice).lyxName);
|
|
|
|
docstring const str = browse(qstring_to_ucs4(fileED->text()), template_name);
|
2007-09-02 08:19:43 +00:00
|
|
|
if (!str.empty()) {
|
2007-05-14 12:43:17 +00:00
|
|
|
fileED->setText(toqstr(str));
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-05-14 12:43:17 +00:00
|
|
|
}
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::change_adaptor()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::closeEvent(QCloseEvent * e)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
slotClose();
|
2007-04-25 08:42:22 +00:00
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::editClicked()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-10-07 08:55:20 +00:00
|
|
|
editExternal();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::extraChanged(const QString& text)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
std::string const format = fromqstr(extraFormatCO->currentText());
|
2007-09-05 20:33:29 +00:00
|
|
|
extra_[format] = text;
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::formatChanged(const QString& format)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
extraED->setText(extra_[fromqstr(format)]);
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::getbbClicked()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
getBB();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::sizeChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
aspectratioCB->setEnabled(activateAspectratio());
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::templateChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
updateTemplate();
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::widthUnitChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
bool useHeight = (widthUnitCO->currentIndex() > 0);
|
|
|
|
|
|
|
|
if (useHeight)
|
|
|
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
|
|
|
else
|
|
|
|
widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
|
|
|
|
|
|
|
|
heightED->setEnabled(useHeight);
|
|
|
|
heightUnitCO->setEnabled(useHeight);
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static Length::UNIT defaultUnit()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-04-28 12:58:49 +00:00
|
|
|
Length::UNIT default_unit = Length::CM;
|
2006-03-05 17:24:44 +00:00
|
|
|
switch (lyxrc.default_papersize) {
|
|
|
|
case PAPER_USLETTER:
|
|
|
|
case PAPER_USLEGAL:
|
|
|
|
case PAPER_USEXECUTIVE:
|
2007-04-28 12:58:49 +00:00
|
|
|
default_unit = Length::IN;
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return default_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void setDisplay(
|
|
|
|
QCheckBox & displayCB, QComboBox & showCO, QLineEdit & scaleED,
|
|
|
|
external::DisplayType display, unsigned int scale, bool read_only)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
int item = 0;
|
|
|
|
switch (display) {
|
|
|
|
case external::DefaultDisplay:
|
|
|
|
item = 0;
|
|
|
|
break;
|
|
|
|
case external::MonochromeDisplay:
|
|
|
|
item = 1;
|
|
|
|
break;
|
|
|
|
case external::GrayscaleDisplay:
|
|
|
|
item = 2;
|
|
|
|
break;
|
|
|
|
case external::ColorDisplay:
|
|
|
|
item = 3;
|
|
|
|
break;
|
|
|
|
case external::PreviewDisplay:
|
|
|
|
item = 4;
|
|
|
|
break;
|
|
|
|
case external::NoDisplay:
|
|
|
|
item = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-08-17 08:54:12 +00:00
|
|
|
showCO.setCurrentIndex(item);
|
2006-03-05 17:24:44 +00:00
|
|
|
bool const no_display = display == external::NoDisplay;
|
|
|
|
showCO.setEnabled(!no_display && !read_only);
|
|
|
|
displayCB.setChecked(!no_display);
|
|
|
|
scaleED.setEnabled(!no_display && !read_only);
|
2007-09-11 18:33:42 +00:00
|
|
|
scaleED.setText(QString::number(scale));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void getDisplay(external::DisplayType & display,
|
2006-03-05 17:24:44 +00:00
|
|
|
unsigned int & scale,
|
|
|
|
QCheckBox const & displayCB,
|
|
|
|
QComboBox const & showCO,
|
|
|
|
QLineEdit const & scaleED)
|
|
|
|
{
|
2006-08-17 08:54:12 +00:00
|
|
|
switch (showCO.currentIndex()) {
|
2006-03-05 17:24:44 +00:00
|
|
|
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;
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
scale = scaleED.text().toInt();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void setRotation(QLineEdit & angleED, QComboBox & originCO,
|
|
|
|
external::RotationData const & data)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-08-17 08:54:12 +00:00
|
|
|
originCO.setCurrentIndex(int(data.origin()));
|
2006-03-05 17:24:44 +00:00
|
|
|
angleED.setText(toqstr(data.angle));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void getRotation(external::RotationData & data,
|
|
|
|
QLineEdit const & angleED, QComboBox const & originCO)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
typedef external::RotationData::OriginType OriginType;
|
|
|
|
|
2006-08-17 08:54:12 +00:00
|
|
|
data.origin(static_cast<OriginType>(originCO.currentIndex()));
|
2006-03-05 17:24:44 +00:00
|
|
|
data.angle = fromqstr(angleED.text());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
|
|
|
|
QLineEdit & heightED, LengthCombo & heightUnitCO,
|
|
|
|
QCheckBox & aspectratioCB,
|
|
|
|
external::ResizeData const & data)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
bool using_scale = data.usingScale();
|
|
|
|
std::string scale = data.scale;
|
|
|
|
if (data.no_resize()) {
|
|
|
|
// Everything is zero, so default to this!
|
|
|
|
using_scale = true;
|
|
|
|
scale = "100";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (using_scale) {
|
|
|
|
widthED.setText(toqstr(scale));
|
2006-08-17 08:54:12 +00:00
|
|
|
widthUnitCO.setCurrentIndex(0);
|
2006-03-05 17:24:44 +00:00
|
|
|
} else {
|
2007-09-11 18:33:42 +00:00
|
|
|
widthED.setText(QString::number(data.width.value()));
|
2006-03-05 17:24:44 +00:00
|
|
|
// Because 'Scale' is position 0...
|
|
|
|
// Note also that width cannot be zero here, so
|
|
|
|
// we don't need to worry about the default unit.
|
2006-08-17 08:54:12 +00:00
|
|
|
widthUnitCO.setCurrentIndex(data.width.unit() + 1);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string const h = data.height.zero() ? string() : data.height.asString();
|
2007-04-28 12:58:49 +00:00
|
|
|
Length::UNIT default_unit = data.width.zero() ?
|
2006-03-05 17:24:44 +00:00
|
|
|
defaultUnit() : data.width.unit();
|
|
|
|
lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
|
|
|
|
|
|
|
|
heightED.setEnabled(!using_scale);
|
|
|
|
heightUnitCO.setEnabled(!using_scale);
|
|
|
|
|
|
|
|
aspectratioCB.setChecked(data.keepAspectRatio);
|
|
|
|
|
|
|
|
bool const disable_aspectRatio = using_scale ||
|
|
|
|
data.width.zero() || data.height.zero();
|
|
|
|
aspectratioCB.setEnabled(!disable_aspectRatio);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void getSize(external::ResizeData & data,
|
|
|
|
QLineEdit const & widthED, QComboBox const & widthUnitCO,
|
|
|
|
QLineEdit const & heightED, LengthCombo const & heightUnitCO,
|
|
|
|
QCheckBox const & aspectratioCB)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
string const width = fromqstr(widthED.text());
|
|
|
|
|
2006-08-17 08:54:12 +00:00
|
|
|
if (widthUnitCO.currentIndex() > 0) {
|
2006-03-05 17:24:44 +00:00
|
|
|
// Subtract one, because scale is 0.
|
2006-08-17 08:54:12 +00:00
|
|
|
int const unit = widthUnitCO.currentIndex() - 1;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
Length w;
|
2006-03-05 17:24:44 +00:00
|
|
|
if (isValidLength(width, &w))
|
|
|
|
data.width = w;
|
|
|
|
else if (isStrDbl(width))
|
2007-04-28 12:58:49 +00:00
|
|
|
data.width = Length(convert<double>(width),
|
|
|
|
static_cast<Length::UNIT>(unit));
|
2006-03-05 17:24:44 +00:00
|
|
|
else
|
2007-04-28 12:58:49 +00:00
|
|
|
data.width = Length();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
data.scale = string();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// scaling instead of a width
|
|
|
|
data.scale = width;
|
2007-04-28 12:58:49 +00:00
|
|
|
data.width = Length();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
data.keepAspectRatio = aspectratioCB.isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setCrop(QCheckBox & clipCB,
|
2007-10-07 08:55:20 +00:00
|
|
|
QLineEdit & xlED, QLineEdit & ybED,
|
|
|
|
QLineEdit & xrED, QLineEdit & ytED,
|
|
|
|
external::ClipData const & data)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
clipCB.setChecked(data.clip);
|
|
|
|
graphics::BoundingBox const & bbox = data.bbox;
|
2007-09-11 18:33:42 +00:00
|
|
|
xlED.setText(QString::number(bbox.xl));
|
|
|
|
ybED.setText(QString::number(bbox.yb));
|
|
|
|
xrED.setText(QString::number(bbox.xr));
|
|
|
|
ytED.setText(QString::number(bbox.yt));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void getCrop(external::ClipData & data,
|
|
|
|
QCheckBox const & clipCB,
|
|
|
|
QLineEdit const & xlED, QLineEdit const & ybED,
|
|
|
|
QLineEdit const & xrED, QLineEdit const & ytED,
|
|
|
|
bool bb_changed)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
data.clip = clipCB.isChecked();
|
|
|
|
|
|
|
|
if (!bb_changed)
|
|
|
|
return;
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
data.bbox.xl = xlED.text().toInt();
|
|
|
|
data.bbox.yb = ybED.text().toInt();
|
|
|
|
data.bbox.xr = xrED.text().toInt();
|
|
|
|
data.bbox.yt = ytED.text().toInt();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
static void getExtra(external::ExtraData & data,
|
|
|
|
GuiExternal::MapType const & extra)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-07 08:55:20 +00:00
|
|
|
typedef GuiExternal::MapType MapType;
|
2007-09-11 18:33:42 +00:00
|
|
|
MapType::const_iterator it = extra.begin();
|
2006-03-05 17:24:44 +00:00
|
|
|
MapType::const_iterator const end = extra.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
data.set(it->first, trim(fromqstr(it->second)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
tab->setCurrentIndex(0);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
string const name =
|
2007-10-07 08:55:20 +00:00
|
|
|
params_.filename.outputFilename(bufferFilepath());
|
2007-09-05 20:33:29 +00:00
|
|
|
fileED->setText(toqstr(name));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
externalCO->setCurrentIndex(getTemplateNumber(params_.templatename()));
|
2006-03-05 17:24:44 +00:00
|
|
|
updateTemplate();
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
draftCB->setChecked(params_.draft);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
setDisplay(*displayCB, *showCO, *displayscaleED,
|
|
|
|
params_.display, params_.lyxscale, isBufferReadonly());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
setRotation(*angleED, *originCO, params_.rotationdata);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
setSize(*widthED, *widthUnitCO, *heightED, *heightUnitCO,
|
|
|
|
*aspectratioCB, params_.resizedata);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
setCrop(*clipCB, *xlED, *ybED, *xrED, *ytED, params_.clipdata);
|
|
|
|
bbChanged_ = !params_.clipdata.bbox.empty();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
isValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::updateTemplate()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-10-07 08:55:20 +00:00
|
|
|
external::Template templ = getTemplate(externalCO->currentIndex());
|
2007-09-05 20:33:29 +00:00
|
|
|
externalTB->setPlainText(qt_(templ.helpText));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
// Ascertain which (if any) transformations the template supports
|
|
|
|
// and disable tabs hosting unsupported transforms.
|
|
|
|
typedef vector<external::TransformID> TransformIDs;
|
|
|
|
TransformIDs const transformIds = templ.transformIds;
|
|
|
|
TransformIDs::const_iterator tr_begin = transformIds.begin();
|
|
|
|
TransformIDs::const_iterator const tr_end = transformIds.end();
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bool found = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
|
|
|
|
tab->setTabEnabled(tab->indexOf(rotatetab), found);
|
|
|
|
found = std::find(tr_begin, tr_end, external::Resize) != tr_end;
|
|
|
|
tab->setTabEnabled(tab->indexOf(scaletab), found);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
found = std::find(tr_begin, tr_end, external::Clip) != tr_end;
|
|
|
|
tab->setTabEnabled(tab->indexOf(croptab), found);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
|
|
|
|
tab->setTabEnabled(tab->indexOf(optionstab), found);
|
2006-08-17 08:54:12 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
if (!found)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Ascertain whether the template has any formats supporting
|
|
|
|
// the 'Extra' option
|
|
|
|
extra_.clear();
|
|
|
|
extraED->clear();
|
2007-09-05 20:33:29 +00:00
|
|
|
extraFormatCO->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
external::Template::Formats::const_iterator it = templ.formats.begin();
|
|
|
|
external::Template::Formats::const_iterator end = templ.formats.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
if (it->second.option_transformers.find(external::Extra) ==
|
|
|
|
it->second.option_transformers.end())
|
|
|
|
continue;
|
|
|
|
string const format = it->first;
|
2007-10-07 08:55:20 +00:00
|
|
|
string const opt = params_.extradata.get(format);
|
2007-09-05 20:33:29 +00:00
|
|
|
extraFormatCO->addItem(toqstr(format));
|
2006-03-05 17:24:44 +00:00
|
|
|
extra_[format] = toqstr(opt);
|
|
|
|
}
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
bool const enabled = extraFormatCO->count() > 0;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
tab->setTabEnabled(
|
|
|
|
tab->indexOf(optionstab), enabled);
|
2007-10-07 08:55:20 +00:00
|
|
|
extraED->setEnabled(enabled && !isBufferReadonly());
|
2007-09-05 20:33:29 +00:00
|
|
|
extraFormatCO->setEnabled(enabled);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
if (enabled) {
|
2007-09-05 20:33:29 +00:00
|
|
|
extraFormatCO->setCurrentIndex(0);
|
|
|
|
extraED->setText(extra_[fromqstr(extraFormatCO->currentText())]);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-11-28 15:25:07 +00:00
|
|
|
params_.filename.set(fromqstr(fileED->text()), bufferFilepath());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
params_.draft = draftCB->isChecked();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
getDisplay(params_.display, params_.lyxscale,
|
2007-09-05 20:33:29 +00:00
|
|
|
*displayCB, *showCO,
|
|
|
|
*displayscaleED);
|
|
|
|
|
|
|
|
if (tab->isTabEnabled(tab->indexOf(rotatetab)))
|
2007-10-07 08:55:20 +00:00
|
|
|
getRotation(params_.rotationdata, *angleED, *originCO);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
if (tab->isTabEnabled(tab->indexOf(scaletab)))
|
2007-10-07 08:55:20 +00:00
|
|
|
getSize(params_.resizedata, *widthED, *widthUnitCO,
|
2007-09-05 20:33:29 +00:00
|
|
|
*heightED, *heightUnitCO, *aspectratioCB);
|
|
|
|
|
|
|
|
if (tab->isTabEnabled(tab->indexOf(croptab)))
|
2007-10-07 08:55:20 +00:00
|
|
|
getCrop(params_.clipdata, *clipCB, *xlED, *ybED,
|
|
|
|
*xrED, *ytED, bbChanged_);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
if (tab->isTabEnabled(tab->indexOf(optionstab)))
|
2007-10-07 08:55:20 +00:00
|
|
|
getExtra(params_.extradata, extra_);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
void GuiExternal::getBB()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
xlED->setText("0");
|
|
|
|
ybED->setText("0");
|
|
|
|
xrED->setText("0");
|
|
|
|
ytED->setText("0");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
string const filename = fromqstr(fileED->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
if (filename.empty())
|
|
|
|
return;
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
string const bb = readBB(filename);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (bb.empty())
|
|
|
|
return;
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
xlED->setText(toqstr(token(bb, ' ', 0)));
|
|
|
|
ybED->setText(toqstr(token(bb, ' ', 1)));
|
|
|
|
xrED->setText(toqstr(token(bb, ' ', 2)));
|
|
|
|
ytED->setText(toqstr(token(bb, ' ', 3)));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
bbChanged_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiExternal::initialiseParams(string const & data)
|
|
|
|
{
|
|
|
|
InsetExternalMailer::string2params(data, buffer(), params_);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiExternal::clearParams()
|
|
|
|
{
|
|
|
|
params_ = InsetExternalParams();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
|
|
|
|
void GuiExternal::dispatchParams()
|
|
|
|
{
|
|
|
|
string const lfun = InsetExternalMailer::params2string(params_, buffer());
|
|
|
|
dispatch(FuncRequest(getLfun(), lfun));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiExternal::editExternal()
|
|
|
|
{
|
2007-10-09 21:21:01 +00:00
|
|
|
applyView();
|
2007-10-07 08:55:20 +00:00
|
|
|
string const lfun = InsetExternalMailer::params2string(params_, buffer());
|
|
|
|
dispatch(FuncRequest(LFUN_EXTERNAL_EDIT, lfun));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> const GuiExternal::getTemplates() const
|
|
|
|
{
|
|
|
|
vector<string> result;
|
|
|
|
|
|
|
|
external::TemplateManager::Templates::const_iterator i1, i2;
|
|
|
|
i1 = external::TemplateManager::get().getTemplates().begin();
|
|
|
|
i2 = external::TemplateManager::get().getTemplates().end();
|
|
|
|
|
|
|
|
for (; i1 != i2; ++i1) {
|
|
|
|
result.push_back(i1->second.lyxName);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GuiExternal::getTemplateNumber(string const & name) const
|
|
|
|
{
|
|
|
|
external::TemplateManager::Templates::const_iterator i1, i2;
|
|
|
|
i1 = external::TemplateManager::get().getTemplates().begin();
|
|
|
|
i2 = external::TemplateManager::get().getTemplates().end();
|
|
|
|
for (int i = 0; i1 != i2; ++i1, ++i) {
|
|
|
|
if (i1->second.lyxName == name)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we can get here if a LyX document has a template not installed
|
|
|
|
// on this machine.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
external::Template GuiExternal::getTemplate(int i) const
|
|
|
|
{
|
|
|
|
external::TemplateManager::Templates::const_iterator i1
|
|
|
|
= external::TemplateManager::get().getTemplates().begin();
|
|
|
|
|
|
|
|
advance(i1, i);
|
|
|
|
|
|
|
|
return i1->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const
|
|
|
|
GuiExternal::getTemplateFilters(string const & template_name) const
|
|
|
|
{
|
|
|
|
/// Determine the template file extension
|
|
|
|
external::TemplateManager const & etm =
|
|
|
|
external::TemplateManager::get();
|
|
|
|
external::Template const * const et_ptr =
|
|
|
|
etm.getTemplateByName(template_name);
|
|
|
|
|
|
|
|
if (et_ptr)
|
|
|
|
return et_ptr->fileRegExp;
|
|
|
|
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
docstring const GuiExternal::browse(docstring const & input,
|
|
|
|
docstring const & template_name) const
|
|
|
|
{
|
|
|
|
docstring const title = _("Select external file");
|
|
|
|
|
2007-10-28 16:32:20 +00:00
|
|
|
docstring const bufpath = from_utf8(bufferFilepath());
|
2007-10-07 08:55:20 +00:00
|
|
|
FileFilterList const filter =
|
2007-10-28 16:32:20 +00:00
|
|
|
FileFilterList(from_utf8(getTemplateFilters(to_utf8(template_name))));
|
2007-10-07 08:55:20 +00:00
|
|
|
|
2007-10-28 16:32:20 +00:00
|
|
|
docstring const label1 = _("Documents|#o#O");
|
|
|
|
docstring const dir1 = from_utf8(lyxrc.document_path);
|
2007-10-07 08:55:20 +00:00
|
|
|
|
2007-10-28 16:32:20 +00:00
|
|
|
return browseRelFile(input, bufpath, title, filter, false, label1, dir1);
|
2007-10-07 08:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const GuiExternal::readBB(string const & file)
|
|
|
|
{
|
|
|
|
FileName const abs_file(makeAbsPath(file, 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) {
|
2007-11-23 22:15:17 +00:00
|
|
|
width = image->width();
|
|
|
|
height = image->height();
|
2007-10-07 08:55:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiExternal(GuiView & lv) { return new GuiExternal(lv); }
|
2007-10-07 08:55:20 +00:00
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiExternal_moc.cpp"
|