]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
Applied Angus patch to compile on DEC C++ and to avoid name clashes
[lyx.git] / src / paragraph.C
index b342451b87b11db1f2915f563372a7c5421bb6ea..7b04bddeb6471e55091a792188c87f3d3e0fd8be 100644 (file)
@@ -55,9 +55,14 @@ int tex_code_break_column = 72;  // needs non-zero initialization. set later.
 extern string bibitemWidest(Buffer const *);
 
 // this is a minibuffer
-static char minibuffer_char;
-static LyXFont minibuffer_font;
-static Inset * minibuffer_inset;
+
+namespace {
+
+char minibuffer_char;
+LyXFont minibuffer_font;
+Inset * minibuffer_inset;
+
+} // namespace anon
 
 
 extern BufferView * current_view;
@@ -124,14 +129,9 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                             char footflag, char dth) const
 {
 #ifndef NEW_INSETS
-       if (
-               footnoteflag != LyXParagraph::NO_FOOTNOTE ||
+       if (footnoteflag != LyXParagraph::NO_FOOTNOTE ||
            !previous_
-           || previous_->footnoteflag == LyXParagraph::NO_FOOTNOTE
-               ) {
-#endif
-               
-#ifndef NEW_INSETS
+           || previous_->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
                // The beginning or the end of a footnote environment?
                if (footflag != footnoteflag) {
                        footflag = footnoteflag;
@@ -211,6 +211,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                        }
                        os << "\\align " << string_align[h] << " ";
                }
+#ifndef NO_PEXTRA
                 if (params.pextraType() != PEXTRA_NONE) {
                         os << "\\pextra_type " << params.pextraType();
                         if (params.pextraType() == PEXTRA_MINIPAGE) {
@@ -232,6 +233,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                         }
                        os << '\n';
                 }
+#endif
 #ifndef NEW_INSETS
        } else {
                // Dummy layout. This means that a footnote ended.
@@ -384,18 +386,22 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
                        (*cit).inset->Validate(features);
        }
 
+#ifndef NO_PEXTRA
         if (params.pextraType() == PEXTRA_INDENT)
                 features.LyXParagraphIndent = true;
         if (params.pextraType() == PEXTRA_FLOATFLT)
                 features.floatflt = true;
+#endif
 #ifndef NEW_INSETS
         if (layout.needprotect 
            && next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                features.NeedLyXFootnoteCode = true;
 #endif
+#ifndef NO_PEXTRA
         if (bparams.paragraph_separation == BufferParams::PARSEP_INDENT
             && params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE)
                features.NeedLyXMinipageIndent = true;
+#endif
 #ifndef NEW_INSETS
        if (footnoteflag != NO_FOOTNOTE && footnotekind == ALGORITHM)
                features.algorithm = true;
@@ -1075,20 +1081,17 @@ string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
 }
 
 
-#ifdef NEW_INSETS
-#warning Remember to get rid of this one. (Lgb)
-#endif
+#ifndef NEW_INSETS
 LyXParagraph::size_type LyXParagraph::Last() const
 {
-#ifndef NEW_INSETS
        if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
                return text.size() + NextAfterFootnote()->Last() + 1;
        // the 1 is the symbol
        // for the footnote
        else
-#endif
                return text.size();
 }
+#endif
 
 
 #ifndef NEW_INSETS
@@ -1496,7 +1499,7 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
                tmp->params.depth(firstpar->params.depth());
                tmp->params.noindent(firstpar->params.noindent());
 #else
-       if (Last() > pos || !Last() || flag == 2) {
+       if (size() > pos || !size() || flag == 2) {
                tmp->SetOnlyLayout(bparams, layout);
                tmp->params.align(params.align());
                tmp->SetLabelWidthString(params.labelWidthString());
@@ -1624,8 +1627,10 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
        int i = 0;
 #ifndef NEW_INSETS
        if (!IsDummy()) {
-#endif
                while (Last()
+#else
+               while (size()
+#endif
                       && (IsNewline(0) || IsLineSeparator(0))){
                        Erase(0);
                        ++i;
@@ -1727,7 +1732,7 @@ void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams,
 
        // When can pos > Last()?
        // I guess pos == Last() is possible.
-       if (Last() > pos) {
+       if (size() > pos) {
                // copy everything behind the break-position to the new
                // paragraph
                size_type pos_end = text.size() - 1;
@@ -1757,23 +1762,24 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams)
 {
        // copy the next paragraph to this one
        LyXParagraph * the_next = next();
-#ifndef NEW_INSETS   
-       LyXParagraph * firstpar = FirstPhysicalPar();
-#endif
    
        // first the DTP-stuff
 #ifndef NEW_INSETS
+       LyXParagraph * firstpar = FirstPhysicalPar();
        firstpar->params.lineBottom(the_next->params.lineBottom());
        firstpar->params.spaceBottom(the_next->params.spaceBottom());
        firstpar->params.pagebreakBottom(the_next->params.pagebreakBottom());
+
+       size_type pos_end = the_next->text.size() - 1;
+       size_type pos_insert = Last();
 #else
        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;
-       size_type pos_insert = Last();
+       size_type pos_insert = size();
+#endif
 
        // ok, now copy the paragraph
        size_type i, j;
@@ -1944,7 +1950,9 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams,
 
        par->layout = new_layout;
 
+#ifndef NO_PEXTRA
         if (par->params.pextraType() == PEXTRA_NONE) {
+#endif
                 if (par->previous()) {
 #ifndef NEW_INSETS
                         ppar = par->previous()->FirstPhysicalPar();
@@ -1975,6 +1983,7 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams,
                        npar = npar->next();
 #endif
                 }
+#ifndef NO_PEXTRA
                 if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) {
                         string p1 = ppar->params.pextraWidth();
                        string p2 = ppar->params.pextraWidthp();
@@ -1990,6 +1999,7 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams,
                                             p1, p2);
                 }
         }
+#endif
 }
 
 
@@ -2012,7 +2022,9 @@ void LyXParagraph::SetLayout(BufferParams const & bparams,
        par->params.spaceBottom(VSpace(VSpace::NONE));
        par->params.spacing(Spacing(Spacing::Default));
 
+#ifndef NO_PEXTRA
         if (par->params.pextraType() == PEXTRA_NONE) {
+#endif
                 if (par->previous()) {
 #ifndef NEW_INSETS
                         ppar = par->previous()->FirstPhysicalPar();
@@ -2043,6 +2055,7 @@ void LyXParagraph::SetLayout(BufferParams const & bparams,
                        npar = npar->next();
 #endif
                 }
+#ifndef NO_PEXTRA
                 if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) {
                         string const p1 = ppar->params.pextraWidth();
                        string const p2 = ppar->params.pextraWidthp();
@@ -2057,6 +2070,7 @@ void LyXParagraph::SetLayout(BufferParams const & bparams,
                                             p1, p2);
                 }
         }
+#endif
 }
 
 
@@ -2385,7 +2399,11 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
        // Is this really needed ? (Dekel)
        // We do not need to use to change the font for the last paragraph
        // or for a command.
+#ifndef NEW_INSETS
        LyXFont font = getFont(bparams, Last() - 1);
+#else
+       LyXFont font = getFont(bparams, size() - 1);
+#endif
        bool is_command = textclasslist.Style(bparams.textclass,
                                              GetLayout()).isCommand();
        if (style.resfont.size() != font.size() && next_ && !is_command) {
@@ -2422,7 +2440,10 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                if (par
                    && (par->layout != layout
                        || par->params.depth() != params.depth()
-                       || par->params.pextraType() != params.pextraType()))
+#ifndef NO_PEXTRA
+                       || par->params.pextraType() != params.pextraType()
+#endif
+                           ))
                        break;
        default:
                // we don't need it for the last paragraph!!!
@@ -2438,7 +2459,13 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
        
        further_blank_line = false;
        if (params.lineBottom()) {
-               os << "\\lyxline{\\" << getFont(bparams, Last() - 1).latexSize() << '}';
+#ifndef NEW_INSETS
+               os << "\\lyxline{\\" << getFont(bparams,
+                                               Last() - 1).latexSize() << '}';
+#else
+               os << "\\lyxline{\\" << getFont(bparams,
+                                               size() - 1).latexSize() << '}';
+#endif
                further_blank_line = true;
        }
 
@@ -3109,7 +3136,10 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf,
 #endif
                if (textclasslist.Style(bparams.textclass, 
                                        par->layout).isEnvironment()
-                   || par->params.pextraType() != PEXTRA_NONE) {
+#ifndef NO_PEXTRA
+                   || par->params.pextraType() != PEXTRA_NONE
+#endif
+                       ) {
                        par = par->TeXEnvironment(buf, bparams,
                                                  os, texrow
 #ifndef NEW_INSETS
@@ -3144,14 +3174,18 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
 #endif
        )
 {
+#ifndef NO_PEXTRA
        bool eindent_open = false;
+#endif
 #ifndef NEW_INSETS
        bool foot_this_level = false;
 #endif
+#ifndef NO_PEXTRA
        // flags when footnotetext should be appended to file.
         static bool minipage_open = false;
         static int minipage_open_depth = 0;
        char par_sep = bparams.paragraph_separation;
+#endif
     
        lyxerr[Debug::LATEX] << "TeXEnvironment...     " << this << endl;
 #ifndef NEW_INSETS
@@ -3162,7 +3196,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
        LyXLayout const & style =
                textclasslist.Style(bparams.textclass,
                                    layout);
-       
+
+#ifndef NO_PEXTRA
        if (params.pextraType() == PEXTRA_INDENT) {
                if (!params.pextraWidth().empty()) {
                        os << "\\begin{LyXParagraphIndent}{"
@@ -3242,7 +3277,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                minipage_open = true;
                 minipage_open_depth = params.depth();
        }
-
+#endif
 #ifdef WITH_WARNINGS
 #warning Define FANCY_FOOTNOTE_CODE to re-enable Allan footnote code
        //I disabled it because it breaks when lists span on several
@@ -3290,7 +3325,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                                     foot, foot_texrow, foot_count
 #endif
                        );
-
+#ifndef NO_PEXTRA
                 if (minipage_open && par && !style.isEnvironment() &&
                     (par->params.pextraType() == PEXTRA_MINIPAGE) &&
                     par->params.pextraStartMinipage()) {
@@ -3302,6 +3337,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        }
                        minipage_open = false;
                 }
+#endif
                if (par && par->params.depth() > params.depth()) {
                        if (textclasslist.Style(bparams.textclass,
                                                par->layout).isParagraph()
@@ -3328,6 +3364,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
 #endif
                                );
                }
+#ifndef NO_PEXTRA
                if (par && par->layout == layout && par->params.depth() == params.depth() &&
                    (par->params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) {
                        if (par->params.pextraHfill() && par->previous() &&
@@ -3379,17 +3416,21 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        minipage_open = true;
                         minipage_open_depth = par->params.depth();
                }
+#endif
        } while (par
                 && par->layout == layout
                 && par->params.depth() == params.depth()
+#ifndef NO_PEXTRA
                 && par->params.pextraType() == params.pextraType()
+#endif
 #ifndef NEW_INSETS
                 && par->footnoteflag == footnoteflag
 #endif
                );
  
        if (style.isEnvironment()) {
-               os << "\\end{" << style.latexname() << '}';
+               os << "\\end{" << style.latexname() << "}\n";
+
 #ifndef NEW_INSETS
                // maybe this should go after the minipage closes?
                if (foot_this_level) {
@@ -3408,6 +3449,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                }
 #endif
        }
+#ifndef NO_PEXTRA
         if (minipage_open && (minipage_open_depth == params.depth()) &&
             (!par || par->params.pextraStartMinipage() ||
              par->params.pextraType() != PEXTRA_MINIPAGE)) {
@@ -3433,6 +3475,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                 os << '\n';
                texrow.newline();
        }
+#endif
        lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
        return par;  // ale970302
 }
@@ -3713,6 +3756,7 @@ bool LyXParagraph::IsDummy() const
 }
 #endif
 
+#ifndef NO_PEXTRA
 void LyXParagraph::SetPExtraType(BufferParams const & bparams,
                                 int type, string const & width,
                                 string const & widthp)
@@ -3821,6 +3865,7 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams)
                }
        }
 }
+#endif
 
 
 bool LyXParagraph::IsHfill(size_type pos) const