Add topsep and bottomsep handling to the default CSS we generate.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35385 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-09-15 13:02:45 +00:00
parent c01de9fd41
commit 89738020e0

View File

@ -18,10 +18,10 @@
#include "Lexer.h"
#include "FontInfo.h"
#include "support/Messages.h"
#include "support/debug.h"
#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/Messages.h"
#include "support/regex.h"
@ -1003,20 +1003,35 @@ string Layout::defaultCSSClass() const
}
// NOTE There is a whole ton of stuff that could go into this.
// Things like bottomsep, topsep, and parsep could become various
// sorts of margins or padding, for example. But for now we are
// going to keep it simple.
namespace {
string makeMarginValue(double d) {
ostringstream os;
os << d << "ex";
return os.str();
}
}
void Layout::makeDefaultCSS() const {
// this never needs to be redone, since reloading layouts will
// wipe out what we did before.
if (!htmldefaultstyle_.empty())
return;
docstring const mainfontCSS = font.asCSS();
if (!mainfontCSS.empty())
htmldefaultstyle_ = font.asCSS();
string tmp;
if (topsep > 0)
tmp += "margin-top: " + makeMarginValue(topsep) + ";\n";
if (bottomsep > 0)
tmp += "margin-bottom: " + makeMarginValue(bottomsep) + ";\n";
if (!tmp.empty()) {
if (!htmldefaultstyle_.empty())
htmldefaultstyle_ += from_ascii("\n");
htmldefaultstyle_ += from_ascii(tmp);
}
if (!htmldefaultstyle_.empty())
htmldefaultstyle_ =
from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
mainfontCSS + from_ascii("\n}\n");
htmldefaultstyle_ + from_ascii("\n}\n");
if (labelfont == font || htmllabeltag() == "NONE")
return;
docstring const labelfontCSS = labelfont.asCSS();