mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Add CopyStyle tag for InsetLayout, per request of Steve Litt.
Update documentation for new tag. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25933 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0b86ea9f71
commit
5d95df6e39
@ -1,5 +1,5 @@
|
||||
#LyX 1.6.0svn created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 338
|
||||
\lyxformat 339
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass scrbook
|
||||
@ -9518,6 +9518,13 @@ CopyStyle
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset CommandInset label
|
||||
LatexCommand label
|
||||
name "des:CopyStyle"
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
@ -12922,6 +12929,26 @@ src/ColorCode.h
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
CopyStyle
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
As with paragraph styles (see page
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand ref
|
||||
reference "des:CopyStyle"
|
||||
|
||||
\end_inset
|
||||
|
||||
).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Decoration
|
||||
\end_layout
|
||||
|
@ -28,6 +28,7 @@ import os, re, string, sys
|
||||
|
||||
# Incremented to format 8, 25 July 2008 by rgh
|
||||
# UseModule tag added to layout files
|
||||
# CopyStyle added to InsetLayout
|
||||
currentFormat = 8
|
||||
|
||||
|
||||
@ -171,6 +172,10 @@ def convert(lines):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format == 7:
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if format == 6:
|
||||
i += 1
|
||||
continue
|
||||
|
@ -513,7 +513,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
|
||||
case TC_INSETLAYOUT:
|
||||
if (lexrc.next()) {
|
||||
InsetLayout il;
|
||||
if (il.read(lexrc))
|
||||
if (il.read(lexrc, *this))
|
||||
insetlayoutlist_[il.name()] = il;
|
||||
// else there was an error, so forget it
|
||||
}
|
||||
|
@ -135,6 +135,8 @@ public:
|
||||
bool hasLayout(docstring const & name) const;
|
||||
///
|
||||
Layout const & operator[](docstring const & vname) const;
|
||||
/// Inset layouts of this doc class
|
||||
InsetLayouts const & insetLayouts() const { return insetlayoutlist_; };
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// reading routines
|
||||
@ -330,8 +332,6 @@ public:
|
||||
bool hasLaTeXLayout(std::string const & lay) const;
|
||||
/// A DocumentClass nevers count as loaded, since it is dynamic
|
||||
virtual bool loaded() { return false; }
|
||||
/// Inset layouts of this doc class
|
||||
InsetLayouts const & insetLayouts() const { return insetlayoutlist_; };
|
||||
/// \return the layout object of an inset given by name. If the name
|
||||
/// is not found as such, the part after the ':' is stripped off, and
|
||||
/// searched again. In this way, an error fallback can be provided:
|
||||
|
@ -17,7 +17,9 @@
|
||||
#include "Color.h"
|
||||
#include "Font.h"
|
||||
#include "Lexer.h"
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <vector>
|
||||
@ -55,16 +57,17 @@ InsetLayout::InsetDecoration translateDecoration(std::string const & str)
|
||||
}
|
||||
|
||||
|
||||
bool InsetLayout::read(Lexer & lex)
|
||||
bool InsetLayout::read(Lexer & lex, TextClass & tclass)
|
||||
{
|
||||
name_ = support::subst(lex.getDocString(), '_', ' ');
|
||||
|
||||
enum {
|
||||
IL_FONT,
|
||||
IL_BGCOLOR,
|
||||
IL_COPYSTYLE,
|
||||
IL_DECORATION,
|
||||
IL_FREESPACING,
|
||||
IL_FONT,
|
||||
IL_FORCELTR,
|
||||
IL_FREESPACING,
|
||||
IL_LABELFONT,
|
||||
IL_LABELSTRING,
|
||||
IL_LATEXNAME,
|
||||
@ -83,6 +86,7 @@ bool InsetLayout::read(Lexer & lex)
|
||||
|
||||
LexerKeyword elementTags[] = {
|
||||
{ "bgcolor", IL_BGCOLOR },
|
||||
{ "copystyle", IL_COPYSTYLE},
|
||||
{ "decoration", IL_DECORATION },
|
||||
{ "end", IL_END },
|
||||
{ "font", IL_FONT },
|
||||
@ -161,6 +165,33 @@ bool InsetLayout::read(Lexer & lex)
|
||||
case IL_NEEDPROTECT:
|
||||
lex >> needprotect_;
|
||||
break;
|
||||
case IL_COPYSTYLE: { // initialize with a known style
|
||||
docstring style;
|
||||
lex >> style;
|
||||
style = support::subst(style, '_', ' ');
|
||||
|
||||
// We don't want to apply the algorithm in DocumentClass::insetLayout()
|
||||
// here. So we do it the long way.
|
||||
TextClass::InsetLayouts::const_iterator it =
|
||||
tclass.insetLayouts().find(style);
|
||||
if (it != tclass.insetLayouts().end()) {
|
||||
docstring const tmpname = name_;
|
||||
this->operator=(it->second);
|
||||
name_ = tmpname;
|
||||
} else {
|
||||
LYXERR0("Cannot copy unknown InsetLayout `"
|
||||
<< style << "'\n"
|
||||
<< "All InsetLayouts so far:");
|
||||
TextClass::InsetLayouts::const_iterator lit =
|
||||
tclass.insetLayouts().begin();
|
||||
TextClass::InsetLayouts::const_iterator len =
|
||||
tclass.insetLayouts().end();
|
||||
for (; lit != len; ++lit)
|
||||
lyxerr << lit->second.name() << "\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case IL_FONT: {
|
||||
font_ = lyxRead(lex, inherit_font);
|
||||
// If you want to define labelfont, you need to do so after
|
||||
|
@ -24,6 +24,7 @@
|
||||
namespace lyx {
|
||||
|
||||
class Lexer;
|
||||
class TextClass;
|
||||
|
||||
///
|
||||
class InsetLayout {
|
||||
@ -38,7 +39,7 @@ public:
|
||||
Default
|
||||
};
|
||||
///
|
||||
bool read(Lexer & lexrc);
|
||||
bool read(Lexer & lexrc, TextClass & tclass);
|
||||
///
|
||||
docstring name() const { return name_; };
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user