]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
I'll find a solution for the 'dirList problem', Abdel.
[lyx.git] / src / Text.cpp
index fce891497d1c47dd82393174ef4e666f54607881..faeb92c4b40d355e6d77adfc55be8b82dd741bd4 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * \file src/text.cpp
+ * \file src/Text.cpp
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
 #include "Cursor.h"
 #include "ParIterator.h"
 #include "CutAndPaste.h"
-#include "debug.h"
 #include "DispatchResult.h"
 #include "Encoding.h"
 #include "ErrorList.h"
 #include "FuncRequest.h"
 #include "factory.h"
 #include "FontIterator.h"
-#include "gettext.h"
 #include "Language.h"
 #include "Length.h"
 #include "Lexer.h"
@@ -44,6 +42,7 @@
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
+#include "TextClass.h"
 #include "TextMetrics.h"
 #include "VSpace.h"
 #include "WordLangTuple.h"
 #include "insets/InsetHFill.h"
 #include "insets/InsetLine.h"
 #include "insets/InsetNewline.h"
-#include "insets/InsetPagebreak.h"
+#include "insets/InsetNewpage.h"
 #include "insets/InsetOptArg.h"
 #include "insets/InsetSpace.h"
 #include "insets/InsetSpecialChar.h"
 #include "insets/InsetTabular.h"
 
+#include "support/convert.h"
+#include "support/debug.h"
 #include "support/docstream.h"
+#include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
-#include "support/convert.h"
 
-#include <boost/current_function.hpp>
 #include <boost/next_prior.hpp>
 
 #include <sstream>
 
 using std::auto_ptr;
-using std::advance;
-using std::distance;
-using std::max;
-using std::min;
-using std::endl;
 using std::string;
 
 namespace lyx {
@@ -86,6 +81,7 @@ namespace lyx {
 using support::bformat;
 using support::contains;
 using support::split;
+using support::subst;
 
 using cap::cutSelection;
 using cap::pasteParagraphList;
@@ -135,15 +131,11 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                par.params().read(lex);
 
        } else if (token == "\\end_layout") {
-               lyxerr << BOOST_CURRENT_FUNCTION
-                      << ": Solitary \\end_layout in line "
-                      << lex.getLineNo() << "\n"
-                      << "Missing \\begin_layout?.\n";
+               LYXERR0("Solitary \\end_layout in line " << lex.getLineNo() << "\n"
+                      << "Missing \\begin_layout ?");
        } else if (token == "\\end_inset") {
-               lyxerr << BOOST_CURRENT_FUNCTION
-                      << ": Solitary \\end_inset in line "
-                      << lex.getLineNo() << "\n"
-                      << "Missing \\begin_inset?.\n";
+               LYXERR0("Solitary \\end_inset in line " << lex.getLineNo() << "\n"
+                      << "Missing \\begin_inset ?");
        } else if (token == "\\begin_inset") {
                Inset * inset = readInset(lex, buf);
                if (inset)
@@ -230,6 +222,10 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                }
        } else if (token == "\\backslash") {
                par.appendChar('\\', font, change);
+       } else if (token == "\\linebreak") {
+               auto_ptr<Inset> inset(new InsetLinebreak);
+               inset->read(buf, lex);
+               par.insertInset(par.size(), inset.release(), font, change);
        } else if (token == "\\newline") {
                auto_ptr<Inset> inset(new InsetNewline);
                inset->read(buf, lex);
@@ -243,6 +239,8 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
        } else if (token == "\\lyxline") {
                par.insertInset(par.size(), new InsetLine, font, change);
        } else if (token == "\\newpage") {
+               par.insertInset(par.size(), new InsetNewpage, font, change);
+       } else if (token == "\\pagebreak") {
                par.insertInset(par.size(), new InsetPagebreak, font, change);
        } else if (token == "\\clearpage") {
                par.insertInset(par.size(), new InsetClearPage, font, change);
@@ -254,7 +252,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                lex.eatLine();
                std::istringstream is(lex.getString());
                unsigned int aid;
-               time_type ct;
+               time_t ct;
                is >> aid >> ct;
                if (aid >= bp.author_map.size()) {
                        errorList.push_back(ErrorItem(_("Change tracking error"),
@@ -267,7 +265,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                lex.eatLine();
                std::istringstream is(lex.getString());
                unsigned int aid;
-               time_type ct;
+               time_t ct;
                is >> aid >> ct;
                if (aid >= bp.author_map.size()) {
                        errorList.push_back(ErrorItem(_("Change tracking error"),
@@ -308,8 +306,7 @@ void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex,
                        break;
                }
 
-               LYXERR(Debug::PARSER) << "Handling paragraph token: `"
-                                     << token << '\'' << endl;
+               LYXERR(Debug::PARSER, "Handling paragraph token: `" << token << '\'');
                if (token == "\\begin_layout" || token == "\\end_document"
                    || token == "\\end_inset" || token == "\\begin_deeper"
                    || token == "\\end_deeper") {
@@ -1107,8 +1104,7 @@ void Text::getWord(CursorSlice & from, CursorSlice & to,
                        --from.pos();
                break;
        case NEXT_WORD:
-               lyxerr << "Text::getWord: NEXT_WORD not implemented yet"
-                      << endl;
+               LYXERR0("Text::getWord: NEXT_WORD not implemented yet");
                break;
        case PARTIAL_WORD:
                // no need to move the 'from' cursor
@@ -1173,14 +1169,12 @@ bool Text::read(Buffer const & buf, Lexer & lex, ErrorList & errorList)
                } else if (token == "\\begin_deeper") {
                        ++depth;
                } else if (token == "\\end_deeper") {
-                       if (!depth) {
+                       if (!depth)
                                lex.printError("\\end_deeper: " "depth is already null");
-                       } else {
+                       else
                                --depth;
-                       }
                } else {
-                       lyxerr << "Handling unknown body token: `"
-                              << token << '\'' << endl;
+                       LYXERR0("Handling unknown body token: `" << token << '\'');
                }
        }
        return true;
@@ -1274,6 +1268,9 @@ docstring Text::getPossibleLabel(Cursor & cur) const
 
        docstring text;
        docstring par_text = pars_[pit].asString(cur.buffer(), false);
+       string piece;
+       // the return string of math matrices might contain linebreaks
+       par_text = subst(par_text, '\n', '-');
        for (int i = 0; i < lyxrc.label_init_length; ++i) {
                if (par_text.empty())
                        break;