From 00efea79702404ee13d1dd593aabeb72897cfb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sun, 24 Nov 2002 15:20:31 +0000 Subject: [PATCH] handle USE_BOOST_FORMAT git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5703 a592a061-630c-0410-9148-cb99ea01b6c8 --- config/ChangeLog | 5 ++ config/acconfig.h | 6 ++ config/configure.ac | 8 ++- src/BoostFormat.h | 8 ++- src/BufferView_pimpl.C | 20 +++++++ src/ChangeLog | 6 +- src/Chktex.C | 20 +++++-- src/LaTeX.C | 12 ++++ src/boost-inst.C | 3 + src/buffer.C | 36 +++++++++++- src/bufferlist.C | 5 +- src/bufferview_funcs.C | 12 +++- src/converter.C | 22 +++++++ src/debug.C | 12 +++- .../controllers/ControlSpellchecker.C | 18 ++++-- src/frontends/controllers/biblio.C | 13 ++++- src/frontends/xforms/ColorHandler.C | 57 ++++++++++++++++--- src/frontends/xforms/FeedbackController.C | 15 ++++- src/frontends/xforms/FormGraphics.C | 4 ++ src/frontends/xforms/checkedwidgets.C | 4 +- src/frontends/xforms/xformsImage.C | 2 +- src/frontends/xforms/xforms_resize.C | 14 ++--- src/frontends/xforms/xscreen.C | 4 +- src/importer.C | 12 +++- src/insets/insetcaption.C | 10 +++- src/insets/insetcollapsable.C | 2 +- src/insets/insetfloatlist.C | 8 +++ src/insets/insetgraphics.C | 11 ++++ src/insets/insetparent.C | 6 +- src/insets/insettabular.C | 2 +- src/lyx_main.C | 55 ++++++++++++++++-- src/lyxfont.C | 35 ++++++++++-- src/lyxfunc.C | 49 +++++++++++++++- src/mathed/formulamacro.C | 6 +- src/mathed/math_data.C | 4 +- src/mathed/math_parser.C | 9 ++- 36 files changed, 447 insertions(+), 68 deletions(-) diff --git a/config/ChangeLog b/config/ChangeLog index 1f06f37bd6..f11981c117 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,8 @@ +2002-11-24 Lars Gullik Bjønnes + + * configure.ac: USE_BOOST_FORMAT + * acconfig.h: ditto + 2002-11-06 Lars Gullik Bjønnes * configure.ac: use AH_TOP and AH_BOTTOM instead of diff --git a/config/acconfig.h b/config/acconfig.h index 229650fe3b..525c081014 100644 --- a/config/acconfig.h +++ b/config/acconfig.h @@ -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 */ diff --git a/config/configure.ac b/config/configure.ac index b76bb7f129..6ed5ec3233 100644 --- a/config/configure.ac +++ b/config/configure.ac @@ -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 ]) diff --git a/src/BoostFormat.h b/src/BoostFormat.h index 1f8defbc66..20715d808e 100644 --- a/src/BoostFormat.h +++ b/src/BoostFormat.h @@ -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 // Add explicit instantion @@ -14,4 +18,6 @@ namespace boost } // namespace boost -#endif +#endif // USE_BOOST_FORMAT + +#endif // LYX_BOOST_FORMAT_H diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 56a3360816..d9b6cbba8b 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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())); } } diff --git a/src/ChangeLog b/src/ChangeLog index e2d196c065..c15d3e45d3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,11 @@ +2002-11-24 Lars Gullik Bjønnes + + * lots of files: handle USE_BOOST_FORMAT + 2002-11-21 John Levon * pspell.C: fix compile - + 2002-11-21 Lars Gullik Bjønnes * lyxfunc.C (dispatch): use boost::format diff --git a/src/Chktex.C b/src/Chktex.C index f9752dac25..83ea11d9cb 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -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; diff --git a/src/LaTeX.C b/src/LaTeX.C index 7e1e9860af..c1740e1b5f 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -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()))); } diff --git a/src/boost-inst.C b/src/boost-inst.C index f090764962..61ab5ba643 100644 --- a/src/boost-inst.C +++ b/src/boost-inst.C @@ -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; } // namespace boost + +#endif // USE_BOOST_FORMAT diff --git a/src/buffer.C b/src/buffer.C index 4f5e71c5b9..0f54556775 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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 diff --git a/src/bufferlist.C b/src/bufferlist.C index 9adbf78831..8140a88150 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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. diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index b7b0d17a7d..258613a1fe 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -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. diff --git a/src/converter.C b/src/converter.C index 72517ce0d7..7b37f0a68d 100644 --- a/src/converter.C +++ b/src/converter.C @@ -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"); diff --git a/src/debug.C b/src/debug.C index ffd83cfa83..cd9e465649 100644 --- a/src/debug.C +++ b/src/debug.C @@ -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 + } + } } diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index c6ecafd5a7..947ee91264 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -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(); diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index 08daff759c..d5ebf67a96 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -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 } diff --git a/src/frontends/xforms/ColorHandler.C b/src/frontends/xforms/ColorHandler.C index c8fcc55ddd..7b51fcbb1e 100644 --- a/src/frontends/xforms/ColorHandler.C +++ b/src/frontends/xforms/ColorHandler.C @@ -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; } diff --git a/src/frontends/xforms/FeedbackController.C b/src/frontends/xforms/FeedbackController.C index 8dd43fe950..20602647d6 100644 --- a/src/frontends/xforms/FeedbackController.C +++ b/src/frontends/xforms/FeedbackController.C @@ -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; diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 0878f073a2..e30b3c3a17 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -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()); diff --git a/src/frontends/xforms/checkedwidgets.C b/src/frontends/xforms/checkedwidgets.C index d351372452..af8998f25f 100644 --- a/src/frontends/xforms/checkedwidgets.C +++ b/src/frontends/xforms/checkedwidgets.C @@ -45,7 +45,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label) { // define color to mark invalid input FL_COLOR const alert_col = FL_RED; - + FL_COLOR const lcol = valid ? FL_LCOL : alert_col; if (label->lcol != lcol && isActive(label)) { fl_set_object_lcol(label, lcol); @@ -61,7 +61,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label) fl_set_object_color(input, icol1, FL_MCOL); } } - + } // namespace anon diff --git a/src/frontends/xforms/xformsImage.C b/src/frontends/xforms/xformsImage.C index c9fb7d35ea..010abea3c1 100644 --- a/src/frontends/xforms/xformsImage.C +++ b/src/frontends/xforms/xformsImage.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ diff --git a/src/frontends/xforms/xforms_resize.C b/src/frontends/xforms/xforms_resize.C index 8b4e57c213..54c9faddc1 100644 --- a/src/frontends/xforms/xforms_resize.C +++ b/src/frontends/xforms/xforms_resize.C @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Angus Leeming + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -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) @@ -45,8 +45,8 @@ double get_scaling_factor(FL_FORM * form) ob->boxtype != FL_NO_BOX && (ob->boxtype != FL_FLAT_BOX || ob->objclass == FL_MENU)) { - fl_get_string_dimension(ob->lstyle, ob->lsize, ob->label, - strlen(ob->label), &sw, &sh); + fl_get_string_dimension(ob->lstyle, ob->lsize, ob->label, + strlen(ob->label), &sw, &sh); bw = (ob->boxtype == FL_UP_BOX || ob->boxtype == FL_DOWN_BOX) ? FL_abs(ob->bw) : 1; @@ -174,7 +174,7 @@ void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor) double get_scale_to_fit(FL_FORM * form) { lyx::Assert(form); - + double factor = get_scaling_factor(form); for (FL_OBJECT * ob = form->first; ob; ob = ob->next) { if (ob->objclass == FL_TABFOLDER) @@ -188,12 +188,12 @@ double get_scale_to_fit(FL_FORM * form) void scale_form_horizontally(FL_FORM * form, double factor) { lyx::Assert(form); - + if (factor <= 1.0) return; fl_scale_form(form, factor, 1); - + for (FL_OBJECT * ob = form->first; ob; ob = ob->next) { if (ob->objclass == FL_TABFOLDER) scale_tabfolder_horizontally(ob, factor); diff --git a/src/frontends/xforms/xscreen.C b/src/frontends/xforms/xscreen.C index 376077c0df..40d72f3953 100644 --- a/src/frontends/xforms/xscreen.C +++ b/src/frontends/xforms/xscreen.C @@ -4,7 +4,7 @@ * Licence details can be found in the file COPYING. * * \author unknown - * \author John Levon + * \author John Levon * * Full author contact details are available in file CREDITS */ @@ -259,4 +259,4 @@ void XScreen::draw(LyXText * text, BufferView * bv, unsigned int y) } XSync(fl_get_display(), 0); -} +} diff --git a/src/importer.C b/src/importer.C index 1a11197aa0..999f5173ff 100644 --- a/src/importer.C +++ b/src/importer.C @@ -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 const Importer::GetImportableFormats() vector const Importer::Loaders() { - vector v; + vector v(3); v.push_back("lyx"); v.push_back("text"); v.push_back("textparagraph"); diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 354d31540c..2b478145d0 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -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); diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 1e38be38b7..15faa9578a 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -247,7 +247,7 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp, #endif if (button == mouse_button::button3) return; - + UpdatableInset::edit(bv, xp, yp, button); if (collapsed_) { diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index 526d85c707..e3d1b9401b 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -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; } diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 01b82f4e99..79bb4f0a93 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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; } diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index 96244473a7..a34133dd77 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -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 } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index e79251d301..fbe8c938e1 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1931,7 +1931,7 @@ void InsetTabular::tabularFeatures(BufferView * bv, updateLocal(bv, INIT, true); } - if (vallen.zero() + if (vallen.zero() && tabular->GetAlignment(actcell, true) == LYX_ALIGN_BLOCK) tabularFeatures(bv, LyXTabular::ALIGN_CENTER, string()); else if (!vallen.zero() diff --git a/src/lyx_main.C b/src/lyx_main.C index f2ba793780..94561f85cb 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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; diff --git a/src/lyxfont.C b/src/lyxfont.C index e834421a89..5c3da3a316 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -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; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7f463b56c5..319f418e4a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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, diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index a4473a9847..fc02a5a8b0 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -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 } diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C index 41b7aa43de..0d4a65fa30 100644 --- a/src/mathed/math_data.C +++ b/src/mathed/math_data.C @@ -215,7 +215,7 @@ Dimension const & MathArray::metrics(MathMetricsInfo & mi) const drawn_ = false; mathed_char_dim(mi.base.font, 'I', dim_); - if (empty()) + if (empty()) return dim_; dim_.w = 0; @@ -400,7 +400,7 @@ void MathArray::notifyCursorLeaves() mathcursor->adjust(i, ar.size() - 1); } } - + // glue adjacent font insets of the same kind for (pos_type i = 0; i + 1 < size(); ++i) { MathFontInset * p = operator[](i).nucleus()->asFontInset(); diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 3afff07b3e..ad506e70ae 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -535,7 +535,7 @@ string Parser::parse_verbatim_option() if (t.cat() == catBegin) { putback(); res += '{' + parse_verbatim_item() + '}'; - } else + } else res += t.asString(); } } @@ -553,7 +553,7 @@ string Parser::parse_verbatim_item() putback(); res += '{' + parse_verbatim_item() + '}'; } - else + else res += t.asString(); } } @@ -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); } -