[LyX features/feature/docbook] DocBook: handle other cases of subfigures.
Thibaut Cuvelier
tcuvelier at lyx.org
Fri Sep 11 11:01:29 UTC 2020
The branch, feature/docbook, has been updated.
discards 4ac929f3df456a0617aae41f3aaed803dd97cf32 (commit)
discards bcbb4f0957bb39d274af0a30158ba9750b127121 (commit)
discards d97b9ebd03d75f0bb8c6a207f1078b32cfd39a2b (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (4ac929f3df456a0617aae41f3aaed803dd97cf32)
\
N -- N -- N (1fccfc24da4ad2f491b659ad7dcd8fbce29eef3d)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
- Log -----------------------------------------------------------------
commit 1fccfc24da4ad2f491b659ad7dcd8fbce29eef3d
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Fri Sep 11 03:14:41 2020 +0200
DocBook: handle other cases of subfigures.
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 981ba40..d680013 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -492,19 +492,22 @@ int InsetFloat::plaintext(odocstringstream & os, OutputParams const & runparams,
}
-std::vector<const InsetBox *> findSubfiguresInParagraph(const Paragraph &par)
+std::vector<const InsetCollapsible *> findSubfiguresInParagraph(const Paragraph &par)
{
// Don't make the hypothesis that all subfigures are in the same paragraph.
// Similarly, there may be several subfigures in the same paragraph (most likely case, based on the documentation).
// Any box is considered as a subfigure, even though the most likely case is \minipage.
- std::vector<const InsetBox *> subfigures;
+ // Boxes are not required to make subfigures. The common root between InsetBox and InsetFLoat is InsetCollapsible.
+ std::vector<const InsetCollapsible *> subfigures;
for (pos_type pos = 0; pos < par.size(); ++pos) {
const Inset *inset = par.getInset(pos);
if (!inset)
continue;
if (const auto box = dynamic_cast<const InsetBox *>(inset))
subfigures.push_back(box);
+ else if (const auto fl = dynamic_cast<const InsetFloat *>(inset))
+ subfigures.push_back(fl);
}
return subfigures;
}
@@ -564,7 +567,7 @@ const InsetCaption* findCaptionInParagraph(const Paragraph &par)
void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption,
- const InsetLabel * label, std::vector<const InsetBox *> & subfigures)
+ const InsetLabel * label, std::vector<const InsetCollapsible *> & subfigures)
{
// Ensure there is no label output, it is supposed to be handled as xml:id.
OutputParams rpNoLabel = runparams;
@@ -592,20 +595,29 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins
// Deal with each subfigure individually. This should also deal with their caption and their label.
// This should be a recursive call to InsetFloat.
- for (const InsetBox *subfigure: subfigures) {
+ // An item in subfigure should either be an InsetBox containing an InsetFloat or directly an InsetFloat.
+ for (const InsetCollapsible *subfigure: subfigures) {
// If there is no InsetFloat in the paragraphs, output a warning.
bool foundInsetFloat = false;
- for (const auto & it : subfigure->paragraphs()) {
- for (pos_type posIn = 0; posIn < it.size(); ++posIn) {
- const Inset *inset = it.getInset(posIn);
- if (inset && dynamic_cast<const InsetFloat*>(inset)) {
- foundInsetFloat = true;
- break;
+
+ // The collapsible may already be a float (InsetFloat).
+ if (subfigure && dynamic_cast<const InsetFloat *>(subfigure))
+ foundInsetFloat = true;
+
+ // Subfigures are in boxes.
+ if (!foundInsetFloat) {
+ for (const auto &it : subfigure->paragraphs()) {
+ for (pos_type posIn = 0; posIn < it.size(); ++posIn) {
+ const Inset *inset = it.getInset(posIn);
+ if (inset && dynamic_cast<const InsetFloat *>(inset)) {
+ foundInsetFloat = true;
+ break;
+ }
}
- }
- if (foundInsetFloat)
- break;
+ if (foundInsetFloat)
+ break;
+ }
}
if (!foundInsetFloat)
@@ -673,11 +685,11 @@ void InsetFloat::docbook(XMLStream & xs, OutputParams const & runparams) const
// The caption and the label for each subfigure is handled by recursive calls.
const InsetCaption* caption = nullptr;
const InsetLabel* label = nullptr;
- std::vector<const InsetBox *> subfigures;
+ std::vector<const InsetCollapsible *> subfigures;
auto end = paragraphs().end();
for (auto it = paragraphs().begin(); it != end; ++it) {
- std::vector<const InsetBox *> foundSubfigures = findSubfiguresInParagraph(*it);
+ std::vector<const InsetCollapsible *> foundSubfigures = findSubfiguresInParagraph(*it);
if (!foundSubfigures.empty()) {
subfigures.reserve(subfigures.size() + foundSubfigures.size());
subfigures.insert(subfigures.end(), foundSubfigures.begin(), foundSubfigures.end());
commit 0a7c29c9b567518d26a378759846e892b33d2925
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Fri Sep 11 03:05:04 2020 +0200
DocBook: in configure.py, DeclareDocBookClass doesn't need to be checked anymore.
diff --git a/lib/configure.py b/lib/configure.py
index 2247c78..b267576 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1339,7 +1339,7 @@ def processLayoutFile(file):
'''
classname = file.split(os.sep)[-1].split('.')[0]
# return ('LaTeX', '[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article}
- p = re.compile('\s*#\s*\\\\Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}\s*$')
+ p = re.compile('\s*#\s*\\\\DeclareLaTeXClass\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}\s*$')
q = re.compile('\s*#\s*\\\\DeclareCategory{(.*)}\s*$')
classdeclaration = ""
categorydeclaration = '""'
@@ -1347,7 +1347,8 @@ def processLayoutFile(file):
res = p.match(line)
qres = q.match(line)
if res != None:
- (classtype, optAll, opt, opt1, desc) = res.groups()
+ (optAll, opt, opt1, desc) = res.groups()
+ classtype = "LaTeX"
avai = {'LaTeX': 'false', 'DocBook': 'true'}[classtype]
if opt == None:
opt = classname
@@ -1434,7 +1435,7 @@ def checkLatexConfig(check_config):
# Construct the list of classes to test for.
# build the list of available layout files and convert it to commands
# for chkconfig.ltx
- declare = re.compile('\\s*#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$')
+ declare = re.compile('\\s*#\\s*\\\\DeclareLaTeXClass\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$')
category = re.compile('\\s*#\\s*\\\\DeclareCategory{(.*)}\\s*$')
empty = re.compile('\\s*$')
testclasses = list()
@@ -1455,10 +1456,10 @@ def checkLatexConfig(check_config):
nodeclaration = True
# A class, but no category declaration. Just break.
break
- if declare.match(line) != None:
+ if declare.match(line) is not None:
decline = "\\TestDocClass{%s}{%s}" % (classname, line[1:].strip())
testclasses.append(decline)
- elif category.match(line) != None:
+ elif category.match(line) is not None:
catline = ("\\DeclareCategory{%s}{%s}"
% (classname, category.match(line).groups()[0]))
testclasses.append(catline)
-----------------------------------------------------------------------
Summary of changes:
lib/configure.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
hooks/post-receive
--
Repository for new features
More information about the lyx-cvs
mailing list