fix some buggy constructs with stringstream

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2127 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-06-14 17:58:49 +00:00
parent 3eaf3246be
commit 15a0218c0f
9 changed files with 147 additions and 84 deletions

View File

@ -10,8 +10,8 @@ src/CutAndPaste.C
src/debug.C src/debug.C
src/exporter.C src/exporter.C
src/ext_l10n.h src/ext_l10n.h
src/figureForm.C
src/figure_form.C src/figure_form.C
src/figureForm.C
src/FontLoader.C src/FontLoader.C
src/frontends/controllers/ButtonController.h src/frontends/controllers/ButtonController.h
src/frontends/controllers/character.C src/frontends/controllers/character.C
@ -89,67 +89,67 @@ src/frontends/qt2/paragraphdlgimpl.C
src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C
src/frontends/xforms/combox.C src/frontends/xforms/combox.C
src/frontends/xforms/FileDialog.C src/frontends/xforms/FileDialog.C
src/frontends/xforms/FormBibitem.C
src/frontends/xforms/form_bibitem.C src/frontends/xforms/form_bibitem.C
src/frontends/xforms/FormBibtex.C src/frontends/xforms/FormBibitem.C
src/frontends/xforms/form_bibtex.C src/frontends/xforms/form_bibtex.C
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/form_browser.C src/frontends/xforms/form_browser.C
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/form_character.C src/frontends/xforms/form_character.C
src/frontends/xforms/FormCitation.C src/frontends/xforms/FormCharacter.C
src/frontends/xforms/form_citation.C src/frontends/xforms/form_citation.C
src/frontends/xforms/FormCopyright.C src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_copyright.C src/frontends/xforms/form_copyright.C
src/frontends/xforms/FormCredits.C src/frontends/xforms/FormCopyright.C
src/frontends/xforms/form_credits.C src/frontends/xforms/form_credits.C
src/frontends/xforms/FormDocument.C src/frontends/xforms/FormCredits.C
src/frontends/xforms/form_document.C src/frontends/xforms/form_document.C
src/frontends/xforms/FormError.C src/frontends/xforms/FormDocument.C
src/frontends/xforms/form_error.C src/frontends/xforms/form_error.C
src/frontends/xforms/FormExternal.C src/frontends/xforms/FormError.C
src/frontends/xforms/form_external.C src/frontends/xforms/form_external.C
src/frontends/xforms/FormFiledialog.C src/frontends/xforms/FormExternal.C
src/frontends/xforms/form_filedialog.C src/frontends/xforms/form_filedialog.C
src/frontends/xforms/FormGraphics.C src/frontends/xforms/FormFiledialog.C
src/frontends/xforms/form_graphics.C src/frontends/xforms/form_graphics.C
src/frontends/xforms/FormInclude.C src/frontends/xforms/FormGraphics.C
src/frontends/xforms/form_include.C src/frontends/xforms/form_include.C
src/frontends/xforms/FormIndex.C src/frontends/xforms/FormInclude.C
src/frontends/xforms/form_index.C src/frontends/xforms/form_index.C
src/frontends/xforms/FormIndex.C
src/frontends/xforms/FormLog.C src/frontends/xforms/FormLog.C
src/frontends/xforms/FormMathsBitmap.C src/frontends/xforms/FormMathsBitmap.C
src/frontends/xforms/FormMathsDeco.C
src/frontends/xforms/form_maths_deco.C src/frontends/xforms/form_maths_deco.C
src/frontends/xforms/FormMathsDelim.C src/frontends/xforms/FormMathsDeco.C
src/frontends/xforms/form_maths_delim.C src/frontends/xforms/form_maths_delim.C
src/frontends/xforms/FormMathsMatrix.C src/frontends/xforms/FormMathsDelim.C
src/frontends/xforms/form_maths_matrix.C src/frontends/xforms/form_maths_matrix.C
src/frontends/xforms/FormMathsPanel.C src/frontends/xforms/FormMathsMatrix.C
src/frontends/xforms/form_maths_panel.C src/frontends/xforms/form_maths_panel.C
src/frontends/xforms/FormMathsSpace.C src/frontends/xforms/FormMathsPanel.C
src/frontends/xforms/form_maths_space.C src/frontends/xforms/form_maths_space.C
src/frontends/xforms/FormMinipage.C src/frontends/xforms/FormMathsSpace.C
src/frontends/xforms/form_minipage.C src/frontends/xforms/form_minipage.C
src/frontends/xforms/FormParagraph.C src/frontends/xforms/FormMinipage.C
src/frontends/xforms/form_paragraph.C src/frontends/xforms/form_paragraph.C
src/frontends/xforms/FormPreamble.C src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_preamble.C src/frontends/xforms/form_preamble.C
src/frontends/xforms/FormPreferences.C src/frontends/xforms/FormPreamble.C
src/frontends/xforms/form_preferences.C src/frontends/xforms/form_preferences.C
src/frontends/xforms/FormPrint.C src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_print.C src/frontends/xforms/form_print.C
src/frontends/xforms/FormRef.C src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_ref.C src/frontends/xforms/form_ref.C
src/frontends/xforms/FormSearch.C src/frontends/xforms/FormRef.C
src/frontends/xforms/form_search.C src/frontends/xforms/form_search.C
src/frontends/xforms/FormTabular.C src/frontends/xforms/FormSearch.C
src/frontends/xforms/form_tabular.C src/frontends/xforms/form_tabular.C
src/frontends/xforms/FormTabularCreate.C src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular_create.C src/frontends/xforms/form_tabular_create.C
src/frontends/xforms/FormToc.C src/frontends/xforms/FormTabularCreate.C
src/frontends/xforms/form_toc.C src/frontends/xforms/form_toc.C
src/frontends/xforms/FormUrl.C src/frontends/xforms/FormToc.C
src/frontends/xforms/form_url.C src/frontends/xforms/form_url.C
src/frontends/xforms/FormUrl.C
src/frontends/xforms/FormVCLog.C src/frontends/xforms/FormVCLog.C
src/frontends/xforms/input_validators.C src/frontends/xforms/input_validators.C
src/frontends/xforms/Menubar_pimpl.C src/frontends/xforms/Menubar_pimpl.C

View File

@ -1122,8 +1122,9 @@ void BufferView::Pimpl::savePosition(unsigned int i)
bv_->text->cursor.par()->id(), bv_->text->cursor.par()->id(),
bv_->text->cursor.pos()); bv_->text->cursor.pos());
if (i > 0) { if (i > 0) {
string const str = _("Saved bookmark") + ' ' + tostr(i); ostringstream str;
owner_->message(str); str << _("Saved bookmark") << ' ' << i;
owner_->message(str.str().c_str());
} }
} }
@ -1153,8 +1154,9 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
update(bv_->text, BufferView::SELECT|BufferView::FITCUR); update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
if (i > 0) { if (i > 0) {
string const str = _("Moved to bookmark") + ' ' + tostr(i); ostringstream str;
owner_->message(str); str << _("Moved to bookmark") << ' ' << i;
owner_->message(str.str().c_str());
} }
} }
@ -1390,19 +1392,24 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
if (!IsLyXFilename(filename)) if (!IsLyXFilename(filename))
filename += ".lyx"; filename += ".lyx";
string const disp_fn(MakeDisplayPath(filename));
// Inserts document // Inserts document
string const s1 = _("Inserting document") + ' ' ostringstream s1;
+ MakeDisplayPath(filename) + " ..."; s1 << _("Inserting document") << ' '
owner_->message(s1); << disp_fn << " ...";
owner_->message(s1.str().c_str());
bool const res = bv_->insertLyXFile(filename); bool const res = bv_->insertLyXFile(filename);
if (res) { if (res) {
string const str = _("Document") + ' ' ostringstream str;
+ MakeDisplayPath(filename) + ' ' + _("inserted."); str << _("Document") << ' ' << disp_fn
owner_->message(str); << ' ' << _("inserted.");
owner_->message(str.str().c_str());
} else { } else {
string const str = _("Could not insert document") + ' ' ostringstream str;
+ MakeDisplayPath(filename); str << _("Could not insert document") << ' '
owner_->message(str); << disp_fn;
owner_->message(str.str().c_str());
} }
} }

View File

@ -1,3 +1,19 @@
2001-06-14 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxfunc.C (Dispatch): use stringstream
(MenuNew): use stringstream
(Open): use stringstream
* importer.C (Import): use stringstream
* bufferview_funcs.C (CurrentState): use stringstream
* LaTeX.C (run): use stringstream
* BufferView_pimpl.C (savePosition): use stringstream
(restorePosition): use stringstream
(MenuInsertLyXFile): use stringstream
2001-06-14 Angus Leeming <a.leeming@ic.ac.uk> 2001-06-14 Angus Leeming <a.leeming@ic.ac.uk>
* BufferView.C: * BufferView.C:

View File

@ -68,7 +68,11 @@ int Chktex::scanLogFile(TeXErrors & terr)
ifstream ifs(tmp.c_str()); ifstream ifs(tmp.c_str());
while (getline(ifs, token)) { while (getline(ifs, token)) {
string srcfile, line, pos, warno, warning; string srcfile;
string line;
string pos;
string warno;
string warning;
token = split(token, srcfile, ':'); token = split(token, srcfile, ':');
token = split(token, line, ':'); token = split(token, line, ':');
token = split(token, pos, ':'); token = split(token, pos, ':');

View File

@ -174,7 +174,12 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
++count; ++count;
lyxerr[Debug::LATEX] << "Run #" << count << endl; lyxerr[Debug::LATEX] << "Run #" << count << endl;
if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run number") + ' ' + tostr(count)); if (lfun) {
ostringstream str;
str << _("LaTeX run number") << ' ' << count;
lfun->Dispatch(LFUN_MESSAGE, str.str().c_str());
}
//WriteStatus(lfun, string(_("LaTeX run number ")) + tostr(count)); //WriteStatus(lfun, string(_("LaTeX run number ")) + tostr(count));
this->operator()(); this->operator()();
@ -251,7 +256,12 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
<< "Dep. file has changed or rerun requested" << endl; << "Dep. file has changed or rerun requested" << endl;
lyxerr[Debug::LATEX] lyxerr[Debug::LATEX]
<< "Run #" << count << endl; << "Run #" << count << endl;
if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run number") + ' ' + tostr(count)); if (lfun) {
ostringstream str;
str << _("LaTeX run number") << ' ' << count;
lfun->Dispatch(LFUN_MESSAGE, str.str().c_str());
}
// WriteStatus(minib, // WriteStatus(minib,
// string(_("LaTeX run number ")) + tostr(count)); // string(_("LaTeX run number ")) + tostr(count));
this->operator()(); this->operator()();
@ -302,7 +312,12 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
rerun = false; rerun = false;
++count; ++count;
lyxerr[Debug::LATEX] << "Run #" << count << endl; lyxerr[Debug::LATEX] << "Run #" << count << endl;
if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run numger") + ' ' + tostr(count)); if (lfun) {
ostringstream str;
str << _("LaTeX run number") << ' ' << count;
lfun->Dispatch(LFUN_MESSAGE, str.str().c_str());
}
// WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count)); // WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));
this->operator()(); this->operator()();
scanres = scanLogFile(terr); scanres = scanLogFile(terr);

View File

@ -191,7 +191,8 @@ void FontSize(BufferView * bv, string const & size)
// Returns the current font and depth as a message. // Returns the current font and depth as a message.
string const CurrentState(BufferView * bv) string const CurrentState(BufferView * bv)
{ {
string state; ostringstream state;
if (bv->available()) { if (bv->available()) {
// I think we should only show changes from the default // I think we should only show changes from the default
// font. (Asger) // font. (Asger)
@ -203,31 +204,37 @@ string const CurrentState(BufferView * bv)
.TextClass(buffer->params.textclass) .TextClass(buffer->params.textclass)
.defaultfont(); .defaultfont();
font.reduce(defaultfont); font.reduce(defaultfont);
state = _("Font: ") + font.stateText(&buffer->params);
state << _("Font:") << ' '
<< font.stateText(&buffer->params);
// The paragraph depth // The paragraph depth
int depth = text->GetDepth(); int depth = text->GetDepth();
if (depth > 0) if (depth > 0)
state += string(_(", Depth: ")) + tostr(depth); state << _(", Depth: ") << depth;
// The paragraph spacing, but only if different from // The paragraph spacing, but only if different from
// buffer spacing. // buffer spacing.
if (!text->cursor.par()->params.spacing().isDefault()) { if (!text->cursor.par()->params.spacing().isDefault()) {
Spacing::Space cur_space = Spacing::Space cur_space =
text->cursor.par()->params.spacing().getSpace(); text->cursor.par()->params.spacing().getSpace();
state += _(", Spacing: "); state << _(", Spacing: ");
switch (cur_space) { switch (cur_space) {
case Spacing::Single: case Spacing::Single:
state += _("Single"); state << _("Single");
break; break;
case Spacing::Onehalf: case Spacing::Onehalf:
state += _("Onehalf"); state << _("Onehalf");
break; break;
case Spacing::Double: case Spacing::Double:
state += _("Double"); state << _("Double");
break; break;
case Spacing::Other: case Spacing::Other:
state += _("Other ("); state << _("Other (")
state += tostr(text->cursor.par()->params.spacing().getValue()); << text->cursor.par()->params.spacing().getValue()
state += ")"; << ")";
break; break;
case Spacing::Default: case Spacing::Default:
// should never happen, do nothing // should never happen, do nothing
@ -235,7 +242,7 @@ string const CurrentState(BufferView * bv)
} }
} }
} }
return state; return state.str().c_str();
} }

View File

@ -37,8 +37,9 @@ bool Importer::Import(LyXView * lv, string const & filename,
string const & format) string const & format)
{ {
string const displaypath = MakeDisplayPath(filename); string const displaypath = MakeDisplayPath(filename);
string const s1 = _("Importing") + ' ' + displaypath + "..."; ostringstream s1;
lv->message(s1); s1 << _("Importing") << ' ' << displaypath << "...";
lv->message(s1.str().c_str());
string const lyxfile = ChangeExtension(filename, ".lyx"); string const lyxfile = ChangeExtension(filename, ".lyx");

View File

@ -587,7 +587,7 @@ bool LyX::ReadRcFile(string const & name)
<< " in " << lyxrc_path << endl; << " in " << lyxrc_path << endl;
if (lyxrc.read(lyxrc_path) < 0) { if (lyxrc.read(lyxrc_path) < 0) {
WriteAlert(_("LyX Warning!"), WriteAlert(_("LyX Warning!"),
_("Error while reading ")+lyxrc_path+".", _("Error while reading ") + lyxrc_path + ".",
_("Using built-in defaults.")); _("Using built-in defaults."));
return false; return false;
} }

View File

@ -869,11 +869,10 @@ string const LyXFunc::Dispatch(int ac,
case LFUN_MENUWRITE: case LFUN_MENUWRITE:
if (!owner->buffer()->isUnnamed()) { if (!owner->buffer()->isUnnamed()) {
string const s1 = _("Saving document") + ' ' ostringstream s1;
+ MakeDisplayPath(owner->buffer()->fileName() s1 << _("Saving document") << ' '
+ "..."); << MakeDisplayPath(owner->buffer()->fileName() + "...");
owner->message(s1.str().c_str());
owner->message(s1);
MenuWrite(owner->view(), owner->buffer()); MenuWrite(owner->view(), owner->buffer());
} else } else
WriteAs(owner->view(), owner->buffer()); WriteAs(owner->view(), owner->buffer());
@ -1043,10 +1042,10 @@ string const LyXFunc::Dispatch(int ac,
AllowInput(owner->view()); AllowInput(owner->view());
break; break;
} }
string const str = _("Opening help file") + ' ' ostringstream str;
+ MakeDisplayPath(fname) + "..."; str << _("Opening help file") << ' '
<< MakeDisplayPath(fname) << "...";
owner->message(str); owner->message(str.str().c_str());
owner->view()->buffer(bufferlist.loadLyXFile(fname,false)); owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
AllowInput(owner->view()); AllowInput(owner->view());
break; break;
@ -1568,14 +1567,22 @@ void LyXFunc::MenuNew(bool fromTemplate)
MakeDisplayPath(s, 50), MakeDisplayPath(s, 50),
_("Do you want to open the document?"))) { _("Do you want to open the document?"))) {
// loads document // loads document
owner->message(_("Opening document") + ' ' string const disp_fn(MakeDisplayPath(s));
+ MakeDisplayPath(s) + "...");
XFlush(fl_get_display()); ostringstream str;
str << _("Opening document") << ' '
<< disp_fn << "...";
owner->message(str.str().c_str());
//XFlush(fl_get_display());
owner->view()->buffer( owner->view()->buffer(
bufferlist.loadLyXFile(s)); bufferlist.loadLyXFile(s));
owner->message(_("Document") + ' ' ostringstream str2;
+ MakeDisplayPath(s) + ' ' str2 << _("Document") << ' '
+ _("opened.")); << disp_fn << ' ' << _("opened.");
owner->message(str2.str().c_str());
return; return;
} }
} }
@ -1667,17 +1674,23 @@ void LyXFunc::Open(string const & fname)
filename += ".lyx"; filename += ".lyx";
// loads document // loads document
owner->message(_("Opening document") + ' ' string const disp_fn(MakeDisplayPath(filename));
+ MakeDisplayPath(filename) + "...");
ostringstream str;
str << _("Opening document") << ' ' << disp_fn << "...";
owner->message(str.str().c_str());
Buffer * openbuf = bufferlist.loadLyXFile(filename); Buffer * openbuf = bufferlist.loadLyXFile(filename);
if (openbuf) { if (openbuf) {
owner->view()->buffer(openbuf); owner->view()->buffer(openbuf);
owner->message(_("Document") + ' ' ostringstream str;
+ MakeDisplayPath(filename) str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
+ ' ' + _("opened.")); owner->message(str.str().c_str());
} else { } else {
owner->message(_("Could not open document") + ' ' ostringstream str;
+ MakeDisplayPath(filename)); str << _("Could not open docuent") << ' ' << disp_fn;
owner->message(str.str().c_str());
} }
} }