Properly implement IsTocCaption for Arguments in standard TOC

Fixes: #10631

Candidate for 2.3.x.

(cherry picked from commit 3a4b233dbd)
This commit is contained in:
Juergen Spitzmueller 2017-12-29 11:51:24 +01:00
parent 4f865d0f4d
commit 438b067b5a
12 changed files with 39 additions and 17 deletions

View File

@ -309,7 +309,7 @@ Style Section
Series Bold Series Bold
Size Huge Size Huge
EndFont EndFont
TocLevel 1 TocLevel 1
End End
@ -319,7 +319,7 @@ Style Subsection
Series Bold Series Bold
Size Larger Size Larger
EndFont EndFont
TocLevel 2 TocLevel 2
End End
@ -329,7 +329,7 @@ Style Subsubsection
Series Bold Series Bold
Size Large Size Large
EndFont EndFont
TocLevel 3 TocLevel 3
End End
@ -339,7 +339,7 @@ Style Paragraph
Series Bold Series Bold
Size Normal Size Normal
EndFont EndFont
TocLevel 4 TocLevel 4
End End
@ -350,7 +350,7 @@ Style Subparagraph
Size Normal Size Normal
Shape Italic Shape Italic
EndFont EndFont
TocLevel 5 TocLevel 5
End End

View File

@ -216,6 +216,7 @@ Style Part
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The part as it appears in the table of contents/running headers" Tooltip "The part as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
NeedProtect 1 NeedProtect 1
NextNoIndent 1 NextNoIndent 1
@ -270,6 +271,7 @@ Style Section
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The section as it appears in the table of contents/running headers" Tooltip "The section as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Family Roman Family Roman
@ -331,6 +333,7 @@ Style Subsection
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The subsection as it appears in the table of contents/running headers" Tooltip "The subsection as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Family Roman Family Roman
@ -392,6 +395,7 @@ Style Subsubsection
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The subsubsection as it appears in the table of contents/running headers" Tooltip "The subsubsection as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Family Roman Family Roman
@ -481,6 +485,7 @@ Style Frame
Size largest Size largest
EndFont EndFont
AutoInsert 1 AutoInsert 1
IsTocCaption 1
EndArgument EndArgument
End End

View File

@ -136,7 +136,8 @@ Style Section
Argument 1 Argument 1
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The title as it appears in the header" Tooltip "The title as it appears in the header"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
ParSkip 0.4 ParSkip 0.4
TopSep 1.3 TopSep 1.3

View File

@ -153,7 +153,7 @@ Style Section
Series Bold Series Bold
Size Normal Size Normal
EndFont EndFont
TocLevel 1 TocLevel 1
End End
# Subsection style definition # Subsection style definition
@ -163,7 +163,7 @@ Style Subsection
Series Bold Series Bold
Size Normal Size Normal
EndFont EndFont
TocLevel 2 TocLevel 2
End End
# Subsubsection style definition # Subsubsection style definition
@ -173,7 +173,7 @@ Style Subsubsection
Series Bold Series Bold
Size Normal Size Normal
EndFont EndFont
TocLevel 3 TocLevel 3
End End
# Section* style definition # Section* style definition

View File

@ -46,11 +46,12 @@ Style Section
Family Sans Family Sans
Series Bold Series Bold
EndFont EndFont
TocLevel 1 TocLevel 1
Argument 1 Argument 1
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The section as it appears in the table of contents/running headers" Tooltip "The section as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
End End

View File

@ -32,6 +32,7 @@ Style Part
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The part as it appears in the table of contents/running headers" Tooltip "The part as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Series Bold Series Bold
@ -63,6 +64,7 @@ Style Chapter
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The chapter as it appears in the table of contents/running headers" Tooltip "The chapter as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Series Bold Series Bold
@ -93,6 +95,7 @@ Style Section
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The section as it appears in the table of contents/running headers" Tooltip "The section as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Series Bold Series Bold

View File

@ -140,6 +140,7 @@ Style PartBacktext
Mandatory 1 Mandatory 1
LabelString "Part Title" LabelString "Part Title"
Tooltip "Title of this part" Tooltip "Title of this part"
IsTocCaption 1
EndArgument EndArgument
Preamble Preamble
\newenvironment{svmultpartbacktext}[1]{\begin{partbacktext} \newenvironment{svmultpartbacktext}[1]{\begin{partbacktext}

View File

@ -81,8 +81,9 @@ Style Chapter
RefPrefix chap RefPrefix chap
Argument 1 Argument 1
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The chapter as it appears in the table of contents/running headers" Tooltip "The chapter as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Series Bold Series Bold
@ -109,8 +110,9 @@ Style Section
RefPrefix sec RefPrefix sec
Argument 1 Argument 1
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The section as it appears in the table of contents/running headers" Tooltip "The section as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Series Bold Series Bold

View File

@ -39,7 +39,8 @@ Style Part
Argument 1 Argument 1
LabelString "Short Title|S" LabelString "Short Title|S"
Tooltip "The part as it appears in the table of contents/running headers" Tooltip "The part as it appears in the table of contents/running headers"
InsertCotext 1 InsertCotext 1
IsTocCaption 1
EndArgument EndArgument
Font Font
Series Bold Series Bold

View File

@ -43,7 +43,7 @@ InsetArgument::InsetArgument(Buffer * buf, string const & name)
: InsetCollapsible(buf), name_(name), labelstring_(docstring()), : InsetCollapsible(buf), name_(name), labelstring_(docstring()),
font_(inherit_font), labelfont_(inherit_font), decoration_(string()), font_(inherit_font), labelfont_(inherit_font), decoration_(string()),
pass_thru_context_(false), pass_thru_local_(false), pass_thru_(false), pass_thru_context_(false), pass_thru_local_(false), pass_thru_(false),
pass_thru_chars_(docstring()) pass_thru_chars_(docstring()), is_toc_caption_(false)
{} {}
@ -119,11 +119,13 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
decoration_ = (*lait).second.decoration; decoration_ = (*lait).second.decoration;
pass_thru_chars_ = (*lait).second.pass_thru_chars; pass_thru_chars_ = (*lait).second.pass_thru_chars;
pass_thru_local_ = false; pass_thru_local_ = false;
if (lait->second.is_toc_caption) if (lait->second.is_toc_caption) {
is_toc_caption_ = true;
// empty if AddToToc is not set // empty if AddToToc is not set
caption_of_toc_ = insetlayout caption_of_toc_ = insetlayout
? it.inset().getLayout().tocType() ? it.inset().getLayout().tocType()
: it.paragraph().layout().tocType(); : it.paragraph().layout().tocType();
}
switch ((*lait).second.passthru) { switch ((*lait).second.passthru) {
case PT_INHERITED: case PT_INHERITED:

View File

@ -69,6 +69,8 @@ public:
/// ///
bool isPassThru() const { return pass_thru_; } bool isPassThru() const { return pass_thru_; }
/// ///
bool isTocCaption() const { return is_toc_caption_; }
///
bool resetFontEdit() const { return false; } bool resetFontEdit() const { return false; }
//@} //@}
/// \name Public functions inherited from InsetCollapsible class /// \name Public functions inherited from InsetCollapsible class
@ -113,6 +115,8 @@ private:
bool pass_thru_; bool pass_thru_;
/// ///
docstring pass_thru_chars_; docstring pass_thru_chars_;
/// Does this argument provide content for the TOC?
bool is_toc_caption_;
/// The type of Toc this is the caption of, empty otherwise. /// The type of Toc this is the caption of, empty otherwise.
std::string caption_of_toc_; std::string caption_of_toc_;

View File

@ -870,13 +870,15 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
addtotoc_stack.push({pit, end}); addtotoc_stack.push({pit, end});
} }
// if we find an optarg, we'll save it for use later. // If we find an InsetArgument that is supposed to provide the TOC caption,
// we'll save it for use later.
InsetArgument const * arginset = nullptr; InsetArgument const * arginset = nullptr;
for (auto const & table : par.insetList()) { for (auto const & table : par.insetList()) {
dit.pos() = table.pos; dit.pos() = table.pos;
table.inset->addToToc(dit, doing_output, utype, backend); table.inset->addToToc(dit, doing_output, utype, backend);
if (InsetArgument const * x = table.inset->asInsetArgument()) if (InsetArgument const * x = table.inset->asInsetArgument())
arginset = x; if (x->isTocCaption())
arginset = x;
} }
// End custom AddToToc in paragraph layouts // End custom AddToToc in paragraph layouts