]> git.lyx.org Git - features.git/commitdiff
More unicode fixes for docbook.
authorJosé Matox <jamatos@lyx.org>
Sat, 21 Oct 2006 19:40:29 +0000 (19:40 +0000)
committerJosé Matox <jamatos@lyx.org>
Sat, 21 Oct 2006 19:40:29 +0000 (19:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15459 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/LaTeXFeatures.C
src/LaTeXFeatures.h
src/buffer.C
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/lyxlength.C
src/lyxlength.h
src/mathed/MathMLStream.C
src/mathed/MathMLStream.h
src/paragraph.C
src/sgml.C
src/sgml.h

index 0ce379ef58282684581792e15aba1c4f1aedb194..1ad591446f068d74f711cd3b3c49291f76412f7e 100644 (file)
@@ -28,8 +28,8 @@
 #include "lyx_sty.h"
 #include "lyxrc.h"
 
+#include "support/docstream.h"
 #include "support/filetools.h"
-
 #include <sstream>
 
 
@@ -191,7 +191,7 @@ void LaTeXFeatures::useLanguage(Language const * lang)
 }
 
 
-void LaTeXFeatures::includeFile(string const & key, string const & name)
+void LaTeXFeatures::includeFile(docstring const & key, string const & name)
 {
        IncludedFiles_[key] = name;
 }
@@ -498,10 +498,10 @@ string const LaTeXFeatures::getTClassPreamble() const
 }
 
 
-string const LaTeXFeatures::getLyXSGMLEntities() const
+docstring const LaTeXFeatures::getLyXSGMLEntities() const
 {
        // Definition of entities used in the document that are LyX related.
-       ostringstream entities;
+       odocstringstream entities;
 
        if (isRequired("lyxarrow")) {
                entities << "<!ENTITY lyxarrow \"-&gt;\">" << '\n';
@@ -511,9 +511,9 @@ string const LaTeXFeatures::getLyXSGMLEntities() const
 }
 
 
-string const LaTeXFeatures::getIncludedFiles(string const & fname) const
+docstring const LaTeXFeatures::getIncludedFiles(string const & fname) const
 {
-       ostringstream sgmlpreamble;
+       odocstringstream sgmlpreamble;
        string const basename = onlyPath(fname);
 
        FileMap::const_iterator end = IncludedFiles_.end();
@@ -521,7 +521,7 @@ string const LaTeXFeatures::getIncludedFiles(string const & fname) const
             fi != end; ++fi)
                sgmlpreamble << "\n<!ENTITY " << fi->first
                             << (isSGMLFilename(fi->second) ? " SYSTEM \"" : " \"")
-                            << makeRelPath(fi->second, basename) << "\">";
+                            << from_ascii(makeRelPath(fi->second, basename)) << "\">";
 
        return sgmlpreamble.str();
 }
index 39cba36f5531948d88cfc99905e71521e7fd4688..84e43dbbe2b01da12d5bac27967523feb2592cd2 100644 (file)
@@ -15,6 +15,7 @@
 
 
 #include "outputparams.h"
+#include "support/docstring.h"
 
 #include <set>
 #include <list>
@@ -55,11 +56,11 @@ public:
        /// The definitions needed by the document's textclass
        std::string const getTClassPreamble() const;
        /// The sgml definitions needed by the document (docbook)
-       std::string const getLyXSGMLEntities() const;
+       docstring const getLyXSGMLEntities() const;
        /// The SGML Required to include the files added with includeFile();
-       std::string const getIncludedFiles(std::string const & fname) const;
+       docstring const getIncludedFiles(std::string const & fname) const;
        /// Include a file for use with the SGML entities
-       void includeFile(std::string const & key, std::string const & name);
+       void includeFile(docstring const & key, std::string const & name);
        /// The float definitions.
        void getFloatDefinitions(std::ostream & os) const;
        /// Print requirements to lyxerr
@@ -119,7 +120,7 @@ private:
        ///
        UsedFloats usedFloats_;
        ///
-       typedef std::map<std::string , std::string> FileMap;
+       typedef std::map<docstring , std::string> FileMap;
        ///
        FileMap IncludedFiles_;
        /** Buffer of the file being processed.
index e500fab155a750dd949a1f129524804590139b1f..2206d32966a7ed482f0bae67233d64712a99f954 100644 (file)
@@ -1026,7 +1026,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
                else
                        os << " PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\"";
 
-               string preamble = params().preamble;
+               docstring preamble = from_utf8(params().preamble);
                if (runparams.flavor != OutputParams::XML ) {
                        preamble += "<!ENTITY % output.print.png \"IGNORE\">\n";
                        preamble += "<!ENTITY % output.print.pdf \"IGNORE\">\n";
@@ -1040,7 +1040,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
                preamble += features.getLyXSGMLEntities();
 
                if (!preamble.empty()) {
-                        os << "\n [ " << from_ascii(preamble) << " ]";
+                        os << "\n [ " << preamble << " ]";
                }
                os << ">\n\n";
        }
index b147d429c5008e8c2c80d4c7c5bab6e6c498287b..82c0876aa1bd24f013ca0701263cbb81201e0cc6 100644 (file)
@@ -349,9 +349,9 @@ string const InsetGraphics::createLatexOptions() const
 }
 
 
-string const InsetGraphics::toDocbookLength(LyXLength const & len) const
+docstring const InsetGraphics::toDocbookLength(LyXLength const & len) const
 {
-       ostringstream result;
+       odocstringstream result;
        switch (len.unit()) {
                case LyXLength::SP: // Scaled point (65536sp = 1pt) TeX's smallest unit.
                        result << len.value() * 65536.0 * 72 / 72.27 << "pt";
@@ -400,13 +400,13 @@ string const InsetGraphics::toDocbookLength(LyXLength const & len) const
                        result << len.value() << "%";
                        break;
                default:
-                       result << len.asString();
+                       result << len.asDocstring();
                        break;
        }
        return result.str();
 }
 
-string const InsetGraphics::createDocBookAttributes() const
+docstring const InsetGraphics::createDocBookAttributes() const
 {
        // Calculate the options part of the command, we must do it to a string
        // stream since we copied the code from createLatexParams() ;-)
@@ -414,7 +414,7 @@ string const InsetGraphics::createDocBookAttributes() const
        // FIXME: av: need to translate spec -> Docbook XSL spec (http://www.sagehill.net/docbookxsl/ImageSizing.html)
        // Right now it only works with my version of db2latex :-)
 
-       ostringstream options;
+       odocstringstream options;
        double const scl = convert<double>(params().scale);
        if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
                if (!float_equal(scl, 100.0, 0.05))
@@ -436,11 +436,10 @@ string const InsetGraphics::createDocBookAttributes() const
 
 
        if (!params().special.empty())
-           options << params().special << " ";
+               options << from_ascii(params().special) << " ";
 
-       string opts = options.str();
        // trailing blanks are ok ...
-       return opts;
+       return options.str();
 }
 
 
@@ -824,7 +823,7 @@ int InsetGraphics::plaintext(Buffer const &, odocstream & os,
 namespace {
 
 int writeImageObject(char * format, odocstream & os, OutputParams const & runparams,
-                     string const graphic_label, string const attributes)
+                     docstring const graphic_label, docstring const attributes)
 {
                if (runparams.flavor != OutputParams::XML) {
                        os << "<![ %output.print."
@@ -832,13 +831,12 @@ int writeImageObject(char * format, odocstream & os, OutputParams const & runpar
                            << "; ["
                            << std::endl;
                }
-                // FIXME UNICODE
                os <<"<imageobject><imagedata fileref=\"&"
-                  << from_ascii(graphic_label)
+                  << graphic_label
                    << ";."
                    << format
                    << "\" "
-                   << from_ascii(attributes);
+                   << attributes;
                if (runparams.flavor == OutputParams::XML) {
                        os <<  " role=\"" << format << "\"/>" ;
                }
@@ -874,7 +872,7 @@ int InsetGraphics::docbook(Buffer const &, odocstream & os,
        os << "<inlinemediaobject>";
 
        int r = 0;
-       string attributes = createDocBookAttributes();
+       docstring attributes = createDocBookAttributes();
        r += writeImageObject("png", os, runparams, graphic_label, attributes);
        r += writeImageObject("pdf", os, runparams, graphic_label, attributes);
        r += writeImageObject("eps", os, runparams, graphic_label, attributes);
index 71930d1363b304152460699be432e6fe9d02d193..0d52776d8d3ca984107c576df1a6a2c68fced97d 100644 (file)
@@ -96,9 +96,9 @@ private:
        /// Create the options for the latex command.
        std::string const createLatexOptions() const;
        /// Create length values for docbook export.
-       std::string const toDocbookLength(LyXLength const & len) const;
+       docstring const toDocbookLength(LyXLength const & len) const;
        /// Create the atributes for docbook export.
-       std::string const createDocBookAttributes() const;
+       docstring const createDocBookAttributes() const;
        /// Convert the file if needed, and return the location of the file.
        std::string const prepareFile(Buffer const & buf, OutputParams const &) const;
 
@@ -106,7 +106,7 @@ private:
        InsetGraphicsParams params_;
 
        /// holds the entity name that defines the graphics location (SGML).
-       std::string const graphic_label;
+       docstring const graphic_label;
 
        /// The thing that actually draws the image on LyX's screen.
        boost::scoped_ptr<RenderGraphic> const graphic_;
index 468f56f676f5986ba78681a0ec448b42dc1b9fcf..89247ce0a54d9ac40efc51e3777fc5e54c84c08d 100644 (file)
@@ -88,10 +88,10 @@ namespace fs = boost::filesystem;
 
 namespace {
 
-string const uniqueID()
+docstring const uniqueID()
 {
        static unsigned int seed = 1000;
-       return "file" + convert<string>(++seed);
+       return "file" + convert<docstring>(++seed);
 }
 
 } // namespace anon
@@ -528,10 +528,10 @@ int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
         // FIXME UNICODE
        if (isVerbatim(params_)) {
                os << "<inlinegraphic fileref=\""
-                  << '&' << from_ascii(include_label) << ';'
+                  << '&' << include_label << ';'
                   << "\" format=\"linespecific\">";
        } else
-                os << '&' << from_ascii(include_label) << ';';
+                os << '&' << include_label << ';';
 
        return 0;
 }
index 23f6f17d47c80723635c488bec865c4c8571c253..cad0d6e1a1e1e7d420465543974d983e64f2c21a 100644 (file)
@@ -119,7 +119,7 @@ private:
        /// the parameters
        InsetCommandParams params_;
        /// holds the entity name that defines the file location (SGML)
-       std::string const include_label;
+       docstring const include_label;
 
        /// The pointer never changes although *preview_'s contents may.
        boost::scoped_ptr<RenderMonitoredPreview> const preview_;
index 3b893bbb59caabcacf1141ae0366d473a5c2741f..fded92c19bcfe53b595f0d24e86a7cc713607f6f 100644 (file)
@@ -19,6 +19,7 @@
 #include "lengthcommon.h"
 #include "lyxrc.h"
 
+#include "support/docstream.h"
 #include <sstream>
 #include <iomanip>
 
@@ -61,6 +62,14 @@ string const LyXLength::asString() const
 }
 
 
+docstring const LyXLength::asDocstring() const
+{
+       odocstringstream os;
+       os << val_ << unit_name[unit_]; // setw?
+       return os.str();
+}
+
+
 string const LyXLength::asLatexString() const
 {
        ostringstream os;
index e45d0f4a110680311d68907b652d4d4d21d25d0a..453cca12490146922c2144f54eb6496454c63c61 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef LYX_LENGTH_H
 #define LYX_LENGTH_H
 
+#include "support/docstring.h"
 #include <string>
 
 
@@ -81,6 +82,8 @@ public:
        bool empty() const;
        /// return string representation
        std::string const asString() const;
+       /// return string representation
+       docstring const asDocstring() const;
        /// return string representation for LaTeX
        std::string const asLatexString() const;
        /// return the on-screen size of this length
index 958a815458f32465bda5a8f7f4a8633222723c4e..4958ad37b5f1436801270d64a0c0bfe8838281b1 100644 (file)
@@ -140,6 +140,12 @@ MathMLStream & operator<<(MathMLStream & ms, MathArray const & ar)
 }
 
 
+MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
+{
+       ms.os() << s;
+       return ms;
+}
+
 MathMLStream & operator<<(MathMLStream & ms, char const * s)
 {
        ms.os() << s;
index 36950cec89801a760f0549a251837f947ac85a5d..555ff7dbef274d0d4770964920e414d78ae58637 100644 (file)
@@ -121,6 +121,8 @@ public:
        int & tab() { return tab_; }
        ///
        friend MathMLStream & operator<<(MathMLStream &, char const *);
+       ///
+       friend MathMLStream & operator<<(MathMLStream &, docstring const &);
 private:
        ///
        odocstream & os_;
index 235963b5a4c98e0accd6638c56da82d1de3b4326..1bd903930a12ea6d2f49eb97d5b11416607bbb99 100644 (file)
@@ -46,7 +46,6 @@
 #include "support/convert.h"
 #include "support/unicode.h"
 
-#include <boost/tuple/tuple.hpp>
 #include <boost/bind.hpp>
 
 #include <algorithm>
index ee8fe4e150c2e0002adf0539fc03d0a005c36a78..526b51e64b421c5958e425ccb047ca4a0849a424 100644 (file)
@@ -105,10 +105,10 @@ docstring sgml::escapeString(docstring const & raw)
 }
 
 
-string const sgml::uniqueID(string const label)
+docstring const sgml::uniqueID(string const label)
 {
        static unsigned int seed = 1000;
-       return label + convert<string>(++seed);
+       return from_ascii(label + convert<string>(++seed));
 }
 
 
index b4c02f5cc8511c258258b6c3975e1e16b8e6546f..055f8638d59de941c1e65062a9967924a9f3270c 100644 (file)
@@ -43,7 +43,7 @@ std::string cleanID(Buffer const & buf, OutputParams const & runparams,
                    std::string const & orig);
 
 /// returns a unique numeric id
-std::string const uniqueID(std::string const label);
+docstring const uniqueID(std::string const label);
 
 /// Opens tag
 void openTag(odocstream & os, std::string const & name,