displayTranslator is now a function. No need to invoke setDisplayTranslator

explicitly.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7915 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-10-13 21:50:33 +00:00
parent 9a01e253a1
commit e9e4ffb1d1
9 changed files with 47 additions and 58 deletions

View File

@ -1,3 +1,10 @@
2003-10-13 Angus Leeming <leeming@lyx.org>
* lyx_main.C (LyX): remove call to setDisplayTranslator().
* lyxrc.C: displayTranslator is now a function,
declared in GraphicsTypes.h.
2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br>
* lyxsocket.[Ch]: new files. A simple local socket interface for lyx.

View File

@ -1,3 +1,8 @@
2003-10-13 Angus Leeming <leeming@lyx.org>
* GraphicsTypes.[Ch] (setDisplayTranslator): removed.
Make displayTranslator a function,
2003-10-10 Angus Leeming <leeming@lyx.org>
* PreviewedInset.[Ch]: removed.

View File

@ -11,8 +11,6 @@
#include <config.h>
#include "graphics/GraphicsTypes.h"
#include "support/translator.h"
using std::string;
@ -20,29 +18,29 @@ using std::string;
namespace lyx {
namespace graphics {
namespace {
/// The translator between the Display enum and corresponding lyx string.
Translator<DisplayType, string> displayTranslator(DefaultDisplay, "default");
void setDisplayTranslator()
Translator<DisplayType, string> const initTranslator()
{
/// This variable keeps a tab on whether the translator is set.
static bool done = false;
Translator<DisplayType, string> translator(DefaultDisplay, "default");
if (!done) {
done = true;
// Fill the display translator
translator.addPair(MonochromeDisplay, "monochrome");
translator.addPair(GrayscaleDisplay, "grayscale");
translator.addPair(ColorDisplay, "color");
translator.addPair(NoDisplay, "none");
// Fill the display translator
displayTranslator.addPair(DefaultDisplay, "default");
displayTranslator.addPair(MonochromeDisplay, "monochrome");
displayTranslator.addPair(GrayscaleDisplay, "grayscale");
displayTranslator.addPair(ColorDisplay, "color");
displayTranslator.addPair(NoDisplay, "none");
return translator;
}
// backward compatibility for old lyxrc.display_graphics
displayTranslator.addPair(MonochromeDisplay, "mono");
displayTranslator.addPair(GrayscaleDisplay, "gray");
displayTranslator.addPair(NoDisplay, "no");
}
} // namespace anon
Translator<DisplayType, string> const & displayTranslator()
{
static Translator<DisplayType, string> const translator =
initTranslator();
return translator;
}
} // namespace graphics

View File

@ -15,6 +15,8 @@
#ifndef GRAPHICSTYPES_H
#define GRAPHICSTYPES_H
#include "support/translator.h"
namespace lyx {
namespace graphics {
@ -62,8 +64,8 @@ enum DisplayType {
};
///
void setDisplayTranslator();
/// The translator between the Display enum and corresponding lyx string.
Translator<DisplayType, std::string> const & displayTranslator();
} // namespace graphics
} // namespace lyx

View File

@ -1,3 +1,8 @@
2003-10-13 Angus Leeming <leeming@lyx.org>
* insetexternal.C:
* insetgraphicsParams.C: displayTranslator is now a function.
2003-10-13 Angus Leeming <leeming@lyx.org>
* insetinclude.C: remove #include "PreviewImage.h".

View File

@ -51,16 +51,6 @@ using std::ostringstream;
using std::vector;
namespace lyx {
namespace graphics {
/// The translator between the DisplayType and the corresponding lyx string.
extern Translator<DisplayType, string> displayTranslator;
} // namespace graphics
} // namespace lyx
namespace {
lyx::graphics::DisplayType const defaultDisplayType = lyx::graphics::NoDisplay;
@ -164,7 +154,7 @@ void InsetExternalParams::write(Buffer const & buffer, ostream & os) const
if (display != defaultDisplayType)
os << "\tdisplay "
<< lyx::graphics::displayTranslator.find(display)
<< lyx::graphics::displayTranslator().find(display)
<< '\n';
if (lyxscale != defaultLyxScale)
@ -269,7 +259,7 @@ bool InsetExternalParams::read(Buffer const & buffer, LyXLex & lex)
case EX_DISPLAY: {
lex.next();
string const name = lex.getString();
display = lyx::graphics::displayTranslator.find(name);
display = lyx::graphics::displayTranslator().find(name);
break;
}

View File

@ -35,14 +35,6 @@ using std::string;
using std::ostream;
namespace lyx {
namespace graphics {
/// The translator between the DisplayType and the corresponding lyx string.
extern Translator<DisplayType, string> displayTranslator;
}
}
InsetGraphicsParams::InsetGraphicsParams()
{
init();
@ -161,7 +153,7 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
if (lyxscale != 100)
os << "\tlyxscale " << lyxscale << '\n';
if (display != lyx::graphics::DefaultDisplay)
os << "\tdisplay " << lyx::graphics::displayTranslator.find(display) << '\n';
os << "\tdisplay " << lyx::graphics::displayTranslator().find(display) << '\n';
if (!float_equal(scale, 0.0, 0.05)) {
if (!float_equal(scale, 100.0, 0.05))
os << "\tscale " << scale << '\n';
@ -208,7 +200,7 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const
} else if (token == "display") {
lex.next();
string const type = lex.getString();
display = lyx::graphics::displayTranslator.find(type);
display = lyx::graphics::displayTranslator().find(type);
} else if (token == "scale") {
lex.next();
scale = lex.getFloat();

View File

@ -113,11 +113,6 @@ LyX::LyX(int & argc, char * argv[])
// we need to parse for "-dbg" and "-help"
bool const want_gui = easyParse(argc, argv);
// set the DisplayTranslator only once; should that be done here??
// if this should not be in this file, please also remove
// #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
lyx::graphics::setDisplayTranslator();
if (want_gui)
lyx_gui::parse_init(argc, argv);

View File

@ -29,6 +29,8 @@
#include "lyxlex.h"
#include "lyxfont.h"
#include "graphics/GraphicsTypes.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/translator.h"
@ -50,13 +52,6 @@ using std::ostream;
using std::string;
namespace lyx {
namespace graphics {
/// The translator between the DisplayType and the corresponding lyx string.
extern Translator<DisplayType, string> displayTranslator;
}
}
namespace {
// when adding something to this array keep it sorted!
@ -357,7 +352,7 @@ int LyXRC::read(string const & filename)
case RC_DISPLAY_GRAPHICS:
if (lexrc.next()) {
display_graphics = lyx::graphics::displayTranslator.find(lexrc.getString());
display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
}
break;
@ -1134,7 +1129,7 @@ void LyXRC::output(ostream & os) const
os << "# Display graphics within LyX\n"
<< "# monochrome|grayscale|color|none\n"
<< "\\display_graphics "
<< lyx::graphics::displayTranslator.find(display_graphics)
<< lyx::graphics::displayTranslator().find(display_graphics)
<< '\n';
}