2003-08-04 10:26:10 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-19 10:04:35 +00:00
|
|
|
/**
|
|
|
|
* \file context.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-08-19 10:04:35 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
#ifndef CONTEXT_H
|
|
|
|
#define CONTEXT_H
|
|
|
|
|
|
|
|
#include "lyxtextclass.h"
|
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
#include <iosfwd>
|
|
|
|
|
2004-06-28 06:53:12 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Small helper struct that holds font properties.
|
|
|
|
* The names are in LyX language, not LaTeX.
|
|
|
|
* We don't use LyXFont, because it pulls in a lot of dependencies and has
|
|
|
|
* more strings than needed (e.g. font family error1 etc.).
|
|
|
|
* If more font related stuff is needed, it might be good to change to
|
|
|
|
* LyXFont.
|
|
|
|
*/
|
2005-02-25 22:13:13 +00:00
|
|
|
class Font {
|
|
|
|
public:
|
2004-06-28 06:53:12 +00:00
|
|
|
Font()
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
size = "normal";
|
|
|
|
family = "default";
|
|
|
|
series = "default";
|
|
|
|
shape = "default";
|
|
|
|
}
|
|
|
|
std::string size;
|
|
|
|
std::string family;
|
|
|
|
std::string series;
|
|
|
|
std::string shape;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Output changed font parameters if \p oldfont and \p newfont differ
|
|
|
|
void output_font_change(std::ostream & os, Font const & oldfont,
|
|
|
|
Font const & newfont);
|
|
|
|
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
// A helper struct
|
2005-02-25 22:13:13 +00:00
|
|
|
class Context {
|
|
|
|
public:
|
2003-08-04 10:26:10 +00:00
|
|
|
Context(bool need_layout_,
|
|
|
|
LyXTextClass const & textclass_,
|
|
|
|
LyXLayout_ptr layout_ = LyXLayout_ptr(),
|
2004-06-28 06:53:12 +00:00
|
|
|
LyXLayout_ptr parent_layout_= LyXLayout_ptr(),
|
|
|
|
Font font_ = Font());
|
2003-08-04 10:26:10 +00:00
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Output a \\begin_layout if requested
|
2003-08-04 10:26:10 +00:00
|
|
|
void check_layout(std::ostream & os);
|
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Output a \\end_layout if needed
|
2003-08-04 10:26:10 +00:00
|
|
|
void check_end_layout(std::ostream & os);
|
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Output a \\begin_deeper if needed
|
2003-08-05 21:55:41 +00:00
|
|
|
void check_deeper(std::ostream & os);
|
2003-08-05 21:46:51 +00:00
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Output a \\end_deeper if needed
|
2003-08-05 21:55:41 +00:00
|
|
|
void check_end_deeper(std::ostream & os);
|
2003-09-09 18:27:24 +00:00
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// dump content on stream (for debugging purpose), with
|
|
|
|
/// description \c desc.
|
2003-08-04 10:26:10 +00:00
|
|
|
void dump(std::ostream &, std::string const & desc = "context") const;
|
|
|
|
|
2003-11-05 10:14:13 +00:00
|
|
|
/// Are we just beginning a new paragraph?
|
|
|
|
bool atParagraphStart() const { return need_layout; }
|
|
|
|
|
|
|
|
/// Begin an item in a list environment
|
|
|
|
void set_item();
|
|
|
|
|
|
|
|
/// Start a new paragraph
|
|
|
|
void new_paragraph(std::ostream & os);
|
|
|
|
|
2003-12-19 10:40:07 +00:00
|
|
|
/// Add extra stuff if not already there
|
|
|
|
void add_extra_stuff(std::string const &);
|
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Do we need to output some \\begin_layout command before the
|
|
|
|
/// next characters?
|
2003-08-04 10:26:10 +00:00
|
|
|
bool need_layout;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// Do we need to output some \\end_layout command
|
2003-08-04 10:26:10 +00:00
|
|
|
bool need_end_layout;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// We may need to add something after this \\begin_layout command
|
2003-08-04 10:26:10 +00:00
|
|
|
std::string extra_stuff;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// If there has been an \\begin_deeper, we'll need a matching
|
|
|
|
/// \\end_deeper
|
2003-08-04 10:26:10 +00:00
|
|
|
bool need_end_deeper;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// If we are in an itemize-like environment, we need an \\item
|
|
|
|
/// for each paragraph, otherwise this has to be a deeper
|
|
|
|
/// paragraph.
|
2003-08-06 22:47:22 +00:00
|
|
|
bool has_item;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// we are handling a standard paragraph in an itemize-like
|
|
|
|
/// environment
|
2003-08-06 22:47:22 +00:00
|
|
|
bool deeper_paragraph;
|
2003-09-09 18:27:24 +00:00
|
|
|
|
2005-07-13 11:38:55 +00:00
|
|
|
/// The textclass of the document. Could actually be a global variable
|
2003-08-04 10:26:10 +00:00
|
|
|
LyXTextClass const & textclass;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// The layout of the current paragraph
|
2003-08-04 10:26:10 +00:00
|
|
|
LyXLayout_ptr layout;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// The layout of the outer paragraph (for environment layouts)
|
2003-08-04 10:26:10 +00:00
|
|
|
LyXLayout_ptr parent_layout;
|
2004-06-28 06:53:12 +00:00
|
|
|
/// font attributes of this context
|
|
|
|
Font font;
|
2005-07-13 11:38:55 +00:00
|
|
|
/// font attributes of normal text
|
|
|
|
static Font normalfont;
|
2003-08-04 10:26:10 +00:00
|
|
|
};
|
2003-09-09 18:27:24 +00:00
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
#endif
|