2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetQuotes.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Jean-Marc Lasgouttes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetQuotes.h"
|
2001-12-13 11:35:25 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
2007-10-28 18:51:54 +00:00
|
|
|
|
#include "BufferView.h"
|
2007-11-03 18:50:54 +00:00
|
|
|
|
#include "Dimension.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Language.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h"
|
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
#include "OutputParams.h"
|
2003-08-26 16:36:53 +00:00
|
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
|
#include "frontends/FontMetrics.h"
|
2003-05-22 22:44:30 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2003-08-26 16:36:53 +00:00
|
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
|
#include "support/debug.h"
|
2007-11-01 22:17:22 +00:00
|
|
|
|
#include "support/docstring.h"
|
2007-11-28 22:12:03 +00:00
|
|
|
|
#include "support/docstream.h"
|
2003-05-19 17:03:12 +00:00
|
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
|
using namespace lyx::support;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2003-07-28 15:45:41 +00:00
|
|
|
|
/* codes used to read/write quotes to LyX files
|
|
|
|
|
* e ``english''
|
|
|
|
|
* s ''spanish''
|
|
|
|
|
* g ,,german``
|
|
|
|
|
* p ,,polish''
|
|
|
|
|
* f <<french>>
|
|
|
|
|
* a >>danish<<
|
|
|
|
|
*/
|
|
|
|
|
|
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 }, // "'',,<>"
|
2007-11-01 22:17:22 +00:00
|
|
|
|
{ 1, 1, 2, 1, 4, 3 } // "`'`'><"
|
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Corresponding LaTeX code, for double and single quotes.
|
2007-11-01 22:17:22 +00:00
|
|
|
|
char const * const latex_quote_t1[2][5] = {
|
|
|
|
|
{ "\\quotesinglbase ", "'", "`",
|
2002-03-21 17:09:55 +00:00
|
|
|
|
"\\guilsinglleft{}", "\\guilsinglright{}" },
|
2007-11-01 22:17:22 +00:00
|
|
|
|
{ ",,", "''", "``", "<<", ">>" }
|
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
|
char const * const latex_quote_ot1[2][5] = {
|
|
|
|
|
{ "\\quotesinglbase ", "'", "`",
|
2002-03-21 17:09:55 +00:00
|
|
|
|
"\\guilsinglleft{}", "\\guilsinglright{}" },
|
2002-10-15 10:39:57 +00:00
|
|
|
|
{ "\\quotedblbase ", "''", "``",
|
2007-11-01 22:17:22 +00:00
|
|
|
|
"\\guillemotleft{}", "\\guillemotright{}" }
|
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
|
char const * const latex_quote_babel[2][5] = {
|
|
|
|
|
{ "\\glq ", "'", "`", "\\flq{}", "\\frq{}" },
|
|
|
|
|
{ "\\glqq ", "''", "``", "\\flqq{}", "\\frqq{}" }
|
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
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
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
|
InsetQuotes::InsetQuotes(QuoteLanguage l, QuoteSide s, QuoteTimes t)
|
2001-07-20 09:38:19 +00:00
|
|
|
|
: language_(l), side_(s), times_(t)
|
2006-10-21 16:03:53 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2008-03-04 22:28:18 +00:00
|
|
|
|
InsetQuotes::InsetQuotes(Buffer const & buf, char_type c)
|
|
|
|
|
: language_(buf.params().quotes_language), times_(buf.params().quotes_times)
|
2004-02-20 10:32:44 +00:00
|
|
|
|
{
|
2008-03-15 00:02:41 +00:00
|
|
|
|
setSide(c);
|
2004-02-20 10:32:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
|
InsetQuotes::InsetQuotes(char_type c, QuoteLanguage l, QuoteTimes t)
|
2004-02-20 10:32:44 +00:00
|
|
|
|
: language_(l), times_(t)
|
|
|
|
|
{
|
2008-03-15 00:02:41 +00:00
|
|
|
|
setSide(c);
|
2004-02-20 10:32:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
|
docstring InsetQuotes::name() const
|
|
|
|
|
{
|
|
|
|
|
return from_ascii("Quotes");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
|
void InsetQuotes::setSide(char_type c)
|
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) {
|
2007-11-01 22:17:22 +00:00
|
|
|
|
case ' ':
|
|
|
|
|
case '(':
|
|
|
|
|
case '[':
|
2008-03-15 00:02:41 +00:00
|
|
|
|
side_ = LeftQuote; // left quote
|
1999-09-27 18:44:28 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2008-03-15 00:02:41 +00:00
|
|
|
|
side_ = RightQuote; // 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
|
|
|
|
{
|
2007-11-28 22:12:03 +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]) {
|
2008-03-15 00:02:41 +00:00
|
|
|
|
language_ = QuoteLanguage(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;
|
2008-03-15 00:02:41 +00:00
|
|
|
|
language_ = EnglishQuotes;
|
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]) {
|
2008-03-15 00:02:41 +00:00
|
|
|
|
side_ = QuoteSide(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;
|
2008-03-15 00:02:41 +00:00
|
|
|
|
side_ = LeftQuote;
|
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]) {
|
2008-03-15 00:02:41 +00:00
|
|
|
|
times_ = QuoteTimes(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;
|
2008-03-15 00:02:41 +00:00
|
|
|
|
times_ = DoubleQuotes;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
|
docstring InsetQuotes::displayString() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
|
Language const * loclang = buffer().params().language;
|
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_]];
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (times_ == DoubleQuotes)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
disp += disp;
|
|
|
|
|
|
2001-07-20 09:38:19 +00:00
|
|
|
|
|
2006-10-21 19:27:02 +00:00
|
|
|
|
docstring retdisp;
|
|
|
|
|
if (disp == "<<")
|
|
|
|
|
retdisp = docstring(1, 0x00ab); //'<27>';
|
|
|
|
|
else if (disp == ">>")
|
|
|
|
|
retdisp = docstring(1, 0x00bb); //'<27>';
|
|
|
|
|
#if 0
|
|
|
|
|
// The below are supposed to work, but something fails.
|
|
|
|
|
else if (disp == ",,")
|
|
|
|
|
retdisp = docstring(1, 0x201e);
|
|
|
|
|
else if (disp == "''")
|
|
|
|
|
retdisp == docstring(1, 0x201d);
|
|
|
|
|
else if (disp == "``")
|
|
|
|
|
retdisp == docstring(1, 0x201c);
|
|
|
|
|
else if (disp == "<")
|
|
|
|
|
retdisp = docstring(1, 0x2039);
|
|
|
|
|
else if (disp == ">")
|
|
|
|
|
retdisp = docstring(1, 0x203a);
|
|
|
|
|
else if (disp == ",")
|
|
|
|
|
retdisp = docstring(1, 0x201a);
|
|
|
|
|
else if (disp == "'")
|
|
|
|
|
retdisp = docstring(1, 0x2019);
|
|
|
|
|
else if (disp == "`")
|
|
|
|
|
retdisp = docstring(1, 0x2018);
|
|
|
|
|
#endif
|
|
|
|
|
else
|
2007-11-01 22:17:22 +00:00
|
|
|
|
retdisp = from_ascii(disp);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2001-07-20 09:38:19 +00:00
|
|
|
|
// in french, spaces are added inside double quotes
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (times_ == DoubleQuotes && prefixIs(loclang->code(), "fr")) {
|
|
|
|
|
if (side_ == LeftQuote)
|
2006-10-21 19:27:02 +00:00
|
|
|
|
retdisp += ' ';
|
2001-07-20 09:38:19 +00:00
|
|
|
|
else
|
2007-11-01 22:17:22 +00:00
|
|
|
|
retdisp.insert(size_t(0), 1, ' ');
|
2001-07-20 09:38:19 +00:00
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2006-10-21 19:27:02 +00:00
|
|
|
|
return retdisp;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2007-10-28 18:51:54 +00:00
|
|
|
|
FontInfo & font = mi.base.font;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
frontend::FontMetrics const & fm =
|
2006-10-11 17:24:46 +00:00
|
|
|
|
theFontMetrics(font);
|
2006-10-07 16:15:06 +00:00
|
|
|
|
dim.asc = fm.maxAscent();
|
|
|
|
|
dim.des = fm.maxDescent();
|
2003-05-27 13:55:03 +00:00
|
|
|
|
dim.wid = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
|
// FIXME: should we add a language or a font parameter member?
|
2008-03-15 00:02:41 +00:00
|
|
|
|
docstring const text = displayString();
|
2000-02-10 17:53:36 +00:00
|
|
|
|
for (string::size_type i = 0; i < text.length(); ++i) {
|
|
|
|
|
if (text[i] == ' ')
|
2006-10-07 16:15:06 +00:00
|
|
|
|
dim.wid += fm.width('i');
|
2002-08-20 17:18:21 +00:00
|
|
|
|
else if (i == 0 || text[i] != text[i - 1])
|
2006-10-07 16:15:06 +00:00
|
|
|
|
dim.wid += fm.width(text[i]);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
else
|
2006-10-07 16:15:06 +00:00
|
|
|
|
dim.wid += fm.width(',');
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2007-10-28 18:51:54 +00:00
|
|
|
|
// FIXME: should we add a language or a font parameter member?
|
2008-03-15 00:02:41 +00:00
|
|
|
|
docstring const text = displayString();
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
2002-06-12 15:56:51 +00:00
|
|
|
|
if (text.length() == 2 && text[0] == text[1]) {
|
2003-05-30 06:48:24 +00:00
|
|
|
|
pi.pain.text(x, y, text[0], pi.base.font);
|
2006-10-11 17:24:46 +00:00
|
|
|
|
int const t = theFontMetrics(pi.base.font)
|
2006-10-07 16:15:06 +00:00
|
|
|
|
.width(',');
|
2003-05-30 06:48:24 +00:00
|
|
|
|
pi.pain.text(x + t, y, text[0], pi.base.font);
|
|
|
|
|
} else {
|
2006-10-21 19:27:02 +00:00
|
|
|
|
pi.pain.text(x, y, text, pi.base.font);
|
2003-05-30 06:48:24 +00:00
|
|
|
|
}
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetQuotes::write(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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetQuotes::read(Lexer & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2004-10-05 12:56:22 +00:00
|
|
|
|
lex.next();
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetQuotes::latex(odocstream & os, OutputParams const & runparams) const
|
1999-09-27 18:44:28 +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
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (language_ == FrenchQuotes && times_ == DoubleQuotes
|
2005-09-09 11:04:53 +00:00
|
|
|
|
&& prefixIs(runparams.local_font->language()->code(), "fr")) {
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (side_ == LeftQuote)
|
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
|
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
|
2003-05-22 22:44:30 +00:00
|
|
|
|
} else if (!runparams.use_babel) {
|
2001-02-25 10:22:54 +00:00
|
|
|
|
#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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_ascii(qstr);
|
2000-03-02 02:19:43 +00:00
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetQuotes::plaintext(odocstream & os, OutputParams const &) const
|
2000-04-24 20:58:23 +00:00
|
|
|
|
{
|
2008-03-15 00:02:41 +00:00
|
|
|
|
docstring const str = displayString();
|
2007-02-17 11:30:58 +00:00
|
|
|
|
os << str;
|
|
|
|
|
return str.size();
|
2000-04-24 20:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (times_ == DoubleQuotes) {
|
|
|
|
|
if (side_ == LeftQuote)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << "“";
|
|
|
|
|
else
|
|
|
|
|
os << "”";
|
|
|
|
|
} else {
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (side_ == LeftQuote)
|
2000-03-06 02:42:40 +00:00
|
|
|
|
os << "‘";
|
|
|
|
|
else
|
|
|
|
|
os << "’";
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetQuotes::textString(odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
|
{
|
2008-03-15 00:02:41 +00:00
|
|
|
|
os << displayString();
|
2005-11-25 14:40:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
void InsetQuotes::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-05-23 11:18:43 +00:00
|
|
|
|
bool const use_babel = features.useBabel();
|
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") {
|
2008-03-15 00:02:41 +00:00
|
|
|
|
if (times_ == SingleQuotes)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
switch (type) {
|
2007-11-01 22:17:22 +00:00
|
|
|
|
case ',': features.require("quotesinglbase"); break;
|
2001-11-19 15:34:11 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|