handle USE_BOOST_FORMAT

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5703 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2002-11-24 15:20:31 +00:00
parent 06bf792012
commit 00efea7970
36 changed files with 447 additions and 68 deletions

View File

@ -1,3 +1,8 @@
2002-11-24 Lars Gullik Bjřnnes <larsbj@gullik.net>
* configure.ac: USE_BOOST_FORMAT
* acconfig.h: ditto
2002-11-06 Lars Gullik Bjønnes <larsbj@gullik.net>
* configure.ac: use AH_TOP and AH_BOTTOM instead of

View File

@ -93,4 +93,10 @@ int mkstemp(char*);
* #endif
*/
#if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
#define USE_BOOST_FORMAT 1
#else
#define USE_BOOST_FORMAT 0
#endif
#endif /* _CONFIG_H */

View File

@ -293,7 +293,7 @@ AC_SUBST(VERSION_INFO)
AH_TOP([
/* -*- C++ -*- */
/* This is the compilation configuration file for LyX. It was generated by
autoconf's configure. You might want to change some of the defaults if
autoconfs configure. You might want to change some of the defaults if
something goes wrong during the compilation
* This file is part of
@ -350,6 +350,12 @@ int mkstemp(char*);
#include "support/nt_defines.h"
#endif
#if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
#define USE_BOOST_FORMAT 1
#else
#define USE_BOOST_FORMAT 0
#endif
#endif
])

View File

@ -2,6 +2,10 @@
#ifndef LYX_BOOST_FORMAT_H
#define LYX_BOOST_FORMAT_H
// Only include this if it is possible to use
// Boost.Format at all.
#if USE_BOOST_FORMAT
#include <boost/format.hpp>
// Add explicit instantion
@ -14,4 +18,6 @@ namespace boost
} // namespace boost
#endif
#endif // USE_BOOST_FORMAT
#endif // LYX_BOOST_FORMAT_H

View File

@ -640,7 +640,11 @@ void BufferView::Pimpl::savePosition(unsigned int i)
bv_->text->cursor.pos());
if (i > 0) {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("Saved bookmark %1$d")) % i;
#else
str << _("Saved bookmark ") << i;
#endif
owner_->message(STRCONV(str.str()));
}
}
@ -672,7 +676,11 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
update(bv_->text, BufferView::SELECT | BufferView::FITCUR);
if (i > 0) {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("Moved to bookmark %1$d")) % i;
#else
str << _("Moved to bookmark ") << i;
#endif
owner_->message(STRCONV(str.str()));
}
}
@ -880,16 +888,28 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
string const disp_fn(MakeDisplayPath(filename));
ostringstream s1;
#if USE_BOOST_FORMAT
s1 << boost::format(_("Inserting document %1$s ...")) % disp_fn;
#else
s1 << _("Inserting document ") << disp_fn << _(" ...");
#endif
owner_->message(STRCONV(s1.str()));
bool const res = bv_->insertLyXFile(filename);
if (res) {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("Document %1$s inserted.")) % disp_fn;
#else
str << _("Document ") << disp_fn << _(" inserted.");
#endif
owner_->message(STRCONV(str.str()));
} else {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("Could not insert document %1$s")) % disp_fn;
#else
str << _("Could not insert document ") << disp_fn;
#endif
owner_->message(STRCONV(str.str()));
}
}

View File

@ -1,3 +1,7 @@
2002-11-24 Lars Gullik Bjønnes <larsbj@gullik.net>
* lots of files: handle USE_BOOST_FORMAT
2002-11-21 John Levon <levon@movementarian.org>
* pspell.C: fix compile

View File

@ -67,8 +67,13 @@ int Chktex::scanLogFile(TeXErrors & terr)
string token;
int retval = 0;
string tmp = OnlyFilename(ChangeExtension(file, ".log"));
string const tmp = OnlyFilename(ChangeExtension(file, ".log"));
#if USE_BOOST_FORMAT
boost::format msg(_("ChkTeX warning id # %1$d"));
#else
string const msg(_("ChkTeX warning id # "));
#endif
ifstream ifs(tmp.c_str());
while (getline(ifs, token)) {
string srcfile;
@ -82,9 +87,16 @@ int Chktex::scanLogFile(TeXErrors & terr)
token = split(token, warno, ':');
token = split(token, warning, ':');
int lineno = lyx::atoi(line);
warno = boost::io::str(boost::format(_("ChkTeX warning id # %1$d")) % warno);
terr.insertError(lineno, warno, warning);
int const lineno = lyx::atoi(line);
#if USE_BOOST_FORMAT
msg % warno;
terr.insertError(lineno, msg.str(), warning);
msg.clear();
#else
terr.insertError(lineno, msg + warno, warning);
#endif
++retval;
}
return retval;

View File

@ -203,7 +203,11 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
lyxerr[Debug::LATEX] << "Run #" << count << endl;
if (lfun) {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("LaTeX run number %1$d")) % count;
#else
str << _("LaTeX run number ") << count;
#endif
lfun->dispatch(FuncRequest(LFUN_MESSAGE, STRCONV(str.str())));
}
@ -288,7 +292,11 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
<< "Run #" << count << endl;
if (lfun) {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("LaTeX run number %1$d")) % count;
#else
str << _("LaTeX run number ") << count;
#endif
// check lyxstring string stream and gcc 3.1 before fixing
lfun->dispatch(FuncRequest(LFUN_MESSAGE, STRCONV(str.str())));
}
@ -345,7 +353,11 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
lyxerr[Debug::LATEX] << "Run #" << count << endl;
if (lfun) {
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("LaTeX run number %1$d")) % count;
#else
str << _("LaTeX run number ") << count;
#endif
lfun->dispatch(FuncRequest(LFUN_MESSAGE, STRCONV(str.str())));
}

View File

@ -2,6 +2,7 @@
#include "BoostFormat.h"
#if USE_BOOST_FORMAT
namespace boost
{
@ -11,3 +12,5 @@ using boost::io::out_of_range_bit;
template class basic_format<char>;
} // namespace boost
#endif // USE_BOOST_FORMAT

View File

@ -360,8 +360,13 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
s += tostr(unknown_layouts);
s += _(" paragraphs");
}
#if USE_BOOST_FORMAT
Alert::alert(_("Textclass Loading Error!"), s,
boost::io::str(boost::format(_("When reading %1$s")) % fileName()));
#else
Alert::alert(_("Textclass Loading Error!"), s,
_("When reading ") + fileName());
#endif
}
if (unknown_tokens > 0) {
@ -372,8 +377,13 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
s += tostr(unknown_tokens);
s += _(" unknown tokens");
}
#if USE_BOOST_FORMAT
Alert::alert(_("Textclass Loading Error!"), s,
boost::io::str(boost::format(_("When reading %1$s")) % fileName()));
#else
Alert::alert(_("Textclass Loading Error!"), s,
_("When reading ") + fileName());
#endif
}
return the_end_read;
@ -608,9 +618,17 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
if (pp.first) {
params.textclass = pp.second;
} else {
#if USE_BOOST_FORMAT
Alert::alert(_("Textclass error"),
boost::io::str(boost::format(_("The document uses an unknown textclass \"%1$s\".")) % lex.getString()),
_("LyX will not be able to produce output correctly."));
#else
Alert::alert(
_("Textclass error"),
_("The document uses an unknown textclass ")
+ lex.getString(),
_("LyX will not be able to produce output correctly."));
#endif
params.textclass = 0;
}
if (!params.getLyXTextClass().load()) {
@ -619,10 +637,17 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
// or stop loading the file.
// I can substitute but I don't see how I can
// stop loading... ideas?? ARRae980418
#if USE_BOOST_FORMAT
Alert::alert(_("Textclass Loading Error!"),
boost::io::str(boost::format(_("Can't load textclass %1$s")) %
params.getLyXTextClass().name()),
_("-- substituting default"));
#else
Alert::alert(_("Textclass Loading Error!"),
_("Can't load textclass ")
+ params.getLyXTextClass().name(),
_("-- substituting default"));
#endif
params.textclass = 0;
}
} else if (token == "\\options") {
@ -926,8 +951,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
// This should be insurance for the future: (Asger)
++unknown_tokens;
lex.eatLine();
string const s = boost::io::str(boost::format(_("Unknown token: %1$s %2$s\n")) % token
% lex.text());
#if USE_BOOST_FORMAT
boost::format fmt(_("Unknown token: %1$s %2$s\n"));
fmt % token % lex.text();
string const s = fmt.str();
#else
string const s = _("Unknown token: ") + token
+ " " + lex.text() + "\n";
#endif
// we can do this here this way because we're actually reading
// the buffer and don't care about LyXText right now.
InsetError * new_inset = new InsetError(s);
@ -939,6 +970,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
return the_end_read;
}
// needed to insert the selection
void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
LyXFont const & fn,string const & str) const

View File

@ -310,10 +310,13 @@ void BufferList::emergencyWrite(Buffer * buf)
string const doc = buf->isUnnamed()
? OnlyFilename(buf->fileName()) : buf->fileName();
#if USE_BOOST_FORMAT
lyxerr << boost::format(_("LyX: Attempting to save document %1$s"))
% doc
<< endl;
#else
lyxerr << _("LyX: Attempting to save document ") << doc << endl;
#endif
// We try to save three places:
// 1) Same place as document. Unless it is an unnamed doc.

View File

@ -159,12 +159,22 @@ string const currentState(BufferView * bv)
buffer->params.getLyXTextClass().defaultfont();
font.reduce(defaultfont);
#if USE_BOOST_FORMAT
state << boost::format(_("Font: %1$s")) % font.stateText(&buffer->params);
#else
state << _("Font: ") << font.stateText(&buffer->params);
#endif
// The paragraph depth
int depth = text->getDepth();
if (depth > 0)
if (depth > 0) {
#if USE_BOOST_FORMAT
state << boost::format(_(", Depth: %1$d")) % depth;
#else
state << _(", Depth: ") << depth;
#endif
}
// The paragraph spacing, but only if different from
// buffer spacing.

View File

@ -177,9 +177,15 @@ bool Formats::view(Buffer const * buffer, string const & filename,
format->isChildFormat())
format = getFormat(format->parentFormat());
if (!format || format->viewer().empty()) {
#if USE_BOOST_FORMAT
Alert::alert(_("Cannot view file"),
boost::io::str(boost::format(_("No information for viewing %1$s"))
% prettyName(format_name)));
#else
Alert::alert(_("Cannot view file"),
_("No information for viewing ")
+ prettyName(format_name));
#endif
return false;
}
@ -706,8 +712,13 @@ bool Converters::convert(Buffer const * buffer,
string to = subst(conv.result_dir,
token_base, to_base);
if (!lyx::rename(from, to)) {
#if USE_BOOST_FORMAT
Alert::alert(_("Error while trying to move directory:"),
from, boost::io::str(boost::format(_("to %1$s")) % to));
#else
Alert::alert(_("Error while trying to move directory:"),
from, _("to ") + to);
#endif
return false;
}
}
@ -716,6 +727,7 @@ bool Converters::convert(Buffer const * buffer,
return move(outfile, to_file, conv.latex);
}
// If from = /path/file.ext and to = /path2/file2.ext2 then this method
// moves each /path/file*.ext file to /path2/file2*.ext2'
bool Converters::move(string const & from, string const & to, bool copy)
@ -742,8 +754,13 @@ bool Converters::move(string const & from, string const & to, bool copy)
? lyx::copy(from2, to2)
: lyx::rename(from2, to2);
if (!moved && no_errors) {
#if USE_BOOST_FORMAT
Alert::alert(_("Error while trying to move file:"),
from2, boost::io::str(boost::format(_("to %1$s")) % to2));
#else
Alert::alert(_("Error while trying to move file:"),
from2, _("to ") + to2);
#endif
no_errors = false;
}
}
@ -829,8 +846,13 @@ bool Converters::scanLog(Buffer const * buffer, string const & command,
}
string head;
split(command, head, ' ');
#if USE_BOOST_FORMAT
Alert::alert(boost::io::str(boost::format(_("There were errors during running of %1$s")) % head),
s, t);
#else
Alert::alert(_("There were errors during running of ") + head,
s, t);
#endif
return false;
} else if (result & LaTeX::NO_OUTPUT) {
string const s = _("The operation resulted in");

View File

@ -105,15 +105,23 @@ Debug::type Debug::value(string const & val)
void Debug::showLevel(ostream & o, Debug::type level)
{
// Show what features are traced
for (int i = 0 ; i < numErrorTags ; ++i)
for (int i = 0 ; i < numErrorTags ; ++i) {
if (errorTags[i].level != Debug::ANY
&& errorTags[i].level != Debug::NONE
&& errorTags[i].level & level)
&& errorTags[i].level & level) {
#if USE_BOOST_FORMAT
o << boost::format(
_("Debugging `%1$s' (%2$s)"))
% errorTags[i].name
% _(errorTags[i].desc)
<< endl;
#else
o << _("Debugging `") << errorTags[i].name << "' ("
<< _(errorTags[i].desc) << ")"
<< endl;
#endif
}
}
}

View File

@ -193,13 +193,23 @@ void ControlSpellchecker::clearParams()
if (speller_->alive()) {
speller_->close();
boost::format fmter("");
message_ = _("Spellchecking completed!") + '\n';
#if USE_BOOST_FORMAT
if (count_ != 1) {
fmter = boost::format(_("Spellchecking completed!\n%1$d words checked."));
boost::format fmter("%1$d words checked.");
fmter % count_;
message_ += fmter.str();
} else {
fmter = boost::format(_("Spellchecking completed!\n%1$d word checked."));
message_+= _("One word checked.");
}
message_ = boost::io::str(fmter % count_);
#else
if (count_ != 1) {
message_ += tostr(count_) + " words checked";
} else {
message_ = _("One word checked.");
}
#endif
} else {
message_ = speller_->error();
speller_->cleanUp();

View File

@ -95,6 +95,7 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
if (authors.empty())
return author;
#if USE_BOOST_FORMAT
boost::format fmter("");
if (authors.size() == 2)
fmter = boost::format(_("%1$s and %2$s"))
@ -103,7 +104,17 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
fmter = boost::format(_("%1$s et al.")) % familyName(authors[0]);
else
fmter = boost::format("%1$s") % familyName(authors[0]);
return boost::io::str(fmter);
return fmter.str();
#else
string msg;
if (authors.size() == 2)
msg = familyName(authors[0]) + _(" and ") + familyName(authors[1]);
else if (authors.size() > 2)
msg = familyName(authors[0]) + _("et al.");
else
msg = familyName(authors[0]);
return msg;
#endif
}

View File

@ -86,23 +86,50 @@ GC LyXColorHandler::getGCForeground(LColor::color c)
// Look up the RGB values for the color, and an approximate
// color that we can hope to get on this display.
if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) {
lyxerr << boost::format(_("LyX: Unknown X11 color %1$s for %2$s\n"
" Using black instead, sorry!"))
% s % lcolor.getGUIName(c) << endl;
#if USE_BOOST_FORMAT
lyxerr << boost::format(
_("LyX: Unknown X11 color %1$s for %2$s\n"
" Using black instead, sorry!"))
% s
% lcolor.getGUIName(c)
<< endl;
#else
lyxerr << _("LyX: Unknown X11 color ") << s << _(" for ")
<< lcolor.getGUIName(c)
<< _("\n Using black instead, sorry!") << endl;
#endif
unsigned long bla = BlackPixel(display,
DefaultScreen(display));
val.foreground = bla;
// Try the exact RGB values first, then the approximate.
} else if (XAllocColor(display, colormap, &xcol) != 0) {
if (lyxerr.debugging(Debug::GUI)) {
lyxerr << boost::format(_("LyX: X11 color %1$s allocated for %2$s"))
% s % lcolor.getGUIName(c)
#if USE_BOOST_FORMAT
lyxerr << boost::format(
_("LyX: X11 color %1$s allocated for %2$s"))
% s
% lcolor.getGUIName(c)
<< endl;
#else
lyxerr << _("LyX: X11 color ") << s
<< _(" allocated for ") << lcolor.getGUIName(c)
<< endl;
#endif
}
val.foreground = xcol.pixel;
} else if (XAllocColor(display, colormap, &ccol)) {
lyxerr << boost::format(_("LyX: Using approximated X11 color %1$s allocated for %2$s"))
% s % lcolor.getGUIName(c) << endl;
#if USE_BOOST_FORMAT
lyxerr << boost::format(
_("LyX: Using approximated X11 color %1$s"
" allocated for %2$s"))
% s
% lcolor.getGUIName(c)
<< endl;
#else
lyxerr << _("LyX: Using approximated X11 color ") << s
<< _(" allocated for ") << lcolor.getGUIName(c)
<< endl;
#endif
val.foreground = xcol.pixel;
} else {
// Here we are traversing the current colormap to find
@ -142,6 +169,7 @@ GC LyXColorHandler::getGCForeground(LColor::color c)
}
}
#if USE_BOOST_FORMAT
lyxerr << boost::format(
_("LyX: Couldn't allocate '%1$s' for %2$s"
" with (r,g,b)=(%3$d,%4$d,%5$d).\n"
@ -156,7 +184,20 @@ GC LyXColorHandler::getGCForeground(LColor::color c)
% cmap[closest_pixel].blue
% closest_pixel
<< endl;
#else
lyxerr << _("LyX: Couldn't allocate '") << s
<< _("' for ") << lcolor.getGUIName(c)
<< _(" with (r,g,b)=(")
<< xcol.red << "," << xcol.green << "," << xcol.blue
<< _(").\n")
<< _(" Using closest allocated color with (r,g,b)=(")
<< cmap[closest_pixel].red << ","
<< cmap[closest_pixel].green << ","
<< cmap[closest_pixel].blue
<< _(") instead.\nPixel [")
<< closest_pixel << _("] is used.")
<< endl;
#endif
val.foreground = cmap[closest_pixel].pixel;
}

View File

@ -165,13 +165,22 @@ void FeedbackController::postMessage(string const & message)
{
lyx::Assert(message_widget_);
int const width = message_widget_->w - 10;
#if USE_BOOST_FORMAT
boost::format fmter = warning_posted_ ?
boost::format(_("WARNING! %1$s")) :
boost::format("%1$s");
fmter % message;
int const width = message_widget_->w - 10;
string const str = formatted(boost::io::str(fmter % message),
width, FL_NORMAL_SIZE);
string const str = formatted(fmter.str(), width, FL_NORMAL_SIZE);
#else
string const tmp = warning_posted_ ?
_("WARNING!") + string(" ") + message :
message;
string const str = formatted(tmp, width, FL_NORMAL_SIZE);
#endif
fl_set_object_label(message_widget_, str.c_str());
FL_COLOR const label_color = warning_posted_ ? FL_RED : FL_LCOL;

View File

@ -123,7 +123,11 @@ void FormGraphics::build()
_("Default|Monochrome|Grayscale|Color|Do not display");
fl_addto_choice(file_->choice_display, display_List.c_str());
#if USE_BOOST_FORMAT
string const width_list = boost::io::str(boost::format(_("Scale%%|%1$s")) % choice_Length_All);
#else
string const width_list = _("Scale%%|") + choice_Length_All;
#endif
fl_addto_choice(file_->choice_width, width_list.c_str());
fl_addto_choice(file_->choice_height, choice_Length_All.c_str());

View File

@ -34,7 +34,7 @@ double get_scaling_factor(FL_FORM * form)
int bw;
// if (fl_no_connection)
// return 1.0f;
// return 1.0f;
max_factor = factor = 1.0f;
for (ob = form->first; ob; ob = ob->next)
@ -46,7 +46,7 @@ double get_scaling_factor(FL_FORM * form)
(ob->boxtype != FL_FLAT_BOX || ob->objclass == FL_MENU))
{
fl_get_string_dimension(ob->lstyle, ob->lsize, ob->label,
strlen(ob->label), &sw, &sh);
strlen(ob->label), &sw, &sh);
bw = (ob->boxtype == FL_UP_BOX || ob->boxtype == FL_DOWN_BOX) ?
FL_abs(ob->bw) : 1;

View File

@ -41,7 +41,11 @@ bool Importer::Import(LyXView * lv, string const & filename,
{
string const displaypath = MakeDisplayPath(filename);
ostringstream s1;
#if USE_BOOST_FORMAT
s1 << boost::format(_("Importing %1$s...")) % displaypath;
#else
s1 << _("Importing ") << displaypath << _("...");
#endif
lv->message(STRCONV(s1.str()));
string const lyxfile = ChangeExtension(filename, ".lyx");
@ -60,9 +64,15 @@ bool Importer::Import(LyXView * lv, string const & filename,
}
}
if (loader_format.empty()) {
#if USE_BOOST_FORMAT
Alert::alert(_("Cannot import file"),
boost::io::str(boost::format(_("No information for importing from %1$s"))
% formats.prettyName(format)));
#else
Alert::alert(_("Cannot import file"),
_("No information for importing from ")
+ formats.prettyName(format));
#endif
return false;
}
} else
@ -106,7 +116,7 @@ vector<Format const *> const Importer::GetImportableFormats()
vector<string> const Importer::Loaders()
{
vector<string> v;
vector<string> v(3);
v.push_back("lyx");
v.push_back("text");
v.push_back("textparagraph");

View File

@ -90,9 +90,15 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
// ...
string const num("#");
#if USE_BOOST_FORMAT
// Generate the label
string const label = boost::io::str(boost::format("%1$s %2$s:") % _(fl) % num);
boost::format frm("%1$s %2$s:");
frm % _(fl) % num;
string const label = frm.str();
#else
// Generate the label
string const label = _(fl) + " " + num + ":";
#endif
Painter & pain = bv->painter();
int const w = font_metrics::width(label, f);
pain.text(int(x), baseline, label, f);

View File

@ -125,11 +125,19 @@ int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
<< cit->second.listName() << "}\n";
}
} else {
#if USE_BOOST_FORMAT
os << "%%\\listof{"
<< getCmdName()
<< "}{"
<< boost::format(_("List of %1$s")) % cit->second.name()
<< "}\n";
#else
os << "%%\\listof{"
<< getCmdName()
<< "}{"
<< _("List of ") << cit->second.name()
<< "}\n";
#endif
}
return 1;
}

View File

@ -666,9 +666,14 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const
Systemcall one;
one.startscript(Systemcall::Wait, command);
if (!IsFileReadable(ChangeExtension(outfile_base, to)))
#if USE_BOOST_FORMAT
Alert::alert(_("Cannot convert Image (not existing file?)"),
boost::io::str(boost::format(_("No information for converting from %1$s to %2$s"))
% from % to));
#else
Alert::alert(_("Cannot convert Image (not existing file?)"),
_("No information for converting from ") + from + " to " + to);
#endif
}
return RemoveExtension(temp_file);
@ -757,9 +762,15 @@ int InsetGraphics::ascii(Buffer const *, ostream & os, int) const
// 1. Convert file to ascii using gifscii
// 2. Read ascii output file and add it to the output stream.
// at least we send the filename
#if USE_BOOST_FORMAT
os << '<'
<< boost::format(_("Graphic file: %1$s")) % params().filename
<< ">\n";
#else
os << '<'
<< _("Graphic file: ") << params().filename
<< ">\n";
#endif
return 0;
}

View File

@ -42,7 +42,11 @@ InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool)
string const InsetParent::getScreenLabel(Buffer const *) const
{
return boost::io::str(boost::format(_("Parent: %1$s")) % getContents());
#if USE_BOOST_FORMAT
return boost::io::str(boost::format(_("Parent: %s")) % getContents());
#else
return _("Parent: ") + getContents();
#endif
}

View File

@ -101,7 +101,15 @@ LyX::LyX(int & argc, char * argv[])
// other than documents
for (int argi = 1; argi < argc ; ++argi) {
if (argv[argi][0] == '-') {
lyxerr << boost::format(_("Wrong command line option `%1$s'. Exiting.")) % argv[argi] << endl;
#if USE_BOOST_FORMAT
lyxerr << boost::format(_("Wrong command line option `%1$s'. Exiting."))
% argv[argi]
<< endl;
#else
lyxerr << _("Wrong command line option `")
<< argv[argi] << _("'. Exiting.")
<< endl;
#endif
exit(1);
}
}
@ -353,8 +361,16 @@ void LyX::init(bool gui)
<< "Giving up." << endl;
exit(1);
}
lyxerr << boost::format(_("Using built-in default %1$s but expect problems.")) % LYX_DIR
#if USE_BOOST_FORMAT
lyxerr << boost::format(_("Using built-in default %1$s"
" but expect problems."))
% LYX_DIR
<< endl;
#else
lyxerr << _("Using built-in default ") << LYX_DIR
<< _(" but expect problems.")
<< endl;
#endif
} else {
lyxerr << _("Expect problems.") << endl;
}
@ -602,13 +618,29 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
return;
}
lyxerr << boost::format(_("LyX: Creating directory %1$s and running configure...")) % user_lyxdir << endl;
#if USE_BOOST_FORMAT
lyxerr << boost::format(_("LyX: Creating directory %1$s"
" and running configure..."))
% user_lyxdir
<< endl;
#else
lyxerr << _("LyX: Creating directory ") << user_lyxdir
<< _(" and running configure...")
<< endl;
#endif
if (!createDirectory(user_lyxdir, 0755)) {
// Failed, let's use $HOME instead.
user_lyxdir = GetEnvPath("HOME");
lyxerr << boost::format(_("Failed. Will use %1$s instead.")) % user_lyxdir
#if USE_BOOST_FORMAT
lyxerr << boost::format(_("Failed. Will use %1$s instead."))
% user_lyxdir
<< endl;
#else
lyxerr << _("Failed. Will use ") << user_lyxdir <<
_(" instead.")
<< endl;
#endif
return;
}
@ -628,9 +660,15 @@ bool LyX::readRcFile(string const & name)
lyxerr[Debug::INIT] << "Found " << name
<< " in " << lyxrc_path << endl;
if (lyxrc.read(lyxrc_path) < 0) {
#if USE_BOOST_FORMAT
Alert::alert(_("LyX Warning!"),
boost::io::str(boost::format(_("Error while reading %1$s.")) % lyxrc_path),
_("Using built-in defaults."));
#else
Alert::alert(_("LyX Warning!"),
_("Error while reading ") + lyxrc_path,
_("Using built-in defaults."));
#endif
return false;
}
return true;
@ -742,7 +780,14 @@ int parse_dbg(string const & arg, string const &)
Debug::showTags(lyxerr);
exit(0);
}
lyxerr << boost::format(_("Setting debug level to %1$s")) % arg << endl;
#if USE_BOOST_FORMAT
lyxerr << boost::format(_("Setting debug level to %1$s"))
% arg
<< endl;
#else
lyxerr << _("Setting debug level to ") << arg << endl;
#endif
lyxerr.level(Debug::value(arg));
Debug::showLevel(lyxerr, lyxerr.level());
return 1;

View File

@ -526,23 +526,48 @@ string const LyXFont::stateText(BufferParams * params) const
ost << _(GUISizeNames[size()]) << ", ";
if (color() != LColor::inherit)
ost << lcolor.getGUIName(color()) << ", ";
if (emph() != INHERIT)
if (emph() != INHERIT) {
#if USE_BOOST_FORMAT
ost << boost::format(_("Emphasis %1$s, "))
% _(GUIMiscNames[emph()]);
if (underbar() != INHERIT)
#else
ost << _("Emphasis ") << _(GUIMiscNames[emph()]) << ", ";
#endif
}
if (underbar() != INHERIT) {
#if USE_BOOST_FORMAT
ost << boost::format(_("Underline %1$s, "))
% _(GUIMiscNames[underbar()]);
if (noun() != INHERIT)
#else
ost << _("Underline ") << _(GUIMiscNames[underbar()]) << ", ";
#endif
}
if (noun() != INHERIT) {
#if USE_BOOST_FORMAT
ost << boost::format(_("Noun %1$s, "))
% _(GUIMiscNames[noun()]);
#else
ost << _("Noun ") << _(GUIMiscNames[noun()]) << ", ";
#endif
}
if (bits == inherit)
ost << _("Default") << ", ";
if (!params || (language() != params->language))
if (!params || (language() != params->language)) {
#if USE_BOOST_FORMAT
ost << boost::format(_("Language: %1$s, "))
% _(language()->display());
if (number() != OFF)
#else
ost << _("Language: ") << _(language()->display()) << ", ";
#endif
}
if (number() != OFF) {
#if USE_BOOST_FORMAT
ost << boost::format(_(" Number %1$s"))
% _(GUIMiscNames[number()]);
#else
ost << _(" Number ") << _(GUIMiscNames[number()]);
#endif
}
string const buf = rtrim(STRCONV(ost.str()), ", ");
return buf;

View File

@ -948,8 +948,14 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
case LFUN_MENUWRITE:
if (!owner->buffer()->isUnnamed()) {
ostringstream s1;
#if USE_BOOST_FORMAT
s1 << boost::format(_("Saving document %1$s..."))
% MakeDisplayPath(owner->buffer()->fileName());
#else
s1 << _("Saving document ")
<< MakeDisplayPath(owner->buffer()->fileName())
<< _("...");
#endif
owner->message(STRCONV(s1.str()));
MenuWrite(view(), owner->buffer());
s1 << _(" done.");
@ -1106,8 +1112,13 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
break;
}
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("Opening help file %1$s..."))
% MakeDisplayPath(fname);
#else
str << _("Opening help file ")
<< MakeDisplayPath(fname) << _("...");
#endif
owner->message(STRCONV(str.str()));
view()->buffer(bufferlist.loadLyXFile(fname, false));
owner->allowInput();
@ -1437,7 +1448,19 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
x11_name != lcolor.getX11Name(LColor::graphicsbg));
if (!lcolor.setColor(lyx_name, x11_name)) {
setErrorMessage(boost::io::str(boost::format(_("Set-color \"%1$s\" failed - color is undefined or may not be redefined")) % lyx_name));
#if USE_BOOST_FORMAT
setErrorMessage(
boost::io::str(
boost::format(
_("Set-color \"%1$s\" failed "
"- color is undefined or "
"may not be redefined"))
% lyx_name));
#else
setErrorMessage(_("Set-color ") + lyx_name
+ _(" failed - color is undefined"
" or may not be redefined"));
#endif
break;
}
@ -1672,7 +1695,11 @@ void LyXFunc::open(string const & fname)
}
ostringstream str;
#if USE_BOOST_FORMAT
str << boost::format(_("Opening document %1$s...")) % disp_fn;
#else
str << _("Opening document ") << disp_fn << _("...");
#endif
owner->message(STRCONV(str.str()));
@ -1680,9 +1707,18 @@ void LyXFunc::open(string const & fname)
ostringstream str2;
if (openbuf) {
view()->buffer(openbuf);
#if USE_BOOST_FORMAT
str2 << boost::format(_("Document %1$s opened.")) % disp_fn;
#else
str2 << _("Document ") << disp_fn << _(" opened.");
#endif
} else {
str2 << boost::format(_("Could not open document %1$s")) % disp_fn;
#if USE_BOOST_FORMAT
str2 << boost::format(_("Could not open document %1$s"))
% disp_fn;
#else
str2 << _("Could not open document ") << disp_fn;
#endif
}
owner->message(STRCONV(str2.str()));
}
@ -1707,7 +1743,14 @@ void LyXFunc::doImport(string const & argument)
initpath = trypath;
}
string const text = boost::io::str(boost::format(_("Select %1$s file to import")) % formats.prettyName(format));
#if USE_BOOST_FORMAT
boost::format fmt(_("Select %1$s file to import"));
fmt % formats.prettyName(format);
string const text = fmt.str();
#else
string const text = _("Select ") + formats.prettyName(format)
+ _(" file to import");;
#endif
FileDialog fileDlg(owner, text,
LFUN_IMPORT,

View File

@ -128,7 +128,11 @@ void InsetFormulaMacro::read(std::istream & is)
string InsetFormulaMacro::prefix() const
{
return boost::io::str(boost::format(_(" Macro: %1$s: ")) % getInsetName());
#if USE_BOOST_FORMAT
return boost::io::str(boost::format(_(" Macro: %s: ")) % getInsetName());
#else
return _(" Macro: ") + getInsetName() + ": ";
#endif
}

View File

@ -1071,7 +1071,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
#warning A hack...
#endif
string s;
while (1) {
while (true) {
Token const & t = getToken();
if (!good()) {
putback();
@ -1168,7 +1168,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
else if (l->inset == "parbox") {
// read optional positioning and width
string pos = parse_verbatim_option();
string width = parse_verbatim_item();
string width = parse_verbatim_item();
cell->push_back(createMathInset(t.cs()));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, MathInset::TEXT_MODE);
cell->back().nucleus()->asParboxInset()->setPosition(pos);
@ -1252,4 +1252,3 @@ void mathed_parse_normal(MathGridInset & grid, string const & str)
istringstream is(str.c_str());
Parser(is).parse1(grid, 0, MathInset::MATH_MODE, false);
}