From 03d1c984a0b22ec123cb86ba9004d9172a4190fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 6 Mar 2001 14:07:14 +0000 Subject: [PATCH] ParagraphParameters and SharedContainer git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1691 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 54 +-- src/ChangeLog | 35 ++ src/Makefile.am | 4 + src/ParagraphParameters.C | 380 +++++++++++++++++ src/ParagraphParameters.h | 113 +++++ src/ParameterStruct.h | 81 ++++ src/ShareContainer.h | 73 ++++ src/Spacing.h | 7 + src/buffer.C | 83 ++-- src/bufferview_funcs.C | 6 +- src/frontends/xforms/ChangeLog | 4 + src/frontends/xforms/FormParagraph.C | 64 +-- src/insets/ChangeLog | 4 + src/insets/insettext.C | 6 +- src/lyxfont.C | 291 +++++++++++-- src/lyxfont.h | 282 +------------ src/lyxparagraph.h | 83 +--- src/paragraph.C | 599 ++++++++++++--------------- src/text.C | 123 +++--- src/text2.C | 108 ++--- 20 files changed, 1476 insertions(+), 924 deletions(-) create mode 100644 src/ParagraphParameters.C create mode 100644 src/ParagraphParameters.h create mode 100644 src/ParameterStruct.h create mode 100644 src/ShareContainer.h diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 48c36c73c7..09ef7f22d3 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -2215,18 +2215,18 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) TEXT(bv_)->CursorRight(bv_); cursor = TEXT(bv_)->cursor; if (cursor.pos() == 0 - && !(cursor.par()->added_space_top + && !(cursor.par()->params.spaceTop() == VSpace (VSpace::NONE))) { TEXT(bv_)->SetParagraph (bv_, - cursor.par()->line_top, - cursor.par()->line_bottom, - cursor.par()->pagebreak_top, - cursor.par()->pagebreak_bottom, + cursor.par()->params.lineTop(), + cursor.par()->params.lineBottom(), + cursor.par()->params.pagebreakTop(), + cursor.par()->params.pagebreakBottom(), VSpace(VSpace::NONE), - cursor.par()->added_space_bottom, - cursor.par()->align, - cursor.par()->labelwidthstring, 0); + cursor.par()->params.spaceBottom(), + cursor.par()->params.align(), + cursor.par()->params.labelWidthString(), 0); TEXT(bv_)->CursorLeft(bv_); update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); @@ -2323,17 +2323,17 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (!TEXT(bv_)->selection) { if (cursor.pos() == 0 - && !(cursor.par()->added_space_top + && !(cursor.par()->params.spaceTop() == VSpace (VSpace::NONE))) { TEXT(bv_)->SetParagraph (bv_, - cursor.par()->line_top, - cursor.par()->line_bottom, - cursor.par()->pagebreak_top, - cursor.par()->pagebreak_bottom, - VSpace(VSpace::NONE), cursor.par()->added_space_bottom, - cursor.par()->align, - cursor.par()->labelwidthstring, 0); + cursor.par()->params.lineTop(), + cursor.par()->params.lineBottom(), + cursor.par()->params.pagebreakTop(), + cursor.par()->params.pagebreakBottom(), + VSpace(VSpace::NONE), cursor.par()->params.spaceBottom(), + cursor.par()->params.align(), + cursor.par()->params.labelWidthString(), 0); update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } else { @@ -2382,16 +2382,16 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) beforeChange(TEXT(bv_)); if (cursor.pos() == 0) { - if (cursor.par()->added_space_top == VSpace(VSpace::NONE)) { + if (cursor.par()->params.spaceTop() == VSpace(VSpace::NONE)) { TEXT(bv_)->SetParagraph (bv_, - cursor.par()->line_top, - cursor.par()->line_bottom, - cursor.par()->pagebreak_top, - cursor.par()->pagebreak_bottom, - VSpace(VSpace::DEFSKIP), cursor.par()->added_space_bottom, - cursor.par()->align, - cursor.par()->labelwidthstring, 1); + cursor.par()->params.lineTop(), + cursor.par()->params.lineBottom(), + cursor.par()->params.pagebreakTop(), + cursor.par()->params.pagebreakBottom(), + VSpace(VSpace::DEFSKIP), cursor.par()->params.spaceBottom(), + cursor.par()->params.align(), + cursor.par()->params.labelWidthString(), 1); //update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } @@ -2411,10 +2411,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_PARAGRAPH_SPACING: { LyXParagraph * par = TEXT(bv_)->cursor.par(); - Spacing::Space cur_spacing = par->spacing.getSpace(); + Spacing::Space cur_spacing = par->params.spacing().getSpace(); float cur_value = 1.0; if (cur_spacing == Spacing::Other) { - cur_value = par->spacing.getValue(); + cur_value = par->params.spacing().getValue(); } istringstream istr(argument.c_str()); @@ -2446,7 +2446,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) << argument << endl; } if (cur_spacing != new_spacing || cur_value != new_value) { - par->spacing.set(new_spacing, new_value); + par->params.spacing(Spacing(new_spacing, new_value)); TEXT(bv_)->RedoParagraph(bv_); update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); diff --git a/src/ChangeLog b/src/ChangeLog index eb0a1ff721..4085ef2491 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,38 @@ +2001-03-06 Lars Gullik Bjønnes + + * lyxparagraph.h: move serveral local vars to + ParameterStruct/ParagraphParameters., use ShareContainer in + FontTable., make vars in FontTable private and add getter and + setter. + + * paragraph.C: changes because of the above. + + * lyxfont.h: remove copy constructor and copy assignment. (the + default ones is ok), move number inside FontBits. move inlines to lyxfont.C + + * lyxfont.C: add number to initializaton of statics, move several + inlines here. constify several local vars. some whitespace + cleanup. Dont hide outerscope variables. + + * Spacing.h: add two new constructors to match the set methods. + + * ShareContainer.h: new file, will perhaps be moved to support + + * ParameterStruct.h: new file + + * ParagraphParameters.h: new file + + * ParagraphParameters.C: new file + + * Makefile.am (lyx_SOURCES): add ParagraphParameters.C, + ParagraphParameters.h, ParameterStruct.h and ShareContainer.h + + * BufferView_pimpl.C: ParagraphParameter changes. + * buffer.C: Likewise. + * bufferview_funcs.C: Likewise. + * text.C: Likewise. + * text2.C: Likewise. + 2001-03-06 Jean-Marc Lasgouttes * lyxfind.C (LyXReplace): do not redefine default argument in diff --git a/src/Makefile.am b/src/Makefile.am index 72c92a32a6..e35a6bf740 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,9 +65,13 @@ lyx_SOURCES = \ Painter.h \ PainterBase.C \ PainterBase.h \ + ParagraphParameters.C \ + ParagraphParameters.h \ + ParameterStruct.h \ PrinterParams.h \ Sectioning.h \ Sectioning.C \ + ShareContainer.h \ Spacing.C \ Spacing.h \ TextCache.C \ diff --git a/src/ParagraphParameters.C b/src/ParagraphParameters.C new file mode 100644 index 0000000000..d5a37e6875 --- /dev/null +++ b/src/ParagraphParameters.C @@ -0,0 +1,380 @@ + +#include + +#include "ParagraphParameters.h" +#include "ParameterStruct.h" + +// Initialize static member var. +ShareContainer ParagraphParameters::container; + +ParagraphParameters::ParagraphParameters() +{ + ParameterStruct tmp; + tmp.appendix = false; + tmp.align = LYX_ALIGN_BLOCK; + + set_from_struct(tmp); +} + + +void ParagraphParameters::clear() +{ + ParameterStruct tmp(*param); + tmp.line_top = false; + tmp.line_bottom = false; + tmp.pagebreak_top = false; + tmp.pagebreak_bottom = false; + tmp.added_space_top = VSpace(VSpace::NONE); + tmp.added_space_bottom = VSpace(VSpace::NONE); + tmp.spacing.set(Spacing::Default); + tmp.align = LYX_ALIGN_LAYOUT; + tmp.depth = 0; + tmp.noindent = false; + tmp.labelstring.erase(); + tmp.labelwidthstring.erase(); + tmp.start_of_appendix = false; + //tmp.pextra_type = PEXTRA_NONE; + tmp.pextra_type = 0; + tmp.pextra_width.erase(); + tmp.pextra_widthp.erase(); + //tmp.pextra_alignment = MINIPAGE_ALIGN_TOP; + tmp.pextra_alignment = 0; + tmp.pextra_hfill = false; + tmp.pextra_start_minipage = false; + + set_from_struct(tmp); +} + + +bool ParagraphParameters::sameLayout(ParagraphParameters const & pp) const +{ + return param->align == pp.param->align && + param->line_bottom == pp.param->line_bottom && + param->pagebreak_bottom == pp.param->pagebreak_bottom && + param->added_space_bottom == pp.param->added_space_bottom && + + param->line_top == pp.param->line_top && + param->pagebreak_top == pp.param->pagebreak_top && + param->added_space_top == pp.param->added_space_top && + param->spacing == pp.param->spacing && + param->pextra_type == pp.param->pextra_type && + param->pextra_width == pp.param->pextra_width && + param->pextra_widthp == pp.param->pextra_widthp && + param->pextra_alignment == pp.param->pextra_alignment && + param->pextra_hfill == pp.param->pextra_hfill && + param->pextra_start_minipage == pp.param->pextra_start_minipage && + param->noindent == pp.param->noindent && + param->depth == pp.param->depth; +} + + +void ParagraphParameters::makeSame(ParagraphParameters const & pp) +{ + ParameterStruct tmp(*param); + tmp.align = pp.param->align; + // tmp.labelwidthstring = pp.params.labelwidthstring; + tmp.line_bottom = pp.param->line_bottom; + tmp.pagebreak_bottom = pp.param->pagebreak_bottom; + tmp.added_space_bottom = pp.param->added_space_bottom; + tmp.line_top = pp.param->line_top; + tmp.pagebreak_top = pp.param->pagebreak_top; + tmp.added_space_top = pp.param->added_space_top; + tmp.spacing = pp.param->spacing; + tmp.pextra_type = pp.param->pextra_type; + tmp.pextra_width = pp.param->pextra_width; + tmp.pextra_widthp = pp.param->pextra_widthp; + tmp.pextra_alignment = pp.param->pextra_alignment; + tmp.pextra_hfill = pp.param->pextra_hfill; + tmp.pextra_start_minipage = pp.param->pextra_start_minipage; + tmp.noindent = pp.param->noindent; + tmp.depth = pp.param->depth; + + set_from_struct(tmp); +} + + +void ParagraphParameters::set_from_struct(ParameterStruct const & ps) +{ + // get new param from container with tmp as template + param = container.get(ps); +} + + +VSpace const & ParagraphParameters::spaceTop() const +{ + return param->added_space_top; +} + + +void ParagraphParameters::spaceTop(VSpace const & vs) +{ + ParameterStruct tmp(*param); + tmp.added_space_top = vs; + set_from_struct(tmp); +} + + +VSpace const & ParagraphParameters::spaceBottom() const +{ + return param->added_space_bottom; +} + + +void ParagraphParameters::spaceBottom(VSpace const & vs) +{ + ParameterStruct tmp(*param); + tmp.added_space_bottom = vs; + set_from_struct(tmp); +} + + +Spacing const & ParagraphParameters::spacing() const +{ + return param->spacing; +} + + +void ParagraphParameters::spacing(Spacing const & s) +{ + ParameterStruct tmp(*param); + tmp.spacing = s; + set_from_struct(tmp); +} + + +bool ParagraphParameters::noindent() const +{ + return param->noindent; +} + + +void ParagraphParameters::noindent(bool ni) +{ + ParameterStruct tmp(*param); + tmp.noindent = ni; + set_from_struct(tmp); +} + + +bool ParagraphParameters::lineTop() const +{ + return param->line_top; +} + + +void ParagraphParameters::lineTop(bool lt) +{ + ParameterStruct tmp(*param); + tmp.line_top = lt; + set_from_struct(tmp); +} + + +bool ParagraphParameters::lineBottom() const +{ + return param->line_bottom; +} + + +void ParagraphParameters::lineBottom(bool lb) +{ + ParameterStruct tmp(*param); + tmp.line_bottom = lb; + set_from_struct(tmp); +} + + +bool ParagraphParameters::pagebreakTop() const +{ + return param->pagebreak_top; +} + + +void ParagraphParameters::pagebreakTop(bool pbt) +{ + ParameterStruct tmp(*param); + tmp.pagebreak_top = pbt; + set_from_struct(tmp); +} + + +bool ParagraphParameters::pagebreakBottom() const +{ + return param->pagebreak_bottom; +} + + +void ParagraphParameters::pagebreakBottom(bool pbb) +{ + ParameterStruct tmp(*param); + tmp.pagebreak_bottom = pbb; + set_from_struct(tmp); +} + + +LyXAlignment ParagraphParameters::align() const +{ + return param->align; +} + + +void ParagraphParameters::align(LyXAlignment la) +{ + ParameterStruct tmp(*param); + tmp.align = la; + set_from_struct(tmp); +} + + +char ParagraphParameters::depth() const +{ + return param->depth; +} + + +void ParagraphParameters::depth(char d) +{ + ParameterStruct tmp(*param); + tmp.depth = d; + set_from_struct(tmp); +} + + +bool ParagraphParameters::startOfAppendix() const +{ + return param->start_of_appendix; +} + + +void ParagraphParameters::startOfAppendix(bool soa) +{ + ParameterStruct tmp(*param); + tmp.start_of_appendix = soa; + set_from_struct(tmp); +} + + +bool ParagraphParameters::appendix() const +{ + return param->appendix; +} + + +void ParagraphParameters::appendix(bool a) +{ + ParameterStruct tmp(*param); + tmp.appendix = a; + set_from_struct(tmp); +} + + +string const & ParagraphParameters::labelString() const +{ + return param->labelstring; +} + + +void ParagraphParameters::labelString(string const & ls) +{ + ParameterStruct tmp(*param); + tmp.labelstring = ls; + set_from_struct(tmp); +} + + +string const & ParagraphParameters::labelWidthString() const +{ + return param->labelwidthstring; +} + + +void ParagraphParameters::labelWidthString(string const & lws) +{ + ParameterStruct tmp(*param); + tmp.labelwidthstring = lws; + set_from_struct(tmp); +} + + +int ParagraphParameters::pextraType() const +{ + return param->pextra_type; +} + + +void ParagraphParameters::pextraType(int t) +{ + ParameterStruct tmp(*param); + tmp.pextra_type = t; + set_from_struct(tmp); +} + + +string const & ParagraphParameters::pextraWidth() const +{ + return param->pextra_width; +} + + +void ParagraphParameters::pextraWidth(string const & w) +{ + ParameterStruct tmp(*param); + tmp.pextra_width = w; + set_from_struct(tmp); +} + + +string const & ParagraphParameters::pextraWidthp() const +{ + return param->pextra_widthp; +} + + +void ParagraphParameters::pextraWidthp(string const & wp) +{ + ParameterStruct tmp(*param); + tmp.pextra_widthp = wp; + set_from_struct(tmp); +} + + +int ParagraphParameters::pextraAlignment() const +{ + return param->pextra_alignment; +} + + +void ParagraphParameters::pextraAlignment(int a) +{ + ParameterStruct tmp(*param); + tmp.pextra_alignment = a; + set_from_struct(tmp); +} + + +bool ParagraphParameters::pextraHfill() const +{ + return param->pextra_hfill; +} + + +void ParagraphParameters::pextraHfill(bool hf) +{ + ParameterStruct tmp(*param); + tmp.pextra_hfill = hf; + set_from_struct(tmp); +} + + +bool ParagraphParameters::pextraStartMinipage() const +{ + return param->pextra_start_minipage; +} + + +void ParagraphParameters::pextraStartMinipage(bool smp) +{ + ParameterStruct tmp(*param); + tmp.pextra_start_minipage = smp; + set_from_struct(tmp); +} diff --git a/src/ParagraphParameters.h b/src/ParagraphParameters.h new file mode 100644 index 0000000000..fe64dbe3cb --- /dev/null +++ b/src/ParagraphParameters.h @@ -0,0 +1,113 @@ +// -*- C++ -*- + +#ifndef PARAGRAPHPARAMETERS_H +#define PARAGRAPHPARAMETERS_H + +#include "ShareContainer.h" +#include "LString.h" +#include "layout.h" + +class VSpace; +class Spacing; +struct ParameterStruct; + +/// +class ParagraphParameters { +public: + /// + ParagraphParameters(); + /// + void clear(); + /// + bool sameLayout(ParagraphParameters const &) const; + /// + void makeSame(ParagraphParameters const & pp); + /// + VSpace const & spaceTop() const; + /// + void spaceTop(VSpace const &); + /// + VSpace const & spaceBottom() const; + /// + void spaceBottom(VSpace const &); + /// + Spacing const & spacing() const; + /// + void spacing(Spacing const &); + /// + bool noindent() const; + /// + void noindent(bool); + /// + bool lineTop() const; + /// + void lineTop(bool); + /// + bool lineBottom() const; + /// + void lineBottom(bool); + /// + bool pagebreakTop() const; + /// + void pagebreakTop(bool); + /// + bool pagebreakBottom() const; + /// + void pagebreakBottom(bool); + /// + LyXAlignment align() const; + /// + void align(LyXAlignment); + /// + char depth() const; + /// + void depth(char); + /// + bool startOfAppendix() const; + /// + void startOfAppendix(bool); + /// + bool appendix() const; + /// + void appendix(bool); + /// + string const & labelString() const; + /// + void labelString(string const &); + /// + string const & labelWidthString() const; + /// + void labelWidthString(string const &); + /// + int pextraType() const; + /// + void pextraType(int); + /// + string const & pextraWidth() const; + /// + void pextraWidth(string const &); + /// + string const & pextraWidthp() const; + /// + void pextraWidthp(string const &); + /// + int pextraAlignment() const; + /// + void pextraAlignment(int); + /// + bool pextraHfill() const; + /// + void pextraHfill(bool); + /// + bool pextraStartMinipage() const; + /// + void pextraStartMinipage(bool); +private: + /// + void set_from_struct(ParameterStruct const &); + /// + boost::shared_ptr param; + /// + static ShareContainer container; +}; +#endif diff --git a/src/ParameterStruct.h b/src/ParameterStruct.h new file mode 100644 index 0000000000..86bc6f1e15 --- /dev/null +++ b/src/ParameterStruct.h @@ -0,0 +1,81 @@ +// -*- C++ -*- + +#ifndef PARAMETERSTRUCT_H +#define PARAMETERSTRUCT_H + +#include "vspace.h" +#include "Spacing.h" +#include "layout.h" + +/// +struct ParameterStruct { + /// + VSpace added_space_top; + /// + VSpace added_space_bottom; + /// + Spacing spacing; + /// + bool noindent; + /// + bool line_top; + /// + bool line_bottom; + /// + bool pagebreak_top; + /// + bool pagebreak_bottom; + /// + LyXAlignment align; + /// + char depth; // wrong type (Lgb) + /// + bool start_of_appendix; + /// + bool appendix; + /// + string labelstring; + /// + string labelwidthstring; + /// + int pextra_type; + /// + string pextra_width; + /// + string pextra_widthp; + /// + int pextra_alignment; + /// + bool pextra_hfill; + /// + bool pextra_start_minipage; +}; + + +inline +bool operator==(ParameterStruct const & ps1, + ParameterStruct const & ps2) +{ + return ps1.added_space_top == ps2.added_space_top + && ps1.added_space_bottom == ps2.added_space_bottom + && ps1.spacing == ps2.spacing + && ps1.noindent == ps2.noindent + && ps1.line_top == ps2.line_top + && ps1.line_bottom == ps2.line_bottom + && ps1.pagebreak_top == ps2.pagebreak_top + && ps1.pagebreak_bottom == ps2.pagebreak_bottom + && ps1.align == ps2.align + && ps1.depth == ps2.depth + && ps1.start_of_appendix == ps2.start_of_appendix + && ps1.appendix == ps2.appendix + && ps1.labelstring == ps2.labelstring + && ps1.labelwidthstring == ps2.labelwidthstring + && ps1.pextra_type == ps2.pextra_type + && ps1.pextra_width == ps2.pextra_width + && ps1.pextra_widthp == ps2.pextra_widthp + && ps1.pextra_alignment == ps2.pextra_alignment + && ps1.pextra_hfill == ps2.pextra_hfill + && ps1.pextra_start_minipage == ps2.pextra_start_minipage; +} + +#endif diff --git a/src/ShareContainer.h b/src/ShareContainer.h new file mode 100644 index 0000000000..0ca488485e --- /dev/null +++ b/src/ShareContainer.h @@ -0,0 +1,73 @@ +// -*- C++ -*- + +#ifndef SHARECONTAINER_H +#define SHARECONTAINER_H + +#include +#include +#include +#include + +/// +template +class ShareContainer : public noncopyable { +public: + /// + typedef std::vector > Params; + /// + Params::value_type + get(Share const & ps) const { + // First see if we already have this ps in the container + Params::iterator it = params.begin(); + Params::iterator end = params.end(); + for (; it != end; ++it) { + if (ps == *(*it).get()) + break; + } + Params::value_type tmp; + if (it == end) { + // ok we don't have it so we should + // insert it. + tmp.reset(new Share(ps)); + params.push_back(tmp); + // We clean here. This can cause us to have + // some (one) unique elemements some times + // but we should gain a lot in speed. + clean(); + std::sort(params.rbegin(), params.rend(), comp()); + } else { + // yes we have it already + tmp = *it; + } + return tmp; + } +private: + /// + struct comp { + int operator()(Params::value_type const & p1, + Params::value_type const & p2) { + return p1.use_count() < p2.use_count(); + } + }; + /// + struct isUnique { + bool operator()(Params::value_type const & p) const { + return p.unique(); + } + }; + + /// + void clean() const { + // Remove all unique items. (i.e. entries that only + // exists in the conatainer and does not have a + // corresponding paragrah. + Params::iterator it = std::remove_if(params.begin(), + params.end(), + isUnique()); + params.erase(it, params.end()); + } + + /// + mutable Params params; +}; +#endif diff --git a/src/Spacing.h b/src/Spacing.h index 98f9463250..ba8e530628 100644 --- a/src/Spacing.h +++ b/src/Spacing.h @@ -39,6 +39,13 @@ public: /// Spacing() : space(Single), value(1.0) {} /// + Spacing(Spacing::Space sp, float val = 1.0) { + set(sp, val); + } + Spacing(Spacing::Space sp, string const & val) { + set(sp, val); + } + /// bool isDefault() const { return space == Default; } diff --git a/src/buffer.C b/src/buffer.C index 3fb4f234a3..65586dc091 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -394,7 +394,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->footnoteflag = footnoteflag; par->footnotekind = footnotekind; #endif - par->depth = depth; + par->params.depth(depth); font = LyXFont(LyXFont::ALL_INHERIT, params.language); if (file_format < 216 && params.language->lang() == "hebrew") font.setLanguage(default_language); @@ -550,21 +550,21 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, lex.EatLine(); params.fonts = lex.GetString(); } else if (token == "\\noindent") { - par->noindent = true; + par->params.noindent(true); } else if (token == "\\fill_top") { - par->added_space_top = VSpace(VSpace::VFILL); + par->params.spaceTop(VSpace(VSpace::VFILL)); } else if (token == "\\fill_bottom") { - par->added_space_bottom = VSpace(VSpace::VFILL); + par->params.spaceBottom(VSpace(VSpace::VFILL)); } else if (token == "\\line_top") { - par->line_top = true; + par->params.lineTop(true); } else if (token == "\\line_bottom") { - par->line_bottom = true; + par->params.lineBottom(true); } else if (token == "\\pagebreak_top") { - par->pagebreak_top = true; + par->params.pagebreakTop(true); } else if (token == "\\pagebreak_bottom") { - par->pagebreak_bottom = true; + par->params.pagebreakBottom(true); } else if (token == "\\start_of_appendix") { - par->start_of_appendix = true; + par->params.startOfAppendix(true); } else if (token == "\\paragraph_separation") { int tmpret = lex.FindToken(string_paragraph_separation); if (tmpret == -1) ++tmpret; @@ -755,7 +755,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, // Small hack so that files written with klyx will be // parsed correctly. if (return_par) { - par->spacing.set(tmp_space, tmp_val); + par->params.spacing(Spacing(tmp_space, tmp_val)); } else { params.spacing.set(tmp_space, tmp_val); } @@ -763,15 +763,15 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, lex.next(); string const tmp = strip(lex.GetString()); if (tmp == "single") { - par->spacing.set(Spacing::Single); + par->params.spacing(Spacing(Spacing::Single)); } else if (tmp == "onehalf") { - par->spacing.set(Spacing::Onehalf); + par->params.spacing(Spacing(Spacing::Onehalf)); } else if (tmp == "double") { - par->spacing.set(Spacing::Double); + par->params.spacing(Spacing(Spacing::Double)); } else if (tmp == "other") { lex.next(); - par->spacing.set(Spacing::Other, - lex.GetFloat()); + par->params.spacing(Spacing(Spacing::Other, + lex.GetFloat())); } else { lex.printError("Unknown spacing token: '$$Token'"); } @@ -844,35 +844,35 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, if (tmpret != LYX_LAYOUT_DEFAULT) { // tmpret != 99 ??? int const tmpret2 = int(pow(2.0, tmpret)); //lyxerr << "Tmpret2 = " << tmpret2 << endl; - par->align = LyXAlignment(tmpret2); + par->params.align(LyXAlignment(tmpret2)); } } else if (token == "\\added_space_top") { lex.nextToken(); - par->added_space_top = VSpace(lex.GetString()); + par->params.spaceTop(VSpace(lex.GetString())); } else if (token == "\\added_space_bottom") { lex.nextToken(); - par->added_space_bottom = VSpace(lex.GetString()); + par->params.spaceBottom(VSpace(lex.GetString())); } else if (token == "\\pextra_type") { lex.nextToken(); - par->pextra_type = lex.GetInteger(); + par->params.pextraType(lex.GetInteger()); } else if (token == "\\pextra_width") { lex.nextToken(); - par->pextra_width = lex.GetString(); + par->params.pextraWidth(lex.GetString()); } else if (token == "\\pextra_widthp") { lex.nextToken(); - par->pextra_widthp = lex.GetString(); + par->params.pextraWidthp(lex.GetString()); } else if (token == "\\pextra_alignment") { lex.nextToken(); - par->pextra_alignment = lex.GetInteger(); + par->params.pextraAlignment(lex.GetInteger()); } else if (token == "\\pextra_hfill") { lex.nextToken(); - par->pextra_hfill = lex.GetInteger(); + par->params.pextraHfill(lex.GetInteger()); } else if (token == "\\pextra_start_minipage") { lex.nextToken(); - par->pextra_start_minipage = lex.GetInteger(); + par->params.pextraStartMinipage(lex.GetInteger()); } else if (token == "\\labelwidthstring") { lex.EatLine(); - par->labelwidthstring = lex.GetString(); + par->params.labelWidthString(lex.GetString()); // do not delete this token, it is still needed! } else if (token == "\\end_inset") { lyxerr << "Solitary \\end_inset. Missing \\begin_inset?.\n" @@ -1343,14 +1343,13 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, } #endif /* begins or ends a deeper area ?*/ - if (depth != par->depth) { - if (par->depth > depth) { - while (par->depth > depth) { + if (depth != par->params.depth()) { + if (par->params.depth() > depth) { + while (par->params.depth() > depth) { ++depth; } - } - else { - while (par->depth < depth) { + } else { + while (par->params.depth() < depth) { --depth; } } @@ -1439,7 +1438,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, } break; default: - buffer << par->labelstring << " "; + buffer << par->params.labelString() << " "; break; } if (ltype_depth > depth) { @@ -2088,7 +2087,7 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par, // flag this with ftcount ftcount = -1; if (layout.isEnvironment() - || par->pextra_type != LyXParagraph::PEXTRA_NONE) { + || par->params.pextraType() != LyXParagraph::PEXTRA_NONE) { par = par->TeXEnvironment(this, params, ofs, texrow #ifndef NEW_INSETS ,ftnote, ft_texrow, ftcount @@ -2254,7 +2253,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) } // environment tag closing - for (; depth > par->depth; --depth) { + for (; depth > par->params.depth(); --depth) { sgmlCloseTag(ofs, depth, environment_stack[depth]); environment_stack[depth].erase(); } @@ -2262,7 +2261,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) // write opening SGML tags switch (style.latextype) { case LATEX_PARAGRAPH: - if (depth == par->depth + if (depth == par->params.depth() && !environment_stack[depth].empty()) { sgmlCloseTag(ofs, depth, environment_stack[depth]); environment_stack[depth].erase(); @@ -2292,7 +2291,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) case LATEX_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: - if (depth == par->depth + if (depth == par->params.depth() && environment_stack[depth] != style.latexname() && !environment_stack[depth].empty()) { @@ -2300,8 +2299,8 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) environment_stack[depth]); environment_stack[depth].erase(); } - if (depth < par->depth) { - depth = par->depth; + if (depth < par->params.depth()) { + depth = par->params.depth(); environment_stack[depth].erase(); } if (environment_stack[depth] != style.latexname()) { @@ -2879,7 +2878,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) par->layout); // environment tag closing - for (; depth > par->depth; --depth) { + for (; depth > par->params.depth(); --depth) { if (environment_inner[depth] != "!-- --") { item_name= "listitem"; sgmlCloseTag(ofs, command_depth + depth, @@ -2894,7 +2893,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) environment_inner[depth].erase(); } - if (depth == par->depth + if (depth == par->params.depth() && environment_stack[depth] != style.latexname() && !environment_stack[depth].empty()) { if (environment_inner[depth] != "!-- --") { @@ -2978,8 +2977,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) case LATEX_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: - if (depth < par->depth) { - depth = par->depth; + if (depth < par->params.depth()) { + depth = par->params.depth(); environment_stack[depth].erase(); } diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 230abe0622..8aa4bcb5c1 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -254,9 +254,9 @@ string const CurrentState(BufferView * bv) state += string(_(", Depth: ")) + tostr(depth); // The paragraph spacing, but only if different from // buffer spacing. - if (!text->cursor.par()->spacing.isDefault()) { + if (!text->cursor.par()->params.spacing().isDefault()) { Spacing::Space cur_space = - text->cursor.par()->spacing.getSpace(); + text->cursor.par()->params.spacing().getSpace(); state += _(", Spacing: "); switch (cur_space) { case Spacing::Single: @@ -270,7 +270,7 @@ string const CurrentState(BufferView * bv) break; case Spacing::Other: state += _("Other ("); - state += tostr(text->cursor.par()->spacing.getValue()); + state += tostr(text->cursor.par()->params.spacing().getValue()); state += ")"; break; case Spacing::Default: diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index e09ef846e4..3fc29337b4 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2001-03-06 Lars Gullik Bjønnes + + * FormParagraph.C: changes because of ParagraphParameters. + 2001-03-06 Jean-Marc Lasgouttes * FormSearch.C (Replace): remove default argument diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index 9d2eb01028..bae9fa87f8 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -336,36 +336,36 @@ void FormParagraph::general_update() #ifndef NEW_INSETS fl_set_button(general_->check_lines_top, - text->cursor.par()->FirstPhysicalPar()->line_top); + text->cursor.par()->FirstPhysicalPar()->params.lineTop()); fl_set_button(general_->check_lines_bottom, - text->cursor.par()->FirstPhysicalPar()->line_bottom); + text->cursor.par()->FirstPhysicalPar()->params.lineBottom()); fl_set_button(general_->check_pagebreaks_top, - text->cursor.par()->FirstPhysicalPar()->pagebreak_top); + text->cursor.par()->FirstPhysicalPar()->params.pagebreakTop()); fl_set_button(general_->check_pagebreaks_bottom, - text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom); + text->cursor.par()->FirstPhysicalPar()->params.pagebreakBottom()); fl_set_button(general_->check_noindent, - text->cursor.par()->FirstPhysicalPar()->noindent); + text->cursor.par()->FirstPhysicalPar()->params.noindent()); #else fl_set_button(general_->check_lines_top, - text->cursor.par()->line_top); + text->cursor.par()->params.lineTop()); fl_set_button(general_->check_lines_bottom, - text->cursor.par()->line_bottom); + text->cursor.par()->params.lineBottom()); fl_set_button(general_->check_pagebreaks_top, - text->cursor.par()->pagebreak_top); + text->cursor.par()->params.pagebreakTop()); fl_set_button(general_->check_pagebreaks_bottom, - text->cursor.par()->pagebreak_bottom); + text->cursor.par()->params.pagebreakBottom()); fl_set_button(general_->check_noindent, - text->cursor.par()->noindent); + text->cursor.par()->params.noindent()); #endif fl_set_input (general_->input_space_above, ""); #ifndef NEW_INSETS - switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) { + switch (text->cursor.par()->FirstPhysicalPar()->params.spaceTop().kind()) { #else - switch (text->cursor.par()->added_space_top.kind()) { + switch (text->cursor.par()->params.spaceTop().kind()) { #endif case VSpace::NONE: @@ -391,25 +391,25 @@ void FormParagraph::general_update() #ifndef NEW_INSETS fl_set_input(general_->input_space_above, text->cursor.par()->FirstPhysicalPar()-> - added_space_top.length().asString().c_str()); + params.spaceTop().length().asString().c_str()); #else fl_set_input(general_->input_space_above, text->cursor.par()-> - added_space_top.length().asString().c_str()); + params.spaceTop().length().asString().c_str()); #endif break; } #ifndef NEW_INSETS fl_set_button(general_->check_space_above, text->cursor.par()->FirstPhysicalPar()-> - added_space_top.keep()); + params.spaceTop().keep()); fl_set_input(general_->input_space_below, ""); switch (text->cursor.par()->FirstPhysicalPar()-> - added_space_bottom.kind()) { + params.spaceBottom().kind()) { #else fl_set_button (general_->check_space_above, - text->cursor.par()->added_space_top.keep()); + text->cursor.par()->params.spaceTop().keep()); fl_set_input (general_->input_space_below, ""); - switch (text->cursor.par()->added_space_bottom.kind()) { + switch (text->cursor.par()->params.spaceBottom().kind()) { #endif case VSpace::NONE: fl_set_choice (general_->choice_space_below, 1); @@ -434,14 +434,14 @@ void FormParagraph::general_update() #ifndef NEW_INSETS fl_set_input(general_->input_space_below, text->cursor.par()->FirstPhysicalPar()-> - added_space_bottom.length().asString().c_str()); + params.spaceBottom().length().asString().c_str()); break; } fl_set_button(general_->check_space_below, text->cursor.par()->FirstPhysicalPar()-> - added_space_bottom.keep()); + params.spaceBottom().keep()); fl_set_button(general_->check_noindent, - text->cursor.par()->FirstPhysicalPar()->noindent); + text->cursor.par()->FirstPhysicalPar()->params.noindent()); bool const enable = (!text->cursor.par()->FirstPhysicalPar()->InInset()); @@ -455,13 +455,13 @@ void FormParagraph::general_update() #else fl_set_input(general_->input_space_below, text->cursor.par()-> - added_space_bottom.length().asString().c_str()); + params.spaceBottom().length().asString().c_str()); break; } fl_set_button(general_->check_space_below, - text->cursor.par()->added_space_bottom.keep()); + text->cursor.par()->params.spaceBottom().keep()); fl_set_button(general_->check_noindent, - text->cursor.par()->noindent); + text->cursor.par()->params.noindent()); #endif } @@ -477,10 +477,10 @@ void FormParagraph::extra_update() setEnabled(extra_->input_pextra_widthp, true); fl_set_input(extra_->input_pextra_width, - par->pextra_width.c_str()); + par->params.pextraWidth().c_str()); fl_set_input(extra_->input_pextra_widthp, - par->pextra_widthp.c_str()); - switch (par->pextra_alignment) { + par->params.pextraWidthp().c_str()); + switch (par->params.pextraAlignment()) { case LyXParagraph::MINIPAGE_ALIGN_TOP: fl_set_button(extra_->radio_pextra_top, 1); break; @@ -492,10 +492,10 @@ void FormParagraph::extra_update() break; } fl_set_button(extra_->radio_pextra_hfill, - par->pextra_hfill); + par->params.pextraHfill()); fl_set_button(extra_->radio_pextra_startmp, - par->pextra_start_minipage); - if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) { + par->params.pextraStartMinipage()); + if (par->params.pextraType() == LyXParagraph::PEXTRA_INDENT) { fl_set_button(extra_->radio_pextra_indent, 1); fl_set_button(extra_->radio_pextra_minipage, 0); fl_set_button(extra_->radio_pextra_floatflt, 0); @@ -503,7 +503,7 @@ void FormParagraph::extra_update() setEnabled(extra_->radio_pextra_middle, false); setEnabled(extra_->radio_pextra_bottom, false); input(extra_->radio_pextra_indent, 0); - } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) { + } else if (par->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) { fl_set_button(extra_->radio_pextra_indent, 0); fl_set_button(extra_->radio_pextra_minipage, 1); fl_set_button(extra_->radio_pextra_floatflt, 0); @@ -511,7 +511,7 @@ void FormParagraph::extra_update() setEnabled(extra_->radio_pextra_middle, true); setEnabled(extra_->radio_pextra_bottom, true); input(extra_->radio_pextra_minipage, 0); - } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) { + } else if (par->params.pextraType() == LyXParagraph::PEXTRA_FLOATFLT) { fl_set_button(extra_->radio_pextra_indent, 0); fl_set_button(extra_->radio_pextra_minipage, 0); fl_set_button(extra_->radio_pextra_floatflt, 1); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index e31a6069ed..779456aef0 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2001-03-06 Lars Gullik Bjønnes + + * insettext.C: changes becuase of ParagraphParameters. + 2001-02-28 Baruch Even * insetgraphics.C (updateInset): Changed due to the change in diff --git a/src/insets/insettext.C b/src/insets/insettext.C index b2240c1539..4e881834e8 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1053,10 +1053,10 @@ InsetText::LocalDispatch(BufferView * bv, // inherit bufferparams/paragraphparams in a strange way. (Lgb) { LyXParagraph * par = TEXT(bv)->cursor.par(); - Spacing::Space cur_spacing = par->spacing.getSpace(); + Spacing::Space cur_spacing = par->params.spacing().getSpace(); float cur_value = 1.0; if (cur_spacing == Spacing::Other) { - cur_value = par->spacing.getValue(); + cur_value = par->params.spacing().getValue(); } std::istringstream istr(arg.c_str()); @@ -1087,7 +1087,7 @@ InsetText::LocalDispatch(BufferView * bv, << arg << endl; } if (cur_spacing != new_spacing || cur_value != new_value) { - par->spacing.set(new_spacing, new_value); + par->params.spacing(Spacing(new_spacing, new_value)); //TEXT(bv)->RedoParagraph(owner->view()); UpdateLocal(bv, CURSOR_PAR, true); //bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); diff --git a/src/lyxfont.C b/src/lyxfont.C index 544e6aafb3..52bfa989a5 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -10,12 +10,12 @@ #include #include +#include #ifdef __GNUG__ -#pragma implementation "lyxfont.h" +#pragma implementation #endif -#include #include "gettext.h" #include "lyxfont.h" @@ -104,6 +104,8 @@ char const * LaTeXSizeNames[14] = "Large", "LARGE", "huge", "Huge", "error8", "error9", "error10", "error11" }; + +// Initialize static member LyXFont::FontBits LyXFont::sane = { ROMAN_FAMILY, MEDIUM_SERIES, @@ -113,8 +115,10 @@ LyXFont::FontBits LyXFont::sane = { OFF, OFF, OFF, + OFF, OFF }; +// Initialize static member LyXFont::FontBits LyXFont::inherit = { INHERIT_FAMILY, INHERIT_SERIES, @@ -124,8 +128,10 @@ LyXFont::FontBits LyXFont::inherit = { INHERIT, INHERIT, INHERIT, - INHERIT }; + INHERIT, + OFF }; +// Initialize static member LyXFont::FontBits LyXFont::ignore = { IGNORE_FAMILY, IGNORE_SERIES, @@ -135,20 +141,22 @@ LyXFont::FontBits LyXFont::ignore = { IGNORE, IGNORE, IGNORE, + IGNORE, IGNORE }; bool LyXFont::FontBits::operator==(LyXFont::FontBits const & fb1) const { - return fb1.family == family && - fb1.series == series && - fb1.shape == shape && - fb1.size == size && - fb1.color == color && - fb1.emph == emph && - fb1.underbar == underbar && - fb1.noun == noun && - fb1.latex == latex; + return fb1.family == family && + fb1.series == series && + fb1.shape == shape && + fb1.size == size && + fb1.color == color && + fb1.emph == emph && + fb1.underbar == underbar && + fb1.noun == noun && + fb1.latex == latex && + fb1.number == number; } @@ -158,6 +166,210 @@ bool LyXFont::FontBits::operator!=(LyXFont::FontBits const & fb1) const } +LyXFont::LyXFont() +{ + bits = sane; + lang = default_language; +} + + +LyXFont::LyXFont(LyXFont::FONT_INIT1) +{ + bits = inherit; + lang = default_language; +} + + +LyXFont::LyXFont(LyXFont::FONT_INIT2) +{ + bits = ignore; + lang = ignore_language; +} + + +LyXFont::LyXFont(LyXFont::FONT_INIT3) +{ + bits = sane; + lang = default_language; +} + + +LyXFont::LyXFont(LyXFont::FONT_INIT1, Language const * l) +{ + bits = inherit; + lang = l; +} + + +LyXFont::LyXFont(LyXFont::FONT_INIT2, Language const * l) +{ + bits = ignore; + lang = l; +} + + +LyXFont::LyXFont(LyXFont::FONT_INIT3, Language const * l) +{ + bits = sane; + lang = l; +} + + +LyXFont::FONT_FAMILY LyXFont::family() const +{ + return bits.family; +} + + +LyXFont::FONT_SERIES LyXFont::series() const +{ + return bits.series; +} + + +LyXFont::FONT_SHAPE LyXFont::shape() const +{ + return bits.shape; +} + + +LyXFont::FONT_SIZE LyXFont::size() const +{ + return bits.size; +} + + +LyXFont::FONT_MISC_STATE LyXFont::emph() const +{ + return bits.emph; +} + + +LyXFont::FONT_MISC_STATE LyXFont::underbar() const +{ + return bits.underbar; +} + + +LyXFont::FONT_MISC_STATE LyXFont::noun() const +{ + return bits.noun; +} + + +LyXFont::FONT_MISC_STATE LyXFont::latex() const +{ + return bits.latex; +} + + +LColor::color LyXFont::color() const +{ + return bits.color; +} + + +Language const * LyXFont::language() const +{ + return lang; +} + + +LyXFont::FONT_MISC_STATE LyXFont::number() const +{ + return bits.number; +} + + +bool LyXFont::isRightToLeft() const +{ + return lang->RightToLeft(); +} + + +bool LyXFont::isVisibleRightToLeft() const +{ + return (lang->RightToLeft() && latex() != ON && number() != ON); +} + + +LyXFont & LyXFont::setFamily(LyXFont::FONT_FAMILY f) +{ + bits.family = f; + return *this; +} + + +LyXFont & LyXFont::setSeries(LyXFont::FONT_SERIES s) +{ + bits.series = s; + return *this; +} + + +LyXFont & LyXFont::setShape(LyXFont::FONT_SHAPE s) +{ + bits.shape = s; + return *this; +} + + +LyXFont & LyXFont::setSize(LyXFont::FONT_SIZE s) +{ + bits.size = s; + return *this; +} + + +LyXFont & LyXFont::setEmph(LyXFont::FONT_MISC_STATE e) +{ + bits.emph = e; + return *this; +} + + +LyXFont & LyXFont::setUnderbar(LyXFont::FONT_MISC_STATE u) +{ + bits.underbar = u; + return *this; +} + + +LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n) +{ + bits.noun = n; + return *this; +} + + +LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l) +{ + bits.latex = l; + return *this; +} + + +LyXFont & LyXFont::setColor(LColor::color c) +{ + bits.color = c; + return *this; +} + + +LyXFont & LyXFont::setLanguage(Language const * l) +{ + lang = l; + return *this; +} + + +LyXFont & LyXFont::setNumber(LyXFont::FONT_MISC_STATE n) +{ + bits.number = n; + return *this; +} + + /// Decreases font size by one LyXFont & LyXFont::decSize() { @@ -365,7 +577,6 @@ LyXFont & LyXFont::realize(LyXFont const & tmplt) if (bits.color == LColor::inherit) { bits.color = tmplt.bits.color; } - return *this; } @@ -422,7 +633,7 @@ string const LyXFont::stateText(BufferParams * params) const // Set family according to lyx format string LyXFont & LyXFont::setLyXFamily(string const & fam) { - string s = lowercase(fam); + string const s = lowercase(fam); int i = 0; while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error") ++i; @@ -438,7 +649,7 @@ LyXFont & LyXFont::setLyXFamily(string const & fam) // Set series according to lyx format string LyXFont & LyXFont::setLyXSeries(string const & ser) { - string s = lowercase(ser); + string const s = lowercase(ser); int i = 0; while (s != LyXSeriesNames[i] && LyXSeriesNames[i] != "error") ++i; @@ -454,7 +665,7 @@ LyXFont & LyXFont::setLyXSeries(string const & ser) // Set shape according to lyx format string LyXFont & LyXFont::setLyXShape(string const & sha) { - string s = lowercase(sha); + string const s = lowercase(sha); int i = 0; while (s != LyXShapeNames[i] && LyXShapeNames[i] != "error") ++i; @@ -470,7 +681,7 @@ LyXFont & LyXFont::setLyXShape(string const & sha) // Set size according to lyx format string LyXFont & LyXFont::setLyXSize(string const & siz) { - string s = lowercase(siz); + string const s = lowercase(siz); int i = 0; while (s != LyXSizeNames[i] && LyXSizeNames[i] != "error") ++i; if (s == LyXSizeNames[i]) { @@ -485,7 +696,7 @@ LyXFont & LyXFont::setLyXSize(string const & siz) // Set size according to lyx format string LyXFont::FONT_MISC_STATE LyXFont::setLyXMisc(string const & siz) { - string s = lowercase(siz); + string const s = lowercase(siz); int i = 0; while (s != LyXMiscNames[i] && LyXMiscNames[i] != "error") ++i; if (s == LyXMiscNames[i]) @@ -519,7 +730,7 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex) bool finished = false; while (!finished && lex.IsOK() && !error) { lex.next(); - string tok = lowercase(lex.GetString()); + string const tok = lowercase(lex.GetString()); if (tok.empty()) { continue; @@ -527,54 +738,54 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex) finished = true; } else if (tok == "family") { lex.next(); - string tok = lex.GetString(); - setLyXFamily(tok); + string const ttok = lex.GetString(); + setLyXFamily(ttok); } else if (tok == "series") { lex.next(); - string tok = lex.GetString(); - setLyXSeries(tok); + string const ttok = lex.GetString(); + setLyXSeries(ttok); } else if (tok == "shape") { lex.next(); - string tok = lex.GetString(); - setLyXShape(tok); + string const ttok = lex.GetString(); + setLyXShape(ttok); } else if (tok == "size") { lex.next(); - string tok = lex.GetString(); - setLyXSize(tok); + string const ttok = lex.GetString(); + setLyXSize(ttok); } else if (tok == "latex") { lex.next(); - string tok = lowercase(lex.GetString()); + string const ttok = lowercase(lex.GetString()); - if (tok == "no_latex") { + if (ttok == "no_latex") { setLatex(OFF); - } else if (tok == "latex") { + } else if (ttok == "latex") { setLatex(ON); } else { lex.printError("Illegal LaTeX type`$$Token'"); } } else if (tok == "misc") { lex.next(); - string tok = lowercase(lex.GetString()); + string const ttok = lowercase(lex.GetString()); - if (tok == "no_bar") { + if (ttok == "no_bar") { setUnderbar(OFF); - } else if (tok == "no_emph") { + } else if (ttok == "no_emph") { setEmph(OFF); - } else if (tok == "no_noun") { + } else if (ttok == "no_noun") { setNoun(OFF); - } else if (tok == "emph") { + } else if (ttok == "emph") { setEmph(ON); - } else if (tok == "underbar") { + } else if (ttok == "underbar") { setUnderbar(ON); - } else if (tok == "noun") { + } else if (ttok == "noun") { setNoun(ON); } else { lex.printError("Illegal misc type `$$Token´"); } } else if (tok == "color") { lex.next(); - string tok = lex.GetString(); - setLyXColor(tok); + string const ttok = lex.GetString(); + setLyXColor(ttok); } else { lex.printError("Unknown tag `$$Token'"); error = true; @@ -677,7 +888,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base, count += 3; } } else { - string tmp = + string const tmp = subst(lyxrc.language_command_local, "$$lang", language()->babel()); os << tmp; diff --git a/src/lyxfont.h b/src/lyxfont.h index 5a5b283d24..2309eab917 100644 --- a/src/lyxfont.h +++ b/src/lyxfont.h @@ -155,9 +155,6 @@ public: /// LyXFont(); - // LyXFont x(LyXFont ...) and LyXFont x = LyXFont ... - LyXFont(LyXFont const & x); - /// Shortcut initialization explicit LyXFont(LyXFont::FONT_INIT1); @@ -174,9 +171,6 @@ public: /// Shortcut initialization LyXFont(LyXFont::FONT_INIT3, Language const * l); - /// LyXFont x, y; x = y; - LyXFont & operator=(LyXFont const & x); - /// Decreases font size by one LyXFont & decSize(); @@ -350,13 +344,15 @@ private: FONT_MISC_STATE noun; /// FONT_MISC_STATE latex; + /// + FONT_MISC_STATE number; }; + /// FontBits bits; + /// Language const * lang; - /// - FONT_MISC_STATE number_; /// Sane font static FontBits sane; @@ -377,276 +373,16 @@ std::ostream & operator<<(std::ostream &, LyXFont::FONT_MISC_STATE); /// inline -bool operator==(LyXFont const & font1, LyXFont const & font2) { +bool operator==(LyXFont const & font1, LyXFont const & font2) +{ return font1.bits == font2.bits && - font1.lang == font2.lang && - font1.number_ == font2.number_; + font1.lang == font2.lang; } /// inline -bool operator!=(LyXFont const & font1, LyXFont const & font2) { +bool operator!=(LyXFont const & font1, LyXFont const & font2) +{ return !(font1 == font2); } - - -inline -LyXFont::LyXFont() -{ - bits = sane; - lang = default_language; - number_ = OFF; -} - - -inline -LyXFont::LyXFont(LyXFont const & x) -{ - bits = x.bits; - lang = x.lang; - number_ = x.number_; -} - - -inline -LyXFont::LyXFont(LyXFont::FONT_INIT1) -{ - bits = inherit; - lang = default_language; - number_ = OFF; -} - - -inline -LyXFont::LyXFont(LyXFont::FONT_INIT2) -{ - bits = ignore; - lang = ignore_language; - number_ = IGNORE; -} - - -inline -LyXFont::LyXFont(LyXFont::FONT_INIT3) -{ - bits = sane; - lang = default_language; - number_ = OFF; -} - - -inline -LyXFont::LyXFont(LyXFont::FONT_INIT1, Language const * l) -{ - bits = inherit; - lang = l; - number_ = OFF; -} - - -inline -LyXFont::LyXFont(LyXFont::FONT_INIT2, Language const * l) -{ - bits = ignore; - lang = l; - number_ = IGNORE; -} - - -inline -LyXFont::LyXFont(LyXFont::FONT_INIT3, Language const * l) -{ - bits = sane; - lang = l; - number_ = OFF; -} - - -inline -LyXFont & LyXFont::operator=(LyXFont const & x) -{ - bits = x.bits; - lang = x.lang; - number_ = x.number_; - return *this; -} - - -inline -LyXFont::FONT_FAMILY LyXFont::family() const -{ - return bits.family; -} - - -inline -LyXFont::FONT_SERIES LyXFont::series() const -{ - return bits.series; -} - - -inline -LyXFont::FONT_SHAPE LyXFont::shape() const -{ - return bits.shape; -} - - -inline -LyXFont::FONT_SIZE LyXFont::size() const -{ - return bits.size; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::emph() const -{ - return bits.emph; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::underbar() const -{ - return bits.underbar; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::noun() const -{ - return bits.noun; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::latex() const -{ - return bits.latex; -} - - -inline -LColor::color LyXFont::color() const -{ - return bits.color; -} - - -inline -Language const * LyXFont::language() const -{ - return lang; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::number() const -{ - return number_; -} - - -inline -bool LyXFont::isRightToLeft() const -{ - return lang->RightToLeft(); -} - - -inline -bool LyXFont::isVisibleRightToLeft() const -{ - return (lang->RightToLeft() && latex() != ON && number() != ON); -} - - -inline -LyXFont & LyXFont::setFamily(LyXFont::FONT_FAMILY f) -{ - bits.family = f; - return *this; -} - - -inline -LyXFont & LyXFont::setSeries(LyXFont::FONT_SERIES s) -{ - bits.series = s; - return *this; -} - - -inline -LyXFont & LyXFont::setShape(LyXFont::FONT_SHAPE s) -{ - bits.shape = s; - return *this; -} - - -inline -LyXFont & LyXFont::setSize(LyXFont::FONT_SIZE s) -{ - bits.size = s; - return *this; -} - - -inline -LyXFont & LyXFont::setEmph(LyXFont::FONT_MISC_STATE e) -{ - bits.emph = e; - return *this; -} - - -inline -LyXFont & LyXFont::setUnderbar(LyXFont::FONT_MISC_STATE u) -{ - bits.underbar = u; - return *this; -} - - -inline -LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n) -{ - bits.noun = n; - return *this; -} - -inline -LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l) -{ - bits.latex = l; - return *this; -} - - -inline -LyXFont & LyXFont::setColor(LColor::color c) -{ - bits.color = c; - return *this; -} - - -inline -LyXFont & LyXFont::setLanguage(Language const * l) -{ - lang = l; - return *this; -} - - -inline -LyXFont & LyXFont::setNumber(LyXFont::FONT_MISC_STATE n) -{ - number_ = n; - return *this; -} - #endif diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 85ff91412e..981f3d3f80 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -18,12 +18,11 @@ #include #include +#include #include "insets/lyxinset.h" -#include "vspace.h" -#include "layout.h" -#include #include "language.h" +#include "ParagraphParameters.h" class BufferParams; class LyXBuffer; @@ -225,14 +224,8 @@ public: void setContentsFromPar(LyXParagraph * par); /// void clearContents(); - /// - VSpace added_space_top; - - /// - VSpace added_space_bottom; - /// - Spacing spacing; + ParagraphParameters params; /// LyXTextClass::LayoutList::size_type layout; @@ -249,26 +242,6 @@ public: /// footnote, margin, fig, tab footnote_kind footnotekind; #endif - /// - bool line_top; - - /// - bool line_bottom; - - /// - bool pagebreak_top; - - /// - bool pagebreak_bottom; - - /// - LyXAlignment align; - - /// - char depth; - - /// - bool noindent; private: /// @@ -280,11 +253,6 @@ public: int getCounter(int i) const; /// void incCounter(int i); - /// - bool start_of_appendix; - - /// - bool appendix; /// char enumdepth; @@ -292,26 +260,6 @@ public: /// char itemdepth; - /* This is for the paragraph extra stuff */ - /// - int pextra_type; - /// - string pextra_width; - /// - string pextra_widthp; - /// - int pextra_alignment; - /// - bool pextra_hfill; - /// - bool pextra_start_minipage; - - /// - string labelstring; - - /// - string labelwidthstring; - /// LyXParagraph * next; /// @@ -524,7 +472,7 @@ private: /// Inset * inset; /// - InsetTable(size_type p, Inset * i) { pos = p; inset = i;} + InsetTable(size_type p, Inset * i) : pos(p), inset(i) {} }; /// friend struct matchIT; @@ -549,8 +497,23 @@ private: (font_1 covers the chars 0,...,pos_1) (Dekel) */ struct FontTable { + /// + FontTable(size_type p, LyXFont const & f) + : pos_(p) + { + font_ = container.get(f); + } + /// + size_type pos() const { return pos_; } + /// + void pos(size_type p) { pos_ = p; } + /// + LyXFont const & font() const { return *font_; } + /// + void font(LyXFont const & f) { font_ = container.get(f);} + private: /// End position of paragraph this font attribute covers - size_type pos; + size_type pos_; /** Font. Interpretation of the font values: If a value is LyXFont::INHERIT_*, it means that the font attribute is inherited from either the layout of this @@ -560,9 +523,9 @@ private: The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT allowed in these font tables. */ - LyXFont font; + boost::shared_ptr font_; /// - FontTable(size_type p, LyXFont const & f) {pos = p; font = f;} + static ShareContainer container; }; /// friend struct matchFT; @@ -572,7 +535,7 @@ private: inline int operator()(LyXParagraph::FontTable const & a, LyXParagraph::FontTable const & b) const { - return a.pos < b.pos; + return a.pos() < b.pos(); } }; diff --git a/src/paragraph.C b/src/paragraph.C index a17825476c..2862334884 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -38,6 +38,7 @@ #include "support/lyxmanip.h" #include "BufferView.h" #include "encoding.h" +#include "ParameterStruct.h" using std::ostream; using std::endl; @@ -65,12 +66,14 @@ extern BufferView * current_view; // declared in lyxparagraph.h unsigned int LyXParagraph::paragraph_id = 0; +// Initialize static member. +ShareContainer LyXParagraph::FontTable::container; + LyXParagraph::LyXParagraph() { text.reserve(500); // is this number too big? for (int i = 0; i < 10; ++i) setCounter(i , 0); - appendix = false; enumdepth = 0; itemdepth = 0; next = 0; @@ -79,7 +82,6 @@ LyXParagraph::LyXParagraph() footnoteflag = LyXParagraph::NO_FOOTNOTE; footnotekind = LyXParagraph::FOOTNOTE; // should not be needed #endif - align = LYX_ALIGN_BLOCK; inset_owner = 0; id_ = paragraph_id++; @@ -95,7 +97,6 @@ LyXParagraph::LyXParagraph(LyXParagraph * par) par->fitToSize(); for (int i = 0; i < 10; ++i) setCounter(i, 0); - appendix = false; enumdepth = 0; itemdepth = 0; // double linked list begin @@ -119,7 +120,7 @@ LyXParagraph::LyXParagraph(LyXParagraph * par) void LyXParagraph::writeFile(Buffer const * buf, ostream & os, - BufferParams const & params, + BufferParams const & bparams, char footflag, char dth) const { #ifndef NEW_INSETS @@ -144,14 +145,14 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, } #endif // The beginning or end of a deeper (i.e. nested) area? - if (dth != depth) { - if (depth > dth) { - while (depth > dth) { + if (dth != params.depth()) { + if (params.depth() > dth) { + while (params.depth() > dth) { os << "\n\\begin_deeper "; ++dth; } } else { - while (depth < dth) { + while (params.depth() < dth) { os << "\n\\end_deeper "; --dth; } @@ -160,49 +161,49 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, // First write the layout os << "\n\\layout " - << textclasslist.NameOfLayout(params.textclass, layout) + << textclasslist.NameOfLayout(bparams.textclass, layout) << "\n"; // Maybe some vertical spaces. - if (added_space_top.kind() != VSpace::NONE) + if (params.spaceTop().kind() != VSpace::NONE) os << "\\added_space_top " - << added_space_top.asLyXCommand() << " "; - if (added_space_bottom.kind() != VSpace::NONE) + << params.spaceTop().asLyXCommand() << " "; + if (params.spaceBottom().kind() != VSpace::NONE) os << "\\added_space_bottom " - << added_space_bottom.asLyXCommand() << " "; + << params.spaceBottom().asLyXCommand() << " "; // Maybe the paragraph has special spacing - spacing.writeFile(os, true); + params.spacing().writeFile(os, true); // The labelwidth string used in lists. - if (!labelwidthstring.empty()) + if (!params.labelWidthString().empty()) os << "\\labelwidthstring " - << labelwidthstring << '\n'; + << params.labelWidthString() << '\n'; // Lines above or below? - if (line_top) + if (params.lineTop()) os << "\\line_top "; - if (line_bottom) + if (params.lineBottom()) os << "\\line_bottom "; // Pagebreaks above or below? - if (pagebreak_top) + if (params.pagebreakTop()) os << "\\pagebreak_top "; - if (pagebreak_bottom) + if (params.pagebreakBottom()) os << "\\pagebreak_bottom "; // Start of appendix? - if (start_of_appendix) + if (params.startOfAppendix()) os << "\\start_of_appendix "; // Noindent? - if (noindent) + if (params.noindent()) os << "\\noindent "; // Alignment? - if (align != LYX_ALIGN_LAYOUT) { + if (params.align() != LYX_ALIGN_LAYOUT) { int h = 0; - switch (align) { + switch (params.align()) { case LYX_ALIGN_LEFT: h = 1; break; case LYX_ALIGN_RIGHT: h = 2; break; case LYX_ALIGN_CENTER: h = 3; break; @@ -210,24 +211,24 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, } os << "\\align " << string_align[h] << " "; } - if (pextra_type != PEXTRA_NONE) { - os << "\\pextra_type " << pextra_type; - if (pextra_type == PEXTRA_MINIPAGE) { + if (params.pextraType() != PEXTRA_NONE) { + os << "\\pextra_type " << params.pextraType(); + if (params.pextraType() == PEXTRA_MINIPAGE) { os << " \\pextra_alignment " - << pextra_alignment; - if (pextra_hfill) + << params.pextraAlignment(); + if (params.pextraHfill()) os << " \\pextra_hfill " - << pextra_hfill; - if (pextra_start_minipage) + << params.pextraHfill(); + if (params.pextraStartMinipage()) os << " \\pextra_start_minipage " - << pextra_start_minipage; + << params.pextraStartMinipage(); } - if (!pextra_width.empty()) { + if (!params.pextraWidth().empty()) { os << " \\pextra_width " - << VSpace(pextra_width).asLyXCommand(); - } else if (!pextra_widthp.empty()) { + << VSpace(params.pextraWidth()).asLyXCommand(); + } else if (!params.pextraWidthp().empty()) { os << " \\pextra_widthp " - << pextra_widthp; + << params.pextraWidthp(); } os << '\n'; } @@ -243,7 +244,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, if (bibkey) bibkey->Write(buf, os); - LyXFont font1(LyXFont::ALL_INHERIT, params.language); + LyXFont font1(LyXFont::ALL_INHERIT, bparams.language); int column = 0; for (size_type i = 0; i < size(); ++i) { @@ -253,7 +254,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, } // Write font changes - LyXFont font2 = GetFontSettings(params, i); + LyXFont font2 = GetFontSettings(bparams, i); if (font2 != font1) { font2.lyxWriteChanges(font1, os); column = 0; @@ -318,45 +319,45 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, // now write the next paragraph if (next) - next->writeFile(buf, os, params, footflag, dth); + next->writeFile(buf, os, bparams, footflag, dth); } void LyXParagraph::validate(LaTeXFeatures & features) const { - BufferParams const & params = features.bufferParams(); + BufferParams const & bparams = features.bufferParams(); #ifndef NEW_INSETS // this will be useful later LyXLayout const & layout = - textclasslist.Style(params.textclass, + textclasslist.Style(bparams.textclass, GetLayout()); #endif // check the params. - if (line_top || line_bottom) + if (params.lineTop() || params.lineBottom()) features.lyxline = true; - if (!spacing.isDefault()) + if (!params.spacing().isDefault()) features.setspace = true; // then the layouts features.layout[GetLayout()] = true; // then the fonts - Language const * doc_language = params.language; + Language const * doc_language = bparams.language; for (FontList::const_iterator cit = fontlist.begin(); cit != fontlist.end(); ++cit) { - if ((*cit).font.noun() == LyXFont::ON) { + if ((*cit).font().noun() == LyXFont::ON) { lyxerr[Debug::LATEX] << "font.noun: " - << (*cit).font.noun() + << (*cit).font().noun() << endl; features.noun = true; lyxerr[Debug::LATEX] << "Noun enabled. Font: " - << (*cit).font.stateText(0) + << (*cit).font().stateText(0) << endl; } - switch ((*cit).font.color()) { + switch ((*cit).font().color()) { case LColor::none: case LColor::inherit: case LColor::ignore: @@ -364,11 +365,11 @@ void LyXParagraph::validate(LaTeXFeatures & features) const default: features.color = true; lyxerr[Debug::LATEX] << "Color enabled. Font: " - << (*cit).font.stateText(0) + << (*cit).font().stateText(0) << endl; } - Language const * language = (*cit).font.language(); + Language const * language = (*cit).font().language(); if (language->babel() != doc_language->babel()) { features.UsedLanguages.insert(language); lyxerr[Debug::LATEX] << "Found language " @@ -383,17 +384,17 @@ void LyXParagraph::validate(LaTeXFeatures & features) const (*cit).inset->Validate(features); } - if (pextra_type == PEXTRA_INDENT) + if (params.pextraType() == PEXTRA_INDENT) features.LyXParagraphIndent = true; - if (pextra_type == PEXTRA_FLOATFLT) + if (params.pextraType() == PEXTRA_FLOATFLT) features.floatflt = true; #ifndef NEW_INSETS if (layout.needprotect && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) features.NeedLyXFootnoteCode = true; #endif - if (params.paragraph_separation == BufferParams::PARSEP_INDENT - && pextra_type == LyXParagraph::PEXTRA_MINIPAGE) + if (bparams.paragraph_separation == BufferParams::PARSEP_INDENT + && params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) features.NeedLyXMinipageIndent = true; #ifndef NEW_INSETS if (footnoteflag != NO_FOOTNOTE && footnotekind == ALGORITHM) @@ -473,33 +474,10 @@ bool LyXParagraph::InsertFromMinibuffer(LyXParagraph::size_type pos) void LyXParagraph::Clear() { - line_top = false; - line_bottom = false; - - pagebreak_top = false; - pagebreak_bottom = false; - - added_space_top = VSpace(VSpace::NONE); - added_space_bottom = VSpace(VSpace::NONE); - spacing.set(Spacing::Default); + params.clear(); - align = LYX_ALIGN_LAYOUT; - depth = 0; - noindent = false; - - pextra_type = PEXTRA_NONE; - pextra_width.erase(); - pextra_widthp.erase(); - pextra_alignment = MINIPAGE_ALIGN_TOP; - pextra_hfill = false; - pextra_start_minipage = false; - - labelstring.erase(); - labelwidthstring.erase(); layout = 0; bibkey = 0; - - start_of_appendix = false; } @@ -566,9 +544,9 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos) lower_bound(fontlist.begin(), fontlist.end(), search_font, matchFT()); - if (it != fontlist.end() && (*it).pos == pos && + if (it != fontlist.end() && (*it).pos() == pos && (pos == 0 || - (it != fontlist.begin() && (*(it - 1)).pos == pos - 1))) { + (it != fontlist.begin() && (*(it - 1)).pos() == pos - 1))) { // If it is a multi-character font // entry, we just make it smaller // (see update below), otherwise we @@ -577,7 +555,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos) fontlist.erase(fontlist.begin() + i); it = fontlist.begin() + i; if (i > 0 && i < fontlist.size() && - fontlist[i - 1].font == fontlist[i].font) { + fontlist[i - 1].font() == fontlist[i].font()) { fontlist.erase(fontlist.begin() + i - 1); it = fontlist.begin() + i - 1; } @@ -586,7 +564,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos) // Update all other entries. FontList::iterator fend = fontlist.end(); for (; it != fend; ++it) - --(*it).pos; + (*it).pos((*it).pos() - 1); // Update the inset table. InsetTable search_inset(pos, 0); @@ -642,7 +620,7 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos, fontlist.end(), search_font, matchFT()); it != fontlist.end(); ++it) - ++(*it).pos; + (*it).pos((*it).pos() + 1); // Update the inset table. InsetTable search_inset(pos, 0); @@ -808,7 +786,7 @@ LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams, fontlist.end(), search_font, matchFT()); if (cit != fontlist.end()) - return (*cit).font; + return (*cit).font(); #ifndef NEW_INSETS } #endif @@ -851,7 +829,7 @@ LyXFont const LyXParagraph::GetFirstFontSettings() const { if (size() > 0) { if (!fontlist.empty()) - return fontlist[0].font; + return fontlist[0].font(); } #ifndef NEW_INSETS @@ -939,7 +917,7 @@ LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos, fontlist.end(), start_search, matchFT()); cit != end_it; ++cit) { - LyXFont::FONT_SIZE size = (*cit).font.size(); + LyXFont::FONT_SIZE size = (*cit).font().size(); if (size > maxsize && size <= LyXFont::SIZE_HUGER) maxsize = size; } @@ -1190,42 +1168,42 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos, unsigned int i = it - fontlist.begin(); bool notfound = it == fontlist.end(); - if (!notfound && fontlist[i].font == font) + if (!notfound && fontlist[i].font() == font) return; bool begin = pos == 0 || notfound || - (i > 0 && fontlist[i-1].pos == pos - 1); + (i > 0 && fontlist[i-1].pos() == pos - 1); // Is position pos is a beginning of a font block? - bool end = !notfound && fontlist[i].pos == pos; + bool end = !notfound && fontlist[i].pos() == pos; // Is position pos is the end of a font block? if (begin && end) { // A single char block if (i + 1 < fontlist.size() && - fontlist[i + 1].font == font) { + fontlist[i + 1].font() == font) { // Merge the singleton block with the next block fontlist.erase(fontlist.begin() + i); - if (i > 0 && fontlist[i - 1].font == font) + if (i > 0 && fontlist[i - 1].font() == font) fontlist.erase(fontlist.begin() + i-1); - } else if (i > 0 && fontlist[i - 1].font == font) { + } else if (i > 0 && fontlist[i - 1].font() == font) { // Merge the singleton block with the previous block - fontlist[i - 1].pos = pos; + fontlist[i - 1].pos(pos); fontlist.erase(fontlist.begin() + i); } else - fontlist[i].font = font; + fontlist[i].font(font); } else if (begin) { - if (i > 0 && fontlist[i - 1].font == font) - fontlist[i - 1].pos = pos; + if (i > 0 && fontlist[i - 1].font() == font) + fontlist[i - 1].pos(pos); else fontlist.insert(fontlist.begin() + i, FontTable(pos, font)); } else if (end) { - fontlist[i].pos = pos - 1; + fontlist[i].pos(pos - 1); if (!(i + 1 < fontlist.size() && - fontlist[i + 1].font == font)) + fontlist[i + 1].font() == font)) fontlist.insert(fontlist.begin() + i + 1, FontTable(pos, font)); } else { // The general case. The block is splitted into 3 blocks fontlist.insert(fontlist.begin() + i, - FontTable(pos - 1, fontlist[i].font)); + FontTable(pos - 1, fontlist[i].font())); fontlist.insert(fontlist.begin() + i + 1, FontTable(pos, font)); } @@ -1460,45 +1438,45 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, // layout stays the same with latex-environments if (flag) { tmp->SetOnlyLayout(bparams, firstpar->layout); - tmp->SetLabelWidthString(firstpar->labelwidthstring); + tmp->SetLabelWidthString(firstpar->params.labelWidthString()); } #else // layout stays the same with latex-environments if (flag) { tmp->SetOnlyLayout(bparams, layout); - tmp->SetLabelWidthString(labelwidthstring); + tmp->SetLabelWidthString(params.labelWidthString()); } #endif #ifndef NEW_INSETS if (Last() > pos || !Last() || flag == 2) { tmp->SetOnlyLayout(bparams, firstpar->layout); - tmp->align = firstpar->align; - tmp->SetLabelWidthString(firstpar->labelwidthstring); + tmp->params.align(firstpar->params.align()); + tmp->SetLabelWidthString(firstpar->params.labelWidthString()); - tmp->line_bottom = firstpar->line_bottom; - firstpar->line_bottom = false; - tmp->pagebreak_bottom = firstpar->pagebreak_bottom; - firstpar->pagebreak_bottom = false; - tmp->added_space_bottom = firstpar->added_space_bottom; - firstpar->added_space_bottom = VSpace(VSpace::NONE); + tmp->params.lineBottom(firstpar->params.lineBottom()); + firstpar->params.lineBottom(false); + tmp->params.pagebreakBottom(firstpar->params.pagebreakBottom()); + firstpar->params.pagebreakBottom(false); + tmp->params.spaceBottom(firstpar->params.spaceBottom()); + firstpar->params.spaceBottom(VSpace(VSpace::NONE)); - tmp->depth = firstpar->depth; - tmp->noindent = firstpar->noindent; + tmp->params.depth(firstpar->params.depth()); + tmp->params.noindent(firstpar->params.noindent()); #else if (Last() > pos || !Last() || flag == 2) { tmp->SetOnlyLayout(bparams, layout); - tmp->align = align; - tmp->SetLabelWidthString(labelwidthstring); + tmp->params.align(params.align()); + tmp->SetLabelWidthString(params.labelWidthString()); - tmp->line_bottom = line_bottom; - line_bottom = false; - tmp->pagebreak_bottom = pagebreak_bottom; - pagebreak_bottom = false; - tmp->added_space_bottom = added_space_bottom; - added_space_bottom = VSpace(VSpace::NONE); + tmp->params.lineBottom(params.lineBottom()); + params.lineBottom(false); + tmp->params.pagebreakBottom(params.pagebreakBottom()); + params.pagebreakBottom(false); + tmp->params.spaceBottom(params.spaceBottom()); + params.spaceBottom(VSpace(VSpace::NONE)); - tmp->depth = depth; - tmp->noindent = noindent; + tmp->params.depth(params.depth()); + tmp->params.noindent(params.noindent()); #endif // copy everything behind the break-position // to the new paragraph @@ -1540,31 +1518,31 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams, #ifndef NEW_INSETS // just an idea of me if (!pos) { - tmp->line_top = firstpar->line_top; - tmp->pagebreak_top = firstpar->pagebreak_top; - tmp->added_space_top = firstpar->added_space_top; + tmp->params.lineTop(firstpar->params.lineTop()); + tmp->params.pagebreakTop(firstpar->params.pagebreakTop()); + tmp->params.spaceTop(firstpar->params.spaceTop()); tmp->bibkey = firstpar->bibkey; firstpar->Clear(); // layout stays the same with latex-environments if (flag) { firstpar->SetOnlyLayout(bparams, tmp->layout); - firstpar->SetLabelWidthString(tmp->labelwidthstring); - firstpar->depth = tmp->depth; + firstpar->SetLabelWidthString(tmp->params.labelWidthString()); + firstpar->params.depth(tmp->params.depth()); } } #else // just an idea of me if (!pos) { - tmp->line_top = line_top; - tmp->pagebreak_top = pagebreak_top; - tmp->added_space_top = added_space_top; + tmp->params.lineTop(params.lineTop()); + tmp->params.pagebreakTop(params.pagebreakTop()); + tmp->params.spaceTop(params.spaceTop()); tmp->bibkey = bibkey; Clear(); // layout stays the same with latex-environments if (flag) { SetOnlyLayout(bparams, tmp->layout); - SetLabelWidthString(tmp->labelwidthstring); - depth = tmp->depth; + SetLabelWidthString(tmp->params.labelWidthString()); + params.depth(tmp->params.depth()); } } #endif @@ -1579,28 +1557,10 @@ void LyXParagraph::MakeSameLayout(LyXParagraph const * par) footnotekind = par->footnotekind; #endif layout = par->layout; - align = par-> align; - SetLabelWidthString(par->labelwidthstring); - - line_bottom = par->line_bottom; - pagebreak_bottom = par->pagebreak_bottom; - added_space_bottom = par->added_space_bottom; - - line_top = par->line_top; - pagebreak_top = par->pagebreak_top; - added_space_top = par->added_space_top; - - spacing = par->spacing; + params.makeSame(par->params); - pextra_type = par->pextra_type; - pextra_width = par->pextra_width; - pextra_widthp = par->pextra_widthp; - pextra_alignment = par->pextra_alignment; - pextra_hfill = par->pextra_hfill; - pextra_start_minipage = par->pextra_start_minipage; - - noindent = par->noindent; - depth = par->depth; + // This can be changed after NEW_INSETS is in effect. (Lgb) + SetLabelWidthString(par->params.labelWidthString()); } @@ -1682,33 +1642,13 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const par = par->FirstPhysicalPar(); #endif - return ( + return #ifndef NEW_INSETS par->footnoteflag == footnoteflag && par->footnotekind == footnotekind && #endif par->layout == layout && - - par->align == align && - - par->line_bottom == line_bottom && - par->pagebreak_bottom == pagebreak_bottom && - par->added_space_bottom == added_space_bottom && - - par->line_top == line_top && - par->pagebreak_top == pagebreak_top && - par->added_space_top == added_space_top && - - par->spacing == spacing && - - par->pextra_type == pextra_type && - par->pextra_width == pextra_width && - par->pextra_widthp == pextra_widthp && - par->pextra_alignment == pextra_alignment && - par->pextra_hfill == pextra_hfill && - par->pextra_start_minipage == pextra_start_minipage && - par->noindent == noindent && - par->depth == depth); + params.sameLayout(par->params); } @@ -1790,13 +1730,13 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams) // first the DTP-stuff #ifndef NEW_INSETS - firstpar->line_bottom = the_next->line_bottom; - firstpar->added_space_bottom = the_next->added_space_bottom; - firstpar->pagebreak_bottom = the_next->pagebreak_bottom; + firstpar->params.lineBottom(the_next->params.lineBottom()); + firstpar->params.spaceBottom(the_next->params.spaceBottom()); + firstpar->params.pagebreakBottom(the_next->params.pagebreakBottom()); #else - line_bottom = the_next->line_bottom; - added_space_bottom = the_next->added_space_bottom; - pagebreak_bottom = the_next->pagebreak_bottom; + params.lineBottom(the_next->params.lineBottom()); + params.spaceBottom(the_next->params.spaceBottom()); + params.pagebreakBottom(the_next->params.pagebreakBottom()); #endif size_type pos_end = the_next->text.size() - 1; @@ -1894,9 +1834,9 @@ LyXTextClass::size_type LyXParagraph::GetLayout() const char LyXParagraph::GetDepth() const { #ifndef NEW_INSETS - return FirstPhysicalPar()->depth; + return FirstPhysicalPar()->params.depth(); #else - return depth; + return params.depth(); #endif } @@ -1904,9 +1844,9 @@ char LyXParagraph::GetDepth() const char LyXParagraph::GetAlign() const { #ifndef NEW_INSETS - return FirstPhysicalPar()->align; + return FirstPhysicalPar()->params.align(); #else - return align; + return params.align(); #endif } @@ -1914,9 +1854,9 @@ char LyXParagraph::GetAlign() const string const & LyXParagraph::GetLabelstring() const { #ifndef NEW_INSETS - return FirstPhysicalPar()->labelstring; + return FirstPhysicalPar()->params.labelString(); #else - return labelstring; + return params.labelString(); #endif } @@ -1935,11 +1875,11 @@ int LyXParagraph::GetFirstCounter(int i) const string const LyXParagraph::GetLabelWidthString() const { #ifndef NEW_INSETS - if (!FirstPhysicalPar()->labelwidthstring.empty()) - return FirstPhysicalPar()->labelwidthstring; + if (!FirstPhysicalPar()->params.labelWidthString().empty()) + return FirstPhysicalPar()->params.labelWidthString(); #else - if (!labelwidthstring.empty()) - return labelwidthstring; + if (!params.labelWidthString().empty()) + return params.labelWidthString(); #endif else return _("Senseless with this layout!"); @@ -1951,9 +1891,9 @@ void LyXParagraph::SetLabelWidthString(string const & s) #ifndef NEW_INSETS LyXParagraph * par = FirstPhysicalPar(); - par->labelwidthstring = s; + par->params.labelWidthString(s); #else - labelwidthstring = s; + params.labelWidthString(s); #endif } @@ -1971,7 +1911,7 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams, par->layout = new_layout; - if (par->pextra_type == PEXTRA_NONE) { + if (par->params.pextraType() == PEXTRA_NONE) { if (par->Previous()) { #ifndef NEW_INSETS ppar = par->Previous()->FirstPhysicalPar(); @@ -1980,7 +1920,7 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams, #endif while(ppar && ppar->Previous() - && (ppar->depth > par->depth)) + && (ppar->params.depth() > par->params.depth())) #ifndef NEW_INSETS ppar = ppar->Previous()->FirstPhysicalPar(); #else @@ -1995,25 +1935,25 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams, #endif while(npar && npar->Next() - && (npar->depth > par->depth)) + && (npar->params.depth() > par->params.depth())) #ifndef NEW_INSETS npar = npar->Next()->NextAfterFootnote(); #else npar = npar->Next(); #endif } - if (ppar && (ppar->pextra_type != PEXTRA_NONE)) { - string - p1 = ppar->pextra_width, - p2 = ppar->pextra_widthp; - ppar->SetPExtraType(bparams, ppar->pextra_type, + if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) { + string p1 = ppar->params.pextraWidth(); + string p2 = ppar->params.pextraWidthp(); + ppar->SetPExtraType(bparams, + ppar->params.pextraType(), p1, p2); } - if ((par->pextra_type == PEXTRA_NONE) && - npar && (npar->pextra_type != PEXTRA_NONE)) { - string const p1 = npar->pextra_width; - string const p2 = npar->pextra_widthp; - npar->SetPExtraType(bparams, npar->pextra_type, + if ((par->params.pextraType() == PEXTRA_NONE) && + npar && (npar->params.pextraType() != PEXTRA_NONE)) { + string const p1 = npar->params.pextraWidth(); + string const p2 = npar->params.pextraWidthp(); + npar->SetPExtraType(bparams, npar->params.pextraType(), p1, p2); } } @@ -2033,13 +1973,13 @@ void LyXParagraph::SetLayout(BufferParams const & bparams, * npar = 0; par->layout = new_layout; - par->labelwidthstring.erase(); - par->align = LYX_ALIGN_LAYOUT; - par->added_space_top = VSpace(VSpace::NONE); - par->added_space_bottom = VSpace(VSpace::NONE); - par->spacing.set(Spacing::Default); + par->params.labelWidthString(string()); + par->params.align(LYX_ALIGN_LAYOUT); + par->params.spaceTop(VSpace(VSpace::NONE)); + par->params.spaceBottom(VSpace(VSpace::NONE)); + par->params.spacing(Spacing(Spacing::Default)); - if (par->pextra_type == PEXTRA_NONE) { + if (par->params.pextraType() == PEXTRA_NONE) { if (par->Previous()) { #ifndef NEW_INSETS ppar = par->Previous()->FirstPhysicalPar(); @@ -2048,7 +1988,7 @@ void LyXParagraph::SetLayout(BufferParams const & bparams, #endif while(ppar && ppar->Previous() - && (ppar->depth > par->depth)) + && (ppar->params.depth() > par->params.depth())) #ifndef NEW_INSETS ppar = ppar->Previous()->FirstPhysicalPar(); #else @@ -2063,24 +2003,24 @@ void LyXParagraph::SetLayout(BufferParams const & bparams, #endif while(npar && npar->Next() - && (npar->depth > par->depth)) + && (npar->params.depth() > par->params.depth())) #ifndef NEW_INSETS npar = npar->Next()->NextAfterFootnote(); #else npar = npar->Next(); #endif } - if (ppar && (ppar->pextra_type != PEXTRA_NONE)) { - string const p1 = ppar->pextra_width; - string const p2 = ppar->pextra_widthp; - ppar->SetPExtraType(bparams, ppar->pextra_type, + if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) { + string const p1 = ppar->params.pextraWidth(); + string const p2 = ppar->params.pextraWidthp(); + ppar->SetPExtraType(bparams, ppar->params.pextraType(), p1, p2); } - if ((par->pextra_type == PEXTRA_NONE) && - npar && (npar->pextra_type != PEXTRA_NONE)) { - string const p1 = npar->pextra_width; - string const p2 = npar->pextra_widthp; - npar->SetPExtraType(bparams, npar->pextra_type, + if ((par->params.pextraType() == PEXTRA_NONE) && + npar && (npar->params.pextraType() != PEXTRA_NONE)) { + string const p1 = npar->params.pextraWidth(); + string const p2 = npar->params.pextraWidthp(); + npar->SetPExtraType(bparams, npar->params.pextraType(), p1, p2); } } @@ -2277,14 +2217,14 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, lyxerr << "ERROR (LyXParagraph::TeXOnePar) is dummy." << endl; #endif - if (start_of_appendix) { + if (params.startOfAppendix()) { os << "\\appendix\n"; texrow.newline(); } - if (!spacing.isDefault() + if (!params.spacing().isDefault() && (!Previous() || !Previous()->HasSameLayout(this))) { - os << spacing.writeEnvirBegin() << "\n"; + os << params.spacing().writeEnvirBegin() << "\n"; texrow.newline(); } @@ -2293,16 +2233,16 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, texrow.newline(); } - if (pagebreak_top) { + if (params.pagebreakTop()) { os << "\\newpage"; further_blank_line = true; } - if (added_space_top.kind() != VSpace::NONE) { - os << added_space_top.asLatexCommand(bparams); + if (params.spaceTop().kind() != VSpace::NONE) { + os << params.spaceTop().asLatexCommand(bparams); further_blank_line = true; } - if (line_top) { + if (params.lineTop()) { os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}' << "\\vspace{-1\\parskip}"; further_blank_line = true; @@ -2438,7 +2378,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, switch (style.latextype) { case LATEX_ITEM_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT: - if (par && (depth < par->depth)) { + if (par && (params.depth() < par->params.depth())) { os << '\n'; texrow.newline(); } @@ -2448,8 +2388,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, // skip it otherwise fall through if (par && (par->layout != layout - || par->depth != depth - || par->pextra_type != pextra_type)) + || par->params.depth() != params.depth() + || par->params.pextraType() != params.pextraType())) break; default: // we don't need it for the last paragraph!!! @@ -2464,17 +2404,17 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, } further_blank_line = false; - if (line_bottom) { + if (params.lineBottom()) { os << "\\lyxline{\\" << getFont(bparams, Last() - 1).latexSize() << '}'; further_blank_line = true; } - if (added_space_bottom.kind() != VSpace::NONE) { - os << added_space_bottom.asLatexCommand(bparams); + if (params.spaceBottom().kind() != VSpace::NONE) { + os << params.spaceBottom().asLatexCommand(bparams); further_blank_line = true; } - if (pagebreak_bottom) { + if (params.pagebreakBottom()) { os << "\\newpage"; further_blank_line = true; } @@ -2484,9 +2424,9 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, texrow.newline(); } - if (!spacing.isDefault() + if (!params.spacing().isDefault() && (!par || !par->HasSameLayout(this))) { - os << spacing.writeEnvirEnd() << "\n"; + os << params.spacing().writeEnvirEnd() << "\n"; texrow.newline(); } @@ -2546,7 +2486,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, if (style.isCommand()) { os << '{'; ++column; - } else if (align != LYX_ALIGN_LAYOUT) { + } else if (params.align() != LYX_ALIGN_LAYOUT) { os << '{'; ++column; return_value = true; @@ -2583,7 +2523,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, if (style.isCommand()) { os << '{'; ++column; - } else if (align != LYX_ALIGN_LAYOUT && next) { + } else if (params.align() != LYX_ALIGN_LAYOUT && next) { // We do not need \par here (Dekel) // os << "{\\par"; os << "{"; @@ -2591,11 +2531,11 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, return_value = true; } - if (noindent) { + if (params.noindent()) { os << "\\noindent "; column += 10; } - switch (align) { + switch (params.align()) { case LYX_ALIGN_NONE: case LYX_ALIGN_BLOCK: case LYX_ALIGN_LAYOUT: @@ -2870,6 +2810,7 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf, if (inset) { bool close = false; int const len = os.tellp(); + //ostream::pos_type const len = os.tellp(); if ((inset->LyxCode() == Inset::GRAPHICS_CODE || inset->LyxCode() == Inset::MATH_CODE || inset->LyxCode() == Inset::URL_CODE) @@ -2887,7 +2828,7 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf, if (tmp) { column = 0; } else { - column += os.tellp() - len; + column += int(os.tellp()) - len; } for (; tmp--;) { texrow.newline(); @@ -3124,7 +3065,7 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf, LyXParagraph * par = this; while (par && - (par->depth == depth) + (par->params.depth() == params.depth()) #ifndef NEW_INSETS && (par->footnoteflag == footnoteflag) #endif @@ -3135,7 +3076,7 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf, #endif if (textclasslist.Style(bparams.textclass, par->layout).isEnvironment() - || par->pextra_type != PEXTRA_NONE) { + || par->params.pextraType() != PEXTRA_NONE) { par = par->TeXEnvironment(buf, bparams, os, texrow #ifndef NEW_INSETS @@ -3189,36 +3130,36 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, textclasslist.Style(bparams.textclass, layout); - if (pextra_type == PEXTRA_INDENT) { - if (!pextra_width.empty()) { + if (params.pextraType() == PEXTRA_INDENT) { + if (!params.pextraWidth().empty()) { os << "\\begin{LyXParagraphIndent}{" - << pextra_width << "}\n"; + << params.pextraWidth() << "}\n"; } else { //float ib = atof(pextra_widthp.c_str())/100; // string can't handle floats at present (971109) // so I'll do a conversion by hand knowing that // the limits are 0.0 to 1.0. ARRae. os << "\\begin{LyXParagraphIndent}{"; - switch (pextra_widthp.length()) { + switch (params.pextraWidthp().length()) { case 3: os << "1.00"; break; case 2: os << "0." - << pextra_widthp; + << params.pextraWidthp(); break; case 1: os << "0.0" - << pextra_widthp; + << params.pextraWidthp(); } os << "\\columnwidth}\n"; } texrow.newline(); eindent_open = true; } - if ((pextra_type == PEXTRA_MINIPAGE) && !minipage_open) { - if (pextra_hfill && Previous() && - (Previous()->pextra_type == PEXTRA_MINIPAGE)) { + if ((params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) { + if (params.pextraHfill() && Previous() && + (Previous()->params.pextraType() == PEXTRA_MINIPAGE)) { os << "\\hfill{}\n"; texrow.newline(); } @@ -3227,7 +3168,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, texrow.newline(); } os << "\\begin{minipage}"; - switch (pextra_alignment) { + switch (params.pextraAlignment()) { case MINIPAGE_ALIGN_TOP: os << "[t]"; break; @@ -3238,25 +3179,25 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, os << "[b]"; break; } - if (!pextra_width.empty()) { - os << '{' << pextra_width << "}\n"; + if (!params.pextraWidth().empty()) { + os << '{' << params.pextraWidth() << "}\n"; } else { //float ib = atof(par->pextra_width.c_str())/100; // string can't handle floats at present // so I'll do a conversion by hand knowing that // the limits are 0.0 to 1.0. ARRae. os << '{'; - switch (pextra_widthp.length()) { + switch (params.pextraWidthp().length()) { case 3: os << "1.00"; break; case 2: os << "0." - << pextra_widthp; + << params.pextraWidthp(); break; case 1: os << "0.0" - << pextra_widthp; + << params.pextraWidthp(); } os << "\\columnwidth}\n"; } @@ -3266,7 +3207,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, texrow.newline(); } minipage_open = true; - minipage_open_depth = depth; + minipage_open_depth = params.depth(); } #ifdef WITH_WARNINGS @@ -3285,7 +3226,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, } #endif os << "\\begin{" << style.latexname() << "}{" - << labelwidthstring << "}\n"; + << params.labelWidthString() << "}\n"; } else if (style.labeltype == LABEL_BIBLIO) { // ale970405 os << "\\begin{" << style.latexname() << "}{" @@ -3318,8 +3259,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, ); if (minipage_open && par && !style.isEnvironment() && - (par->pextra_type == PEXTRA_MINIPAGE) && - par->pextra_start_minipage) { + (par->params.pextraType() == PEXTRA_MINIPAGE) && + par->params.pextraStartMinipage()) { os << "\\end{minipage}\n"; texrow.newline(); if (par_sep == BufferParams::PARSEP_INDENT) { @@ -3328,7 +3269,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, } minipage_open = false; } - if (par && par->depth > depth) { + if (par && par->params.depth() > params.depth()) { if (textclasslist.Style(bparams.textclass, par->layout).isParagraph() // Thinko! @@ -3354,10 +3295,10 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, #endif ); } - if (par && par->layout == layout && par->depth == depth && - (par->pextra_type == PEXTRA_MINIPAGE) && !minipage_open) { - if (par->pextra_hfill && par->Previous() && - (par->Previous()->pextra_type == PEXTRA_MINIPAGE)){ + if (par && par->layout == layout && par->params.depth() == params.depth() && + (par->params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) { + if (par->params.pextraHfill() && par->Previous() && + (par->Previous()->params.pextraType() == PEXTRA_MINIPAGE)){ os << "\\hfill{}\n"; texrow.newline(); } @@ -3366,7 +3307,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, texrow.newline(); } os << "\\begin{minipage}"; - switch (par->pextra_alignment) { + switch (par->params.pextraAlignment()) { case MINIPAGE_ALIGN_TOP: os << "[t]"; break; @@ -3377,23 +3318,23 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, os << "[b]"; break; } - if (!par->pextra_width.empty()) { - os << '{' << par->pextra_width << "}\n"; + if (!par->params.pextraWidth().empty()) { + os << '{' << par->params.pextraWidth() << "}\n"; } else { //float ib = atof(par->pextra_widthp.c_str())/100; // string can't handle floats at present // so I'll do a conversion by hand knowing that // the limits are 0.0 to 1.0. ARRae. os << '{'; - switch (par->pextra_widthp.length()) { + switch (par->params.pextraWidthp().length()) { case 3: os << "1.00"; break; case 2: - os << "0." << par->pextra_widthp; + os << "0." << par->params.pextraWidthp(); break; case 1: - os << "0.0" << par->pextra_widthp; + os << "0.0" << par->params.pextraWidthp(); } os << "\\columnwidth}\n"; } @@ -3403,12 +3344,12 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, texrow.newline(); } minipage_open = true; - minipage_open_depth = par->depth; + minipage_open_depth = par->params.depth(); } } while (par && par->layout == layout - && par->depth == depth - && par->pextra_type == pextra_type + && par->params.depth() == params.depth() + && par->params.pextraType() == params.pextraType() #ifndef NEW_INSETS && par->footnoteflag == footnoteflag #endif @@ -3434,16 +3375,16 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, } #endif } - if (minipage_open && (minipage_open_depth == depth) && - (!par || par->pextra_start_minipage || - par->pextra_type != PEXTRA_MINIPAGE)) { + if (minipage_open && (minipage_open_depth == params.depth()) && + (!par || par->params.pextraStartMinipage() || + par->params.pextraType() != PEXTRA_MINIPAGE)) { os << "\\end{minipage}\n"; texrow.newline(); if (par_sep == BufferParams::PARSEP_INDENT) { os << "}\n"; texrow.newline(); } - if (par && par->pextra_type != PEXTRA_MINIPAGE) { + if (par && par->params.pextraType() != PEXTRA_MINIPAGE) { os << "\\medskip\n\n"; texrow.newline(); texrow.newline(); @@ -3454,8 +3395,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, os << "\\end{LyXParagraphIndent}\n"; texrow.newline(); } - if (!(par && (par->pextra_type == PEXTRA_MINIPAGE) - && par->pextra_hfill)) { + if (!(par && (par->params.pextraType() == PEXTRA_MINIPAGE) + && par->params.pextraHfill())) { os << '\n'; texrow.newline(); } @@ -3550,15 +3491,15 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, os << "\\marginpar{\n"; break; case LyXParagraph::FIG: - if (pextra_type == PEXTRA_FLOATFLT - && (!pextra_width.empty() - || !pextra_widthp.empty())) { - if (!pextra_width.empty()) + if (params.pextraType() == PEXTRA_FLOATFLT + && (!params.pextraWidth().empty() + || !params.pextraWidthp().empty())) { + if (!params.pextraWidth().empty()) os << "\\begin{floatingfigure}{" - << pextra_width << "}\n"; + << params.pextraWidth() << "}\n"; else os << "\\begin{floatingfigure}{" - << lyx::atoi(pextra_widthp) / 100.0 + << lyx::atoi(params.pextraWidthp()) / 100.0 << "\\textwidth}\n"; } else { os << "\\begin{figure}"; @@ -3610,7 +3551,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, lyxerr << "ERROR (LyXParagraph::TeXFootnote)" << endl; if (style.isEnvironment() - || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */ + || par->params.pextraType() == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */ // Allows the use of minipages within float // environments. Shouldn't be circular because // we don't support footnotes inside @@ -3626,7 +3567,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, foot_count); } - if (par && !par->IsDummy() && par->depth > depth) { + if (par && !par->IsDummy() && par->params.depth() > params.depth()) { par = par->TeXDeeper(buf, bparams, os, texrow, foot, foot_texrow, foot_count); @@ -3647,7 +3588,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, lyxerr << "ERROR (LyXParagraph::TeXFootnote)" << endl; if (style.isEnvironment() - || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */ + || par->params.pextraType() == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */ // Allows the use of minipages within float // environments. Shouldn't be circular because // we don't support footnotes inside @@ -3664,7 +3605,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, dummy_count); } - if (par && !par->IsDummy() && par->depth > depth) { + if (par && !par->IsDummy() && par->params.depth() > params.depth()) { par = par->TeXDeeper(buf, bparams, foot, foot_texrow, dummy, dummy_texrow, @@ -3694,9 +3635,9 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, os << '}'; break; case LyXParagraph::FIG: - if (pextra_type == PEXTRA_FLOATFLT - && (!pextra_width.empty() - || !pextra_widthp.empty())) + if (params.pextraType() == PEXTRA_FLOATFLT + && (!params.pextraWidth().empty() + || !params.pextraWidthp().empty())) os << "\\end{floatingfigure}"; else os << "\\end{figure}"; @@ -3743,9 +3684,9 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, int type, string const & width, string const & widthp) { - pextra_type = type; - pextra_width = width; - pextra_widthp = widthp; + params.pextraType(type); + params.pextraWidth(width); + params.pextraWidthp(widthp); if (textclasslist.Style(bparams.textclass, layout).isEnvironment()) { @@ -3753,14 +3694,14 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, LyXParagraph * ppar = par; while (par && (par->layout == layout) - && (par->depth == depth)) { + && (par->params.depth() == params.depth())) { ppar = par; par = par->Previous(); #ifndef NEW_INSETS if (par) par = par->FirstPhysicalPar(); #endif - while (par && par->depth > depth) { + while (par && par->params.depth() > params.depth()) { par = par->Previous(); #ifndef NEW_INSETS if (par) @@ -3770,23 +3711,23 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, } par = ppar; while (par && (par->layout == layout) - && (par->depth == depth)) { - par->pextra_type = type; - par->pextra_width = width; - par->pextra_widthp = widthp; + && (par->params.depth() == params.depth())) { + par->params.pextraType(type); + par->params.pextraWidth(width); + par->params.pextraWidthp(widthp); #ifndef NEW_INSETS par = par->NextAfterFootnote(); #else par = par->Next(); #endif - if (par && (par->depth > depth)) + if (par && (par->params.depth() > params.depth())) par->SetPExtraType(bparams, type, width, widthp); #ifndef NEW_INSETS - while (par && ((par->depth > depth) || par->IsDummy())) + while (par && ((par->params.depth() > params.depth()) || par->IsDummy())) par = par->NextAfterFootnote(); #else - while (par && ((par->depth > depth))) + while (par && par->params.depth() > params.depth()) par = par->Next(); #endif } @@ -3796,12 +3737,12 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) { - if (pextra_type == PEXTRA_NONE) + if (params.pextraType() == PEXTRA_NONE) return; - pextra_type = PEXTRA_NONE; - pextra_width.erase(); - pextra_widthp.erase(); + params.pextraType(PEXTRA_NONE); + params.pextraWidth(string()); + params.pextraWidthp(string()); if (textclasslist.Style(bparams.textclass, layout).isEnvironment()) { @@ -3809,14 +3750,14 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) LyXParagraph * ppar = par; while (par && (par->layout == layout) - && (par->depth == depth)) { + && (par->params.depth() == params.depth())) { ppar = par; par = par->Previous(); #ifndef NEW_INSETS if (par) par = par->FirstPhysicalPar(); #endif - while (par && par->depth > depth) { + while (par && par->params.depth() > params.depth()) { par = par->Previous(); #ifndef NEW_INSETS if (par) @@ -3826,22 +3767,22 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) } par = ppar; while (par && (par->layout == layout) - && (par->depth == depth)) { - par->pextra_type = PEXTRA_NONE; - par->pextra_width.erase(); - par->pextra_widthp.erase(); + && (par->params.depth() == params.depth())) { + par->params.pextraType(PEXTRA_NONE); + par->params.pextraWidth(string()); + par->params.pextraWidthp(string()); #ifndef NEW_INSETS par = par->NextAfterFootnote(); #else par = par->Next(); #endif - if (par && (par->depth > depth)) + if (par && (par->params.depth() > params.depth())) par->UnsetPExtraType(bparams); #ifndef NEW_INSETS - while (par && ((par->depth > depth) || par->IsDummy())) + while (par && ((par->params.depth() > params.depth()) || par->IsDummy())) par = par->NextAfterFootnote(); #else - while (par && ((par->depth > depth))) + while (par && par->params.depth() > params.depth()) par = par->Next(); #endif } @@ -3957,7 +3898,7 @@ bool LyXParagraph::isMultiLingual(BufferParams const & bparams) Language const * doc_language = bparams.language; for (FontList::const_iterator cit = fontlist.begin(); cit != fontlist.end(); ++cit) - if ((*cit).font.language() != doc_language) + if ((*cit).font().language() != doc_language) return true; return false; } @@ -3970,11 +3911,11 @@ string const LyXParagraph::String(Buffer const * buffer, bool label) BufferParams const & bparams = buffer->params; string s; #ifndef NEW_INSETS - if (label && !IsDummy() && !labelstring.empty()) + if (label && !IsDummy() && !params.labelString().empty()) #else - if (label && !labelstring.empty()) + if (label && !params.labelString().empty()) #endif - s += labelstring + ' '; + s += params.labelString() + ' '; string::size_type const len = s.size(); for (LyXParagraph::size_type i = 0; i < size(); ++i) { @@ -4012,11 +3953,11 @@ string const LyXParagraph::String(Buffer const * buffer, string s; #ifndef NEW_INSETS - if (beg == 0 && !IsDummy() && !labelstring.empty()) + if (beg == 0 && !IsDummy() && !params.labelString().empty()) #else - if (beg == 0 && !labelstring.empty()) + if (beg == 0 && !params.labelString().empty()) #endif - s += labelstring + ' '; + s += params.labelString() + ' '; for (LyXParagraph::size_type i = beg; i < end; ++i) { value_type c = GetUChar(buffer->params, i); diff --git a/src/text.C b/src/text.C index e60dfb18a5..590dd65429 100644 --- a/src/text.C +++ b/src/text.C @@ -727,17 +727,17 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const // a layout. Since there is always a redo, // LeftMargin() is always called #ifndef NEW_INSETS - row->par()->FirstPhysicalPar()->depth = 0; + row->par()->FirstPhysicalPar()->params.depth(0); #else - row->par()->depth = 0; + row->par()->params.depth(0); #endif } if (newpar && !row->par()->GetLayout()) { #ifndef NEW_INSETS - if (newpar->FirstPhysicalPar()->noindent) + if (newpar->FirstPhysicalPar()->params.noindent()) #else - if (newpar->noindent) + if (newpar->params.noindent()) #endif parindent.erase(); else @@ -837,12 +837,12 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const break; } if ((workWidth(bview) > 0) && - (row->par()->pextra_type == LyXParagraph::PEXTRA_INDENT)) { - if (!row->par()->pextra_widthp.empty()) { + (row->par()->params.pextraType() == LyXParagraph::PEXTRA_INDENT)) { + if (!row->par()->params.pextraWidthp().empty()) { x += workWidth(bview) * - lyx::atoi(row->par()->pextra_widthp) / 100; - } else if (!row->par()->pextra_width.empty()) { - int xx = VSpace(row->par()->pextra_width).inPixels(bview); + lyx::atoi(row->par()->params.pextraWidthp()) / 100; + } else if (!row->par()->params.pextraWidth().empty()) { + int xx = VSpace(row->par()->params.pextraWidth()).inPixels(bview); if (xx > workWidth(bview)) xx = workWidth(bview) * 80 / 100; x += xx; @@ -854,15 +854,15 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const int align; // wrong type #ifndef NEW_INSETS - if (row->par()->FirstPhysicalPar()->align == LYX_ALIGN_LAYOUT) + if (row->par()->FirstPhysicalPar()->params.align() == LYX_ALIGN_LAYOUT) align = layout.align; else - align = row->par()->FirstPhysicalPar()->align; + align = row->par()->FirstPhysicalPar()->params.align(); #else - if (row->par()->align == LYX_ALIGN_LAYOUT) + if (row->par()->params.align() == LYX_ALIGN_LAYOUT) align = layout.align; else - align = row->par()->align; + align = row->par()->params.align(); #endif // set the correct parindent if (row->pos() == 0) { @@ -876,7 +876,7 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const && row->par() == row->par()->FirstPhysicalPar() #endif && align == LYX_ALIGN_BLOCK - && !row->par()->noindent + && !row->par()->params.noindent() && (row->par()->layout || bview->buffer()->params.paragraph_separation == BufferParams::PARSEP_INDENT)) @@ -958,9 +958,9 @@ int LyXText::RightMargin(Buffer const * buf, Row const * row) const // a layout. Since there is always a redo, // LeftMargin() is always called #ifndef NEW_INSETS - row->par()->FirstPhysicalPar()->depth = 0; + row->par()->FirstPhysicalPar()->params.depth(0); #else - row->par()->depth = 0; + row->par()->params.depth(0); #endif } } @@ -1188,8 +1188,8 @@ int LyXText::LabelFill(BufferView * bview, Row const * row) const } int fill = 0; - if (!row->par()->labelwidthstring.empty()) { - fill = max(lyxfont::width(row->par()->labelwidthstring, + if (!row->par()->params.labelWidthString().empty()) { + fill = max(lyxfont::width(row->par()->params.labelWidthString(), GetFont(bview->buffer(), row->par(), -2)) - w, 0); } @@ -1341,8 +1341,8 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const LyXFont labelfont = GetFont(bview->buffer(), par, -2); float spacing_val = 1.0; - if (!row_ptr->par()->spacing.isDefault()) { - spacing_val = row_ptr->par()->spacing.getValue(); + if (!row_ptr->par()->params.spacing().isDefault()) { + spacing_val = row_ptr->par()->params.spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -1422,17 +1422,17 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const maxasc += LYX_PAPER_MARGIN; /* add the vertical spaces, that the user added */ - if (firstpar->added_space_top.kind() != VSpace::NONE) - maxasc += int(firstpar->added_space_top.inPixels(bview)); + if (firstpar->params.spaceTop().kind() != VSpace::NONE) + maxasc += int(firstpar->params.spaceTop().inPixels(bview)); /* do not forget the DTP-lines! * there height depends on the font of the nearest character */ - if (firstpar->line_top) + if (firstpar->params.lineTop()) maxasc += 2 * lyxfont::ascent('x', GetFont(bview->buffer(), firstpar, 0)); /* and now the pagebreaks */ - if (firstpar->pagebreak_top) + if (firstpar->params.pagebreakTop()) maxasc += 3 * DefaultHeight(); /* this is special code for the chapter, since the label of this @@ -1440,8 +1440,8 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const if (layout.labeltype == LABEL_COUNTER_CHAPTER && bview->buffer()->params.secnumdepth >= 0) { float spacing_val = 1.0; - if (!row_ptr->par()->spacing.isDefault()) { - spacing_val = row_ptr->par()->spacing.getValue(); + if (!row_ptr->par()->params.spacing().isDefault()) { + spacing_val = row_ptr->par()->params.spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -1461,8 +1461,8 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const && row_ptr->par()->IsFirstInSequence() && !row_ptr->par()->GetLabelstring().empty()) { float spacing_val = 1.0; - if (!row_ptr->par()->spacing.isDefault()) { - spacing_val = row_ptr->par()->spacing.getValue(); + if (!row_ptr->par()->params.spacing().isDefault()) { + spacing_val = row_ptr->par()->params.spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -1481,7 +1481,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const /* and now the layout spaces, for example before and after a section, * or between the items of a itemize or enumerate environment */ - if (!firstpar->pagebreak_top) { + if (!firstpar->params.pagebreakTop()) { LyXParagraph * prev = row_ptr->par()->Previous(); if (prev) prev = row_ptr->par()->DepthHook(row_ptr->par()->GetDepth()); @@ -1502,7 +1502,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const if (tmptop > 0) layoutasc = (tmptop * DefaultHeight()); } - else if (row_ptr->par()->line_top){ + else if (row_ptr->par()->params.lineTop()) { tmptop = layout.topsep; if (tmptop > 0) @@ -1541,22 +1541,22 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const maxdesc += LYX_PAPER_MARGIN; /* add the vertical spaces, that the user added */ - if (firstpar->added_space_bottom.kind() != VSpace::NONE) - maxdesc += int(firstpar->added_space_bottom.inPixels(bview)); + if (firstpar->params.spaceBottom().kind() != VSpace::NONE) + maxdesc += int(firstpar->params.spaceBottom().inPixels(bview)); /* do not forget the DTP-lines! * there height depends on the font of the nearest character */ - if (firstpar->line_bottom) + if (firstpar->params.lineBottom()) maxdesc += 2 * lyxfont::ascent('x', GetFont(bview->buffer(), par, par->Last() - 1)); /* and now the pagebreaks */ - if (firstpar->pagebreak_bottom) + if (firstpar->params.pagebreakBottom()) maxdesc += 3 * DefaultHeight(); /* and now the layout spaces, for example before and after a section, * or between the items of a itemize or enumerate environment */ - if (!firstpar->pagebreak_bottom && row_ptr->par()->Next()) { + if (!firstpar->params.pagebreakBottom() && row_ptr->par()->Next()) { LyXParagraph * nextpar = row_ptr->par()->Next(); LyXParagraph * comparepar = row_ptr->par(); float usual = 0; @@ -2241,15 +2241,15 @@ void LyXText::PrepareToPrint(BufferView * bview, // set x how you need it int align; #ifndef NEW_INSETS - if (row->par()->FirstPhysicalPar()->align == LYX_ALIGN_LAYOUT) + if (row->par()->FirstPhysicalPar()->params.align() == LYX_ALIGN_LAYOUT) align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->GetLayout()).align; else - align = row->par()->FirstPhysicalPar()->align; + align = row->par()->FirstPhysicalPar()->params.align(); #else - if (row->par()->align == LYX_ALIGN_LAYOUT) + if (row->par()->params.align() == LYX_ALIGN_LAYOUT) align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->GetLayout()).align; else - align = row->par()->align; + align = row->par()->params.align(); #endif // center displayed insets @@ -2734,11 +2734,11 @@ void LyXText::Backspace(BufferView * bview) && cursor.par()->footnoteflag == tmppar->footnoteflag #endif && cursor.par()->GetAlign() == tmppar->GetAlign()) { - // Inherit botom DTD from the paragraph below. + // Inherit bottom DTD from the paragraph below. // (the one we are deleting) - tmppar->line_bottom = cursor.par()->line_bottom; - tmppar->added_space_bottom = cursor.par()->added_space_bottom; - tmppar->pagebreak_bottom = cursor.par()->pagebreak_bottom; + tmppar->params.lineBottom(cursor.par()->params.lineBottom()); + tmppar->params.spaceBottom(cursor.par()->params.spaceBottom()); + tmppar->params.pagebreakBottom(cursor.par()->params.pagebreakBottom()); } CursorLeft(bview); @@ -3322,7 +3322,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, // Draw appendix lines LyXParagraph * p = row_ptr->par()->PreviousBeforeFootnote()->FirstPhysicalPar(); - if (p->appendix){ + if (p->params.appendix()) { pain.line(1, y_offset, 1, y_offset + row_ptr->height(), LColor::appendixline); @@ -3334,7 +3334,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, // Draw minipage line bool const minipage = - (p->pextra_type == LyXParagraph::PEXTRA_MINIPAGE); + (p->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE); if (minipage) pain.line(LYX_PAPER_MARGIN/5, y_offset, LYX_PAPER_MARGIN/5, @@ -3370,7 +3370,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, #else LyXParagraph * firstpar = row_ptr->par(); #endif - if (firstpar->appendix){ + if (firstpar->params.appendix()) { pain.line(1, y_offset, 1, y_offset + row_ptr->height(), LColor::appendixline); @@ -3381,7 +3381,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, // Draw minipage line bool const minipage = - (firstpar->pextra_type == LyXParagraph::PEXTRA_MINIPAGE); + (firstpar->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE); if (minipage) pain.line(LYX_PAPER_MARGIN/5 + box_x, y_offset, LYX_PAPER_MARGIN/5 + box_x, @@ -3444,7 +3444,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, if (!row_ptr->pos() && (row_ptr->par() == firstpar)) { /* start of appendix? */ - if (row_ptr->par()->start_of_appendix){ + if (row_ptr->par()->params.startOfAppendix()) { pain.line(1, y_offset, ww - 2, y_offset, LColor::appendixline); @@ -3454,7 +3454,8 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, if (!row_ptr->previous() && bv_owner) y_top += LYX_PAPER_MARGIN; - if (row_ptr->par()->pagebreak_top){ /* draw a top pagebreak */ + /* draw a top pagebreak */ + if (row_ptr->par()->params.pagebreakTop()) { LyXFont pb_font; pb_font.setColor(LColor::pagebreak).decSize(); int w = 0, a = 0, d = 0; @@ -3478,7 +3479,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, y_top += 3 * DefaultHeight(); } - if (row_ptr->par()->added_space_top.kind() == VSpace::VFILL) { + if (row_ptr->par()->params.spaceTop().kind() == VSpace::VFILL) { /* draw a vfill top */ pain.line(0, y_offset + 2 + y_top, LYX_PAPER_MARGIN, y_offset + 2 + y_top, @@ -3498,7 +3499,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } /* think about user added space */ - y_top += int(row_ptr->par()->added_space_top.inPixels(bview)); + y_top += int(row_ptr->par()->params.spaceTop().inPixels(bview)); /* think about the parskip */ /* some parskips VERY EASY IMPLEMENTATION */ @@ -3515,7 +3516,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, y_top += bview->buffer()->params.getDefSkip().inPixels(bview); } - if (row_ptr->par()->line_top) { /* draw a top line */ + if (row_ptr->par()->params.lineTop()) { /* draw a top line */ y_top += lyxfont::ascent('x', GetFont(bview->buffer(), row_ptr->par(), 0)); @@ -3548,8 +3549,8 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, /* this is special code for the chapter layout. This is printed in * an extra row and has a pagebreak at the top. */ float spacing_val = 1.0; - if (!row_ptr->par()->spacing.isDefault()) { - spacing_val = row_ptr->par()->spacing.getValue(); + if (!row_ptr->par()->params.spacing().isDefault()) { + spacing_val = row_ptr->par()->params.spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -3595,8 +3596,8 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, string const tmpstring = row_ptr->par()->GetLabelstring(); float spacing_val = 1.0; - if (!row_ptr->par()->spacing.isDefault()) { - spacing_val = row_ptr->par()->spacing.getValue(); + if (!row_ptr->par()->params.spacing().isDefault()) { + spacing_val = row_ptr->par()->params.spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -3653,7 +3654,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, y_bottom -= LYX_PAPER_MARGIN; /* draw a bottom pagebreak */ - if (firstpar->pagebreak_bottom) { + if (firstpar->params.pagebreakBottom()) { LyXFont pb_font; pb_font.setColor(LColor::pagebreak).decSize(); int w = 0, a = 0, d = 0; @@ -3678,7 +3679,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, y_bottom -= 3 * DefaultHeight(); } - if (firstpar->added_space_bottom.kind() == VSpace::VFILL) { + if (firstpar->params.spaceBottom().kind() == VSpace::VFILL) { /* draw a vfill bottom */ pain.line(0, y_offset + y_bottom - 3 * DefaultHeight(), LYX_PAPER_MARGIN, @@ -3697,9 +3698,9 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } /* think about user added space */ - y_bottom -= int(firstpar->added_space_bottom.inPixels(bview)); + y_bottom -= int(firstpar->params.spaceBottom().inPixels(bview)); - if (firstpar->line_bottom) { + if (firstpar->params.lineBottom()) { /* draw a bottom line */ y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(), par, par->Last() - 1)); @@ -3971,7 +3972,7 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, } /* no marginpars in minipages */ if (kind == LyXParagraph::MARGIN - && cursor.par()->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) { + && cursor.par()->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) { WriteAlert(_("Impossible operation"), _("You can't insert a marginpar in a minipage!"), _("Sorry.")); diff --git a/src/text2.C b/src/text2.C index 0614935ef1..6dac6a12ba 100644 --- a/src/text2.C +++ b/src/text2.C @@ -590,10 +590,10 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview, #else LyXParagraph * fppar = cur.par(); #endif - fppar->added_space_top = lyxlayout.fill_top ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); - fppar->added_space_bottom = lyxlayout.fill_bottom ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); + fppar->params.spaceTop(lyxlayout.fill_top ? + VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); + fppar->params.spaceBottom(lyxlayout.fill_bottom ? + VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); if (lyxlayout.margintype == MARGIN_MANUAL) cur.par()->SetLabelWidthString(lyxlayout.labelstring()); if (lyxlayout.labeltype != LABEL_BIBLIO @@ -616,10 +616,10 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview, #else LyXParagraph * fppar = cur.par(); #endif - fppar->added_space_top = lyxlayout.fill_top ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); - fppar->added_space_bottom = lyxlayout.fill_bottom ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); + fppar->params.spaceTop(lyxlayout.fill_top ? + VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); + fppar->params.spaceBottom(lyxlayout.fill_bottom ? + VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); if (lyxlayout.margintype == MARGIN_MANUAL) cur.par()->SetLabelWidthString(lyxlayout.labelstring()); if (lyxlayout.labeltype != LABEL_BIBLIO @@ -735,9 +735,9 @@ void LyXText::IncDepth(BufferView * bview) && textclasslist.Style(bview->buffer()->params.textclass, prev->GetLayout()).isEnvironment()))) { #ifndef NEW_INSETS - cursor.par()->FirstPhysicalPar()->depth++; + cursor.par()->FirstPhysicalPar()->params.depth(cursor.par()->FirstPhysicalPar()->params.depth() + 1); #else - cursor.par()->depth++; + cursor.par()->params.depth(cursor.par()->params.depth() + 1); #endif anything_changed = true; } @@ -752,17 +752,17 @@ void LyXText::IncDepth(BufferView * bview) cursor = sel_start_cursor; while (cursor.par() != sel_end_cursor.par()) { #ifndef NEW_INSETS - cursor.par()->FirstPhysicalPar()->depth = 0; + cursor.par()->FirstPhysicalPar()->params.depth(0); #else - cursor.par()->depth = 0; + cursor.par()->params.depth(0); #endif cursor.par(cursor.par()->Next()); } #ifndef NEW_INSETS if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag) - cursor.par()->FirstPhysicalPar()->depth = 0; + cursor.par()->FirstPhysicalPar()->params.depth(0); #else - cursor.par()->depth = 0; + cursor.par()->params.depth(0); #endif } @@ -831,12 +831,12 @@ void LyXText::DecDepth(BufferView * bview) #ifndef NEW_INSETS if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag) { - if (cursor.par()->FirstPhysicalPar()->depth) - cursor.par()->FirstPhysicalPar()->depth--; + if (cursor.par()->FirstPhysicalPar()->params.depth()) + cursor.par()->FirstPhysicalPar()->params.depth(cursor.par()->FirstPhysicalPar()->params.depth() - 1); } #else - if (cursor.par()->depth) - cursor.par()->depth--; + if (cursor.par()->params.depth()) + cursor.par()->params.depth(cursor.par()->params.depth() - 1); #endif if (cursor.par() == sel_end_cursor.par()) break; @@ -1208,7 +1208,7 @@ string const LyXText::selectionAsString(Buffer const * buffer) const } -void LyXText::ClearSelection(BufferView * bview) const +void LyXText::ClearSelection(BufferView * /*bview*/) const { selection = false; mark_set = false; @@ -1484,12 +1484,12 @@ void LyXText::SetParagraph(BufferView * bview, if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag) { #endif - cursor.par()->line_top = line_top; - cursor.par()->line_bottom = line_bottom; - cursor.par()->pagebreak_top = pagebreak_top; - cursor.par()->pagebreak_bottom = pagebreak_bottom; - cursor.par()->added_space_top = space_top; - cursor.par()->added_space_bottom = space_bottom; + cursor.par()->params.lineTop(line_top); + cursor.par()->params.lineBottom(line_bottom); + cursor.par()->params.pagebreakTop(pagebreak_top); + cursor.par()->params.pagebreakBottom(pagebreak_bottom); + cursor.par()->params.spaceTop(space_top); + cursor.par()->params.spaceBottom(space_bottom); // does the layout allow the new alignment? if (align == LYX_ALIGN_LAYOUT) align = textclasslist @@ -1501,12 +1501,12 @@ void LyXText::SetParagraph(BufferView * bview, if (align == textclasslist .Style(bview->buffer()->params.textclass, cursor.par()->GetLayout()).align) - cursor.par()->align = LYX_ALIGN_LAYOUT; + cursor.par()->params.align(LYX_ALIGN_LAYOUT); else - cursor.par()->align = align; + cursor.par()->params.align(align); } cursor.par()->SetLabelWidthString(labelwidthstring); - cursor.par()->noindent = noindent; + cursor.par()->params.noindent(noindent); #ifndef NEW_INSETS } @@ -1589,16 +1589,16 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type, sel_start_cursor.par()->footnoteflag) { #endif if (type == LyXParagraph::PEXTRA_NONE) { - if (cursor.par()->pextra_type != LyXParagraph::PEXTRA_NONE) { + if (cursor.par()->params.pextraType() != LyXParagraph::PEXTRA_NONE) { cursor.par()->UnsetPExtraType(bview->buffer()->params); - cursor.par()->pextra_type = LyXParagraph::PEXTRA_NONE; + cursor.par()->params.pextraType(LyXParagraph::PEXTRA_NONE); } } else { cursor.par()->SetPExtraType(bview->buffer()->params, type, width, widthp); - cursor.par()->pextra_hfill = hfill; - cursor.par()->pextra_start_minipage = start_minipage; - cursor.par()->pextra_alignment = alignment; + cursor.par()->params.pextraHfill(hfill); + cursor.par()->params.pextraStartMinipage(start_minipage); + cursor.par()->params.pextraAlignment(alignment); } #ifndef NEW_INSETS } @@ -1697,12 +1697,12 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const par->setCounter(i, par->Previous()->GetFirstCounter(i)); } #ifndef NEW_INSETS - par->appendix = par->Previous()->FirstPhysicalPar()->appendix; + par->params.appendix(par->Previous()->FirstPhysicalPar()->params.appendix()); #else - par->appendix = par->Previous()->appendix; + par->params.appendix(par->Previous()->params.appendix()); #endif - if (!par->appendix && par->start_of_appendix){ - par->appendix = true; + if (!par->params.appendix() && par->params.startOfAppendix()) { + par->params.appendix(true); for (int i = 0; i < 10; ++i) { par->setCounter(i, 0); } @@ -1718,7 +1718,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const for (int i = 0; i < 10; ++i) { par->setCounter(i, 0); } - par->appendix = par->start_of_appendix; + par->params.appendix(par->params.startOfAppendix()); par->enumdepth = 0; par->itemdepth = 0; } @@ -1787,12 +1787,12 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const par->setCounter(i, 0); } - if (!par->labelstring.empty()) { - par->labelstring.erase(); + if (!par->params.labelString().empty()) { + par->params.labelString(string()); } if (layout.margintype == MARGIN_MANUAL) { - if (par->labelwidthstring.empty()) { + if (par->params.labelWidthString().empty()) { par->SetLabelWidthString(layout.labelstring()); } } else { @@ -1807,21 +1807,21 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const par->incCounter(i); // increment the counter // Is there a label? Useful for Chapter layout - if (!par->appendix){ + if (!par->params.appendix()) { if (!layout.labelstring().empty()) - par->labelstring = layout.labelstring(); + par->params.labelString(layout.labelstring()); else - par->labelstring.erase(); + par->params.labelString(string()); } else { if (!layout.labelstring_appendix().empty()) - par->labelstring = layout.labelstring_appendix(); + par->params.labelString(layout.labelstring_appendix()); else - par->labelstring.erase(); + par->params.labelString(string()); } std::ostringstream s; - if (!par->appendix) { + if (!par->params.appendix()) { switch (2 * LABEL_COUNTER_CHAPTER - textclass.maxcounter() + i) { case LABEL_COUNTER_CHAPTER: @@ -1944,7 +1944,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const } } - par->labelstring += s.str().c_str(); + par->params.labelString(par->params.labelString() +s.str().c_str()); // We really want to remove the c_str as soon as // possible... @@ -1996,7 +1996,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const break; } - par->labelstring = s.str().c_str(); + par->params.labelString(s.str().c_str()); // we really want to get rid of that c_str() for (i += par->enumdepth + 1; i < 10; ++i) @@ -2012,7 +2012,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const par->bibkey = new InsetBibKey(p); } par->bibkey->setCounter(number); - par->labelstring = layout.labelstring(); + par->params.labelString(layout.labelstring()); // In biblio should't be following counters but... } else { @@ -2052,7 +2052,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const ? " :úåòîùî øñç" : "Senseless: "; } } - par->labelstring = s; + par->params.labelString(s); /* reset the enumeration counter. They are always resetted * when there is any other layout between */ @@ -3503,13 +3503,13 @@ void LyXText::toggleAppendix(BufferView * bview) #else LyXParagraph * par = cursor.par(); #endif - bool start = !par->start_of_appendix; + bool start = !par->params.startOfAppendix(); // ensure that we have only one start_of_appendix in this document LyXParagraph * tmp = FirstParagraph(); for (; tmp; tmp = tmp->next) - tmp->start_of_appendix = 0; - par->start_of_appendix = start; + tmp->params.startOfAppendix(false); + par->params.startOfAppendix(start); // we can set the refreshing parameters now status = LyXText::NEED_MORE_REFRESH;