mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Re-add the RasterImage template.
Several small clean-ups of the InsetExternal code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7823 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a6d13f91ee
commit
9a3737148b
@ -1,3 +1,7 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* external_templates: re-add the RasterImage template.
|
||||
|
||||
2003-09-23 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* CREDITS: add Hartmut Haase
|
||||
|
@ -33,6 +33,53 @@ PreambleDef InputOrWarn
|
||||
\IfFileExists{#1}{\input{#1}}{\warnNotFound{#1}}}
|
||||
PreambleDefEnd
|
||||
|
||||
|
||||
Template RasterImage
|
||||
GuiName "Bitmap: $$Basename"
|
||||
HelpText
|
||||
A bitmap file.
|
||||
In the parameters box, you can provide optional
|
||||
parameters for the ImageMagick convert program.
|
||||
E.g., use `-border 10x10 -bordercolor black'
|
||||
to surround the picture with a black border
|
||||
when you export to LaTeX.
|
||||
When you export to Ascii, you can provide a
|
||||
number describing how many columns the picture
|
||||
should expand to.
|
||||
This template uses Gimp for editing.
|
||||
HelpTextEnd
|
||||
InputFormat "*"
|
||||
FileFilter "*.(gif|png|jpg|bmp|pbm|ppm|tga|tif|xpm|xbm)"
|
||||
EditCommand "gimp $$FName"
|
||||
AutomaticProduction true
|
||||
Format LaTeX
|
||||
Product "\\includegraphics{$$Basename}"
|
||||
UpdateFormat eps
|
||||
UpdateResult "$$Basename.eps"
|
||||
Requirement "graphicx"
|
||||
FormatEnd
|
||||
Format PDFLaTeX
|
||||
Product "\\includegraphics{$$Basename}"
|
||||
UpdateFormat png
|
||||
UpdateResult "$$Basename.png"
|
||||
Requirement "graphicx"
|
||||
FormatEnd
|
||||
Format Ascii
|
||||
Product "$$Contents(\"$$Basename.asc\")"
|
||||
UpdateFormat asciiimage
|
||||
UpdateResult "$$Basename.asc"
|
||||
FormatEnd
|
||||
Format DocBook
|
||||
Product "<graphic fileref=\"$$Basename.eps\"></graphic>"
|
||||
UpdateFormat eps
|
||||
UpdateResult "$$Basename.eps"
|
||||
FormatEnd
|
||||
Format LinuxDoc
|
||||
Product "[Bitmap: $$FName]"
|
||||
FormatEnd
|
||||
TemplateEnd
|
||||
|
||||
|
||||
Template XFig
|
||||
GuiName "XFig: $$Basename"
|
||||
HelpText
|
||||
@ -74,6 +121,7 @@ Template XFig
|
||||
FormatEnd
|
||||
TemplateEnd
|
||||
|
||||
|
||||
Template ChessDiagram
|
||||
GuiName "Chess: $$Basename"
|
||||
HelpText
|
||||
@ -116,6 +164,7 @@ Template ChessDiagram
|
||||
FormatEnd
|
||||
TemplateEnd
|
||||
|
||||
|
||||
Template Date
|
||||
GuiName "Date"
|
||||
HelpText
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlExternal.C (getTemplatePtr): simplify, due to change in
|
||||
ExternalTemplateManager interface.
|
||||
|
||||
2003-09-21 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* ControlDocument.C (setParams): fix new bug
|
||||
|
@ -121,11 +121,8 @@ namespace {
|
||||
|
||||
ExternalTemplate const * getTemplatePtr(InsetExternal::Params const & params)
|
||||
{
|
||||
ExternalTemplateManager & etm = ExternalTemplateManager::get();
|
||||
ExternalTemplate const & templ = etm.getTemplateByName(params.templatename);
|
||||
if (templ.lyxName.empty())
|
||||
return 0;
|
||||
return &templ;
|
||||
ExternalTemplateManager const & etm = ExternalTemplateManager::get();
|
||||
return etm.getTemplateByName(params.templatename());
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* QExternal.C (update_contents, apply): InsetExternal::Params::
|
||||
templatename now has accessor functions.
|
||||
|
||||
2003-09-22 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* QLPopupMenu.C (getLabel): fix so that bindings are added even if
|
||||
|
@ -68,7 +68,8 @@ void QExternal::update_contents()
|
||||
params.filename.outputFilename(kernel().bufferFilepath());
|
||||
dialog_->fileED->setText(toqstr(name));
|
||||
|
||||
dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templatename));
|
||||
dialog_->externalCO->setCurrentItem(controller()
|
||||
.getTemplateNumber(params.templatename()));
|
||||
dialog_->externalTV->setText(toqstr(helpText()));
|
||||
|
||||
int item = 0;
|
||||
@ -106,8 +107,8 @@ void QExternal::apply()
|
||||
params.filename.set(fromqstr(dialog_->fileED->text()),
|
||||
kernel().bufferFilepath());
|
||||
|
||||
params.templatename =
|
||||
controller().getTemplate(dialog_->externalCO->currentItem()).lyxName;
|
||||
params.settemplate(
|
||||
controller().getTemplate(dialog_->externalCO->currentItem()).lyxName);
|
||||
|
||||
switch (dialog_->showCB->currentItem()) {
|
||||
case 0: params.display = lyx::graphics::DefaultDisplay; break;
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* FormExternal.C (update, apply): InsetExternal::Params::
|
||||
templatename now has accessor functions.
|
||||
|
||||
2003-09-24 Martin Vermeer <martin.vermeer@hut.fi>
|
||||
|
||||
* FormNote.C: generalize loop end/vector size
|
||||
|
@ -47,7 +47,7 @@ void FormExternal::apply()
|
||||
params.filename.set(getString(dialog_->input_filename), buffer_path);
|
||||
|
||||
int const choice = fl_get_choice(dialog_->choice_template) - 1;
|
||||
params.templatename = controller().getTemplate(choice).lyxName;
|
||||
params.settemplate(controller().getTemplate(choice).lyxName);
|
||||
|
||||
params.lyxscale = strToInt(getString(dialog_->input_lyxscale));
|
||||
if (params.lyxscale == 0)
|
||||
@ -127,7 +127,7 @@ void FormExternal::update()
|
||||
string const name = params.filename.outputFilename(buffer_path);
|
||||
fl_set_input(dialog_->input_filename, name.c_str());
|
||||
|
||||
int ID = controller().getTemplateNumber(params.templatename);
|
||||
int ID = controller().getTemplateNumber(params.templatename());
|
||||
if (ID < 0) ID = 0;
|
||||
fl_set_choice(dialog_->choice_template, ID+1);
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* GraphicsParams.[Ch] (asString): new member function.
|
||||
|
||||
2003-09-21 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* Previews.C (Previews): fix new bug
|
||||
|
@ -22,6 +22,14 @@ using std::abs;
|
||||
namespace lyx {
|
||||
namespace graphics {
|
||||
|
||||
string const BoundingBox::asString() const
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << xl << ' ' << yb << ' ' << xr << ' ' << yt;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
Params::Params()
|
||||
: display(ColorDisplay),
|
||||
scale(100),
|
||||
|
@ -33,6 +33,9 @@ struct BoundingBox {
|
||||
/// 0 0 0 0 is empty!
|
||||
bool empty() const;
|
||||
|
||||
/// The bounding box as "xl yb xr yr"
|
||||
string const asString() const;
|
||||
|
||||
unsigned int xl;
|
||||
unsigned int yb;
|
||||
unsigned int xr;
|
||||
|
@ -1,7 +1,19 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetexternal.[Ch] (TempName): new (private) nested struct with
|
||||
fake copy semantics. Enables us to use the generated copy c-tor
|
||||
in the Params struct.
|
||||
(Params::templatename, Params::tempname): use accessor functions.
|
||||
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ExternalTemplate.[Ch] (getTemplateByName): now it's a const member
|
||||
function, returning a const pointer.
|
||||
|
||||
2003-09-23 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ExternalTemplate.[Ch]: can have multiple preamble snippets if we store them
|
||||
in a vector, preambleNames.
|
||||
* ExternalTemplate.[Ch]: can have multiple preamble snippets if we
|
||||
store them in a vector, preambleNames.
|
||||
|
||||
* insetexternal.C (validate): loop over all preambleNames and call
|
||||
LaTeXFeatures::addExternalPreamble with each.
|
||||
|
@ -46,7 +46,6 @@ ExternalTemplate::FormatTemplate::FormatTemplate()
|
||||
|
||||
ExternalTemplateManager::ExternalTemplateManager()
|
||||
{
|
||||
// gimp gnuchess gnuplot ical netscape tetris xpaint
|
||||
readTemplates(support::user_lyxdir());
|
||||
if (lyxerr.debugging(Debug::EXTERNAL)) {
|
||||
dumpPreambleDefs(lyxerr);
|
||||
@ -114,12 +113,10 @@ public:
|
||||
<< "\t\tUpdateResult " << ft.updateResult << '\n'
|
||||
<< "\t\tRequirement " << ft.requirement << '\n';
|
||||
|
||||
if (!ft.preambleNames.empty()) {
|
||||
vector<string>::const_iterator it = ft.preambleNames.begin();
|
||||
vector<string>::const_iterator end = ft.preambleNames.end();
|
||||
for (; it != end; ++it) {
|
||||
ost << "\t\tPreamble " << *it << '\n';
|
||||
}
|
||||
vector<string>::const_iterator it = ft.preambleNames.begin();
|
||||
vector<string>::const_iterator end = ft.preambleNames.end();
|
||||
for (; it != end; ++it) {
|
||||
ost << "\t\tPreamble " << *it << '\n';
|
||||
}
|
||||
|
||||
ost << "\tFormatEnd\n";
|
||||
@ -168,9 +165,11 @@ ExternalTemplateManager::getTemplates() const
|
||||
}
|
||||
|
||||
|
||||
ExternalTemplate const & ExternalTemplateManager::getTemplateByName(string const & name)
|
||||
ExternalTemplate const *
|
||||
ExternalTemplateManager::getTemplateByName(string const & name) const
|
||||
{
|
||||
return templates[name];
|
||||
Templates::const_iterator it = templates.find(name);
|
||||
return (it == templates.end()) ? 0 : &it->second;
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,15 +12,15 @@
|
||||
#ifndef EXTERNALTEMPLATE_H
|
||||
#define EXTERNALTEMPLATE_H
|
||||
|
||||
|
||||
#include <iosfwd>
|
||||
#include <map>
|
||||
#include "support/std_string.h"
|
||||
#include <boost/utility.hpp>
|
||||
#include <iosfwd>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class LyXLex;
|
||||
|
||||
|
||||
///
|
||||
struct ExternalTemplate {
|
||||
/// What is the name of this template in the LyX format?
|
||||
@ -85,7 +85,13 @@ public:
|
||||
static ExternalTemplateManager & get();
|
||||
Templates & getTemplates();
|
||||
Templates const & getTemplates() const;
|
||||
/// return the template by LyX name
|
||||
/** return the template by LyX name.
|
||||
* If it isn't found, return 0.
|
||||
*/
|
||||
ExternalTemplate const * getTemplateByName(string const & name) const;
|
||||
/** return the preamble definition by LyX name.
|
||||
* If it isn't found, return an empty string.
|
||||
*/
|
||||
ExternalTemplate const & getTemplateByName(string const & name);
|
||||
string const getPreambleDefByName(string const & name) const;
|
||||
private:
|
||||
|
@ -71,23 +71,62 @@ string const doSubstitution(InsetExternal::Params const & params,
|
||||
/// Invoke the external editor.
|
||||
void editExternal(InsetExternal::Params const & params, Buffer const & buffer);
|
||||
|
||||
|
||||
ExternalTemplate const * getTemplatePtr(string const & name)
|
||||
{
|
||||
ExternalTemplateManager const & etm = ExternalTemplateManager::get();
|
||||
return etm.getTemplateByName(name);
|
||||
}
|
||||
|
||||
|
||||
ExternalTemplate const * getTemplatePtr(InsetExternal::Params const & params)
|
||||
{
|
||||
ExternalTemplateManager const & etm = ExternalTemplateManager::get();
|
||||
return etm.getTemplateByName(params.templatename());
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
InsetExternal::TempName::TempName()
|
||||
{
|
||||
tempname_ = support::tempName(string(), "lyxext");
|
||||
support::unlink(tempname_);
|
||||
// must have an extension for the converter code to work correctly.
|
||||
tempname_ += ".tmp";
|
||||
}
|
||||
|
||||
|
||||
InsetExternal::TempName::TempName(InsetExternal::TempName const &)
|
||||
{
|
||||
tempname_ = TempName()();
|
||||
}
|
||||
|
||||
|
||||
InsetExternal::TempName::~TempName()
|
||||
{
|
||||
support::unlink(tempname_);
|
||||
}
|
||||
|
||||
|
||||
InsetExternal::TempName &
|
||||
InsetExternal::TempName::operator=(InsetExternal::TempName const & other)
|
||||
{
|
||||
if (this != &other)
|
||||
tempname_ = TempName()();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
InsetExternal::Params::Params()
|
||||
: display(defaultDisplayType),
|
||||
lyxscale(defaultLyxScale)
|
||||
{
|
||||
tempname = support::tempName(string(), "lyxext");
|
||||
support::unlink(tempname);
|
||||
// must have an extension for the converter code to work correctly.
|
||||
tempname += ".tmp";
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
InsetExternal::Params::~Params()
|
||||
void InsetExternal::Params::settemplate(string const & name)
|
||||
{
|
||||
support::unlink(tempname);
|
||||
templatename_ = name;
|
||||
}
|
||||
|
||||
|
||||
@ -203,23 +242,13 @@ lyx::graphics::Params get_grfx_params(InsetExternal::Params const & eparams)
|
||||
}
|
||||
|
||||
|
||||
ExternalTemplate const * getTemplatePtr(InsetExternal::Params const & params)
|
||||
{
|
||||
ExternalTemplateManager & etm = ExternalTemplateManager::get();
|
||||
ExternalTemplate const & templ = etm.getTemplateByName(params.templatename);
|
||||
if (templ.lyxName.empty())
|
||||
return 0;
|
||||
return &templ;
|
||||
}
|
||||
|
||||
|
||||
string const getScreenLabel(InsetExternal::Params const & params,
|
||||
Buffer const & buffer)
|
||||
{
|
||||
ExternalTemplate const * const ptr = getTemplatePtr(params);
|
||||
if (!ptr)
|
||||
return support::bformat(_("External template %1$s is not installed"),
|
||||
params.templatename);
|
||||
params.templatename());
|
||||
return doSubstitution(params, buffer, ptr->guiName);
|
||||
}
|
||||
|
||||
@ -235,10 +264,7 @@ InsetExternal::Params const & InsetExternal::params() const
|
||||
void InsetExternal::setParams(Params const & p, Buffer const & buffer)
|
||||
{
|
||||
// The stored params; what we would like to happen in an ideal world.
|
||||
params_.filename = p.filename;
|
||||
params_.templatename = p.templatename;
|
||||
params_.display = p.display;
|
||||
params_.lyxscale = p.lyxscale;
|
||||
params_ = p;
|
||||
|
||||
// We display the inset as a button by default.
|
||||
bool display_button = (!getTemplatePtr(params_) ||
|
||||
@ -273,7 +299,7 @@ void InsetExternal::setParams(Params const & p, Buffer const & buffer)
|
||||
void InsetExternal::write(Buffer const & buffer, ostream & os) const
|
||||
{
|
||||
os << "External\n"
|
||||
<< "\ttemplate " << params_.templatename << '\n';
|
||||
<< "\ttemplate " << params_.templatename() << '\n';
|
||||
|
||||
if (!params_.filename.empty())
|
||||
os << "\tfilename "
|
||||
@ -317,7 +343,7 @@ void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
|
||||
switch (lex.lex()) {
|
||||
case EX_TEMPLATE: {
|
||||
lex.next();
|
||||
params.templatename = lex.getString();
|
||||
params.settemplate(lex.getString());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -366,7 +392,7 @@ void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
|
||||
|
||||
lyxerr[Debug::EXTERNAL]
|
||||
<< "InsetExternal::Read: "
|
||||
<< "template: '" << params_.templatename
|
||||
<< "template: '" << params_.templatename()
|
||||
<< "' filename: '" << params_.filename.absFilename()
|
||||
<< "' display: '" << params_.display
|
||||
<< "' scale: '" << params_.lyxscale
|
||||
@ -389,7 +415,7 @@ int InsetExternal::write(string const & format,
|
||||
lyxerr[Debug::EXTERNAL]
|
||||
<< "External template format '" << format
|
||||
<< "' not specified in template "
|
||||
<< params_.templatename << endl;
|
||||
<< params_.templatename() << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -568,7 +594,7 @@ string const doSubstitution(InsetExternal::Params const & params,
|
||||
result = support::subst(s, "$$FName", filename);
|
||||
result = support::subst(result, "$$Basename", basename);
|
||||
result = support::subst(result, "$$FPath", filepath);
|
||||
result = support::subst(result, "$$Tempname", params.tempname);
|
||||
result = support::subst(result, "$$Tempname", params.tempname());
|
||||
result = support::subst(result, "$$Sysdir", support::system_lyxdir());
|
||||
|
||||
// Handle the $$Contents(filename) syntax
|
||||
|
@ -24,22 +24,46 @@
|
||||
class RenderInset;
|
||||
|
||||
///
|
||||
class InsetExternal : public InsetOld, public boost::signals::trackable {
|
||||
class InsetExternal : public InsetOld, public boost::signals::trackable
|
||||
{
|
||||
/** No two Params variables can have the same temporary file.
|
||||
* This struct has copy-semantics but the copy constructor
|
||||
* and assignment operator simply call the default constructor.
|
||||
* Use of this struct enables us to use the compiler-generated
|
||||
* copy constructor and assignment operator for the Params struct.
|
||||
*/
|
||||
struct TempName {
|
||||
TempName();
|
||||
TempName(TempName const &);
|
||||
~TempName();
|
||||
TempName & operator=(TempName const &);
|
||||
string const & operator()() const { return tempname_; }
|
||||
private:
|
||||
string tempname_;
|
||||
};
|
||||
|
||||
public:
|
||||
/// hold parameters settable from the GUI
|
||||
struct Params {
|
||||
Params();
|
||||
~Params();
|
||||
|
||||
/// The name of the tempfile used for manipulations.
|
||||
string const & tempname() const { return tempname_(); }
|
||||
|
||||
/// the current template used
|
||||
void settemplate(string const &);
|
||||
string const & templatename() const { return templatename_; }
|
||||
|
||||
/// the filename
|
||||
lyx::support::FileName filename;
|
||||
/// the current template used
|
||||
string templatename;
|
||||
/// The name of the tempfile used for manipulations.
|
||||
string tempname;
|
||||
/// how the inset is displayed by LyX
|
||||
lyx::graphics::DisplayType display;
|
||||
/// The scale of the displayed graphic (If shown).
|
||||
unsigned int lyxscale;
|
||||
|
||||
private:
|
||||
TempName tempname_;
|
||||
string templatename_;
|
||||
};
|
||||
|
||||
InsetExternal();
|
||||
|
@ -1,12 +1,17 @@
|
||||
2003-09-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* translator.h (add): new member function.
|
||||
|
||||
2003-09-16 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* textutils.h: remove #include "paragraph.h". Remove functions IsInsetChar
|
||||
and IsWordChar.
|
||||
* textutils.h: remove #include "paragraph.h". Remove functions
|
||||
IsInsetChar and IsWordChar.
|
||||
|
||||
2003-09-15 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* copied_ptr.h: re-jig to something that resembles Herb Sutter's HolderPtr ---
|
||||
see http://www.gotw.ca/gotw/062.htm. Also known in his book as ValuePtr.
|
||||
* copied_ptr.h: re-jig to something that resembles Herb Sutter's
|
||||
HolderPtr --- see http://www.gotw.ca/gotw/062.htm. Also known in
|
||||
his book as ValuePtr.
|
||||
Use a memory_traits template parameter to create/destroy memory in a
|
||||
flexible manner.
|
||||
|
||||
@ -27,8 +32,8 @@
|
||||
|
||||
2003-09-15 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* translator.h: add #include <boost/assert.hpp>, so that the template is
|
||||
self-contained.
|
||||
* translator.h: add #include <boost/assert.hpp>, so that the
|
||||
template is self-contained.
|
||||
|
||||
2003-09-11 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
|
@ -48,6 +48,12 @@ public:
|
||||
void addPair(T1 const & first, T2 const & second) {
|
||||
map.push_back(MapPair(first, second));
|
||||
}
|
||||
// Add the contents of \c other
|
||||
void add(Translator const & other) {
|
||||
if (other.map.empty())
|
||||
return;
|
||||
map.insert(map.end(), other.map.begin(), other.map.end());
|
||||
}
|
||||
|
||||
/// Find the mapping for the first argument
|
||||
T2 const & find(T1 const & first) const {
|
||||
|
Loading…
Reference in New Issue
Block a user