]> git.lyx.org Git - lyx.git/commitdiff
Introduce wide streams. This fixes the remaining problems of plain text
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 11 Oct 2006 19:40:50 +0000 (19:40 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 11 Oct 2006 19:40:50 +0000 (19:40 +0000)
export (e.g. the ToC) and the navigate menu.

* src/insets/insetbase.h
(InsetBase::plaintext): output to a docstream
(InsetBase::textString): ditto

* src/mathed/TextPainter.h
(TextPainter::show): ditto

* src/support/docstream.[Ch] New file and string streams for
docstring. The file streams convert to UTF8 on the fly.

* many more files: Adjust to the changes above

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15301 a592a061-630c-0410-9148-cb99ea01b6c8

112 files changed:
development/scons/scons_manifest.py
src/CutAndPaste.C
src/CutAndPaste.h
src/MenuBackend.C
src/TocBackend.C
src/TocBackend.h
src/cursor.C
src/frontends/LyXView.C
src/frontends/gtk/GToc.C
src/frontends/qt3/QToc.C
src/frontends/qt3/QToc.h
src/frontends/qt4/QToc.C
src/frontends/qt4/TocModel.C
src/insets/insetbase.C
src/insets/insetbase.h
src/insets/insetbibitem.C
src/insets/insetbibitem.h
src/insets/insetbibtex.C
src/insets/insetbibtex.h
src/insets/insetbox.C
src/insets/insetbox.h
src/insets/insetbranch.C
src/insets/insetbranch.h
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetcharstyle.C
src/insets/insetcharstyle.h
src/insets/insetcite.C
src/insets/insetcite.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloat.C
src/insets/insetfloatlist.C
src/insets/insetfloatlist.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insethfill.C
src/insets/insethfill.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetline.C
src/insets/insetline.h
src/insets/insetnewline.C
src/insets/insetnewline.h
src/insets/insetnote.C
src/insets/insetnote.h
src/insets/insetoptarg.C
src/insets/insetoptarg.h
src/insets/insetpagebreak.C
src/insets/insetpagebreak.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insetspace.C
src/insets/insetspace.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/insets/insetvspace.C
src/insets/insetvspace.h
src/insets/insetwrap.C
src/insets/render_button.C
src/insets/render_button.h
src/lyxfunc.C
src/mathed/InsetFormulaMacro.C
src/mathed/InsetFormulaMacro.h
src/mathed/InsetMathCommand.C
src/mathed/InsetMathCommand.h
src/mathed/InsetMathGrid.C
src/mathed/InsetMathHull.C
src/mathed/InsetMathHull.h
src/mathed/InsetMathNest.C
src/mathed/InsetMathRef.C
src/mathed/InsetMathRef.h
src/mathed/TextPainter.C
src/mathed/TextPainter.h
src/output.C
src/output.h
src/output_latex.C
src/output_plaintext.C
src/output_plaintext.h
src/paragraph.C
src/paragraph.h
src/paragraph_pimpl.C
src/support/Makefile.am
src/support/docstream.C [new file with mode: 0644]
src/support/docstream.h [new file with mode: 0644]
src/support/lstrings.C
src/support/lstrings.h
src/tabular.C
src/tabular.h
src/text.C
src/toc.C
src/toc.h

index 1cdaee1103274aaa1ff4d125a8c375e3e5abc25c..fc4ca8fb46154bfb7a641eb7486406f1d314734c 100644 (file)
@@ -96,6 +96,7 @@ src_support_header_files = Split('''
     copied_ptr.h
     cow_ptr.h
     debugstream.h
+    docstream.h
     docstring.h
     environment.h
     filefilterlist.h
@@ -134,6 +135,7 @@ src_support_files = Split('''
     chdir.C
     convert.C
     copy.C
+    docstream.C
     docstring.C
     environment.C
     filefilterlist.C
index 20c3f85bd8e252d7e7edb9e704a910b6b5ace7ff..2a5b52b9fb2c7302d154a4b608c01000203b87a2 100644 (file)
@@ -48,6 +48,7 @@
 
 #include <boost/tuple/tuple.hpp>
 
+using lyx::docstring;
 using lyx::pos_type;
 using lyx::pit_type;
 using lyx::textclass_type;
@@ -456,9 +457,9 @@ void switchBetweenClasses(textclass_type c1, textclass_type c2,
 }
 
 
-std::vector<string> const availableSelections(Buffer const & buffer)
+std::vector<docstring> const availableSelections(Buffer const & buffer)
 {
-       vector<string> selList;
+       vector<docstring> selList;
 
        CutStack::const_iterator cit = theCuts.begin();
        CutStack::const_iterator end = theCuts.end();
@@ -466,13 +467,14 @@ std::vector<string> const availableSelections(Buffer const & buffer)
                // we do not use cit-> here because gcc 2.9x does not
                // like it (JMarc)
                ParagraphList const & pars = (*cit).first;
-               string asciiSel;
+               docstring asciiSel;
                ParagraphList::const_iterator pit = pars.begin();
                ParagraphList::const_iterator pend = pars.end();
                for (; pit != pend; ++pit) {
                        asciiSel += pit->asString(buffer, false);
                        if (asciiSel.size() > 25) {
-                               asciiSel.replace(22, string::npos, "...");
+                               asciiSel.replace(22, docstring::npos,
+                                                lyx::from_ascii("..."));
                                break;
                        }
                }
@@ -614,11 +616,11 @@ void copySelection(LCursor & cur)
 }
 
 
-std::string getSelection(Buffer const & buf, size_t sel_index)
+docstring getSelection(Buffer const & buf, size_t sel_index)
 {
        return sel_index < theCuts.size()
                ? theCuts[sel_index].first.back().asString(buf, false)
-               : string();
+               : docstring();
 }
 
 
index 10e5a80c3def8dda551fb008033d594b6a248f5c..0b09ca8df22881a33d5be2ad1ce44f3e1a83450a 100644 (file)
@@ -16,9 +16,8 @@
 
 #include "ParagraphList_fwd.h"
 
-#include "support/types.h"
+#include "support/docstring.h"
 
-#include <string>
 #include <vector>
 
 class Buffer;
@@ -32,11 +31,11 @@ namespace lyx {
 namespace cap {
 
 ///
-std::vector<std::string> const availableSelections(Buffer const & buffer);
+std::vector<lyx::docstring> const availableSelections(Buffer const & buffer);
 ///
 lyx::size_type numberOfSelections();
 ///
-std::string getSelection(Buffer const & buffer, size_t sel_index);
+lyx::docstring getSelection(Buffer const & buffer, size_t sel_index);
 
 ///
 void cutSelection(LCursor & cur, bool doclear, bool realcut);
index c099129f156357341997245deb88fb3843b228ed..9bf73f70080bf58ce048a73c035544a98460ebba 100644 (file)
@@ -417,9 +417,9 @@ public:
        }
 };
 
-string const limit_string_length(string const & str)
+docstring const limit_string_length(docstring const & str)
 {
-       string::size_type const max_item_length = 45;
+       docstring::size_type const max_item_length = 45;
 
        if (str.size() > max_item_length)
                return str.substr(0, max_item_length - 3) + "...";
@@ -436,7 +436,7 @@ void expandLastfiles(Menu & tomenu)
        int ii = 1;
 
        for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
-               docstring const label = convert<docstring>(ii) + lyx::from_ascii(". ")
+               docstring const label = convert<docstring>(ii) + ". "
                        + makeDisplayPath((*lfit), 30)
                        + char_type('|') + convert<docstring>(ii);
                tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))));
@@ -461,7 +461,7 @@ void expandDocuments(Menu & tomenu)
        for (; docit != end; ++docit, ++ii) {
                docstring label = makeDisplayPath(*docit, 20);
                if (ii < 10)
-                       label = convert<docstring>(ii) + lyx::from_ascii(". ") + label + char_type('|') + convert<docstring>(ii);
+                       label = convert<docstring>(ii) + ". " + label + char_type('|') + convert<docstring>(ii);
                tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, *docit)));
        }
 }
@@ -512,7 +512,7 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
                                label = _("Plain Text as Lines");
                        else if ((*fit)->name() == "textparagraph")
                                label = _("Plain Text as Paragraphs");
-                       label += lyx::from_ascii("...");
+                       label += "...";
                        break;
                case MenuItem::ViewFormats:
                case MenuItem::ExportFormats:
@@ -623,7 +623,7 @@ void expandToc2(Menu & tomenu,
        if (to - from <= max_number_of_items) {
                for (lyx::toc::Toc::size_type i = from; i < to; ++i) {
                        docstring label(4 * max(0, toc_list[i].depth() - depth), char_type(' '));
-                       label += lyx::from_utf8(limit_string_length(toc_list[i].str()));
+                       label += limit_string_length(toc_list[i].str());
                        if (toc_list[i].depth() == depth
                            && shortcut_count < 9) {
                                if (label.find(convert<docstring>(shortcut_count + 1)) != docstring::npos)
@@ -641,12 +641,12 @@ void expandToc2(Menu & tomenu,
                                ++new_pos;
 
                        docstring label(4 * max(0, toc_list[pos].depth() - depth), ' ');
-                       label += lyx::from_utf8(limit_string_length(toc_list[pos].str()));
+                       label += limit_string_length(toc_list[pos].str());
                        if (toc_list[pos].depth() == depth &&
                            shortcut_count < 9) {
                                if (label.find(convert<docstring>(shortcut_count + 1)) != docstring::npos)
                                        label += char_type('|') + convert<docstring>(++shortcut_count);
-                               }
+                       }
                        if (new_pos == pos + 1) {
                                tomenu.add(MenuItem(MenuItem::Command,
                                                    label, FuncRequest(toc_list[pos].action())));
@@ -691,7 +691,7 @@ void expandToc(Menu & tomenu, Buffer const * buf)
                lyx::toc::Toc::const_iterator ccit = cit->second.begin();
                lyx::toc::Toc::const_iterator eend = cit->second.end();
                for (; ccit != eend; ++ccit) {
-                       docstring const label = lyx::from_utf8(limit_string_length(ccit->str()));
+                       docstring const label = limit_string_length(ccit->str());
                        menu->add(MenuItem(MenuItem::Command,
                                           label,
                                           FuncRequest(ccit->action())));
@@ -719,14 +719,14 @@ void expandPasteRecent(Menu & tomenu, Buffer const * buf)
        if (!buf)
                return;
 
-       vector<string> const sel =
+       vector<docstring> const sel =
                lyx::cap::availableSelections(*buf);
 
-       vector<string>::const_iterator cit = sel.begin();
-       vector<string>::const_iterator end = sel.end();
+       vector<docstring>::const_iterator cit = sel.begin();
+       vector<docstring>::const_iterator end = sel.end();
 
        for (unsigned int index = 0; cit != end; ++cit, ++index) {
-               tomenu.add(MenuItem(MenuItem::Command, lyx::from_utf8(*cit),
+               tomenu.add(MenuItem(MenuItem::Command, *cit,
                                    FuncRequest(LFUN_PASTE, convert<string>(index))));
        }
 }
@@ -745,7 +745,7 @@ void expandBranches(Menu & tomenu, Buffer const * buf)
        for (int ii = 1; cit != end; ++cit, ++ii) {
                docstring label = lyx::from_utf8(cit->getBranch());
                if (ii < 10)
-                       label = convert<docstring>(ii) + lyx::from_ascii(". ") + label + char_type('|') + convert<docstring>(ii);
+                       label = convert<docstring>(ii) + ". " + label + char_type('|') + convert<docstring>(ii);
                tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
                                    FuncRequest(LFUN_BRANCH_INSERT,
                                                cit->getBranch())));
index ad885cdf80a2acf3e7eadb06fe6b05403db35b13..d7eb1250b8d8f7a9621a02e849784f1dc632eefb 100644 (file)
@@ -33,6 +33,8 @@
 
 #include <iostream>
 
+using lyx::docstring;
+
 using std::vector;
 using std::max;
 using std::ostream;
@@ -46,7 +48,7 @@ namespace lyx {
 // TocBackend::Item implementation
 
 TocBackend::Item::Item(ParConstIterator const & par_it, int d,
-                                          std::string const & s)
+               docstring const & s)
                : par_it_(par_it), depth_(d), str_(s)
 {
 /*
@@ -96,15 +98,15 @@ int const TocBackend::Item::depth() const
 }
 
 
-std::string const & TocBackend::Item::str() const
+docstring const & TocBackend::Item::str() const
 {
        return str_;
 }
 
 
-string const TocBackend::Item::asString() const
+docstring const TocBackend::Item::asString() const
 {
-       return string(4 * depth_, ' ') + str_;
+       return docstring(4 * depth_, ' ') + str_;
 }
 
 
@@ -163,7 +165,7 @@ void TocBackend::update()
        for (; pit != end; ++pit) {
 
                // the string that goes to the toc (could be the optarg)
-               string tocstring;
+               docstring tocstring;
 
                // For each paragraph, traverse its insets and look for
                // FLOAT_CODE or WRAP_CODE
@@ -184,8 +186,9 @@ void TocBackend::update()
                                        break;
                                Paragraph const & par = *static_cast<InsetOptArg*>(it->inset)->paragraphs().begin();
                                if (!pit->getLabelstring().empty())
-                                       tocstring = pit->getLabelstring()
-                                               + ' ';
+                                       // FIXME UNICODE
+                                       tocstring = lyx::from_utf8(
+                                               pit->getLabelstring() + ' ');
                                tocstring += par.asString(*buffer_, false);
                                break;
                        }
@@ -245,7 +248,7 @@ TocBackend::TocIterator const TocBackend::item(std::string const & type, ParCons
 }
 
 
-void TocBackend::asciiTocList(string const & type, ostream & os) const
+void TocBackend::asciiTocList(string const & type, lyx::odocstream & os) const
 {
        TocList::const_iterator cit = tocs_.find(type);
        if (cit != tocs_.end()) {
index 1c7308dc4e63308bce866a762a9be91734fce91c..a2643e82add6b822edce4569dab9d2dba7e69f15 100644 (file)
@@ -51,7 +51,7 @@ public:
                Item(
                        ParConstIterator const & par_it = ParConstIterator(),
                        int d = -1,
-                       std::string const & s = std::string());
+                       lyx::docstring const & s = lyx::docstring());
                ///
                ~Item() {}
                ///
@@ -61,9 +61,9 @@ public:
                ///
                int const depth() const;
                ///
-               std::string const & str() const;
+               lyx::docstring const & str() const;
                ///
-               std::string const asString() const;
+               lyx::docstring const asString() const;
                /// set cursor in LyXView to this Item
                void goTo(LyXView & lv_) const;
                /// the action corresponding to the goTo above
@@ -77,7 +77,7 @@ public:
                int depth_;
 
                /// Full item string
-               std::string str_;
+               lyx::docstring str_;
        };
 
        ///
@@ -109,7 +109,7 @@ public:
        /// Return the first Toc Item before the cursor
        TocIterator const item(std::string const & type, ParConstIterator const &);
 
-       void asciiTocList(std::string const & type, std::ostream & os) const;
+       void asciiTocList(std::string const & type, lyx::odocstream & os) const;
 
 private:
        /// 
index fb66b06f54e39ebfc96350013255ef47eea69855..a2990d05bec560986cd35e1bcaf07b6230747d25 100644 (file)
@@ -1129,10 +1129,10 @@ docstring LCursor::selectionAsString(bool label) const
                size_t const endpos = selEnd().pos();
 
                if (startpit == endpit)
-                       return lyx::from_utf8(pars[startpit].asString(buffer, startpos, endpos, label));
+                       return pars[startpit].asString(buffer, startpos, endpos, label);
 
                // First paragraph in selection
-               string result = pars[startpit].
+               docstring result = pars[startpit].
                        asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
 
                // The paragraphs in between (if any)
@@ -1144,7 +1144,7 @@ docstring LCursor::selectionAsString(bool label) const
                // Last paragraph in selection
                result += pars[endpit].asString(buffer, 0, endpos, label);
 
-               return lyx::from_utf8(result);
+               return result;
        }
 
        if (inMathed())
index 9598c5fbe19636ec2a2d5e327df6ce37a13d1588..5199a14f0f2758b7bfc2f45bb3febeda6d851882 100644 (file)
@@ -347,7 +347,7 @@ void LyXView::updateWindowTitle()
        if (view()->buffer()) {
                string const cur_title = buffer()->fileName();
                if (!cur_title.empty()) {
-                       maximize_title += lyx::from_ascii(": ") + makeDisplayPath(cur_title, 30);
+                       maximize_title += ": " + makeDisplayPath(cur_title, 30);
                        minimize_title = lyx::from_utf8(onlyFilename(cur_title));
                        if (!buffer()->isClean()) {
                                maximize_title += _(" (changed)");
index 417ddb186b27d0eb88cb3d9ac14b744a577615b2..5486c748c37d4861a8019a3c4e35eebb69fc9547 100644 (file)
@@ -157,7 +157,7 @@ void GToc::updateContents()
 
        for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
                Gtk::ListStore::iterator row = tocstore_->append();
-               (*row)[listCol_] = cit->asString();
+               (*row)[listCol_] = lyx::to_utf8(cit->asString());
                (*row)[listColIndex_] = rowindex;
        }
        changing_views_ = false;
index 0d35533166a594635039f8c9cc089d518f9c6d94..d189a4c0db9937daf898caae1ab876e339265536 100644 (file)
@@ -154,7 +154,7 @@ void QToc::updateToc(int newdepth)
 
                lyxerr[Debug::GUI]
                        << "Table of contents\n"
-                       << "Added item " << iter->str()
+                       << "Added item " << lyx::to_utf8(iter->str())
                        << " at depth " << iter->depth()
                        << ", previous sibling \""
                        << (last ? fromqstr(last->text(0)) : "0")
@@ -193,8 +193,10 @@ bool QToc::canOutline()
 }
 
 
-void QToc::select(string const & text)
+void QToc::select(string const & t)
 {
+       // FIXME UNICODE
+       docstring const text = lyx::from_utf8(t);
        toc::Toc::const_iterator iter = toclist.begin();
 
        for (; iter != toclist.end(); ++iter) {
@@ -204,7 +206,7 @@ void QToc::select(string const & text)
 
        if (iter == toclist.end()) {
                lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry: "
-                       << text << endl;
+                       << t << endl;
                return;
        }
 
index 769bc9a766a9d8249b16af7db734780d25f7b9a6..0d828d2549fd99cdffa9a12eda90443dabc15901 100644 (file)
@@ -69,7 +69,7 @@ private:
        int depth_;
 
        /// Store selected item's string
-       std::string text_;
+       lyx::docstring text_;
 
        /// Store ToC list type
        std::string type_;
index 4d3b332cedace6f2f6652206e7b942d5937084b7..57965fb538f2e6a79eba2ed3ad1855c5c93aa5e3 100644 (file)
@@ -99,7 +99,7 @@ void QToc::goTo(QModelIndex const & index)
        TocIterator const it = toc_models_[type_]->tocIterator(index);
        
        lyxerr[Debug::GUI]
-               << "QToc::goTo " << it->str()
+               << "QToc::goTo " << lyx::to_utf8(it->str())
                << endl;
 
        it->goTo(kernel().lyxview());
index 72fce8f1a6011f5cf66c36d4299906fa5e9538c6..570631cf2ac551cf60680e34d0688add8ac02c88 100644 (file)
@@ -101,7 +101,7 @@ void TocModel::populate(TocBackend::Toc const & toc)
 
                        lyxerr[Debug::GUI]
                                << "Toc: at depth " << iter->depth()
-                               << ", added item " << iter->str()
+                               << ", added item " << lyx::to_utf8(iter->str())
                                << endl;
 
                        populate(iter, end, top_level_item);
index 9551300a6fdc12bc4d14f68cccad8025320f44d0..7cef1778c865733dafe79cec9e24b6f3019ecb06 100644 (file)
@@ -221,7 +221,7 @@ bool InsetBase::idxUpDown(LCursor &, bool) const
 
 
 int InsetBase::plaintext(Buffer const &,
-       std::ostream &, OutputParams const &) const
+       lyx::odocstream &, OutputParams const &) const
 {
        return 0;
 }
index 62ec6a50256356419927a4dee68cfe8f021f6fb2..08232c3e4b6ea4c88972237ad5a5aa9fccd8e2ad 100644 (file)
 #ifndef INSETBASE_H
 #define INSETBASE_H
 
-#include "support/docstring.h"
+#include "support/docstream.h"
 
 #include <memory>
-#include <string>
 #include <vector>
 
 class Buffer;
@@ -186,14 +185,14 @@ public:
        /// describe content if cursor behind
        virtual void infoize2(std::ostream &) const {}
 
-       /// plain ascii output
-       virtual int plaintext(Buffer const &, std::ostream & os,
+       /// plain text output in ucs4 encoding
+       virtual int plaintext(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        /// docbook output
        virtual int docbook(Buffer const &, std::ostream & os,
                OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream &,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const { return 0; };
 
        /** This enum indicates by which means the inset can be modified:
index f81d02e456f6cf16e9bf4d8b07eafbaa52465d14..e40cf508083345bd3b9dc2e5bc3f696b982a8259 100644 (file)
@@ -114,18 +114,23 @@ void InsetBibitem::read(Buffer const &, LyXLex & lex)
 }
 
 
-string const InsetBibitem::getBibLabel() const
+docstring const InsetBibitem::getBibLabel() const
 {
-       return getOptions().empty() ? convert<string>(counter) : getOptions();
+       // FIXME UNICODE
+       return getOptions().empty() ?
+               convert<docstring>(counter) :
+               lyx::from_utf8(getOptions());
 }
 
 
-string const InsetBibitem::getScreenLabel(Buffer const &) const
+docstring const InsetBibitem::getScreenLabel(Buffer const &) const
 {
-       return getContents() + " [" + getBibLabel() + ']';
+       // FIXME UNICODE
+       return lyx::from_utf8(getContents()) + " [" + getBibLabel() + ']';
 }
 
-int InsetBibitem::plaintext(Buffer const &, ostream & os,
+
+int InsetBibitem::plaintext(Buffer const &, lyx::odocstream & os,
                            OutputParams const &) const
 {
        os << '[' << getCounter() << "] ";
@@ -134,7 +139,7 @@ int InsetBibitem::plaintext(Buffer const &, ostream & os,
 
 
 // ale070405
-string const bibitemWidest(Buffer const & buffer)
+docstring const bibitemWidest(Buffer const & buffer)
 {
        int w = 0;
        // Does look like a hack? It is! (but will change at 0.13)
@@ -149,11 +154,10 @@ string const bibitemWidest(Buffer const & buffer)
 
        for (; it != end; ++it) {
                if (it->bibitem()) {
-                        string const label = it->bibitem()->getBibLabel();
-                        docstring const dlab(label.begin(), label.end());
+                       docstring const label = it->bibitem()->getBibLabel();
                     
                        int const wx =
-                               fm.width(dlab);
+                               fm.width(label);
                        if (wx > w) {
                                w = wx;
                                bitem = it->bibitem();
@@ -164,5 +168,5 @@ string const bibitemWidest(Buffer const & buffer)
        if (bitem && !bitem->getBibLabel().empty())
                return bitem->getBibLabel();
 
-       return "99";
+       return lyx::from_ascii("99");
 }
index 250b8f3c08cab157704df4daed9d7240f9c75bdd..d98ae8f8a2cf123fdd68640a0a307f353aadcc9d 100644 (file)
@@ -31,7 +31,7 @@ public:
        ///
        void read(Buffer const &, LyXLex & lex);
        ///
-       virtual std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -43,9 +43,9 @@ public:
        ///
        int getCounter() const { return counter; }
        ///
-       std::string const getBibLabel() const;
+       lyx::docstring const getBibLabel() const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                      OutputParams const &) const;
 protected:
        ///
@@ -61,6 +61,6 @@ private:
 
 
 /// Return the widest label in the Bibliography.
-std::string const bibitemWidest(Buffer const &);
+lyx::docstring const bibitemWidest(Buffer const &);
 
 #endif // INSET_BIBITEM_H
index 7f5e2dc84c4fd5925cf6395b3f7bf1e5c068f7c0..13e0cc78240779317cf8385628ae08d6bec47570 100644 (file)
@@ -36,6 +36,7 @@
 #include <fstream>
 #include <sstream>
 
+using lyx::docstring;
 using lyx::support::absolutePath;
 using lyx::support::ascii_lowercase;
 using lyx::support::changeExtension;
@@ -102,10 +103,9 @@ void InsetBibtex::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
-string const InsetBibtex::getScreenLabel(Buffer const &) const
+docstring const InsetBibtex::getScreenLabel(Buffer const &) const
 {
-       // FIXME UNICODE
-       return lyx::to_utf8(_("BibTeX Generated Bibliography"));
+       return _("BibTeX Generated Bibliography");
 }
 
 
index 4daf8f589fff4b0c9179c2bdb9a8bb386290b05c..09ba9816f806a162f26b54d6de5e8beb6bd7e897 100644 (file)
@@ -23,7 +23,7 @@ public:
        ///
        InsetBibtex(InsetCommandParams const &);
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index e570d456b876a1bd93162792e9f362c13a545615..c87311d5e0cc90b1c6b010a16d0def60e4b719bd 100644 (file)
@@ -381,7 +381,7 @@ int InsetBox::docbook(Buffer const & buf, std::ostream & os,
 }
 
 
-int InsetBox::plaintext(Buffer const & buf, std::ostream & os,
+int InsetBox::plaintext(Buffer const & buf, lyx::odocstream & os,
                    OutputParams const & runparams) const
 {
        BoxType const btype = boxtranslator().find(params_.type);
index 577878c7520e8fa11f2be9f246628eb4c269a088..c3ff251896ca9be5f75a06c1fef8f4ab23015ba4 100644 (file)
@@ -88,7 +88,7 @@ public:
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const & runparams) const;
        ///
        void validate(LaTeXFeatures &) const;
index 0948e52f08037ab8bef3fa5aa54e3b08a20a05f2..fd3932db6483b84602ce43cbe2bec146a5a69ea4 100644 (file)
@@ -236,7 +236,7 @@ int InsetBranch::docbook(Buffer const & buf, std::ostream & os,
 }
 
 
-int InsetBranch::plaintext(Buffer const & buf, std::ostream & os,
+int InsetBranch::plaintext(Buffer const & buf, lyx::odocstream & os,
                           OutputParams const & runparams) const
 {
        return isBranchSelected(buf) ?
index 490e02b73a3989cba797d9d9051dcdf8316fa183..65e2310fb6938f47c3902cb8f56392572d4590c9 100644 (file)
@@ -59,7 +59,7 @@ public:
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const & runparams) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const & runparams) const;
        ///
        void validate(LaTeXFeatures &) const;
index 3b8818faaa242bb5bd7340c3ebb1d09f3e45a7a1..0638430c70ef38b89a57eacf2d9bd7af34ca6cd6 100644 (file)
@@ -191,7 +191,7 @@ int InsetCaption::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetCaption::plaintext(Buffer const & /*buf*/,ostream & /*os*/,
+int InsetCaption::plaintext(Buffer const & /*buf*/, lyx::odocstream & /*os*/,
                        OutputParams const & /*runparams*/) const
 {
        // FIXME: Implement me!
index 19e564be2c1342ff53a75ce2510f33fde66313f3..3b57d832c80f986b1746dbe4de34effd3842bcc8 100644 (file)
@@ -51,7 +51,7 @@ public:
        virtual int latex(Buffer const & buf, std::ostream & os,
                          OutputParams const &) const;
        ///
-       int plaintext(Buffer const & buf, std::ostream & os,
+       int plaintext(Buffer const & buf, lyx::odocstream & os,
                  OutputParams const & runparams) const;
        ///
        int docbook(Buffer const & buf, std::ostream & os,
index d509beb1ea3bb32f91ce3159280adf53883a1519..88039d98982973edb5c84da27024f2850516bc1d 100644 (file)
@@ -306,14 +306,14 @@ int InsetCharStyle::docbook(Buffer const & buf, ostream & os,
 }
 
 
-int InsetCharStyle::plaintext(Buffer const & buf, ostream & os,
+int InsetCharStyle::plaintext(Buffer const & buf, lyx::odocstream & os,
                              OutputParams const & runparams) const
 {
        return InsetText::plaintext(buf, os, runparams);
 }
 
 
-int InsetCharStyle::textString(Buffer const & buf, ostream & os,
+int InsetCharStyle::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 23b27a3e3c1d8e660ed405ac24965627a376f78a..92583eea9ffd3e53c5544832aa7ca7321ca2ab58 100644 (file)
@@ -77,10 +77,10 @@ public:
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
index 7cf1151a5a1a9e45efd779b458104d6bd4072de7..1d8a16cf4b6c22ff95d09d6f19c498eee4eead2b 100644 (file)
@@ -30,6 +30,7 @@
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/exception.hpp>
 
+using lyx::docstring;
 using lyx::support::ascii_lowercase;
 using lyx::support::contains;
 using lyx::support::getStringFromVector;
@@ -305,7 +306,7 @@ InsetCitation::InsetCitation(InsetCommandParams const & p)
 {}
 
 
-string const InsetCitation::generateLabel(Buffer const & buffer) const
+docstring const InsetCitation::generateLabel(Buffer const & buffer) const
 {
        string const before = getSecOptions();
        string const after  = getOptions();
@@ -322,11 +323,12 @@ string const InsetCitation::generateLabel(Buffer const & buffer) const
                label = getBasicLabel(getContents(), after);
        }
 
-       return label;
+       // FIXME UNICODE
+       return lyx::from_utf8(label);
 }
 
 
-string const InsetCitation::getScreenLabel(Buffer const & buffer) const
+docstring const InsetCitation::getScreenLabel(Buffer const & buffer) const
 {
        biblio::CiteEngine const engine = biblio::getEngine(buffer);
        if (cache.params == params() && cache.engine == engine)
@@ -336,11 +338,11 @@ string const InsetCitation::getScreenLabel(Buffer const & buffer) const
        string const before = getSecOptions();
        string const after  = getOptions();
 
-       string const glabel = generateLabel(buffer);
+       docstring const glabel = generateLabel(buffer);
 
        unsigned int const maxLabelChars = 45;
 
-       string label = glabel;
+       docstring label = glabel;
        if (label.size() > maxLabelChars) {
                label.erase(maxLabelChars-3);
                label += "...";
@@ -355,7 +357,8 @@ string const InsetCitation::getScreenLabel(Buffer const & buffer) const
 }
 
 
-int InsetCitation::plaintext(Buffer const & buffer, ostream & os, OutputParams const &) const
+int InsetCitation::plaintext(Buffer const & buffer, lyx::odocstream & os,
+                             OutputParams const &) const
 {
        if (cache.params == params() &&
            cache.engine == biblio::getEngine(buffer))
@@ -395,7 +398,7 @@ int InsetCitation::docbook(Buffer const &, ostream & os, OutputParams const &) c
 }
 
 
-int InsetCitation::textString(Buffer const & buf, ostream & os,
+int InsetCitation::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index c5bc0d207c0ac428cbde3497be1a9dba4a98e22d..b66947db36859e51af9cbd933328f773f9c264fe 100644 (file)
@@ -25,13 +25,13 @@ public:
        ///
        InsetCitation(InsetCommandParams const &);
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
        InsetBase::Code lyxCode() const { return InsetBase::CITE_CODE; }
        ///
-       int plaintext(Buffer const &, std::ostream &, OutputParams const &) const;
+       int plaintext(Buffer const &, lyx::odocstream &, OutputParams const &) const;
        ///
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
@@ -39,7 +39,7 @@ public:
        int docbook(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
@@ -53,7 +53,7 @@ private:
        }
 
        /// This function does the donkey work of creating the pretty label
-       std::string const generateLabel(Buffer const &) const;
+       lyx::docstring const generateLabel(Buffer const &) const;
 
        class Cache {
        public:
@@ -64,9 +64,9 @@ private:
                ///
                InsetCommandParams params;
                ///
-               std::string generated_label;
+               lyx::docstring generated_label;
                ///
-               std::string screen_label;
+               lyx::docstring screen_label;
        };
        ///
        mutable Cache cache;
index 272a9c1af8d3c31bfc499d6468de26b8e089fba5..59c9c0a7fa2dbc242d0ba6745e958c2c872f2ebb 100644 (file)
@@ -78,7 +78,7 @@ int InsetCommand::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetCommand::plaintext(Buffer const &, ostream &,
+int InsetCommand::plaintext(Buffer const &, lyx::odocstream &,
                        OutputParams const &) const
 {
        return 0;
index beb0c6a5562e7a2c68da08ce7b5084f71028fc15..42edb946da1fa27fcf8dc70b954ebb63615b71af 100644 (file)
@@ -50,7 +50,7 @@ public:
        virtual int latex(Buffer const &, std::ostream &,
                          OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        virtual int docbook(Buffer const &, std::ostream &,
@@ -107,7 +107,7 @@ protected:
        ///
        void setParams(InsetCommandParams const &);
        /// This should provide the text for the button
-       virtual std::string const getScreenLabel(Buffer const &) const = 0;
+       virtual lyx::docstring const getScreenLabel(Buffer const &) const = 0;
 
 private:
        ///
index f6a9342204c6fb67bbef6375408aa3e4074ece27..32358d130d86b540b9d5663c25f5e31cf351f633 100644 (file)
@@ -170,7 +170,7 @@ int InsetERT::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetERT::plaintext(Buffer const &, ostream &,
+int InsetERT::plaintext(Buffer const &, lyx::odocstream &,
                    OutputParams const & /*runparams*/) const
 {
        return 0;
index bcfe8615129fdf1d286f52f0fbe067bb62550fed..801f4e4a44fae6d7295375581f4344880d19f77d 100644 (file)
@@ -52,7 +52,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const & runparams) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index f597932fd7da666479658c2a49033f16d7b73120..59f4c6322d21403254d92f0b31542343ae0eb295 100644 (file)
@@ -49,6 +49,7 @@ namespace support = lyx::support;
 namespace external = lyx::external;
 namespace graphics = lyx::graphics;
 
+using lyx::docstring;
 using std::endl;
 using std::string;
 using std::auto_ptr;
@@ -569,16 +570,18 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
 }
 
 
-string const getScreenLabel(InsetExternalParams const & params,
+docstring const getScreenLabel(InsetExternalParams const & params,
                            Buffer const & buffer)
 {
        external::Template const * const ptr =
                external::getTemplatePtr(params);
        if (!ptr)
                // FIXME UNICODE
-               return lyx::to_utf8(support::bformat(_("External template %1$s is not installed"),
-                                       lyx::from_utf8(params.templatename())));
-       return external::doSubstitution(params, buffer, ptr->guiName, false);
+               return support::bformat((_("External template %1$s is not installed")),
+                                       lyx::from_utf8(params.templatename()));
+       // FIXME UNICODE
+       return lyx::from_utf8(external::doSubstitution(params, buffer,
+                               ptr->guiName, false));
 }
 
 void add_preview_and_start_loading(RenderMonitoredPreview &,
@@ -715,12 +718,16 @@ int InsetExternal::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetExternal::plaintext(Buffer const & buf, ostream & os,
+int InsetExternal::plaintext(Buffer const & buf, lyx::odocstream & os,
                         OutputParams const & runparams) const
 {
-       return external::writeExternal(params_, "Ascii", buf, os,
+       std::ostringstream oss;
+       int const retval = external::writeExternal(params_, "Ascii", buf, oss,
                                       *(runparams.exportdata), false,
                                       runparams.inComment);
+       // FIXME UNICODE
+       os << lyx::from_utf8(oss.str());
+       return retval;
 }
 
 
index 7937b0c0f67c336b72000c0bf7553b79fbfed6d9..7ad563a070fb98577c6c9d31db7eec6c4fd72190 100644 (file)
@@ -126,7 +126,7 @@ public:
        virtual int latex(Buffer const &, std::ostream &,
                          OutputParams const &) const;
        ///
-       virtual int plaintext(Buffer const &, std::ostream &,
+       virtual int plaintext(Buffer const &, lyx::odocstream &,
                          OutputParams const &) const;
        ///
        virtual int docbook(Buffer const &, std::ostream &,
index b0edf66b8842fbe7ef37c08f03cc290db4aa401f..6e617210a43067c440f7302edb31d65e6aa4cfea 100644 (file)
@@ -384,10 +384,10 @@ void InsetFloat::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const
        for (; pit != end; ++pit) {
                if (pit->layout()->labeltype == LABEL_SENSITIVE) {
                        string const type = params_.type;
-                       string const str =
-                               convert<string>(toclist[type].size() + 1)
+                       docstring const str =
+                               convert<docstring>(toclist[type].size() + 1)
                                + ". " + pit->asString(buf, false);
-                       lyx::toc::TocItem const item(pit, 0 , str);
+                       lyx::toc::TocItem const item(pit, 0, str);
                        toclist[type].push_back(item);
                }
        }
index a16280888f6c84327cb737b133f47980381d497f..d7e538c18e355bb57e486aae8ea281f3c1c4a5e8 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "support/lstrings.h"
 
+using lyx::docstring;
 using lyx::support::bformat;
 
 using std::endl;
@@ -46,16 +47,14 @@ InsetFloatList::InsetFloatList(string const & type)
 }
 
 
-string const InsetFloatList::getScreenLabel(Buffer const & buf) const
+docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
 {
        FloatList const & floats = buf.params().getLyXTextClass().floats();
        FloatList::const_iterator it = floats[getCmdName()];
        if (it != floats.end())
-               // FIXME UNICODE
-               return lyx::to_utf8(buf.B_(it->second.listName()));
+               return buf.B_(it->second.listName());
        else
-               // FIXME UNICODE
-               return lyx::to_utf8(_("ERROR: Nonexistent float type!"));
+               return _("ERROR: Nonexistent float type!");
 }
 
 
@@ -128,7 +127,8 @@ int InsetFloatList::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetFloatList::plaintext(Buffer const & buffer, ostream & os, OutputParams const &) const
+int InsetFloatList::plaintext(Buffer const & buffer, lyx::odocstream & os,
+                              OutputParams const &) const
 {
        os << getScreenLabel(buffer) << "\n\n";
 
index ffb0622552881c0d56e991f6bd5bc0177d8c27be..301d14c8a08e99644adac567835e605b77662e8c 100644 (file)
@@ -24,7 +24,7 @@ public:
        ///
        InsetFloatList(std::string const & type);
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -42,7 +42,7 @@ public:
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const { return 0; }
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const & runparams) const;
        ///
        void validate(LaTeXFeatures & features) const;
index 6620a9451a0214f385d3e1e3171f1e6fdf01bad4..cceb22e3faacf5a86110d13700b0ea17bc2ac734 100644 (file)
@@ -804,7 +804,7 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetGraphics::plaintext(Buffer const &, ostream & os,
+int InsetGraphics::plaintext(Buffer const &, lyx::odocstream & os,
                         OutputParams const &) const
 {
        // No graphics in ascii output. Possible to use gifscii to convert
@@ -813,8 +813,10 @@ int InsetGraphics::plaintext(Buffer const &, ostream & os,
        // 2. Read ascii output file and add it to the output stream.
        // at least we send the filename
        // FIXME UNICODE
-       os << '<' << lyx::to_utf8(bformat(_("Graphics file: %1$s"),
-                            lyx::from_utf8(params().filename.absFilename()))) << ">\n";
+       // FIXME: We have no idea what the encoding of the filename is
+       os << '<' << bformat(_("Graphics file: %1$s"),
+                            lyx::from_utf8(params().filename.absFilename()))
+          << ">\n";
        return 0;
 }
 
index 23d8eaa96b8f8bcf3586f4914c5bb823e96dccbe..effe8489e034627b6cf19b950556975a0b5b43af 100644 (file)
@@ -46,7 +46,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index 21f9e79e709523b49be4801512e187c229a6a63b..03d7abb2fac96023692e1d0776519b2e8e4d2e8f 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "support/std_ostream.h"
 
+using lyx::docstring;
+
 using std::ostream;
 
 
@@ -37,9 +39,9 @@ void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
 }
 
 
-std::string const InsetHFill::getScreenLabel(Buffer const &) const
+docstring const InsetHFill::getScreenLabel(Buffer const &) const
 {
-       return getContents();
+       return lyx::from_ascii(getContents());
 }
 
 
@@ -51,7 +53,7 @@ int InsetHFill::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetHFill::plaintext(Buffer const &, ostream & os,
+int InsetHFill::plaintext(Buffer const &, lyx::odocstream & os,
                      OutputParams const &) const
 {
        os << '\t';
index 2aaff5240839f7263432b2fa0b69767fc6b1c93f..cd66169d102eb3eca5a0420d978008ca3176e86a 100644 (file)
@@ -22,14 +22,14 @@ public:
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        InsetBase::Code lyxCode() const { return InsetBase::HFILL_CODE; }
        ///
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const & runparams) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index 47198006c2e5858044ec46f84f78c664fc4d698b..a1a4da035d6ed3cefc92c6264ed38a23436e506f 100644 (file)
 
 #include "insets/render_preview.h"
 
-#include "support/lyxalgo.h"
 #include "support/filename.h"
 #include "support/filetools.h"
 #include "support/lstrings.h" // contains
+#include "support/lyxalgo.h"
 #include "support/lyxlib.h"
 #include "support/convert.h"
 
@@ -275,7 +275,7 @@ void InsetInclude::read(LyXLex & lex)
 }
 
 
-string const InsetInclude::getScreenLabel(Buffer const &) const
+docstring const InsetInclude::getScreenLabel(Buffer const &) const
 {
        docstring temp;
 
@@ -294,15 +294,15 @@ string const InsetInclude::getScreenLabel(Buffer const &) const
                        break;
        }
 
-       temp += lyx::from_ascii(": ");
+       temp += ": ";
 
        if (params_.getContents().empty())
-               temp += lyx::from_ascii("???");
+               temp += "???";
        else
+               // FIXME: We don't know the encoding of the filename
                temp += lyx::from_ascii(onlyFilename(params_.getContents()));
 
-       // FIXME UNICODE
-       return lyx::to_utf8(temp);
+       return temp;
 }
 
 
@@ -468,12 +468,13 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
 }
 
 
-int InsetInclude::plaintext(Buffer const & buffer, ostream & os,
+int InsetInclude::plaintext(Buffer const & buffer, lyx::odocstream & os,
                        OutputParams const &) const
 {
        if (isVerbatim(params_)) {
-               string const str =
-                       getFileContents(includedFilename(buffer, params_));
+               // FIXME: We don't know the encoding of the file
+               docstring const str = lyx::from_utf8(
+                       getFileContents(includedFilename(buffer, params_)));
                os << str;
                // Return how many newlines we issued.
                return int(lyx::count(str.begin(), str.end(), '\n'));
index 06b944b8cb1212d21f4e320d5a86fa4ecd01efed..c1e7649dd3d35cb506e98d061f2e7a7e3370e57f 100644 (file)
@@ -78,7 +78,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
@@ -106,7 +106,7 @@ private:
        /// set the parameters
        void set(InsetCommandParams const & params, Buffer const &);
        /// get the text displayed on the button
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        void write(std::ostream &) const;
        ///
index f067231148e8014d0940f646268e70b0a706f423..e9c0e6ac23ca08297bbc4235c20089f041db8908 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "support/std_ostream.h"
 
+using lyx::docstring;
+
 using std::string;
 using std::ostream;
 
@@ -34,10 +36,9 @@ InsetIndex::InsetIndex(InsetCommandParams const & p)
 // {}
 
 
-string const InsetIndex::getScreenLabel(Buffer const &) const
+docstring const InsetIndex::getScreenLabel(Buffer const &) const
 {
-       // FIXME UNICODE
-       return lyx::to_utf8(_("Idx"));
+       return _("Idx");
 }
 
 
@@ -67,10 +68,9 @@ InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
 // {}
 
 
-string const InsetPrintIndex::getScreenLabel(Buffer const &) const
+docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
 {
-       // FIXME UNICODE
-       return lyx::to_utf8(_("Index"));
+       return _("Index");
 }
 
 
index 8dc585a1577ecd60cc231488999efcea4133dc64..1a6c22cced357fa5eb16e7ff3bd37d861269b262 100644 (file)
@@ -24,7 +24,7 @@ public:
        ///
        InsetIndex(InsetCommandParams const &);
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -52,7 +52,7 @@ public:
        ///
        bool display() const { return true; }
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
 private:
        virtual std::auto_ptr<InsetBase> doClone() const {
                return std::auto_ptr<InsetBase>(new InsetPrintIndex(params()));
index b176327ca27464b6ba8512a3ebba0a5fabd83209..675bb0ace516bb0dd168cc9956d2d0d85cc976c4 100644 (file)
@@ -26,6 +26,7 @@
 #include "support/lyxalgo.h"
 #include "support/std_ostream.h"
 
+using lyx::docstring;
 using lyx::support::escape;
 
 using std::string;
@@ -50,9 +51,10 @@ void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
 }
 
 
-string const InsetLabel::getScreenLabel(Buffer const &) const
+docstring const InsetLabel::getScreenLabel(Buffer const &) const
 {
-       return getContents();
+       // FIXME UNICODE
+       return lyx::from_utf8(getContents());
 }
 
 
@@ -89,10 +91,11 @@ int InsetLabel::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetLabel::plaintext(Buffer const &, ostream & os,
+int InsetLabel::plaintext(Buffer const &, lyx::odocstream & os,
                      OutputParams const &) const
 {
-       os << '<' << getContents()  << '>';
+       // FIXME UNICODE
+       os << '<' << lyx::from_utf8(getContents()) << '>';
        return 0;
 }
 
index 112fed3222c6e01d2680586a0b4060aa08daab7e..d4ba049a31fdc81460249e2cffc4f21cceeda1fd 100644 (file)
@@ -19,7 +19,7 @@ public:
        ///
        InsetLabel(InsetCommandParams const &);
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -30,7 +30,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index 429bfbea588e15545572c600aff0e16d966f6f83..901fa926fba11dbc144c678020d0429b9f987fcb 100644 (file)
@@ -579,10 +579,10 @@ int InsetLatexAccent::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetLatexAccent::plaintext(Buffer const &, ostream & os,
+int InsetLatexAccent::plaintext(Buffer const &, lyx::odocstream & os,
                            OutputParams const &) const
 {
-       os << contents;
+       os << lyx::from_ascii(contents);
        return 0;
 }
 
@@ -595,7 +595,7 @@ int InsetLatexAccent::docbook(Buffer const &, ostream & os,
 }
 
 
-int InsetLatexAccent::textString(Buffer const & buf, ostream & os,
+int InsetLatexAccent::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 9d270e1bcf5426c01ae039c5213b570ac2dc541c..4e3fd9cc06d08c6eac5e621981d4e5e839c7b80d 100644 (file)
@@ -46,13 +46,13 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        ///
        bool directWrite() const;
index f65d1ab70caa94780b608d7687135a557c576d71..8a83f7c17c6fd1bd254fd6d6fd53bee39f71c796 100644 (file)
@@ -63,7 +63,7 @@ int InsetLine::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetLine::plaintext(Buffer const &, ostream & os,
+int InsetLine::plaintext(Buffer const &, lyx::odocstream & os,
                     OutputParams const &) const
 {
        os << "-------------------------------------------";
index 75f1475981c1d3e8d76f937062f2b3fc4389cfa6..1297b6fcc2beed63234e56bb5770c5a9a9084f80 100644 (file)
@@ -29,7 +29,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                          OutputParams const &) const;
 
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
 
        int docbook(Buffer const &, std::ostream &,
index 7b09eae190ab3466a63a6e5dff3b8d035abb3eb5..0079488fe54f1586a0f4e20f4ef71066d7c750c0 100644 (file)
@@ -57,7 +57,7 @@ int InsetNewline::latex(Buffer const &, ostream &,
 }
 
 
-int InsetNewline::plaintext(Buffer const &, ostream & os,
+int InsetNewline::plaintext(Buffer const &, lyx::odocstream & os,
                        OutputParams const &) const
 {
        os << '\n';
index 5122bbe4d9bddef081afda762f7c3a0f3e9ecb01..b8e2da897aaf8fe2a95bf37d9cd477d1262caea0 100644 (file)
@@ -29,7 +29,7 @@ public:
        virtual int latex(Buffer const &, std::ostream &,
                          OutputParams const &) const;
 
-       virtual int plaintext(Buffer const &, std::ostream &,
+       virtual int plaintext(Buffer const &, lyx::odocstream &,
                          OutputParams const &) const;
 
        virtual int docbook(Buffer const &, std::ostream &,
index a87d77f1274099cefd8eeb553246d38e0c3a9880..33916d7cae1de5830950c896c5a54dd18ed40148 100644 (file)
@@ -322,7 +322,7 @@ int InsetNote::docbook(Buffer const & buf, std::ostream & os,
 }
 
 
-int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
+int InsetNote::plaintext(Buffer const & buf, lyx::odocstream & os,
                         OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
index 02e7ba0afb5d4987fdb0dff95b7b9314f961ee4e..4fe09a452ebb1d5f1459539ba51cc9c60d083ac0 100644 (file)
@@ -63,7 +63,7 @@ public:
        int docbook(Buffer const &, std::ostream &,
               OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
               OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
index 1c4950feb7e91232f271c8aa73c9817f671542fe..7eb44dafc4c6affa4e3cfe6747ecd10d96260d31 100644 (file)
@@ -79,7 +79,7 @@ int InsetOptArg::docbook(Buffer const &, ostream &,
 }
 
 
-int InsetOptArg::plaintext(Buffer const &, ostream &,
+int InsetOptArg::plaintext(Buffer const &, lyx::odocstream &,
                       OutputParams const &) const
 {
        return 0;
index 9676c335f0300aceab28f6065292f6a5bf111b99..0454519740f45f1d346bdca1e990882e9537027b 100644 (file)
@@ -37,7 +37,7 @@ public:
                  OutputParams const &) const;
 
        /// Standard plain text output -- short-circuited
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
 
        /// Outputting the optional parameter of a LaTeX command
index 96d27662de6988a1d663e5ed4b836a3c60eaaa1d..9c55d83d885d00409a0f40d6652dcfda0737233b 100644 (file)
@@ -83,7 +83,7 @@ int InsetPagebreak::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetPagebreak::plaintext(Buffer const &, ostream & os,
+int InsetPagebreak::plaintext(Buffer const &, lyx::odocstream & os,
                          OutputParams const &) const
 {
        os << '\n';
index 95b0ec5bf5364eedf7d13dde8fb97e60763206d2..8ee273ec06a06e00385d36cdf761097ea439c0a1 100644 (file)
@@ -29,7 +29,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
 
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
 
        int docbook(Buffer const &, std::ostream &,
index de8ec480322d2a1e48adf396d0cd5ac58ed191a5..378a6e34ce97749f434c458c223b4a06972f2316 100644 (file)
@@ -301,7 +301,7 @@ int InsetQuotes::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetQuotes::plaintext(Buffer const &, ostream & os,
+int InsetQuotes::plaintext(Buffer const &, lyx::odocstream & os,
                       OutputParams const &) const
 {
        os << '"';
@@ -327,7 +327,7 @@ int InsetQuotes::docbook(Buffer const &, ostream & os,
 }
 
 
-int InsetQuotes::textString(Buffer const & buf, ostream & os,
+int InsetQuotes::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 116005f3b51e4b799384e473f40b9a94e17922a7..0d51ecfb55e4e3ff8b6585d770ac36e23abc97ab 100644 (file)
@@ -87,14 +87,14 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
 
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
 
        ///
index 11a24ffe0a52fd660bd5b332444faf58d456cbb6..4d1d4fc1ef548ac8ef3e60a85355bc00f04fe369 100644 (file)
@@ -24,6 +24,7 @@
 #include "support/lstrings.h"
 
 
+using lyx::docstring;
 using lyx::support::escape;
 
 using std::string;
@@ -62,21 +63,22 @@ void InsetRef::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
-string const InsetRef::getScreenLabel(Buffer const &) const
+docstring const InsetRef::getScreenLabel(Buffer const &) const
 {
-       string temp;
+       docstring temp;
        for (int i = 0; !types[i].latex_name.empty(); ++i) {
                if (getCmdName() == types[i].latex_name) {
-                       // FIXME UNIOCDE
-                       temp = lyx::to_utf8(_(types[i].short_gui_name));
+                       temp = _(types[i].short_gui_name);
                        break;
                }
        }
-       temp += getContents();
+       // FIXME UNIOCDE
+       temp += lyx::from_utf8(getContents());
 
        if (!isLatex && !getOptions().empty()) {
                temp += "||";
-               temp += getOptions();
+               // FIXME UNIOCDE
+               temp += lyx::from_utf8(getOptions());
        }
        return temp;
 }
@@ -95,10 +97,11 @@ int InsetRef::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetRef::plaintext(Buffer const &, ostream & os,
+int InsetRef::plaintext(Buffer const &, lyx::odocstream & os,
                    OutputParams const &) const
 {
-       os << '[' << getContents() << ']';
+       // FIXME UNIOCDE
+       os << '[' << lyx::from_utf8(getContents()) << ']';
        return 0;
 }
 
@@ -119,7 +122,7 @@ int InsetRef::docbook(Buffer const & buf, ostream & os,
 }
 
 
-int InsetRef::textString(Buffer const & buf, ostream & os,
+int InsetRef::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 1909a2e2640cd4bac82699ca50c487e9b64b1c2b..35550dde373f8fd1cf14612302bd44d8b422d0de 100644 (file)
@@ -36,7 +36,7 @@ public:
        InsetRef(InsetCommandParams const &, Buffer const &);
 
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -47,13 +47,13 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        ///
        void validate(LaTeXFeatures & features) const;
index 8ececce4e5ba2994f863fd233627840ff34d1b90..bd7faede4a1f3277319aea85fa7e79132cf899e6 100644 (file)
@@ -195,7 +195,7 @@ int InsetSpace::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetSpace::plaintext(Buffer const &, ostream & os,
+int InsetSpace::plaintext(Buffer const &, lyx::odocstream & os,
                      OutputParams const &) const
 {
        switch (kind_) {
@@ -235,7 +235,7 @@ int InsetSpace::docbook(Buffer const &, ostream & os,
 }
 
 
-int InsetSpace::textString(Buffer const & buf, ostream & os,
+int InsetSpace::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 76ec3c95c187f19de53b9b96199560d7a025d9c8..4d84e7c0c0597ced3080777e938f9ade9d56658a 100644 (file)
@@ -64,13 +64,13 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        ///
        InsetBase::Code lyxCode() const { return InsetBase::SPACE_CODE; }
index b2c01b68a820b89447b7d224f4a250255379657e..386fca533aa3c935765810a2b19d21817f555de2 100644 (file)
@@ -188,7 +188,7 @@ int InsetSpecialChar::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetSpecialChar::plaintext(Buffer const &, ostream & os,
+int InsetSpecialChar::plaintext(Buffer const &, lyx::odocstream & os,
                            OutputParams const &) const
 {
        switch (kind_) {
@@ -230,7 +230,7 @@ int InsetSpecialChar::docbook(Buffer const &, ostream & os,
 }
 
 
-int InsetSpecialChar::textString(Buffer const & buf, ostream & os,
+int InsetSpecialChar::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 8923bbdc2fd32abcb0091b7641f7744d98e51934..3606f9633ff9b403003de1563461be1fc24792de 100644 (file)
@@ -56,13 +56,13 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
        ///
        InsetBase::Code lyxCode() const { return InsetBase::SPECIALCHAR_CODE; }
index 39fc6c32f10b73cd1aa04e0084b393ce02a282c5..451b009898d6bad80699ef64bb23d3166005c859 100644 (file)
@@ -1060,7 +1060,7 @@ int InsetTabular::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetTabular::plaintext(Buffer const & buf, ostream & os,
+int InsetTabular::plaintext(Buffer const & buf, lyx::odocstream & os,
                        OutputParams const & runparams) const
 {
        int const dp = runparams.linelen ? runparams.depth : 0;
@@ -1788,10 +1788,10 @@ bool InsetTabular::copySelection(LCursor & cur)
        paste_tabular->setRightLine(paste_tabular->getLastCellInRow(0),
                                    true, true);
 
-       ostringstream os;
+       lyx::odocstringstream os;
        OutputParams const runparams;
        paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
-       theClipboard().put(lyx::from_utf8(os.str()));
+       theClipboard().put(os.str());
        // mark tabular stack dirty
        // FIXME: this is a workaround for bug 1919. Should be removed for 1.5,
        // when we (hopefully) have a one-for-all paste mechanism.
index 0532d31ad3b259088edfb639311e3122dcdcb52a..7feb753958533d6a0ccd9c5be3c5e110c141a210 100644 (file)
@@ -87,7 +87,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index 7519d91470cbd39458520c28c9091aa1e2585b57..f104bd63124de1422c2bb22bc7be3109a5014e7f 100644 (file)
@@ -268,18 +268,18 @@ int InsetText::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetText::plaintext(Buffer const & buf, ostream & os,
+int InsetText::plaintext(Buffer const & buf, lyx::odocstream & os,
                     OutputParams const & runparams) const
 {
        ParagraphList::const_iterator beg = paragraphs().begin();
        ParagraphList::const_iterator end = paragraphs().end();
        ParagraphList::const_iterator it = beg;
        bool ref_printed = false;
-       std::ostringstream oss;
+       lyx::odocstringstream oss;
        for (; it != end; ++it)
                asciiParagraph(buf, *it, oss, runparams, ref_printed);
 
-       string const str = oss.str();
+       docstring const str = oss.str();
        os << str;
        // Return how many newlines we issued.
        return int(lyx::count(str.begin(), str.end(), '\n'));
index 95c282a5587886c6d7846bee06ba0f66a448caf2..23f054e93b06d555ee3092a54a1249f11823e56e 100644 (file)
@@ -64,7 +64,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index ea06bf37e8da1518901c8c076a5b77252ce1c0d3..c08da017e20598290d13d90e0d26ab212dacbad2 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "support/std_ostream.h"
 
+using lyx::docstring;
+
 using std::string;
 using std::ostream;
 
@@ -36,12 +38,11 @@ std::auto_ptr<InsetBase> InsetTOC::doClone() const
 }
 
 
-string const InsetTOC::getScreenLabel(Buffer const &) const
+docstring const InsetTOC::getScreenLabel(Buffer const &) const
 {
-       // FIXME UNICODE
        if (getCmdName() == "tableofcontents")
-               return lyx::to_utf8(_("Table of Contents"));
-       return lyx::to_utf8(_("Unknown toc list"));
+               return _("Table of Contents");
+       return _("Unknown toc list");
 }
 
 
@@ -53,7 +54,7 @@ InsetBase::Code InsetTOC::lyxCode() const
 }
 
 
-int InsetTOC::plaintext(Buffer const & buffer, ostream & os,
+int InsetTOC::plaintext(Buffer const & buffer, lyx::odocstream & os,
                    OutputParams const &) const
 {
        os << getScreenLabel(buffer) << "\n\n";
index 6f321f462436f75812f7688471959d4048f3bb09..126f10ef812eb1470f0b6e2ae3825244f4aa8c3c 100644 (file)
@@ -21,7 +21,7 @@ public:
        ///
        explicit InsetTOC(InsetCommandParams const &);
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -29,7 +29,7 @@ public:
        ///
        bool display() const { return true; }
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index b6f5e82d78b7d8a6588d7de83f74cfe987a9e551..ffceee1cf92e2821b444d48d0e44d4295ee8c638 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "support/std_ostream.h"
 
+using lyx::docstring;
 using lyx::support::subst;
 
 using std::string;
@@ -33,14 +34,10 @@ InsetUrl::InsetUrl(InsetCommandParams const & p)
 {}
 
 
-string const InsetUrl::getScreenLabel(Buffer const &) const
+docstring const InsetUrl::getScreenLabel(Buffer const &) const
 {
-       string temp;
-       // FIXME UNICODE
-       if (getCmdName() == "url")
-               temp = lyx::to_utf8(_("Url: "));
-       else
-               temp = lyx::to_utf8(_("HtmlUrl: "));
+       docstring const temp =
+               (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
 
        string url;
 
@@ -54,7 +51,8 @@ string const InsetUrl::getScreenLabel(Buffer const &) const
                url = url.substr(0, 10) + "..."
                        + url.substr(url.length() - 17, url.length());
        }
-       return temp + url;
+       // FIXME UNICODE
+       return temp + lyx::from_utf8(url);
 }
 
 
@@ -70,13 +68,16 @@ int InsetUrl::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetUrl::plaintext(Buffer const &, ostream & os,
+int InsetUrl::plaintext(Buffer const &, lyx::odocstream & os,
                    OutputParams const &) const
 {
+       // FIXME UNICODE
+       os << '[' << lyx::from_utf8(getContents());
        if (getOptions().empty())
-               os << '[' << getContents() << ']';
+               os << ']';
        else
-               os << '[' << getContents() << "||" <<  getOptions() << ']';
+               // FIXME UNICODE
+               os << "||" << lyx::from_utf8(getOptions()) << ']';
        return 0;
 }
 
@@ -90,7 +91,7 @@ int InsetUrl::docbook(Buffer const &, ostream & os,
 }
 
 
-int InsetUrl::textString(Buffer const & buf, ostream & os,
+int InsetUrl::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 1aba7e51e3cc24754a3076ead0ec5b8331a9eea1..a509ea60e1250f17d8e7b9c8601cd12a110444b0 100644 (file)
@@ -29,7 +29,7 @@ public:
        ///
        void validate(LaTeXFeatures &) const;
        ///
-       std::string const getScreenLabel(Buffer const &) const;
+       lyx::docstring const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
@@ -38,13 +38,13 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
 private:
        virtual std::auto_ptr<InsetBase> doClone() const {
index e5cb547a9c17f11c5da84b05be429785dc224f93..65cb980c0d9d0ccae860b1f7eb167ff17d948073 100644 (file)
@@ -210,7 +210,7 @@ int InsetVSpace::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetVSpace::plaintext(Buffer const &, ostream & os,
+int InsetVSpace::plaintext(Buffer const &, lyx::odocstream & os,
                           OutputParams const &) const
 {
        os << "\n\n";
index 0aaf68e736cdf51d34c1fdaf40f8627bfc57e8a6..e96024dd434513950078664f77f338633fcfc3ab 100644 (file)
@@ -33,7 +33,7 @@ public:
        int latex(Buffer const &, std::ostream &,
                  OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                      OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
index 6cf8150a3abfa3ce2f604cf521d39fce33751d07..f3903c16d3473b8294ed94538234b092b81d0dbd 100644 (file)
@@ -233,10 +233,10 @@ void InsetWrap::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const
        for (; pit != end; ++pit) {
                if (pit->layout()->labeltype == LABEL_SENSITIVE) {
                        string const type = params_.type;
-                       string const str =
-                               convert<string>(toclist[type].size() + 1)
+                       docstring const str =
+                               convert<docstring>(toclist[type].size() + 1)
                                + ". " + pit->asString(buf, false);
-                       lyx::toc::TocItem const item(pit, 0 , str);
+                       lyx::toc::TocItem const item(pit, 0, str);
                        toclist[type].push_back(item);
                }
        }
index 16a153fcdf6f487826176e1ef7e509e178103341..ebc29bc1db88810b1bc7e4c2efe6c9e910aab3b1 100644 (file)
@@ -35,7 +35,7 @@ auto_ptr<RenderBase> RenderButton::clone(InsetBase const *) const
 }
 
 
-void RenderButton::update(string const & text, bool editable)
+void RenderButton::update(docstring const & text, bool editable)
 {
        text_ = text;
        editable_ = editable;
@@ -49,12 +49,10 @@ void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
        lyx::frontend::FontMetrics const & fm =
                theFontMetrics(font);
        
-       docstring dtext(text_.begin(), text_.end());
-        
        if (editable_)
-               fm.buttonText(dtext, dim.wid, dim.asc, dim.des);
+               fm.buttonText(text_, dim.wid, dim.asc, dim.des);
        else
-               fm.rectText(dtext, dim.wid, dim.asc, dim.des);
+               fm.rectText(text_, dim.wid, dim.asc, dim.des);
 
        dim.wid += 4;
 }
@@ -67,12 +65,10 @@ void RenderButton::draw(PainterInfo & pi, int x, int y) const
        font.setColor(LColor::command);
        font.decSize();
 
-        docstring dtext(text_.begin(), text_.end());
-        
        if (editable_) {
-               pi.pain.buttonText(x + 2, y, dtext, font);
+               pi.pain.buttonText(x + 2, y, text_, font);
        } else {
-               pi.pain.rectText(x + 2, y, dtext, font,
+               pi.pain.rectText(x + 2, y, text_, font,
                                 LColor::commandbg, LColor::commandframe);
        }
 }
index 4d805359d9e0264defd18976723bfa4efe4f82bc..5122c4e197e1d3631dbf123fe1dbf50cb614a595 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "render_base.h"
 #include "box.h"
-#include <string>
+#include "support/docstring.h"
 
 
 class RenderButton : public RenderBase
@@ -30,7 +30,7 @@ public:
        virtual void draw(PainterInfo & pi, int x, int y) const;
 
        /// Provide the text for the button
-       void update(std::string const &, bool editable);
+       void update(lyx::docstring const &, bool editable);
 
        /// The "sensitive area" box, i.e., the button area
        Box box() const { return button_box_; }
@@ -42,7 +42,7 @@ public:
 
 private:
        /// The stored data.
-       std::string text_;
+       lyx::docstring text_;
        bool editable_;
        Box button_box_;
 };
index 6d25032ddcef78d47e97ecb2dfecbf75faac38bf..b74f997c87b21e6f818fe0523249d8ee34c12106 100644 (file)
@@ -1281,7 +1281,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                makeAbsPath(argument, owner->buffer()->filePath());
                        // FIXME Should use bformat
                        setMessage(_("Opening child document ") +
-                                        makeDisplayPath(filename) + lyx::from_ascii("..."));
+                                        makeDisplayPath(filename) + "...");
                        view()->savePosition(0);
                        string const parentfilename = owner->buffer()->fileName();
                        if (theBufferList().exists(filename))
index ea9076f75f8faf1369c668c8e7b4b617c4db6bde..1c0df28003ef5f48af63335d27c765f18d547064 100644 (file)
@@ -85,7 +85,7 @@ int InsetFormulaMacro::latex(Buffer const &, ostream & os,
 }
 
 
-int InsetFormulaMacro::plaintext(Buffer const &, ostream & os,
+int InsetFormulaMacro::plaintext(Buffer const &, lyx::odocstream & os,
                             OutputParams const &) const
 {
        WriteStream wi(os, false, true);
index 8f9f46a6eb6085db5dd0a396dcff278677584081..5c0a325957a52c9befa4918acf57ba321465e573 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        void write(Buffer const &, std::ostream & os) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int latex(Buffer const &, std::ostream & os,
index d74801a34249b3a74b599f0237d2f11dd4474c1f..a001ff413292120ebc161339650ffda37c85d19f 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <sstream>
 
+using lyx::docstring;
+
 using std::string;
 using std::auto_ptr;
 using std::ostringstream;
@@ -70,9 +72,9 @@ void CommandInset::write(WriteStream & os) const
 }
 
 
-string const CommandInset::screenLabel() const
+docstring const CommandInset::screenLabel() const
 {
-       return name_;
+       return lyx::from_ascii(name_);
 }
 
 
index ab2b4875fadc20464ab9ee32d1541fd8c3265fc0..130d032a4fd748ec1f11bd68e330666f6c9cf6b9 100644 (file)
@@ -34,7 +34,7 @@ public:
        //
        // void infoize(std::ostream & os) const;
        ///
-       virtual std::string const screenLabel() const;
+       virtual lyx::docstring const screenLabel() const;
        /// generate something that will be understood by the Dialogs.
        std::string const createDialogStr(std::string const & name) const;
        ///
index 06b53ae5c45a52ce7eab45ed5f7f962ae0fbca6b..4336e0657278ab41eb31cbe0ac6bac65c2d36836 100644 (file)
@@ -1210,7 +1210,9 @@ void InsetMathGrid::doDispatch(LCursor & cur, FuncRequest & cmd)
                int n = 0;
                is >> n;
                InsetMathGrid grid(1, 1);
-               mathed_parse_normal(grid, lyx::cap::getSelection(cur.buffer(), n));
+               // FIXME UNICODE
+               mathed_parse_normal(grid,
+                       lyx::to_utf8(lyx::cap::getSelection(cur.buffer(), n)));
                if (grid.nargs() == 1) {
                        // single cell/part of cell
                        recordUndo(cur);
index c6f12f352397debe43d04ce429d990689f936bdd..927e533acb05bf8e683a496f5fa8cafc6612a89b 100644 (file)
@@ -1425,7 +1425,7 @@ void InsetMathHull::read(Buffer const &, LyXLex & lex)
 }
 
 
-int InsetMathHull::plaintext(Buffer const &, ostream & os,
+int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
                        OutputParams const &) const
 {
        if (0 && display()) {
@@ -1439,8 +1439,11 @@ int InsetMathHull::plaintext(Buffer const &, ostream & os,
                //metrics();
                return tpain.textheight();
        } else {
-               WriteStream wi(os, false, true);
+               std::ostringstream oss;
+               WriteStream wi(oss, false, true);
                wi << cell(0);
+               // FIXME UNICODE
+               os << lyx::from_utf8(oss.str());
                return wi.line();
        }
 }
@@ -1498,7 +1501,7 @@ int InsetMathHull::docbook(Buffer const & buf, ostream & os,
 }
 
 
-int InsetMathHull::textString(Buffer const & buf, ostream & os,
+int InsetMathHull::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
index 9add217f75bd819ceff0232f092752565bb0494d..08d1833d785d593c7f139bd93790d8e94c5dc1ec 100644 (file)
@@ -100,13 +100,13 @@ public:
        ///
        void read(Buffer const &, LyXLex & lex);
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
                    OutputParams const &) const;
        /// the string that is passed to the TOC
-       virtual int textString(Buffer const &, std::ostream & os,
+       virtual int textString(Buffer const &, lyx::odocstream &,
                OutputParams const &) const;
 
        /// get notification when the cursor leaves this inset
index b23dc673d7ab2cb402690711501588e44b1b8eb9..a882e0e65949b7ee1af61b0a62081ba7601ba8e9 100644 (file)
@@ -59,6 +59,7 @@
 
 #include <sstream>
 
+using lyx::docstring;
 using lyx::cap::copySelection;
 using lyx::cap::grabAndEraseSelection;
 using lyx::cap::cutSelection;
@@ -424,8 +425,9 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                size_t n = 0;
                istringstream is(lyx::to_utf8(cmd.argument()));
                is >> n;
-               string const selection = lyx::cap::getSelection(cur.buffer(), n);
-               cur.niceInsert(selection);
+               docstring const selection = lyx::cap::getSelection(cur.buffer(), n);
+               // FIXME UNICODE
+               cur.niceInsert(lyx::to_utf8(selection));
                cur.clearSelection(); // bug 393
                cur.bv().switchKeyMap();
                finishUndo();
index ac9f9726cbc8bf6ec95719102f145ae5fc76522d..e36839981f73bc05bd0325ca87d894401d8fe84c 100644 (file)
@@ -26,6 +26,8 @@
 #include "outputparams.h"
 #include "sgml.h"
 
+using lyx::docstring;
+
 using std::string;
 using std::auto_ptr;
 using std::endl;
@@ -118,16 +120,16 @@ bool RefInset::getStatus(LCursor & cur, FuncRequest const & cmd,
 }
 
 
-string const RefInset::screenLabel() const
+docstring const RefInset::screenLabel() const
 {
-       string str;
+       docstring str;
        for (int i = 0; !types[i].latex_name.empty(); ++i)
                if (commandname() == types[i].latex_name) {
-                       // FIXME UNICODE
-                       str = lyx::to_utf8(_(types[i].short_gui_name));
+                       str = _(types[i].short_gui_name);
                        break;
                }
-       str += asString(cell(0));
+       // FIXME UNICODE
+       str += lyx::from_utf8(asString(cell(0)));
 
        //if (/* !isLatex && */ !cell(0).empty()) {
        //      str += "||";
@@ -146,9 +148,10 @@ void RefInset::validate(LaTeXFeatures & features) const
 }
 
 
-int RefInset::plaintext(std::ostream & os, OutputParams const &) const
+int RefInset::plaintext(lyx::odocstream & os, OutputParams const &) const
 {
-       os << '[' << asString(cell(0)) << ']';
+       // FIXME UNICODE
+       os << '[' << lyx::from_utf8(asString(cell(0))) << ']';
        return 0;
 }
 
index daf0c8c3169ed6119bb031546134fbd209e6c491..aa23efe0934775271a5f8a2093cac4fe9230cc59 100644 (file)
@@ -28,14 +28,14 @@ public:
        ///
        void infoize(std::ostream & os) const;
        ///
-       std::string const screenLabel() const;
+       lyx::docstring const screenLabel() const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
        virtual RefInset * asRefInset() { return this; }
 
-       /// plain ascii output
-       int plaintext(std::ostream & os, OutputParams const &) const;
+       /// plain text output in ucs4 encoding
+       int plaintext(lyx::odocstream &, OutputParams const &) const;
        /// docbook output
        int docbook(Buffer const & buf, std::ostream & os, OutputParams const &) const;
 
index e2403f625c1352a2238f92cdb20114cd60e70e09..79180784e8430561612a2ee6e261ee3fb0c0d43a 100644 (file)
@@ -62,7 +62,7 @@ void TextPainter::draw(int x, int y, char c)
 }
 
 
-void TextPainter::show(std::ostream & os, int offset) const
+void TextPainter::show(lyx::odocstream & os, int offset) const
 {
        os << '\n';
        for (int j = 0; j <= ymax_; ++j) {
index d9da7234bcefd1d911ac72a73a8ba0f6c6b44dd7..6f02fd57e07a8985991755a44f01aa8633e353d4 100644 (file)
@@ -13,8 +13,9 @@
 #define TEXTPAINTER_H
 
 
+#include "support/docstream.h"
+
 #include <vector>
-#include <iosfwd>
 
 class TextPainter {
        public:
@@ -25,7 +26,7 @@ class TextPainter {
                ///
                void draw(int x, int y, char c);
                ///
-               void show(std::ostream & os, int offset = 0) const;
+               void show(lyx::odocstream & os, int offset = 0) const;
                ///
                int textheight() const { return ymax_; }
                ///
index fbdef6bbbb60579bbd40dd4c19e32429ad5a88e0..e946cb2b820b1a221ef913ed04c0b3d33ece1873 100644 (file)
@@ -18,8 +18,7 @@
 
 #include "support/filetools.h"
 
-#include <fstream>
-
+using lyx::odocfstream;
 using lyx::support::bformat;
 using lyx::support::makeDisplayPath;
 
@@ -28,7 +27,10 @@ using lyx::docstring;
 using std::ofstream;
 using std::string;
 
-bool openFileWrite(ofstream & ofs, string const & fname)
+namespace {
+
+template<typename OFStream>
+bool doOpenFileWrite(OFStream & ofs, string const & fname)
 {
        ofs.open(fname.c_str());
        if (!ofs) {
@@ -40,3 +42,17 @@ bool openFileWrite(ofstream & ofs, string const & fname)
        }
        return true;
 }
+
+}
+
+
+bool openFileWrite(ofstream & ofs, string const & fname)
+{
+       return doOpenFileWrite(ofs, fname);
+}
+
+
+bool openFileWrite(odocfstream & ofs, string const & fname)
+{
+       return doOpenFileWrite(ofs, fname);
+}
index beecef7a3939124662d95b6557a7dfde0de12900..4b39c9c8fdc94bd5bc78548abe9fcdc50148e2b0 100644 (file)
@@ -12,9 +12,9 @@
 #ifndef OUTPUT_H
 #define OUTPUT_H
 
-#include <iosfwd>
-#include <string>
+#include "support/docstream.h"
 
 bool openFileWrite(std::ofstream & ofs, std::string const & fname);
+bool openFileWrite(lyx::odocfstream & ofs, std::string const & fname);
 
 #endif
index c945e19c2d08ff95c3e435f681aadef394a93366..643b456242215eb8267fdc5f40cd0824b726a51e 100644 (file)
@@ -133,7 +133,8 @@ TeXEnvironment(Buffer const & buf,
                        os << "{" << pit->params().labelWidthString() << "}\n";
                } else if (style->labeltype == LABEL_BIBLIO) {
                        // ale970405
-                       os << "{" <<  bibitemWidest(buf) << "}\n";
+                       // FIXME UNICODE
+                       os << '{' << lyx::to_utf8(bibitemWidest(buf)) << "}\n";
                } else
                        os << style->latexparam() << '\n';
                texrow.newline();
index 311a0058e746d4a3bd3a5fa685507385aa518c02..59039655954d7e91f34e42876529c46f90b4fc27 100644 (file)
 #include "ParagraphParameters.h"
 
 #include "support/lstrings.h"
-#include "support/unicode.h"
-
-#include <fstream>
 
 using lyx::support::ascii_lowercase;
 using lyx::support::compare_ascii_no_case;
 using lyx::support::compare_no_case;
 using lyx::support::contains;
 
+using lyx::docstring;
 using lyx::pos_type;
 using std::endl;
 using std::ostream;
@@ -44,14 +42,14 @@ void writeFileAscii(Buffer const & buf,
                    string const & fname,
                    OutputParams const & runparams)
 {
-       ofstream ofs;
+       lyx::odocfstream ofs;
        if (!::openFileWrite(ofs, fname))
                return;
        writeFileAscii(buf, ofs, runparams);
 }
 
 
-void writeFileAscii(Buffer const & buf, ostream & os,
+void writeFileAscii(Buffer const & buf, lyx::odocstream & os,
        OutputParams const & runparams)
 {
        bool ref_printed = false;
@@ -68,12 +66,12 @@ void writeFileAscii(Buffer const & buf, ostream & os,
 
 namespace {
 
-pair<int, string> const addDepth(int depth, int ldepth)
+pair<int, docstring> const addDepth(int depth, int ldepth)
 {
        int d = depth * 2;
        if (ldepth > depth)
                d += (ldepth - depth) * 2;
-       return make_pair(d, string(d, ' '));
+       return make_pair(d, docstring(d, ' '));
 }
 
 }
@@ -81,7 +79,7 @@ pair<int, string> const addDepth(int depth, int ldepth)
 
 void asciiParagraph(Buffer const & buf,
                    Paragraph const & par,
-                   ostream & os,
+                   lyx::odocstream & os,
                    OutputParams const & runparams,
                    bool & ref_printed)
 {
@@ -136,7 +134,7 @@ void asciiParagraph(Buffer const & buf,
        if (runparams.linelen > 0)
                os << "\n\n";
 
-       os << string(depth * 2, ' ');
+       os << docstring(depth * 2, ' ');
        currlinelen += depth * 2;
 
        //--
@@ -152,10 +150,10 @@ void asciiParagraph(Buffer const & buf,
 
        case 6: // Abstract
                if (runparams.linelen > 0) {
-                       os << lyx::to_utf8(_("Abstract")) << "\n\n";
+                       os << _("Abstract") << "\n\n";
                        currlinelen = 0;
                } else {
-                       string const abst = lyx::to_utf8(_("Abstract: "));
+                       docstring const abst = _("Abstract: ");
                        os << abst;
                        currlinelen += abst.length();
                }
@@ -164,10 +162,10 @@ void asciiParagraph(Buffer const & buf,
        case 7: // Bibliography
                if (!ref_printed) {
                        if (runparams.linelen > 0) {
-                               os << lyx::to_utf8(_("References")) << "\n\n";
+                               os << _("References") << "\n\n";
                                currlinelen = 0;
                        } else {
-                               string const refs = lyx::to_utf8(_("References: "));
+                               docstring const refs = _("References: ");
                                os << refs;
                                currlinelen += refs.length();
                        }
@@ -176,7 +174,9 @@ void asciiParagraph(Buffer const & buf,
                break;
 
        default: {
-               string const label = par.params().labelString();
+               // FIXME UNICODE
+               docstring const label =
+                       lyx::from_utf8(par.params().labelString());
                os << label << ' ';
                currlinelen += label.length() + 1;
                break;
@@ -185,7 +185,7 @@ void asciiParagraph(Buffer const & buf,
        }
 
        if (!currlinelen) {
-               pair<int, string> p = addDepth(depth, ltype_depth);
+               pair<int, docstring> p = addDepth(depth, ltype_depth);
                os << p.second;
                currlinelen += p.first;
        }
@@ -194,7 +194,7 @@ void asciiParagraph(Buffer const & buf,
        // intelligent hopefully! (only in the case where we have a
        // max runparams.linelength!) (Jug)
 
-       string word;
+       docstring word;
 
        for (pos_type i = 0; i < par.size(); ++i) {
                lyx::char_type c = par.getUChar(buf.params(), i);
@@ -218,8 +218,8 @@ void asciiParagraph(Buffer const & buf,
                case ' ':
                        if (runparams.linelen > 0 &&
                            currlinelen + word.length() > runparams.linelen - 10) {
-                               os << "\n";
-                               pair<int, string> p = addDepth(depth, ltype_depth);
+                               os << '\n';
+                               pair<int, docstring> p = addDepth(depth, ltype_depth);
                                os << p.second;
                                currlinelen = p.first;
                        }
@@ -233,20 +233,18 @@ void asciiParagraph(Buffer const & buf,
                                "writeAsciiFile: NULL char in structure." << endl;
                        break;
 
-               default: {
-                       std::vector<char> const tmp = ucs4_to_utf8(c);
-                       word.append(tmp.begin(), tmp.end());
+               default:
+                       word += c;
                        if (runparams.linelen > 0 &&
                            currlinelen + word.length() > runparams.linelen)
                        {
-                               os << "\n";
-                               pair<int, string> p = addDepth(depth, ltype_depth);
+                               os << '\n';
+                               pair<int, docstring> p = addDepth(depth, ltype_depth);
                                os << p.second;
                                currlinelen = p.first;
                        }
                        break;
                }
-               }
        }
        os << word;
 }
index f4ad4f7768dfcceeb4db6df3d36dec0e5ae8f872..c997b9be2b4b6baaa3c67c6885b24e6dae23bd8b 100644 (file)
@@ -12,8 +12,7 @@
 #ifndef OUTPUT_PLAINTEXT_H
 #define OUTPUT_PLAINTEXT_H
 
-#include <iosfwd>
-#include <string>
+#include "support/docstream.h"
 
 class Buffer;
 class OutputParams;
@@ -25,12 +24,12 @@ void writeFileAscii(Buffer const & buf, std::string const &,
        OutputParams const &);
 
 ///
-void writeFileAscii(Buffer const & buf, std::ostream &, OutputParams const &);
+void writeFileAscii(Buffer const & buf, lyx::odocstream &, OutputParams const &);
 
 ///
 void asciiParagraph(Buffer const & buf,
                    Paragraph const & paragraphs,
-                   std::ostream & ofs,
+                   lyx::odocstream & ofs,
                    OutputParams const &,
                    bool & ref_printed);
 
index eafe3ce560b8d3a6b19fac6c6bee0a7fb356e6b2..7abffd2ea29889c2b95e79cc3195a7dcfcc671ff 100644 (file)
@@ -54,6 +54,7 @@
 #include <stack>
 #include <sstream>
 
+using lyx::docstring;
 using lyx::pos_type;
 using lyx::char_type;
 
@@ -1338,14 +1339,14 @@ bool Paragraph::isMultiLingual(BufferParams const & bparams) const
 
 // Convert the paragraph to a string.
 // Used for building the table of contents
-string const Paragraph::asString(Buffer const & buffer, bool label) const
+docstring const Paragraph::asString(Buffer const & buffer, bool label) const
 {
        OutputParams runparams;
        return asString(buffer, runparams, label);
 }
 
 
-string const Paragraph::asString(Buffer const & buffer,
+docstring const Paragraph::asString(Buffer const & buffer,
                                 OutputParams const & runparams,
                                 bool label) const
 {
@@ -1369,13 +1370,13 @@ string const Paragraph::asString(Buffer const & buffer,
        return s;
 #else
        // This should really be done by the caller and not here.
-       string ret = asString(buffer, runparams, 0, size(), label);
+       docstring ret = asString(buffer, runparams, 0, size(), label);
        return subst(ret, '\n', ' ');
 #endif
 }
 
 
-string const Paragraph::asString(Buffer const & buffer,
+docstring const Paragraph::asString(Buffer const & buffer,
                                 pos_type beg, pos_type end, bool label) const
 {
 
@@ -1384,19 +1385,21 @@ string const Paragraph::asString(Buffer const & buffer,
 }
 
 
-string const Paragraph::asString(Buffer const & buffer,
+docstring const Paragraph::asString(Buffer const & buffer,
                                 OutputParams const & runparams,
                                 pos_type beg, pos_type end, bool label) const
 {
-       ostringstream os;
+       lyx::odocstringstream os;
 
        if (beg == 0 && label && !params().labelString().empty())
-               os << params().labelString() << ' ';
+               // FIXME UNICODE
+               os << lyx::from_utf8(params().labelString()) << ' ';
 
        for (pos_type i = beg; i < end; ++i) {
                value_type const c = getUChar(buffer.params(), i);
+               // FIXME: isPrintable does not work for lyx::char_type
                if (isPrintable(c))
-                       os << c;
+                       os.put(c);
                else if (c == META_INSET)
                        getInset(i)->textString(buffer, os, runparams);
        }
index d7a6a2841f0c3556519d5bd042184ac4f22209ea..df46cb4b40d82e18a52aad485cfb8978628983ce 100644 (file)
@@ -111,18 +111,18 @@ public:
        bool isMultiLingual(BufferParams const &) const;
 
        ///
-       std::string const asString(Buffer const &,
+       lyx::docstring const asString(Buffer const &,
                                   OutputParams const & runparams,
                                   bool label) const;
        ///
-       std::string const asString(Buffer const &, bool label) const;
+       lyx::docstring const asString(Buffer const &, bool label) const;
        ///
-       std::string const asString(Buffer const & buffer,
+       lyx::docstring const asString(Buffer const & buffer,
                                   lyx::pos_type beg,
                                   lyx::pos_type end,
                                   bool label) const;
        ///
-       std::string const asString(Buffer const &,
+       lyx::docstring const asString(Buffer const &,
                                   OutputParams const & runparams,
                                   lyx::pos_type beg,
                                   lyx::pos_type end,
index 2fe007d7db6c2a7486a8e6aebe4f919d4a260054..bf4ab321f25284e07d7c9d2f9f549aac233f1def 100644 (file)
@@ -446,7 +446,10 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
                        if (c != '\0')
                                os << c;
                } else {
-                       owner_->getInset(i)->plaintext(buf, os, runparams);
+                       lyx::odocstringstream oss;
+                       owner_->getInset(i)->plaintext(buf, oss, runparams);
+                       // FIXME UNICODE
+                       os << lyx::to_utf8(oss.str());
                }
                return;
        }
index de535eebb3c643c15e3d92f09feaa894ea9e6673..b3c3f775e37265c0c77f7c0b4884d1f2dc70df33 100644 (file)
@@ -27,6 +27,8 @@ libsupport_la_SOURCES = \
        copied_ptr.h \
        cow_ptr.h \
        debugstream.h \
+       docstream.C \
+       docstream.h \
        docstring.C \
        docstring.h \
        environment.h \
diff --git a/src/support/docstream.C b/src/support/docstream.C
new file mode 100644 (file)
index 0000000..24c08ee
--- /dev/null
@@ -0,0 +1,233 @@
+/**
+ * \file docstream.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Georg Baum
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "docstream.h"
+
+#include <cerrno>
+#include <cstdio>
+#include <iconv.h>
+#include <locale>
+
+namespace {
+
+#ifdef WORDS_BIGENDIAN
+char const * ucs4_codeset = "UCS-4BE";
+#else
+char const * ucs4_codeset = "UCS-4LE";
+#endif
+char const * utf8_codeset = "UTF-8";
+
+// We use C IO throughout this file, because the facets might be used with
+// lyxerr in the future.
+
+
+class utf8_codecvt_facet_exception : public std::exception {
+public:
+       virtual ~utf8_codecvt_facet_exception() throw() {}
+       virtual const char* what() const throw()
+       {
+               return "iconv problem in utf8_codecvt_facet initialization";
+       }
+};
+
+
+/// codecvt facet for conversion of UCS4 (internal representation) to UTF8
+/// (external representation) or vice versa
+class utf8_codecvt_facet : public std::codecvt<lyx::char_type, char, std::mbstate_t>
+{
+       typedef std::codecvt<lyx::char_type, char, std::mbstate_t> base;
+public:
+       /// Constructor. You have to specify with \p inout whether you want
+       /// to use this facet only for input, only for output or for both.
+       explicit utf8_codecvt_facet(std::ios_base::openmode inout = std::ios_base::in | std::ios_base::out,
+                       size_t refs = 0)
+               : base(refs)
+       {
+               if (inout & std::ios_base::in) {
+                       in_cd_ = iconv_open(ucs4_codeset, utf8_codeset);
+                       if (in_cd_ == (iconv_t)(-1)) {
+                               fprintf(stderr, "Error %d returned from iconv_open(in_cd_): %s\n",
+                                       errno, strerror(errno));
+                               fflush(stderr);
+                               throw utf8_codecvt_facet_exception();
+                       }
+               } else
+                       in_cd_ = (iconv_t)(-1);
+               if (inout & std::ios_base::out) {
+                       out_cd_ = iconv_open(utf8_codeset, ucs4_codeset);
+                       if (out_cd_ == (iconv_t)(-1)) {
+                               fprintf(stderr, "Error %d returned from iconv_open(out_cd_): %s\n",
+                                       errno, strerror(errno));
+                               fflush(stderr);
+                               throw utf8_codecvt_facet_exception();
+                       }
+               } else
+                       out_cd_ = (iconv_t)(-1);
+       }
+protected:
+       virtual ~utf8_codecvt_facet()
+       {
+               if (in_cd_ != (iconv_t)(-1))
+                       if (iconv_close(in_cd_) == -1) {
+                               fprintf(stderr, "Error %d returned from iconv_close(in_cd_): %s\n",
+                                       errno, strerror(errno));
+                               fflush(stderr);
+                       }
+               if (out_cd_ != (iconv_t)(-1))
+                       if (iconv_close(out_cd_) == -1) {
+                               fprintf(stderr, "Error %d returned from iconv_close(out_cd_): %s\n",
+                                       errno, strerror(errno));
+                               fflush(stderr);
+                       }
+       }
+       virtual result do_out(state_type &, intern_type const * from,
+                       intern_type const * from_end, intern_type const *& from_next,
+                       extern_type * to, extern_type * to_end,
+                       extern_type *& to_next) const
+       {
+               size_t inbytesleft = (from_end - from) * sizeof(intern_type);
+               size_t outbytesleft = (to_end - to) * sizeof(extern_type);
+               from_next = from;
+               to_next = to;
+               return do_iconv(out_cd_, reinterpret_cast<char const **>(&from_next),
+                               &inbytesleft, &to_next, &outbytesleft);
+       }
+       virtual result do_unshift(state_type &, extern_type * to,
+                       extern_type *, extern_type *& to_next) const
+       {
+               // utf8 does not use shifting
+               to_next = to;
+               return base::noconv;
+       }
+       virtual result do_in(state_type &,
+                       extern_type const * from, extern_type const * from_end,
+                       extern_type const *& from_next,
+                       intern_type * to, intern_type * to_end,
+                       intern_type *& to_next) const
+       {
+               size_t inbytesleft = (from_end - from) * sizeof(extern_type);
+               size_t outbytesleft = (to_end - to) * sizeof(intern_type);
+               from_next = from;
+               to_next = to;
+               return do_iconv(in_cd_, &from_next, &inbytesleft,
+                               reinterpret_cast<char **>(&to_next),
+                               &outbytesleft);
+       }
+       virtual int do_encoding() const throw()
+       {
+               return 0;
+       }
+       virtual bool do_always_noconv() const throw()
+       {
+               return false;
+       }
+       virtual int do_length(state_type & /*state*/, extern_type const * from,
+                       extern_type const * end, size_t max) const
+       {
+               // The docs are a bit unclear about this method.
+               // It seems that we should calculate the actual length of the
+               // converted sequence, but that would not make sense, since
+               // once could just do the conversion directly.
+               // Therefore we just return the number of unconverted
+               // characters, since that is the best guess we can do.
+#if 0
+               intern_type * to = new intern_type[max];
+               intern_type * to_end = to + max;
+               intern_type * to_next = to;
+               extern_type const * from_next = from;
+               do_in(state, from, end, from_next, to, to_end, to_next);
+               delete[] to;
+               return to_next - to;
+#else
+               size_t const length = end - from;
+               return std::min(length, max);
+#endif
+       }
+       virtual int do_max_length() const throw()
+       {
+               // UTF8 uses at most 6 bytes to represent one code point
+               return 6;
+       }
+private:
+       /// Do the actual conversion. The interface is equivalent to that of
+       /// iconv() (but const correct).
+       inline base::result do_iconv(iconv_t cd, char const ** from,
+                       size_t * inbytesleft, char ** to, size_t * outbytesleft) const
+       {
+               char const * to_start = *to;
+               size_t converted = iconv(cd, const_cast<char ICONV_CONST **>(from),
+                               inbytesleft, to, outbytesleft);
+               if (converted == (size_t)(-1)) {
+                       switch(errno) {
+                       case EINVAL:
+                       case E2BIG:
+                               return base::partial;
+                       case EILSEQ:
+                       default:
+                               fprintf(stderr, "Error %d returned from iconv: %s\n",
+                                       errno, strerror(errno));
+                               fflush(stderr);
+                               return base::error;
+                       }
+               }
+               if (*to == to_start)
+                       return base::noconv;
+               return base::ok;
+       }
+       iconv_t in_cd_;
+       iconv_t out_cd_;
+};
+
+}
+
+
+namespace lyx {
+
+
+idocfstream::idocfstream() : base()
+{
+       std::locale global;
+       std::locale locale(global, new utf8_codecvt_facet(in));
+       imbue(locale);
+}
+
+       
+idocfstream::idocfstream(const char* s, std::ios_base::openmode mode)
+       : base()
+{
+       // We must imbue the stream before openening the file
+       std::locale global;
+       std::locale locale(global, new utf8_codecvt_facet(in));
+       imbue(locale);
+       open(s, mode);
+}
+
+
+odocfstream::odocfstream() : base()
+{
+       std::locale global;
+       std::locale locale(global, new utf8_codecvt_facet(out));
+       imbue(locale);
+}
+
+       
+odocfstream::odocfstream(const char* s, std::ios_base::openmode mode)
+       : base()
+{
+       // We must imbue the stream before openening the file
+       std::locale global;
+       std::locale locale(global, new utf8_codecvt_facet(out));
+       imbue(locale);
+       open(s, mode);
+}
+
+}
diff --git a/src/support/docstream.h b/src/support/docstream.h
new file mode 100644 (file)
index 0000000..4552a2f
--- /dev/null
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+/**
+ * \file docstream.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Georg Baum
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef LYX_DOCSTREAM_H
+#define LYX_DOCSTREAM_H
+
+#include "support/docstring.h"
+
+#include <fstream>
+#include <sstream>
+
+namespace lyx {
+
+/// Base class for UCS4 input streams
+typedef std::basic_istream<char_type> idocstream;
+
+/** Base class for UCS4 output streams.
+    If you want to output a single UCS4 character, use \code
+    os.put(c);
+    \endcode, not \code
+    os << c;
+    \endcode . The latter will not output the character, but the code point
+    as number. This is because we can't overload operator<< (our character
+    type is not a real type but a typedef). Narrow characters of type char
+    can be output as usual.
+ */
+typedef std::basic_ostream<char_type> odocstream;
+
+/// File stream for reading UTF8-encoded files with automatic conversion to
+/// UCS4.
+class idocfstream : public std::basic_ifstream<char_type> {
+       typedef std::basic_ifstream<char_type> base;
+public:
+       idocfstream();
+       explicit idocfstream(const char* s,
+               std::ios_base::openmode mode = std::ios_base::in);
+       ~idocfstream() {}
+};
+
+/// File stream for writing UTF8-encoded files with automatic conversion from
+/// UCS4.
+class odocfstream : public std::basic_ofstream<char_type> {
+       typedef std::basic_ofstream<char_type> base;
+public:
+       odocfstream();
+       explicit odocfstream(const char* s,
+               std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc);
+       ~odocfstream() {}
+};
+
+/// UCS4 input stringstream
+typedef std::basic_istringstream<char_type> idocstringstream;
+
+/// UCS4 output stringstream
+typedef std::basic_ostringstream<char_type> odocstringstream;
+
+}
+#endif
index 1cd22acbb987df057b463a78f4d75df601e032e2..578eb85f3941160965c663a025e021009914f59d 100644 (file)
@@ -93,18 +93,19 @@ int compare_no_case(docstring const & s, docstring const & s2)
 
 
 namespace {
-       int ascii_tolower(int c) {
-               if (c >= 'A' && c <= 'Z')
-                       return c - 'A' + 'a';
-               return c;
-       }
+
+int ascii_tolower(int c) {
+       if (c >= 'A' && c <= 'Z')
+               return c - 'A' + 'a';
+       return c;
 }
 
 
-int compare_ascii_no_case(string const & s, string const & s2)
+template<typename String> inline
+int do_compare_ascii_no_case(String const & s, String const & s2)
 {
-       string::const_iterator p = s.begin();
-       string::const_iterator p2 = s2.begin();
+       typename String::const_iterator p = s.begin();
+       typename String::const_iterator p2 = s2.begin();
 
        while (p != s.end() && p2 != s2.end()) {
                int const lc1 = ascii_tolower(*p);
@@ -122,6 +123,20 @@ int compare_ascii_no_case(string const & s, string const & s2)
        return 1;
 }
 
+}
+
+
+int compare_ascii_no_case(string const & s, string const & s2)
+{
+       return do_compare_ascii_no_case(s, s2);
+}
+
+
+int compare_ascii_no_case(docstring const & s, docstring const & s2)
+{
+       return do_compare_ascii_no_case(s, s2);
+}
+
 
 int compare_no_case(string const & s, string const & s2, unsigned int len)
 {
@@ -411,6 +426,7 @@ int tokenPos(string const & a, char delim, string const & tok)
 
 namespace {
 
+/// Substitute all \a oldchar with \a newchar
 template<typename Ch> inline
 std::basic_string<Ch> const subst_char(std::basic_string<Ch> const & a,
                Ch oldchar, Ch newchar)
@@ -426,6 +442,7 @@ std::basic_string<Ch> const subst_char(std::basic_string<Ch> const & a,
 }
 
 
+/// substitutes all instances of \a oldstr with \a newstr
 template<typename String> inline
 String const subst_string(String const & a,
                String const & oldstr, String const & newstr)
@@ -542,6 +559,8 @@ string const ltrim(string const & a, char const * p)
 }
 
 
+namespace {
+
 template<typename String, typename Char> inline
 String const doSplit(String const & a, String & piece, Char delim)
 {
@@ -561,6 +580,8 @@ String const doSplit(String const & a, String & piece, Char delim)
        return tmp;
 }
 
+}
+
 
 string const split(string const & a, string & piece, char delim)
 {
index 4011708b72695afc03c68b4f6f80bf09fcef5832..2f61aaa8f4b1ed8b743c5af5e8b582c028e21372 100644 (file)
@@ -31,6 +31,9 @@ int compare_no_case(lyx::docstring const & s, lyx::docstring const & s2);
 ///
 int compare_ascii_no_case(std::string const & s, std::string const & s2);
 
+///
+int compare_ascii_no_case(docstring const & s, docstring const & s2);
+
 ///
 int compare_no_case(std::string const & s, std::string const & s2, unsigned int len);
 
index 10c59096e06a964984e03e96c0e6929f27909a4a..bb28318de32bba4404cc46029793065e9159755d 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <sstream>
 
+using lyx::docstring;
 using lyx::support::ltrim;
 using lyx::support::prefixIs;
 using lyx::support::rtrim;
@@ -2434,7 +2435,7 @@ int LyXTabular::docbook(Buffer const & buf, ostream & os,
 }
 
 
-int LyXTabular::asciiTopHLine(ostream & os, row_type row,
+int LyXTabular::asciiTopHLine(lyx::odocstream & os, row_type row,
                              vector<unsigned int> const & clen) const
 {
        idx_type const fcell = getFirstCellInRow(row);
@@ -2450,7 +2451,7 @@ int LyXTabular::asciiTopHLine(ostream & os, row_type row,
        if (!tmp)
                return 0;
 
-       unsigned char ch;
+       lyx::char_type ch;
        for (idx_type i = fcell; i < n; ++i) {
                if (topLine(i)) {
                        if (leftLine(i))
@@ -2467,7 +2468,7 @@ int LyXTabular::asciiTopHLine(ostream & os, row_type row,
                while (column < columns_ - 1
                       && isPartOfMultiColumn(row, ++column))
                        len += clen[column] + 4;
-               os << string(len, ch);
+               os << docstring(len, ch);
                if (topLine(i)) {
                        if (rightLine(i))
                                os << "-+";
@@ -2482,7 +2483,7 @@ int LyXTabular::asciiTopHLine(ostream & os, row_type row,
 }
 
 
-int LyXTabular::asciiBottomHLine(ostream & os, row_type row,
+int LyXTabular::asciiBottomHLine(lyx::odocstream & os, row_type row,
                                 vector<unsigned int> const & clen) const
 {
        idx_type const fcell = getFirstCellInRow(row);
@@ -2498,7 +2499,7 @@ int LyXTabular::asciiBottomHLine(ostream & os, row_type row,
        if (!tmp)
                return 0;
 
-       unsigned char ch;
+       lyx::char_type ch;
        for (idx_type i = fcell; i < n; ++i) {
                if (bottomLine(i)) {
                        if (leftLine(i))
@@ -2515,7 +2516,7 @@ int LyXTabular::asciiBottomHLine(ostream & os, row_type row,
                while (column < columns_ -1
                       && isPartOfMultiColumn(row, ++column))
                        len += clen[column] + 4;
-               os << string(len, ch);
+               os << docstring(len, ch);
                if (bottomLine(i)) {
                        if (rightLine(i))
                                os << "-+";
@@ -2530,13 +2531,13 @@ int LyXTabular::asciiBottomHLine(ostream & os, row_type row,
 }
 
 
-int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
+int LyXTabular::asciiPrintCell(Buffer const & buf, lyx::odocstream & os,
                               OutputParams const & runparams,
                               idx_type cell, row_type row, col_type column,
                               vector<unsigned int> const & clen,
                               bool onlydata) const
 {
-       ostringstream sstr;
+       lyx::odocstringstream sstr;
        int const ret = getCellInset(cell)->plaintext(buf, sstr, runparams);
 
        if (onlydata) {
@@ -2571,7 +2572,8 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
                break;
        }
 
-       os << string(len1, ' ') << sstr.str() << string(len2, ' ');
+       os << docstring(len1, ' ') << sstr.str()
+          << docstring(len2, ' ');
 
        if (rightLine(cell))
                os << " |";
@@ -2582,7 +2584,7 @@ int LyXTabular::asciiPrintCell(Buffer const & buf, ostream & os,
 }
 
 
-int LyXTabular::plaintext(Buffer const & buf, ostream & os,
+int LyXTabular::plaintext(Buffer const & buf, lyx::odocstream & os,
                      OutputParams const & runparams,
                      int const depth,
                      bool onlydata, unsigned char delim) const
@@ -2600,7 +2602,7 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os,
                                idx_type cell = getCellNumber(i, j);
                                if (isMultiColumnReal(cell))
                                        continue;
-                               ostringstream sstr;
+                               lyx::odocstringstream sstr;
                                getCellInset(cell)->plaintext(buf, sstr, runparams);
                                if (clen[j] < sstr.str().length())
                                        clen[j] = sstr.str().length();
@@ -2612,7 +2614,7 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os,
                                idx_type cell = getCellNumber(i, j);
                                if (!isMultiColumnReal(cell) || isPartOfMultiColumn(i, j))
                                        continue;
-                               ostringstream sstr;
+                               lyx::odocstringstream sstr;
                                getCellInset(cell)->plaintext(buf, sstr, runparams);
                                int len = int(sstr.str().length());
                                idx_type const n = cells_in_multicolumn(cell);
@@ -2626,7 +2628,7 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os,
        idx_type cell = 0;
        for (row_type i = 0; i < rows_; ++i) {
                if (!onlydata && asciiTopHLine(os, i, clen))
-                       os << string(depth * 2, ' ');
+                       os << docstring(depth * 2, ' ');
                for (col_type j = 0; j < columns_; ++j) {
                        if (isPartOfMultiColumn(i, j))
                                continue;
@@ -2638,9 +2640,9 @@ int LyXTabular::plaintext(Buffer const & buf, ostream & os,
                }
                os << endl;
                if (!onlydata) {
-                       os << string(depth * 2, ' ');
+                       os << docstring(depth * 2, ' ');
                        if (asciiBottomHLine(os, i, clen))
-                               os << string(depth * 2, ' ');
+                               os << docstring(depth * 2, ' ');
                }
        }
        return ret;
index e3fe328fe8706c509609320397449cb310d6672c..b650db8717efdc2aa0e1eddc0a28aaa177dbe8df 100644 (file)
@@ -316,7 +316,7 @@ public:
        int docbook(Buffer const & buf, std::ostream & os,
                    OutputParams const &) const;
        ///
-       int plaintext(Buffer const &, std::ostream &,
+       int plaintext(Buffer const &, lyx::odocstream &,
                  OutputParams const & runparams,
                  int const depth,
                  bool onlydata, unsigned char delim) const;
@@ -605,13 +605,13 @@ public:
        ///
        // helper function for ASCII returns number of newlines
        ///
-       int asciiTopHLine(std::ostream &, row_type row,
+       int asciiTopHLine(lyx::odocstream &, row_type row,
                          std::vector<unsigned int> const &) const;
        ///
-       int asciiBottomHLine(std::ostream &, row_type row,
+       int asciiBottomHLine(lyx::odocstream &, row_type row,
                             std::vector<unsigned int> const &) const;
        ///
-       int asciiPrintCell(Buffer const &, std::ostream &,
+       int asciiPrintCell(Buffer const &, lyx::odocstream &,
                           OutputParams const &,
                           idx_type cell, row_type row, col_type column,
                           std::vector<unsigned int> const &,
index a224f124ac4b8f7ee9de1ded4bdc39e27b01f41d..975c658a48695cc6bd5dd1243482ace5de9a625e 100644 (file)
@@ -2481,7 +2481,8 @@ string LyXText::getPossibleLabel(LCursor & cur) const
        if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
                text.erase();
 
-       string par_text = pars_[pit].asString(cur.buffer(), false);
+       // FIXME UNICODE
+       string par_text = lyx::to_utf8(pars_[pit].asString(cur.buffer(), false));
        for (int i = 0; i < lyxrc.label_init_length; ++i) {
                if (par_text.empty())
                        break;
index f4485aaf7287edd6e958ca028bf82343b58a1184..ffd5ee9fbc02a4ad3225bef7ecaf0cdfa3c06f2f 100644 (file)
--- a/src/toc.C
+++ b/src/toc.C
@@ -93,7 +93,7 @@ vector<string> const & getTypes(Buffer const & buf)
 }
 
 
-void asciiTocList(string const & type, Buffer const & buf, ostream & os)
+void asciiTocList(string const & type, Buffer const & buf, lyx::odocstream & os)
 {
        toc_backend_[&buf].asciiTocList(type, os);
 }
index 919d1ba28243cb6413162099f8664e048ae3be24..750b841467535a9d3ad0ece00f3da88ee773df4e 100644 (file)
--- a/src/toc.h
+++ b/src/toc.h
@@ -44,7 +44,7 @@ TocIterator const getCurrentTocItem(Buffer const &, LCursor const &,
                                                                          std::string const & type);
 
 ///
-void asciiTocList(std::string const &, Buffer const &, std::ostream &);
+void asciiTocList(std::string const &, Buffer const &, lyx::odocstream &);
 
 /** Given the cmdName of the TOC param, returns the type used
     by ControlToc::getContents() */