mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
revert r30515: too many files there
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30516 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
834bfe5e21
commit
c355edfb6d
@ -26,7 +26,7 @@ fi
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
save_PACKAGE=$PACKAGE
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5 silent-rules])
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5])
|
||||
PACKAGE=$save_PACKAGE
|
||||
|
||||
### Set the execute permissions of the various scripts correctly
|
||||
|
@ -3389,8 +3389,7 @@ static void setLabel(Buffer const & buf, ParIterator & it)
|
||||
counters.reset(enumcounter);
|
||||
counters.step(enumcounter);
|
||||
|
||||
string const & lang = par.getParLanguage(bp)->code();
|
||||
par.params().labelString(counters.theCounter(enumcounter, lang));
|
||||
par.params().labelString(counters.theCounter(enumcounter));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -3403,11 +3402,10 @@ 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), lang));
|
||||
counters.theCounter(from_utf8(type)));
|
||||
} else
|
||||
full_label = bformat(from_ascii("%1$s #:"), name);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -144,12 +143,19 @@ docstring const & Counter::labelString(bool in_appendix) const
|
||||
}
|
||||
|
||||
|
||||
Counter::StringMap & Counter::flatLabelStrings(bool in_appendix) const
|
||||
docstring const & Counter::flatLabelString(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,
|
||||
@ -249,6 +255,20 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -410,29 +430,18 @@ docstring Counters::labelItem(docstring const & ctr,
|
||||
}
|
||||
|
||||
|
||||
docstring Counters::theCounter(docstring const & counter,
|
||||
string const & lang) const
|
||||
docstring Counters::theCounter(docstring const & counter) const
|
||||
{
|
||||
CounterList::const_iterator it = counterList_.find(counter);
|
||||
if (it == counterList_.end())
|
||||
return from_ascii("??");
|
||||
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);
|
||||
// FIXME: this should get translated.
|
||||
return counterLabel(it->second.flatLabelString(appendix()));
|
||||
}
|
||||
|
||||
|
||||
docstring Counters::flattenLabelString(docstring const & counter,
|
||||
bool in_appendix,
|
||||
string const & lang,
|
||||
bool in_appendix,
|
||||
vector<docstring> & callers) const
|
||||
{
|
||||
docstring label;
|
||||
@ -450,12 +459,12 @@ docstring Counters::flattenLabelString(docstring const & counter,
|
||||
return from_ascii("??");
|
||||
Counter const & c = it->second;
|
||||
|
||||
docstring ls = translateIfPossible(c.labelString(in_appendix), lang);
|
||||
docstring ls = c.labelString(in_appendix);
|
||||
|
||||
callers.push_back(counter);
|
||||
if (ls.empty()) {
|
||||
if (!c.master().empty())
|
||||
ls = flattenLabelString(c.master(), in_appendix, lang, callers)
|
||||
ls = flattenLabelString(c.master(), in_appendix, callers)
|
||||
+ from_ascii(".");
|
||||
callers.pop_back();
|
||||
return ls + from_ascii("\\arabic{") + counter + "}";
|
||||
@ -472,8 +481,7 @@ 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,
|
||||
lang, callers);
|
||||
docstring const repl = flattenLabelString(newc, in_appendix, callers);
|
||||
ls.replace(i, k - j + 4, repl);
|
||||
}
|
||||
callers.pop_back();
|
||||
@ -482,8 +490,7 @@ docstring Counters::flattenLabelString(docstring const & counter,
|
||||
}
|
||||
|
||||
|
||||
docstring Counters::counterLabel(docstring const & format,
|
||||
string const & lang) const
|
||||
docstring Counters::counterLabel(docstring const & format) const
|
||||
{
|
||||
docstring label = format;
|
||||
|
||||
@ -500,7 +507,7 @@ docstring Counters::counterLabel(docstring const & format,
|
||||
&& lowercase(label[k]) <= 'z')
|
||||
++k;
|
||||
docstring const newc = label.substr(j, k - j);
|
||||
docstring const repl = theCounter(newc, lang);
|
||||
docstring const repl = theCounter(newc);
|
||||
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 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.
|
||||
/// 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.
|
||||
*/
|
||||
typedef std::map<std::string, docstring> StringMap;
|
||||
StringMap & flatLabelStrings(bool in_appendix) const;
|
||||
docstring const & flatLabelString(bool in_appendix) const;
|
||||
/// set the \c flatLabelString values.
|
||||
void setFlatLabelStrings(docstring const & fls, docstring const & flsa);
|
||||
private:
|
||||
///
|
||||
int value_;
|
||||
@ -75,12 +75,10 @@ private:
|
||||
docstring labelstring_;
|
||||
/// The same as labelstring_, but in appendices.
|
||||
docstring labelstringappendix_;
|
||||
/// 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_;
|
||||
/// 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_;
|
||||
};
|
||||
|
||||
|
||||
@ -121,17 +119,11 @@ 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 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;
|
||||
/// 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;
|
||||
/// Are we in appendix?
|
||||
bool appendix() const { return appendix_; };
|
||||
/// Set the state variable indicating whether we are in appendix.
|
||||
@ -145,12 +137,9 @@ 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. The \c lang code is used to
|
||||
* translate the string.
|
||||
*/
|
||||
docstring flattenLabelString(docstring const & counter, bool in_appendix,
|
||||
std::string const &lang,
|
||||
/// expands recusrsively any \\the<counter> macro in the
|
||||
/// labelstring of \c counter.
|
||||
docstring flattenLabelString(docstring const & counter, bool in_appendix,
|
||||
std::vector<docstring> & callers) const;
|
||||
/// Returns the value of the counter according to the
|
||||
/// numbering scheme numbertype.
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Messages.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -1608,7 +1609,14 @@ void Paragraph::setLabelWidthString(docstring const & s)
|
||||
docstring const Paragraph::translateIfPossible(docstring const & s,
|
||||
BufferParams const & bparams) const
|
||||
{
|
||||
return lyx::translateIfPossible(s, getParLanguage(bparams)->code());
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@ -1616,18 +1624,17 @@ 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 = lyx::translateIfPossible(layout.labelstring_appendix(),
|
||||
lang);
|
||||
fmt = translateIfPossible(layout.labelstring_appendix(),
|
||||
bparams);
|
||||
else
|
||||
fmt = lyx::translateIfPossible(layout.labelstring(), lang);
|
||||
fmt = translateIfPossible(layout.labelstring(), bparams);
|
||||
|
||||
if (fmt.empty() && layout.labeltype == LABEL_COUNTER
|
||||
&& !layout.counter.empty())
|
||||
return tclass.counters().theCounter(layout.counter, lang);
|
||||
return tclass.counters().theCounter(layout.counter);
|
||||
|
||||
// handle 'inherited level parts' in 'fmt',
|
||||
// i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
|
||||
@ -1645,7 +1652,7 @@ docstring Paragraph::expandLabel(Layout const & layout,
|
||||
}
|
||||
}
|
||||
|
||||
return tclass.counters().counterLabel(fmt, lang);
|
||||
return tclass.counters().counterLabel(fmt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -469,6 +469,14 @@ 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;
|
||||
qtext.trimmed().toDouble(&ok);
|
||||
double d = qtext.trimmed().toDouble(&ok);
|
||||
if (qtext.isEmpty() || ok)
|
||||
return QValidator::Acceptable;
|
||||
|
||||
|
@ -23,12 +23,10 @@
|
||||
#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"
|
||||
@ -255,15 +253,13 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it)
|
||||
|
||||
|
||||
// Update the counters of this inset and of its contents
|
||||
void InsetBibitem::updateLabels(ParIterator const & it)
|
||||
void InsetBibitem::updateLabels(ParIterator const &)
|
||||
{
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
Counters & counters = bp.documentClass().counters();
|
||||
Counters & counters = buffer().masterBuffer()->params().documentClass().counters();
|
||||
docstring const bibitem = from_ascii("bibitem");
|
||||
if (counters.hasCounter(bibitem) && getParam("label").empty()) {
|
||||
counters.step(bibitem);
|
||||
string const & lang = it.paragraph().getParLanguage(bp)->code();
|
||||
autolabel_ = counters.theCounter(bibitem, lang);
|
||||
autolabel_ = counters.theCounter(bibitem);
|
||||
} else {
|
||||
autolabel_ = from_ascii("??");
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "InsetList.h"
|
||||
#include "Language.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "output_latex.h"
|
||||
#include "OutputParams.h"
|
||||
@ -302,7 +301,6 @@ 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().
|
||||
@ -327,7 +325,7 @@ void InsetCaption::updateLabels(ParIterator const & it)
|
||||
cnts.step(counter);
|
||||
full_label_ = bformat(from_ascii("%1$s %2$s:"),
|
||||
name,
|
||||
cnts.theCounter(counter, lang));
|
||||
cnts.theCounter(counter));
|
||||
} else
|
||||
full_label_ = bformat(from_ascii("%1$s #:"), name);
|
||||
}
|
||||
|
@ -970,12 +970,11 @@ docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparam
|
||||
|
||||
bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
|
||||
if (!il.counter().empty()) {
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
Counters & cntrs = bp.documentClass().counters();
|
||||
// FIXME Master buffer?
|
||||
Counters & cntrs = buffer().params().documentClass().counters();
|
||||
cntrs.step(il.counter());
|
||||
// FIXME: translate to paragraph language
|
||||
if (!il.htmllabel().empty())
|
||||
os << cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
|
||||
os << cntrs.counterLabel(translateIfPossible(from_ascii(il.htmllabel())));
|
||||
}
|
||||
bool innertag_opened = false;
|
||||
if (!il.htmlinnertag().empty())
|
||||
|
@ -16,8 +16,9 @@
|
||||
#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"
|
||||
@ -32,7 +33,6 @@ 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)
|
||||
{
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
Counters & cnts = bp.documentClass().counters();
|
||||
DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass();
|
||||
Counters & cnts = tclass.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_= bformat(from_utf8("%1$s %2$s"),
|
||||
translateIfPossible(getLayout(bp).labelstring()),
|
||||
cnts.theCounter(foot, outer.getParLanguage(bp)->code()));
|
||||
custom_label_= support::bformat(from_utf8("%1$s %2$s"),
|
||||
translateIfPossible(getLayout(buffer().params()).labelstring()),
|
||||
cnts.theCounter(foot));
|
||||
setLabel(custom_label_);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user