From 6a55be9506b112110826cf63bc21786044569f1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 6 Jan 2005 15:40:49 +0000 Subject: [PATCH] tostr -> convert and some bformat work git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9446 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 38 ++--- src/ChangeLog | 43 ++++- src/LaTeX.C | 4 +- src/MenuBackend.C | 19 +-- src/Spacing.C | 18 +-- src/buffer.C | 2 +- src/bufferparams.C | 6 +- src/bufferview_funcs.C | 8 +- src/counters.C | 2 +- src/frontends/controllers/ChangeLog | 8 + src/frontends/controllers/ControlExternal.C | 2 +- src/frontends/controllers/ControlGraphics.C | 2 +- src/frontends/controllers/ControlPrint.C | 6 +- .../controllers/ControlSpellchecker.C | 2 +- .../controllers/ControlTabularCreate.C | 2 +- src/frontends/gtk/ChangeLog | 16 +- src/frontends/gtk/GGraphics.C | 6 +- src/frontends/gtk/GParagraph.C | 2 +- src/frontends/gtk/GPrint.C | 4 +- src/frontends/gtk/GSpellchecker.C | 2 +- src/frontends/qt2/ChangeLog | 15 +- src/frontends/qt2/QBox.C | 5 +- src/frontends/qt2/QDocument.C | 29 ++-- src/frontends/qt2/QExternal.C | 12 +- src/frontends/qt2/QGraphics.C | 24 +-- src/frontends/qt2/QParagraph.C | 2 - src/frontends/qt2/QTabular.C | 8 +- src/frontends/qt2/QVSpace.C | 1 - src/frontends/qt2/QWrap.C | 3 +- src/frontends/qt2/qt_helpers.C | 4 +- src/frontends/xforms/ChangeLog | 17 +- src/frontends/xforms/ColorHandler.C | 8 +- src/frontends/xforms/FontInfo.C | 2 +- src/frontends/xforms/FormBox.C | 4 +- src/frontends/xforms/FormColorpicker.C | 4 +- src/frontends/xforms/FormExternal.C | 12 +- src/frontends/xforms/FormFiledialog.C | 5 +- src/frontends/xforms/FormGraphics.C | 10 +- src/frontends/xforms/FormParagraph.C | 2 +- src/frontends/xforms/FormPrint.C | 4 +- src/frontends/xforms/FormSpellchecker.C | 2 +- src/frontends/xforms/FormWrap.C | 2 +- src/frontends/xforms/XFormsMenubar.C | 4 +- src/frontends/xforms/xforms_helpers.C | 2 +- src/graphics/ChangeLog | 4 + src/graphics/GraphicsConverter.C | 4 +- src/graphics/PreviewLoader.C | 2 +- src/insets/ChangeLog | 10 ++ src/insets/ExternalTransforms.C | 2 +- src/insets/insetbibitem.C | 4 +- src/insets/insetexternal.C | 2 +- src/insets/insetfloat.C | 2 +- src/insets/insetinclude.C | 4 +- src/insets/insettabular.C | 8 +- src/insets/insetwrap.C | 2 +- src/lyxfind.C | 2 +- src/lyxfunc.C | 4 +- src/lyxrc.C | 51 +++--- src/output_docbook.C | 2 +- src/paragraph.C | 29 ++-- src/rowpainter.C | 10 +- src/sgml.C | 8 +- src/support/ChangeLog | 9 ++ src/support/filetools.C | 2 +- src/support/lstrings.C | 152 ++++++++++++------ src/support/lstrings.h | 59 +++++-- src/support/tempname.C | 2 +- src/support/tostr.C | 36 +++-- src/support/tostr.h | 49 ++++-- src/tabular.C | 11 +- src/tex-accent.C | 2 +- src/tex2lyx/ChangeLog | 4 + src/tex2lyx/text.C | 2 +- src/text.C | 30 ++-- src/text2.C | 10 +- src/text3.C | 16 +- src/toc.C | 4 +- 77 files changed, 570 insertions(+), 341 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 08d3e03a6e..e76eaf3052 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -337,7 +337,7 @@ void BufferView::Pimpl::setBuffer(Buffer * b) cursor_ = LCursor(*bv_); anchor_ref_ = 0; offset_ref_ = 0; - + // if we're quitting lyx, don't bother updating stuff if (quitting) @@ -410,7 +410,7 @@ void BufferView::Pimpl::updateScrollbar() anchor_ref_ = int(t.paragraphs().size()) - 1; offset_ref_ = 0; } - + lyxerr[Debug::GUI] << "Updating scrollbar: height: " << t.paragraphs().size() << " curr par: " << bv_->cursor().bottom().pit() @@ -454,7 +454,7 @@ void BufferView::Pimpl::scrollDocView(int value) int const first = height; int const last = workarea().workHeight() - height; LCursor & cur = bv_->cursor(); - + bv_funcs::CurStatus st = bv_funcs::status(bv_, cur); switch (st) { @@ -601,7 +601,7 @@ void BufferView::Pimpl::update(bool fitcursor, bool forceupdate) { lyxerr << "BufferView::Pimpl::update(fc=" << fitcursor << ", fu=" << forceupdate << ") buffer: " << buffer_ << endl; - + // check needed to survive LyX startup if (buffer_) { // update macro store @@ -680,7 +680,7 @@ void BufferView::Pimpl::savePosition(unsigned int i) bv_->cursor().paragraph().id(), bv_->cursor().pos()); if (i > 0) - owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i))); + owner_->message(bformat(_("Saved bookmark %1$d"), i)); } @@ -713,7 +713,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) min(par->size(), saved_positions[i].par_pos)); if (i > 0) - owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i))); + owner_->message(bformat(_("Moved to bookmark %1$d"), i)); } @@ -961,7 +961,7 @@ FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd) case LFUN_WORDS_COUNT: flag.enabled(true); break; - + case LFUN_BOOKMARK_GOTO: flag.enabled(bv_->isSavedPosition(strToUnsignedInt(cmd.argument))); break; @@ -1144,16 +1144,16 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd) string message; if (count != 1) { if (cur.selection()) - message = bformat(_("%1$s words in selection."), - tostr(count)); + message = bformat(_("%1$d words in selection."), + count); else - message = bformat(_("%1$s words in document."), - tostr(count)); + message = bformat(_("%1$d words in document."), + count); } else { if (cur.selection()) message = _("One word in selection."); - else + else message = _("One word in document."); } @@ -1183,13 +1183,13 @@ ViewMetricsInfo BufferView::Pimpl::metrics() int pit1 = pit; int pit2 = pit; size_t npit = text->paragraphs().size(); - lyxerr << "npit: " << npit << " pit1: " << pit1 + lyxerr << "npit: " << npit << " pit1: " << pit1 << " pit2: " << pit2 << endl; - // rebreak anchor par + // rebreak anchor par text->redoParagraph(pit); int y0 = text->getPar(pit1).ascent() - offset_ref_; - + // redo paragraphs above cursor if necessary int y1 = y0; while (y1 > 0 && pit1 > 0) { @@ -1199,7 +1199,7 @@ ViewMetricsInfo BufferView::Pimpl::metrics() y1 -= text->getPar(pit1).descent(); } - + // take care of ascent of first line y1 -= text->getPar(pit1).ascent(); @@ -1213,7 +1213,7 @@ ViewMetricsInfo BufferView::Pimpl::metrics() y1 = 0; anchor_ref_ = 0; } - + // redo paragraphs below cursor if necessary int y2 = y0; while (y2 < bv.workHeight() && pit2 < int(npit) - 1) { @@ -1223,7 +1223,7 @@ ViewMetricsInfo BufferView::Pimpl::metrics() y2 += text->getPar(pit2).ascent(); } - // take care of descent of last line + // take care of descent of last line y2 += text->getPar(pit2).descent(); // the coordinates of all these paragraphs are correct, cache them @@ -1233,7 +1233,7 @@ ViewMetricsInfo BufferView::Pimpl::metrics() theCoords.pars_[text][pit] = Point(0, y); y += text->getPar(pit).descent(); } - + lyxerr << "bv:metrics: y1: " << y1 << " y2: " << y2 << endl; return ViewMetricsInfo(pit1, pit2, y1, y2); } diff --git a/src/ChangeLog b/src/ChangeLog index 10e6a6481c..213d911a3e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,16 +1,49 @@ +2005-01-06 Lars Gullik Bjonnes + + * tabular.C: make all write_attributes templates, tostr -> convert + + * paragraph.C (simpleLinuxDocOnePar): fix type for ret from getChar + (emptyTag): and -> &&, and fix type for ret from getChar + (getFirstWord): fix type for ret from getChar + (onlyText): and -> && + (simpleDocBookOnePar): and not -> && !, fix type for ret from + getChar + + * toc.C (goTo, action): + * text3.C (dispatch): + * text.C (currentState): + * tex-accent.C (DoAccent): + * sgml.C: + * lyxrc.C: + * lyxfunc.C (menuNew): + * lyxfinc.C (replace): + * counters.C (laberItem): + * bufferview_funcs.C (font2string): + * bufferparams.C (writeFile): + * buffer.C (readFile): + * Spacing.C (set): + * MenuBackend.C: tostr -> convert + + * LaTeX.C (runMessage): fix format + (scanAuxFiles): tostr -> convert + + * BufferView_pimpl.C (savePosition): fix format + (restorePosition): ditto + (dispatch): ditto + 2005-01-06 Jürgen Spitzmüller * Spacing.[Ch]: New method getValueAsString(). * Spacing.[Ch]: * bufferparams.C: - * ParagraphParameters.C: - * lyxlayout.C: + * ParagraphParameters.C: + * lyxlayout.C: * text.C: * text3.C: store/read spacing value as string. - + * rowpainter.C: change float value (spacing_val) to double. - + * bufferparams.C: add Spacing::Other to spacetranslator (fixes broken custom document spacing). @@ -18,7 +51,7 @@ * lyxfunc.C (getStatus): moved from lyxfunc.C put into anon namespace, also more use of temp references and const - + * cursor.[Ch] (getStatus): move to lyxfunc.C * bufferparams.C: reformat slightly diff --git a/src/LaTeX.C b/src/LaTeX.C index 8609c3ed53..92ee3ac0ce 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -84,7 +84,7 @@ namespace { string runMessage(unsigned int count) { - return bformat(_("Waiting for LaTeX run number %1$s"), tostr(count)); + return bformat(_("Waiting for LaTeX run number %1$d"), count); } } // anon namespace @@ -412,7 +412,7 @@ LaTeX::scanAuxFiles(string const & file) result.push_back(scanAuxFile(file)); for (int i = 1; i < 1000; ++i) { - string file2 = ChangeExtension(file, "") + '.' + tostr(i) + string file2 = ChangeExtension(file, "") + '.' + convert(i) + ".aux"; FileInfo fi(file2); if (!fi.exist()) diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 294599d1cf..d57a1292a1 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -435,13 +435,14 @@ void expandLastfiles(Menu & tomenu, LyXView const * view) LastFiles::const_iterator end = lastfiles.end(); for (; lfit != end && ii < 10; ++lfit, ++ii) { - string const label = tostr(ii) + ". " + string const label = convert(ii) + ". " + MakeDisplayPath((*lfit), 30) - + '|' + tostr(ii); + + '|' + convert(ii); tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))), view); } } + void expandDocuments(Menu & tomenu, LyXView const * view) { typedef vector Strings; @@ -459,7 +460,7 @@ void expandDocuments(Menu & tomenu, LyXView const * view) for (; docit != end; ++docit, ++ii) { string label = MakeDisplayPath(*docit, 20); if (ii < 10) - label = tostr(ii) + ". " + label + '|' + tostr(ii); + label = convert(ii) + ". " + label + '|' + convert(ii); tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_SWITCHBUFFER, *docit)), view); } } @@ -612,8 +613,8 @@ void expandToc2(Menu & tomenu, label += limit_string_length(toc_list[i].str); if (toc_list[i].depth == depth && shortcut_count < 9) { - if (label.find(tostr(shortcut_count + 1)) != string::npos) - label += '|' + tostr(++shortcut_count); + if (label.find(convert(shortcut_count + 1)) != string::npos) + label += '|' + convert(++shortcut_count); } tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(toc_list[i].action()))); @@ -630,8 +631,8 @@ void expandToc2(Menu & tomenu, label += limit_string_length(toc_list[pos].str); if (toc_list[pos].depth == depth && shortcut_count < 9) { - if (label.find(tostr(shortcut_count + 1)) != string::npos) - label += '|' + tostr(++shortcut_count); + if (label.find(convert(shortcut_count + 1)) != string::npos) + label += '|' + convert(++shortcut_count); } if (new_pos == pos + 1) { tomenu.add(MenuItem(MenuItem::Command, @@ -715,7 +716,7 @@ void expandPasteRecent(Menu & tomenu, LyXView const * view) for (unsigned int index = 0; cit != end; ++cit, ++index) { tomenu.add(MenuItem(MenuItem::Command, *cit, - FuncRequest(LFUN_PASTE, tostr(index)))); + FuncRequest(LFUN_PASTE, convert(index)))); } } @@ -733,7 +734,7 @@ void expandBranches(Menu & tomenu, LyXView const * view) for (int ii = 1; cit != end; ++cit, ++ii) { string label = cit->getBranch(); if (ii < 10) - label = tostr(ii) + ". " + label + "|" + tostr(ii); + label = convert(ii) + ". " + label + "|" + convert(ii); tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_INSERT_BRANCH, cit->getBranch())), view); diff --git a/src/Spacing.C b/src/Spacing.C index bc9ec91ca5..c4fcdb1edd 100644 --- a/src/Spacing.C +++ b/src/Spacing.C @@ -51,7 +51,7 @@ double Spacing::getValue() const void Spacing::set(Spacing::Space sp, float val) { - set(sp, tostr(val)); + set(sp, convert(val)); } @@ -60,17 +60,17 @@ void Spacing::set(Spacing::Space sp, string const & val) space = sp; if (sp == Other) { switch (int(strToDbl(val) * 1000 + 0.5)) { - case 1000: - space = Single; + case 1000: + space = Single; break; - case 1250: - space = Onehalf; + case 1250: + space = Onehalf; break; - case 1667: - space = Double; + case 1667: + space = Double; break; - default: - value = val; + default: + value = val; break; } } diff --git a/src/buffer.C b/src/buffer.C index c2b4e9a29e..4e58256a87 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -630,7 +630,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename, pit_type const pit) return false; } command += " -t" - + tostr(LYX_FORMAT) + + convert(LYX_FORMAT) + " -o " + tmpfile + ' ' + QuoteName(filename); lyxerr[Debug::INFO] << "Running '" diff --git a/src/bufferparams.C b/src/bufferparams.C index d173469581..c8f659b6e1 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -637,10 +637,10 @@ void BufferParams::writeFile(ostream & os) const os << "\\papersize " << string_papersize[papersize2] << "\n\\paperpackage " << string_paperpackages[paperpackage] - << "\n\\use_geometry " << tostr(use_geometry) + << "\n\\use_geometry " << convert(use_geometry) << "\n\\use_amsmath " << use_amsmath << "\n\\cite_engine " << citeenginetranslator().find(cite_engine) - << "\n\\use_bibtopic " << tostr(use_bibtopic) + << "\n\\use_bibtopic " << convert(use_bibtopic) << "\n\\paperorientation " << string_orientation[orientation] << '\n'; @@ -709,7 +709,7 @@ void BufferParams::writeFile(ostream & os) const } } - os << "\\tracking_changes " << tostr(tracking_changes) << "\n"; + os << "\\tracking_changes " << convert(tracking_changes) << "\n"; if (tracking_changes) { AuthorList::Authors::const_iterator it = pimpl_->authorlist.begin(); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 0576f55b96..d4dbfe353a 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -67,7 +67,7 @@ bool font2string(LyXFont const & font, bool const toggle, string & data) << "number " << font.number() << '\n' << "color " << font.color() << '\n' << "language " << lang << '\n' - << "toggleall " << tostr(toggle); + << "toggleall " << convert(toggle); data = os.str(); return true; } @@ -150,11 +150,11 @@ bool string2font(string const & data, LyXFont & font, bool & toggle) // the next two should probably go elsewhere // this give the position relative to (0, baseline) of outermost // paragraph -Point coordOffset(DocIterator const & dit) +Point coordOffset(DocIterator const & dit) { int x = 0; int y = 0; - + // Contribution of nested insets for (size_t i = 1; i != dit.size(); ++i) { CursorSlice const & sl = dit[i]; @@ -196,7 +196,7 @@ Point getPos(DocIterator const & dit) CurStatus status(BufferView const * bv, DocIterator const & dit) { CoordCache::InnerParPosCache & cache = theCoords.pars_[dit.bottom().text()]; - + if (cache.find(dit.bottom().pit()) != cache.end()) return CUR_INSIDE; else if (dit.bottom().pit() < bv->anchor_ref()) diff --git a/src/counters.C b/src/counters.C index 82be8664f0..7f65d86af9 100644 --- a/src/counters.C +++ b/src/counters.C @@ -282,7 +282,7 @@ string Counters::labelItem(string const & ctr, string const & numbertype) if (numbertype == "Roman") return romanCounter(value(ctr)); - return tostr(value(ctr)); + return convert(value(ctr)); } diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 527c1c5491..d9c4f73e20 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2005-01-06 Lars Gullik Bjonnes + + * ControlTabularCreate.C (dispatchParams): + * ControlSpellchekcer.C (showSummary): + * ControlPrint.C (dispatchParams): + * ControlGraphics.C (readBB): + * ControlExternal.C (readBB): tostr -> convert + 2004-12-17 Martin Vermeer * ControlMath.C: fixed Ångström, Ørsted. diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 9c6a251b14..6e64ea1d13 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -189,7 +189,7 @@ string const ControlExternal::readBB(string const & file) } } - return ("0 0 " + tostr(width) + ' ' + tostr(height)); + return ("0 0 " + convert(width) + ' ' + convert(height)); } } // namespace frontend diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index a7a46506b6..a0cda6f91f 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -125,7 +125,7 @@ string const ControlGraphics::readBB(string const & file) } } - return ("0 0 " + tostr(width) + ' ' + tostr(height)); + return ("0 0 " + convert(width) + ' ' + convert(height)); } diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index bd2344d8af..53f3678efb 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -92,11 +92,11 @@ void ControlPrint::dispatchParams() if (!pp.all_pages && pp.from_page) { command += lyxrc.print_pagerange_flag + ' '; - command += tostr(pp.from_page); + command += convert(pp.from_page); if (pp.to_page) { // we have a range "from-to" command += '-' - + tostr(pp.to_page); + + convert(pp.to_page); } command += ' '; } @@ -117,7 +117,7 @@ void ControlPrint::dispatchParams() command += lyxrc.print_copies_flag; } command += ' ' - + tostr(pp.count_copies) + + convert(pp.count_copies) + ' '; } diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 2efe8ed93d..6bbb8e51ea 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -270,7 +270,7 @@ void ControlSpellchecker::showSummary() string message; if (count_ != 1) - message = bformat(_("%1$s words checked."), tostr(count_)); + message = bformat(_("%1$d words checked."), count_); else message = _("One word checked."); diff --git a/src/frontends/controllers/ControlTabularCreate.C b/src/frontends/controllers/ControlTabularCreate.C index c51a9abd17..f2d026e30a 100644 --- a/src/frontends/controllers/ControlTabularCreate.C +++ b/src/frontends/controllers/ControlTabularCreate.C @@ -43,7 +43,7 @@ void ControlTabularCreate::clearParams() void ControlTabularCreate::dispatchParams() { - string data = tostr(params().first) + ' ' + tostr(params().second); + string data = convert(params().first) + ' ' + convert(params().second); kernel().dispatch(FuncRequest(LFUN_TABULAR_INSERT, data)); } diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 4ef76371fb..4123144369 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,7 +1,15 @@ +2005-01-06 Lars Gullik Bjonnes + + * GParagraph.C: drop unused include tostr.h + + * GSpellchecker.C: + * GPrint.C: + * GGraphics.C (apply): tostr -> convert + 2005-01-04 Jürgen Spitzmüller * xftFontLoader.C: lyxrc.font_sizes is a string now. - + * lyx_gui.C: change getDVI() to int. 2005-01-04 Jürgen Spitzmüller @@ -30,15 +38,15 @@ 2004-12-08 John Spray - * FileDialogPrivate.C: use Gtk::FileChooser.set_current_name + * FileDialogPrivate.C: use Gtk::FileChooser.set_current_name to make suggested filenames work when saving 2004-12-07 John Spray - * glade/: improve layouts, set spinbuttons to display 2 + * glade/: improve layouts, set spinbuttons to display 2 decimal places where apropriate * GSearch.C: focus 'find' entry on update() - * GParagraph.C: don't require that 'ControlBox' widget + * GParagraph.C: don't require that 'ControlBox' widget be an HBox. * The Include Dialog: Dialogs.C, Makefile.am, GInclude.[Ch], glade/include.glade diff --git a/src/frontends/gtk/GGraphics.C b/src/frontends/gtk/GGraphics.C index 54bb6f8fe4..5728c9af2c 100644 --- a/src/frontends/gtk/GGraphics.C +++ b/src/frontends/gtk/GGraphics.C @@ -268,7 +268,7 @@ void GGraphics::apply() if (setscalingradio_->get_active()) { float scaleValue = outputscalespin_->get_adjustment()->get_value(); - igp.scale = tostr(scaleValue); + igp.scale = convert(scaleValue); if (float_equal(scaleValue, 0.0, 0.05)) igp.scale = string(); igp.width = LyXLength(); @@ -329,7 +329,7 @@ void GGraphics::apply() igp.clip = clipcheck_->get_active(); // the extra section - igp.rotateAngle = tostr(anglespin_->get_adjustment()->get_value()); + igp.rotateAngle = convert(anglespin_->get_adjustment()->get_value()); int const origin_pos = origincombo_->get_active_row_number(); igp.rotateOrigin = origins_[origin_pos]; @@ -380,7 +380,7 @@ void GGraphics::update() { unitsComboFromLength(heightunitscombo_, stringcol_, igp.height, defaultUnit); - if (!igp.scale.empty() + if (!igp.scale.empty() && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) { // scaling sizing mode setscalingradio_->set_active(true); diff --git a/src/frontends/gtk/GParagraph.C b/src/frontends/gtk/GParagraph.C index 18cbd44774..cb9b37025b 100644 --- a/src/frontends/gtk/GParagraph.C +++ b/src/frontends/gtk/GParagraph.C @@ -24,10 +24,10 @@ #include "ParagraphParameters.h" #include "Spacing.h" #include "support/lstrings.h" -#include "support/tostr.h" using std::string; + namespace lyx { namespace frontend { diff --git a/src/frontends/gtk/GPrint.C b/src/frontends/gtk/GPrint.C index db3b2399ef..079cbf5a5d 100644 --- a/src/frontends/gtk/GPrint.C +++ b/src/frontends/gtk/GPrint.C @@ -68,8 +68,8 @@ void GPrint::update() fileEntry_->set_text(pp.file_name); all_->set_active(pp.all_pages); - string const from = ( pp.from_page ? tostr(pp.from_page) : string() ); - string const to = ( pp.to_page ? tostr(pp.to_page) : string() ); + string const from = ( pp.from_page ? convert(pp.from_page) : string() ); + string const to = ( pp.to_page ? convert(pp.to_page) : string() ); fromEntry_->set_text(from); toEntry_->set_text(to); odd_->set_active(pp.odd_pages); diff --git a/src/frontends/gtk/GSpellchecker.C b/src/frontends/gtk/GSpellchecker.C index ebb5d8295f..685542e49c 100644 --- a/src/frontends/gtk/GSpellchecker.C +++ b/src/frontends/gtk/GSpellchecker.C @@ -130,7 +130,7 @@ void GSpellchecker::partialUpdate(int s) int const progress = controller().getProgress(); if (progress != 0) { progress_->set_fraction(float(progress)/100.0f); - progress_->set_text(tostr(progress) + "% " + _("checked")); + progress_->set_text(convert(progress) + "% " + _("checked")); } } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 1cb174c62e..0176107e67 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,6 +1,19 @@ +2005-01-06 Lars Gullik Bjonnes + + * QDocument.C: + * QBox.C: drop unused include tostr.h + + * qt_helpers.C: + * QWrap.C: + * QVSpace.C + * QTabular.C: + * QParagraph.C: + * QGraphics.C: + * QExternal.C: tostr -> convert + 2005-01-06 Jürgen Spitzmüller - * QDocument.C: + * QDocument.C: * QParagraph.C: store all float/double values as strings. 2005-01-05 Lars Gullik Bjonnes diff --git a/src/frontends/qt2/QBox.C b/src/frontends/qt2/QBox.C index bdc1529ae4..291d990686 100644 --- a/src/frontends/qt2/QBox.C +++ b/src/frontends/qt2/QBox.C @@ -29,7 +29,6 @@ #include "insets/insetbox.h" #include "support/lstrings.h" -#include "support/tostr.h" #include #include @@ -83,7 +82,7 @@ void QBox::build_dialog() bcview().setOK(dialog_->okPB); bcview().setApply(dialog_->applyPB); bcview().setCancel(dialog_->closePB); - + // initialize the length validator addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA); addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA); @@ -197,7 +196,7 @@ void QBox::apply() } else if (special == qt_("Width")) { i = 4; spec = true; - } + } // the user might insert a non-special value in the line edit if (isValidLength(fromqstr(value))) { i = 0; diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index 4c77698888..181f9c7bcc 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -25,7 +25,6 @@ #include "lyxtextclasslist.h" #include "tex-strings.h" // tex_graphics -#include "support/tostr.h" #include "support/lstrings.h" #include "controllers/ControlDocument.h" @@ -175,26 +174,26 @@ void QDocument::build_dialog() bcview().setApply(dialog_->applyPB); bcview().setCancel(dialog_->closePB); bcview().setRestore(dialog_->restorePB); - + // initialize the length validator addCheckedLineEdit(bcview(), dialog_->textLayoutModule->skipLE); - addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperheightLE, + addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperheightLE, dialog_->pageLayoutModule->paperheightL); - addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperwidthLE, + addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperwidthLE, dialog_->pageLayoutModule->paperwidthL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->topLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->topLE, dialog_->marginsModule->topL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->bottomLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->bottomLE, dialog_->marginsModule->bottomL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->innerLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->innerLE, dialog_->marginsModule->innerL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->outerLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->outerLE, dialog_->marginsModule->outerL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->headsepLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->headsepLE, dialog_->marginsModule->headsepL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->headheightLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->headheightLE, dialog_->marginsModule->headheightL); - addCheckedLineEdit(bcview(), dialog_->marginsModule->footskipLE, + addCheckedLineEdit(bcview(), dialog_->marginsModule->footskipLE, dialog_->marginsModule->footskipL); } @@ -343,7 +342,7 @@ void QDocument::apply() case 3: { VSpace vs = VSpace( - widgetsToLength(dialog_->textLayoutModule->skipLE, + widgetsToLength(dialog_->textLayoutModule->skipLE, dialog_->textLayoutModule->skipLengthCO) ); params.setDefSkip(vs); @@ -565,7 +564,7 @@ void QDocument::update_contents() dialog_->textLayoutModule->lspacingCO->setCurrentItem(nitem); if (params.spacing().getSpace() == Spacing::Other) { dialog_->textLayoutModule->lspacingLE->setText( - toqstr(params.spacing().getValueAsString())); + toqstr(params.spacing().getValueAsString())); } dialog_->setLSpacing(nitem); @@ -591,8 +590,8 @@ void QDocument::update_contents() { skip = 3; string const length = params.getDefSkip().asLyXCommand(); - lengthToWidgets(dialog_->textLayoutModule->skipLE, - dialog_->textLayoutModule->skipLengthCO, + lengthToWidgets(dialog_->textLayoutModule->skipLE, + dialog_->textLayoutModule->skipLengthCO, length, defaultUnit); break; } diff --git a/src/frontends/qt2/QExternal.C b/src/frontends/qt2/QExternal.C index 2aff4929c8..4d8fd2d6e6 100644 --- a/src/frontends/qt2/QExternal.C +++ b/src/frontends/qt2/QExternal.C @@ -103,7 +103,7 @@ void setDisplay(QCheckBox & displayCB, QComboBox & showCO, QLineEdit & scaleED, showCO.setEnabled(!no_display && !read_only); displayCB.setChecked(!no_display); scaleED.setEnabled(!no_display && !read_only); - scaleED.setText(toqstr(tostr(scale))); + scaleED.setText(toqstr(convert(scale))); } @@ -173,7 +173,7 @@ void setSize(QLineEdit & widthED, QComboBox & widthUnitCO, widthED.setText(toqstr(scale)); widthUnitCO.setCurrentItem(0); } else { - widthED.setText(toqstr(tostr(data.width.value()))); + widthED.setText(toqstr(convert(data.width.value()))); // Because 'Scale' is position 0... // Note also that width cannot be zero here, so // we don't need to worry about the default unit. @@ -237,10 +237,10 @@ void setCrop(QCheckBox & clipCB, { clipCB.setChecked(data.clip); graphics::BoundingBox const & bbox = data.bbox; - xlED.setText(toqstr(tostr(bbox.xl))); - ybED.setText(toqstr(tostr(bbox.yb))); - xrED.setText(toqstr(tostr(bbox.xr))); - ytED.setText(toqstr(tostr(bbox.yt))); + xlED.setText(toqstr(convert(bbox.xl))); + ybED.setText(toqstr(convert(bbox.yb))); + xrED.setText(toqstr(convert(bbox.xr))); + ytED.setText(toqstr(convert(bbox.yt))); } diff --git a/src/frontends/qt2/QGraphics.C b/src/frontends/qt2/QGraphics.C index 63aed8835c..45d44e3880 100644 --- a/src/frontends/qt2/QGraphics.C +++ b/src/frontends/qt2/QGraphics.C @@ -106,7 +106,7 @@ void QGraphics::build_dialog() bcview().addReadOnly(dialog_->origin); bcview().addReadOnly(dialog_->latexoptions); bcview().addReadOnly(dialog_->getPB); - + // initialize the length validator addCheckedLineEdit(bcview(), dialog_->width, dialog_->sizewidthL_2); addCheckedLineEdit(bcview(), dialog_->height, dialog_->sizeheightL_2); @@ -193,28 +193,28 @@ void QGraphics::update_contents() string const xr(token(igp.bb, ' ', 2)); string const yr(token(igp.bb, ' ', 3)); if (isValidLength(xl, &anyLength)) { - dialog_->lbX->setText(toqstr(tostr(anyLength.value()))); + dialog_->lbX->setText(toqstr(convert(anyLength.value()))); string const unit(unit_name[anyLength.unit()]); dialog_->lbXunit->setCurrentItem(getItemNo(bb_units, unit)); } else { dialog_->lbX->setText(toqstr(xl)); } if (isValidLength(yl, &anyLength)) { - dialog_->lbY->setText(toqstr(tostr(anyLength.value()))); + dialog_->lbY->setText(toqstr(convert(anyLength.value()))); string const unit(unit_name[anyLength.unit()]); dialog_->lbYunit->setCurrentItem(getItemNo(bb_units, unit)); } else { dialog_->lbY->setText(toqstr(xl)); } if (isValidLength(xr, &anyLength)) { - dialog_->rtX->setText(toqstr(tostr(anyLength.value()))); + dialog_->rtX->setText(toqstr(convert(anyLength.value()))); string const unit(unit_name[anyLength.unit()]); dialog_->rtXunit->setCurrentItem(getItemNo(bb_units, unit)); } else { dialog_->rtX->setText(toqstr(xl)); } if (isValidLength(yr, &anyLength)) { - dialog_->rtY->setText(toqstr(tostr(anyLength.value()))); + dialog_->rtY->setText(toqstr(convert(anyLength.value()))); string const unit(unit_name[anyLength.unit()]); dialog_->rtYunit->setCurrentItem(getItemNo(bb_units, unit)); } else { @@ -244,7 +244,7 @@ void QGraphics::update_contents() dialog_->showCB->setEnabled(igp.display != lyx::graphics::NoDisplay && !readOnly()); dialog_->displayCB->setChecked(igp.display != lyx::graphics::NoDisplay); dialog_->displayscale->setEnabled(igp.display != lyx::graphics::NoDisplay && !readOnly()); - dialog_->displayscale->setText(toqstr(tostr(igp.lyxscale))); + dialog_->displayscale->setText(toqstr(convert(igp.lyxscale))); //// the output section (width/height) // set the length combo boxes @@ -256,13 +256,13 @@ void QGraphics::update_contents() for (int i = 0; i < num_units; i++) dialog_->widthUnit->insertItem(unit_name_gui[i], -1); - if (!igp.scale.empty() + if (!igp.scale.empty() && !float_equal(strToDbl(igp.scale), 0.0, 0.05)) { dialog_->width->setText(toqstr(igp.scale)); dialog_->widthUnit->setCurrentItem(0); } else { // no scale means default width/height - dialog_->width->setText(toqstr(tostr(igp.width.value()))); + dialog_->width->setText(toqstr(convert(igp.width.value()))); // the width cannot have a unitDefault, because // it is a "Scale%" or another user defined unit! // +1 instead of the "Scale%" option @@ -270,7 +270,7 @@ void QGraphics::update_contents() dialog_->widthUnit->setCurrentItem(unit_ + 1); } // 2. the height (a lengthgcombo type) - lengthToWidgets(dialog_->height, dialog_->heightUnit, + lengthToWidgets(dialog_->height, dialog_->heightUnit, igp.height.asString(), unitDefault); // enable height input in case of non "Scale%" as width-unit @@ -362,7 +362,7 @@ void QGraphics::apply() string value = fromqstr(dialog_->width->text()); if (dialog_->widthUnit->currentItem() > 0 || isValidLength(value)) { // width/height combination - igp.width = + igp.width = widgetsToLength(dialog_->width, dialog_->widthUnit); igp.scale = string(); } else { @@ -371,7 +371,7 @@ void QGraphics::apply() igp.width = LyXLength(); } value = fromqstr(dialog_->height->text()); - igp.height = + igp.height = LyXLength(widgetsToLength(dialog_->height, dialog_->heightUnit)); igp.keepAspectRatio = dialog_->aspectratio->isChecked(); @@ -385,7 +385,7 @@ void QGraphics::apply() float rotAngle = strToDbl(igp.rotateAngle); if (std::abs(rotAngle) > 360.0) { rotAngle -= 360.0 * floor(rotAngle / 360.0); - igp.rotateAngle = tostr(rotAngle); + igp.rotateAngle = convert(rotAngle); } // save the latex name for the origin. If it is the default diff --git a/src/frontends/qt2/QParagraph.C b/src/frontends/qt2/QParagraph.C index a6c27203be..31ecfb3fc3 100644 --- a/src/frontends/qt2/QParagraph.C +++ b/src/frontends/qt2/QParagraph.C @@ -21,8 +21,6 @@ #include "controllers/ControlParagraph.h" #include "controllers/helper_funcs.h" -#include "support/tostr.h" - #include #include #include diff --git a/src/frontends/qt2/QTabular.C b/src/frontends/qt2/QTabular.C index 4f851221f9..bc25e7b897 100644 --- a/src/frontends/qt2/QTabular.C +++ b/src/frontends/qt2/QTabular.C @@ -76,9 +76,9 @@ void QTabular::build_dialog() bcview().addReadOnly(dialog_->lastfooterBorderBelowCB); bcview().addReadOnly(dialog_->lastfooterNoContentsCB); bcview().addReadOnly(dialog_->newpageCB); - + // initialize the length validator - addCheckedLineEdit(bcview(), dialog_->widthED, + addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->fixedWidthColLA); } @@ -139,8 +139,8 @@ void QTabular::update_contents() LyXTabular::row_type const row(tabular.row_of_cell(cell)); LyXTabular::col_type const col(tabular.column_of_cell(cell)); - dialog_->tabularRowED->setText(toqstr(tostr(row + 1))); - dialog_->tabularColumnED->setText(toqstr(tostr(col + 1))); + dialog_->tabularRowED->setText(toqstr(convert(row + 1))); + dialog_->tabularColumnED->setText(toqstr(convert(col + 1))); bool const multicol(tabular.isMultiColumn(cell)); diff --git a/src/frontends/qt2/QVSpace.C b/src/frontends/qt2/QVSpace.C index d9b59c8345..91fdb0074f 100644 --- a/src/frontends/qt2/QVSpace.C +++ b/src/frontends/qt2/QVSpace.C @@ -31,7 +31,6 @@ #include "controllers/helper_funcs.h" #include "support/lstrings.h" -#include "support/tostr.h" #include #include diff --git a/src/frontends/qt2/QWrap.C b/src/frontends/qt2/QWrap.C index 967c125ad1..413dd043c8 100644 --- a/src/frontends/qt2/QWrap.C +++ b/src/frontends/qt2/QWrap.C @@ -88,7 +88,8 @@ void QWrap::apply() namespace { string const numtostr(double val) { - string a(tostr(val)); + string a(convert(val)); +#warning Will this test ever trigger? (Lgb) if (a == "0") a.erase(); return a; diff --git a/src/frontends/qt2/qt_helpers.C b/src/frontends/qt2/qt_helpers.C index f35c89fa28..d12e3fc134 100644 --- a/src/frontends/qt2/qt_helpers.C +++ b/src/frontends/qt2/qt_helpers.C @@ -91,7 +91,7 @@ LyXLength widgetsToLength(QLineEdit const * input, QComboBox const * combo) return LyXLength(fromqstr(length)); LyXLength::UNIT unit = unitFromString(fromqstr(combo->currentText())); - + return LyXLength(length.toDouble(), unit); } @@ -109,7 +109,7 @@ void lengthToWidgets(QLineEdit * input, LengthCombo * combo, input->setText(toqstr(len)); } else { combo->setCurrentItem(LyXLength(len).unit()); - input->setText(toqstr(tostr(LyXLength(len).value()))); + input->setText(toqstr(convert(LyXLength(len).value()))); } } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 834c02402a..ea6cc1f3d9 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,6 +1,21 @@ +2005-01-06 Lars Gullik Bjonnes + + * xforms_helpers.C: + * XFormsMenubar.C: + * FormWrap.C: + * FormSpellchecker.C: + * FormPrint.C: + * FormGraphics.C: + * FormFiledialog.C: + * FormExternal.C: + * FormColorPicker.C: + * FormBox.C: + * FontInfo.C: + * ColorHandler.C: convert -> tostr + 2005-01-06 Jürgen Spitzmüller - * FormDocument.C: + * FormDocument.C: * FormParagraph.C: store all float/double values as strings. 2005-01-05 Lars Gullik Bjonnes diff --git a/src/frontends/xforms/ColorHandler.C b/src/frontends/xforms/ColorHandler.C index e4309fe78c..a43bc9036f 100644 --- a/src/frontends/xforms/ColorHandler.C +++ b/src/frontends/xforms/ColorHandler.C @@ -40,9 +40,9 @@ namespace { string tostr(XColor const & col) { return bformat("(%1$s,%2$s,%3$s)", - ::tostr(col.red), - ::tostr(col.green), - ::tostr(col.blue)); + ::convert(col.red), + ::convert(col.green), + ::convert(col.blue)); } } // namespace @@ -161,7 +161,7 @@ GC LyXColorHandler::getGCForeground(string const & s) lyxerr << bformat( _(" Using closest allocated color with (r,g,b)=%1$s instead.\n" "Pixel [%2$s] is used."), - tostr(cmap[closest_pixel]), ::tostr(closest_pixel)) << endl; + tostr(cmap[closest_pixel]), convert(closest_pixel)) << endl; val.foreground = cmap[closest_pixel].pixel; } diff --git a/src/frontends/xforms/FontInfo.C b/src/frontends/xforms/FontInfo.C index 13a7d5ab0e..6fae730671 100644 --- a/src/frontends/xforms/FontInfo.C +++ b/src/frontends/xforms/FontInfo.C @@ -99,7 +99,7 @@ string const FontInfo::resize(string const & font, int size) const break; } } - ret.replace(before, after, tostr(size)); + ret.replace(before, after, convert(size)); return ret; } diff --git a/src/frontends/xforms/FormBox.C b/src/frontends/xforms/FormBox.C index 0c90df376e..2bf22abeeb 100644 --- a/src/frontends/xforms/FormBox.C +++ b/src/frontends/xforms/FormBox.C @@ -151,7 +151,7 @@ void FormBox::update() setEnabled(dialog_->radio_minipage, controller().params().inner_box); LyXLength len(controller().params().width); - fl_set_input(dialog_->input_width, tostr(len.value()).c_str()); + fl_set_input(dialog_->input_width, convert(len.value()).c_str()); fl_set_choice(dialog_->choice_width_unit, len.unit() + 1); string special(controller().params().special); for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) { @@ -165,7 +165,7 @@ void FormBox::update() setEnabled(dialog_->choice_special, !controller().params().inner_box); LyXLength ht(controller().params().height); - fl_set_input(dialog_->input_height, tostr(ht.value()).c_str()); + fl_set_input(dialog_->input_height, convert(ht.value()).c_str()); fl_set_choice(dialog_->choice_height_unit, ht.unit() + 1); string const height_special(controller().params().height_special); for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) { diff --git a/src/frontends/xforms/FormColorpicker.C b/src/frontends/xforms/FormColorpicker.C index 7a23f9f01a..90f93e9c51 100644 --- a/src/frontends/xforms/FormColorpicker.C +++ b/src/frontends/xforms/FormColorpicker.C @@ -39,7 +39,7 @@ enum GuiColors { string const fillLabel(RGBColor const & rgb) { - return tostr(rgb.r) + ", " + tostr(rgb.g) + ", " + tostr(rgb.b); + return convert(rgb.r) + ", " + convert(rgb.g) + ", " + convert(rgb.b); } @@ -49,7 +49,7 @@ string const fillLabel(HSVColor const & hsv) int const s = int(100.0 * hsv.s); int const v = int(100.0 * hsv.v); - return tostr(h) + ", " + tostr(s) + ", " + tostr(v); + return convert(h) + ", " + convert(s) + ", " + convert(v); } } // namespace anon diff --git a/src/frontends/xforms/FormExternal.C b/src/frontends/xforms/FormExternal.C index fb1de73f11..b3b8070a29 100644 --- a/src/frontends/xforms/FormExternal.C +++ b/src/frontends/xforms/FormExternal.C @@ -109,7 +109,7 @@ void setDisplay(FL_OBJECT * displayCB, FL_OBJECT * showCO, FL_OBJECT * scaleED, fl_set_button(displayCB, !no_display); - fl_set_input(scaleED, tostr(scale).c_str()); + fl_set_input(scaleED, convert(scale).c_str()); setEnabled(scaleED, !no_display && !read_only); } @@ -197,7 +197,7 @@ void setSize(FL_OBJECT * widthED, FL_OBJECT * widthUnitCO, fl_set_input(widthED, scale.c_str()); fl_set_choice(widthUnitCO, 1); } else { - fl_set_input(widthED, tostr(data.width.value()).c_str()); + fl_set_input(widthED, convert(data.width.value()).c_str()); // Because 'Scale' is position 1... // Note also that width cannot be zero here, so // we don't need to worry about the default unit. @@ -275,10 +275,10 @@ void setCrop(FL_OBJECT * clipCB, fl_set_button(clipCB, data.clip); graphics::BoundingBox const & bbox = data.bbox; - fl_set_input(xlED, tostr(bbox.xl).c_str()); - fl_set_input(ybED, tostr(bbox.yb).c_str()); - fl_set_input(xrED, tostr(bbox.xr).c_str()); - fl_set_input(ytED, tostr(bbox.yt).c_str()); + fl_set_input(xlED, convert(bbox.xl).c_str()); + fl_set_input(ybED, convert(bbox.yb).c_str()); + fl_set_input(xrED, convert(bbox.xr).c_str()); + fl_set_input(ytED, convert(bbox.yt).c_str()); } diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index cd54ca947c..d2e8bd601a 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -166,7 +166,7 @@ private: void UserCache::add(uid_t ID) const { struct passwd const * entry = getpwuid(ID); - users[ID] = entry ? entry->pw_name : tostr(int(ID)); + users[ID] = entry ? entry->pw_name : convert(int(ID)); } @@ -199,9 +199,10 @@ string const & GroupCache::find(gid_t ID) const void GroupCache::add(gid_t ID) const { struct group const * entry = getgrgid(ID); - groups[ID] = entry ? entry->gr_name : tostr(int(ID)); + groups[ID] = entry ? entry->gr_name : convert(int(ID)); } + // local instances UserCache lyxUserCache; GroupCache lyxGroupCache; diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 1b6430a7c7..77d17cb5b3 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -331,8 +331,8 @@ void FormGraphics::apply() // first item in choice_width means scaling if (fl_get_choice(file_->choice_width) == 1) { igp.scale = getString(file_->input_width); - if (igp.scale.empty() - || float_equal(strToDbl(igp.scale), 0.0, 0.05) + if (igp.scale.empty() + || float_equal(strToDbl(igp.scale), 0.0, 0.05) || float_equal(strToDbl(igp.scale), 100.0, 0.05)) { igp.scale = string(); } @@ -414,7 +414,7 @@ void FormGraphics::apply() float rotAngle = strToDbl(igp.rotateAngle); if (std::abs(rotAngle) > 360.0) { rotAngle -= 360.0 * floor(rotAngle / 360.0); - igp.rotateAngle = tostr(rotAngle); + igp.rotateAngle = convert(rotAngle); } fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str()); @@ -441,7 +441,7 @@ void FormGraphics::update() { string const name = igp.filename.outputFilename(kernel().bufferFilepath()); fl_set_input(file_->input_filename, name.c_str()); - fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str()); + fl_set_input(file_->input_lyxscale, convert(igp.lyxscale).c_str()); switch (igp.display) { case graphics::NoDisplay: @@ -477,7 +477,7 @@ void FormGraphics::update() { igp.height, defaultUnit); // disable height input in case of scaling - bool const disable_height = (!igp.scale.empty() + bool const disable_height = (!igp.scale.empty() && !float_equal(strToDbl(igp.scale), 0.0, 0.05)); setEnabled(file_->input_height, !disable_height); setEnabled(file_->choice_height, !disable_height); diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index f2128a43a4..29fffa227a 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -266,7 +266,7 @@ void FormParagraph::update() bool const spacing_other = space.getSpace() == Spacing::Other; setEnabled(dialog_->input_linespacing, spacing_other); if (spacing_other) { - fl_set_input(dialog_->input_linespacing, + fl_set_input(dialog_->input_linespacing, space.getValueAsString().c_str()); } else { fl_set_input(dialog_->input_linespacing, ""); diff --git a/src/frontends/xforms/FormPrint.C b/src/frontends/xforms/FormPrint.C index 48d38d464b..f67946fb4d 100644 --- a/src/frontends/xforms/FormPrint.C +++ b/src/frontends/xforms/FormPrint.C @@ -159,8 +159,8 @@ void FormPrint::update() // we might just be remembering the last time this was printed. all_pages_.set(pp.all_pages); - string const from = ( pp.from_page ? tostr(pp.from_page) : string() ); - string const to = ( pp.to_page ? tostr(pp.to_page) : string() ); + string const from = ( pp.from_page ? convert(pp.from_page) : string() ); + string const to = ( pp.to_page ? convert(pp.to_page) : string() ); fl_set_input(dialog_->input_from_page, from.c_str()); fl_set_input(dialog_->input_to_page, to.c_str()); diff --git a/src/frontends/xforms/FormSpellchecker.C b/src/frontends/xforms/FormSpellchecker.C index 4f51c8d664..1eba6cf52e 100644 --- a/src/frontends/xforms/FormSpellchecker.C +++ b/src/frontends/xforms/FormSpellchecker.C @@ -111,7 +111,7 @@ void FormSpellchecker::partialUpdate(int s) double const wordcount = controller().getCount(); double const total = 100.0 * wordcount / progress; - string const label = tostr(progress) + " %"; + string const label = convert(progress) + " %"; fl_set_slider_bounds(dialog_->slider_progress, 0.0, total); fl_set_slider_value(dialog_->slider_progress, wordcount); diff --git a/src/frontends/xforms/FormWrap.C b/src/frontends/xforms/FormWrap.C index 37788f0202..85ea19a6b1 100644 --- a/src/frontends/xforms/FormWrap.C +++ b/src/frontends/xforms/FormWrap.C @@ -108,7 +108,7 @@ void FormWrap::update() { InsetWrapParams const & params = controller().params(); LyXLength len(params.width); - fl_set_input(dialog_->input_width, tostr(len.value()).c_str()); + fl_set_input(dialog_->input_width, convert(len.value()).c_str()); fl_set_choice(dialog_->choice_width_units, len.unit() + 1); if (params.placement.empty()) diff --git a/src/frontends/xforms/XFormsMenubar.C b/src/frontends/xforms/XFormsMenubar.C index 31aaac9475..c6ea81a5ce 100644 --- a/src/frontends/xforms/XFormsMenubar.C +++ b/src/frontends/xforms/XFormsMenubar.C @@ -308,7 +308,7 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view, *item.submenu(), smn, funcs); if (submenuid == -1) return -1; - label += "%x" + tostr(smn.size()); + label += "%x" + convert(smn.size()); lyxerr[Debug::GUI] << "Menu: " << submenuid << " (at index " << smn.size() @@ -320,7 +320,7 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view, int const action_count = distance(funcs.begin(), fit); - label += "%x" + tostr(action_count + action_offset); + label += "%x" + convert(action_count + action_offset); lyxerr[Debug::GUI] << "Action: \"" << item.func().action << "(" << item.func().argument diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 50fb6409d4..f5a4e19a0e 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -225,7 +225,7 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice, fl_set_input(input, ""); fl_set_choice_text(choice, default_unit.c_str()); } else { - fl_set_input(input, tostr(len.value()).c_str()); + fl_set_input(input, convert(len.value()).c_str()); // Set the choice to the desired unit, if present in the choice. // Else set the choice to the default unit. diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 78b1d44352..8166642e02 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,7 @@ +2005-01-06 Lars Gullik Bjonnes + + * PreviewLoader.C (unique_filename): tostr -> convert + 2005-01-04 Jürgen Spitzmüller * PreviewLoader.C: lyxrc.preview_scale_factor is a string now. diff --git a/src/graphics/GraphicsConverter.C b/src/graphics/GraphicsConverter.C index 7810eff5dc..cc013e773a 100644 --- a/src/graphics/GraphicsConverter.C +++ b/src/graphics/GraphicsConverter.C @@ -184,7 +184,7 @@ Converter::Impl::Impl(string const & from_file, string const & to_file_base, // Output the script to file. static int counter = 0; script_file_ = OnlyPath(to_file_base) + "lyxconvert" + - tostr(counter++) + ".sh"; + convert(counter++) + ".sh"; std::ofstream fs(script_file_.c_str()); if (!fs.good()) { @@ -299,7 +299,7 @@ bool build_script(string const & from_file, // Create a temporary base file-name for all intermediate steps. // Remember to remove the temp file because we only want the name... static int counter = 0; - string const tmp = "gconvert" + tostr(counter++); + string const tmp = "gconvert" + convert(counter++); string const to_base = tempName(string(), tmp); unlink(to_base); diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index 2b18903382..04d63ea334 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -648,7 +648,7 @@ namespace { string const unique_filename(string const bufferpath) { static int theCounter = 0; - string const filename = tostr(theCounter++) + "lyxpreview"; + string const filename = convert(theCounter++) + "lyxpreview"; return support::AddName(bufferpath, filename); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 8f7c9f4821..a73f5cdf18 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2005-01-06 Lars Gullik Bjonnes + + * insetwrap.C: + * insettabular.C: + * insetinclude.C: + * insetfloat.C: + * insetexternal.C: + * insetbibitem.C: + * ExternalTransforms.C (adjAngle): tostr -> convert + 2005-01-05 Lars Gullik Bjonnes * inset.[Ch] (forceDefaultParagraphs): delete since it is same as diff --git a/src/insets/ExternalTransforms.C b/src/insets/ExternalTransforms.C index 7d645df7a3..19670f087f 100644 --- a/src/insets/ExternalTransforms.C +++ b/src/insets/ExternalTransforms.C @@ -70,7 +70,7 @@ string const RotationData::adjAngle() const double rotAngle = strToDbl(angle); if (std::abs(rotAngle) > 360.0) { rotAngle -= 360.0 * floor(rotAngle / 360.0); - return tostr(rotAngle); + return convert(rotAngle); } return angle; } diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 1fd1b6304c..74e3f29fae 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -43,7 +43,7 @@ InsetBibitem::InsetBibitem(InsetCommandParams const & p) : InsetCommand(p, "bibitem"), counter(1) { if (getContents().empty()) - setContents(key_prefix + tostr(++key_counter)); + setContents(key_prefix + convert(++key_counter)); } @@ -111,7 +111,7 @@ void InsetBibitem::read(Buffer const &, LyXLex & lex) string const InsetBibitem::getBibLabel() const { - return getOptions().empty() ? tostr(counter) : getOptions(); + return getOptions().empty() ? convert(counter) : getOptions(); } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 9c14a29984..6fc0e5e05c 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -201,7 +201,7 @@ void InsetExternalParams::write(Buffer const & buffer, ostream & os) const << '\n'; if (lyxscale != defaultLyxScale) - os << "\tlyxscale " << tostr(lyxscale) << '\n'; + os << "\tlyxscale " << convert(lyxscale) << '\n'; if (draft) os << "\tdraft\n"; diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index cf506c945c..aaa87eca6a 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -427,7 +427,7 @@ void InsetFloat::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const if (pit->layout()->name() == caplayout) { string const name = floatname(params_.type, buf.params()); string const str = - tostr(toclist[name].size() + 1) + convert(toclist[name].size() + 1) + ". " + pit->asString(buf, false); lyx::toc::TocItem const item(pit->id(), 0 , str); toclist[name].push_back(item); diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index bd11f6874b..a887ba9f4e 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -87,7 +87,7 @@ namespace { string const uniqueID() { static unsigned int seed = 1000; - return "file" + tostr(++seed); + return "file" + convert(++seed); } } // namespace anon @@ -241,7 +241,7 @@ void InsetInclude::write(Buffer const &, ostream & os) const void InsetInclude::write(ostream & os) const { os << "Include " << params_.getCommand() << '\n' - << "preview " << tostr(params_.preview()) << '\n'; + << "preview " << convert(params_.preview()) << '\n'; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 6ad7025498..f8cae34e8a 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -325,7 +325,7 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const x += scroll(); x += ADD_TO_TABULAR_WIDTH; - + if (tablemode(cur)) { row_type rs, re; col_type cs, ce; @@ -345,11 +345,11 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const pi.pain.fillRectangle(xx, y - a, w, h, LColor::selection); xx += w; - + } y += h; } - + } else { cur.text()->drawSelection(pi, x + getCellXPos(cur.idx()) + tabular.getBeginningOfTextInCell(cur.idx()), 0 /*this value is ignored */); } @@ -1016,7 +1016,7 @@ void InsetTabular::getCursorPos(CursorSlice const & sl, int & x, int & y) const namespace { - + // Manhattan distance to nearest corner int dist(InsetOld const & inset, int x, int y) diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 3b3a82c1c8..486f933f2c 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -235,7 +235,7 @@ void InsetWrap::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const if (tmp->layout()->name() == caplayout) { string const name = floatname(params_.type, buf.params()); string const str = - tostr(toclist[name].size() + 1) + convert(toclist[name].size() + 1) + ". " + tmp->asString(buf, false); lyx::toc::TocItem const item(tmp->id(), 0 , str); toclist[name].push_back(item); diff --git a/src/lyxfind.C b/src/lyxfind.C index 769aa2c44c..5d23c82976 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -326,7 +326,7 @@ void replace(BufferView * bv, FuncRequest const & ev) if (replace_count == 1) { lv->message(_("String has been replaced.")); } else { - string str = tostr(replace_count); + string str = convert(replace_count); str += _(" strings have been replaced."); lv->message(str); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 1fe53cce62..e5eb20d52a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1605,12 +1605,12 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate) if (filename.empty()) { filename = AddName(lyxrc.document_path, - "newfile" + tostr(++newfile_number) + ".lyx"); + "newfile" + convert(++newfile_number) + ".lyx"); FileInfo fi(filename); while (bufferlist.exists(filename) || fi.readable()) { ++newfile_number; filename = AddName(lyxrc.document_path, - "newfile" + tostr(newfile_number) + + "newfile" + convert(newfile_number) + ".lyx"); fi.newFile(filename); } diff --git a/src/lyxrc.C b/src/lyxrc.C index 7128115c3d..9ff5301030 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -1215,7 +1215,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const auto_region_delete != system_lyxrc.auto_region_delete) { os << "# Set to false to inhibit automatic replacement of\n" << "# the current selection.\n" - << "\\auto_region_delete " << tostr(auto_region_delete) + << "\\auto_region_delete " << convert(auto_region_delete) << '\n'; } case RC_AUTORESET_OPTIONS: @@ -1223,7 +1223,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const auto_reset_options != system_lyxrc.auto_reset_options) { os << "# Set to false to inhibit automatic reset of\n" << "# the class options to defaults on class change.\n" - << "\\auto_reset_options " << tostr(auto_reset_options) + << "\\auto_reset_options " + << convert(auto_reset_options) << '\n'; } case RC_AUTOSAVE: @@ -1293,7 +1294,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_KBMAP: if (ignore_system_lyxrc || use_kbmap != system_lyxrc.use_kbmap) { - os << "\\kbmap " << tostr(use_kbmap) << '\n'; + os << "\\kbmap " << convert(use_kbmap) << '\n'; } case RC_KBMAP_PRIMARY: if (ignore_system_lyxrc || @@ -1333,7 +1334,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_SHOW_BANNER: if (ignore_system_lyxrc || show_banner != system_lyxrc.show_banner) { - os << "\\show_banner " << tostr(show_banner) << '\n'; + os << "\\show_banner " << convert(show_banner) << '\n'; } case RC_PREVIEW: @@ -1359,7 +1360,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const preview_hashed_labels != system_lyxrc.preview_hashed_labels) { os << "\\preview_hashed_labels " - << tostr(preview_hashed_labels) << '\n'; + << convert(preview_hashed_labels) << '\n'; } case RC_PREVIEW_SCALE_FACTOR: @@ -1411,14 +1412,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const cursor_follows_scrollbar != system_lyxrc.cursor_follows_scrollbar) { os << "\\cursor_follows_scrollbar " - << tostr(cursor_follows_scrollbar) << '\n'; + << convert(cursor_follows_scrollbar) << '\n'; } case RC_DIALOGS_ICONIFY_WITH_MAIN: if (ignore_system_lyxrc || dialogs_iconify_with_main != system_lyxrc.dialogs_iconify_with_main) { os << "\\dialogs_iconify_with_main " - << tostr(dialogs_iconify_with_main) << '\n'; + << convert(dialogs_iconify_with_main) << '\n'; } case RC_SCREEN_FONT_ROMAN: if (ignore_system_lyxrc || @@ -1461,7 +1462,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const if (ignore_system_lyxrc || use_scalable_fonts != system_lyxrc.use_scalable_fonts) { os << "\\screen_font_scalable " - << tostr(use_scalable_fonts) + << convert(use_scalable_fonts) << '\n'; } case RC_SCREEN_FONT_ENCODING: @@ -1538,7 +1539,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const if (ignore_system_lyxrc || print_adapt_output != system_lyxrc.print_adapt_output) { os << "\\print_adapt_output " - << tostr(print_adapt_output) + << convert(print_adapt_output) << '\n'; } case RC_PRINT_COMMAND: @@ -1693,7 +1694,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_CHECKLASTFILES: if (ignore_system_lyxrc || check_lastfiles != system_lyxrc.check_lastfiles) { - os << "\\check_lastfiles " << tostr(check_lastfiles) + os << "\\check_lastfiles " << convert(check_lastfiles) << '\n'; } case RC_TEMPLATEPATH: @@ -1716,7 +1717,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_MAKE_BACKUP: if (ignore_system_lyxrc || make_backup != system_lyxrc.make_backup) { - os << "\\make_backup " << tostr(make_backup) << '\n'; + os << "\\make_backup " << convert(make_backup) << '\n'; } case RC_BACKUPDIR_PATH: if (ignore_system_lyxrc || @@ -1741,7 +1742,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_USE_SPELL_LIB: if (ignore_system_lyxrc || use_spell_lib != system_lyxrc.use_spell_lib) { - os << "\\use_spell_lib " << tostr(use_spell_lib) << '\n'; + os << "\\use_spell_lib " << convert(use_spell_lib) << '\n'; } case RC_SPELL_COMMAND: if (ignore_system_lyxrc || @@ -1751,13 +1752,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_ACCEPT_COMPOUND: if (ignore_system_lyxrc || isp_accept_compound != system_lyxrc.isp_accept_compound) { - os << "\\accept_compound " << tostr(isp_accept_compound) + os << "\\accept_compound " << convert(isp_accept_compound) << '\n'; } case RC_USE_ALT_LANG: if (ignore_system_lyxrc || isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) { - os << "\\use_alt_language " << tostr(isp_use_alt_lang) + os << "\\use_alt_language " << convert(isp_use_alt_lang) << '\n'; } case RC_ALT_LANG: @@ -1769,7 +1770,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_USE_ESC_CHARS: if (ignore_system_lyxrc || isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) { - os << "\\use_escape_chars " << tostr(isp_use_esc_chars) + os << "\\use_escape_chars " << convert(isp_use_esc_chars) << '\n'; } case RC_ESC_CHARS: @@ -1781,7 +1782,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const if (ignore_system_lyxrc || isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) { os << "\\use_personal_dictionary " - << tostr(isp_use_pers_dict) + << convert(isp_use_pers_dict) << '\n'; } case RC_PERS_DICT: @@ -1794,7 +1795,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const isp_use_input_encoding != system_lyxrc.isp_use_input_encoding) { os << "\\use_input_encoding " - << tostr(isp_use_input_encoding) + << convert(isp_use_input_encoding) << '\n'; } @@ -1805,7 +1806,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_RTL_SUPPORT: if (ignore_system_lyxrc || rtl_support != system_lyxrc.rtl_support) { - os << "\\rtl " << tostr(rtl_support) << '\n'; + os << "\\rtl " << convert(rtl_support) << '\n'; } case RC_LANGUAGE_PACKAGE: if (ignore_system_lyxrc || @@ -1818,14 +1819,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const language_global_options != system_lyxrc.language_global_options) { os << "\\language_global_options \"" - << tostr(language_global_options) + << convert(language_global_options) << "\"\n"; } case RC_LANGUAGE_USE_BABEL: if (ignore_system_lyxrc || language_use_babel != system_lyxrc.language_use_babel) { os << "\\language_use_babel \"" - << tostr(language_use_babel) + << convert(language_use_babel) << "\"\n"; } case RC_LANGUAGE_COMMAND_BEGIN: @@ -1855,20 +1856,20 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const if (ignore_system_lyxrc || language_auto_begin != system_lyxrc.language_auto_begin) { os << "\\language_auto_begin " - << tostr(language_auto_begin) << '\n'; + << convert(language_auto_begin) << '\n'; } case RC_LANGUAGE_AUTO_END: if (ignore_system_lyxrc || language_auto_end != system_lyxrc.language_auto_end) { os << "\\language_auto_end " - << tostr(language_auto_end) << '\n'; + << convert(language_auto_end) << '\n'; } case RC_MARK_FOREIGN_LANGUAGE: if (ignore_system_lyxrc || mark_foreign_language != system_lyxrc.mark_foreign_language) { os << "\\mark_foreign_language " << - tostr(mark_foreign_language) << '\n'; + convert(mark_foreign_language) << '\n'; } os << "\n#\n" @@ -1878,7 +1879,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const case RC_AUTO_NUMBER: if (ignore_system_lyxrc || auto_number != system_lyxrc.auto_number) { - os << "\\auto_number " << tostr(auto_number) << '\n'; + os << "\\auto_number " << convert(auto_number) << '\n'; } case RC_DEFAULT_LANGUAGE: if (ignore_system_lyxrc || @@ -2172,7 +2173,7 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_NUMLASTFILES: - str = bformat(_("Maximal number of lastfiles. Up to %1$s can appear in the file menu."), tostr(maxlastfiles)); + str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles); break; case RC_CHECKLASTFILES: diff --git a/src/output_docbook.C b/src/output_docbook.C index ead3b3cc31..825914f779 100644 --- a/src/output_docbook.C +++ b/src/output_docbook.C @@ -235,7 +235,7 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf, sgml::closeTag(os, bstyle->labeltag()); } - // Opend inner tag and close inner tags + // Opend inner tag and close inner tags sgml::openTag(os, bstyle->innertag()); par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs)); sgml::closeTag(os, bstyle->innertag()); diff --git a/src/paragraph.C b/src/paragraph.C index b33ebcfdd9..b1a9a60f82 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1265,7 +1265,7 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, os << '<' << tag_name(*j) << '>'; } - char c = getChar(i); + value_type c = getChar(i); if (c == Paragraph::META_INSET) { @@ -1323,20 +1323,19 @@ bool Paragraph::emptyTag() const if (isInset(i)) { InsetBase const * inset = getInset(i); InsetBase::Code lyx_code = inset->lyxCode(); - if (lyx_code != InsetBase::TOC_CODE and - lyx_code != InsetBase::INCLUDE_CODE and - lyx_code != InsetBase::GRAPHICS_CODE and - lyx_code != InsetBase::ERT_CODE and - lyx_code != InsetBase::FLOAT_CODE and + if (lyx_code != InsetBase::TOC_CODE && + lyx_code != InsetBase::INCLUDE_CODE && + lyx_code != InsetBase::GRAPHICS_CODE && + lyx_code != InsetBase::ERT_CODE && + lyx_code != InsetBase::FLOAT_CODE && lyx_code != InsetBase::TABULAR_CODE) { return false; } } else { - char c = getChar(i); - if(c!= ' ' and c!= '\t') + value_type c = getChar(i); + if (c != ' ' && c != '\t') return false; } - } return true; } @@ -1367,7 +1366,7 @@ pos_type Paragraph::getFirstWord(Buffer const & buf, ostream & os, OutputParams InsetBase const * inset = getInset(i); inset->docbook(buf, os, runparams); } else { - char c = getChar(i); + value_type c = getChar(i); if (c == ' ') break; bool ws; @@ -1389,7 +1388,7 @@ bool Paragraph::onlyText(Buffer const & buf, LyXFont const & outerfont, pos_type LyXFont font = getFont(buf.params(), i, outerfont); if (isInset(i)) return false; - if ( i != initial and font != font_old) + if (i != initial && font != font_old) return false; font_old = font; } @@ -1410,8 +1409,9 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, LyXFont font_old = style->labeltype == LABEL_MANUAL ? style->labelfont : style->font; - if (style->pass_thru and not onlyText(buf, outerfont, initial)) + if (style->pass_thru && !onlyText(buf, outerfont, initial)) os << "]]>"; + // parsing main loop for (pos_type i = initial; i < size(); ++i) { LyXFont font = getFont(buf.params(), i, outerfont); @@ -1431,7 +1431,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, InsetBase const * inset = getInset(i); inset->docbook(buf, os, runparams); } else { - char c = getChar(i); + value_type c = getChar(i); bool ws; string str; boost::tie(ws, str) = sgml::escapeChar(c); @@ -1450,7 +1450,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, if (style->free_spacing) os << '\n'; - if (style->pass_thru and not onlyText(buf, outerfont, initial)) + if (style->pass_thru && !onlyText(buf, outerfont, initial)) os << "spacing.getValue() * spacing_val); int const maxdesc = int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val) @@ -662,7 +662,7 @@ void RowPainter::paintText() // if we reach the end of a struck out range, paint it // we also don't paint across things like tables if (running_strikeout && (highly_editable_inset || !is_struckout)) { - // FIXME this should take real text height into account, not + // FIXME this should take real text height into account, not // the whole row including padding whitespace //int const middle = yo_ + (- row_.ascent() + row_.top_of_text()) / 2; int const middle = yo_ - row_.ascent() / 2; @@ -733,7 +733,7 @@ void paintPar static NullPainter nop; static PainterInfo nullpi(pi.base.bv, nop); int const ww = pi.base.bv->workHeight(); - + Paragraph & par = text.paragraphs()[pit]; RowList::iterator const rb = par.rows().begin(); @@ -746,7 +746,7 @@ void paintPar bool const inside = (y + rit->descent() >= 0 && y - rit->ascent() < ww); RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y); - + y += rit->descent(); rp.paintAppendix(); rp.paintDepthBar(); @@ -783,7 +783,7 @@ void paintText(BufferView const & bv, ViewMetricsInfo const & vi) paintPar(pi, *bv.text(), pit, 0, yy); yy += text->getPar(pit).descent(); } - + // paint one paragraph above and one below if (vi.p1 > 0) { diff --git a/src/sgml.C b/src/sgml.C index 9d159f4d7a..c10e8d81f7 100644 --- a/src/sgml.C +++ b/src/sgml.C @@ -117,7 +117,7 @@ string escapeString(string const & raw) string const uniqueID(string const label) { static unsigned int seed = 1000; - return label + tostr(++seed); + return label + convert(++seed); } @@ -172,9 +172,9 @@ string cleanID(Buffer const & buf, OutputParams const & runparams, std::string c } } if (mangle) { - content += "-" + tostr(mangleID++); + content += "-" + convert(mangleID++); } - else if (isdigit(content[content.size()-1])) { + else if (isdigit(content[content.size() - 1])) { content += "."; } @@ -231,7 +231,7 @@ void openTag(Buffer const & buf, ostream & os, OutputParams const & runparams, P else counters.step(style->latexname()); int i = counters.value(name); - attribute = subst(param, "#", tostr(i)); + attribute = subst(param, "#", convert(i)); } else { attribute = param; } diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 487246b617..db6f478951 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,12 @@ +2005-01-06 Lars Gullik Bjonnes + + * lstrings.[Ch]: change bformat to be a template + + * tostr.[Ch]: tostr -> convert, convert is a template + + * tempname.C: + * filetools.C (createBufferTmpDir): tostr -> convert + 2005-01-05 Angus Leeming * os_win32.C (external_path, internal_path): s/MAX_PATH/PATH_MAX/. diff --git a/src/support/filetools.C b/src/support/filetools.C index 7f3a6c5e96..4b29034661 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -497,7 +497,7 @@ string const createBufferTmpDir() // We are in our own directory. Why bother to mangle name? // In fact I wrote this code to circumvent a problematic behaviour (bug?) // of EMX mkstemp(). - string const tmpfl = os::getTmpDir() + "/lyx_tmpbuf" + tostr(count++); + string const tmpfl = os::getTmpDir() + "/lyx_tmpbuf" + convert(count++); if (mkdir(tmpfl, 0777)) { lyxerr << "LyX could not create the temporary directory '" << tmpfl << "'" << endl; diff --git a/src/support/lstrings.C b/src/support/lstrings.C index dae295717c..1c60dd4c8f 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -19,7 +19,12 @@ #include #include + +#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES +#if USE_BOOST_FORMAT #include +#endif +#endif #include #include @@ -544,20 +549,7 @@ vector const getVectorFromString(string const & str, #else boost::char_separator sep(delim.c_str()); boost::tokenizer > tokens(str, sep); -#ifndef USE_INCLUDED_STRING return vector(tokens.begin(), tokens.end()); -#else - vector vec; - using boost::tokenizer; - using boost::char_separator; - - tokenizer >::iterator it = tokens.begin(); - tokenizer >::iterator end = tokens.end(); - for (; it != end; ++it) { - vec.push_back(STRCONV((*it))); - } - return vec; -#endif #endif } @@ -581,49 +573,110 @@ string const getStringFromVector(vector const & vec, } +#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES #if USE_BOOST_FORMAT -string bformat(string const & fmt, string const & arg1) +template<> +string bformat(string const & fmt, int arg1) { return (boost::format(fmt) % arg1).str(); } -string bformat(string const & fmt, string const & arg1, string const & arg2) +template<> +string bformat(string const & fmt, long arg1) { - return (boost::format(fmt) % arg1 % arg2).str(); + return (boost::format(fmt) % arg1).str(); +} + + +template<> +string bformat(string const & fmt, unsigned int arg1) +{ + return (boost::format(fmt) % arg1).str(); +} + + +template<> +string bformat(string const & fmt, string arg1) +{ + return (boost::format(fmt) % arg1).str(); +} + + +template<> +string bformat(string const & fmt, char * arg1) +{ + return (boost::format(fmt) % arg1).str(); } +template<> string bformat(string const & fmt, int arg1, int arg2) { return (boost::format(fmt) % arg1 % arg2).str(); } -string bformat(string const & fmt, string const & arg1, string const & arg2, - string const & arg3) +template<> +string bformat(string const & fmt, string arg1, string arg2) +{ + return (boost::format(fmt) % arg1 % arg2).str(); +} + + +template<> +string bformat(string const & fmt, char const * arg1, string arg2) +{ + return (boost::format(fmt) % arg1 % arg2).str(); +} + + +template<> +string bformat(string const & fmt, string arg1, string arg2, string arg3) { return (boost::format(fmt) % arg1 % arg2 % arg3).str(); } -string bformat(string const & fmt, string const & arg1, string const & arg2, - string const & arg3, string const & arg4) +template<> +string bformat(string const & fmt, + string arg1, string arg2, string arg3, string arg4) { return (boost::format(fmt) % arg1 % arg2 % arg3 % arg4).str(); } +#else + +template<> +string bformat(string const & fmt, int arg1) +{ + BOOST_ASSERT(contains(fmt, "%1$d")); + string const str = subst(fmt, "%1$d", convert(arg1)); + return subst(str, "%%", "%"); +} + -string bformat(string const & fmt, string const & arg1, string const & arg2, - string const & arg3, string const & arg4, string const & arg5) +template<> +string bformat(string const & fmt, long arg1) { - return (boost::format(fmt) % arg1 % arg2 % arg3 % arg4 % arg5).str(); + BOOST_ASSERT(contains(fmt, "%1$d")); + string const str = subst(fmt, "%1$d", convert(arg1)); + return subst(str, "%%", "%"); } -#else -string bformat(string const & fmt, string const & arg1) +template<> +string bformat(string const & fmt, unsigned int arg1) +{ + BOOST_ASSERT(contains(fmt, "%1$d")); + string const str = subst(fmt, "%1$d", convert(arg1)); + return subst(str, "%%", "%"); +} + + +template<> +string bformat(string const & fmt, string arg1) { BOOST_ASSERT(contains(fmt, "%1$s")); string const str = subst(fmt, "%1$s", arg1); @@ -631,7 +684,15 @@ string bformat(string const & fmt, string const & arg1) } -string bformat(string const & fmt, string const & arg1, string const & arg2) +template<> +string bformat(string const & fmt, char * arg1) +{ + BOOST_ASSERT(contains(fmt, "%1$s")); + string const str = subst(fmt, "%1$s", arg1); + return subst(str, "%%", "%"); +} +template<> +string bformat(string const & fmt, string arg1, string arg2) { BOOST_ASSERT(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%2$s")); @@ -641,60 +702,57 @@ string bformat(string const & fmt, string const & arg1, string const & arg2) } -string bformat(string const & fmt, int arg1, int arg2) +template<> +string bformat(string const & fmt, char const * arg1, string arg2) { - BOOST_ASSERT(contains(fmt, "%1$d")); - BOOST_ASSERT(contains(fmt, "%2$d")); - string str = subst(fmt, "%1$d", tostr(arg1)); - str = subst(str, "%2$d", tostr(arg2)); + BOOST_ASSERT(contains(fmt, "%1$s")); + BOOST_ASSERT(contains(fmt, "%2$s")); + string str = subst(fmt, "%1$s", arg1); + str = subst(fmt, "%2$s", arg2); return subst(str, "%%", "%"); } -string bformat(string const & fmt, string const & arg1, string const & arg2, - string const & arg3) +template<> +string bformat(string const & fmt, int arg1, int arg2) { - BOOST_ASSERT(contains(fmt, "%1$s")); - BOOST_ASSERT(contains(fmt, "%2$s")); - BOOST_ASSERT(contains(fmt, "%3$s")); - string str = subst(fmt, "%1$s", arg1); - str = subst(str, "%2$s", arg2); - str = subst(str, "%3$s", arg3); + BOOST_ASSERT(contains(fmt, "%1$d")); + BOOST_ASSERT(contains(fmt, "%2$d")); + string str = subst(fmt, "%1$d", convert(arg1)); + str = subst(str, "%2$d", convert(arg2)); return subst(str, "%%", "%"); } -string bformat(string const & fmt, string const & arg1, string const & arg2, - string const & arg3, string const & arg4) +template<> +string bformat(string const & fmt, string arg1, string arg2, string arg3) { BOOST_ASSERT(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%2$s")); BOOST_ASSERT(contains(fmt, "%3$s")); - BOOST_ASSERT(contains(fmt, "%4$s")); string str = subst(fmt, "%1$s", arg1); str = subst(str, "%2$s", arg2); str = subst(str, "%3$s", arg3); - str = subst(str, "%4$s", arg4); return subst(str, "%%", "%"); } -string bformat(string const & fmt, string const & arg1, string const & arg2, - string const & arg3, string const & arg4, string const & arg5) +template<> +string bformat(string const & fmt, + string arg1, string arg2, string arg3, string arg4) { BOOST_ASSERT(contains(fmt, "%1$s")); BOOST_ASSERT(contains(fmt, "%2$s")); BOOST_ASSERT(contains(fmt, "%3$s")); BOOST_ASSERT(contains(fmt, "%4$s")); - BOOST_ASSERT(contains(fmt, "%5$s")); string str = subst(fmt, "%1$s", arg1); str = subst(str, "%2$s", arg2); str = subst(str, "%3$s", arg3); str = subst(str, "%4$s", arg4); - str = subst(str, "%5$s", arg5); return subst(str, "%%", "%"); } +#endif #endif } // namespace support diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 7d371266e3..ab75fd6202 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -185,18 +185,53 @@ std::vector const getVectorFromString(std::string const & str, std::string const getStringFromVector(std::vector const & vec, std::string const & delim = std::string(",")); -// wrapper around boost::format using one argument %1$s -std::string bformat(std::string const & fmt, std::string const & arg1); -// arguments %1$s and %2$s -std::string bformat(std::string const & fmt, std::string const & arg1, std::string const & arg2); -// arguments %1$d and %2$d -std::string bformat(std::string const & fmt, int arg1, int arg2); -// arguments %1$s and %2$s and %3$s -std::string bformat(std::string const & fmt, std::string const & arg1, std::string const & arg2, - std::string const & arg3); -// arguments %1$s and %2$s and %3$s and %4$s -std::string bformat(std::string const & fmt, std::string const & arg1, std::string const & arg2, - std::string const & arg3, std::string const & arg4); + +#ifdef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES + +#include + +template +string bformat(string const & fmt, Arg1 arg1) +{ + return (boost::format(fmt) % arg1).str(); +} + + +template +string bformat(string const & fmt, Arg1 arg1, Arg2 arg2) +{ + return (boost::format(fmt) % arg1 % arg2).str(); +} + + +template +string bformat(string const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3) +{ + return (boost::format(fmt) % arg1 % arg2 % arg3).str(); +} + + +template +string bformat(string const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) +{ + return (boost::format(fmt) % arg1 % arg2 % arg3 % arg4).str(); +} + +#else + +template +std::string bformat(std::string const & fmt, Arg1); + +template +std::string bformat(std::string const & fmt, Arg1, Arg2); + +template +std::string bformat(std::string const & fmt, Arg1, Arg2, Arg3); + +template +std::string bformat(std::string const & fmt, Arg1, Arg2, Arg3, Arg4); + +#endif } // namespace support } // namespace lyx diff --git a/src/support/tempname.C b/src/support/tempname.C index d80e3b9795..4202312076 100644 --- a/src/support/tempname.C +++ b/src/support/tempname.C @@ -55,7 +55,7 @@ string const lyx::support::tempName(string const & dir, string const & mask) { string const tmpdir(dir.empty() ? os::getTmpDir() : dir); string tmpfl(AddName(tmpdir, mask)); - tmpfl += tostr(getpid()); + tmpfl += convert(getpid()); tmpfl += "XXXXXX"; // The supposedly safe mkstemp version diff --git a/src/support/tostr.C b/src/support/tostr.C index d490413f84..c137dbb627 100644 --- a/src/support/tostr.C +++ b/src/support/tostr.C @@ -11,51 +11,59 @@ #include -#include +#include "tostr.h" +#include using boost::lexical_cast; using std::string; -string const tostr(bool b) +template<> +string convert(bool b) { return (b ? "true" : "false"); } -string const tostr(unsigned int i) +template<> +string convert(char c) { - return lexical_cast(i); + return string(1, c); } -string const tostr(long int i) +template<> +string convert(short unsigned int sui) { - return lexical_cast(i); + return lexical_cast(sui); } -string const tostr(double d) +template<> +string convert(int i) { - return lexical_cast(d); + return lexical_cast(i); } -string const tostr(int i) +template<> +string convert(unsigned int ui) { - return lexical_cast(i); + return lexical_cast(ui); } -string const tostr(string const & s) +template<> +string convert(float f) { - return s; + return lexical_cast(f); } -string const tostr(long unsigned int i) +template<> +string convert(double d) { - return lexical_cast(i); + return lexical_cast(d); } diff --git a/src/support/tostr.h b/src/support/tostr.h index 2e362d9199..93e1f9a943 100644 --- a/src/support/tostr.h +++ b/src/support/tostr.h @@ -5,6 +5,7 @@ * Licence details can be found in the file COPYING. * * \author André Pönitz + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. * @@ -15,21 +16,41 @@ #ifndef TOSTR_H #define TOSTR_H +#include + #include -/// convert things to strings -std::string const tostr(bool b); -/// -std::string const tostr(int); -/// -std::string const tostr(unsigned int); -/// -std::string const tostr(long int); -/// -std::string const tostr(double); -/// -std::string const tostr(std::string const & s); -/// -std::string const tostr(long unsigned int); +template +Target convert(Source arg) +{ + // We use a static assert here since we want all instances of + // this template to be specializations. + BOOST_STATIC_ASSERT(sizeof(bool) == 0); + return Target(); +} + +template<> +std::string convert(bool); + +template<> +std::string convert(char); + +template<> +std::string convert(unsigned short); + +template<> +std::string convert(int); + +template<> +std::string convert(unsigned int); + +template<> +std::string convert(float); + +template<> +std::string convert(double); + +template<> +std::string convert(std::string); #endif diff --git a/src/tabular.C b/src/tabular.C index 9655a5c508..02ddbd7e46 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -70,36 +70,41 @@ string const write_attribute(string const & name, T const & t) return s.empty() ? s : " " + name + "=\"" + s + "\""; } +template <> string const write_attribute(string const & name, string const & t) { return t.empty() ? t : " " + name + "=\"" + t + "\""; } +template <> string const write_attribute(string const & name, bool const & b) { // we write only true attribute values so we remove a bit of the // file format bloat for tabulars. - return b ? write_attribute(name, tostr(b)) : string(); + return b ? write_attribute(name, convert(b)) : string(); } +template <> string const write_attribute(string const & name, int const & i) { // we write only true attribute values so we remove a bit of the // file format bloat for tabulars. - return i ? write_attribute(name, tostr(i)) : string(); + return i ? write_attribute(name, convert(i)) : string(); } +template <> string const write_attribute(string const & name, LyXTabular::idx_type const & i) { // we write only true attribute values so we remove a bit of the // file format bloat for tabulars. - return i ? write_attribute(name, tostr(i)) : string(); + return i ? write_attribute(name, convert(i)) : string(); } +template <> string const write_attribute(string const & name, LyXLength const & value) { // we write only the value if we really have one same reson as above. diff --git a/src/tex-accent.C b/src/tex-accent.C index 59b0d1778c..8b7f740672 100644 --- a/src/tex-accent.C +++ b/src/tex-accent.C @@ -99,5 +99,5 @@ string const DoAccent(string const & s, tex_accent accent) string const DoAccent(char c, tex_accent accent) { - return DoAccent(tostr(c), accent); + return DoAccent(convert(c), accent); } diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index f8315f8566..45dbfea54f 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,7 @@ +2005-01-06 Lars Gullik Bjonnes + + * text.C: tostr -> convert + 2005-01-06 Jürgen Spitzmüller * Spacing.h: adapt dummy file to the changes in src/Spacing.h. diff --git a/src/tex2lyx/text.C b/src/tex2lyx/text.C index 1002b99b4b..d1bd74209f 100644 --- a/src/tex2lyx/text.C +++ b/src/tex2lyx/text.C @@ -664,7 +664,7 @@ void parse_environment(Parser & p, ostream & os, bool outer, if (p.next_token().asInput() == "[") { os << "placement " << p.getArg('[', ']') << '\n'; } - os << "wide " << tostr(is_starred) + os << "wide " << convert(is_starred) << "\nsideways false" << "\nstatus open\n\n"; parse_text_in_inset(p, os, FLAG_END, outer, parent_context); diff --git a/src/text.C b/src/text.C index ed8801ee00..dc94664fe5 100644 --- a/src/text.C +++ b/src/text.C @@ -999,7 +999,7 @@ void LyXText::setHeightOfRow(pit_type const pit, Row & row) // incalculate the layout spaces maxasc += int(layoutasc * 2 / (2 + pars_[pit].getDepth())); maxdesc += int(layoutdesc * 2 / (2 + pars_[pit].getDepth())); - + row.ascent(maxasc + labeladdon); row.descent(maxdesc); } @@ -1676,8 +1676,8 @@ void LyXText::redoParagraph(pit_type const pit) z = row.endpos(); } while (z < par.size()); - dim.asc += par.rows()[0].ascent(); - dim.des -= par.rows()[0].ascent(); + dim.asc += par.rows()[0].ascent(); + dim.des -= par.rows()[0].ascent(); par.dim_ = dim; //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n"; } @@ -1734,7 +1734,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x , int) const beg.top() = cur.selBegin(); end.top() = cur.selEnd(); - + // the selection doesn't touch the visible screen if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW || bv_funcs::status(pi.base.bv, end) == bv_funcs::CUR_ABOVE) @@ -1742,10 +1742,10 @@ void LyXText::drawSelection(PainterInfo & pi, int x , int) const Paragraph const & par1 = pars_[beg.pit()]; Paragraph const & par2 = pars_[end.pit()]; - + Row const & row1 = par1.getRow(beg.pos()); Row const & row2 = par2.getRow(end.pos()); - + int y1,x1,x2; if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_ABOVE) { y1 = 0; @@ -1769,9 +1769,9 @@ void LyXText::drawSelection(PainterInfo & pi, int x , int) const X1 = isRTL(par2) ? 0 : endx; X2 = isRTL(par2) ? endx : 0 + dim_.wid; } - + lyxerr << " y1: " << y1 << " y2: " << y2 - << " xo: " << xo_ << " wid: " << dim_.wid + << " xo: " << xo_ << " wid: " << dim_.wid << endl; // paint big rectangle in one go @@ -1804,7 +1804,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const beg.top() = cur.selBegin(); end.top() = cur.selEnd(); - + // the selection doesn't touch the visible screen if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW || bv_funcs::status(pi.base.bv, end) == bv_funcs::CUR_ABOVE) @@ -1812,7 +1812,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const Paragraph const & par1 = pars_[beg.pit()]; Paragraph const & par2 = pars_[end.pit()]; - + bool const above = (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_ABOVE); bool const below = (bv_funcs::status(pi.base.bv, end) @@ -2116,7 +2116,7 @@ string LyXText::currentState(LCursor & cur) // The paragraph depth int depth = cur.paragraph().getDepth(); if (depth > 0) - os << bformat(_(", Depth: %1$s"), tostr(depth)); + os << bformat(_(", Depth: %1$d"), depth); // The paragraph spacing, but only if different from // buffer spacing. @@ -2222,7 +2222,7 @@ pos_type LyXText::x2pos(pit_type pit, int row, int x) const // Paragraph const & par = pars_[pit]; // Row const & r = par.rows()[row]; // int x = 0; -// pos -= r.pos(); +// pos -= r.pos(); //} @@ -2232,7 +2232,7 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) { pit_type pit = getPitNearY(y); int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent(); - lyxerr << "setCursorFromCoordinates: x: " << x << " y: " << y + lyxerr << "setCursorFromCoordinates: x: " << x << " y: " << y << " pit: " << pit << " yy: " << yy << endl; Paragraph const & par = pars_[pit]; @@ -2246,10 +2246,10 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) } Row const & row = par.rows()[r]; - + lyxerr << "setCursorFromCoordinates: row " << r << " from pos: " << row.pos() << endl; - + bool bound = false; int xx = x; pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound); diff --git a/src/text2.C b/src/text2.C index 44e897db0f..0ffd04c0f6 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1184,7 +1184,7 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const const_cast(this)->setCurrentFont(cur); return 0; } - + // This should be just before or just behind the // cursor position set above. BOOST_ASSERT((pos != 0 && inset == pars_[pit].getInset(pos - 1)) @@ -1273,7 +1273,7 @@ void LyXText::cursorUp(LCursor & cur) } else if (cur.pit() > 0) { --cur.pit(); setCursor(cur, cur.pit(), x2pos(cur.pit(), cur.paragraph().rows().size() - 1, x)); - + } cur.x_target() = x; @@ -1282,7 +1282,7 @@ void LyXText::cursorUp(LCursor & cur) void LyXText::cursorDown(LCursor & cur) { - + Paragraph const & par = cur.paragraph(); int const row = par.pos2row(cur.pos()); @@ -1293,14 +1293,14 @@ void LyXText::cursorDown(LCursor & cur) editXY(cur, x, y + par.rows()[row].descent() + 1); return; } - + if (row + 1 < int(par.rows().size())) { setCursor(cur, cur.pit(), x2pos(cur.pit(), row + 1, x)); } else if (cur.pit() + 1 < int(paragraphs().size())) { ++cur.pit(); setCursor(cur, cur.pit(), x2pos(cur.pit(), 0, x)); } - + cur.x_target() = x; } diff --git a/src/text3.C b/src/text3.C index 479216bda0..d65d24bf45 100644 --- a/src/text3.C +++ b/src/text3.C @@ -458,7 +458,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.undispatched(); } break; - + case LFUN_ENDBUFSEL: if (cur.size() == 1) { if (!cur.selection()) @@ -784,7 +784,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) lyxerr << _("Unknown spacing argument: ") << cmd.argument << endl; } - if (cur_spacing != new_spacing || cur_value != new_value) + if (cur_spacing != new_spacing || cur_value != new_value) par.params().spacing(Spacing(new_spacing, new_value)); break; } @@ -905,8 +905,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) break; case LFUN_GETXY: - cur.message(tostr(cursorX(cur.top())) + ' ' - + tostr(cursorY(cur.top()))); + cur.message(convert(cursorX(cur.top())) + ' ' + + convert(cursorY(cur.top()))); break; case LFUN_SETXY: { @@ -1153,7 +1153,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) int const wh = bv->workHeight(); int const y = std::max(0, std::min(wh - 1, cmd.y)); - + setCursorFromCoordinates(cur, cmd.x, y); cur.x_target() = cmd.x; if (cmd.y >= wh) @@ -1176,7 +1176,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) bvcur.selection() = true; lyxerr << "MOTION: " << bv->cursor() << endl; } - + } else cur.undispatched(); break; @@ -1338,7 +1338,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) //cur.nextInset()->edit(cur, true); } break; - + // passthrough hat and underscore outside mathed: case LFUN_SUBSCRIPT: mathDispatch(cur, FuncRequest(LFUN_SELFINSERT, "_"), false); @@ -1486,7 +1486,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) InsetBase & inset = cur.inset(); bool const accept = !inset.forceDefaultParagraphs(&inset); - data = "update " + tostr(accept) + '\n' + data; + data = "update " + convert(accept) + '\n' + data; bv->owner()->getDialogs().update("paragraph", data); break; } diff --git a/src/toc.C b/src/toc.C index 9e06fc52ea..42141c3dc2 100644 --- a/src/toc.C +++ b/src/toc.C @@ -43,14 +43,14 @@ string const TocItem::asString() const void TocItem::goTo(LyXView & lv_) const { - string const tmp = tostr(id_); + string const tmp = convert(id_); lv_.dispatch(FuncRequest(LFUN_GOTO_PARAGRAPH, tmp)); } FuncRequest TocItem::action() const { - return FuncRequest(LFUN_GOTO_PARAGRAPH, tostr(id_)); + return FuncRequest(LFUN_GOTO_PARAGRAPH, convert(id_)); } -- 2.39.2