compile fix in XPM image loader; fix opaque handling; remove warnings; fix turkish locale problems; add shortcuts to documents menu

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4661 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-07-16 21:17:10 +00:00
parent 88d7912df3
commit 57e89ae2bf
26 changed files with 149 additions and 50 deletions

View File

@ -1,3 +1,36 @@
2002-07-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* MenuBackend.C (expand): add numeric shortcuts to document menu
* lyxrc.C (getDescription): remove RC_NEW_ASK_FILENAME
2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* lyxfont.C (setLyXFamily):
(setLyXSeries):
(setLyXShape):
(setLyXSize):
(setLyXMisc):
(lyxRead):
* debug.C (value):
* buffer.C (asciiParagraph): use ascii_lowercase
2002-07-15 Mike Fabian <mfabian@suse.de>
* lyxlex_pimpl.C (search_kw):
* lyxlex.C (getLongString):
* converter.h (operator<):
* converter.C (operator<):
* buffer.C (parseSingleLyXformat2Token):
(asciiParagraph):
* ToolbarDefaults.C (read):
* MenuBackend.C (checkShortcuts):
(read):
* LColor.C (getFromGUIName):
(getFromLyXName): use the compare_ascii_no_case instead of
compare_no_case, because in turkish, 'i' is not the lowercase
version of 'I', and thus turkish locale breaks parsing of tags.
2002-07-16 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (buffer): Previews::generateBufferPreviews

View File

@ -185,7 +185,7 @@ LColor::color LColor::getFromGUIName(string const & guiname) const
InfoTab::const_iterator ici = infotab.begin();
InfoTab::const_iterator end = infotab.end();
for (; ici != end; ++ici) {
if (!compare_no_case(_(ici->second.guiname), guiname))
if (!compare_ascii_no_case(_(ici->second.guiname), guiname))
return ici->first;
}
return LColor::inherit;
@ -198,7 +198,7 @@ LColor::color LColor::getFromLyXName(string const & lyxname) const
InfoTab::const_iterator ici = infotab.begin();
InfoTab::const_iterator end = infotab.end();
for (; ici != end; ++ici) {
if (!compare_no_case(ici->second.lyxname, lyxname))
if (!compare_ascii_no_case(ici->second.lyxname, lyxname))
return ici->first;
}
return LColor::inherit;

View File

@ -237,7 +237,7 @@ void Menu::checkShortcuts() const
<< "\" does not contain shortcut `"
<< shortcut << '\'' << endl;
for (const_iterator it2 = begin(); it2 != it1 ; ++it2) {
if (!compare_no_case(it2->shortcut(), shortcut)) {
if (!compare_ascii_no_case(it2->shortcut(), shortcut)) {
lyxerr << "Menu warning: menu entries "
<< '"' << it1->fulllabel()
<< "\" and \"" << it2->fulllabel()
@ -296,14 +296,17 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const
break;
}
int ii = 1;
Strings::const_iterator docit = names.begin();
Strings::const_iterator end = names.end();
for (; docit != end ; ++docit) {
for (; docit != end; ++docit, ++ii) {
int const action = lyxaction
.getPseudoAction(LFUN_SWITCHBUFFER,
*docit);
string const label =
MakeDisplayPath(*docit, 30);
string label = MakeDisplayPath(*docit, 30);
if (ii < 10)
label = tostr(ii) + ". "
+ label + '|' + tostr(ii);
tomenu.add(MenuItem(MenuItem::Command,
label, action));
}
@ -451,7 +454,7 @@ void MenuBackend::read(LyXLex & lex)
};
//consistency check
if (compare_no_case(lex.getString(), "menuset")) {
if (compare_ascii_no_case(lex.getString(), "menuset")) {
lyxerr << "Menubackend::read: ERROR wrong token:`"
<< lex.getString() << '\'' << endl;
}

View File

@ -98,7 +98,7 @@ void ToolbarDefaults::init()
void ToolbarDefaults::read(LyXLex & lex)
{
//consistency check
if (compare_no_case(lex.getString(), "toolbar")) {
if (compare_ascii_no_case(lex.getString(), "toolbar")) {
lyxerr << "Toolbar::read: ERROR wrong token:`"
<< lex.getString() << '\'' << endl;
}

View File

@ -548,7 +548,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
layoutname = tclass.defaultLayoutName();
}
#ifndef NO_COMPABILITY
if (compare_no_case(layoutname, "latex") == 0) {
if (compare_ascii_no_case(layoutname, "latex") == 0) {
ert_comp.active = true;
ert_comp.fromlayout = true;
ert_comp.font = font;
@ -569,7 +569,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
#ifdef USE_CAPTION
// The is the compability reading of layout caption.
// It can be removed in LyX version 1.3.0. (Lgb)
if (compare_no_case(layoutname, "caption") == 0) {
if (compare_ascii_no_case(layoutname, "caption") == 0) {
// We expect that the par we are now working on is
// really inside a InsetText inside a InsetFloat.
// We also know that captions can only be
@ -1581,7 +1581,7 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
// This strange command allows LyX to recognize "natbib" style
// citations: citet, citep, Citet etc.
if (compare_no_case(cmdName, "cite", 4) == 0) {
if (compare_ascii_no_case(cmdName.substr(0,4), "cite") == 0) {
inset = new InsetCitation(inscmd);
} else if (cmdName == "bibitem") {
lex.printError("Wrong place for bibitem");
@ -1958,22 +1958,22 @@ string const Buffer::asciiParagraph(Paragraph const * par,
if (compare_no_case(tmp, "itemize") == 0) {
ltype = 1;
ltype_depth = depth + 1;
} else if (compare_no_case(tmp, "enumerate") == 0) {
} else if (compare_ascii_no_case(tmp, "enumerate") == 0) {
ltype = 2;
ltype_depth = depth + 1;
} else if (contains(lowercase(tmp), "ection")) {
} else if (contains(ascii_lowercase(tmp), "ection")) {
ltype = 3;
ltype_depth = depth + 1;
} else if (contains(lowercase(tmp), "aragraph")) {
} else if (contains(ascii_lowercase(tmp), "aragraph")) {
ltype = 4;
ltype_depth = depth + 1;
} else if (compare_no_case(tmp, "description") == 0) {
} else if (compare_ascii_no_case(tmp, "description") == 0) {
ltype = 5;
ltype_depth = depth + 1;
} else if (compare_no_case(tmp, "abstract") == 0) {
} else if (compare_ascii_no_case(tmp, "abstract") == 0) {
ltype = 6;
ltype_depth = 0;
} else if (compare_no_case(tmp, "bibliography") == 0) {
} else if (compare_ascii_no_case(tmp, "bibliography") == 0) {
ltype = 7;
ltype_depth = 0;
} else {

View File

@ -264,10 +264,13 @@ void Converter::readFlags()
bool operator<(Converter const & a, Converter const & b)
{
int const i = compare_no_case(a.From->prettyname(),
b.From->prettyname());
// use the compare_ascii_no_case instead of compare_no_case,
// because in turkish, 'i' is not the lowercase version of 'I',
// and thus turkish locale breaks parsing of tags.
int const i = compare_ascii_no_case(a.From->prettyname(),
b.From->prettyname());
if (i == 0)
return compare_no_case(a.To->prettyname(), b.To->prettyname())
return compare_ascii_no_case(a.To->prettyname(), b.To->prettyname())
< 0;
else
return i < 0;

View File

@ -77,7 +77,11 @@ private:
inline
bool operator<(Format const & a, Format const & b)
{
return compare_no_case(a.prettyname(), b.prettyname()) < 0;
// use the compare_ascii_no_case instead of compare_no_case,
// because in turkish, 'i' is not the lowercase version of 'I',
// and thus turkish locale breaks parsing of tags.
return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0;
}

View File

@ -80,7 +80,7 @@ Debug::type Debug::value(string const & val)
string v(val);
while (!v.empty()) {
string::size_type st = v.find(',');
string tmp(lowercase(v.substr(0, st)));
string tmp(ascii_lowercase(v.substr(0, st)));
if (tmp.empty())
break;
// Is it a number?

View File

@ -1,3 +1,13 @@
2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* biblio.C (parseBibTeX): use ascii_lowercase instead of lowercase
2002-07-15 Mike Fabian <mfabian@suse.de>
* biblio.C (compareNoCase): use the compare_ascii_no_case instead
of compare_no_case, because in turkish, 'i' is not the lowercase
version of 'I', and thus turkish locale breaks parsing of tags.
2002-07-04 Lars Gullik Bjønnes <larsbj@birdstep.com>
* ControlBibtex.C (applyParamsToInset): ws change

View File

@ -266,7 +266,7 @@ string const getYear(InfoMap const & map, string const & key)
struct compareNoCase: public std::binary_function<string, string, bool>
{
bool operator()(string const & s1, string const & s2) const {
return compare_no_case(s1, s2) < 0;
return compare_ascii_no_case(s1, s2) < 0;
}
};
@ -424,9 +424,9 @@ string const parseBibTeX(string data, string const & findkey)
do {
dummy = token(data, ',', Entries++);
if (!dummy.empty()) {
found = contains(lowercase(dummy), findkey);
found = contains(ascii_lowercase(dummy), findkey);
if (findkey == "title" &&
contains(lowercase(dummy), "booktitle"))
contains(ascii_lowercase(dummy), "booktitle"))
found = false;
}
} while (!found && !dummy.empty());

View File

@ -1,3 +1,15 @@
2002-07-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* PreviewLoader.C (setConverter): remove unused variable
* GraphicsImageXPM.C (isDrawable): implement
(setPixmap): the opaque color is black, not white
2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* GraphicsImageXPM.C (color_none_id):
(contains_color_none): use ascii_lowercase instead of lowercase
2002-07-16 Angus Leeming <leeming@lyx.org>
* PreviewLoader.C: greater use of STL algorithms.
@ -280,6 +292,7 @@
pretty temperamemtal at the moment.
2002-04-16 Rob Lahaye <lahaye@users.sourceforge.net>
* GraphicsImageXPM.C: fix clipping for boundingbox y-coordinates
2002-04-08 Angus Leeming <a.leeming@ic.ac.uk>

View File

@ -95,6 +95,12 @@ unsigned int ImageXPM::getHeight() const
}
bool ImageXPM::isDrawable() const
{
return pixmap_;
}
Pixmap ImageXPM::getPixmap() const
{
if (!pixmap_status_ == PIXMAP_SUCCESS)
@ -207,7 +213,7 @@ bool ImageXPM::setPixmap(Params const & params)
// some image magick versions use this
xpm_col[1].name = 0;
xpm_col[1].value = "opaque";
xpm_col[1].pixel = lyxColorHandler->colorPixel(LColor::white);
xpm_col[1].pixel = lyxColorHandler->colorPixel(LColor::black);
attrib.numsymbols = 2;
attrib.colorsymbols = xpm_col;
@ -552,7 +558,7 @@ unsigned int ImageXPM::Data::color_none_id() const
XpmColor * table = colorTable_.get();
for (size_t i = 0; i < ncolors_; ++i) {
char const * const color = table[i].c_color;
if (color && lowercase(color) == "none")
if (color && ascii_lowercase(color) == "none")
return uint(i);
}
return 0;
@ -699,7 +705,7 @@ bool contains_color_none(XpmImage const & image)
{
for (size_t i = 0; i < image.ncolors; ++i) {
char const * const color = image.colorTable[i].c_color;
if (color && lowercase(color) == "none")
if (color && ascii_lowercase(color) == "none")
return true;
}
return false;

View File

@ -48,6 +48,8 @@ public:
/// Get the image height
unsigned int getHeight() const;
bool isDrawable() const;
/** Load the image file into memory.
* In this case (ImageXPM), the process is blocking.
*/

View File

@ -605,8 +605,6 @@ string const unique_filename(string const bufferpath)
Converter const * setConverter()
{
Converter const * converter = 0;
string const from = "lyxpreview";
Formats::FormatList::const_iterator it = formats.begin();

View File

@ -1,3 +1,8 @@
2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insetcite.C (getNatbibLabel):
* insetbib.C (getKeys): use ascii_lowercase instead of lowercase
2002-07-15 John Levon <moz@compsoc.man.ac.uk>
* insetgraphics.C: use ->isDrawable()

View File

@ -259,7 +259,7 @@ vector<pair<string, string> > const InsetBibtex::getKeys(Buffer const * buffer)
linebuf = subst(linebuf, '{', '(');
string tmp;
linebuf = split(linebuf, tmp, '(');
tmp = lowercase(tmp);
tmp = ascii_lowercase(tmp);
if (!prefixIs(tmp, "@string")
&& !prefixIs(tmp, "@preamble")) {
linebuf = split(linebuf, tmp, ',');

View File

@ -93,8 +93,8 @@ string const getNatbibLabel(Buffer const * buffer,
bool const full = citeType[citeType.size()-1] == '*';
string const cite_type = full ?
lowercase(citeType.substr(0,citeType.size()-1)) :
lowercase(citeType);
ascii_lowercase(citeType.substr(0,citeType.size()-1)) :
ascii_lowercase(citeType);
string before_str;
if (!before.empty()) {

View File

@ -580,7 +580,7 @@ string const LyXFont::stateText(BufferParams * params) const
// Set family according to lyx format string
LyXFont & LyXFont::setLyXFamily(string const & fam)
{
string const s = lowercase(fam);
string const s = ascii_lowercase(fam);
int i = 0;
while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error") ++i;
@ -596,7 +596,7 @@ LyXFont & LyXFont::setLyXFamily(string const & fam)
// Set series according to lyx format string
LyXFont & LyXFont::setLyXSeries(string const & ser)
{
string const s = lowercase(ser);
string const s = ascii_lowercase(ser);
int i = 0;
while (s != LyXSeriesNames[i] && LyXSeriesNames[i] != "error") ++i;
@ -612,7 +612,7 @@ LyXFont & LyXFont::setLyXSeries(string const & ser)
// Set shape according to lyx format string
LyXFont & LyXFont::setLyXShape(string const & sha)
{
string const s = lowercase(sha);
string const s = ascii_lowercase(sha);
int i = 0;
while (s != LyXShapeNames[i] && LyXShapeNames[i] != "error") ++i;
@ -628,7 +628,7 @@ LyXFont & LyXFont::setLyXShape(string const & sha)
// Set size according to lyx format string
LyXFont & LyXFont::setLyXSize(string const & siz)
{
string const s = lowercase(siz);
string const s = ascii_lowercase(siz);
int i = 0;
while (s != LyXSizeNames[i] && LyXSizeNames[i] != "error") ++i;
if (s == LyXSizeNames[i]) {
@ -643,7 +643,7 @@ LyXFont & LyXFont::setLyXSize(string const & siz)
// Set size according to lyx format string
LyXFont::FONT_MISC_STATE LyXFont::setLyXMisc(string const & siz)
{
string const s = lowercase(siz);
string const s = ascii_lowercase(siz);
int i = 0;
while (s != LyXMiscNames[i] && LyXMiscNames[i] != "error") ++i;
if (s == LyXMiscNames[i])
@ -677,7 +677,7 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
bool finished = false;
while (!finished && lex.isOK() && !error) {
lex.next();
string const tok = lowercase(lex.getString());
string const tok = ascii_lowercase(lex.getString());
if (tok.empty()) {
continue;
@ -701,7 +701,7 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
setLyXSize(ttok);
} else if (tok == "misc") {
lex.next();
string const ttok = lowercase(lex.getString());
string const ttok = ascii_lowercase(lex.getString());
if (ttok == "no_bar") {
setUnderbar(OFF);

View File

@ -168,7 +168,7 @@ string const LyXLex::getLongString(string const & endtoken)
// We do a case independent comparison, like search_kw
// does.
if (compare_no_case(token, endtoken) != 0) {
if (compare_ascii_no_case(token, endtoken) != 0) {
string tmpstr = getString();
if (firstline) {
unsigned int i = 0;

View File

@ -379,8 +379,11 @@ int LyXLex::Pimpl::search_kw(char const * const tag) const
keyword_item * res =
lower_bound(table, table + no_items,
search_tag, compare_tags());
// use the compare_ascii_no_case instead of compare_no_case,
// because in turkish, 'i' is not the lowercase version of 'I',
// and thus turkish locale breaks parsing of tags.
if (res != table + no_items
&& !compare_no_case(res->tag, tag))
&& !compare_ascii_no_case(res->tag, tag))
return res->code;
return LEX_UNDEF;
}

View File

@ -501,7 +501,7 @@ int LyXRC::read(string const & filename)
case RC_DEFAULT_PAPERSIZE:
if (lexrc.next()) {
string const size =
lowercase(lexrc.getString());
ascii_lowercase(lexrc.getString());
if (size == "usletter")
default_papersize =
BufferParams::PAPER_USLETTER;
@ -2003,10 +2003,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
case RC_FORMAT:
break;
case RC_NEW_ASK_FILENAME:
str = _("This sets the behaviour if you want to be asked for a filename when creating a new document or wait until you save it and be asked then.");
break;
case RC_DEFAULT_LANGUAGE:
str = _("New documents will be assigned this language.");
break;

View File

@ -116,7 +116,6 @@ enum LyXRCTags {
RC_CONVERTER,
RC_VIEWER,
RC_FORMAT,
RC_NEW_ASK_FILENAME,
RC_DEFAULT_LANGUAGE,
RC_LABEL_INIT_LENGTH,
RC_DISPLAY_GRAPHICS,

View File

@ -1,4 +1,10 @@
2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* filetools.C (IsLyXFilename):
(IsSGMLFilename): use ascii_lowercase instead of lowercase
* lstrings.[Ch] (ascii_lowercase): new function
2002-07-16 André Pönitz <poenitz@gmx.net>
* FileInfo.Ch: remove unneeded code

View File

@ -85,13 +85,13 @@ extern string system_packageList;
bool IsLyXFilename(string const & filename)
{
return suffixIs(lowercase(filename), ".lyx");
return suffixIs(ascii_lowercase(filename), ".lyx");
}
bool IsSGMLFilename(string const & filename)
{
return suffixIs(lowercase(filename), ".sgml");
return suffixIs(ascii_lowercase(filename), ".sgml");
}

View File

@ -248,6 +248,12 @@ struct local_uppercase {
}
};
struct local_ascii_lowercase {
char operator()(char c) const {
return ascii_tolower(c);
}
};
} // end of anon namespace
string const lowercase(string const & a)
@ -265,6 +271,15 @@ string const uppercase(string const & a)
}
string const ascii_lowercase(string const & a)
{
string tmp(a);
transform(tmp.begin(), tmp.end(), tmp.begin(),
local_ascii_lowercase());
return tmp;
}
bool prefixIs(string const & a, char const * pre)
{
lyx::Assert(pre);

View File

@ -80,6 +80,9 @@ char lowercase(char c);
///
char uppercase(char c);
/// same as lowercase(), but ignores locale
string const ascii_lowercase(string const &);
///
string const lowercase(string const &);