mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Patch from Bo. Fixes problem with labels in child docs of the listings type:
Duplicate labels were not being updated. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28556 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ae6462af96
commit
072ed23ffc
@ -41,6 +41,7 @@
|
||||
#include "insets/InsetCommand.h"
|
||||
#include "insets/InsetGraphics.h"
|
||||
#include "insets/InsetGraphicsParams.h"
|
||||
#include "insets/InsetInclude.h"
|
||||
#include "insets/InsetTabular.h"
|
||||
|
||||
#include "mathed/MathData.h"
|
||||
@ -244,6 +245,12 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
|
||||
break;
|
||||
}
|
||||
|
||||
case INCLUDE_CODE: {
|
||||
InsetInclude & inc = static_cast<InsetInclude &>(*it);
|
||||
inc.updateCommand();
|
||||
break;
|
||||
}
|
||||
|
||||
case BIBITEM_CODE: {
|
||||
// check for duplicates
|
||||
InsetCommand & bib = static_cast<InsetCommand &>(*it);
|
||||
|
@ -922,6 +922,27 @@ void InsetInclude::addToToc(DocIterator const & cpit)
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::updateCommand()
|
||||
{
|
||||
if (!label_)
|
||||
return;
|
||||
|
||||
docstring old_label = label_->getParam("name");
|
||||
label_->updateCommand(old_label, false);
|
||||
// the label might have been adapted (duplicate)
|
||||
docstring new_label = label_->getParam("name");
|
||||
if (old_label == new_label)
|
||||
return;
|
||||
|
||||
// update listings parameters...
|
||||
InsetCommandParams p(INCLUDE_CODE);
|
||||
p = params();
|
||||
InsetListingsParams par(to_utf8(params()["lstparams"]));
|
||||
par.addParam("label", "{" + to_utf8(new_label) + "}", true);
|
||||
p["lstparams"] = from_utf8(par.params());
|
||||
setParams(p);
|
||||
}
|
||||
|
||||
void InsetInclude::updateLabels(ParIterator const & it)
|
||||
{
|
||||
Buffer const * const childbuffer = getChildBuffer(buffer());
|
||||
|
@ -86,6 +86,8 @@ public:
|
||||
///
|
||||
void addToToc(DocIterator const &);
|
||||
///
|
||||
void updateCommand();
|
||||
///
|
||||
void updateLabels(ParIterator const &);
|
||||
///
|
||||
static ParamInfo const & findInfo(std::string const &);
|
||||
|
@ -741,14 +741,15 @@ string InsetListingsParams::params(string const & sep) const
|
||||
}
|
||||
|
||||
|
||||
void InsetListingsParams::addParam(string const & key, string const & value)
|
||||
void InsetListingsParams::addParam(string const & key,
|
||||
string const & value, bool replace)
|
||||
{
|
||||
if (key.empty())
|
||||
return;
|
||||
|
||||
// duplicate parameters!
|
||||
string keyname = key;
|
||||
if (params_.find(key) != params_.end())
|
||||
if (!replace && params_.find(key) != params_.end())
|
||||
// key=value,key=value1 is allowed in listings
|
||||
// use key_, key__, key___ etc to avoid name conflict
|
||||
while (params_.find(keyname += '_') != params_.end()) { }
|
||||
|
@ -37,8 +37,10 @@ public:
|
||||
/// valid parameter string
|
||||
std::string params(std::string const & sep=",") const;
|
||||
|
||||
/// add key=value to params_
|
||||
void addParam(std::string const & key, std::string const & value);
|
||||
/// add key=value to params_. key_=value will be used if key=value already exists
|
||||
/// unless replace=true.
|
||||
void addParam(std::string const & key, std::string const & value,
|
||||
bool replace = false);
|
||||
|
||||
/// add a few parameters
|
||||
void addParams(std::string const & par);
|
||||
|
Loading…
Reference in New Issue
Block a user