+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
\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
FormatEnd
TemplateEnd
+
Template ChessDiagram
GuiName "Chess: $$Basename"
HelpText
FormatEnd
TemplateEnd
+
Template Date
GuiName "Date"
HelpText
+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
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
+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
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;
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;
+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
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)
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);
+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
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),
/// 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;
+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.
ExternalTemplateManager::ExternalTemplateManager()
{
- // gimp gnuchess gnuplot ical netscape tetris xpaint
readTemplates(support::user_lyxdir());
if (lyxerr.debugging(Debug::EXTERNAL)) {
dumpPreambleDefs(lyxerr);
<< "\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";
}
-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;
}
#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?
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:
/// 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::Params::Params()
- : display(defaultDisplayType),
- lyxscale(defaultLyxScale)
+InsetExternal::TempName::TempName()
{
- tempname = support::tempName(string(), "lyxext");
- support::unlink(tempname);
+ tempname_ = support::tempName(string(), "lyxext");
+ support::unlink(tempname_);
// must have an extension for the converter code to work correctly.
- tempname += ".tmp";
+ tempname_ += ".tmp";
}
-InsetExternal::Params::~Params()
+InsetExternal::TempName::TempName(InsetExternal::TempName const &)
{
- support::unlink(tempname);
+ 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)
+{}
+
+
+void InsetExternal::Params::settemplate(string const & name)
+{
+ templatename_ = name;
}
}
-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);
}
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_) ||
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 "
switch (lex.lex()) {
case EX_TEMPLATE: {
lex.next();
- params.templatename = lex.getString();
+ params.settemplate(lex.getString());
break;
}
lyxerr[Debug::EXTERNAL]
<< "InsetExternal::Read: "
- << "template: '" << params_.templatename
+ << "template: '" << params_.templatename()
<< "' filename: '" << params_.filename.absFilename()
<< "' display: '" << params_.display
<< "' scale: '" << params_.lyxscale
lyxerr[Debug::EXTERNAL]
<< "External template format '" << format
<< "' not specified in template "
- << params_.templatename << endl;
+ << params_.templatename() << endl;
return 0;
}
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
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();
+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.
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>
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 {