mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
move the the latex and validate methods from InsetCollapsable to InsetText; small cleanups
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30582 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
34fc56c9bc
commit
ace4f7d3b8
@ -76,6 +76,7 @@ InsetLayout Marginal
|
||||
Size Small
|
||||
EndFont
|
||||
MultiPar true
|
||||
NeedProtect true
|
||||
HTMLTag span
|
||||
HTMLAttr class='marginal'
|
||||
HTMLStyle
|
||||
@ -240,8 +241,6 @@ End
|
||||
|
||||
InsetLayout Index
|
||||
LabelString Idx
|
||||
LatexType command
|
||||
LatexName index
|
||||
Decoration classic
|
||||
Font
|
||||
Color foreground
|
||||
@ -260,7 +259,6 @@ InsetLayout Index
|
||||
MultiPar false
|
||||
CustomPars false
|
||||
ForcePlain true
|
||||
NeedProtect true
|
||||
End
|
||||
|
||||
InsetLayout Box
|
||||
@ -307,11 +305,16 @@ End
|
||||
|
||||
InsetLayout URL
|
||||
LyXType standard
|
||||
LatexName url
|
||||
LatexType command
|
||||
Decoration classic
|
||||
LabelString URL
|
||||
LatexName url
|
||||
LatexType command
|
||||
Requires url
|
||||
MultiPar false
|
||||
CustomPars false
|
||||
ForcePlain true
|
||||
PassThru true
|
||||
FreeSpacing true
|
||||
ForceLTR true
|
||||
Font
|
||||
Family Typewriter
|
||||
@ -322,7 +325,6 @@ InsetLayout URL
|
||||
Color urllabel
|
||||
Size Small
|
||||
EndFont
|
||||
Requires url
|
||||
End
|
||||
|
||||
InsetLayout OptArg
|
||||
|
@ -26,10 +26,10 @@
|
||||
#include "InsetLayout.h"
|
||||
#include "InsetList.h"
|
||||
#include "Language.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Lexer.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "output_xhtml.h"
|
||||
#include "OutputParams.h"
|
||||
#include "paragraph_funcs.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "sgml.h"
|
||||
@ -616,47 +616,6 @@ InsetLayout::InsetDecoration InsetCollapsable::decoration() const
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::latex(odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
// This implements the standard way of handling the LaTeX output of
|
||||
// a collapsable inset, either a command or an environment. Standard
|
||||
// collapsable insets should not redefine this, non-standard ones may
|
||||
// call this.
|
||||
InsetLayout const & il = getLayout();
|
||||
if (!il.latexname().empty()) {
|
||||
if (il.latextype() == InsetLayout::COMMAND) {
|
||||
// FIXME UNICODE
|
||||
if (runparams.moving_arg)
|
||||
os << "\\protect";
|
||||
os << '\\' << from_utf8(il.latexname());
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
os << '{';
|
||||
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
|
||||
os << "%\n\\begin{" << from_utf8(il.latexname()) << "}\n";
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
}
|
||||
}
|
||||
OutputParams rp = runparams;
|
||||
if (il.isPassThru())
|
||||
rp.verbatim = true;
|
||||
if (il.isNeedProtect())
|
||||
rp.moving_arg = true;
|
||||
int i = InsetText::latex(os, rp);
|
||||
if (!il.latexname().empty()) {
|
||||
if (il.latextype() == InsetLayout::COMMAND) {
|
||||
os << "}";
|
||||
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
|
||||
os << "\n\\end{" << from_utf8(il.latexname()) << "}\n";
|
||||
i += 4;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
// FIXME It seems as if it ought to be possible to do this more simply,
|
||||
// maybe by calling InsetText::docbook() in the middle there.
|
||||
int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
@ -709,13 +668,6 @@ docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparam
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.useInsetLayout(getLayout());
|
||||
InsetText::validate(features);
|
||||
}
|
||||
|
||||
|
||||
bool InsetCollapsable::undefined() const
|
||||
{
|
||||
docstring const & n = getLayout().name();
|
||||
|
@ -126,16 +126,12 @@ public:
|
||||
///
|
||||
ColorCode labelColor() const { return getLayout().labelfont().color(); }
|
||||
///
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
int docbook(odocstream &, OutputParams const &) const;
|
||||
/// It will rarely be right to call this from subclasses, due
|
||||
/// to the fact that it steps counters, etc. Instead, call
|
||||
/// InsetText::xhtml().
|
||||
docstring xhtml(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
|
||||
|
||||
///
|
||||
|
@ -35,18 +35,6 @@ docstring InsetMarginal::editMessage() const
|
||||
}
|
||||
|
||||
|
||||
int InsetMarginal::latex(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
os << "%\n";
|
||||
if (runparams.moving_arg)
|
||||
os << "\\protect";
|
||||
os << "\\marginpar{";
|
||||
int const i = InsetText::latex(os, runparams);
|
||||
os << "%\n}";
|
||||
return i + 2;
|
||||
}
|
||||
|
||||
|
||||
int InsetMarginal::plaintext(odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
|
@ -31,8 +31,6 @@ public:
|
||||
///
|
||||
docstring name() const { return from_ascii("Marginal"); }
|
||||
///
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
int plaintext(odocstream &, OutputParams const & runparams) const;
|
||||
///
|
||||
int docbook(odocstream &, OutputParams const & runparams) const;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "InsetList.h"
|
||||
#include "Intl.h"
|
||||
#include "Language.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Lexer.h"
|
||||
#include "lyxfind.h"
|
||||
#include "LyXRC.h"
|
||||
@ -377,9 +378,48 @@ void InsetText::rejectChanges()
|
||||
|
||||
int InsetText::latex(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// This implements the standard way of handling the LaTeX
|
||||
// output of a text inset, either a command or an
|
||||
// environment. Standard collapsable insets should not
|
||||
// redefine this, non-standard ones may call this.
|
||||
InsetLayout const & il = getLayout();
|
||||
int rows = 0;
|
||||
if (!il.latexname().empty()) {
|
||||
if (il.latextype() == InsetLayout::COMMAND) {
|
||||
// FIXME UNICODE
|
||||
if (runparams.moving_arg)
|
||||
os << "\\protect";
|
||||
os << '\\' << from_utf8(il.latexname());
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
os << '{';
|
||||
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
|
||||
os << "%\n\\begin{" << from_utf8(il.latexname()) << "}\n";
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
rows += 2;
|
||||
}
|
||||
}
|
||||
OutputParams rp = runparams;
|
||||
if (il.isPassThru())
|
||||
rp.verbatim = true;
|
||||
if (il.isNeedProtect())
|
||||
rp.moving_arg = true;
|
||||
|
||||
// Output the contents of the inset
|
||||
TexRow texrow;
|
||||
latexParagraphs(buffer(), text_, os, texrow, runparams);
|
||||
return texrow.rows();
|
||||
latexParagraphs(buffer(), text_, os, texrow, rp);
|
||||
rows += texrow.rows();
|
||||
|
||||
if (!il.latexname().empty()) {
|
||||
if (il.latextype() == InsetLayout::COMMAND) {
|
||||
os << "}";
|
||||
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
|
||||
os << "\n\\end{" << from_utf8(il.latexname()) << "}\n";
|
||||
rows += 2;
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
@ -425,6 +465,7 @@ docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) cons
|
||||
|
||||
void InsetText::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.useInsetLayout(getLayout());
|
||||
for_each(paragraphs().begin(), paragraphs().end(),
|
||||
bind(&Paragraph::validate, _1, ref(features)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user