mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
reduction of header dependencies, part II (use new types
lyx::layout_type and lyx::textclass_type all ovcer the place) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3117 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a969abe2f6
commit
d659612225
@ -78,7 +78,10 @@ using std::endl;
|
||||
using std::make_pair;
|
||||
using std::min;
|
||||
using SigC::slot;
|
||||
|
||||
using lyx::pos_type;
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
/* the selection possible is needed, that only motion events are
|
||||
* used, where the bottom press event was on the drawing area too */
|
||||
@ -1596,10 +1599,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
break;
|
||||
|
||||
case LFUN_FILE_INSERT:
|
||||
{
|
||||
MenuInsertLyXFile(argument);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case LFUN_FILE_INSERT_ASCII_PARA:
|
||||
InsertAsciiFile(bv_, argument, true);
|
||||
@ -1616,18 +1617,16 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
|
||||
// Derive layout number from given argument (string)
|
||||
// and current buffer's textclass (number). */
|
||||
LyXTextClassList::ClassList::size_type tclass =
|
||||
buffer_->params.textclass;
|
||||
pair <bool, LyXTextClass::size_type> layout =
|
||||
textclass_type tclass = buffer_->params.textclass;
|
||||
pair <bool, layout_type> layout =
|
||||
textclasslist.NumberOfLayout(tclass, argument);
|
||||
|
||||
// If the entry is obsolete, use the new one instead.
|
||||
if (layout.first) {
|
||||
string obs = textclasslist.Style(tclass,layout.second)
|
||||
string obs = textclasslist.Style(tclass, layout.second)
|
||||
.obsoleted_by();
|
||||
if (!obs.empty())
|
||||
layout =
|
||||
textclasslist.NumberOfLayout(tclass, obs);
|
||||
layout = textclasslist.NumberOfLayout(tclass, obs);
|
||||
}
|
||||
|
||||
// see if we found the layout number:
|
||||
@ -3320,10 +3319,9 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
|
||||
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
}
|
||||
|
||||
pair<bool, LyXTextClass::size_type> lres =
|
||||
textclasslist.NumberOfLayout(buffer_->params
|
||||
.textclass, lout);
|
||||
LyXTextClass::size_type lay;
|
||||
pair<bool, layout_type> lres =
|
||||
textclasslist.NumberOfLayout(buffer_->params .textclass, lout);
|
||||
layout_type lay = 0;
|
||||
if (lres.first != false) {
|
||||
// layout found
|
||||
lay = lres.second;
|
||||
|
@ -1,3 +1,9 @@
|
||||
2001-11-28 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* all the files from the change on 2001/11/26:
|
||||
use lyx::layout_type instead of LyXTextClass::size_type
|
||||
use lyx::textclass_type instead of LyXTextClassList::size_type
|
||||
|
||||
2001-11-29 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* text.C: added support for paragraph::isFreeSpacing()
|
||||
@ -71,7 +77,8 @@
|
||||
2001-11-28 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* paragraph.C: whitespace changes
|
||||
* files form the 26th: change *::pos_type into lyx::pos_type
|
||||
* all the other files from the change on 2001/11/26:
|
||||
change *::pos_type into lyx::pos_type
|
||||
|
||||
2001-11-27 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
using std::pair;
|
||||
using lyx::pos_type;
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
extern BufferView * current_view;
|
||||
|
||||
@ -49,7 +51,7 @@ extern BufferView * current_view;
|
||||
namespace {
|
||||
|
||||
Paragraph * buf = 0;
|
||||
LyXTextClassList::size_type textclass = 0;
|
||||
textclass_type textclass = 0;
|
||||
|
||||
// for now here this should be in another Cut&Paste Class!
|
||||
// Jürgen, I moved this out of CutAndPaste since it does not operate on any
|
||||
@ -335,19 +337,17 @@ int CutAndPaste::nrOfParagraphs()
|
||||
}
|
||||
|
||||
|
||||
int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
|
||||
LyXTextClassList::size_type c2,
|
||||
Paragraph * par)
|
||||
int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
|
||||
textclass_type c2, Paragraph * par)
|
||||
{
|
||||
int ret = 0;
|
||||
if (!par || c1 == c2)
|
||||
return ret;
|
||||
|
||||
while (par) {
|
||||
string const name = textclasslist.NameOfLayout(c1,
|
||||
par->layout);
|
||||
string const name = textclasslist.NameOfLayout(c1, par->layout);
|
||||
int lay = 0;
|
||||
pair<bool, LyXTextClass::LayoutList::size_type> pp =
|
||||
pair<bool, layout_type> pp =
|
||||
textclasslist.NumberOfLayout(c2, name);
|
||||
if (pp.first) {
|
||||
lay = pp.second;
|
||||
|
@ -43,9 +43,9 @@ public:
|
||||
return value is the number of wrong conversions
|
||||
*/
|
||||
static
|
||||
int SwitchLayoutsBetweenClasses(LyXTextClassList::size_type class1,
|
||||
LyXTextClassList::size_type class2,
|
||||
Paragraph * par);
|
||||
int SwitchLayoutsBetweenClasses(lyx::textclass_type class1,
|
||||
lyx::textclass_type class2,
|
||||
Paragraph * par);
|
||||
///
|
||||
static
|
||||
bool checkPastePossible(Paragraph *);
|
||||
|
@ -30,11 +30,12 @@
|
||||
using std::endl;
|
||||
using std::set;
|
||||
|
||||
LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n)
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
LaTeXFeatures::LaTeXFeatures(BufferParams const & p, layout_type n)
|
||||
: layout(n, false), params(p)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void LaTeXFeatures::require(string const & name)
|
||||
@ -45,50 +46,56 @@ void LaTeXFeatures::require(string const & name)
|
||||
features.push_back("graphics");
|
||||
} else
|
||||
features.push_back(name);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::useLayout(std::vector<bool>::size_type const & idx)
|
||||
{
|
||||
layout[idx] = true;
|
||||
}
|
||||
|
||||
|
||||
bool LaTeXFeatures::isRequired(string const & name) const
|
||||
{
|
||||
FeaturesList::const_iterator i = std::find(features.begin(),
|
||||
features.end(),
|
||||
name);
|
||||
return i!= features.end();
|
||||
return i != features.end();
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::addExternalPreamble(string const & pream)
|
||||
{
|
||||
externalPreambles += pream;
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::useFloat(string const & name)
|
||||
{
|
||||
usedFloats.insert(name);
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::useLanguage(Language const * lang)
|
||||
{
|
||||
UsedLanguages.insert(lang);
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::includeFile(string const & key, string const & name)
|
||||
{
|
||||
IncludedFiles[key] = name;
|
||||
}
|
||||
|
||||
|
||||
bool LaTeXFeatures::hasLanguages()
|
||||
{
|
||||
return !UsedLanguages.empty();
|
||||
}
|
||||
|
||||
|
||||
string LaTeXFeatures::getLanguages() const
|
||||
{
|
||||
|
||||
ostringstream languages;
|
||||
|
||||
for (LanguageList::const_iterator cit =
|
||||
@ -100,6 +107,7 @@ string LaTeXFeatures::getLanguages() const
|
||||
return languages.str().c_str();
|
||||
}
|
||||
|
||||
|
||||
set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding)
|
||||
{
|
||||
set<string> encodings;
|
||||
@ -111,6 +119,7 @@ set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding)
|
||||
return encodings;
|
||||
}
|
||||
|
||||
|
||||
string const LaTeXFeatures::getPackages() const
|
||||
{
|
||||
ostringstream packages;
|
||||
@ -123,7 +132,7 @@ string const LaTeXFeatures::getPackages() const
|
||||
* packages which we just \usepackage{package}
|
||||
**/
|
||||
|
||||
// array-package
|
||||
// array-package
|
||||
if (isRequired("array"))
|
||||
packages << "\\usepackage{array}\n";
|
||||
|
||||
@ -282,7 +291,6 @@ string const LaTeXFeatures::getPackages() const
|
||||
packages << externalPreambles;
|
||||
|
||||
return packages.str().c_str();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -297,13 +305,11 @@ string const LaTeXFeatures::getMacros() const
|
||||
if (isRequired("lyxline"))
|
||||
macros << lyxline_def << '\n';
|
||||
|
||||
if (isRequired("noun")) {
|
||||
if (isRequired("noun"))
|
||||
macros << noun_def << '\n';
|
||||
}
|
||||
|
||||
if (isRequired("lyxarrow")) {
|
||||
if (isRequired("lyxarrow"))
|
||||
macros << lyxarrow_def << '\n';
|
||||
}
|
||||
|
||||
// quotes.
|
||||
if (isRequired("quotesinglbase"))
|
||||
@ -326,11 +332,11 @@ string const LaTeXFeatures::getMacros() const
|
||||
macros << binom_def << '\n';
|
||||
|
||||
// other
|
||||
if (isRequired("NeedLyXMinipageIndent"))
|
||||
if (isRequired("NeedLyXMinipageIndent"))
|
||||
macros << minipageindent_def;
|
||||
if (isRequired("ParagraphIndent"))
|
||||
if (isRequired("ParagraphIndent"))
|
||||
macros << paragraphindent_def;
|
||||
if (isRequired("NeedLyXFootnoteCode"))
|
||||
if (isRequired("NeedLyXFootnoteCode"))
|
||||
macros << floatingfootnote_def;
|
||||
|
||||
// floats
|
||||
@ -350,13 +356,12 @@ string const LaTeXFeatures::getMacros() const
|
||||
string const LaTeXFeatures::getTClassPreamble() const
|
||||
{
|
||||
// the text class specific preamble
|
||||
LyXTextClass const & tclass =
|
||||
textclasslist.TextClass(params.textclass);
|
||||
LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
|
||||
ostringstream tcpreamble;
|
||||
|
||||
tcpreamble << tclass.preamble();
|
||||
|
||||
for (LyXTextClass::size_type i = 0; i < tclass.numLayouts(); ++i) {
|
||||
for (layout_type i = 0; i < tclass.numLayouts(); ++i) {
|
||||
if (layout[i]) {
|
||||
tcpreamble << tclass[i].preamble();
|
||||
}
|
||||
@ -372,8 +377,7 @@ string const LaTeXFeatures::getLyXSGMLEntities() const
|
||||
ostringstream entities;
|
||||
|
||||
if (isRequired("lyxarrow")) {
|
||||
entities << "<!ENTITY lyxarrow \"->\">"
|
||||
<< '\n';
|
||||
entities << "<!ENTITY lyxarrow \"->\">" << '\n';
|
||||
}
|
||||
|
||||
return entities.str().c_str();
|
||||
|
@ -44,7 +44,7 @@ class LaTeXFeatures {
|
||||
|
||||
public:
|
||||
///
|
||||
LaTeXFeatures(BufferParams const &, LyXTextClass::size_type n) ;
|
||||
LaTeXFeatures(BufferParams const &, lyx::layout_type n) ;
|
||||
/// The packages needed by the document
|
||||
string const getPackages() const;
|
||||
/// The macros definitions needed by the document
|
||||
|
@ -37,11 +37,12 @@
|
||||
#include "BufferView.h"
|
||||
|
||||
using std::endl;
|
||||
using lyx::layout_type;
|
||||
|
||||
extern void AutoSave(BufferView *);
|
||||
extern void QuitLyX();
|
||||
|
||||
LyXTextClass::size_type current_layout = 0;
|
||||
layout_type current_layout = 0;
|
||||
|
||||
|
||||
LyXView::LyXView()
|
||||
@ -99,7 +100,7 @@ Toolbar * LyXView::getToolbar() const
|
||||
}
|
||||
|
||||
|
||||
void LyXView::setLayout(LyXTextClass::size_type layout)
|
||||
void LyXView::setLayout(layout_type layout)
|
||||
{
|
||||
toolbar->setLayout(layout);
|
||||
}
|
||||
@ -205,8 +206,7 @@ void LyXView::updateLayoutChoice()
|
||||
toolbar->updateLayoutList(false);
|
||||
}
|
||||
|
||||
LyXTextClass::size_type layout =
|
||||
bufferview->text->cursor.par()->getLayout();
|
||||
layout_type layout = bufferview->text->cursor.par()->getLayout();
|
||||
|
||||
if (layout != current_layout){
|
||||
toolbar->setLayout(layout);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "LString.h"
|
||||
#include "frontends/Timeout.h"
|
||||
#include "layout.h" // Just for LyXTextClass::size_type (sic)
|
||||
#include "support/types.h"
|
||||
|
||||
class Buffer;
|
||||
class Toolbar;
|
||||
@ -53,7 +53,7 @@ public:
|
||||
Toolbar * getToolbar() const;
|
||||
|
||||
/// sets the layout in the toolbar layout combox
|
||||
void setLayout(LyXTextClass::size_type layout);
|
||||
void setLayout(lyx::layout_type layout);
|
||||
|
||||
/// update the toolbar
|
||||
void updateToolbar();
|
||||
|
21
src/buffer.C
21
src/buffer.C
@ -124,6 +124,8 @@ using std::stack;
|
||||
using std::list;
|
||||
|
||||
using lyx::pos_type;
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
// all these externs should eventually be removed.
|
||||
extern BufferList bufferlist;
|
||||
@ -447,11 +449,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
// Do the insetert.
|
||||
insertErtContents(par, pos, font);
|
||||
#endif
|
||||
lex.eatLine();
|
||||
string const layoutname = lex.getString();
|
||||
pair<bool, LyXTextClass::LayoutList::size_type> pp
|
||||
= textclasslist.NumberOfLayout(params.textclass,
|
||||
layoutname);
|
||||
lex.eatLine();
|
||||
string const layoutname = lex.getString();
|
||||
pair<bool, layout_type> pp
|
||||
= textclasslist.NumberOfLayout(params.textclass, layoutname);
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
if (compare_no_case(layoutname, "latex") == 0) {
|
||||
@ -662,7 +663,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
params.readPreamble(lex);
|
||||
} else if (token == "\\textclass") {
|
||||
lex.eatLine();
|
||||
pair<bool, LyXTextClassList::size_type> pp =
|
||||
pair<bool, textclass_type> pp =
|
||||
textclasslist.NumberOfClass(lex.getString());
|
||||
if (pp.first) {
|
||||
params.textclass = pp.second;
|
||||
@ -2777,7 +2778,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
|
||||
{
|
||||
LyXLayout const & style = textclasslist.Style(params.textclass,
|
||||
par->getLayout());
|
||||
string::size_type char_line_count = 5; // Heuristic choice ;-)
|
||||
string::size_type char_line_count = 5; // Heuristic choice ;-)
|
||||
|
||||
// gets paragraph main font
|
||||
LyXFont font_old;
|
||||
@ -3494,16 +3495,16 @@ Buffer::Lists const Buffer::getLists() const
|
||||
Paragraph * par = paragraph;
|
||||
|
||||
#if 1
|
||||
std::pair<bool, LyXTextClassList::size_type> const tmp =
|
||||
std::pair<bool, textclass_type> const tmp =
|
||||
textclasslist.NumberOfLayout(params.textclass, "Caption");
|
||||
bool const found = tmp.first;
|
||||
LyXTextClassList::size_type const cap = tmp.second;
|
||||
textclass_type const cap = tmp.second;
|
||||
|
||||
#else
|
||||
// This is the prefered way to to this, but boost::tie can break
|
||||
// some compilers
|
||||
bool found;
|
||||
LyXTextClassList::size_type cap;
|
||||
textclass_type cap;
|
||||
boost::tie(found, cap) = textclasslist
|
||||
.NumberOfLayout(params.textclass, "Caption");
|
||||
#endif
|
||||
|
@ -29,26 +29,26 @@ using std::ostream;
|
||||
using std::endl;
|
||||
|
||||
BufferParams::BufferParams()
|
||||
// Initialize textclass to point to article. if `first' is
|
||||
// true in the returned pair, then `second' is the textclass
|
||||
// number; if it is false, second is 0. In both cases, second
|
||||
// is what we want.
|
||||
: textclass(textclasslist.NumberOfClass("article").second)
|
||||
{
|
||||
paragraph_separation = PARSEP_INDENT;
|
||||
defskip = VSpace(VSpace::MEDSKIP);
|
||||
quotes_language = InsetQuotes::EnglishQ;
|
||||
quotes_times = InsetQuotes::DoubleQ;
|
||||
fontsize = "default";
|
||||
// Initialize textclass to point to article. if `first' is
|
||||
// true in the returned pair, then `second' is the textclass
|
||||
// number; if it is false, second is 0. In both cases, second
|
||||
// is what we want.
|
||||
textclass = textclasslist.NumberOfClass("article").second;
|
||||
|
||||
/* PaperLayout */
|
||||
/* PaperLayout */
|
||||
papersize = PAPER_DEFAULT;
|
||||
papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
|
||||
paperpackage = PACKAGE_NONE;
|
||||
papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
|
||||
paperpackage = PACKAGE_NONE;
|
||||
orientation = ORIENTATION_PORTRAIT;
|
||||
use_geometry = false;
|
||||
use_amsmath = false;
|
||||
use_natbib = false;
|
||||
use_geometry = false;
|
||||
use_amsmath = false;
|
||||
use_natbib = false;
|
||||
use_numerical_citations = false;
|
||||
secnumdepth = 3;
|
||||
tocdepth = 3;
|
||||
@ -60,8 +60,8 @@ BufferParams::BufferParams()
|
||||
columns = 1;
|
||||
pagestyle = "default";
|
||||
for (int iter = 0; iter < 4; ++iter) {
|
||||
user_defined_bullets[iter] = temp_bullets[iter]
|
||||
= ITEMIZE_DEFAULTS[iter];
|
||||
user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
|
||||
temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,45 +130,45 @@ public:
|
||||
*/
|
||||
PARSEP paragraph_separation;
|
||||
///
|
||||
InsetQuotes::quote_language quotes_language;
|
||||
InsetQuotes::quote_language quotes_language;
|
||||
///
|
||||
InsetQuotes::quote_times quotes_times;
|
||||
InsetQuotes::quote_times quotes_times;
|
||||
///
|
||||
string fontsize;
|
||||
string fontsize;
|
||||
///
|
||||
LyXTextClassList::size_type textclass;
|
||||
lyx::textclass_type textclass;
|
||||
|
||||
/* this are for the PaperLayout */
|
||||
/// the general papersize (papersize2 or paperpackage
|
||||
char papersize; // add apprip. signedness
|
||||
/// the selected Geometry papersize
|
||||
char papersize2; // add approp. signedness
|
||||
/// a special paperpackage .sty-file
|
||||
char paperpackage; // add approp. signedness
|
||||
///
|
||||
char papersize; // add apprip. signedness
|
||||
/// the selected Geometry papersize
|
||||
char papersize2; // add approp. signedness
|
||||
/// a special paperpackage .sty-file
|
||||
char paperpackage; // add approp. signedness
|
||||
///
|
||||
PAPER_ORIENTATION orientation; // add approp. signedness
|
||||
///
|
||||
bool use_geometry;
|
||||
///
|
||||
string paperwidth;
|
||||
///
|
||||
string paperheight;
|
||||
///
|
||||
string leftmargin;
|
||||
///
|
||||
string topmargin;
|
||||
///
|
||||
string rightmargin;
|
||||
///
|
||||
string bottommargin;
|
||||
///
|
||||
string headheight;
|
||||
///
|
||||
string headsep;
|
||||
///
|
||||
string footskip;
|
||||
|
||||
/* some LaTeX options */
|
||||
bool use_geometry;
|
||||
///
|
||||
string paperwidth;
|
||||
///
|
||||
string paperheight;
|
||||
///
|
||||
string leftmargin;
|
||||
///
|
||||
string topmargin;
|
||||
///
|
||||
string rightmargin;
|
||||
///
|
||||
string bottommargin;
|
||||
///
|
||||
string headheight;
|
||||
///
|
||||
string headsep;
|
||||
///
|
||||
string footskip;
|
||||
|
||||
/* some LaTeX options */
|
||||
/// The graphics driver
|
||||
string graphicsDriver;
|
||||
///
|
||||
@ -206,13 +206,13 @@ public:
|
||||
///
|
||||
void readGraphicsDriver(LyXLex &);
|
||||
///
|
||||
bool use_amsmath;
|
||||
bool use_amsmath;
|
||||
///
|
||||
bool use_natbib;
|
||||
bool use_natbib;
|
||||
///
|
||||
bool use_numerical_citations;
|
||||
bool use_numerical_citations;
|
||||
/// Time ago we agreed that this was a buffer property [ale990407]
|
||||
string parentname;
|
||||
string parentname;
|
||||
private:
|
||||
///
|
||||
friend class Buffer;
|
||||
|
@ -1,3 +1,10 @@
|
||||
|
||||
2001-11-29 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* inseterror.C:
|
||||
* insettext.C: further reduction of header dependencies by using
|
||||
lyx::layout_type and lyx::textclass_type from support/types.h
|
||||
|
||||
2001-11-29 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.C: inserted a reinitLyXText function everywhere I delete
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "font.h"
|
||||
#include "lyxfont.h"
|
||||
#include "gettext.h"
|
||||
#include "inseterror.h"
|
||||
#include "LyXView.h"
|
||||
|
@ -62,6 +62,8 @@ using std::make_pair;
|
||||
using std::vector;
|
||||
|
||||
using lyx::pos_type;
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
extern unsigned char getCurrentTextClass(Buffer *);
|
||||
extern bool math_insert_greek(BufferView *, char);
|
||||
@ -1239,13 +1241,12 @@ InsetText::localDispatch(BufferView * bv,
|
||||
case LFUN_LAYOUT:
|
||||
// do not set layouts on non breakable textinsets
|
||||
if (autoBreakRows) {
|
||||
LyXTextClass::size_type cur_layout = cpar(bv)->layout;
|
||||
layout_type cur_layout = cpar(bv)->layout;
|
||||
|
||||
// Derive layout number from given argument (string)
|
||||
// and current buffer's textclass (number). */
|
||||
LyXTextClassList::ClassList::size_type tclass =
|
||||
bv->buffer()->params.textclass;
|
||||
std::pair <bool, LyXTextClass::size_type> layout =
|
||||
textclass_type tclass = bv->buffer()->params.textclass;
|
||||
std::pair <bool, layout_type> layout =
|
||||
textclasslist.NumberOfLayout(tclass, arg);
|
||||
|
||||
// If the entry is obsolete, use the new one instead.
|
||||
|
37
src/layout.C
37
src/layout.C
@ -34,6 +34,10 @@ using std::endl;
|
||||
using std::find_if;
|
||||
using std::remove_if;
|
||||
|
||||
using lyx::layout_type;
|
||||
using lyx::textclass_type;
|
||||
|
||||
|
||||
// Global variable: textclass table.
|
||||
LyXTextClassList textclasslist;
|
||||
|
||||
@ -1233,22 +1237,22 @@ void LyXTextClass::load()
|
||||
//////////////////////////////////////////
|
||||
|
||||
// Gets textclass number from name
|
||||
pair<bool, LyXTextClassList::size_type> const
|
||||
pair<bool, textclass_type> const
|
||||
LyXTextClassList::NumberOfClass(string const & textclass) const
|
||||
{
|
||||
ClassList::const_iterator cit =
|
||||
find_if(classlist.begin(), classlist.end(),
|
||||
lyx::compare_memfun(&LyXTextClass::name, textclass));
|
||||
return cit != classlist.end() ?
|
||||
make_pair(true, size_type(cit - classlist.begin())) :
|
||||
make_pair(false, size_type(0));
|
||||
make_pair(true, textclass_type(cit - classlist.begin())) :
|
||||
make_pair(false, textclass_type(0));
|
||||
}
|
||||
|
||||
|
||||
// Gets layout structure from style number and textclass number
|
||||
LyXLayout const &
|
||||
LyXTextClassList::Style(LyXTextClassList::size_type textclass,
|
||||
LyXTextClass::size_type layout) const
|
||||
LyXTextClassList::Style(textclass_type textclass,
|
||||
layout_type layout) const
|
||||
{
|
||||
classlist[textclass].load();
|
||||
if (layout < classlist[textclass].numLayouts())
|
||||
@ -1258,8 +1262,8 @@ LyXTextClassList::Style(LyXTextClassList::size_type textclass,
|
||||
|
||||
|
||||
// Gets layout number from name and textclass number
|
||||
pair<bool, LyXTextClass::size_type> const
|
||||
LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass,
|
||||
pair<bool, layout_type> const
|
||||
LyXTextClassList::NumberOfLayout(textclass_type textclass,
|
||||
string const & name) const
|
||||
{
|
||||
classlist[textclass].load();
|
||||
@ -1268,15 +1272,15 @@ LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass,
|
||||
return make_pair(true, i);
|
||||
}
|
||||
if (name == "dummy")
|
||||
return make_pair(true, LyXTextClassList::size_type(LYX_DUMMY_LAYOUT));
|
||||
return make_pair(false, LyXTextClass::size_type(0)); // not found
|
||||
return make_pair(true, layout_type(LYX_DUMMY_LAYOUT));
|
||||
return make_pair(false, layout_type(0)); // not found
|
||||
}
|
||||
|
||||
|
||||
// Gets a layout (style) name from layout number and textclass number
|
||||
string const &
|
||||
LyXTextClassList::NameOfLayout(LyXTextClassList::size_type textclass,
|
||||
LyXTextClass::size_type layout) const
|
||||
LyXTextClassList::NameOfLayout(textclass_type textclass,
|
||||
layout_type layout) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
classlist[textclass].load();
|
||||
@ -1288,7 +1292,7 @@ LyXTextClassList::NameOfLayout(LyXTextClassList::size_type textclass,
|
||||
|
||||
// Gets a textclass name from number
|
||||
string const &
|
||||
LyXTextClassList::NameOfClass(LyXTextClassList::size_type number) const
|
||||
LyXTextClassList::NameOfClass(textclass_type number) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
if (classlist.empty()) {
|
||||
@ -1301,7 +1305,7 @@ LyXTextClassList::NameOfClass(LyXTextClassList::size_type number) const
|
||||
|
||||
// Gets a textclass latexname from number
|
||||
string const &
|
||||
LyXTextClassList::LatexnameOfClass(LyXTextClassList::size_type number) const
|
||||
LyXTextClassList::LatexnameOfClass(textclass_type number) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
classlist[number].load();
|
||||
@ -1315,7 +1319,7 @@ LyXTextClassList::LatexnameOfClass(LyXTextClassList::size_type number) const
|
||||
|
||||
// Gets a textclass description from number
|
||||
string const &
|
||||
LyXTextClassList::DescOfClass(LyXTextClassList::size_type number) const
|
||||
LyXTextClassList::DescOfClass(textclass_type number) const
|
||||
{
|
||||
static string const dummy("dummy");
|
||||
if (classlist.empty()) {
|
||||
@ -1328,7 +1332,7 @@ LyXTextClassList::DescOfClass(LyXTextClassList::size_type number) const
|
||||
|
||||
// Gets a textclass structure from number
|
||||
LyXTextClass const &
|
||||
LyXTextClassList::TextClass(LyXTextClassList::size_type textclass) const
|
||||
LyXTextClassList::TextClass(textclass_type textclass) const
|
||||
{
|
||||
classlist[textclass].load();
|
||||
if (textclass < classlist.size())
|
||||
@ -1444,8 +1448,7 @@ bool LyXTextClassList::Read ()
|
||||
/* Load textclass
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool
|
||||
LyXTextClassList::Load (LyXTextClassList::size_type number) const
|
||||
bool LyXTextClassList::Load(textclass_type number) const
|
||||
{
|
||||
bool result = true;
|
||||
if (number < classlist.size()) {
|
||||
|
36
src/layout.h
36
src/layout.h
@ -18,11 +18,13 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
class LyXLeX;
|
||||
#include "lyxfont.h"
|
||||
#include "Spacing.h"
|
||||
#include "support/types.h"
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
class LyXLeX;
|
||||
|
||||
/// Reads the style files
|
||||
extern void LyXSetStyle();
|
||||
|
||||
@ -386,8 +388,6 @@ public:
|
||||
///
|
||||
typedef LayoutList::const_iterator const_iterator;
|
||||
///
|
||||
typedef LayoutList::size_type size_type;
|
||||
///
|
||||
explicit
|
||||
LyXTextClass (string const & = string(),
|
||||
string const & = string(),
|
||||
@ -479,9 +479,9 @@ public:
|
||||
///
|
||||
int maxcounter() const { return maxcounter_; }
|
||||
///
|
||||
size_type numLayouts() const { return layoutlist.size(); }
|
||||
lyx::layout_type numLayouts() const { return layoutlist.size(); }
|
||||
///
|
||||
LyXLayout const & operator[](size_type i) const {
|
||||
LyXLayout const & operator[](lyx::layout_type i) const {
|
||||
return layoutlist[i];
|
||||
}
|
||||
private:
|
||||
@ -558,43 +558,39 @@ public:
|
||||
///
|
||||
typedef ClassList::const_iterator const_iterator;
|
||||
///
|
||||
typedef ClassList::size_type size_type;
|
||||
///
|
||||
const_iterator begin() const { return classlist.begin(); }
|
||||
///
|
||||
const_iterator end() const { return classlist.end(); }
|
||||
|
||||
/// Gets layout structure from layout number and textclass number
|
||||
LyXLayout const & Style(size_type textclass,
|
||||
LyXTextClass::size_type layout) const;
|
||||
LyXLayout const & Style(lyx::textclass_type textclass,
|
||||
lyx::layout_type layout) const;
|
||||
|
||||
/// Gets layout number from textclass number and layout name
|
||||
std::pair<bool, LyXTextClass::size_type> const
|
||||
NumberOfLayout(size_type textclass,
|
||||
string const & name) const;
|
||||
std::pair<bool, lyx::layout_type> const
|
||||
NumberOfLayout(lyx::textclass_type textclass, string const & name) const;
|
||||
|
||||
/// Gets a layout name from layout number and textclass number
|
||||
string const &
|
||||
NameOfLayout(size_type textclass,
|
||||
LyXTextClass::size_type layout) const;
|
||||
NameOfLayout(lyx::textclass_type textclass, lyx::layout_type layout) const;
|
||||
|
||||
/** Gets textclass number from name.
|
||||
Returns -1 if textclass name does not exist
|
||||
*/
|
||||
std::pair<bool, size_type> const
|
||||
std::pair<bool, lyx::textclass_type> const
|
||||
NumberOfClass(string const & textclass) const;
|
||||
|
||||
///
|
||||
string const & NameOfClass(size_type number) const;
|
||||
string const & NameOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
string const & LatexnameOfClass(size_type number) const;
|
||||
string const & LatexnameOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
string const & DescOfClass(size_type number) const;
|
||||
string const & DescOfClass(lyx::textclass_type number) const;
|
||||
|
||||
///
|
||||
LyXTextClass const & TextClass(size_type textclass) const;
|
||||
LyXTextClass const & TextClass(lyx::textclass_type textclass) const;
|
||||
|
||||
/** Read textclass list.
|
||||
Returns false if this fails
|
||||
@ -604,7 +600,7 @@ public:
|
||||
/** Load textclass.
|
||||
Returns false if this fails
|
||||
*/
|
||||
bool Load(size_type number) const;
|
||||
bool Load(lyx::textclass_type number) const;
|
||||
private:
|
||||
///
|
||||
mutable ClassList classlist;
|
||||
|
@ -117,8 +117,6 @@ extern LyXAction lyxaction;
|
||||
// (alkis)
|
||||
extern tex_accent_struct get_accent(kb_action action);
|
||||
|
||||
extern LyXTextClass::size_type current_layout;
|
||||
|
||||
extern void ShowLatexLog();
|
||||
|
||||
|
||||
|
@ -255,10 +255,12 @@ void MathGridInset::metrics(MathMetricsInfo const & mi) const
|
||||
break;
|
||||
default:
|
||||
h = rowinfo_[nrows()].offset_ / 2;
|
||||
//lyxerr << "\nnrows: " << nrows() << ' ' << ncols() << '\n';
|
||||
}
|
||||
for (row_type row = 0; row <= nrows(); ++row)
|
||||
//lyxerr << "\nnrows: " << nrows() << " h: " << h << '\n';
|
||||
for (row_type row = 0; row <= nrows(); ++row) {
|
||||
rowinfo_[row].offset_ -= h;
|
||||
//lyxerr << "row: " << row << " off: " << rowinfo_[row].offset_ << '\n';
|
||||
}
|
||||
|
||||
|
||||
// adjust horizontal structure
|
||||
|
@ -76,9 +76,10 @@ extern BufferView * current_view;
|
||||
|
||||
|
||||
Paragraph::Paragraph()
|
||||
: pimpl_(new Paragraph::Pimpl(this))
|
||||
: layout(0), pimpl_(new Paragraph::Pimpl(this))
|
||||
{
|
||||
for (int i = 0; i < 10; ++i) setCounter(i , 0);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
setCounter(i, 0);
|
||||
next_ = 0;
|
||||
previous_ = 0;
|
||||
enumdepth = 0;
|
||||
@ -88,9 +89,9 @@ Paragraph::Paragraph()
|
||||
}
|
||||
|
||||
|
||||
// This konstruktor inserts the new paragraph in a list.
|
||||
// This construktor inserts the new paragraph in a list.
|
||||
Paragraph::Paragraph(Paragraph * par)
|
||||
: pimpl_(new Paragraph::Pimpl(this))
|
||||
: layout(0), pimpl_(new Paragraph::Pimpl(this))
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
setCounter(i, 0);
|
||||
@ -112,7 +113,7 @@ Paragraph::Paragraph(Paragraph * par)
|
||||
|
||||
|
||||
Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
|
||||
: pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
|
||||
: layout(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
setCounter(i, 0);
|
||||
@ -926,7 +927,7 @@ void Paragraph::makeSameLayout(Paragraph const * par)
|
||||
}
|
||||
|
||||
|
||||
int Paragraph::stripLeadingSpaces(LyXTextClassList::size_type tclass)
|
||||
int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
|
||||
{
|
||||
if (textclasslist.Style(tclass, getLayout()).free_spacing ||
|
||||
isFreeSpacing())
|
||||
@ -935,8 +936,7 @@ int Paragraph::stripLeadingSpaces(LyXTextClassList::size_type tclass)
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (size()
|
||||
&& (isNewline(0) || isLineSeparator(0))){
|
||||
while (size() && (isNewline(0) || isLineSeparator(0))) {
|
||||
erase(0);
|
||||
++i;
|
||||
}
|
||||
|
@ -19,13 +19,13 @@
|
||||
#include "LString.h"
|
||||
|
||||
#include "insets/inset.h" // Just for Inset::Code
|
||||
#include "layout.h"
|
||||
#include "lyxfont.h" // Just for LyXFont::FONT_SIZE
|
||||
#include "support/types.h"
|
||||
|
||||
class ParagraphParameters;
|
||||
class BufferParams;
|
||||
class TexRow;
|
||||
struct LaTeXFeatures;
|
||||
class LaTeXFeatures;
|
||||
class InsetBibKey;
|
||||
class BufferView;
|
||||
class Language;
|
||||
@ -321,7 +321,7 @@ public:
|
||||
Paragraph * getParFromID(int id) const;
|
||||
|
||||
///
|
||||
int stripLeadingSpaces(LyXTextClassList::size_type tclass);
|
||||
int stripLeadingSpaces(lyx::textclass_type tclass);
|
||||
|
||||
#ifndef NO_PEXTRA_REALLY
|
||||
/* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
|
||||
|
@ -1,10 +1,15 @@
|
||||
|
||||
2001-11-29 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* types.h: introduce types for textclass numbers and layout numbers
|
||||
|
||||
2001-11-28 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* Makefile.am: put types.h in
|
||||
|
||||
2001-11-26 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* types.h: introduce type for paragraph positions and layout numbers
|
||||
* types.h: introduce types for paragraph positions and layout numbers
|
||||
|
||||
2001-11-04 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
|
@ -11,17 +11,75 @@
|
||||
|
||||
namespace lyx
|
||||
{
|
||||
/// a type for sizes
|
||||
typedef std::vector<char>::size_type size_type;
|
||||
|
||||
/// a type for positions used in paragraphs
|
||||
// needs to be signed for a while to hold the special value -1 that is
|
||||
// used there...
|
||||
typedef std::vector<char>::difference_type pos_type;
|
||||
|
||||
/// a type used for numbering layouts
|
||||
|
||||
// set this to '0' if you want to have really safe types
|
||||
#if 1
|
||||
|
||||
/// a type for sizes
|
||||
typedef std::vector<char>::size_type size_type;
|
||||
|
||||
/// a type used for numbering layouts within a text class
|
||||
// used to be LyXTextClass::size_type
|
||||
typedef std::vector<char>::size_type layout_type;
|
||||
|
||||
/// a type used for numbering text classes
|
||||
// used to be LyXTextClassList::size_type
|
||||
typedef std::vector<char>::size_type textclass_type;
|
||||
|
||||
#else
|
||||
|
||||
// These structs wrap simple things to make them distinguishible
|
||||
// to the compiler.
|
||||
// It's a shame that different typedefs are not "really" different
|
||||
|
||||
struct size_type {
|
||||
///
|
||||
typedef std::vector<char>::size_type base_type;
|
||||
///
|
||||
size_type(base_type t) { data_ = t; }
|
||||
///
|
||||
operator base_type() const { return data_; }
|
||||
///
|
||||
private:
|
||||
base_type data_;
|
||||
};
|
||||
|
||||
|
||||
struct layout_type {
|
||||
///
|
||||
typedef std::vector<char>::size_type base_type;
|
||||
///
|
||||
layout_type(base_type t) { data_ = t; }
|
||||
///
|
||||
operator base_type() const { return data_; }
|
||||
///
|
||||
void operator++() { ++data_; }
|
||||
///
|
||||
private:
|
||||
base_type data_;
|
||||
};
|
||||
|
||||
|
||||
struct textclass_type {
|
||||
///
|
||||
typedef std::vector<char>::size_type base_type;
|
||||
///
|
||||
textclass_type(base_type t) { data_ = t; }
|
||||
///
|
||||
operator base_type() const { return data_; }
|
||||
///
|
||||
private:
|
||||
base_type data_;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "lyxlex.h"
|
||||
#include "layout.h"
|
||||
#include "LString.h"
|
||||
#include "insets/insettext.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user