]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInfo.cpp
Move Lexer to support/ directory (and lyx::support namespace)
[lyx.git] / src / insets / InsetInfo.cpp
index 4b9277490d9c98fe917a7e2eac1453b043b502ff..cfb5b7eafc6869a2af6cad6eeb752b4ba6bf8fc9 100644 (file)
@@ -30,7 +30,6 @@
 #include "LyXAction.h"
 #include "LyXRC.h"
 #include "LyXVC.h"
-#include "Lexer.h"
 #include "output_docbook.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
@@ -49,6 +48,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/Length.h"
+#include "support/Lexer.h"
 #include "support/Messages.h"
 #include "support/lstrings.h"
 #include "support/qstring_helpers.h"
@@ -180,10 +180,9 @@ bool translateString(docstring const & in, docstring & out, string const & lcode
        out = translateIfPossible(in, lcode);
        return in != out;
 }
-} // namespace anon
 
 
-docstring InsetInfoParams::getDate(string const & iname, QDate const date) const
+docstring getDate(string const & iname, QDate const date, Language const * lang)
 {
        QLocale loc;
        if (lang)
@@ -208,7 +207,7 @@ docstring InsetInfoParams::getDate(string const & iname, QDate const date) const
 }
 
 
-docstring InsetInfoParams::getTime(string const & iname, QTime const time) const
+docstring getTime(string const & iname, QTime const time, Language const * lang)
 {
        QLocale loc;
        if (lang)
@@ -222,6 +221,7 @@ docstring InsetInfoParams::getTime(string const & iname, QTime const time) const
        else
                return qstring_to_ucs4(loc.toString(time, toqstr(iname)));
 }
+} // namespace anon
 
 
 vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
@@ -313,17 +313,17 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
                        date = (gdate.isValid()) ? gdate : QDate::currentDate();
                } else
                        date = QDate::currentDate();
-               result.push_back(make_pair("long",getDate("long", date)));
-               result.push_back(make_pair("short", getDate("short", date)));
-               result.push_back(make_pair("loclong", getDate("loclong", date)));
-               result.push_back(make_pair("locmedium", getDate("locmedium", date)));
-               result.push_back(make_pair("locshort", getDate("locshort", date)));
-               result.push_back(make_pair("ISO", getDate("ISO", date)));
-               result.push_back(make_pair("yyyy", getDate("yyyy", date)));
-               result.push_back(make_pair("MMMM", getDate("MMMM", date)));
-               result.push_back(make_pair("MMM", getDate("MMM", date)));
-               result.push_back(make_pair("dddd", getDate("dddd", date)));
-               result.push_back(make_pair("ddd", getDate("ddd", date)));
+               result.push_back(make_pair("long",getDate("long", date, lang)));
+               result.push_back(make_pair("short", getDate("short", date, lang)));
+               result.push_back(make_pair("loclong", getDate("loclong", date, lang)));
+               result.push_back(make_pair("locmedium", getDate("locmedium", date, lang)));
+               result.push_back(make_pair("locshort", getDate("locshort", date, lang)));
+               result.push_back(make_pair("ISO", getDate("ISO", date, lang)));
+               result.push_back(make_pair("yyyy", getDate("yyyy", date, lang)));
+               result.push_back(make_pair("MMMM", getDate("MMMM", date, lang)));
+               result.push_back(make_pair("MMM", getDate("MMM", date, lang)));
+               result.push_back(make_pair("dddd", getDate("dddd", date, lang)));
+               result.push_back(make_pair("ddd", getDate("ddd", date, lang)));
                result.push_back(make_pair("custom", _("Custom")));
                break;
        }
@@ -344,9 +344,9 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
                        time = (gtime.isValid()) ? gtime : QTime::currentTime();
                } else
                        time = QTime::currentTime();
-               result.push_back(make_pair("long",getTime("long", time)));
-               result.push_back(make_pair("short", getTime("short", time)));
-               result.push_back(make_pair("ISO", getTime("ISO", time)));
+               result.push_back(make_pair("long",getTime("long", time, lang)));
+               result.push_back(make_pair("short", getTime("short", time, lang)));
+               result.push_back(make_pair("ISO", getTime("ISO", time, lang)));
                result.push_back(make_pair("custom", _("Custom")));
                break;
        }
@@ -1239,7 +1239,7 @@ void InsetInfo::build()
                        date = QDate::fromString(toqstr(date_specifier), Qt::ISODate);
                else
                        date = QDate::currentDate();
-               setText(params_.getDate(date_format, date), params_.lang);
+               setText(getDate(date_format, date, params_.lang), params_.lang);
                break;
        }
        case InsetInfoParams::TIME_INFO:
@@ -1261,7 +1261,7 @@ void InsetInfo::build()
                        time = QTime::fromString(toqstr(time_specifier), Qt::ISODate);
                else
                        time = QTime::currentTime();
-               setText(params_.getTime(time_format, time), params_.lang);
+               setText(getTime(time_format, time, params_.lang), params_.lang);
                break;
        }
        }
@@ -1506,7 +1506,7 @@ void docbookShortcutInfo(XMLStream & xs, const InsetInfoParams & params) {
        for (char_type const c : sequence) {
                const auto keyMapping = keyToString.find(c);
                if (keyMapping != keyToString.end()) {
-                       translateString(from_ascii(keyMapping->second), trans, lcode);
+                       (void) translateString(from_ascii(keyMapping->second), trans, lcode);
 
                        // db:keysym: symbolic name (like Page Up), unlike what is printed on the key (like
                        // ⇞, ↑, ▲, PgUp, Page Up, etc.)
@@ -1580,11 +1580,11 @@ void xhtmlShortcutInfo(XMLStream & xs, const InsetInfoParams & params) {
        odocstringstream ods;
        string const lcode = params.lang->code();
        docstring trans;
-       for (int i = 0; i < sequence.length(); ++i) {
+       for (size_t i = 0; i < sequence.length(); ++i) {
            char_type const c = sequence[i];
                const auto keyMapping = keyToString.find(c);
                if (keyMapping != keyToString.end()) {
-                       translateString(from_ascii(keyMapping->second), trans, lcode);
+                       (void) translateString(from_ascii(keyMapping->second), trans, lcode);
                        xs << trans;
                } else {
                        xs << c;
@@ -1675,7 +1675,7 @@ void docbookMenuInfo(XMLStream & xs, Buffer const & buffer, const InsetInfoParam
        xml::openTag(xs, "menuchoice", attr, "inline"); // More of an inline tag in this case, as there is no db:shortcut to
        // accompany the succession of menus.
 
-       for (int i = 0; i < names.size(); ++i) {
+       for (size_t i = 0; i < names.size(); ++i) {
            docstring const & name = names[i];
 
                std::string tag;
@@ -1746,7 +1746,7 @@ void xhtmlMenuInfo(XMLStream & xs, Buffer const & buffer, const InsetInfoParams
        // Use bdo instead of span to specify the text direction (dir is only allowed globally or on bdo).
        xml::openTag(xs, "bdo", attr, "inline");
 
-       for (int i = 0; i < names.size(); ++i) {
+       for (size_t i = 0; i < names.size(); ++i) {
            docstring const & name = names[i];
 
                //FIXME: add proper underlines here. This
@@ -2057,7 +2057,7 @@ docstring InsetInfo::xhtml(XMLStream & xs, OutputParams const & rp) const
                std::tie(date, date_format) = parseDate(buffer(), params_);
 
                xml::openTag(xs, "span", std::string("class=\"infodate-") + cssClass + "\"", "inline");
-               xs << params_.getDate(date_format, date);
+               xs << getDate(date_format, date, params_.lang);
                xml::closeTag(xs, "span", "inline");
                break;
        }
@@ -2086,7 +2086,7 @@ docstring InsetInfo::xhtml(XMLStream & xs, OutputParams const & rp) const
                std::tie(time, time_format) = parseTime(buffer(), params_);
 
                xml::openTag(xs, "span", std::string("class=\"infotime-") + cssClass + "\"", "inline");
-               xs << params_.getTime(time_format, time);
+               xs << getTime(time_format, time, params_.lang);
                xml::closeTag(xs, "span", "inline");
                break;
        }