-namespace {
-
-const InsetLabel* findLabelInParagraph(const Paragraph &par)
-{
- for (pos_type pos = 0; pos < par.size(); ++pos) {
- // If this inset is a subfigure, skip it.
- const Inset *inset = par.getInset(pos);
- if (dynamic_cast<const InsetBox *>(inset)) {
- continue;
- }
-
- // Maybe an inset is directly a label, in which case no more work is needed.
- if (inset && dynamic_cast<const InsetLabel *>(inset))
- return dynamic_cast<const InsetLabel *>(inset);
-
- // More likely, the label is hidden in an inset of a paragraph (only if a subtype of InsetText).
- if (!dynamic_cast<const InsetText *>(inset))
- continue;
-
- auto insetAsText = dynamic_cast<const InsetText *>(inset);
- auto itIn = insetAsText->paragraphs().begin();
- auto endIn = insetAsText->paragraphs().end();
- for (; itIn != endIn; ++itIn) {
- for (pos_type posIn = 0; posIn < itIn->size(); ++posIn) {
- const Inset *insetIn = itIn->getInset(posIn);
- if (insetIn && dynamic_cast<const InsetLabel *>(insetIn)) {
- return dynamic_cast<const InsetLabel *>(insetIn);
- }
- }
- }
-
- // Obviously, this solution does not scale with more levels of paragraphs-insets, but this should be enough.
- }
-
- return nullptr;
-}
-
-} // anonymous namespace
-
-
-const InsetCaption* findCaptionInParagraph(const Paragraph &par)
-{
- // Don't dive too deep, otherwise, this could be a subfigure caption.
- for (pos_type pos = 0; pos < par.size(); ++pos) {
- // If this inset is a subfigure, skip it.
- const Inset *inset = par.getInset(pos);
- if (dynamic_cast<const InsetBox *>(inset))
- continue;
-
- if (inset && dynamic_cast<const InsetCaption *>(inset))
- return dynamic_cast<const InsetCaption *>(inset);
- }
-
- return nullptr;
-}
-
-