mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 18:19:42 +00:00
Increase listings counter for InsetInclude with lstinputlisting and a caption, fix bug 3708
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18486 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7f9f6bce57
commit
1561aef0b5
@ -419,6 +419,10 @@ void setCaptions(Paragraph & par, TextClass const & textclass)
|
||||
}
|
||||
else if (inset.lyxCode() == Inset::LISTINGS_CODE)
|
||||
setCaptionLabels(inset, "listing", from_ascii("Listing"), counters);
|
||||
else if (inset.lyxCode() == Inset::INCLUDE_CODE)
|
||||
// if this include inset contains lstinputlisting, and has a caption
|
||||
// it will increase the 'listing' counter by one
|
||||
static_cast<InsetInclude &>(inset).updateCounter(counters);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ bool isListings(InsetCommandParams const & params)
|
||||
InsetInclude::InsetInclude(InsetCommandParams const & p)
|
||||
: params_(p), include_label(uniqueID()),
|
||||
preview_(new RenderMonitoredPreview(this)),
|
||||
set_label_(false)
|
||||
set_label_(false), counter_(0)
|
||||
{
|
||||
preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
|
||||
}
|
||||
@ -118,7 +118,7 @@ InsetInclude::InsetInclude(InsetInclude const & other)
|
||||
params_(other.params_),
|
||||
include_label(other.include_label),
|
||||
preview_(new RenderMonitoredPreview(this)),
|
||||
set_label_(false)
|
||||
set_label_(false), counter_(0)
|
||||
{
|
||||
preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
|
||||
}
|
||||
@ -336,9 +336,13 @@ docstring const InsetInclude::getScreenLabel(Buffer const & buf) const
|
||||
case INCLUDE:
|
||||
temp += buf.B_("Include");
|
||||
break;
|
||||
case LISTINGS:
|
||||
temp += buf.B_("Program Listing");
|
||||
case LISTINGS: {
|
||||
if (counter_ > 0)
|
||||
temp += buf.B_("Program Listing ") + convert<docstring>(counter_);
|
||||
else
|
||||
temp += buf.B_("Program Listing");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
temp += ": ";
|
||||
@ -882,6 +886,21 @@ void InsetInclude::updateLabels(Buffer const & buffer) const
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::updateCounter(Counters & counters)
|
||||
{
|
||||
if (!isListings(params_))
|
||||
return;
|
||||
|
||||
InsetListingsParams const par = params_.getOptions();
|
||||
if (par.getParamValue("caption").empty())
|
||||
counter_ = 0;
|
||||
else {
|
||||
counters.step(from_ascii("listing"));
|
||||
counter_ = counters.value(from_ascii("listing"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const InsetIncludeMailer::name_("include");
|
||||
|
||||
InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "InsetCommandParams.h"
|
||||
#include "RenderButton.h"
|
||||
#include "MailInset.h"
|
||||
#include "Counters.h"
|
||||
|
||||
#include "support/FileName.h"
|
||||
|
||||
@ -99,6 +100,9 @@ public:
|
||||
void updateLabels(Buffer const & buffer) const;
|
||||
///
|
||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||
/// if this inset contains lstinputlisting and has a caption,
|
||||
/// update internal counter and passed counter
|
||||
void updateCounter(Counters & counters);
|
||||
protected:
|
||||
InsetInclude(InsetInclude const &);
|
||||
///
|
||||
@ -133,6 +137,7 @@ private:
|
||||
/// cache
|
||||
mutable bool set_label_;
|
||||
mutable RenderButton button_;
|
||||
int counter_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user