mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Lengths for HTML. Use them for InsetBox.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30074 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fc63c87e2e
commit
bd5cccbb34
@ -110,6 +110,48 @@ string const Length::asLatexString() const
|
||||
}
|
||||
|
||||
|
||||
string const Length::asHTMLString() const
|
||||
{
|
||||
ostringstream os;
|
||||
switch (unit_) {
|
||||
case PT:
|
||||
case BP:
|
||||
case DD:
|
||||
// close enough
|
||||
os << val_ << "pt";
|
||||
break;
|
||||
case MM:
|
||||
case CM:
|
||||
case PC:
|
||||
case IN:
|
||||
case EX:
|
||||
case EM:
|
||||
os << val_ << unit_name[unit_];
|
||||
break;
|
||||
case CC:
|
||||
os << val_/12.0 << "pt";
|
||||
break;
|
||||
case MU:
|
||||
os << val_/18.0 << "em";
|
||||
break;
|
||||
case PTW:
|
||||
case PPW:
|
||||
case PLW:
|
||||
case PCW:
|
||||
case PTH:
|
||||
case PPH:
|
||||
// what it's a percentage of probably won't make sense for HTML,
|
||||
// so we'll assume people have chosen these appropriately
|
||||
os << val_ << '%';
|
||||
break;
|
||||
case SP:
|
||||
case UNIT_NONE:
|
||||
break;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
double Length::value() const
|
||||
{
|
||||
return val_;
|
||||
|
@ -87,6 +87,8 @@ public:
|
||||
docstring const asDocstring() const;
|
||||
/// return string representation for LaTeX
|
||||
std::string const asLatexString() const;
|
||||
/// return string representation for HTML
|
||||
std::string const asHTMLString() const;
|
||||
/// return the on-screen size of this length
|
||||
int inPixels(int text_width, int em_width = 0) const;
|
||||
/// return the value in Big Postscript points.
|
||||
|
@ -486,12 +486,19 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
|
||||
int InsetBox::xhtml(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// FIXME We also want to do something with the length info, etc,
|
||||
// presumably as "style='...'".
|
||||
os << from_ascii("<span class='" + params_.type + "'>\n");
|
||||
int ret = InsetText::xhtml(os, runparams);
|
||||
string style;
|
||||
if (!params_.width.empty())
|
||||
style += ("width: " + params_.width.asHTMLString() + ";");
|
||||
if (!params_.height.empty())
|
||||
style += ("height: " + params_.height.asHTMLString() + ";");
|
||||
|
||||
os << from_ascii("<span class='" + params_.type + "'");
|
||||
if (!style.empty())
|
||||
os << from_ascii(" style='" + style + "'");
|
||||
os << ">\n";
|
||||
InsetText::xhtml(os, runparams);
|
||||
os << "</span>\n";
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user