]> git.lyx.org Git - features.git/blobdiff - src/paragraph.C
clear()->erase() ; lots of using directives for cxx
[features.git] / src / paragraph.C
index 7e869d7872e1cc1fb4859ebc6cb3244ee90dce1e..e1833d2248a9bcd40869a11219ffa0441ec264f3 100644 (file)
@@ -38,6 +38,8 @@ using std::ostream;
 using std::endl;
 using std::fstream;
 using std::ios;
+using std::lower_bound;
+using std::upper_bound;
 
 int tex_code_break_column = 72;  // needs non-zero initialization. set later.
 // this is a bad idea, but how can LyXParagraph find its buffer to get
@@ -287,12 +289,6 @@ void LyXParagraph::writeFile(ostream & os, BufferParams const & params,
                        os << "\n\\hfill \n";
                        column = 0;
                        break;
-#if 0
-               case META_PROTECTED_SEPARATOR: 
-                       os << "\n\\protected_separator \n";
-                       column = 0;
-                       break;
-#endif
                case '\\':
                        os << "\n\\backslash \n";
                        column = 0;
@@ -485,14 +481,14 @@ void LyXParagraph::Clear()
        noindent = false;
 
         pextra_type = PEXTRA_NONE;
-        pextra_width.clear();
-        pextra_widthp.clear();
+        pextra_width.erase();
+        pextra_widthp.erase();
         pextra_alignment = MINIPAGE_ALIGN_TOP;
         pextra_hfill = false;
         pextra_start_minipage = false;
 
-        labelstring.clear();
-       labelwidthstring.clear();
+        labelstring.erase();
+       labelwidthstring.erase();
        layout = 0;
        bibkey = 0;
        
@@ -650,6 +646,8 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
                                "there is an inset in position: " << pos << endl;
                else
                        insetlist.insert(it, InsetTable(pos,inset));
+               if (inset_owner)
+                       inset->setOwner(inset_owner);
        }
 }
 
@@ -1774,7 +1772,7 @@ void LyXParagraph::SetLayout(LyXTextClass::size_type new_layout)
                * npar = 0;
 
         par->layout = new_layout;
-       par->labelwidthstring.clear();
+       par->labelwidthstring.erase();
        par->align = LYX_ALIGN_LAYOUT;
        par->added_space_top = VSpace(VSpace::NONE);
        par->added_space_bottom = VSpace(VSpace::NONE);
@@ -1986,8 +1984,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
 
        if (!spacing.isDefault()
            && (!Previous() || !Previous()->HasSameLayout(this))) {
-               os << "\\begin{spacing}{"
-                  << spacing.getValue() << "}\n";
+               os << spacing.writeEnvirBegin() << "\n";
                texrow.newline();
        }
        
@@ -2131,7 +2128,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
                        || par->pextra_type != pextra_type))
                        break;
        default:
-               if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE
+               // we don't need it for the last paragraph!!!
+               if (next && !(footnoteflag != LyXParagraph::NO_FOOTNOTE
                      && footnotekind != LyXParagraph::FOOTNOTE
                      && footnotekind != LyXParagraph::MARGIN
                      && (table
@@ -2169,11 +2167,12 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
 
        if (!spacing.isDefault()
            && (!par || !par->HasSameLayout(this))) {
-               os << "\\end{spacing}\n";
+               os << spacing.writeEnvirEnd() << "\n";
                texrow.newline();
        }
        
-       if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
+       // we don't need it for the last paragraph!!!
+       if (next && !(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
               par->footnoteflag == LyXParagraph::NO_FOOTNOTE)) {
                os << '\n';
                texrow.newline();
@@ -2686,13 +2685,8 @@ bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
        bool retval = false;
        switch (c) {
        case LyXParagraph::META_HFILL:
-               sgml_string.clear();
-               break;
-#if 0
-       case LyXParagraph::META_PROTECTED_SEPARATOR: 
-               sgml_string = ' ';
+               sgml_string.erase();
                break;
-#endif
        case LyXParagraph::META_NEWLINE:
                sgml_string = '\n';
                break;
@@ -2740,7 +2734,7 @@ bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
                sgml_string = ' ';
                break;
        case '\0': // Ignore :-)
-               sgml_string.clear();
+               sgml_string.erase();
                break;
        default:
                sgml_string = c;
@@ -3139,20 +3133,13 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
                            && running_font.isRightToLeft()) {
                                os << "\\L{";
                                close = true;
-                       } else if (inset->LyxCode() == Inset::NUMBER_CODE
-                                  && running_font.isRightToLeft()) {
-                               os << "{\\beginL ";
-                               close = true;
                        }
 
                        int tmp = inset->Latex(os, style.isCommand(),
                                               style.free_spacing);
 
                        if (close)
-                               if (inset->LyxCode() == Inset::NUMBER_CODE)
-                                       os << "\\endL}";
-                               else
-                                       os << "}";
+                               os << "}";
 
                        if (tmp) {
                                column = 0;
@@ -3190,11 +3177,6 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
                        // but I'll leave it as a switch statement
                        // so its simpler to extend. (ARRae)
                        switch (c) {
-#if 0
-                       case LyXParagraph::META_PROTECTED_SEPARATOR: 
-                               os << ' ';
-                               break;
-#endif
                        default:
                                // make sure that we will not print
                                // error generating chars to the tex
@@ -3209,11 +3191,6 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
                } else {
                        // Plain mode (i.e. not LaTeX)
                        switch (c) {
-#if 0
-                       case LyXParagraph::META_PROTECTED_SEPARATOR: 
-                               os << '~';
-                               break;
-#endif
                        case '\\': 
                                os << "\\textbackslash{}";
                                column += 15;
@@ -3423,10 +3400,9 @@ bool LyXParagraph::RoffContTableRows(ostream & os,
                        switch (c) {
                        case LyXParagraph::META_INSET:
                                if ((inset = GetInset(i))) {
-#if 1
 #ifdef HAVE_SSTREAM
                                        stringstream ss(ios::in | ios::out);
-                                       inset->Latex(ss, -1);
+                                       inset->Ascii(ss);
                                        ss.seekp(0);
                                        ss.get(c);
                                        while (!ss) {
@@ -3438,7 +3414,7 @@ bool LyXParagraph::RoffContTableRows(ostream & os,
                                        }
 #else
                                        strstream ss;
-                                       inset->Latex(ss, -1);
+                                       inset->Ascii(ss);
                                        ss.seekp(0);
                                        ss.get(c);
                                        while (!ss) {
@@ -3449,27 +3425,6 @@ bool LyXParagraph::RoffContTableRows(ostream & os,
                                                ss.get(c);
                                        }
                                        delete [] ss.str();
-#endif
-#else
-                                       fstream fs(fname2.c_str(),
-                                                  ios::in|ios::out);
-                                       if (!fs) {
-                                               WriteAlert(_("LYX_ERROR:"),
-                                                          _("Cannot open temporary file:"),
-                                                          fname2);
-                                               return false;
-                                       }
-                                       inset->Latex(fs, -1);
-                                       fs.seekp(0);
-                                       fs.get(c);
-                                       while (!fs) {
-                                               if (c == '\\')
-                                                       os << "\\\\";
-                                               else
-                                                       os << c;
-                                               fs.get(c);
-                                       }
-                                       fs.close();
 #endif
                                }
                                break;
@@ -3477,10 +3432,6 @@ bool LyXParagraph::RoffContTableRows(ostream & os,
                                break;
                        case LyXParagraph::META_HFILL: 
                                break;
-#if 0
-                       case LyXParagraph::META_PROTECTED_SEPARATOR:
-                               break;
-#endif
                        case '\\': 
                                os << "\\\\";
                                break;
@@ -3509,7 +3460,9 @@ LyXParagraph * LyXParagraph::TeXDeeper(ostream & os, TexRow & texrow,
        lyxerr[Debug::LATEX] << "TeXDeeper...     " << this << endl;
        LyXParagraph * par = this;
 
-       while (par && par->depth == depth) {
+       while (par &&
+              (par->depth == depth) &&
+              (par->footnoteflag == footnoteflag)) {
                if (par->IsDummy())
                        lyxerr << "ERROR (LyXParagraph::TeXDeeper)" << endl;
                if (textclasslist.Style(current_view->buffer()->params.textclass, 
@@ -3762,7 +3715,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(ostream & os, TexRow & texrow,
        } while (par
                 && par->layout == layout
                 && par->depth == depth
-                && par->pextra_type == pextra_type);
+                && par->pextra_type == pextra_type
+                && par->footnoteflag == footnoteflag);
  
        if (style.isEnvironment()) {
                os << "\\end{" << style.latexname() << '}';
@@ -4134,8 +4088,8 @@ void LyXParagraph::UnsetPExtraType()
                return;
     
        pextra_type = PEXTRA_NONE;
-       pextra_width.clear();
-       pextra_widthp.clear();
+       pextra_width.erase();
+       pextra_widthp.erase();
 
        if (textclasslist.Style(current_view->buffer()->params.textclass, 
                                layout).isEnvironment()) {
@@ -4159,8 +4113,8 @@ void LyXParagraph::UnsetPExtraType()
                while (par && (par->layout == layout)
                       && (par->depth == depth)) {
                        par->pextra_type = PEXTRA_NONE;
-                       par->pextra_width.clear();
-                       par->pextra_widthp.clear();
+                       par->pextra_width.erase();
+                       par->pextra_widthp.erase();
                        par = par->NextAfterFootnote();
                        if (par && (par->depth > depth))
                                par->UnsetPExtraType();
@@ -4268,7 +4222,7 @@ void LyXParagraph::ChangeLanguage(Language const * from, Language const * to)
                LyXFont font = GetFontSettings(i);
                if (font.language() == from) {
                        font.setLanguage(to);
-                       SetFont(i,font);
+                       SetFont(i, font);
                }
        }
 }