]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetQuotes.cpp
Pure HTML output for math macros.
[lyx.git] / src / insets / InsetQuotes.cpp
index 3b7c589071b5988afe2c57dd678873c8d65fd527..9fd534b2b6f5e847b1843a0e69efbe0d71403d55 100644 (file)
@@ -22,6 +22,7 @@
 #include "LyXRC.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
+#include "output_xhtml.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
@@ -40,7 +41,7 @@ namespace {
 
 /* codes used to read/write quotes to LyX files
  * e    ``english''
- * s    ''spanish''
+ * s    ''swedish''
  * g    ,,german``
  * p    ,,polish''
  * f    <<french>>
@@ -88,25 +89,27 @@ char const * const latex_quote_babel[2][5] = {
 } // namespace anon
 
 
-InsetQuotes::InsetQuotes(Buffer const & buf, string const & str)
+InsetQuotes::InsetQuotes(Buffer * buf, string const & str) : Inset(buf)
 {
        parseString(str);
-       setBuffer(const_cast<Buffer &>(buf));
 }
 
-InsetQuotes::InsetQuotes(Buffer const & buf, char_type c)
-       : language_(buf.params().quotes_language), times_(buf.params().quotes_times)
+InsetQuotes::InsetQuotes(Buffer * buf, char_type c) : Inset(buf)
 {
+       if (buf) {
+               language_ = buf->params().quotes_language;
+               times_ = buf->params().quotes_times;
+       }
        setSide(c);
-       setBuffer(const_cast<Buffer &>(buf));
 }
 
 
-InsetQuotes::InsetQuotes(Buffer const & buf, char_type c, QuoteTimes t)
-       : language_(buf.params().quotes_language), times_(t)
+InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteTimes t)
+       : Inset(buf), times_(t)
 {
+       if (buf)
+               language_ = buf->params().quotes_language;
        setSide(c);
-       setBuffer(const_cast<Buffer &>(buf));
 }
 
 
@@ -182,12 +185,14 @@ void InsetQuotes::parseString(string const & s)
 
 docstring InsetQuotes::displayString() const
 {
-       Language const * loclang = buffer().params().language;
+       Language const * loclang = 
+               isBufferValid() ? buffer().params().language : 0;
        int const index = quote_index[side_][language_];
        docstring retdisp = docstring(1, display_quote_char[times_][index]);
 
        // in french, spaces are added inside double quotes
-       if (times_ == DoubleQuotes && prefixIs(loclang->code(), "fr")) {
+       // FIXME: this should be done by a separate quote type.
+       if (times_ == DoubleQuotes && loclang && prefixIs(loclang->code(), "fr")) {
                if (side_ == LeftQuote)
                        retdisp += ' ';
                else
@@ -312,9 +317,9 @@ int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetQuotes::xhtml(odocstream & os, OutputParams const & op) const
+docstring InsetQuotes::xhtml(XHTMLStream & xs, OutputParams const & op) const
 {
-       docbook(os, op);
+       docbook(xs.os(), op);
        return docstring();
 }