More unicode fixes for docbook.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15459 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
José Matox 2006-10-21 19:40:29 +00:00
parent a36aac0510
commit 354fb450c2
14 changed files with 56 additions and 38 deletions

View 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();
}

View 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.

View 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";
}

View 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);

View 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_;

View 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;
}

View 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_;

View 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;

View 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

View 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;

View 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_;

View File

@ -46,7 +46,6 @@
#include "support/convert.h"
#include "support/unicode.h"
#include <boost/tuple/tuple.hpp>
#include <boost/bind.hpp>
#include <algorithm>

View 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));
}

View 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,