From d659612225b93787899a9e5f1c622ba93d181651 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 29 Nov 2001 17:12:21 +0000 Subject: [PATCH] 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 --- src/BufferView_pimpl.C | 24 ++++++------- src/ChangeLog | 9 ++++- src/CutAndPaste.C | 14 ++++---- src/CutAndPaste.h | 6 ++-- src/LaTeXFeatures.C | 46 +++++++++++++----------- src/LaTeXFeatures.h | 2 +- src/LyXView.C | 8 ++--- src/LyXView.h | 4 +-- src/buffer.C | 21 +++++------ src/bufferparams.C | 26 +++++++------- src/bufferparams.h | 70 ++++++++++++++++++------------------- src/insets/ChangeLog | 7 ++++ src/insets/inseterror.C | 1 + src/insets/insettext.C | 9 ++--- src/layout.C | 37 +++++++++++--------- src/layout.h | 36 +++++++++---------- src/lyxfunc.C | 2 -- src/mathed/math_gridinset.C | 6 ++-- src/paragraph.C | 16 ++++----- src/paragraph.h | 6 ++-- src/support/ChangeLog | 7 +++- src/support/types.h | 66 +++++++++++++++++++++++++++++++--- src/tabular.h | 1 + 23 files changed, 253 insertions(+), 171 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index b7d44616bd..628522e855 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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 layout = + textclass_type tclass = buffer_->params.textclass; + pair 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 lres = - textclasslist.NumberOfLayout(buffer_->params - .textclass, lout); - LyXTextClass::size_type lay; + pair lres = + textclasslist.NumberOfLayout(buffer_->params .textclass, lout); + layout_type lay = 0; if (lres.first != false) { // layout found lay = lres.second; diff --git a/src/ChangeLog b/src/ChangeLog index 1c8fc58a78..5d0d4cacf3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-11-28 André Pönitz + + * 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 * text.C: added support for paragraph::isFreeSpacing() @@ -71,7 +77,8 @@ 2001-11-28 André Pönitz * 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 diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 80c62c28f2..ffae84eb45 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -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 pp = + pair pp = textclasslist.NumberOfLayout(c2, name); if (pp.first) { lay = pp.second; diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index 13ff9ed33d..0eaceb16ed 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -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 *); diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index f208c53590..7feac98724 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -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::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 LaTeXFeatures::getEncodingSet(string const & doc_encoding) { set encodings; @@ -111,6 +119,7 @@ set 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 << "" - << '\n'; + entities << "" << '\n'; } return entities.str().c_str(); diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index bf49291929..c9b628dacd 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -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 diff --git a/src/LyXView.C b/src/LyXView.C index c5e3c53030..36804ac4c6 100644 --- a/src/LyXView.C +++ b/src/LyXView.C @@ -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); diff --git a/src/LyXView.h b/src/LyXView.h index 40f44074ad..2a570d958d 100644 --- a/src/LyXView.h +++ b/src/LyXView.h @@ -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(); diff --git a/src/buffer.C b/src/buffer.C index a253c87229..a89d1e3160 100644 --- a/src/buffer.C +++ b/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 pp - = textclasslist.NumberOfLayout(params.textclass, - layoutname); + lex.eatLine(); + string const layoutname = lex.getString(); + pair 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 pp = + pair 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 const tmp = + std::pair 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 diff --git a/src/bufferparams.C b/src/bufferparams.C index 9143c03fc3..0a6466b158 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -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]; } } diff --git a/src/bufferparams.h b/src/bufferparams.h index aeed3a1572..7bc93df13e 100644 --- a/src/bufferparams.h +++ b/src/bufferparams.h @@ -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; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f83fa34f21..d697ee9208 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ + +2001-11-29 André Pönitz + + * 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 * insettext.C: inserted a reinitLyXText function everywhere I delete diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 20810a11ae..611558bcb4 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -16,6 +16,7 @@ #include "BufferView.h" #include "font.h" +#include "lyxfont.h" #include "gettext.h" #include "inseterror.h" #include "LyXView.h" diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 73c43939e2..d313c0daa2 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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 layout = + textclass_type tclass = bv->buffer()->params.textclass; + std::pair layout = textclasslist.NumberOfLayout(tclass, arg); // If the entry is obsolete, use the new one instead. diff --git a/src/layout.C b/src/layout.C index ba04bcb15d..f3cd8aee4d 100644 --- a/src/layout.C +++ b/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 const +pair 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 const -LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass, +pair 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()) { diff --git a/src/layout.h b/src/layout.h index 1aa6c6ddd7..51f4af3bcb 100644 --- a/src/layout.h +++ b/src/layout.h @@ -18,11 +18,13 @@ #pragma interface #endif -class LyXLeX; #include "lyxfont.h" #include "Spacing.h" +#include "support/types.h" #include +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 const - NumberOfLayout(size_type textclass, - string const & name) const; + std::pair 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 const + std::pair 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; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index b9330f0201..a8683531be 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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(); diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 8ca134842e..f2d3ba939b 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -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 diff --git a/src/paragraph.C b/src/paragraph.C index 76311c2558..2a414c3134 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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; } diff --git a/src/paragraph.h b/src/paragraph.h index 3662fee3e5..a12c269dfa 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -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 diff --git a/src/support/ChangeLog b/src/support/ChangeLog index e075f904e8..27c41bcbcf 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,10 +1,15 @@ + +2001-11-29 André Pönitz + + * types.h: introduce types for textclass numbers and layout numbers + 2001-11-28 André Pönitz * Makefile.am: put types.h in 2001-11-26 André Pönitz - * 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 diff --git a/src/support/types.h b/src/support/types.h index 2b3413fdeb..c3c08913eb 100644 --- a/src/support/types.h +++ b/src/support/types.h @@ -11,17 +11,75 @@ namespace lyx { - /// a type for sizes - typedef std::vector::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::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::size_type size_type; + + /// a type used for numbering layouts within a text class + // used to be LyXTextClass::size_type typedef std::vector::size_type layout_type; + /// a type used for numbering text classes + // used to be LyXTextClassList::size_type + typedef std::vector::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::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::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::size_type base_type; + /// + textclass_type(base_type t) { data_ = t; } + /// + operator base_type() const { return data_; } + /// + private: + base_type data_; + }; + + +#endif + } #endif diff --git a/src/tabular.h b/src/tabular.h index b434ab4a95..e660ba2f57 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -20,6 +20,7 @@ #include #include "lyxlex.h" +#include "layout.h" #include "LString.h" #include "insets/insettext.h" -- 2.39.5