]> git.lyx.org Git - features.git/commitdiff
tostr -> convert and some bformat work
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 6 Jan 2005 15:40:49 +0000 (15:40 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 6 Jan 2005 15:40:49 +0000 (15:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9446 a592a061-630c-0410-9148-cb99ea01b6c8

77 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/LaTeX.C
src/MenuBackend.C
src/Spacing.C
src/buffer.C
src/bufferparams.C
src/bufferview_funcs.C
src/counters.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/ControlSpellchecker.C
src/frontends/controllers/ControlTabularCreate.C
src/frontends/gtk/ChangeLog
src/frontends/gtk/GGraphics.C
src/frontends/gtk/GParagraph.C
src/frontends/gtk/GPrint.C
src/frontends/gtk/GSpellchecker.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/QBox.C
src/frontends/qt2/QDocument.C
src/frontends/qt2/QExternal.C
src/frontends/qt2/QGraphics.C
src/frontends/qt2/QParagraph.C
src/frontends/qt2/QTabular.C
src/frontends/qt2/QVSpace.C
src/frontends/qt2/QWrap.C
src/frontends/qt2/qt_helpers.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/ColorHandler.C
src/frontends/xforms/FontInfo.C
src/frontends/xforms/FormBox.C
src/frontends/xforms/FormColorpicker.C
src/frontends/xforms/FormExternal.C
src/frontends/xforms/FormFiledialog.C
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormParagraph.C
src/frontends/xforms/FormPrint.C
src/frontends/xforms/FormSpellchecker.C
src/frontends/xforms/FormWrap.C
src/frontends/xforms/XFormsMenubar.C
src/frontends/xforms/xforms_helpers.C
src/graphics/ChangeLog
src/graphics/GraphicsConverter.C
src/graphics/PreviewLoader.C
src/insets/ChangeLog
src/insets/ExternalTransforms.C
src/insets/insetbibitem.C
src/insets/insetexternal.C
src/insets/insetfloat.C
src/insets/insetinclude.C
src/insets/insettabular.C
src/insets/insetwrap.C
src/lyxfind.C
src/lyxfunc.C
src/lyxrc.C
src/output_docbook.C
src/paragraph.C
src/rowpainter.C
src/sgml.C
src/support/ChangeLog
src/support/filetools.C
src/support/lstrings.C
src/support/lstrings.h
src/support/tempname.C
src/support/tostr.C
src/support/tostr.h
src/tabular.C
src/tex-accent.C
src/tex2lyx/ChangeLog
src/tex2lyx/text.C
src/text.C
src/text2.C
src/text3.C
src/toc.C

index 08d3e03a6e31667d56a3c0354bfb4d6359ed940d..e76eaf3052af1385e0e7a23c6ba38dded5e9dde2 100644 (file)
@@ -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);
 }
index 10e6a6481c96492e4b3a40f5dacaf767949b11b5..213d911a3ef774574f9a55a88452cbe0e62df22a 100644 (file)
@@ -1,16 +1,49 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * 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  <j.spitzmueller@gmx.de>
 
        * 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
index 8609c3ed53dc20f92c5167fc0305b71f8574d928..92ee3ac0ce78b8dc2e26167052383621268954af 100644 (file)
@@ -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<string>(i)
                        + ".aux";
                FileInfo fi(file2);
                if (!fi.exist())
index 294599d1cf3e0042c23799418b6aea525c7b3c9b..d57a1292a101483075c5cafa9afb59584e111643 100644 (file)
@@ -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<string>(ii) + ". "
                        + MakeDisplayPath((*lfit), 30)
-                       + '|' + tostr(ii);
+                       + '|' + convert<string>(ii);
                tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))), view);
        }
 }
 
+
 void expandDocuments(Menu & tomenu, LyXView const * view)
 {
        typedef vector<string> 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<string>(ii) + ". " + label + '|' + convert<string>(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<string>(shortcut_count + 1)) != string::npos)
+                                       label += '|' + convert<string>(++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<string>(shortcut_count + 1)) != string::npos)
+                                       label += '|' + convert<string>(++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<string>(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<string>(ii) + ". " + label + "|" + convert<string>(ii);
                tomenu.add(MenuItem(MenuItem::Command, label,
                                    FuncRequest(LFUN_INSERT_BRANCH,
                                                cit->getBranch())), view);
index bc9ec91ca5c8743a49eb7e5b3bdddfcc7a804058..c4fcdb1edddedee8902a7b9e2b3f0769b450e2d2 100644 (file)
@@ -51,7 +51,7 @@ double Spacing::getValue() const
 
 void Spacing::set(Spacing::Space sp, float val)
 {
-       set(sp, tostr(val));
+       set(sp, convert<string>(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;
                }
        }
index c2b4e9a29e1819c16a19d8329f4e2f5616ab49be..4e58256a87bc50d981f51242280fff63556373a5 100644 (file)
@@ -630,7 +630,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename, pit_type const pit)
                        return false;
                }
                command += " -t"
-                       + tostr(LYX_FORMAT)
+                       + convert<string>(LYX_FORMAT)
                        + " -o " + tmpfile + ' '
                        + QuoteName(filename);
                lyxerr[Debug::INFO] << "Running '"
index d1734695812aba9fd0d22d85095a1fc9b7ccd880..c8f659b6e1eedc9983402418f5cf89b08e1295bf 100644 (file)
@@ -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<string>(use_geometry)
           << "\n\\use_amsmath " << use_amsmath
           << "\n\\cite_engine " << citeenginetranslator().find(cite_engine)
-          << "\n\\use_bibtopic " << tostr(use_bibtopic)
+          << "\n\\use_bibtopic " << convert<string>(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<string>(tracking_changes) << "\n";
 
        if (tracking_changes) {
                AuthorList::Authors::const_iterator it = pimpl_->authorlist.begin();
index 0576f55b9680cdbc2a73aa8d1c3d1d87d8751284..d4dbfe353a9151bb0495da61d822b55da608c039 100644 (file)
@@ -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<string>(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())
index 82be8664f0177a7c79ca178f5244efc26f49eeb3..7f65d86af9452050f9387388f6111e718260821d 100644 (file)
@@ -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<string>(value(ctr));
 }
 
 
index 527c1c5491d24590c5f8e638c3e850038791b432..d9c4f73e2099fc488f88d4ad0ac3e1be18641bf7 100644 (file)
@@ -1,3 +1,11 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * ControlTabularCreate.C (dispatchParams):
+       * ControlSpellchekcer.C (showSummary):
+       * ControlPrint.C (dispatchParams):
+       * ControlGraphics.C (readBB):
+       * ControlExternal.C (readBB): tostr -> convert
+
 2004-12-17  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * ControlMath.C: fixed Ångström, Ørsted.
index 9c6a251b14f9d1079bbdf38ad59ab1b9e32d2a40..6e64ea1d13978b84f78aca069db67b123791dd9d 100644 (file)
@@ -189,7 +189,7 @@ string const ControlExternal::readBB(string const & file)
                }
        }
 
-       return ("0 0 " + tostr(width) + ' ' + tostr(height));
+       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
 }
 
 } // namespace frontend
index a7a46506b61a3e3182561a6d07ab627c14141bcc..a0cda6f91fc4fd3630de4b5dfdd24b0b1bd20cbe 100644 (file)
@@ -125,7 +125,7 @@ string const ControlGraphics::readBB(string const & file)
                }
        }
 
-       return ("0 0 " + tostr(width) + ' ' + tostr(height));
+       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
 }
 
 
index bd2344d8af29b09545c17918185c8df58457cf48..53f3678efb51bd29b1fbd27669ac8d56ed08eee1 100644 (file)
@@ -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<string>(pp.from_page);
                if (pp.to_page) {
                        // we have a range "from-to"
                        command += '-'
-                               + tostr(pp.to_page);
+                               + convert<string>(pp.to_page);
                }
                command += ' ';
        }
@@ -117,7 +117,7 @@ void ControlPrint::dispatchParams()
                        command += lyxrc.print_copies_flag;
                }
                command += ' '
-                       + tostr(pp.count_copies)
+                       + convert<string>(pp.count_copies)
                        + ' ';
        }
 
index 2efe8ed93d22496717d826c0b804e12fcda1ef24..6bbb8e51ea2e44fa0bfef623969eb8ee3acf3238 100644 (file)
@@ -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.");
 
index c51a9abd17359761c46dc87736029cebb62dd380..f2d026e30ac4e65e1463fd9b67629503d3bbfad6 100644 (file)
@@ -43,7 +43,7 @@ void ControlTabularCreate::clearParams()
 
 void ControlTabularCreate::dispatchParams()
 {
-       string data = tostr(params().first) + ' ' + tostr(params().second);
+       string data = convert<string>(params().first) + ' ' + convert<string>(params().second);
        kernel().dispatch(FuncRequest(LFUN_TABULAR_INSERT, data));
 }
 
index 4ef76371fbb813ede2475d19707cfb6929d97ecc..4123144369dc49920c4e1ac790307cc49fbeffe9 100644 (file)
@@ -1,7 +1,15 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * GParagraph.C: drop unused include tostr.h
+
+       * GSpellchecker.C:
+       * GPrint.C:
+       * GGraphics.C (apply): tostr -> convert
+
 2005-01-04  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * xftFontLoader.C: lyxrc.font_sizes is a string now.
-       
+
        * lyx_gui.C: change getDVI() to int.
 
 2005-01-04  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
 2004-12-08  John Spray  <spray_john@users.sourceforge.net>
 
-       * 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  <spray_john@users.sourceforge.net>
 
-       * 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
index 54bb6f8fe44f438a94f89cb25cd4bc0be3e88e19..5728c9af2c12acdf6a7c9e11e1a95c552199a83d 100644 (file)
@@ -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<string>(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<string>(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);
index 18cbd44774920391ad3b6e197c7a59d326525784..cb9b37025b1e6002c66bf564039a3f8d1bde0d38 100644 (file)
 #include "ParagraphParameters.h"
 #include "Spacing.h"
 #include "support/lstrings.h"
-#include "support/tostr.h"
 
 using std::string;
 
+
 namespace lyx {
 
 namespace frontend {
index db3b2399eff43b8efaf14ccb957d3c0ce6d0b97a..079cbf5a5d23a80bd4de9ad0c383823810426f10 100644 (file)
@@ -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<string>(pp.from_page) : string() );
+       string const to   = ( pp.to_page   ? convert<string>(pp.to_page)   : string() );
        fromEntry_->set_text(from);
        toEntry_->set_text(to);
        odd_->set_active(pp.odd_pages);
index ebb5d8295fad26394a3f648409d68e1435239697..685542e49c235279580edc6967b2f88eff06beb9 100644 (file)
@@ -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<string>(progress) + "% " + _("checked"));
        }
 }
 
index 1cb174c62e2a7b6f3d8d62d99c699e4cccec555a..0176107e67805f08a50202355a8434ab31873b5c 100644 (file)
@@ -1,6 +1,19 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * 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  <j.spitzmueller@gmx.de>
 
-       * QDocument.C: 
+       * QDocument.C:
        * QParagraph.C: store all float/double values as strings.
 
 2005-01-05  Lars Gullik Bjonnes  <larsbj@gullik.net>
index bdc1529ae4929732437502966930146dd68946f3..291d990686a2fcdb69ce32e46f82b5ebb537d2ac 100644 (file)
@@ -29,7 +29,6 @@
 #include "insets/insetbox.h"
 
 #include "support/lstrings.h"
-#include "support/tostr.h"
 
 #include <qpushbutton.h>
 #include <qlineedit.h>
@@ -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;
index 4c77698888d9af513128d1fa4fc9abe294582dd8..181f9c7bcc484e2320d211d1dfa1264d6574a36b 100644 (file)
@@ -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;
        }
index 2aff4929c80ed8b8e76337abfa7a4d501ca9eb3d..4d8fd2d6e6254d0576687b6c19d75b1cebadb8b1 100644 (file)
@@ -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<string>(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<string>(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<string>(bbox.xl)));
+       ybED.setText(toqstr(convert<string>(bbox.yb)));
+       xrED.setText(toqstr(convert<string>(bbox.xr)));
+       ytED.setText(toqstr(convert<string>(bbox.yt)));
 }
 
 
index 63aed8835cd8196138a3923721c67bf0e133d370..45d44e3880d5094a90162b81da87a9a464c57185 100644 (file)
@@ -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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(rotAngle);
        }
 
        // save the latex name for the origin. If it is the default
index a6c27203be8d99d2777cb402c515ddf87c3c77ad..31ecfb3fc3e6096f3fe1c7a97cb5ad87442697ec 100644 (file)
@@ -21,8 +21,6 @@
 #include "controllers/ControlParagraph.h"
 #include "controllers/helper_funcs.h"
 
-#include "support/tostr.h"
-
 #include <qbuttongroup.h>
 #include <qcheckbox.h>
 #include <qcombobox.h>
index 4f851221f9512118a22610ec0f8b3b5221059a2f..bc25e7b897fcf3f7febd730b31b983f372b136f0 100644 (file)
@@ -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<string>(row + 1)));
+       dialog_->tabularColumnED->setText(toqstr(convert<string>(col + 1)));
 
        bool const multicol(tabular.isMultiColumn(cell));
 
index d9b59c8345d1deaebe46f33374a9625699098f31..91fdb0074f9d11611f6873d922806bc7b1f78d97 100644 (file)
@@ -31,7 +31,6 @@
 #include "controllers/helper_funcs.h"
 
 #include "support/lstrings.h"
-#include "support/tostr.h"
 
 #include <qcombobox.h>
 #include <qlineedit.h>
index 967c125ad107fbc773d59e1fad14aa1b8f474b18..413dd043c8ab27a617d13d647a55e1b4fd72c05f 100644 (file)
@@ -88,7 +88,8 @@ void QWrap::apply()
 namespace {
 
 string const numtostr(double val) {
-       string a(tostr(val));
+       string a(convert<string>(val));
+#warning Will this test ever trigger? (Lgb)
        if (a == "0")
                a.erase();
        return a;
index f35c89fa2867bf6040363fbe0ae10998bbb00c8d..d12e3fc134c7cde71a070c4592fc7f5776b3cec7 100644 (file)
@@ -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<string>(LyXLength(len).value())));
        }
 }
 
index 834c02402ad460dc9d7a42dab861ab80f4415e42..ea6cc1f3d9dab8c5b173f3c0e22f1a2051076e29 100644 (file)
@@ -1,6 +1,21 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * 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  <j.spitzmueller@gmx.de>
 
-       * FormDocument.C: 
+       * FormDocument.C:
        * FormParagraph.C: store all float/double values as strings.
 
 2005-01-05  Lars Gullik Bjonnes  <larsbj@gullik.net>
index e4309fe78cfc488c685d859807984f6ab73ecc18..a43bc9036f5cb3878ab4e3a1454403bbfa73f666 100644 (file)
@@ -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<string>(col.red),
+                              ::convert<string>(col.green),
+                              ::convert<string>(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<string>(closest_pixel)) << endl;
 
                val.foreground = cmap[closest_pixel].pixel;
        }
index 13a7d5ab0e6c42185383d5a6dcd95f5d8f44be0d..6fae730671bd9f9eca05b0266c6a31f74e612625 100644 (file)
@@ -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<string>(size));
        return ret;
 }
 
index 0c90df376e1bb007918c11664a2352cd4be4d812..2bf22abeebf1da219b10e98c6a2fbb7213349176 100644 (file)
@@ -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<string>(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<string>(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) {
index 7a23f9f01ab059a4403b52d548d22ddf6eef094f..90f93e9c5178af2cb7e139dd4bbdecfc1ab11d5b 100644 (file)
@@ -39,7 +39,7 @@ enum GuiColors {
 
 string const fillLabel(RGBColor const & rgb)
 {
-       return tostr(rgb.r) + ", " + tostr(rgb.g) + ", " + tostr(rgb.b);
+       return convert<string>(rgb.r) + ", " + convert<string>(rgb.g) + ", " + convert<string>(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<string>(h) + ", " + convert<string>(s) + ", " + convert<string>(v);
 }
 
 } // namespace anon
index fb1de73f1164eff96cfd313f6f2cc6c1e8c1912b..b3b8070a299df6ca8e19649491a349e31eb5af74 100644 (file)
@@ -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<string>(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<string>(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<string>(bbox.xl).c_str());
+       fl_set_input(ybED, convert<string>(bbox.yb).c_str());
+       fl_set_input(xrED, convert<string>(bbox.xr).c_str());
+       fl_set_input(ytED, convert<string>(bbox.yt).c_str());
 }
 
 
index cd54ca947c3aeb837b39e08c9a4604496d4ad4d3..d2e8bd601ae23f11f37834a26b9e2c4feb5bdb6a 100644 (file)
@@ -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<string>(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<string>(int(ID));
 }
 
+
 // local instances
 UserCache lyxUserCache;
 GroupCache lyxGroupCache;
index 1b6430a7c760138f35a6993324b9549bec008c1d..77d17cb5b3ff9bd6a393bbc26f7bc5fad157690e 100644 (file)
@@ -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<string>(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<string>(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);
index f2128a43a4cd6f3a8fda086b52d937c45e9f9b68..29fffa227a26c04ac03d4eb0d25f2850dc2672b3 100644 (file)
@@ -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, "");
index 48d38d464bd744ae796e8e2e474b7644365250a4..f67946fb4d0fceabd42028bd779f09fcf3c7ea4a 100644 (file)
@@ -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<string>(pp.from_page) : string() );
+       string const to   = ( pp.to_page   ? convert<string>(pp.to_page)   : string() );
        fl_set_input(dialog_->input_from_page, from.c_str());
        fl_set_input(dialog_->input_to_page, to.c_str());
 
index 4f51c8d6640a88b1d6334e6e518bb527f4acb07c..1eba6cf52e0b637b8b3f276cd10a7b32b1d7f971 100644 (file)
@@ -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<string>(progress) + " %";
 
                fl_set_slider_bounds(dialog_->slider_progress, 0.0, total);
                fl_set_slider_value(dialog_->slider_progress, wordcount);
index 37788f02026d9c819649869f947be8d485c44de9..85ea19a6b12954518ba3e6b37c8368090116c618 100644 (file)
@@ -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<string>(len.value()).c_str());
        fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
 
        if (params.placement.empty())
index 31aaac9475bef07ca9aed992bc8029d9fccbe71b..c6ea81a5ce1246973720794298f30691ce6409a0 100644 (file)
@@ -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<string>(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<string>(action_count + action_offset);
                                lyxerr[Debug::GUI] << "Action: \""
                                                   << item.func().action
                                                   << "(" << item.func().argument
index 50fb6409d4fb85485fd65cbb49a8008bd56552fa..f5a4e19a0e4373a23dc590e65c0ba663fb922abe 100644 (file)
@@ -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<string>(len.value()).c_str());
 
                // Set the choice to the desired unit, if present in the choice.
                // Else set the choice to the default unit.
index 78b1d44352adabecbc62dc13491e55d8fd5dde6d..8166642e0291b5852c41088448184edd4ba11dc7 100644 (file)
@@ -1,3 +1,7 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * PreviewLoader.C (unique_filename): tostr -> convert
+
 2005-01-04  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * PreviewLoader.C: lyxrc.preview_scale_factor is a string now.
index 7810eff5dc99dee8c54ac0296d6b2b7c4a4ff2c7..cc013e773aeb037b69c2bf2990240307b480ce1b 100644 (file)
@@ -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<string>(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<string>(counter++);
        string const to_base = tempName(string(), tmp);
        unlink(to_base);
 
index 2b1890338287b7ed52e2c0935de1446321329218..04d63ea334268cfa72b88e0e85cd3c323a14c987 100644 (file)
@@ -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<string>(theCounter++) + "lyxpreview";
        return support::AddName(bufferpath, filename);
 }
 
index 8f7c9f48214fd8eb9b5d3b6c07edd7d3ad16528d..a73f5cdf1869bde817c64cba9409ccfd29e46a37 100644 (file)
@@ -1,3 +1,13 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * insetwrap.C:
+       * insettabular.C:
+       * insetinclude.C:
+       * insetfloat.C:
+       * insetexternal.C:
+       * insetbibitem.C:
+       * ExternalTransforms.C (adjAngle): tostr -> convert
+
 2005-01-05  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * inset.[Ch] (forceDefaultParagraphs): delete since it is same as
index 7d645df7a3946770a0deca37209a19e601d86c69..19670f087f33bf92c599f5b2e47531739e5b16ef 100644 (file)
@@ -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<string>(rotAngle);
        }
        return angle;
 }
index 1fd1b6304cc05ae7f162a59813fcefe5a5f832c9..74e3f29fae19ed49178b392b6388e6ed4cb44d3f 100644 (file)
@@ -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<string>(++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<string>(counter) : getOptions();
 }
 
 
index 9c14a299848375695e4dff87a77e369afce4bc70..6fc0e5e05c5d55a0890a0f6c32ff97e7379d0523 100644 (file)
@@ -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<string>(lyxscale) << '\n';
 
        if (draft)
                os << "\tdraft\n";
index cf506c945cebbe956a52655175daf2767a6bc5f9..aaa87eca6a11e2033222d1d1a6c3c6234ecb8f3e 100644 (file)
@@ -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<string>(toclist[name].size() + 1)
                                + ". " + pit->asString(buf, false);
                        lyx::toc::TocItem const item(pit->id(), 0 , str);
                        toclist[name].push_back(item);
index bd11f6874b1c204064017961fd06c5b67711e39b..a887ba9f4efd8b2238fbe43719777474da53eefc 100644 (file)
@@ -87,7 +87,7 @@ namespace {
 string const uniqueID()
 {
        static unsigned int seed = 1000;
-       return "file" + tostr(++seed);
+       return "file" + convert<string>(++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<string>(params_.preview()) << '\n';
 }
 
 
index 6ad7025498922f71eb75d234babe4a8a306b1ca9..f8cae34e8a11f0e420f33d8beacd9ec432ee5288 100644 (file)
@@ -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)
index 3b3a82c1c8228fe66e9c22a827d8d65e368a1cce..486f933f2c05fe14092b499c869e71623d3a01d7 100644 (file)
@@ -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<string>(toclist[name].size() + 1)
                                + ". " + tmp->asString(buf, false);
                        lyx::toc::TocItem const item(tmp->id(), 0 , str);
                        toclist[name].push_back(item);
index 769aa2c44c6ec65ba5c2e943be3ad5076fa60872..5d23c8297699b6a5983c9a25921a547fd223653c 100644 (file)
@@ -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<string>(replace_count);
                        str += _(" strings have been replaced.");
                        lv->message(str);
                }
index 1fe53cce62daae8cb5bb5b0ded2c0656c2ce1e6f..e5eb20d52ad12c1c2b4f4e0cb783556905571003 100644 (file)
@@ -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<string>(++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<string>(newfile_number) +
                                    ".lyx");
                        fi.newFile(filename);
                }
index 7128115c3de7996ef947f67f33a67fd3f78b48d6..9ff530103082b6cc3522cf2b0177053518bfcfbd 100644 (file)
@@ -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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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<string>(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:
index ead3b3cc31d11edb5c9c5bc35d2202cc61a8717f..825914f77990be20a42e6a6271532d94350c0df3 100644 (file)
@@ -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());
index b33ebcfdd983e593de32b00ae3ae330a1fe9d69f..b1a9a60f826163e2e79ad46ffe1829df46fb10fb 100644 (file)
@@ -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 << "<![CDATA[";
 }
 
@@ -1868,4 +1868,3 @@ void Paragraph::dump() const
 //void draw(PainterInfo & pi, int x, int y, LyXText & text) const
 //{
 //}
-
index 3f9994d10110da8f5a8915fba9c1dcd24adaa962..b807d3361ae95e9c99708acf8bd6d8742f2a7999 100644 (file)
@@ -515,7 +515,7 @@ void RowPainter::paintFirst()
                                        } else {
                                                spacing_val = buffer.params().spacing().getValue();
                                        }
-#warning Look is this correct?                                 
+#warning Look is this correct?
                                        int const labeladdon = int(font_metrics::maxHeight(font) * layout->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) {
index 9d159f4d7a32981ef4fca6601b0c522275a9ea4e..c10e8d81f77a393429096aaaa58ae4603b46cdc3 100644 (file)
@@ -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<string>(++seed);
 }
 
 
@@ -172,9 +172,9 @@ string cleanID(Buffer const & buf, OutputParams const & runparams, std::string c
                }
        }
        if (mangle) {
-               content += "-" + tostr(mangleID++);
+               content += "-" + convert<string>(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<string>(i));
                } else {
                        attribute = param;
                }
index 487246b6178d541b083febd7583ee53861da2d6f..db6f478951d6a311a33e6027c9d748ff0477743b 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * 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  <leeming@lyx.org>
 
        * os_win32.C (external_path, internal_path): s/MAX_PATH/PATH_MAX/.
index 7f3a6c5e96a4937211defcf564ad8462a1cc6649..4b29034661b3e84e5c6df4810061214b1299bf4c 100644 (file)
@@ -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<string>(count++);
        if (mkdir(tmpfl, 0777)) {
                lyxerr << "LyX could not create the temporary directory '"
                       << tmpfl << "'" << endl;
index dae295717c8d423a7d52ab4168c0190195990fd6..1c60dd4c8f701357024d29aca84113a49a2f6dea 100644 (file)
 
 #include <boost/tokenizer.hpp>
 #include <boost/assert.hpp>
+
+#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
+#if USE_BOOST_FORMAT
 #include <boost/format.hpp>
+#endif
+#endif
 
 #include <cctype>
 #include <cstdlib>
@@ -544,20 +549,7 @@ vector<string> const getVectorFromString(string const & str,
 #else
        boost::char_separator<char> sep(delim.c_str());
        boost::tokenizer<boost::char_separator<char> > tokens(str, sep);
-#ifndef USE_INCLUDED_STRING
        return vector<string>(tokens.begin(), tokens.end());
-#else
-       vector<string> vec;
-       using boost::tokenizer;
-       using boost::char_separator;
-
-       tokenizer<char_separator<char> >::iterator it = tokens.begin();
-       tokenizer<char_separator<char> >::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<string> 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>(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<string>(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<string>(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<string>(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<string>(arg1));
+       str = subst(str, "%2$d", convert<string>(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
index 7d371266e327ac143cb1e26b10b4c78841c0b018..ab75fd6202e11565d7fea1939f8f5525bb5d4929 100644 (file)
@@ -185,18 +185,53 @@ std::vector<std::string> const getVectorFromString(std::string const & str,
 std::string const getStringFromVector(std::vector<std::string> 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 <boost/format.hpp>
+
+template<class Arg1>
+string bformat(string const & fmt, Arg1 arg1)
+{
+       return (boost::format(fmt) % arg1).str();
+}
+
+
+template<class Arg1, class Arg2>
+string bformat(string const & fmt, Arg1 arg1, Arg2 arg2)
+{
+       return (boost::format(fmt) % arg1 % arg2).str();
+}
+
+
+template<class Arg1, class Arg2, class Arg3>
+string bformat(string const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3)
+{
+       return (boost::format(fmt) % arg1 % arg2 % arg3).str();
+}
+
+
+template<class Arg1, class Arg2, class Arg3, class Arg4>
+string bformat(string const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
+{
+       return (boost::format(fmt) % arg1 % arg2 % arg3 % arg4).str();
+}
+
+#else
+
+template <class Arg1>
+std::string bformat(std::string const & fmt, Arg1);
+
+template <class Arg1, class Arg2>
+std::string bformat(std::string const & fmt, Arg1, Arg2);
+
+template <class Arg1, class Arg2, class Arg3>
+std::string bformat(std::string const & fmt, Arg1, Arg2, Arg3);
+
+template <class Arg1, class Arg2, class Arg3, class Arg4>
+std::string bformat(std::string const & fmt, Arg1, Arg2, Arg3, Arg4);
+
+#endif
 
 } // namespace support
 } // namespace lyx
index d80e3b9795f7a2fd4f69233773bb506206b37e05..420231207684d55a86b45bdfcedc35d75f799e26 100644 (file)
@@ -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<string>(getpid());
        tmpfl += "XXXXXX";
 
        // The supposedly safe mkstemp version
index d490413f849c261e7991b317df684d36c7acf09c..c137dbb6279c16ab976e9a47976d3251a82e2e16 100644 (file)
 
 #include <config.h>
 
-#include <boost/lexical_cast.hpp>
+#include "tostr.h"
 
+#include <boost/lexical_cast.hpp>
 
 using boost::lexical_cast;
 
 using std::string;
 
 
-string const tostr(bool b)
+template<>
+string convert<string>(bool b)
 {
        return (b ? "true" : "false");
 }
 
 
-string const tostr(unsigned int i)
+template<>
+string convert<string>(char c)
 {
-       return lexical_cast<string>(i);
+       return string(1, c);
 }
 
 
-string const tostr(long int i)
+template<>
+string convert<string>(short unsigned int sui)
 {
-       return lexical_cast<string>(i);
+       return lexical_cast<string>(sui);
 }
 
 
-string const tostr(double d)
+template<>
+string convert<string>(int i)
 {
-       return lexical_cast<string>(d);
+       return lexical_cast<string>(i);
 }
 
 
-string const tostr(int i)
+template<>
+string convert<string>(unsigned int ui)
 {
-       return lexical_cast<string>(i);
+       return lexical_cast<string>(ui);
 }
 
 
-string const tostr(string const & s)
+template<>
+string convert<string>(float f)
 {
-       return s;
+       return lexical_cast<string>(f);
 }
 
 
-string const tostr(long unsigned int i)
+template<>
+string convert<string>(double d)
 {
-       return lexical_cast<string>(i);
+       return lexical_cast<string>(d);
 }
index 2e362d91999ab3957d23d8e91cf74f7f89df5c1b..93e1f9a943cedb10831a7459bc39e485751ad9bf 100644 (file)
@@ -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.
  *
 #ifndef TOSTR_H
 #define TOSTR_H
 
+#include <boost/static_assert.hpp>
+
 #include <string>
 
-/// 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 <class Target, class Source>
+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<std::string>(bool);
+
+template<>
+std::string convert<std::string>(char);
+
+template<>
+std::string convert<std::string>(unsigned short);
+
+template<>
+std::string convert<std::string>(int);
+
+template<>
+std::string convert<std::string>(unsigned int);
+
+template<>
+std::string convert<std::string>(float);
+
+template<>
+std::string convert<std::string>(double);
+
+template<>
+std::string convert<std::string>(std::string);
 
 #endif
index 9655a5c50899fab606c4de83cc170306991a001d..02ddbd7e4645ff6487d2c68c62931177f40f1dde 100644 (file)
@@ -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<string>(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<string>(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<string>(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.
index 59b0d1778ccef3af5c95ce05e76ec44438764bf7..8b7f74067289c45f62eb25ad7939f02effb45179 100644 (file)
@@ -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<string>(c), accent);
 }
index f8315f85667ee5e2d7323241f45aa4e779f40431..45dbfea54f6b23a986c7ee09e5a3d1684bbfe981 100644 (file)
@@ -1,3 +1,7 @@
+2005-01-06  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * text.C: tostr -> convert
+
 2005-01-06  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * Spacing.h: adapt dummy file to the changes in src/Spacing.h.
index 1002b99b4b7014b97bbbc36cbd32b9d56525db9c..d1bd74209f8af934fefbd92c041fd315f2ad0234 100644 (file)
@@ -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<string>(is_starred)
                   << "\nsideways false"
                   << "\nstatus open\n\n";
                parse_text_in_inset(p, os, FLAG_END, outer, parent_context);
index ed8801ee0013af162b552dad43080e1b77d8fecd..dc94664fe5ef81e5b1d0e57c58d60299217ab794 100644 (file)
@@ -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);
index 44e897db0fae661c17a8c4ec35b665381cc095fd..0ffd04c0f6bdb9a77efd5f85dc9a75220fa5c189 100644 (file)
@@ -1184,7 +1184,7 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const
                const_cast<LyXText *>(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;
 }
 
index 479216bda0e7a5cb9a2ee772cb7c523960b4570b..d65d24bf45419004436274a5bd87877bdde20b43 100644 (file)
@@ -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<string>(cursorX(cur.top())) + ' '
+                         + convert<string>(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<string>(accept) + '\n' + data;
                bv->owner()->getDialogs().update("paragraph", data);
                break;
        }
index 9e06fc52eae051531aaa7067d05a12c46560dbe8..42141c3dc2f29c027069fc88b3467a7aec7cf861 100644 (file)
--- 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<string>(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<string>(id_));
 }