Add alignment to default CSS.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35392 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-09-15 14:06:36 +00:00
parent 36765b8e21
commit a5e4f310fe
3 changed files with 34 additions and 3 deletions

View File

@ -13,10 +13,11 @@
#include <config.h>
#include "Layout.h"
#include "Language.h"
#include "TextClass.h"
#include "Lexer.h"
#include "FontInfo.h"
#include "Language.h"
#include "Lexer.h"
#include "output_xhtml.h"
#include "TextClass.h"
#include "support/debug.h"
#include "support/lassert.h"
@ -1032,6 +1033,15 @@ void Layout::makeDefaultCSS() const {
htmldefaultstyle_ += from_ascii("\n");
htmldefaultstyle_ += from_ascii(tmp);
}
// tex2lyx does not see output_xhtml.cpp
#ifndef TEX2LYX
// alignment
string where = alignmentToCSS(align);
if (!where.empty()) {
htmldefaultstyle_ += from_ascii("text-align: " + where + ";\n");
}
#endif
// wrap up what we have, if anything
if (!htmldefaultstyle_.empty())

View File

@ -881,4 +881,20 @@ void xhtmlParagraphs(Text const & text,
}
string alignmentToCSS(LyXAlignment align) {
switch (align) {
case LYX_ALIGN_BLOCK:
// we are NOT going to use text-align: justify!!
case LYX_ALIGN_LEFT:
return "left";
case LYX_ALIGN_RIGHT:
return "right";
case LYX_ALIGN_CENTER:
return "center";
default:
break;
}
return "";
}
} // namespace lyx

View File

@ -12,6 +12,7 @@
#ifndef OUTPUT_XHTML_H
#define OUTPUT_XHTML_H
#include "LayoutEnums.h"
#include "support/docstream.h"
#include "support/strfwd.h"
@ -149,6 +150,10 @@ void xhtmlParagraphs(Text const & text,
XHTMLStream & xs,
OutputParams const & runparams);
/// \return a string appropriate for setting alignment in CSS
/// Does NOT return "justify" for "block"
std::string alignmentToCSS(LyXAlignment align);
namespace html {
///
docstring escapeChar(char_type c);