1999-09-27 18:44:28 +00:00
|
|
|
|
/* This file is part of
|
|
|
|
|
* ======================================================
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
1999-09-27 18:44:28 +00:00
|
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
1999-11-15 10:58:38 +00:00
|
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "insetquotes.h"
|
2001-12-13 11:35:25 +00:00
|
|
|
|
|
|
|
|
|
#include "support/LAssert.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2001-12-13 11:35:25 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "LaTeXFeatures.h"
|
2002-05-23 09:21:32 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2001-12-13 11:35:25 +00:00
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "debug.h"
|
2002-05-24 14:34:32 +00:00
|
|
|
|
#include "frontends/font_metrics.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
|
#include "language.h"
|
2001-12-13 11:35:25 +00:00
|
|
|
|
#include "lyxfont.h"
|
|
|
|
|
#include "lyxrc.h"
|
|
|
|
|
#include "paragraph.h"
|
2002-07-21 21:21:06 +00:00
|
|
|
|
#include "lyxlex.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
|
using std::ostream;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Quotes. Used for the various quotes. German, English, French,
|
|
|
|
|
// Danish, Polish, all either double or single.
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// codes used to read/write quotes to LyX files
|
2001-03-20 01:22:46 +00:00
|
|
|
|
char const * const language_char = "esgpfa";
|
|
|
|
|
char const * const side_char = "lr" ;
|
|
|
|
|
char const * const times_char = "sd";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// List of known quote chars
|
2001-03-20 01:22:46 +00:00
|
|
|
|
char const * const quote_char = ",'`<>";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-15 10:58:38 +00:00
|
|
|
|
// Index of chars used for the quote. Index is [side, language]
|
1999-12-07 00:44:53 +00:00
|
|
|
|
int quote_index[2][6] = {
|
2002-03-21 17:09:55 +00:00
|
|
|
|
{ 2, 1, 0, 0, 3, 4 }, // "'',,<>"
|
1999-12-07 00:44:53 +00:00
|
|
|
|
{ 1, 1, 2, 1, 4, 3 } }; // "`'`'><"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Corresponding LaTeX code, for double and single quotes.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
char const * const latex_quote_t1[2][5] =
|
|
|
|
|
{ { "\\quotesinglbase{}", "'", "`",
|
|
|
|
|
"\\guilsinglleft{}", "\\guilsinglright{}" },
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{ ",,", "''", "``", "<<", ">>" } };
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
char const * const latex_quote_ot1[2][5] =
|
|
|
|
|
{ { "\\quotesinglbase{}", "'", "`",
|
|
|
|
|
"\\guilsinglleft{}", "\\guilsinglright{}" },
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{ "\\quotedblbase{}", "''", "``",
|
|
|
|
|
"\\guillemotleft{}", "\\guillemotright{}" } };
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
char const * const latex_quote_babel[2][5] =
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{ { "\\glq{}", "'", "`", "\\flq{}", "\\frq{}" },
|
|
|
|
|
{ "\\glqq{}", "''", "``", "\\flqq{}", "\\frqq{}" } };
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
InsetQuotes::InsetQuotes(string const & str)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
|
parseString(str);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2001-07-20 09:38:19 +00:00
|
|
|
|
InsetQuotes::InsetQuotes(quote_language l,
|
|
|
|
|
quote_side s,
|
|
|
|
|
quote_times t)
|
|
|
|
|
: language_(l), side_(s), times_(t)
|
2000-07-15 23:51:46 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
InsetQuotes::InsetQuotes(char c, BufferParams const & params)
|
2001-07-20 09:38:19 +00:00
|
|
|
|
: language_(params.quotes_language), times_(params.quotes_times)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2002-03-21 17:09:55 +00:00
|
|
|
|
// Decide whether left or right
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (c) {
|
2002-03-21 17:09:55 +00:00
|
|
|
|
case ' ': case '(':
|
2001-06-25 00:06:33 +00:00
|
|
|
|
case Paragraph::META_HFILL:
|
2002-03-21 17:09:55 +00:00
|
|
|
|
case Paragraph::META_NEWLINE:
|
|
|
|
|
side_ = LeftQ; // left quote
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2001-07-20 09:38:19 +00:00
|
|
|
|
side_ = RightQ; // right quote
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetQuotes::parseString(string const & s)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
|
string str(s);
|
1999-10-02 16:21:10 +00:00
|
|
|
|
if (str.length() != 3) {
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
|
|
|
" bad string length." << endl;
|
1999-10-02 16:21:10 +00:00
|
|
|
|
str = "eld";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
int i;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
for (i = 0; i < 6; ++i) {
|
1999-10-02 16:21:10 +00:00
|
|
|
|
if (str[0] == language_char[i]) {
|
2001-07-20 09:38:19 +00:00
|
|
|
|
language_ = quote_language(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
if (i >= 6) {
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
|
|
|
" bad language specification." << endl;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
language_ = EnglishQ;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
for (i = 0; i < 2; ++i) {
|
1999-10-02 16:21:10 +00:00
|
|
|
|
if (str[1] == side_char[i]) {
|
2001-07-20 09:38:19 +00:00
|
|
|
|
side_ = quote_side(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
if (i >= 2) {
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
|
|
|
" bad side specification." << endl;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
side_ = LeftQ;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
for (i = 0; i < 2; ++i) {
|
1999-10-02 16:21:10 +00:00
|
|
|
|
if (str[2] == times_char[i]) {
|
2001-07-20 09:38:19 +00:00
|
|
|
|
times_ = quote_times(i);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
if (i >= 2) {
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
|
|
|
" bad times specification." << endl;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
times_ = DoubleQ;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
|
string const InsetQuotes::dispString(Language const * loclang) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2002-03-21 17:09:55 +00:00
|
|
|
|
string disp;
|
2001-07-20 09:38:19 +00:00
|
|
|
|
disp += quote_char[quote_index[side_][language_]];
|
|
|
|
|
if (times_ == DoubleQ)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
disp += disp;
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
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) {
|
2001-07-27 16:07:33 +00:00
|
|
|
|
if (disp == "'")
|
|
|
|
|
disp = "<EFBFBD>";
|
|
|
|
|
else if (disp == "''")
|
|
|
|
|
disp = "<EFBFBD><EFBFBD>";
|
2001-10-05 16:25:34 +00:00
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
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) {
|
2001-10-05 16:25:34 +00:00
|
|
|
|
if (disp == "<<")
|
1999-09-27 18:44:28 +00:00
|
|
|
|
disp = '<EFBFBD>';
|
|
|
|
|
else if (disp == ">>")
|
|
|
|
|
disp = '<EFBFBD>';
|
2001-07-27 16:07:33 +00:00
|
|
|
|
}
|
2001-07-20 09:38:19 +00:00
|
|
|
|
|
|
|
|
|
// in french, spaces are added inside double quotes
|
2001-07-23 09:11:14 +00:00
|
|
|
|
if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) {
|
2001-07-20 09:38:19 +00:00
|
|
|
|
if (side_ == LeftQ)
|
|
|
|
|
disp += " ";
|
|
|
|
|
else
|
|
|
|
|
disp = " " + disp;
|
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
|
|
|
|
return disp;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
|
int InsetQuotes::ascent(BufferView *, LyXFont const & font) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2002-05-24 14:34:32 +00:00
|
|
|
|
return font_metrics::maxAscent(font);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
|
int InsetQuotes::descent(BufferView *, LyXFont const & font) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2002-05-24 14:34:32 +00:00
|
|
|
|
return font_metrics::maxDescent(font);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
|
int InsetQuotes::width(BufferView *, LyXFont const & font) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2001-07-23 09:11:14 +00:00
|
|
|
|
string const text = dispString(font.language());
|
2000-02-10 17:53:36 +00:00
|
|
|
|
int w = 0;
|
|
|
|
|
|
|
|
|
|
for (string::size_type i = 0; i < text.length(); ++i) {
|
|
|
|
|
if (text[i] == ' ')
|
2002-05-24 14:34:32 +00:00
|
|
|
|
w += font_metrics::width('i', font);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
else if (i == 0 || text[i] != text[i-1])
|
2002-05-24 14:34:32 +00:00
|
|
|
|
w += font_metrics::width(text[i], font);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
else
|
2002-05-24 14:34:32 +00:00
|
|
|
|
w += font_metrics::width(',', font);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return w;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#if 0
|
2001-06-28 10:25:20 +00:00
|
|
|
|
LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#if 1
|
|
|
|
|
return f;
|
|
|
|
|
#else
|
2000-07-15 23:51:46 +00:00
|
|
|
|
LyXFont font(f);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return font;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
|
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
|
2000-06-23 15:02:46 +00:00
|
|
|
|
int baseline, float & x, bool) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2001-07-23 09:11:14 +00:00
|
|
|
|
string const text = dispString(font.language());
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
2002-06-12 15:56:51 +00:00
|
|
|
|
if (text.length() == 2 && text[0] == text[1]) {
|
|
|
|
|
bv->painter().text(int(x), baseline, text[0], font);
|
2002-06-13 10:11:32 +00:00
|
|
|
|
int x2 = int(x + font_metrics::width(',', font));
|
2002-06-12 15:56:51 +00:00
|
|
|
|
bv->painter().text(x2, baseline, text[0], font);
|
|
|
|
|
} else
|
|
|
|
|
bv->painter().text(int(x), baseline, text, font);
|
2000-07-05 14:57:48 +00:00
|
|
|
|
x += width(bv, font);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetQuotes::write(Buffer const *, ostream & os) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string text;
|
2001-07-20 09:38:19 +00:00
|
|
|
|
text += language_char[language_];
|
|
|
|
|
text += side_char[side_];
|
2002-03-21 17:09:55 +00:00
|
|
|
|
text += times_char[times_];
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "Quotes " << text;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetQuotes::read(Buffer const *, LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
lex.nextToken();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
parseString(lex.getString());
|
2000-07-15 23:51:46 +00:00
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
if (lex.getString() != "\\end_inset") {
|
2001-07-23 09:11:14 +00:00
|
|
|
|
lex.printError("Missing \\end_inset at this point");
|
2001-08-06 19:13:25 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-02-25 10:22:54 +00:00
|
|
|
|
extern bool use_babel;
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetQuotes::latex(Buffer const * buf, ostream & os,
|
2001-12-13 11:35:25 +00:00
|
|
|
|
bool /*fragile*/, bool /* free_spc */) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-08-19 13:13:47 +00:00
|
|
|
|
// How do we get the local language here??
|
2001-12-13 11:35:25 +00:00
|
|
|
|
lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this);
|
|
|
|
|
lyx::Assert(curr_pos != -1);
|
|
|
|
|
string const curr_lang =
|
|
|
|
|
parOwner()->getFont(buf->params,
|
|
|
|
|
curr_pos).language()->babel();
|
2001-08-19 13:13:47 +00:00
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
|
const int quoteind = quote_index[side_][language_];
|
2000-03-02 02:19:43 +00:00
|
|
|
|
string qstr;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-07-23 10:04:17 +00:00
|
|
|
|
if (language_ == FrenchQ && times_ == DoubleQ
|
2001-12-13 11:35:25 +00:00
|
|
|
|
&& curr_lang == "frenchb") {
|
2002-03-21 17:09:55 +00:00
|
|
|
|
if (side_ == LeftQ)
|
2001-07-23 10:04:17 +00:00
|
|
|
|
qstr = "\\og "; //the spaces are important here
|
2002-03-21 17:09:55 +00:00
|
|
|
|
else
|
2001-07-23 10:04:17 +00:00
|
|
|
|
qstr = " \\fg{}"; //and here
|
|
|
|
|
} else if (language_ == FrenchQ && times_ == DoubleQ
|
2001-12-13 11:35:25 +00:00
|
|
|
|
&& curr_lang == "french") {
|
2002-03-21 17:09:55 +00:00
|
|
|
|
if (side_ == LeftQ)
|
2001-07-23 10:04:17 +00:00
|
|
|
|
qstr = "<< "; //the spaces are important here
|
2002-03-21 17:09:55 +00:00
|
|
|
|
else
|
2001-07-23 10:04:17 +00:00
|
|
|
|
qstr = " >>"; //and here
|
2001-07-20 09:38:19 +00:00
|
|
|
|
} else if (lyxrc.fontenc == "T1") {
|
|
|
|
|
qstr = latex_quote_t1[times_][quoteind];
|
2001-02-25 10:22:54 +00:00
|
|
|
|
#ifdef DO_USE_DEFAULT_LANGUAGE
|
2000-07-15 23:51:46 +00:00
|
|
|
|
} else if (doclang == "default") {
|
2001-02-25 10:22:54 +00:00
|
|
|
|
#else
|
|
|
|
|
} else if (!use_babel) {
|
|
|
|
|
#endif
|
2001-07-20 09:38:19 +00:00
|
|
|
|
qstr = latex_quote_ot1[times_][quoteind];
|
2002-03-21 17:09:55 +00:00
|
|
|
|
} else {
|
2001-07-20 09:38:19 +00:00
|
|
|
|
qstr = latex_quote_babel[times_][quoteind];
|
|
|
|
|
}
|
2000-03-02 02:19:43 +00:00
|
|
|
|
|
|
|
|
|
// Always guard against unfortunate ligatures (!` ?`)
|
2001-04-18 13:37:27 +00:00
|
|
|
|
if (prefixIs(qstr, "`"))
|
|
|
|
|
qstr.insert(0, "{}");
|
2000-03-02 02:19:43 +00:00
|
|
|
|
|
|
|
|
|
os << qstr;
|
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetQuotes::ascii(Buffer const *, ostream & os, int) const
|
2000-04-24 20:58:23 +00:00
|
|
|
|
{
|
|
|
|
|
os << "\"";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetQuotes::linuxdoc(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
|
|
|
|
os << "\"";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
int InsetQuotes::docbook(Buffer const *, ostream & os, bool) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
2001-07-20 09:38:19 +00:00
|
|
|
|
if (times_ == DoubleQ) {
|
|
|
|
|
if (side_ == LeftQ)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << "“";
|
|
|
|
|
else
|
|
|
|
|
os << "”";
|
|
|
|
|
} else {
|
2001-07-20 09:38:19 +00:00
|
|
|
|
if (side_ == LeftQ)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << "‘";
|
|
|
|
|
else
|
|
|
|
|
os << "’";
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
void InsetQuotes::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-07-20 09:38:19 +00:00
|
|
|
|
char type = quote_char[quote_index[side_][language_]];
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
|
#ifdef DO_USE_DEFAULT_LANGUAGE
|
2002-03-21 17:09:55 +00:00
|
|
|
|
if (features.bufferParams().language->lang() == "default"
|
2001-07-23 09:11:14 +00:00
|
|
|
|
#else
|
|
|
|
|
if (!use_babel
|
|
|
|
|
#endif
|
2000-03-12 10:35:05 +00:00
|
|
|
|
&& lyxrc.fontenc != "T1") {
|
2002-03-21 17:09:55 +00:00
|
|
|
|
if (times_ == SingleQ)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
switch (type) {
|
2001-11-19 15:34:11 +00:00
|
|
|
|
case ',': features.require("quotesinglbase"); break;
|
|
|
|
|
case '<': features.require("guilsinglleft"); break;
|
|
|
|
|
case '>': features.require("guilsinglright"); break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
default: break;
|
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
else
|
1999-09-27 18:44:28 +00:00
|
|
|
|
switch (type) {
|
2001-11-19 15:34:11 +00:00
|
|
|
|
case ',': features.require("quotedblbase"); break;
|
|
|
|
|
case '<': features.require("guillemotleft"); break;
|
|
|
|
|
case '>': features.require("guillemotright"); break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
Inset * InsetQuotes::clone(Buffer const &, bool) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-07-20 09:38:19 +00:00
|
|
|
|
return new InsetQuotes(language_, side_, times_);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
Inset::Code InsetQuotes::lyxCode() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
return Inset::QUOTE_CODE;
|
|
|
|
|
}
|