}
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);
}
}
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));
}
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));
}
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 += ": ";
}
+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)
#include "InsetCommandParams.h"
#include "RenderButton.h"
#include "MailInset.h"
+#include "Counters.h"
#include "support/FileName.h"
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 &);
///
/// cache
mutable bool set_label_;
mutable RenderButton button_;
+ int counter_;
};