fix the switch layout bug, add some more boost.format, some additional cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5757 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2002-12-01 21:10:37 +00:00
parent 2523638092
commit 271b807e8b
12 changed files with 116 additions and 65 deletions

View File

@ -1,3 +1,12 @@
2002-12-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* text2.C (setCounter): clean up a bit, use boost.format.
(updateCounters): initialize par upon declaration.
* CutAndPaste.C (SwitchLayoutsBetweenClasses): set the layout also
if the layout exists. We do not just store the layout any more.
(SwitchLayoutsBetweenClasses): use boost.format
2002-11-18 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* converter.C (convert): if from and to files are the same, use a

View File

@ -29,6 +29,8 @@
#include "insets/inseterror.h"
#include <boost/format.hpp>
using std::pair;
using lyx::pos_type;
using lyx::textclass_type;
@ -422,17 +424,32 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
string const name = par->layout()->name();
bool hasLayout = tclass2.hasLayout(name);
if (!hasLayout)
if (hasLayout)
par->layout(tclass2[name]);
else
par->layout(tclass2.defaultLayout());
if (!hasLayout && name != tclass1.defaultLayoutName()) {
++ret;
#if USE_BOOST_FORMAT
boost::format fmt(_("Layout had to be changed from\n"
"%1$s to %2$s\n"
"because of class conversion from\n"
"%3$s to %4$s"));
fmt % name
% par->layout()->name()
% tclass1.name()
% tclass2.name();
string const s = fmt.str();
#else
string const s = _("Layout had to be changed from\n")
+ name + _(" to ")
+ par->layout()->name()
+ _("\nbecause of class conversion from\n")
+ tclass1.name() + _(" to ")
+ tclass2.name();
#endif
freezeUndo();
InsetError * new_inset = new InsetError(s);
LyXText * txt = current_view->getLyXText();

View File

@ -1,3 +1,7 @@
2002-12-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* ControlDocument.C (classApply): use boost.format
2002-11-29 Angus Leeming <leeming@lyx.org>
* ControlButtons.h (isClosing): make it public, so that the view can

View File

@ -35,6 +35,10 @@
#include "support/lstrings.h"
#include "support/filetools.h"
#include <boost/format.hpp>
using std::endl;
ControlDocument::ControlDocument(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d), bp_(0)
@ -113,6 +117,7 @@ void ControlDocument::classApply()
// successfully loaded
view().apply();
buffer()->params = *bp_;
lv_.message(_("Converting document to new document class..."));
int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
old_class, new_class,
@ -123,8 +128,14 @@ void ControlDocument::classApply()
if (ret == 1) {
s = _("One paragraph couldn't be converted");
} else {
#if USE_BOOST_FORMAT
boost::format fmt(_("%1$s paragraphs couldn't be converted"));
fmt % ret;
s = fmt.str();
#else
s += tostr(ret);
s += _(" paragraphs couldn't be converted");
#endif
}
Alert::alert(_("Conversion Errors!"),s,
_("into chosen document class"));

View File

@ -1,3 +1,8 @@
2002-12-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* checkedwidgets.C (setWidget): make sure that FL_LCOL and FL_COL1
will be seen as FL_COLORs.
2002-12-01 John Levon <levon@movementarian.org>
* FormMathsBitmap.C: fix _(_(blah))

View File

@ -46,7 +46,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;
FL_COLOR const lcol = valid ? FL_COLOR(FL_LCOL) : alert_col;
if (label->lcol != lcol && isActive(label)) {
fl_set_object_lcol(label, lcol);
}
@ -56,7 +56,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label)
// Reflect the validity of the data in the background color of the
// input widget only when this widget is not being edited.
FL_COLOR const icol1 = valid ? FL_COL1 : alert_col;
FL_COLOR const icol1 = valid ? FL_COLOR(FL_COL1) : alert_col;
if (input->col1 != icol1) {
fl_set_object_color(input, icol1, FL_MCOL);
}

View File

@ -1,3 +1,8 @@
2002-12-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* insetquotes.C (dispString): use string::insert for prepending a
char.
2002-11-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insetparent.C (getScreenLabel): use boost::format

View File

@ -178,7 +178,7 @@ string const InsetQuotes::dispString(Language const * loclang) const
if (side_ == LeftQ)
disp += ' ';
else
disp = ' ' + disp;
disp.insert(0, 1, ' ');
}
return disp;

View File

@ -45,6 +45,8 @@
#include "support/textutils.h"
#include "support/lstrings.h"
#include <boost/format.hpp>
using std::vector;
using std::copy;
using std::endl;
@ -1218,30 +1220,24 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
// is it a layout that has an automatic label?
if (layout->labeltype >= LABEL_COUNTER_CHAPTER) {
int const i = layout->labeltype - LABEL_COUNTER_CHAPTER;
int i = layout->labeltype - LABEL_COUNTER_CHAPTER;
string numbertype;
string langtype;
ostringstream s;
if (i >= 0 && i <= buf->params.secnumdepth) {
string numbertype;
string langtype;
textclass.counters().step(layout->latexname());
// Is there a label? Useful for Chapter layout
if (!par->params().appendix()) {
if (!layout->labelstring().empty())
par->params().labelString(layout->labelstring());
else
par->params().labelString(string());
s << layout->labelstring();
} else {
if (!layout->labelstring_appendix().empty())
par->params().labelString(layout->labelstring_appendix());
else
par->params().labelString(string());
s << layout->labelstring_appendix();
}
// Use if an integer is here less than elegant. For now.
// Use of an integer is here less than elegant. For now.
int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER;
if (!par->params().appendix()) {
numbertype = "sectioning";
@ -1257,8 +1253,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
.numberLabel(layout->latexname(),
numbertype, langtype, head);
par->params().labelString(par->params().labelString()
+ STRCONV(s.str()));
par->params().labelString(STRCONV(s.str()));
// reset enum counters
textclass.counters().reset("enum");
@ -1289,8 +1284,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
textclass.counters().step(enumcounter);
s << textclass.counters()
.numberLabel(enumcounter,
"enumeration", langtype);
.numberLabel(enumcounter, "enumeration");
par->params().labelString(STRCONV(s.str()));
}
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
@ -1331,15 +1325,22 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
textclass.counters().step(fl.type());
// Doesn't work... yet.
#warning use boost.format
#if USE_BOOST_FORMAT
s = boost::io::str(boost::format(_("%1$s #:")) % fl.name());
// s << boost::format(_("%1$s %1$d:")
// % fl.name()
// % buf->counters().value(fl.name());
#else
ostringstream o;
//o << fl.name() << ' ' << buf->counters().value(fl.name()) << ":";
o << fl.name() << " #:";
s = STRCONV(o.str());
#endif
} else {
// par->SetLayout(0);
// s = layout->labelstring;
s = (par->getParLanguage(buf->params)->lang() == "hebrew")
? " :úåòîùî øñç" : "Senseless: ";
s = _("Senseless: ");
}
}
par->params().labelString(s);
@ -1365,10 +1366,8 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
// Updates all counters. Paragraphs with changed label string will be rebroken
void LyXText::updateCounters(BufferView * bview) const
{
Paragraph * par;
Row * row = firstrow;
par = row->par();
Paragraph * par = row->par();
// CHECK if this is really needed. (Lgb)
bview->buffer()->params.getLyXTextClass().counters().reset();
@ -1379,6 +1378,7 @@ void LyXText::updateCounters(BufferView * bview) const
string const oldLabel = par->params().labelString();
// setCounter can potentially change the labelString.
setCounter(bview->buffer(), par);
string const & newLabel = par->params().labelString();