git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25000 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-05-29 17:57:57 +00:00
parent 77ed747114
commit 2e968d0661
7 changed files with 50 additions and 58 deletions

View File

@ -21,7 +21,6 @@
#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/lassert.h"
#include <map>
@ -237,16 +236,14 @@ bool ColorSet::setColor(ColorCode col, string const & x11name)
{
InfoTab::iterator it = infotab.find(col);
if (it == infotab.end()) {
lyxerr << "Color " << col << " not found in database."
<< endl;
LYXERR0("Color " << col << " not found in database.");
return false;
}
// "inherit" is returned for colors not in the database
// (and anyway should not be redefined)
if (col == Color_none || col == Color_inherit || col == Color_ignore) {
lyxerr << "Color " << getLyXName(col)
<< " may not be redefined" << endl;
LYXERR0("Color " << getLyXName(col) << " may not be redefined.");
return false;
}
@ -280,8 +277,8 @@ ColorCode ColorSet::getFromLyXName(string const & lyxname) const
string const lcname = ascii_lowercase(lyxname);
Transform::const_iterator it = lyxcolors.find(lcname);
if (it == lyxcolors.end()) {
lyxerr << "ColorSet::getFromLyXName: Unknown color \""
<< lyxname << '"' << endl;
LYXERR0("ColorSet::getFromLyXName: Unknown color \""
<< lyxname << '"');
return Color_none;
}

View File

@ -663,7 +663,7 @@ int LyXRC::read(Lexer & lexrc)
case RC_USETEMPDIR:
if (lexrc.next())
lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
LYXERR0("Ignoring obsolete use_tempdir flag.");
break;
case RC_USELASTFILEPOS:
@ -757,23 +757,18 @@ int LyXRC::read(Lexer & lexrc)
lexrc >> typewriter_font_foundry;
break;
case RC_SET_COLOR:
{
string lyx_name, x11_name;
if (lexrc.next()) {
lyx_name = lexrc.getString();
} else {
case RC_SET_COLOR: {
if (!lexrc.next()) {
lexrc.printError("Missing color tag.");
break;
}
string lyx_name = lexrc.getString();
if (lexrc.next()) {
x11_name = lexrc.getString();
} else {
if (!lexrc.next()) {
lexrc.printError("Missing color name for color: `$$Token'");
break;
}
string x11_name = lexrc.getString();
ColorCode const col =
lcolor.getFromLyXName(lyx_name);
@ -782,13 +777,11 @@ int LyXRC::read(Lexer & lexrc)
col == Color_ignore)
break;
if (!lcolor.setColor(col, x11_name)) {
lyxerr << "Bad lyxrc set_color for "
<< lyx_name << endl;
}
if (!lcolor.setColor(col, x11_name))
LYXERR0("Bad lyxrc set_color for " << lyx_name);
break;
}
case RC_AUTOREGIONDELETE:
// Auto region delete defaults to true
lexrc >> auto_region_delete;
@ -832,9 +825,8 @@ int LyXRC::read(Lexer & lexrc)
lexrc >> use_spell_lib;
break;
case RC_SPELL_COMMAND:
if (lexrc.next(true)) {
if (lexrc.next(true))
isp_command = lexrc.getString();
}
break;
case RC_ACCEPT_COMPOUND:
lexrc >> isp_accept_compound;
@ -918,30 +910,24 @@ int LyXRC::read(Lexer & lexrc)
case RC_COPIER: {
string fmt, command;
if (lexrc.next()) {
if (lexrc.next())
fmt = lexrc.getString();
}
if (lexrc.next(true)) {
if (lexrc.next(true))
command = lexrc.getString();
}
setMover(fmt, command);
break;
}
case RC_CONVERTER: {
string from, to, command, flags;
if (lexrc.next()) {
if (lexrc.next())
from = lexrc.getString();
}
if (lexrc.next()) {
if (lexrc.next())
to = lexrc.getString();
}
if (lexrc.next(true)) {
if (lexrc.next(true))
command = lexrc.getString();
}
if (lexrc.next()) {
if (lexrc.next())
flags = lexrc.getString();
}
if (command.empty())
theConverters().erase(from, to);
else
@ -987,13 +973,13 @@ int LyXRC::read(Lexer & lexrc)
else if (flag == "vector")
flgs |= Format::vector;
else
lyxerr << "Ignoring unknown flag `"
LYXERR0("Ignoring unknown flag `"
<< flag << "' for format `"
<< format << "'." << endl;
<< format << "'.");
}
if (prettyname.empty()) {
if (theConverters().formatIsUsed(format))
LYXERR0( "Can't delete format " << format);
LYXERR0("Can't delete format " << format);
else
formats.erase(format);
} else {
@ -1024,9 +1010,8 @@ int LyXRC::read(Lexer & lexrc)
else {
preview = PREVIEW_OFF;
if (tmp != "false" && tmp != "off")
lyxerr << "Unrecognized "
"preview status \""
<< tmp << '\n' << endl;
LYXERR0("Unrecognized preview status \""
<< tmp << '\n');
}
}
break;
@ -1679,10 +1664,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
case RC_SET_COLOR:
for (int i = 0; i < Color_ignore; ++i) {
ColorCode lc = static_cast<ColorCode>(i);
string const col(lcolor.getX11Name(lc));
if (ignore_system_lyxrc ||
col != system_lcolor.getX11Name(lc)) {
string const col = lcolor.getX11Name(lc);
if (ignore_system_lyxrc
|| col != system_lcolor.getX11Name(lc)) {
os << "\\set_color \""
<< lcolor.getLyXName(lc) << "\" \""
<< col << "\"\n";

View File

@ -22,6 +22,16 @@ void ColorCache::init()
{
for (int col = 0; col <= Color_ignore; ++col)
lcolors_[col] = QColor(lcolor.getX11Name(ColorCode(col)).c_str());
initialized_ = true;
}
/// get the given color
QColor const & ColorCache::get(ColorCode color) const
{
if (!initialized_)
const_cast<ColorCache *>(this)->init();
return lcolors_[color];
}

View File

@ -26,19 +26,21 @@ struct RGBColor;
class ColorCache
{
public:
ColorCache() { init(); }
ColorCache() : initialized_(false) {}
/// get the given color
QColor const & get(ColorCode color) const { return lcolors_[color]; }
QColor const & get(ColorCode color) const;
/// clear all colors
void clear() { init(); }
void clear() { initialized_ = false; }
private:
///
void init();
///
QColor lcolors_[Color_ignore + 1];
///
bool initialized_;
};
///

View File

@ -200,7 +200,9 @@ public:
}
bool canConvert(QString const & mime, QString flav)
{ return mimeFor(flav) == mime; }
{
return mimeFor(flav) == mime;
}
QVariant convertToMime(QString const & mime, QList<QByteArray> data, QString flav)
{

View File

@ -20,8 +20,6 @@
#include "GuiView.h"
#include "qt_helpers.h"
#include "support/debug.h"
#include <QDockWidget>
#include <QString>
#include <QTextCharFormat>

View File

@ -12,22 +12,21 @@
#include "support/docstring.h"
#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/qstring_helpers.h"
#include "support/unicode.h"
#include <QFile>
#include <locale>
#include <iostream>
#include <typeinfo>
#include <QFile>
#include "support/lassert.h"
using namespace std;
namespace lyx {
namespace lyx {
docstring const from_ascii(char const * ascii)
{