\change_inserted -712698321 1690284277
AllowedInInsets
+\change_unchanged
+
\end_layout
\end_inset
\change_inserted -712698321 1690284318
EndAllowedInInsets
+\change_unchanged
+
\end_layout
\end_inset
\change_inserted -712698321 1690284329
AllowedInLayouts
+\change_unchanged
+
\end_layout
\end_inset
\begin_layout Description
-\change_inserted -712698321 1690284561
+\change_inserted -712698321 1690292495
\begin_inset Flex Code
status collapsed
\change_inserted -712698321 1690284338
AllowedInLayouts
+\change_unchanged
+
\end_layout
\end_inset
\change_inserted -712698321 1690284353
EndAllowedInLayouts
+\change_unchanged
+
\end_layout
\end_inset
\change_inserted -712698321 1690284358
AllowedInInsets
+\change_unchanged
+
\end_layout
\end_inset
.
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1690292676
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1690292501
+AllowedOccurrences
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1690292507
+int
+\end_layout
+
+\end_inset
+
+] If
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1690292530
+AllowedInInsets
+\end_layout
+
+\end_inset
+
+ or
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1690292536
+AllowedInLayouts
+\end_layout
+
+\end_inset
+
+ has been defined,
+ this can be used to determine how many times the inset can be inserted to a given paragraph.
\change_unchanged
\end_layout
\begin_inset Flex Code
status collapsed
+\begin_layout Plain Layout
+AllowedOccurrences
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+int
+\end_layout
+
+\end_inset
+
+] Falls
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+AllowedInInsets
+\end_layout
+
+\end_inset
+
+ oder
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+AllowedInLayouts
+\end_layout
+
+\end_inset
+
+ definiert wurde,
+ kann hiermit eine maximale Anzahl von Einfügungen pro Absatz festgelegt werden.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
\begin_layout Plain Layout
Argument
\end_layout
AllowedInLayouts
Affiliation
EndAllowedInLayouts
+ AllowedOccurrences 1
End
InsetLayout Flex:Street_Address
AllowedInLayouts
Affiliation
EndAllowedInLayouts
+ AllowedOccurrences 1
End
InsetLayout Flex:City
AllowedInLayouts
Affiliation
EndAllowedInLayouts
+ AllowedOccurrences 1
End
InsetLayout Flex:Country
AllowedInLayouts
Affiliation
EndAllowedInLayouts
+ AllowedOccurrences 1
End
InsetLayout Flex:State
AllowedInLayouts
Affiliation
EndAllowedInLayouts
+ AllowedOccurrences 1
End
InsetLayout Flex:Postal_Code
AllowedInLayouts
Affiliation
EndAllowedInLayouts
+ AllowedOccurrences 1
End
Style TitleNote
AllowedInLayouts
Numbered_Example_(multiline), Numbered_Examples_(consecutive)
EndAllowedInLayouts
+ AllowedOccurrences 1
End
InsetLayout Flex:Subexample_Preamble
# Incremented to format 102, 25 July 2023 by spitz
# add InsetLayout tags AllowedInInsets, EndAllowedInInsets,
-# AllowedInLayouts, EndAllowedInLayouts
+# AllowedInLayouts, EndAllowedInLayouts, AllowedOccurrences
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
set<docstring> const & allowed_insets = il.allowedInInsets();
set<docstring> const & allowed_layouts = il.allowedInLayouts();
+ bool result = false;
if (allowed_insets.find(inInset().getLayout().name()) != allowed_insets.end())
- return true;
+ result = true;
- if (allowed_layouts.find(d->layout_->name()) != allowed_layouts.end())
- return true;
+ else if (allowed_layouts.find(d->layout_->name()) != allowed_layouts.end())
+ result = true;
- if (inInset().asInsetArgument()) {
+ else if (inInset().asInsetArgument()) {
// check if the argument allows the inset in question
if (cur.depth() > 1) {
docstring parlayout = cur[cur.depth() - 2].inset().getLayout().name()
+ from_ascii("@") + from_ascii(inInset().asInsetArgument()->name());
if (allowed_insets.find(parlayout) != allowed_insets.end())
- return true;
+ result = true;
}
}
+
+ if (result && il.allowedOccurrences() != -1) {
+ int have_ins = 0;
+ for (auto const & table : insetList())
+ if (table.inset->getLayout().name() == il.name())
+ ++have_ins;
+ if (have_ins >= il.allowedOccurrences())
+ return false;
+ }
+
+ if (result)
+ return true;
return (allowed_insets.empty() && allowed_layouts.empty());
}
// You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files.
//
-int const LAYOUT_FORMAT = 102; // spitz: add AllowedInInsets and AllowedInLayouts tag
+int const LAYOUT_FORMAT = 102; // spitz: add tags AllowedInInsets, AllowedInLayouts, AllowedOccurrences
// Layout format for the current lyx file format. Controls which format is
IL_ADDTOTOC,
IL_ALLOWED_IN_INSET,
IL_ALLOWED_IN_LAYOUT,
+ IL_ALLOWED_OCCURRENCES,
IL_ARGUMENT,
IL_BABELPREAMBLE,
IL_BGCOLOR,
{ "addtotoc", IL_ADDTOTOC },
{ "allowedininsets", IL_ALLOWED_IN_INSET },
{ "allowedinlayouts", IL_ALLOWED_IN_LAYOUT },
+ { "allowedoccurrences", IL_ALLOWED_OCCURRENCES },
{ "argument", IL_ARGUMENT },
{ "babelpreamble", IL_BABELPREAMBLE },
{ "bgcolor", IL_BGCOLOR },
allowed_in_layouts_.insert(allowances.begin(), allowances.end());
break;
}
+ case IL_ALLOWED_OCCURRENCES:
+ lex >> allowed_occurrences_;
+ break;
case IL_END:
getout = true;
break;
std::set<docstring> const & allowedInInsets() const { return allowed_in_insets_; }
///
std::set<docstring> const & allowedInLayouts() const { return allowed_in_layouts_; }
+ ///
+ int allowedOccurrences() const { return allowed_occurrences_; }
private:
///
void makeDefaultCSS() const;
std::set<docstring> allowed_in_insets_;
/// Layouts that can hold insets with this InsetLayout
std::set<docstring> allowed_in_layouts_;
+ ///
+ int allowed_occurrences_ = -1;
};
///