2003-08-17 11:28:23 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetBranch.h
|
2003-08-17 11:28:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Martin Vermeer
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-08-17 11:28:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSETBRANCH_H
|
|
|
|
#define INSETBRANCH_H
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetCollapsable.h"
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class InsetBranchParams {
|
|
|
|
public:
|
2008-03-27 22:26:24 +00:00
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
explicit InsetBranchParams(docstring const & b = docstring())
|
2003-12-14 16:33:56 +00:00
|
|
|
: branch(b) {}
|
2003-08-28 07:41:31 +00:00
|
|
|
///
|
|
|
|
void write(std::ostream & os) const;
|
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void read(Lexer & lex);
|
2003-08-28 07:41:31 +00:00
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
docstring branch;
|
2003-12-14 16:33:56 +00:00
|
|
|
};
|
2003-08-28 07:41:31 +00:00
|
|
|
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetBranch
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/// The Branch inset for alternative, conditional output.
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
class InsetBranch : public InsetCollapsable
|
|
|
|
{
|
2003-08-17 11:28:23 +00:00
|
|
|
public:
|
|
|
|
///
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetBranch(Buffer *, InsetBranchParams const &);
|
2008-03-27 22:26:24 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
static std::string params2string(InsetBranchParams const &);
|
|
|
|
///
|
|
|
|
static void string2params(std::string const &, InsetBranchParams &);
|
2009-07-09 09:48:34 +00:00
|
|
|
///
|
|
|
|
docstring branch() const { return params_.branch; }
|
2009-07-10 06:49:51 +00:00
|
|
|
///
|
|
|
|
void rename(docstring const & newname) { params_.branch = newname; }
|
2008-03-27 22:26:24 +00:00
|
|
|
|
|
|
|
private:
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2007-10-13 09:04:52 +00:00
|
|
|
InsetCode lyxCode() const { return BRANCH_CODE; }
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void read(Lexer & lex);
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2009-02-25 22:35:41 +00:00
|
|
|
docstring const buttonLabel(BufferView const & bv) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2009-12-17 14:09:37 +00:00
|
|
|
ColorCode backgroundColor(PainterInfo const &) const;
|
2007-06-12 13:45:49 +00:00
|
|
|
///
|
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
|
|
|
int latex(otexstream &, OutputParams const &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int plaintext(odocstream &, OutputParams const &) const;
|
2007-02-16 09:28:25 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream &, OutputParams const &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2009-11-21 23:24:21 +00:00
|
|
|
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
2009-06-05 17:48:14 +00:00
|
|
|
///
|
2010-12-15 01:34:04 +00:00
|
|
|
void toString(odocstream &) const;
|
2007-01-19 16:23:47 +00:00
|
|
|
///
|
2010-12-20 21:55:09 +00:00
|
|
|
void forToc(docstring &, size_t) const;
|
|
|
|
///
|
2003-08-17 11:28:23 +00:00
|
|
|
void validate(LaTeXFeatures &) const;
|
|
|
|
///
|
2010-11-29 21:27:25 +00:00
|
|
|
docstring contextMenuName() const;
|
2009-03-31 09:38:07 +00:00
|
|
|
///
|
2011-01-12 22:23:27 +00:00
|
|
|
void addToToc(DocIterator const &) const;
|
2008-05-30 13:59:29 +00:00
|
|
|
///
|
2003-08-17 11:28:23 +00:00
|
|
|
InsetBranchParams const & params() const { return params_; }
|
|
|
|
///
|
|
|
|
void setParams(InsetBranchParams const & params) { params_ = params; }
|
2003-12-14 16:33:56 +00:00
|
|
|
|
|
|
|
/** \returns true if params_.branch is listed as 'selected' in
|
2005-10-25 15:21:49 +00:00
|
|
|
\c buffer. This handles the case of child documents.
|
2003-12-14 16:33:56 +00:00
|
|
|
*/
|
2008-02-27 20:43:16 +00:00
|
|
|
bool isBranchSelected() const;
|
2008-04-23 10:55:51 +00:00
|
|
|
/*!
|
|
|
|
* Is the content of this inset part of the output document?
|
|
|
|
*
|
|
|
|
* Note that Branch insets are only considered part of the
|
|
|
|
* document when they are selected.
|
|
|
|
*/
|
|
|
|
bool producesOutput() const { return isBranchSelected(); }
|
2005-04-22 08:57:22 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
2007-12-21 20:42:46 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
bool isMacroScope() const;
|
2008-02-12 09:11:06 +00:00
|
|
|
///
|
|
|
|
docstring toolTip(BufferView const & bv, int x, int y) const;
|
2008-03-24 19:18:18 +00:00
|
|
|
///
|
2008-07-10 17:41:52 +00:00
|
|
|
bool usePlainLayout() const { return false; }
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2008-03-04 22:28:18 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2007-04-30 14:39:09 +00:00
|
|
|
docstring name() const { return from_ascii("Branch"); }
|
2008-03-04 22:28:18 +00:00
|
|
|
///
|
|
|
|
Inset * clone() const { return new InsetBranch(*this); }
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
friend class InsetBranchParams;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetBranchParams params_;
|
2003-08-17 11:28:23 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
#endif
|