2007-11-07 22:31:07 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file InsetLayout.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-02-22 02:32:52 +00:00
|
|
|
* \author Martin Vermeer
|
|
|
|
* \author Richard Heck
|
|
|
|
*
|
2007-11-07 22:31:07 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSET_LAYOUT_H
|
|
|
|
#define INSET_LAYOUT_H
|
|
|
|
|
|
|
|
#include "ColorCode.h"
|
|
|
|
#include "FontInfo.h"
|
|
|
|
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2008-02-01 15:12:04 +00:00
|
|
|
#include <set>
|
2008-01-07 16:59:10 +00:00
|
|
|
#include <string>
|
|
|
|
|
2007-11-07 22:31:07 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2008-02-22 03:39:10 +00:00
|
|
|
class Lexer;
|
2008-07-28 15:14:37 +00:00
|
|
|
class TextClass;
|
2008-02-22 16:15:21 +00:00
|
|
|
|
2007-11-07 22:31:07 +00:00
|
|
|
///
|
|
|
|
class InsetLayout {
|
|
|
|
public:
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2010-01-14 23:45:53 +00:00
|
|
|
InsetLayout();
|
2010-01-14 21:31:27 +00:00
|
|
|
///
|
2008-02-22 16:24:55 +00:00
|
|
|
enum InsetDecoration {
|
2008-10-25 13:41:02 +00:00
|
|
|
CLASSIC,
|
|
|
|
MINIMALISTIC,
|
|
|
|
CONGLOMERATE,
|
|
|
|
DEFAULT
|
2008-02-22 16:24:55 +00:00
|
|
|
};
|
2009-10-26 20:53:46 +00:00
|
|
|
///
|
2008-10-25 13:32:54 +00:00
|
|
|
enum InsetLyXType {
|
|
|
|
NOLYXTYPE,
|
|
|
|
CHARSTYLE,
|
|
|
|
CUSTOM,
|
|
|
|
ELEMENT,
|
|
|
|
END,
|
|
|
|
STANDARD
|
|
|
|
};
|
2009-10-26 20:53:46 +00:00
|
|
|
///
|
2008-10-25 14:02:25 +00:00
|
|
|
enum InsetLaTeXType {
|
|
|
|
NOLATEXTYPE,
|
|
|
|
COMMAND,
|
|
|
|
ENVIRONMENT,
|
|
|
|
ILT_ERROR
|
|
|
|
};
|
2008-02-22 16:24:55 +00:00
|
|
|
///
|
2008-12-16 14:13:02 +00:00
|
|
|
bool read(Lexer & lexrc, TextClass const & tclass);
|
2008-02-22 03:27:42 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
docstring name() const { return name_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2010-01-14 23:45:53 +00:00
|
|
|
void setName(docstring const & n) { name_ = n; }
|
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
InsetLyXType lyxtype() const { return lyxtype_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
docstring labelstring() const { return labelstring_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-12-18 00:29:22 +00:00
|
|
|
bool contentaslabel() const { return contentaslabel_; }
|
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
InsetDecoration decoration() const { return decoration_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
InsetLaTeXType latextype() const { return latextype_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
std::string latexname() const { return latexname_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
std::string latexparam() const { return latexparam_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
FontInfo font() const { return font_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
FontInfo labelfont() const { return labelfont_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
ColorCode bgcolor() const { return bgcolor_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
docstring preamble() const { return preamble_; }
|
|
|
|
///
|
|
|
|
docstring counter() const { return counter_; }
|
2010-03-17 12:23:24 +00:00
|
|
|
///
|
|
|
|
docstring refprefix() const { return refprefix_; }
|
2010-01-20 17:51:07 +00:00
|
|
|
/// The tag enclosing all the material in this inset. Default is "span".
|
2009-10-27 19:46:47 +00:00
|
|
|
std::string const & htmltag() const;
|
2010-01-20 17:51:07 +00:00
|
|
|
/// Additional attributes for inclusion with the start tag. Default (if
|
|
|
|
/// a tag is provided) is: class="name".
|
2009-10-27 19:17:52 +00:00
|
|
|
std::string const & htmlattr() const;
|
2010-01-20 17:51:07 +00:00
|
|
|
/// Tag for individual paragraphs in the inset. Default is none.
|
2009-10-27 19:17:52 +00:00
|
|
|
std::string const & htmlinnertag() const { return htmlinnertag_; }
|
2010-01-20 17:51:07 +00:00
|
|
|
/// Attributes for that tag. Default (if a tag is provided) is:
|
|
|
|
/// class="name_inner".
|
2009-10-27 19:17:52 +00:00
|
|
|
std::string const & htmlinnerattr() const;
|
2010-01-20 17:51:07 +00:00
|
|
|
/// A label for this environment, possibly including a reference
|
|
|
|
/// to a counter. E.g., for footnote, it might be:
|
|
|
|
/// \arabic{footnote}
|
|
|
|
/// No default.
|
|
|
|
/// FIXME Could we get this from the layout?
|
2009-06-06 03:02:43 +00:00
|
|
|
std::string const & htmllabel() const { return htmllabel_; }
|
2009-10-27 19:17:52 +00:00
|
|
|
///
|
|
|
|
inline std::string htmllabeltag() const { return "span"; }
|
|
|
|
///
|
|
|
|
std::string htmllabelattr() const
|
|
|
|
{ return "class=\"" + defaultCSSClass() + "_label\""; }
|
2010-01-20 17:51:07 +00:00
|
|
|
/// CSS associated with this inset.
|
2009-10-27 14:33:01 +00:00
|
|
|
docstring htmlstyle() const;
|
2010-01-20 17:51:07 +00:00
|
|
|
/// Additional material for the header.
|
2009-06-05 19:42:56 +00:00
|
|
|
docstring htmlpreamble() const { return htmlpreamble_; }
|
2010-01-20 17:51:07 +00:00
|
|
|
/// Whether this inset represents a "block" of material, i.e., a set
|
|
|
|
/// of paragraphs of its own (true), or should be run into the previous
|
|
|
|
/// paragraph (false). Examples:
|
|
|
|
/// For branches, this is false.
|
|
|
|
/// For footnotes, this is true.
|
|
|
|
/// Defaults to true.
|
2009-10-26 20:53:46 +00:00
|
|
|
bool htmlisblock() const { return htmlisblock_; }
|
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
std::set<std::string> requires() const { return requires_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool isMultiPar() const { return multipar_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2008-10-05 19:38:22 +00:00
|
|
|
bool forcePlainLayout() const { return forceplain_; }
|
|
|
|
///
|
|
|
|
bool allowParagraphCustomization() const { return custompars_; }
|
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool isPassThru() const { return passthru_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2010-08-09 21:20:29 +00:00
|
|
|
bool parbreakIsNewline() const { return parbreakisnewline_; }
|
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool isNeedProtect() const { return needprotect_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool isFreeSpacing() const { return freespacing_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool isKeepEmpty() const { return keepempty_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool forceLTR() const { return forceltr_; }
|
2009-02-06 17:54:33 +00:00
|
|
|
///
|
2009-12-03 23:10:08 +00:00
|
|
|
bool isInToc() const { return intoc_; }
|
2009-10-27 14:33:01 +00:00
|
|
|
///
|
2010-02-13 15:44:17 +00:00
|
|
|
bool spellcheck() const { return spellcheck_; }
|
2010-10-13 15:54:39 +00:00
|
|
|
///
|
|
|
|
bool resetsFont() const { return resetsfont_; }
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
///
|
|
|
|
bool isDisplay() const { return display_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
private:
|
2009-10-27 14:33:01 +00:00
|
|
|
///
|
|
|
|
void makeDefaultCSS() const;
|
|
|
|
///
|
|
|
|
std::string defaultCSSClass() const;
|
|
|
|
///
|
|
|
|
std::string defaultCSSLabelClass() const { return defaultCSSClass() + "_label"; }
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2008-02-22 03:27:42 +00:00
|
|
|
docstring name_;
|
2008-04-06 16:17:03 +00:00
|
|
|
/**
|
|
|
|
* This is only used (at present) to decide where to put them on the menus.
|
|
|
|
* Values are 'charstyle', 'custom' (things that by default look like a
|
|
|
|
* footnote), 'element' (docbook), 'standard'.
|
|
|
|
*/
|
2008-10-25 13:32:54 +00:00
|
|
|
InsetLyXType lyxtype_;
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
|
|
|
docstring labelstring_;
|
|
|
|
///
|
2009-12-18 00:29:22 +00:00
|
|
|
bool contentaslabel_;
|
|
|
|
///
|
2008-02-22 16:15:21 +00:00
|
|
|
InsetDecoration decoration_;
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
2008-10-25 14:02:25 +00:00
|
|
|
InsetLaTeXType latextype_;
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
|
|
|
std::string latexname_;
|
|
|
|
///
|
|
|
|
std::string latexparam_;
|
|
|
|
///
|
|
|
|
FontInfo font_;
|
|
|
|
///
|
|
|
|
FontInfo labelfont_;
|
|
|
|
///
|
|
|
|
ColorCode bgcolor_;
|
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
docstring counter_;
|
|
|
|
///
|
2009-06-03 23:44:31 +00:00
|
|
|
docstring preamble_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2010-03-17 12:23:24 +00:00
|
|
|
docstring refprefix_;
|
|
|
|
///
|
2009-10-27 19:46:47 +00:00
|
|
|
mutable std::string htmltag_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-10-27 19:17:52 +00:00
|
|
|
mutable std::string htmlattr_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
std::string htmlinnertag_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-10-27 19:17:52 +00:00
|
|
|
mutable std::string htmlinnerattr_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-06-06 03:02:43 +00:00
|
|
|
std::string htmllabel_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-06-05 17:36:51 +00:00
|
|
|
docstring htmlstyle_;
|
2009-10-27 14:33:01 +00:00
|
|
|
/// Cache for default CSS info for this inset.
|
|
|
|
mutable docstring htmldefaultstyle_;
|
2010-01-20 17:51:07 +00:00
|
|
|
/// Cache for default CSS class.
|
2009-10-27 14:33:01 +00:00
|
|
|
mutable std::string defaultcssclass_;
|
|
|
|
/// Whether to force generation of default CSS even if some is given.
|
|
|
|
/// False by default.
|
|
|
|
bool htmlforcecss_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-06-05 19:42:56 +00:00
|
|
|
docstring htmlpreamble_;
|
2010-01-20 17:51:07 +00:00
|
|
|
///
|
2009-10-26 20:53:46 +00:00
|
|
|
bool htmlisblock_;
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
|
|
|
std::set<std::string> requires_;
|
|
|
|
///
|
|
|
|
bool multipar_;
|
2008-10-05 19:38:22 +00:00
|
|
|
///
|
|
|
|
bool custompars_;
|
|
|
|
///
|
|
|
|
bool forceplain_;
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
|
|
|
bool passthru_;
|
|
|
|
///
|
2010-08-09 21:20:29 +00:00
|
|
|
bool parbreakisnewline_;
|
2008-02-22 02:32:52 +00:00
|
|
|
///
|
|
|
|
bool freespacing_;
|
|
|
|
///
|
|
|
|
bool keepempty_;
|
|
|
|
///
|
|
|
|
bool forceltr_;
|
2010-08-09 21:20:29 +00:00
|
|
|
///
|
|
|
|
bool needprotect_;
|
2009-02-06 17:54:33 +00:00
|
|
|
/// should the contents be written to TOC strings?
|
|
|
|
bool intoc_;
|
2010-02-13 15:44:17 +00:00
|
|
|
/// check spelling of this inset?
|
|
|
|
bool spellcheck_;
|
2010-10-13 15:54:39 +00:00
|
|
|
///
|
|
|
|
bool resetsfont_;
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
///
|
|
|
|
bool display_;
|
2007-11-07 22:31:07 +00:00
|
|
|
};
|
|
|
|
|
2008-10-25 13:32:54 +00:00
|
|
|
///
|
|
|
|
InsetLayout::InsetLyXType translateLyXType(std::string const & str);
|
|
|
|
|
2007-11-07 22:31:07 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif
|