From c2b8eeaf9609ca0770fe538694081d105257f582 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 27 Oct 2009 13:29:26 +0000 Subject: [PATCH] Rename some things to improve clarity. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31765 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Layout.cpp | 30 +++++++++++++++--------------- src/Layout.h | 18 ++++++++++++------ src/output_xhtml.cpp | 14 +++++++------- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/Layout.cpp b/src/Layout.cpp index 1eaffdc1bc..bb90723848 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -494,7 +494,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) break; case LT_HTMLITEM: - lex >> htmlitem_; + lex >> htmlitemtag_; break; case LT_HTMLITEMATTR: @@ -502,7 +502,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) break; case LT_HTMLLABEL: - lex >> htmllabel_; + lex >> htmllabeltag_; break; case LT_HTMLLABELATTR: @@ -869,10 +869,10 @@ docstring const Layout::babelpreamble(Language const * lang) const } -string const Layout::htmltag() const +string const & Layout::htmltag() const { if (htmltag_.empty()) - htmltag_ = "div"; + htmltag_ = "div"; return htmltag_; } @@ -880,39 +880,39 @@ string const Layout::htmltag() const string const & Layout::htmlattr() const { if (htmlattr_.empty()) - htmlattr_ = "class=\"" + to_utf8(name()) + "\""; + htmlattr_ = "class=\"" + defaultCSSClass() + "\""; return htmlattr_; } -string const & Layout::htmlitem() const +string const & Layout::htmlitemtag() const { - if (htmlitem_.empty()) - htmlitem_ = "div"; - return htmlitem_; + if (htmlitemtag_.empty()) + htmlitemtag_ = "div"; + return htmlitemtag_; } string const & Layout::htmlitemattr() const { if (htmlitemattr_.empty()) - htmlitemattr_ = "class=\"" + to_utf8(name()) + "item\""; + htmlitemattr_ = "class=\"" + defaultCSSItemClass() + "\""; return htmlitemattr_; } -string const & Layout::htmllabel() const +string const & Layout::htmllabeltag() const { - if (htmllabel_.empty()) - htmllabel_ = "span"; - return htmllabel_; + if (htmllabeltag_.empty()) + htmllabeltag_ = "span"; + return htmllabeltag_; } string const & Layout::htmllabelattr() const { if (htmllabelattr_.empty()) - htmllabelattr_ = "class=\"" + to_utf8(name()) + "label\""; + htmllabelattr_ = "class=\"" + defaultCSSLabelClass() + "\""; return htmllabelattr_; } diff --git a/src/Layout.h b/src/Layout.h index ef6b69613b..34f64803cd 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -110,15 +110,15 @@ public: /// std::string const & itemtag() const { return itemtag_; } /// - std::string const htmltag() const; + std::string const & htmltag() const; /// std::string const & htmlattr() const; /// - std::string const & htmlitem() const; + std::string const & htmlitemtag() const; /// std::string const & htmlitemattr() const; /// - std::string const & htmllabel() const; + std::string const & htmllabeltag() const; /// std::string const & htmllabelattr() const; /// @@ -251,6 +251,12 @@ public: private: /// generates the default CSS for this layout void makeDefaultCSS() const; + /// + inline std::string defaultCSSClass() const { return to_utf8(name()); } + /// + inline std::string defaultCSSItemClass() const { return to_utf8(name()) + "item"; } + /// + inline std::string defaultCSSLabelClass() const { return to_utf8(name()) + "label"; } /// Name of the layout/paragraph environment docstring name_; @@ -310,15 +316,15 @@ private: /// in "p" tags. Default is "div". /// Note that when I said "environment", I meant it: This has no /// effect for LATEX_PARAGRAPH type layouts. - mutable std::string htmlitem_; - /// Attributes for htmlitem_. Default is: class="layoutnameitem". + mutable std::string htmlitemtag_; + /// Attributes for htmlitemtag_. Default is: class="layoutnameitem". mutable std::string htmlitemattr_; /// Tag for labels, of whatever sort. One use for this is in setting /// descriptions, in which case it would be: dt. Another use is to /// customize the display of, say, the auto-generated label for /// sections. Defaults to "span". /// If set to "NONE", this suppresses the printing of the label. - mutable std::string htmllabel_; + mutable std::string htmllabeltag_; /// Attributes for the label. Defaults to: class="layoutnamelabel". mutable std::string htmllabelattr_; /// Whether to put the label before the item, or within the item. diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 340b363f89..eef25c318e 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -122,25 +122,25 @@ bool closeTag(odocstream & os, Layout const & lay) bool openLabelTag(odocstream & os, Layout const & lay) { - return html::openTag(os, lay.htmllabel(), lay.htmllabelattr()); + return html::openTag(os, lay.htmllabeltag(), lay.htmllabelattr()); } bool closeLabelTag(odocstream & os, Layout const & lay) { - return html::closeTag(os, lay.htmllabel()); + return html::closeTag(os, lay.htmllabeltag()); } bool openItemTag(odocstream & os, Layout const & lay) { - return html::openTag(os, lay.htmlitem(), lay.htmlitemattr()); + return html::openTag(os, lay.htmlitemtag(), lay.htmlitemattr()); } bool closeItemTag(odocstream & os, Layout const & lay) { - return html::closeTag(os, lay.htmlitem()); + return html::closeTag(os, lay.htmlitemtag()); } ParagraphList::const_iterator searchParagraphHtml( @@ -305,7 +305,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf, // in this case, we print the label only for the first // paragraph (as in a theorem). item_tag_opened = openItemTag(os, style); - if (par == pbegin && style.htmllabel() != "NONE") { + if (par == pbegin && style.htmllabeltag() != "NONE") { docstring const lbl = pbegin->expandLabel(style, buf.params(), false); if (!lbl.empty()) { @@ -320,7 +320,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf, if (!labelfirst) item_tag_opened = openItemTag(os, style); if (style.labeltype == LABEL_MANUAL - && style.htmllabel() != "NONE") { + && style.htmllabeltag() != "NONE") { madelabel = openLabelTag(os, style); sep = par->firstWordLyXHTML(os, runparams); if (madelabel) @@ -328,7 +328,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf, os << '\n'; } else if (style.labeltype != LABEL_NO_LABEL - && style.htmllabel() != "NONE") { + && style.htmllabeltag() != "NONE") { madelabel = openLabelTag(os, style); os << par->expandLabel(style, buf.params(), false); if (madelabel)