cosmetics

(maily move layout related enums into a header of there own to remov
include dependencies, alos rename a few things)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20598 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-29 20:02:32 +00:00
parent 473b41a736
commit cd72af583f
34 changed files with 248 additions and 211 deletions

View File

@ -33,6 +33,7 @@
#include "Language.h"
#include "LaTeX.h"
#include "LaTeXFeatures.h"
#include "Layout.h"
#include "LyXAction.h"
#include "Lexer.h"
#include "Text.h"

View File

@ -23,6 +23,7 @@
#include "Floating.h"
#include "FloatList.h"
#include "Language.h"
#include "Layout.h"
#include "Lexer.h"
#include "LyXRC.h"

View File

@ -94,8 +94,7 @@ enum LayoutTags {
/////////////////////
// Constructor for layout
Layout::Layout ()
Layout::Layout()
{
margintype = MARGIN_STATIC;
latextype = LATEX_PARAGRAPH;
@ -131,7 +130,6 @@ Layout::Layout ()
}
// Reads a layout definition from file
bool Layout::read(Lexer & lexrc, TextClass const & tclass)
{
// This table is sorted alphabetically [asierra 30March96]
@ -656,17 +654,14 @@ void Layout::readLabelType(Lexer & lexrc)
}
namespace {
keyword_item endlabelTypeTags[] = {
static keyword_item endlabelTypeTags[] =
{
{ "box", END_LABEL_BOX },
{ "filled_box", END_LABEL_FILLED_BOX },
{ "no_label", END_LABEL_NO_LABEL },
{ "static", END_LABEL_STATIC }
};
} // namespace anon
void Layout::readEndLabelType(Lexer & lexrc)
{
@ -681,7 +676,7 @@ void Layout::readEndLabelType(Lexer & lexrc)
case END_LABEL_BOX:
case END_LABEL_FILLED_BOX:
case END_LABEL_NO_LABEL:
endlabeltype = static_cast<LYX_END_LABEL_TYPES>(le);
endlabeltype = static_cast<EndLabelType>(le);
break;
default:
lyxerr << "Unhandled value " << le
@ -713,7 +708,7 @@ void Layout::readMargin(Lexer & lexrc)
case MARGIN_DYNAMIC:
case MARGIN_FIRST_DYNAMIC:
case MARGIN_RIGHT_ADDRESS_BOX:
margintype = static_cast<LYX_MARGIN_TYPE>(le);
margintype = static_cast<MarginType>(le);
break;
default:
lyxerr << "Unhandled value " << le
@ -746,7 +741,7 @@ void Layout::readLatexType(Lexer & lexrc)
case LATEX_ITEM_ENVIRONMENT:
case LATEX_BIB_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
latextype = static_cast<LYX_LATEX_TYPES>(le);
latextype = static_cast<LatexType>(le);
break;
default:
lyxerr << "Unhandled value " << le
@ -805,9 +800,9 @@ docstring const & Layout::name() const
}
void Layout::setName(docstring const & n)
void Layout::setName(docstring const & name)
{
name_ = n;
name_ = name;
}
@ -833,6 +828,4 @@ Layout * Layout::forCaption()
return lay;
}
} // namespace lyx

View File

@ -11,149 +11,19 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef LYX_LAYOUT_H
#define LYX_LAYOUT_H
#ifndef LAYOUT_H
#define LAYOUT_H
#include "Font.h"
#include "LayoutEnums.h"
#include "Spacing.h"
#include "support/docstring.h"
#include <string>
namespace lyx {
class Lexer;
class TextClass;
/// The different output types
enum OutputType {
///
LATEX = 1,
///
DOCBOOK,
///
LITERATE
};
/// The different margin types
enum LYX_MARGIN_TYPE {
///
MARGIN_MANUAL = 1,
///
MARGIN_FIRST_DYNAMIC,
///
MARGIN_DYNAMIC,
///
MARGIN_STATIC,
///
MARGIN_RIGHT_ADDRESS_BOX
};
///
enum LyXAlignment {
///
LYX_ALIGN_NONE = 0,
///
LYX_ALIGN_BLOCK = 1,
///
LYX_ALIGN_LEFT = 2,
///
LYX_ALIGN_RIGHT = 4,
///
LYX_ALIGN_CENTER = 8,
///
LYX_ALIGN_LAYOUT = 16,
///
LYX_ALIGN_SPECIAL = 32
};
///
inline
void operator|=(LyXAlignment & la1, LyXAlignment la2) {
la1 = static_cast<LyXAlignment>(la1 | la2);
}
///
inline
LyXAlignment operator|(LyXAlignment la1, LyXAlignment la2) {
return static_cast<LyXAlignment>(static_cast<int>(la1) | static_cast<int>(la2));
}
/// The different LaTeX-Types
enum LYX_LATEX_TYPES {
///
LATEX_PARAGRAPH = 1,
///
LATEX_COMMAND,
///
LATEX_ENVIRONMENT,
///
LATEX_ITEM_ENVIRONMENT,
///
LATEX_BIB_ENVIRONMENT,
///
LATEX_LIST_ENVIRONMENT
};
/// The different title types
enum LYX_TITLE_LATEX_TYPES {
///
TITLE_COMMAND_AFTER = 1,
///
TITLE_ENVIRONMENT
};
/// The different label types
enum LYX_LABEL_TYPES {
///
LABEL_NO_LABEL,
///
LABEL_MANUAL,
///
LABEL_BIBLIO,
///
LABEL_TOP_ENVIRONMENT,
///
LABEL_CENTERED_TOP_ENVIRONMENT,
// the flushright labels following now must start with LABEL_STATIC
///
LABEL_STATIC,
///
LABEL_SENSITIVE,
///
LABEL_COUNTER,
///
LABEL_ENUMERATE,
///
LABEL_ITEMIZE
};
///
enum LYX_END_LABEL_TYPES {
///
END_LABEL_NO_LABEL,
///
END_LABEL_BOX,
///
END_LABEL_FILLED_BOX,
///
END_LABEL_STATIC,
///
END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
///
END_LABEL_ENUM_LAST = END_LABEL_STATIC
};
/* Fix labels are printed flushright, manual labels flushleft.
* MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
* MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
@ -178,7 +48,7 @@ class Layout {
public:
///
Layout();
///
/// Reads a layout definition from file
bool read(Lexer &, TextClass const &);
///
void readAlign(Lexer &);
@ -278,11 +148,11 @@ public:
///
LyXAlignment alignpossible;
///
LYX_LABEL_TYPES labeltype;
LabelType labeltype;
///
LYX_END_LABEL_TYPES endlabeltype;
EndLabelType endlabeltype;
///
LYX_MARGIN_TYPE margintype;
MarginType margintype;
///
bool fill_top;
///
@ -320,22 +190,18 @@ public:
/// true when empty paragraphs should be kept.
bool keepempty;
///
bool isParagraph() const {
return latextype == LATEX_PARAGRAPH;
}
bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
///
bool isCommand() const {
return latextype == LATEX_COMMAND;
}
bool isCommand() const { return latextype == LATEX_COMMAND; }
///
bool isEnvironment() const {
return (latextype == LATEX_ENVIRONMENT
return latextype == LATEX_ENVIRONMENT
|| latextype == LATEX_BIB_ENVIRONMENT
|| latextype == LATEX_ITEM_ENVIRONMENT
|| latextype == LATEX_LIST_ENVIRONMENT);
|| latextype == LATEX_LIST_ENVIRONMENT;
}
/// Type of LaTeX object
LYX_LATEX_TYPES latextype;
LatexType latextype;
/// Does this object belong in the title part of the document?
bool intitle;
/// Does this layout allow for an optional parameter?

150
src/LayoutEnums.h Normal file
View File

@ -0,0 +1,150 @@
// -*- C++ -*-
/**
* \file Layout.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef LAYOUTENUMS_H
#define LAYOUTENUMS_H
// Do not include anything here
namespace lyx {
/// The different output types
enum OutputType {
///
LATEX = 1,
///
DOCBOOK,
///
LITERATE
};
/// The different margin types
enum MarginType {
///
MARGIN_MANUAL = 1,
///
MARGIN_FIRST_DYNAMIC,
///
MARGIN_DYNAMIC,
///
MARGIN_STATIC,
///
MARGIN_RIGHT_ADDRESS_BOX
};
///
enum LyXAlignment {
///
LYX_ALIGN_NONE = 0,
///
LYX_ALIGN_BLOCK = 1,
///
LYX_ALIGN_LEFT = 2,
///
LYX_ALIGN_RIGHT = 4,
///
LYX_ALIGN_CENTER = 8,
///
LYX_ALIGN_LAYOUT = 16,
///
LYX_ALIGN_SPECIAL = 32
};
///
inline void operator|=(LyXAlignment & la1, LyXAlignment la2)
{
la1 = static_cast<LyXAlignment>(la1 | la2);
}
///
inline LyXAlignment operator|(LyXAlignment la1, LyXAlignment la2)
{
return static_cast<LyXAlignment>(int(la1) | int(la2));
}
/// The different LaTeX-Types
enum LatexType {
///
LATEX_PARAGRAPH = 1,
///
LATEX_COMMAND,
///
LATEX_ENVIRONMENT,
///
LATEX_ITEM_ENVIRONMENT,
///
LATEX_BIB_ENVIRONMENT,
///
LATEX_LIST_ENVIRONMENT
};
/// The different title types
enum TitleLatexType {
///
TITLE_COMMAND_AFTER = 1,
///
TITLE_ENVIRONMENT
};
/// The different label types
enum LabelType {
///
LABEL_NO_LABEL,
///
LABEL_MANUAL,
///
LABEL_BIBLIO,
///
LABEL_TOP_ENVIRONMENT,
///
LABEL_CENTERED_TOP_ENVIRONMENT,
// the flushright labels following now must start with LABEL_STATIC
///
LABEL_STATIC,
///
LABEL_SENSITIVE,
///
LABEL_COUNTER,
///
LABEL_ENUMERATE,
///
LABEL_ITEMIZE
};
///
enum EndLabelType {
///
END_LABEL_NO_LABEL,
///
END_LABEL_BOX,
///
END_LABEL_FILLED_BOX,
///
END_LABEL_STATIC,
///
END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
///
END_LABEL_ENUM_LAST = END_LABEL_STATIC
};
} // namespace lyx
#endif

View File

@ -173,6 +173,7 @@ liblyxcore_la_SOURCES = \
LaTeX.h \
Layout.cpp \
Layout.h \
LayoutEnum.h \
Length.cpp \
Length.h \
lengthcommon.cpp \

View File

@ -28,6 +28,7 @@
#include "Language.h"
#include "LaTeXFeatures.h"
#include "Color.h"
#include "Layout.h"
#include "Length.h"
#include "Font.h"
#include "LyXRC.h"

View File

@ -28,6 +28,7 @@
#include "gettext.h"
#include "Language.h"
#include "LaTeXFeatures.h"
#include "Layout.h"
#include "Font.h"
#include "LyXRC.h"
#include "Row.h"

View File

@ -18,10 +18,10 @@
#define PARAGRAPH_METRICS_H
#include "Dimension.h"
#include "Paragraph.h"
#include "Row.h"
#include <map>
#include <vector>
namespace lyx {
@ -32,16 +32,21 @@ namespace lyx {
*/
typedef std::vector<Row> RowList;
class Buffer;
class BufferParams;
class Font;
class Inset;
class Paragraph;
class MetricsInfo;
class PainterInfo;
/// Helper class for Paragraph Metrics.
class ParagraphMetrics {
/// Helper class for paragraph metrics.
class ParagraphMetrics {
public:
/// Default constructor (only here for STL containers).
ParagraphMetrics(): par_(0) {};
ParagraphMetrics() : par_(0) {}
/// The only useful constructor.
ParagraphMetrics(Paragraph const & par);
explicit ParagraphMetrics(Paragraph const & par);
/// Copy operator.
ParagraphMetrics & operator=(ParagraphMetrics const &);

View File

@ -14,7 +14,7 @@
#ifndef PARAGRAPHPARAMETERS_H
#define PARAGRAPHPARAMETERS_H
#include "Layout.h"
#include "LayoutEnums.h"
#include "Length.h"
#include "Spacing.h"
@ -28,6 +28,7 @@
namespace lyx {
class BufferView;
class Layout;
class Length;
class Lexer;
class Paragraph;

View File

@ -22,7 +22,6 @@
namespace lyx {
///
class Spacing {
public:
@ -42,16 +41,11 @@ public:
///
Spacing() : space(Default), value("1.0") {}
///
Spacing(Spacing::Space sp, double val = 1.0) {
set(sp, val);
}
Spacing(Spacing::Space sp, std::string const & val) {
set(sp, val);
}
Spacing(Spacing::Space sp, double val = 1.0) { set(sp, val); }
///
bool isDefault() const {
return space == Default;
}
Spacing(Spacing::Space sp, std::string const & val) { set(sp, val); }
///
bool isDefault() const { return space == Default; }
///
std::string const getValueAsString() const;
///

View File

@ -37,6 +37,7 @@
#include "FuncRequest.h"
#include "gettext.h"
#include "Language.h"
#include "Layout.h"
#include "Lexer.h"
#include "LyXFunc.h"
#include "LyXRC.h"

View File

@ -35,6 +35,7 @@
#include "gettext.h"
#include "Intl.h"
#include "Language.h"
#include "Layout.h"
#include "LyXAction.h"
#include "LyXFunc.h"
#include "Lexer.h"

View File

@ -16,6 +16,7 @@
#include "TextClass.h"
#include "debug.h"
#include "Layout.h"
#include "Lexer.h"
#include "Counters.h"
#include "gettext.h"
@ -30,10 +31,10 @@
#include "support/os.h"
#include <boost/filesystem/operations.hpp>
namespace fs = boost::filesystem;
#include <sstream>
namespace fs = boost::filesystem;
namespace lyx {
@ -514,7 +515,7 @@ void TextClass::readTitleType(Lexer & lexrc)
return;
case TITLE_COMMAND_AFTER:
case TITLE_ENVIRONMENT:
titletype_ = static_cast<LYX_TITLE_LATEX_TYPES>(le);
titletype_ = static_cast<TitleLatexType>(le);
break;
default:
lyxerr << "Unhandled value " << le
@ -1168,7 +1169,7 @@ unsigned int TextClass::columns() const
}
LYX_TITLE_LATEX_TYPES TextClass::titletype() const
TitleLatexType TextClass::titletype() const
{
return titletype_;
}

View File

@ -11,7 +11,8 @@
#define LYXTEXTCLASS_H
#include "Color.h"
#include "Layout.h"
#include "Font.h"
#include "LayoutEnums.h"
#include "lyxlayout_ptr_fwd.h"
#include <boost/shared_ptr.hpp>
@ -24,6 +25,7 @@ namespace lyx {
namespace support { class FileName; }
class Layout;
class Lexer;
class Counters;
class FloatList;
@ -178,7 +180,7 @@ public:
docstring const & rightmargin() const;
/// The type of command used to produce a title
LYX_TITLE_LATEX_TYPES titletype() const;
TitleLatexType titletype() const;
/// The name of the title command
std::string const & titlename() const;
@ -243,7 +245,7 @@ private:
docstring rightmargin_;
/// The type of command used to produce a title
LYX_TITLE_LATEX_TYPES titletype_;
TitleLatexType titletype_;
/// The name of the title command
std::string titlename_;

View File

@ -29,6 +29,7 @@
#include "debug.h"
#include "FontIterator.h"
#include "FuncRequest.h"
#include "Layout.h"
#include "Length.h"
#include "LyXRC.h"
#include "MetricsInfo.h"

View File

@ -15,22 +15,19 @@
#define TEXT_METRICS_H
#include "Font.h"
// FIXME: We only need Point class definition, not the full
// CoordCache.
// FIXME: We only need Point class definition, not the full CoordCache.
#include "CoordCache.h"
#include "ParagraphMetrics.h"
#include "support/types.h"
#include <boost/utility.hpp>
#include <boost/tuple/tuple.hpp>
#include <map>
namespace lyx {
class BufferView;
class Cursor;
class CursorSlice;
class DocIterator;
class MetricsInfo;
class Text;
@ -40,7 +37,7 @@ class TextMetrics
{
public:
/// Default constructor (only here for STL containers).
TextMetrics(): text_(0) {}
TextMetrics() : text_(0) {}
/// The only useful constructor.
TextMetrics(BufferView *, Text *);
@ -58,11 +55,10 @@ public:
///
Dimension const & dimension() const { return dim_; }
///
Point const & origin() const { return origin_; }
/// compute text metrics.
bool metrics(MetricsInfo & mi, Dimension & dim, int min_width = 0);

View File

@ -16,11 +16,12 @@
#include "Buffer.h"
#include "BufferParams.h"
#include "debug.h"
#include "FloatList.h"
#include "FuncRequest.h"
#include "Layout.h"
#include "LyXAction.h"
#include "Paragraph.h"
#include "debug.h"
#include "insets/InsetOptArg.h"
@ -31,7 +32,10 @@ using std::string;
namespace lyx {
///////////////////////////////////////////////////////////////////////////
//
// TocItem implementation
//
///////////////////////////////////////////////////////////////////////////
TocItem::TocItem(ParConstIterator const & par_it, int d,
docstring const & s)
@ -71,7 +75,10 @@ FuncRequest TocItem::action() const
///////////////////////////////////////////////////////////////////////////
//
// TocBackend implementation
//
///////////////////////////////////////////////////////////////////////////
Toc const & TocBackend::toc(std::string const & type) const
{

View File

@ -26,6 +26,7 @@
#include "InsetIterator.h"
#include "Language.h"
#include "LaTeX.h"
#include "Layout.h"
#include "LyX.h"
#include "lyxlayout_ptr_fwd.h"
#include "TextClass.h"
@ -347,7 +348,7 @@ depth_type getDepth(DocIterator const & it)
depth_type getItemDepth(ParIterator const & it)
{
Paragraph const & par = *it;
LYX_LABEL_TYPES const labeltype = par.layout()->labeltype;
LabelType const labeltype = par.layout()->labeltype;
if (labeltype != LABEL_ENUMERATE && labeltype != LABEL_ITEMIZE)
return 0;

View File

@ -23,13 +23,14 @@
#include "BufferList.h"
#include "BufferParams.h"
#include "BufferView.h"
#include "callback.h"
#include "Cursor.h"
#include "debug.h"
#include "ErrorList.h"
#include "FuncRequest.h"
#include "gettext.h"
#include "Intl.h"
#include "callback.h"
#include "Layout.h"
#include "LyX.h"
#include "LyXFunc.h"
#include "LyXRC.h"

View File

@ -21,6 +21,7 @@
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "gettext.h"
#include "Layout.h"
#include "LyX.h"
#include "LyXFunc.h"
#include "TextClass.h"

View File

@ -14,11 +14,12 @@
#include <config.h>
#include "ControlViewSource.h"
#include "gettext.h"
#include "support/types.h"
#include "BufferView.h"
#include "Buffer.h"
#include "Cursor.h"
#include "gettext.h"
#include "Paragraph.h"
#include "TexRow.h"

View File

@ -14,6 +14,7 @@
#include "GuiDocument.h"
#include "FloatPlacement.h"
#include "Layout.h"
#include "LengthCombo.h"
#include "PanelStack.h"
#include "qt_helpers.h"

View File

@ -21,6 +21,7 @@
#include "FuncStatus.h"
#include "gettext.h"
#include "IconPalette.h"
#include "Layout.h"
#include "LyXFunc.h"
#include "ToolbarBackend.h"

View File

@ -23,6 +23,7 @@
#include "FuncStatus.h"
#include "gettext.h"
#include "Language.h"
#include "Layout.h"
#include "Color.h"
#include "LyXAction.h"
#include "Lexer.h"

View File

@ -14,6 +14,7 @@
#include "BufferParams.h"
#include "gettext.h"
#include "Layout.h"
#include "OutputParams.h"
#include "output_latex.h"
#include "TexRow.h"

View File

@ -18,7 +18,8 @@
#include "BufferParams.h"
#include "Counters.h"
#include "gettext.h"
// the following is needed just to get the layout of the enclosing
#include "Layout.h"
// FIXME: the following is needed just to get the layout of the enclosing
// paragraph. This seems a bit too much to me (JMarc)
#include "OutputParams.h"
#include "ParIterator.h"

View File

@ -16,17 +16,16 @@
#include "Buffer.h"
#include "buffer_funcs.h"
#include "BufferParams.h"
#include "OutputParams.h"
#include "Counters.h"
#include "debug.h"
#include "Layout.h"
#include "OutputParams.h"
#include "Paragraph.h"
#include "paragraph_funcs.h"
#include "ParagraphList.h"
#include "ParagraphParameters.h"
#include "sgml.h"
#include "insets/InsetCommand.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/convert.h"

View File

@ -17,6 +17,7 @@
#include "debug.h"
#include "Encoding.h"
#include "Language.h"
#include "Layout.h"
#include "LyXRC.h"
#include "OutputParams.h"
#include "Paragraph.h"
@ -170,12 +171,12 @@ TeXEnvironment(Buffer const & buf,
os << '\n';
texrow.newline();
} else if (par->params().depth() > pit->params().depth()) {
if (par->layout()->isParagraph()) {
if (par->layout()->isParagraph()) {
// Thinko!
// How to handle this? (Lgb)
//&& !suffixIs(os, "\n\n")
//) {
// Thinko!
// How to handle this? (Lgb)
//&& !suffixIs(os, "\n\n")
//) {
// There should be at least one '\n' already
// but we need there to be two for Standard
// paragraphs that are depth-increment'ed to be

View File

@ -16,6 +16,7 @@
#include "BufferParams.h"
#include "debug.h"
#include "gettext.h"
#include "Layout.h"
#include "output.h"
#include "OutputParams.h"
#include "Paragraph.h"

View File

@ -14,6 +14,7 @@
#include "BufferParams.h"
#include "debug.h"
#include "Layout.h"
#include "Text.h"
#include "Paragraph.h"
#include "ParagraphParameters.h"

View File

@ -16,6 +16,7 @@
#include "Bidi.h"
#include "Buffer.h"
#include "CoordCache.h"
#include "Color.h"
#include "Cursor.h"
#include "debug.h"
#include "BufferParams.h"
@ -23,7 +24,7 @@
#include "Encoding.h"
#include "gettext.h"
#include "Language.h"
#include "Color.h"
#include "Layout.h"
#include "LyXRC.h"
#include "Row.h"
#include "MetricsInfo.h"

View File

@ -17,6 +17,7 @@
#include "BufferParams.h"
#include "Counters.h"
#include "Text.h"
#include "Layout.h"
#include "OutputParams.h"
#include "Paragraph.h"

View File

@ -16,20 +16,21 @@
#include "Buffer.h"
#include "BufferParams.h"
#include "Cursor.h"
#include "debug.h"
#include "FuncRequest.h"
#include "Text.h"
#include "Layout.h"
#include "LyXAction.h"
#include "Paragraph.h"
#include "ParIterator.h"
#include "Cursor.h"
#include "debug.h"
#include "Text.h"
#include "Undo.h"
namespace lyx {
namespace toc {
void outline(OutlineOp mode, Cursor & cur)
void outline(OutlineOp mode, Cursor & cur)
{
Buffer & buf = cur.buffer();
pit_type & pit = cur.pit();