]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Small changes; ChangeLog is your friend
[lyx.git] / src / buffer.C
index 9d6b55b0ffdd09aaea997707c93d125d0a19dc19..f36aa069e7945b6e222e6a48f86cda9988a7a4a4 100644 (file)
 
 #include <fstream>
 #include <iomanip>
-using std::ofstream;
-using std::ifstream;
-using std::fstream;
-using std::ios;
-using std::setw;
-
 
 #include <cstdlib>
 #include <unistd.h>
@@ -74,7 +68,7 @@ using std::setw;
 #include "insets/insetspecialchar.h"
 #include "insets/figinset.h"
 #include "insets/insettext.h"
-#include "insets/insetnumber.h"
+//#include "insets/insetnumber.h"
 #include "insets/insetert.h"
 #include "insets/insetgraphics.h"
 #include "insets/insetfoot.h"
@@ -93,7 +87,14 @@ using std::setw;
 #include "gettext.h"
 #include "language.h"
 
+using std::ostream;
+using std::ofstream;
+using std::ifstream;
+using std::fstream;
+using std::ios;
+using std::setw;
 using std::endl;
+using std::pair;
 
 // Uncomment this line to enable a workaround for the weird behaviour
 // of the cursor between a displayed inset and last character
@@ -166,6 +167,26 @@ Buffer::~Buffer()
 }
 
 
+string Buffer::getLatexName(bool no_path /* = true */) const
+{
+       return ChangeExtension(MakeLatexName(filename), 
+                              ".tex", no_path); 
+}
+
+
+void Buffer::setReadonly(bool flag /* = true */)
+{
+       if (read_only != flag) {
+               read_only = flag; 
+               updateTitles();
+               updateAllVisibleBufferRelatedPopups();
+       }
+       if (read_only) {
+               WarnReadonly(filename);
+       }
+}
+
+
 bool Buffer::saveParamsAsDefaults()
 {
        string fname = AddName(AddPath(user_lyxdir, "templates/"),
@@ -715,10 +736,10 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                }
        } else if (token == "\\added_space_top") {
                lex.nextToken();
-               par->added_space_top = lex.GetString();
+               par->added_space_top = VSpace(lex.GetString());
        } else if (token == "\\added_space_bottom") {
                lex.nextToken();
-               par->added_space_bottom = lex.GetString();
+               par->added_space_bottom = VSpace(lex.GetString());
        } else if (token == "\\pextra_type") {
                lex.nextToken();
                par->pextra_type = lex.GetInteger();
@@ -813,6 +834,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                        par->InsertInset(pos, inset);
                        par->SetFont(pos, font);
                        ++pos;
+#if 0
                } else if (tmptok == "Number") {
                        inset = new InsetNumber(this);
                        inset->Read(lex);
@@ -820,6 +842,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                        par->InsertInset(pos, inset);
                        par->SetFont(pos, font);
                        ++pos;
+#endif
                } else if (tmptok == "Foot") {
                        inset = new InsetFoot(this);
                        inset->Read(lex);
@@ -857,7 +880,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                                if (!inscmd.getOptions().empty() || !inscmd.getContents().empty()) {
                                        inset = new InsetRef(inscmd, this);
                                }
-#warning Verify that this else clause is still needed. (Lgb)
+#warning Check if this else clause is still needed. (Lgb)
 #if 0
                                // This condition comes from a
                                // temporary solution to the latexdel
@@ -1389,7 +1412,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
                                        if ((inset = par->GetInset(i))) {
 #if 1
 #ifdef HAVE_SSTREAM
-                                               ostringstream ost;
+                                               std::ostringstream ost;
                                                inset->Latex(ost, -1, free_spc);
                                                h += ost.str().length();
 #else
@@ -1630,7 +1653,7 @@ void Buffer::makeLaTeXFile(string const & fname,
        
        // validate the buffer.
        lyxerr[Debug::LATEX] << "  Validating buffer..." << endl;
-       LaTeXFeatures features(tclass.numLayouts());
+       LaTeXFeatures features(params, tclass.numLayouts());
        validate(features);
        lyxerr[Debug::LATEX] << "  Buffer validation done." << endl;
        
@@ -1950,13 +1973,13 @@ void Buffer::makeLaTeXFile(string const & fname,
                string preamble, tmppreamble;
 
                // The optional packages;
-               preamble = features.getPackages(params);
+               preamble = features.getPackages();
 
                // this might be useful...
                preamble += "\n\\makeatletter\n\n";
 
                // Some macros LyX will need
-               tmppreamble = features.getMacros(params);
+               tmppreamble = features.getMacros();
 
                if (!tmppreamble.empty()) {
                        preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
@@ -1965,7 +1988,7 @@ void Buffer::makeLaTeXFile(string const & fname,
                }
 
                // the text class specific preamble 
-               tmppreamble = features.getTClassPreamble(params);
+               tmppreamble = features.getTClassPreamble();
                if (!tmppreamble.empty()) {
                        preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
                                "Textclass specific LaTeX commands.\n"
@@ -2038,7 +2061,7 @@ void Buffer::makeLaTeXFile(string const & fname,
        bool was_title = false;
        bool already_title = false;
 #ifdef HAVE_SSTREAM
-       ostringstream ftnote;
+       std::ostringstream ftnote;
 #else
        char * tmpholder = 0;
 #endif
@@ -2495,7 +2518,7 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
                    .NumberOfLayout(params.textclass,
                                    "Caption").second) {
 #ifdef HAVE_SSTREAM
-                       ostringstream ost;
+                       std::ostringstream ost;
 #else
                        ostrstream ost;
 #endif
@@ -3127,7 +3150,7 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
                if (c == LyXParagraph::META_INSET) {
                        Inset * inset = par->GetInset(i);
 #ifdef HAVE_SSTREAM
-                       ostringstream ost;
+                       std::ostringstream ost;
                        inset->DocBook(ost);
                        string tmp_out = ost.str().c_str();
 #else
@@ -3698,7 +3721,7 @@ void Buffer::validate(LaTeXFeatures & features) const
        }
        
        if (lyxerr.debugging(Debug::LATEX)) {
-               features.showStruct(params);
+               features.showStruct();
        }
 }
 
@@ -3902,3 +3925,25 @@ void Buffer::Dispatch(int action, string const & argument)
 
        } // end of switch
 }
+
+void Buffer::ChangeLanguage(Language const * from, Language const * to)
+{
+
+       LyXParagraph * par = paragraph;
+       while (par) {
+               par->ChangeLanguage(from,to);
+               par = par->next;
+       }
+}
+
+bool Buffer::isMultiLingual()
+{
+
+       LyXParagraph * par = paragraph;
+       while (par) {
+               if (par->isMultiLingual())
+                       return true;
+               par = par->next;
+       }
+       return false;
+}