mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Pass local font to arguments and assure pass_thru is inherited
This commit is contained in:
parent
4f6c0b5202
commit
53002538fa
BIN
src/.Layout.h.kate-swp
Normal file
BIN
src/.Layout.h.kate-swp
Normal file
Binary file not shown.
@ -1461,9 +1461,11 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
|
||||
// we have to provide all the optional arguments here, even though
|
||||
// the last one is the only one we care about.
|
||||
// Separate handling of optional argument inset.
|
||||
if (!layout_->latexargs().empty())
|
||||
latexArgInsets(*owner_, os, features.runparams(),
|
||||
layout_->latexargs());
|
||||
if (!layout_->latexargs().empty()) {
|
||||
OutputParams rp = features.runparams();
|
||||
rp.local_font = &owner_->getFirstFontSettings(bp);
|
||||
latexArgInsets(*owner_, os, rp, layout_->latexargs());
|
||||
}
|
||||
os << from_ascii(layout_->latexparam());
|
||||
}
|
||||
docstring::size_type const length = ods.str().length();
|
||||
@ -2168,7 +2170,7 @@ bool Paragraph::usePlainLayout() const
|
||||
|
||||
bool Paragraph::isPassThru() const
|
||||
{
|
||||
return inInset().getLayout().isPassThru() || d->layout_->pass_thru;
|
||||
return inInset().isPassThru() || d->layout_->pass_thru;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "ColorCode.h"
|
||||
#include "InsetCode.h"
|
||||
#include "InsetLayout.h"
|
||||
#include "LayoutEnums.h"
|
||||
#include "OutputEnums.h"
|
||||
|
||||
@ -418,6 +419,8 @@ public:
|
||||
virtual docstring layoutName() const;
|
||||
///
|
||||
virtual InsetLayout const & getLayout() const;
|
||||
///
|
||||
virtual bool isPassThru() const { return getLayout().isPassThru(); }
|
||||
/// Is this inset's layout defined in the document's textclass?
|
||||
bool undefined() const;
|
||||
/// should this inset be handled like a normal character?
|
||||
|
@ -13,10 +13,13 @@
|
||||
|
||||
#include "InsetArgument.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "Cursor.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "InsetList.h"
|
||||
#include "Language.h"
|
||||
#include "Layout.h"
|
||||
#include "Lexer.h"
|
||||
#include "OutputParams.h"
|
||||
@ -35,7 +38,8 @@ namespace lyx {
|
||||
|
||||
InsetArgument::InsetArgument(Buffer * buf, string const & name)
|
||||
: InsetCollapsable(buf), name_(name), labelstring_(docstring()),
|
||||
font_(inherit_font), labelfont_(inherit_font), decoration_(string())
|
||||
font_(inherit_font), labelfont_(inherit_font), decoration_(string()),
|
||||
pass_thru_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -55,16 +59,19 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
{
|
||||
Layout::LaTeXArgMap args;
|
||||
bool const insetlayout = &it.inset() && it.paragraph().layout().latexargs().empty();
|
||||
if (insetlayout)
|
||||
if (insetlayout) {
|
||||
args = it.inset().getLayout().latexargs();
|
||||
else
|
||||
pass_thru_ = it.inset().getLayout().isPassThru();
|
||||
} else {
|
||||
args = it.paragraph().layout().latexargs();
|
||||
|
||||
pass_thru_ = it.paragraph().layout().pass_thru;
|
||||
}
|
||||
|
||||
// Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
|
||||
if (name_ == "999") {
|
||||
unsigned int const req = insetlayout ? it.inset().getLayout().numRequiredArgs()
|
||||
unsigned int const req = insetlayout ? it.inset().getLayout().requiredArgs()
|
||||
: it.paragraph().layout().requiredArgs();
|
||||
unsigned int const opts = insetlayout ? it.inset().getLayout().numOptArgs()
|
||||
unsigned int const opts = insetlayout ? it.inset().getLayout().optArgs()
|
||||
: it.paragraph().layout().optArgs();
|
||||
unsigned int nr = 0;
|
||||
unsigned int ours = 0;
|
||||
@ -251,8 +258,6 @@ void InsetArgument::latexArgument(otexstream & os,
|
||||
odocstringstream ss;
|
||||
otexstream ots(ss, texrow);
|
||||
OutputParams runparams = runparams_in;
|
||||
if (getLayout().isPassThru())
|
||||
runparams.pass_thru = true;
|
||||
InsetText::latex(ots, runparams);
|
||||
docstring str = ss.str();
|
||||
if (ldelim != "{" && support::contains(str, rdelim))
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
bool neverIndent() const { return true; }
|
||||
///
|
||||
std::string contextMenuName() const;
|
||||
///
|
||||
bool isPassThru() const { return pass_thru_; }
|
||||
//@}
|
||||
/// \name Public functions inherited from InsetCollapsable class
|
||||
//@{
|
||||
@ -90,6 +92,8 @@ private:
|
||||
FontInfo labelfont_;
|
||||
///
|
||||
std::string decoration_;
|
||||
///
|
||||
bool pass_thru_;
|
||||
|
||||
protected:
|
||||
/// \name Protected functions inherited from Inset class
|
||||
|
@ -544,7 +544,7 @@ void InsetLayout::readArgument(Lexer & lex)
|
||||
latexargs_[nr] = arg;
|
||||
}
|
||||
|
||||
unsigned int InsetLayout::numOptArgs() const
|
||||
unsigned int InsetLayout::optArgs() const
|
||||
{
|
||||
unsigned int nr = 0;
|
||||
Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
|
||||
@ -556,7 +556,7 @@ unsigned int InsetLayout::numOptArgs() const
|
||||
}
|
||||
|
||||
|
||||
unsigned int InsetLayout::numRequiredArgs() const
|
||||
unsigned int InsetLayout::requiredArgs() const
|
||||
{
|
||||
unsigned int nr = 0;
|
||||
Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
|
||||
|
@ -88,9 +88,9 @@ public:
|
||||
///
|
||||
Layout::LaTeXArgMap latexargs() const { return latexargs_; }
|
||||
///
|
||||
unsigned int numOptArgs() const;
|
||||
unsigned int optArgs() const;
|
||||
///
|
||||
unsigned int numRequiredArgs() const;
|
||||
unsigned int requiredArgs() const;
|
||||
///
|
||||
docstring preamble() const { return preamble_; }
|
||||
/// Get language dependent macro definitions needed for this inset
|
||||
|
@ -266,7 +266,7 @@ void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
LYXERR(Debug::ACTION, "InsetText::doDispatch(): cmd: " << cmd);
|
||||
|
||||
if (getLayout().isPassThru()) {
|
||||
if (isPassThru()) {
|
||||
// Force any new text to latex_language FIXME: This
|
||||
// should only be necessary in constructor, but new
|
||||
// paragraphs that are created by pressing enter at
|
||||
@ -436,7 +436,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
if (runparams.moving_arg)
|
||||
os << "\\protect";
|
||||
os << '\\' << from_utf8(il.latexname());
|
||||
getOptArg(os, runparams);
|
||||
if (!il.latexargs().empty())
|
||||
getOptArg(os, runparams);
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
os << '{';
|
||||
@ -449,13 +450,15 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os.texrow().start(runparams.lastid,
|
||||
runparams.lastpos);
|
||||
os << "\\begin{" << from_utf8(il.latexname()) << "}";
|
||||
getOptArg(os, runparams);
|
||||
if (!il.latexargs().empty())
|
||||
getOptArg(os, runparams);
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
os << '\n';
|
||||
}
|
||||
} else {
|
||||
getOptArg(os, runparams);
|
||||
if (!il.latexargs().empty())
|
||||
getOptArg(os, runparams);
|
||||
if (!il.latexparam().empty())
|
||||
os << from_utf8(il.latexparam());
|
||||
}
|
||||
@ -464,7 +467,7 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << il.leftdelim();
|
||||
|
||||
OutputParams rp = runparams;
|
||||
if (il.isPassThru())
|
||||
if (isPassThru())
|
||||
rp.pass_thru = true;
|
||||
if (il.isNeedProtect())
|
||||
rp.moving_arg = true;
|
||||
@ -605,8 +608,13 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
|
||||
}
|
||||
|
||||
void InsetText::getOptArg(otexstream & os,
|
||||
OutputParams const & runparams) const
|
||||
OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams = runparams_in;
|
||||
runparams.local_font =
|
||||
¶graphs()[0].getFirstFontSettings(buffer().masterBuffer()->params());
|
||||
if (isPassThru())
|
||||
runparams.pass_thru = true;
|
||||
latexArgInsets(paragraphs()[0], os, runparams, getLayout().latexargs());
|
||||
}
|
||||
|
||||
@ -728,7 +736,7 @@ bool InsetText::insetAllowed(InsetCode code) const
|
||||
case ARG_CODE:
|
||||
return true;
|
||||
default:
|
||||
return !getLayout().isPassThru();
|
||||
return !isPassThru();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,11 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
|
||||
|
||||
if (style.isEnvironment()) {
|
||||
os << "\\begin{" << from_ascii(style.latexname()) << '}';
|
||||
if (!style.latexargs().empty())
|
||||
latexArgInsets(*pit, os, runparams, style.latexargs());
|
||||
if (!style.latexargs().empty()) {
|
||||
OutputParams rp = runparams;
|
||||
rp.local_font = &pit->getFirstFontSettings(bparams);
|
||||
latexArgInsets(*pit, os, rp, style.latexargs());
|
||||
}
|
||||
if (style.latextype == LATEX_LIST_ENVIRONMENT) {
|
||||
os << '{'
|
||||
<< pit->params().labelWidthString()
|
||||
@ -465,7 +468,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
open_encoding_ = none;
|
||||
}
|
||||
|
||||
if (text.inset().getLayout().isPassThru()) {
|
||||
if (text.inset().isPassThru()) {
|
||||
Font const outerfont = text.outerFont(pit);
|
||||
|
||||
// No newline before first paragraph in this lyxtext
|
||||
@ -484,6 +487,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
|
||||
if (style.pass_thru) {
|
||||
Font const outerfont = text.outerFont(pit);
|
||||
runparams.local_font = &par.getFirstFontSettings(bparams);
|
||||
parStartCommand(par, os, runparams, style);
|
||||
|
||||
par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
|
||||
@ -712,8 +716,8 @@ void TeXOnePar(Buffer const & buf,
|
||||
}
|
||||
}
|
||||
|
||||
runparams.local_font = &par.getFirstFontSettings(bparams);
|
||||
parStartCommand(par, os, runparams, style);
|
||||
|
||||
Font const outerfont = text.outerFont(pit);
|
||||
|
||||
// FIXME UNICODE
|
||||
|
Loading…
Reference in New Issue
Block a user