X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLColor.C;h=b2f1ba545fb5cc54cacea464eac6d175d36df273;hb=6a55be9506b112110826cf63bc21786044569f1d;hp=96e11cad0d54ff69562960f28ae42f6969e98fc9;hpb=1cad117882dc393b2d55174c6f2ab67920a54ce1;p=lyx.git diff --git a/src/LColor.C b/src/LColor.C index 96e11cad0d..b2f1ba545f 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -24,6 +24,7 @@ #include using lyx::support::compare_ascii_no_case; +using lyx::support::ascii_lowercase; using std::endl; using std::string; @@ -159,10 +160,10 @@ LColor::~LColor() {} -void LColor::operator=(LColor const & c) +LColor & LColor::operator=(LColor tmp) { - LColor tmp(c); boost::swap(pimpl_, tmp.pimpl_); + return *this; } @@ -222,12 +223,27 @@ bool LColor::setColor(LColor::color col, string const & x11name) << " may not be redefined" << endl; return false; } - + it->second.x11name = x11name; return true; } +bool LColor::setColor(string const & lyxname, string const &x11name) +{ + string const lcname = ascii_lowercase(lyxname); + if (pimpl_->transform.find(lcname) == pimpl_->transform.end()) { + lyxerr[Debug::GUI] + << "LColor::setColor: Unknown color \"" + << lyxname << '"' << endl; + addColor(static_cast(pimpl_->infotab.size()), lcname); + } + + return setColor(static_cast(pimpl_->transform[lcname]), + x11name); +} + + LColor::color LColor::getFromGUIName(string const & guiname) const { Pimpl::InfoTab::const_iterator it = pimpl_->infotab.begin(); @@ -249,10 +265,14 @@ void LColor::addColor(LColor::color c, string const & lyxname) const LColor::color LColor::getFromLyXName(string const & lyxname) const { - if (pimpl_->transform.find(lyxname) == pimpl_->transform.end()) - addColor(static_cast(pimpl_->infotab.size()), lyxname); + string const lcname = ascii_lowercase(lyxname); + if (pimpl_->transform.find(lcname) == pimpl_->transform.end()) { + lyxerr << "LColor::getFromLyXName: Unknown color \"" + << lyxname << '"' << endl; + return none; + } - return static_cast(pimpl_->transform[lyxname]); + return static_cast(pimpl_->transform[lcname]); }