]> git.lyx.org Git - lyx.git/blobdiff - src/xml.cpp
Hack to display section symbol
[lyx.git] / src / xml.cpp
index 7c614dac8bad4b0c88dd5a44fc00c0947b009703..53ccb8a8c83ee3cc7255e9cadf93b71f82d3458d 100644 (file)
@@ -123,12 +123,6 @@ docstring StartTag::writeEndTag() const
 }
 
 
-bool StartTag::operator==(FontTag const &rhs) const
-{
-       return rhs == *this;
-}
-
-
 docstring EndTag::writeEndTag() const
 {
        return from_utf8("</") + tag_ + from_utf8(">");
@@ -152,21 +146,12 @@ docstring CompTag::writeTag() const
        return output;
 }
 
-
-bool FontTag::operator==(StartTag const & tag) const
-{
-       FontTag const * const ftag = tag.asFontTag();
-       if (!ftag)
-               return false;
-       return (font_type_ == ftag->font_type_);
-}
-
 } // namespace xml
 
 
 void XMLStream::writeError(std::string const &s)
 {
-       LYXERR0(s);
+       LYXERR(Debug::OUTFILE, s);
        *this << ESCAPE_NONE << from_utf8("<!-- Output Error: " + s + " -->");
        *this << xml::CR();
 }
@@ -174,7 +159,7 @@ void XMLStream::writeError(std::string const &s)
 
 void XMLStream::writeError(docstring const &s)
 {
-       LYXERR0(s);
+       LYXERR(Debug::OUTFILE, s);
        *this << ESCAPE_NONE << from_utf8("<!-- Output Error: ");
        *this << s;
        *this << ESCAPE_NONE << from_utf8(" -->");
@@ -679,6 +664,44 @@ docstring xml::cleanID(docstring const & orig)
 }
 
 
+bool operator==(xml::StartTag const & lhs, xml::StartTag const & rhs)
+{
+       xml::FontTag const * const lhs_ft = lhs.asFontTag();
+       xml::FontTag const * const rhs_ft = rhs.asFontTag();
+
+       if ((!lhs_ft && rhs_ft) || (lhs_ft && !rhs_ft))
+               return false;
+       if (!lhs_ft && !rhs_ft)
+               return lhs.tag_ == rhs.tag_;
+       return lhs_ft->tag_ == rhs_ft->tag_ && lhs_ft->font_type_ == rhs_ft->font_type_;
+}
+
+
+bool operator==(xml::EndTag const & lhs, xml::StartTag const & rhs)
+{
+       xml::EndFontTag const * const lhs_ft = lhs.asFontTag();
+       xml::FontTag const * const rhs_ft = rhs.asFontTag();
+
+       if ((!lhs_ft && rhs_ft) || (lhs_ft && !rhs_ft))
+               return false;
+       if (!lhs_ft && !rhs_ft)
+               return lhs.tag_ == rhs.tag_;
+       return lhs_ft->tag_ == rhs_ft->tag_ && lhs_ft->font_type_ == rhs_ft->font_type_;
+}
+
+
+bool operator!=(xml::EndTag const & lhs, xml::StartTag const & rhs)
+{
+       return !(lhs == rhs);
+}
+
+
+bool operator!=(xml::StartTag const & lhs, xml::StartTag const & rhs)
+{
+       return !(lhs == rhs);
+}
+
+
 void xml::openTag(odocstream & os, string const & name, string const & attribute)
 {
     // FIXME UNICODE
@@ -686,9 +709,9 @@ void xml::openTag(odocstream & os, string const & name, string const & attribute
     string param = subst(attribute, "<", "\"");
     param = subst(param, ">", "\"");
 
-    // Note: we ignore the name if it empty or if it is a comment "<!-- -->" or
+    // Note: we ignore the name if it is empty or if it is a comment "<!-- -->" or
     // if the name is *dummy*.
-    // We ignore dummy because dummy is not a valid docbook element and it is
+    // We ignore dummy because dummy is not a valid DocBook element and it is
     // the internal name given to single paragraphs in the latex output.
     // This allow us to simplify the code a lot and is a reasonable compromise.
     if (!name.empty() && name != "!-- --" && name != "dummy") {
@@ -800,10 +823,10 @@ void closeBlockTag(XMLStream & xs, const docstring & tag)
 
 void xml::openTag(XMLStream & xs, const docstring & tag, const docstring & attr, const std::string & tagtype)
 {
-       if (tag.empty() || tag == "NONE") // Common check to be performed elsewhere, if it was not here.
+       if (tag.empty() || tag == from_ascii("NONE")) // Common check to be performed elsewhere, if it was not here.
                return;
 
-       if (tag == "para" || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
+       if (tag == from_ascii("para") || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
                openParTag(xs, tag, attr);
        else if (tagtype == "block")
                openBlockTag(xs, tag, attr);
@@ -812,7 +835,8 @@ void xml::openTag(XMLStream & xs, const docstring & tag, const docstring & attr,
        else if (tagtype == "none")
                xs << xml::StartTag(tag, attr);
        else
-               xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + to_utf8(tag) + " " + to_utf8(attr) + "'");
+               xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + to_utf8(tag) + (attr.empty() ? "" : " ") +
+                               to_utf8(attr) + "'");
 }