2003-03-12 22:17:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file bufferview_funcs.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-03-12 22:17:50 +00:00
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Angus Leeming
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-12 22:17:50 +00:00
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
2000-04-12 15:11:29 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "bufferview_funcs.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "author.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2000-04-12 15:11:29 +00:00
|
|
|
|
#include "BufferView.h"
|
2003-11-11 13:17:28 +00:00
|
|
|
|
#include "cursor.h"
|
2001-04-17 15:15:59 +00:00
|
|
|
|
#include "gettext.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "language.h"
|
2003-09-16 10:30:59 +00:00
|
|
|
|
#include "LColor.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
#include "lyxlex.h"
|
|
|
|
|
#include "lyxrow.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
|
#include "pariterator.h"
|
2000-04-12 15:11:29 +00:00
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include "frontends/Alert.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
|
|
2003-05-13 14:36:24 +00:00
|
|
|
|
#include "support/tostr.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
2003-02-20 17:39:48 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::bformat;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
|
|
|
|
using std::ostringstream;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
|
2002-11-21 18:33:09 +00:00
|
|
|
|
|
2003-04-03 00:36:31 +00:00
|
|
|
|
namespace bv_funcs {
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
// Set data using font and toggle
|
|
|
|
|
// If successful, returns true
|
|
|
|
|
bool font2string(LyXFont const & font, bool toggle, string & data)
|
|
|
|
|
{
|
|
|
|
|
string lang = "ignore";
|
|
|
|
|
if (font.language())
|
|
|
|
|
lang = font.language()->lang();
|
|
|
|
|
|
|
|
|
|
ostringstream os;
|
|
|
|
|
os << "family " << font.family() << '\n'
|
|
|
|
|
<< "series " << font.series() << '\n'
|
|
|
|
|
<< "shape " << font.shape() << '\n'
|
|
|
|
|
<< "size " << font.size() << '\n'
|
|
|
|
|
<< "emph " << font.emph() << '\n'
|
|
|
|
|
<< "underbar " << font.underbar() << '\n'
|
|
|
|
|
<< "noun " << font.noun() << '\n'
|
|
|
|
|
<< "number " << font.number() << '\n'
|
|
|
|
|
<< "color " << font.color() << '\n'
|
|
|
|
|
<< "language " << lang << '\n'
|
|
|
|
|
<< "toggleall " << tostr(toggle);
|
2003-09-15 11:00:00 +00:00
|
|
|
|
data = os.str();
|
2003-03-12 22:17:50 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set font and toggle using data
|
|
|
|
|
// If successful, returns true
|
|
|
|
|
bool string2font(string const & data, LyXFont & font, bool & toggle)
|
|
|
|
|
{
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(data);
|
2003-03-12 22:17:50 +00:00
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(is);
|
|
|
|
|
|
|
|
|
|
int nset = 0;
|
|
|
|
|
while (lex.isOK()) {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
string token;
|
|
|
|
|
if (lex.next())
|
|
|
|
|
token = lex.getString();
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
2003-04-01 09:39:06 +00:00
|
|
|
|
if (token.empty() || !lex.next())
|
2003-03-12 22:17:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (token == "family") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setFamily(LyXFont::FONT_FAMILY(next));
|
2003-03-30 21:42:09 +00:00
|
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
|
} else if (token == "series") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setSeries(LyXFont::FONT_SERIES(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "shape") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setShape(LyXFont::FONT_SHAPE(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "size") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setSize(LyXFont::FONT_SIZE(next));
|
2003-04-01 09:39:06 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "emph" || token == "underbar" ||
|
|
|
|
|
token == "noun" || token == "number") {
|
|
|
|
|
|
|
|
|
|
int const next = lex.getInteger();
|
|
|
|
|
LyXFont::FONT_MISC_STATE const misc =
|
2003-04-01 10:07:08 +00:00
|
|
|
|
LyXFont::FONT_MISC_STATE(next);
|
2003-04-01 09:39:06 +00:00
|
|
|
|
|
|
|
|
|
if (token == "emph")
|
|
|
|
|
font.setEmph(misc);
|
|
|
|
|
else if (token == "underbar")
|
|
|
|
|
font.setUnderbar(misc);
|
|
|
|
|
else if (token == "noun")
|
|
|
|
|
font.setNoun(misc);
|
|
|
|
|
else if (token == "number")
|
|
|
|
|
font.setNumber(misc);
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "color") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
int const next = lex.getInteger();
|
2003-04-01 10:07:08 +00:00
|
|
|
|
font.setColor(LColor::color(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "language") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
string const next = lex.getString();
|
|
|
|
|
if (next == "ignore")
|
2003-03-12 22:17:50 +00:00
|
|
|
|
font.setLanguage(ignore_language);
|
|
|
|
|
else
|
2003-04-01 09:39:06 +00:00
|
|
|
|
font.setLanguage(languages.getLanguage(next));
|
2003-03-12 22:17:50 +00:00
|
|
|
|
|
|
|
|
|
} else if (token == "toggleall") {
|
2003-04-01 09:39:06 +00:00
|
|
|
|
toggle = lex.getBool();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Unrecognised token
|
|
|
|
|
break;
|
2003-03-12 22:17:50 +00:00
|
|
|
|
}
|
2003-04-01 09:39:06 +00:00
|
|
|
|
|
|
|
|
|
++nset;
|
2003-03-12 22:17:50 +00:00
|
|
|
|
}
|
|
|
|
|
return (nset > 0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-10 09:45:32 +00:00
|
|
|
|
} // namespace bv_funcs
|