]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetquotes.C
Rename LatexRunParams::fragile as moving_arg.
[lyx.git] / src / insets / insetquotes.C
index 103b05f393750bc89201cfd03f05f84cb3889327..571adbf73b1e90f26170e509f592cb3f7fcfd1e9 100644 (file)
 
 #include <config.h>
 
-
 #include "insetquotes.h"
 
-#include "support/LAssert.h"
-#include "support/lstrings.h"
-#include "BufferView.h"
-#include "LaTeXFeatures.h"
-#include "frontends/Painter.h"
 #include "buffer.h"
+#include "BufferView.h"
 #include "debug.h"
-#include "frontends/font_metrics.h"
+#include "dimension.h"
 #include "language.h"
+#include "LaTeXFeatures.h"
+#include "latexrunparams.h"
 #include "lyxfont.h"
+#include "lyxlex.h"
 #include "lyxrc.h"
 #include "paragraph.h"
-#include "lyxlex.h"
+#include "frontends/font_metrics.h"
+#include "frontends/Painter.h"
+#include "support/LAssert.h"
+#include "support/lstrings.h"
 
 using std::ostream;
 using std::endl;
 
-// Quotes. Used for the various quotes. German, English, French,
-// Danish, Polish, all either double or single.
-
 namespace {
 
 // codes used to read/write quotes to LyX files
@@ -73,9 +71,7 @@ InsetQuotes::InsetQuotes(string const & str)
 }
 
 
-InsetQuotes::InsetQuotes(quote_language l,
-                        quote_side s,
-                        quote_times t)
+InsetQuotes::InsetQuotes(quote_language l, quote_side s, quote_times t)
        : language_(l), side_(s), times_(t)
 {}
 
@@ -86,8 +82,9 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params)
        // Decide whether left or right
        switch (c) {
        case ' ': case '(':
-       case Paragraph::META_HFILL:
-       case Paragraph::META_NEWLINE:
+#warning eh ? I am lost here ...
+       //case Paragraph::META_HFILL:
+       // case Paragraph::META_NEWLINE:
                side_ = LeftQ;   // left quote
                break;
        default:
@@ -152,15 +149,6 @@ string const InsetQuotes::dispString(Language const * loclang) const
        if (times_ == DoubleQ)
                disp += disp;
 
-       if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
-           || lyxrc.font_norm_type == LyXRC::ISO_8859_3
-           || lyxrc.font_norm_type == LyXRC::ISO_8859_4
-           || lyxrc.font_norm_type == LyXRC::ISO_8859_9) {
-               if (disp == "'")
-                       disp = "´";
-               else if (disp == "''")
-                       disp = "´´";
-       }
        if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
            || lyxrc.font_norm_type == LyXRC::ISO_8859_9
            || lyxrc.font_norm_type == LyXRC::ISO_8859_15) {
@@ -182,33 +170,22 @@ string const InsetQuotes::dispString(Language const * loclang) const
 }
 
 
-int InsetQuotes::ascent(BufferView *, LyXFont const & font) const
+void InsetQuotes::dimension(BufferView *, LyXFont const & font,
+       Dimension & dim) const
 {
-       return font_metrics::maxAscent(font);
-}
-
-
-int InsetQuotes::descent(BufferView *, LyXFont const & font) const
-{
-       return font_metrics::maxDescent(font);
-}
+       dim.a = font_metrics::maxAscent(font);
+       dim.d = font_metrics::maxDescent(font);
+       dim.w = 0;
 
-
-int InsetQuotes::width(BufferView *, LyXFont const & font) const
-{
        string const text = dispString(font.language());
-       int w = 0;
-
        for (string::size_type i = 0; i < text.length(); ++i) {
                if (text[i] == ' ')
-                       w += font_metrics::width('i', font);
+                       dim.w += font_metrics::width('i', font);
                else if (i == 0 || text[i] != text[i - 1])
-                       w += font_metrics::width(text[i], font);
+                       dim.w += font_metrics::width(text[i], font);
                else
-                       w += font_metrics::width(',', font);
+                       dim.w += font_metrics::width(',', font);
        }
-
-       return w;
 }
 
 
@@ -226,7 +203,7 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
 
 
 void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
-                      int baseline, float & x, bool) const
+                      int baseline, float & x) const
 {
        string const text = dispString(font.language());
 
@@ -261,18 +238,23 @@ void InsetQuotes::read(Buffer const *, LyXLex & lex)
 }
 
 
-extern bool use_babel;
-
 int InsetQuotes::latex(Buffer const * buf, ostream & os,
-                      bool /*fragile*/, bool /* free_spc */) const
+                      LatexRunParams const & runparams) const
 {
        // How do we get the local language here??
        lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this);
        lyx::Assert(curr_pos != -1);
+
+#warning FIXME. We _must_ find another way to get the language. (Lgb)
+#if 0
+       // This cannot be used. (Lgb)
        string const curr_lang =
                parOwner()->getFont(buf->params,
                                    curr_pos).language()->babel();
-
+#else
+       // And this is not the way... (Lgb)
+       string const curr_lang = buf->params.language->lang();
+#endif
        const int quoteind = quote_index[side_][language_];
        string qstr;
 
@@ -293,7 +275,7 @@ int InsetQuotes::latex(Buffer const * buf, ostream & os,
 #ifdef DO_USE_DEFAULT_LANGUAGE
        } else if (doclang == "default") {
 #else
-       } else if (!use_babel) {
+       } else if (!runparams.use_babel) {
 #endif
                qstr = latex_quote_ot1[times_][quoteind];
        } else {
@@ -340,6 +322,8 @@ int InsetQuotes::docbook(Buffer const *, ostream & os, bool) const
 }
 
 
+extern bool use_babel;
+
 void InsetQuotes::validate(LaTeXFeatures & features) const
 {
        char type = quote_char[quote_index[side_][language_]];