mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
fix a couple warnings after the number localization patch
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30515 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
52d9b45b0c
commit
834bfe5e21
@ -26,7 +26,7 @@ fi
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
save_PACKAGE=$PACKAGE
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5])
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5 silent-rules])
|
||||
PACKAGE=$save_PACKAGE
|
||||
|
||||
### Set the execute permissions of the various scripts correctly
|
||||
|
@ -3389,7 +3389,8 @@ static void setLabel(Buffer const & buf, ParIterator & it)
|
||||
counters.reset(enumcounter);
|
||||
counters.step(enumcounter);
|
||||
|
||||
par.params().labelString(counters.theCounter(enumcounter));
|
||||
string const & lang = par.getParLanguage(bp)->code();
|
||||
par.params().labelString(counters.theCounter(enumcounter, lang));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -3402,10 +3403,11 @@ static void setLabel(Buffer const & buf, ParIterator & it)
|
||||
else {
|
||||
docstring name = buf.B_(textclass.floats().getType(type).name());
|
||||
if (counters.hasCounter(from_utf8(type))) {
|
||||
string const & lang = par.getParLanguage(bp)->code();
|
||||
counters.step(from_utf8(type));
|
||||
full_label = bformat(from_ascii("%1$s %2$s:"),
|
||||
name,
|
||||
counters.theCounter(from_utf8(type)));
|
||||
counters.theCounter(from_utf8(type), lang));
|
||||
} else
|
||||
full_label = bformat(from_ascii("%1$s #:"), name);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -143,19 +144,12 @@ docstring const & Counter::labelString(bool in_appendix) const
|
||||
}
|
||||
|
||||
|
||||
docstring const & Counter::flatLabelString(bool in_appendix) const
|
||||
Counter::StringMap & Counter::flatLabelStrings(bool in_appendix) const
|
||||
{
|
||||
return in_appendix ? flatlabelstringappendix_ : flatlabelstring_;
|
||||
}
|
||||
|
||||
|
||||
void Counter::setFlatLabelStrings(docstring const & fls, docstring const & flsa)
|
||||
{
|
||||
flatlabelstring_ = fls;
|
||||
flatlabelstringappendix_ = flsa;
|
||||
}
|
||||
|
||||
|
||||
void Counters::newCounter(docstring const & newc,
|
||||
docstring const & masterc,
|
||||
docstring const & ls,
|
||||
@ -255,20 +249,6 @@ void Counters::reset()
|
||||
appendix_ = false;
|
||||
subfloat_ = false;
|
||||
current_float_.erase();
|
||||
CounterList::iterator it = counterList_.begin();
|
||||
CounterList::iterator const end = counterList_.end();
|
||||
std::vector<docstring> callers;
|
||||
for (; it != end; ++it) {
|
||||
it->second.reset();
|
||||
// Compute the explicit counter labels without any
|
||||
// \thexxx strings, in order to avoid recursion.
|
||||
// It only needs to be done when the textclass is
|
||||
// updated, but in practice the extra work is probably
|
||||
// not noticeable (JMarc)
|
||||
docstring const fls = flattenLabelString(it->first, false, callers);
|
||||
docstring const flsa = flattenLabelString(it->first, true, callers);
|
||||
it->second.setFlatLabelStrings(fls, flsa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -430,18 +410,29 @@ docstring Counters::labelItem(docstring const & ctr,
|
||||
}
|
||||
|
||||
|
||||
docstring Counters::theCounter(docstring const & counter) const
|
||||
docstring Counters::theCounter(docstring const & counter,
|
||||
string const & lang) const
|
||||
{
|
||||
CounterList::const_iterator it = counterList_.find(counter);
|
||||
if (it == counterList_.end())
|
||||
return from_ascii("??");
|
||||
// FIXME: this should get translated.
|
||||
return counterLabel(it->second.flatLabelString(appendix()));
|
||||
Counter const & ctr = it->second;
|
||||
Counter::StringMap sm = ctr.flatLabelStrings(appendix());
|
||||
Counter::StringMap::iterator smit = sm.find(lang);
|
||||
if (smit != sm.end())
|
||||
return counterLabel(smit->second, lang);
|
||||
|
||||
vector<docstring> callers;
|
||||
docstring const & fls = flattenLabelString(counter, appendix(),
|
||||
lang, callers);
|
||||
sm[lang] = fls;
|
||||
return counterLabel(fls, lang);
|
||||
}
|
||||
|
||||
|
||||
docstring Counters::flattenLabelString(docstring const & counter,
|
||||
bool in_appendix,
|
||||
bool in_appendix,
|
||||
string const & lang,
|
||||
vector<docstring> & callers) const
|
||||
{
|
||||
docstring label;
|
||||
@ -459,12 +450,12 @@ docstring Counters::flattenLabelString(docstring const & counter,
|
||||
return from_ascii("??");
|
||||
Counter const & c = it->second;
|
||||
|
||||
docstring ls = c.labelString(in_appendix);
|
||||
docstring ls = translateIfPossible(c.labelString(in_appendix), lang);
|
||||
|
||||
callers.push_back(counter);
|
||||
if (ls.empty()) {
|
||||
if (!c.master().empty())
|
||||
ls = flattenLabelString(c.master(), in_appendix, callers)
|
||||
ls = flattenLabelString(c.master(), in_appendix, lang, callers)
|
||||
+ from_ascii(".");
|
||||
callers.pop_back();
|
||||
return ls + from_ascii("\\arabic{") + counter + "}";
|
||||
@ -481,7 +472,8 @@ docstring Counters::flattenLabelString(docstring const & counter,
|
||||
&& lowercase(ls[k]) <= 'z')
|
||||
++k;
|
||||
docstring const newc = ls.substr(j, k - j);
|
||||
docstring const repl = flattenLabelString(newc, in_appendix, callers);
|
||||
docstring const repl = flattenLabelString(newc, in_appendix,
|
||||
lang, callers);
|
||||
ls.replace(i, k - j + 4, repl);
|
||||
}
|
||||
callers.pop_back();
|
||||
@ -490,7 +482,8 @@ docstring Counters::flattenLabelString(docstring const & counter,
|
||||
}
|
||||
|
||||
|
||||
docstring Counters::counterLabel(docstring const & format) const
|
||||
docstring Counters::counterLabel(docstring const & format,
|
||||
string const & lang) const
|
||||
{
|
||||
docstring label = format;
|
||||
|
||||
@ -507,7 +500,7 @@ docstring Counters::counterLabel(docstring const & format) const
|
||||
&& lowercase(label[k]) <= 'z')
|
||||
++k;
|
||||
docstring const newc = label.substr(j, k - j);
|
||||
docstring const repl = theCounter(newc);
|
||||
docstring const repl = theCounter(newc, lang);
|
||||
label.replace(i, k - j + 4, repl);
|
||||
}
|
||||
while (true) {
|
||||
|
@ -49,19 +49,19 @@ public:
|
||||
docstring const & master() const;
|
||||
/// Returns a LaTeX-like string to format the counter.
|
||||
/** This is similar to what one gets in LaTeX when using
|
||||
* "\the<counter>". The \c in_appendix bool tells whether
|
||||
* we want the version shown in an appendix.
|
||||
* "\the<counter>". The \c in_appendix bool tells whether we
|
||||
* want the version shown in an appendix.
|
||||
*/
|
||||
docstring const & labelString(bool in_appendix) const;
|
||||
/// Returns a LaTeX-like string to format the counter.
|
||||
/** This is similar to what one gets in LaTeX when using
|
||||
* "\the<counter>". The \c in_appendix bool tells whether
|
||||
* we want the version shown in an appendix. This version does
|
||||
* not contain any \\the<counter> expression.
|
||||
/// Returns a map of LaTeX-like strings to format the counter.
|
||||
/** For each language, the string is similar to what one gets
|
||||
* in LaTeX when using "\the<counter>". The \c in_appendix
|
||||
* bool tells whether we want the version shown in an
|
||||
* appendix. This version does not contain any \\the<counter>
|
||||
* expression.
|
||||
*/
|
||||
docstring const & flatLabelString(bool in_appendix) const;
|
||||
/// set the \c flatLabelString values.
|
||||
void setFlatLabelStrings(docstring const & fls, docstring const & flsa);
|
||||
typedef std::map<std::string, docstring> StringMap;
|
||||
StringMap & flatLabelStrings(bool in_appendix) const;
|
||||
private:
|
||||
///
|
||||
int value_;
|
||||
@ -75,10 +75,12 @@ private:
|
||||
docstring labelstring_;
|
||||
/// The same as labelstring_, but in appendices.
|
||||
docstring labelstringappendix_;
|
||||
/// A version of the labelstring with \\the<counter> expressions expanded
|
||||
docstring flatlabelstring_;
|
||||
/// A version of the appendix labelstring with \\the<counter> expressions expanded
|
||||
docstring flatlabelstringappendix_;
|
||||
/// Cache of the labelstring with \\the<counter> expressions expanded,
|
||||
/// indexed by language
|
||||
mutable StringMap flatlabelstring_;
|
||||
/// Cache of the appendix labelstring with \\the<counter> expressions expanded,
|
||||
/// indexed by language
|
||||
mutable StringMap flatlabelstringappendix_;
|
||||
};
|
||||
|
||||
|
||||
@ -119,11 +121,17 @@ public:
|
||||
/// the &to array of counters. Empty string matches all.
|
||||
void copy(Counters & from, Counters & to,
|
||||
docstring const & match = docstring());
|
||||
/// returns the expanded string representation of the counter.
|
||||
docstring theCounter(docstring const & c) const;
|
||||
/// Replace in \c format all the LaTeX-like macros that depend on
|
||||
/// counters.
|
||||
docstring counterLabel(docstring const & format) const;
|
||||
/** returns the expanded string representation of counter \c
|
||||
* c. The \c lang code is used to translate the string.
|
||||
*/
|
||||
docstring theCounter(docstring const & c,
|
||||
std::string const & lang) const;
|
||||
/** Replace in \c format all the LaTeX-like macros that depend
|
||||
* on counters. The \c lang code is used to translate the
|
||||
* string.
|
||||
*/
|
||||
docstring counterLabel(docstring const & format,
|
||||
std::string const & lang) const;
|
||||
/// Are we in appendix?
|
||||
bool appendix() const { return appendix_; };
|
||||
/// Set the state variable indicating whether we are in appendix.
|
||||
@ -137,9 +145,12 @@ public:
|
||||
/// Set the state variable indicating whether we are in a subfloat.
|
||||
void isSubfloat(bool s) { subfloat_ = s; };
|
||||
private:
|
||||
/// expands recusrsively any \\the<counter> macro in the
|
||||
/// labelstring of \c counter.
|
||||
docstring flattenLabelString(docstring const & counter, bool in_appendix,
|
||||
/** expands recusrsively any \\the<counter> macro in the
|
||||
* labelstring of \c counter. The \c lang code is used to
|
||||
* translate the string.
|
||||
*/
|
||||
docstring flattenLabelString(docstring const & counter, bool in_appendix,
|
||||
std::string const &lang,
|
||||
std::vector<docstring> & callers) const;
|
||||
/// Returns the value of the counter according to the
|
||||
/// numbering scheme numbertype.
|
||||
|
@ -58,7 +58,6 @@
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Messages.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -1609,14 +1608,7 @@ void Paragraph::setLabelWidthString(docstring const & s)
|
||||
docstring const Paragraph::translateIfPossible(docstring const & s,
|
||||
BufferParams const & bparams) const
|
||||
{
|
||||
if (!isAscii(s) || s.empty()) {
|
||||
// This must be a user defined layout. We cannot translate
|
||||
// this, since gettext accepts only ascii keys.
|
||||
return s;
|
||||
}
|
||||
// Probably standard layout, try to translate
|
||||
Messages & m = getMessages(getParLanguage(bparams)->code());
|
||||
return m.get(to_ascii(s));
|
||||
return lyx::translateIfPossible(s, getParLanguage(bparams)->code());
|
||||
}
|
||||
|
||||
|
||||
@ -1624,17 +1616,18 @@ docstring Paragraph::expandLabel(Layout const & layout,
|
||||
BufferParams const & bparams, bool process_appendix) const
|
||||
{
|
||||
DocumentClass const & tclass = bparams.documentClass();
|
||||
string const & lang = getParLanguage(bparams)->code();
|
||||
|
||||
docstring fmt;
|
||||
if (process_appendix && d->params_.appendix())
|
||||
fmt = translateIfPossible(layout.labelstring_appendix(),
|
||||
bparams);
|
||||
fmt = lyx::translateIfPossible(layout.labelstring_appendix(),
|
||||
lang);
|
||||
else
|
||||
fmt = translateIfPossible(layout.labelstring(), bparams);
|
||||
fmt = lyx::translateIfPossible(layout.labelstring(), lang);
|
||||
|
||||
if (fmt.empty() && layout.labeltype == LABEL_COUNTER
|
||||
&& !layout.counter.empty())
|
||||
return tclass.counters().theCounter(layout.counter);
|
||||
return tclass.counters().theCounter(layout.counter, lang);
|
||||
|
||||
// handle 'inherited level parts' in 'fmt',
|
||||
// i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
|
||||
@ -1652,7 +1645,7 @@ docstring Paragraph::expandLabel(Layout const & layout,
|
||||
}
|
||||
}
|
||||
|
||||
return tclass.counters().counterLabel(fmt);
|
||||
return tclass.counters().counterLabel(fmt, lang);
|
||||
}
|
||||
|
||||
|
||||
|
@ -469,14 +469,6 @@ void GuiGraphics::on_angle_textChanged(const QString & filename)
|
||||
(filename != "0"));
|
||||
}
|
||||
|
||||
// returns the number of the string s in the vector v
|
||||
static int itemNumber(const vector<string> & v, string const & s)
|
||||
{
|
||||
vector<string>::const_iterator cit =
|
||||
find(v.begin(), v.end(), s);
|
||||
return (cit != v.end()) ? int(cit - v.begin()) : 0;
|
||||
}
|
||||
|
||||
|
||||
void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ LengthValidator::LengthValidator(QWidget * parent)
|
||||
QValidator::State LengthValidator::validate(QString & qtext, int &) const
|
||||
{
|
||||
bool ok;
|
||||
double d = qtext.trimmed().toDouble(&ok);
|
||||
qtext.trimmed().toDouble(&ok);
|
||||
if (qtext.isEmpty() || ok)
|
||||
return QValidator::Acceptable;
|
||||
|
||||
|
@ -23,10 +23,12 @@
|
||||
#include "FuncRequest.h"
|
||||
#include "InsetIterator.h"
|
||||
#include "InsetList.h"
|
||||
#include "Language.h"
|
||||
#include "Lexer.h"
|
||||
#include "output_xhtml.h"
|
||||
#include "Paragraph.h"
|
||||
#include "ParagraphList.h"
|
||||
#include "ParIterator.h"
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
@ -253,13 +255,15 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it)
|
||||
|
||||
|
||||
// Update the counters of this inset and of its contents
|
||||
void InsetBibitem::updateLabels(ParIterator const &)
|
||||
void InsetBibitem::updateLabels(ParIterator const & it)
|
||||
{
|
||||
Counters & counters = buffer().masterBuffer()->params().documentClass().counters();
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
Counters & counters = bp.documentClass().counters();
|
||||
docstring const bibitem = from_ascii("bibitem");
|
||||
if (counters.hasCounter(bibitem) && getParam("label").empty()) {
|
||||
counters.step(bibitem);
|
||||
autolabel_ = counters.theCounter(bibitem);
|
||||
string const & lang = it.paragraph().getParLanguage(bp)->code();
|
||||
autolabel_ = counters.theCounter(bibitem, lang);
|
||||
} else {
|
||||
autolabel_ = from_ascii("??");
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "InsetList.h"
|
||||
#include "Language.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "output_latex.h"
|
||||
#include "OutputParams.h"
|
||||
@ -301,6 +302,7 @@ void InsetCaption::updateLabels(ParIterator const & it)
|
||||
{
|
||||
Buffer const & master = *buffer().masterBuffer();
|
||||
DocumentClass const & tclass = master.params().documentClass();
|
||||
string const & lang = it.paragraph().getParLanguage(master.params())->code();
|
||||
Counters & cnts = tclass.counters();
|
||||
string const & type = cnts.current_float();
|
||||
// Memorize type for addToToc().
|
||||
@ -325,7 +327,7 @@ void InsetCaption::updateLabels(ParIterator const & it)
|
||||
cnts.step(counter);
|
||||
full_label_ = bformat(from_ascii("%1$s %2$s:"),
|
||||
name,
|
||||
cnts.theCounter(counter));
|
||||
cnts.theCounter(counter, lang));
|
||||
} else
|
||||
full_label_ = bformat(from_ascii("%1$s #:"), name);
|
||||
}
|
||||
|
@ -970,11 +970,12 @@ docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparam
|
||||
|
||||
bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
|
||||
if (!il.counter().empty()) {
|
||||
// FIXME Master buffer?
|
||||
Counters & cntrs = buffer().params().documentClass().counters();
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
Counters & cntrs = bp.documentClass().counters();
|
||||
cntrs.step(il.counter());
|
||||
// FIXME: translate to paragraph language
|
||||
if (!il.htmllabel().empty())
|
||||
os << cntrs.counterLabel(translateIfPossible(from_ascii(il.htmllabel())));
|
||||
os << cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
|
||||
}
|
||||
bool innertag_opened = false;
|
||||
if (!il.htmlinnertag().empty())
|
||||
|
@ -16,9 +16,8 @@
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "Counters.h"
|
||||
#include "Language.h"
|
||||
#include "Layout.h"
|
||||
// FIXME: the following is needed just to get the layout of the enclosing
|
||||
// paragraph. This seems a bit too much to me (JMarc)
|
||||
#include "OutputParams.h"
|
||||
#include "ParIterator.h"
|
||||
#include "TextClass.h"
|
||||
@ -33,6 +32,7 @@ using namespace std;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::bformat;
|
||||
|
||||
InsetFoot::InsetFoot(Buffer const & buf)
|
||||
: InsetFootlike(buf)
|
||||
@ -47,16 +47,16 @@ docstring InsetFoot::editMessage() const
|
||||
|
||||
void InsetFoot::updateLabels(ParIterator const & it)
|
||||
{
|
||||
DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass();
|
||||
Counters & cnts = tclass.counters();
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
Counters & cnts = bp.documentClass().counters();
|
||||
docstring const foot = from_ascii("footnote");
|
||||
Paragraph const & outer = it.paragraph();
|
||||
if (!outer.layout().intitle && cnts.hasCounter(foot)) {
|
||||
cnts.step(foot);
|
||||
// FIXME: the counter should format itself.
|
||||
custom_label_= support::bformat(from_utf8("%1$s %2$s"),
|
||||
translateIfPossible(getLayout(buffer().params()).labelstring()),
|
||||
cnts.theCounter(foot));
|
||||
custom_label_= bformat(from_utf8("%1$s %2$s"),
|
||||
translateIfPossible(getLayout(bp).labelstring()),
|
||||
cnts.theCounter(foot, outer.getParLanguage(bp)->code()));
|
||||
setLabel(custom_label_);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user