]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
Remove 3rdparty/boost/Makefile.am
[lyx.git] / src / tex2lyx / text.cpp
index 0d4db90e18d2be948a57d0166f5c3ddaea8a81a5..e06ba2dd27ab240388c821fee996d6093a683a8a 100644 (file)
@@ -21,7 +21,6 @@
 #include "FloatList.h"
 #include "LaTeXPackages.h"
 #include "Layout.h"
-#include "Length.h"
 #include "Preamble.h"
 
 #include "insets/ExternalTemplate.h"
@@ -30,6 +29,7 @@
 #include "support/convert.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
+#include "support/Length.h"
 #include "support/lstrings.h"
 #include "support/lyxtime.h"
 
@@ -47,7 +47,7 @@ namespace lyx {
 
 namespace {
 
-void output_arguments(ostream &, Parser &, bool, bool, string, Context &,
+void output_arguments(ostream &, Parser &, bool, bool, const string &, Context &,
                       Layout::LaTeXArgMap const &);
 
 }
@@ -55,7 +55,7 @@ void output_arguments(ostream &, Parser &, bool, bool, string, Context &,
 
 void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
                Context const & context, InsetLayout const * layout,
-               string const rdelim)
+               string const rdelim)
 {
        bool const forcePlainLayout =
                layout ? layout->forcePlainLayout() : false;
@@ -86,7 +86,7 @@ namespace {
 
 void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
                Context const & context, string const & name,
-               string const rdelim = string())
+               string const rdelim = string())
 {
        InsetLayout const * layout = 0;
        DocumentClass::InsetLayouts::const_iterator it =
@@ -318,16 +318,16 @@ char const * const known_tex_extensions[] = {"tex", 0};
 /// spaces known by InsetSpace
 char const * const known_spaces[] = { " ", "space", ",",
 "thinspace", "quad", "qquad", "enspace", "enskip",
-"negthinspace", "negmedspace", "negthickspace", "textvisiblespace",
-"hfill", "dotfill", "hrulefill", "leftarrowfill", "rightarrowfill",
-"upbracefill", "downbracefill", 0};
+"medspace", "thickspace", "negthinspace", "negmedspace", "negthickspace",
+"textvisiblespace", "hfill", "dotfill", "hrulefill", "leftarrowfill",
+"rightarrowfill", "upbracefill", "downbracefill", 0};
 
 /// the same as known_spaces with .lyx names
 char const * const known_coded_spaces[] = { "space{}", "space{}",
 "thinspace{}", "thinspace{}", "quad{}", "qquad{}", "enspace{}", "enskip{}",
-"negthinspace{}", "negmedspace{}", "negthickspace{}", "textvisiblespace{}",
-"hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}", "rightarrowfill{}",
-"upbracefill{}", "downbracefill{}", 0};
+"medspace{}", "thickspace{}", "negthinspace{}", "negmedspace{}", "negthickspace{}",
+"textvisiblespace{}", "hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}",
+"rightarrowfill{}", "upbracefill{}", "downbracefill{}", 0};
 
 /// known TIPA combining diacritical marks
 char const * const known_tipa_marks[] = {"textsubwedge", "textsubumlaut",
@@ -459,7 +459,7 @@ bool translate_len(string const & length, string & valstring, string & unit)
 
 /// If we have ambiguous quotation marks, make a smart guess
 /// based on main quote style
-string guessQuoteStyle(string in, bool const opening)
+string guessQuoteStyle(string const & in, bool const opening)
 {
        string res = in;
        if (prefixIs(in, "qr")) {// straight quote
@@ -528,7 +528,7 @@ string guessQuoteStyle(string in, bool const opening)
 }
 
 
-string const fromPolyglossiaEnvironment(string const s)
+string const fromPolyglossiaEnvironment(string const s)
 {
        // Since \arabic is taken by the LaTeX kernel,
        // the Arabic polyglossia environment is upcased
@@ -539,7 +539,7 @@ string const fromPolyglossiaEnvironment(string const s)
 }
 
 
-string uncapitalize(string const s)
+string uncapitalize(string const s)
 {
        docstring in = from_ascii(s);
        char_type t = lowercase(s[0]);
@@ -548,7 +548,7 @@ string uncapitalize(string const s)
 }
 
 
-bool isCapitalized(string const s)
+bool isCapitalized(string const s)
 {
        docstring in = from_ascii(s);
        char_type t = uppercase(s[0]);
@@ -686,7 +686,7 @@ pair<bool, string> convert_latexed_command_inset_arg(string s)
 
 /// try to convert \p s to a valid InsetCommand argument
 /// without trying to recode macros.
-string convert_literate_command_inset_arg(string s)
+string convert_literate_command_inset_arg(string const & s)
 {
        // LyX cannot handle newlines in a latex command
        return subst(s, "\n", " ");
@@ -695,14 +695,14 @@ string convert_literate_command_inset_arg(string s)
 void output_ert(ostream & os, string const & s, Context & context)
 {
        context.check_layout(os);
-       for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
-               if (*it == '\\')
+       for (char const c : s) {
+               if (c == '\\')
                        os << "\n\\backslash\n";
-               else if (*it == '\n') {
+               else if (c == '\n') {
                        context.new_paragraph(os);
                        context.check_layout(os);
                } else
-                       os << *it;
+                       os << c;
        }
        context.check_end_layout(os);
 }
@@ -789,7 +789,7 @@ void skip_spaces_braces(Parser & p, bool keepws = false)
 }
 
 
-void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, string const prefix,
+void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, string const prefix,
                       Context & context, Layout::LaTeXArgMap const & latexargs)
 {
        if (context.layout->latextype != LATEX_ITEM_ENVIRONMENT || !prefix.empty()) {
@@ -1310,7 +1310,7 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
                        os << "use_makebox " << (inner_type == "makebox") << '\n';
                if (outer_type == "mbox" || (outer_type == "fbox" && inner_type.empty()))
                        os << "width \"\"\n";
-               // for values like "1.5\width" LyX uses "1.5in" as width ad sets "width" as special
+               // for values like "1.5\width" LyX uses "1.5in" as width and sets "width" as special
                else if (contains(width_unit, '\\'))
                        os << "width \"" << width_value << "in" << "\"\n";
                else
@@ -2536,7 +2536,7 @@ void get_cite_arguments(Parser & p, bool natbibOrder,
 }
 
 
-void copy_file(FileName const & src, string dstname)
+void copy_file(FileName const & src, string const & dstname)
 {
        if (!copyFiles())
                return;
@@ -2867,7 +2867,7 @@ void fix_child_filename(string & name)
 
 
 void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
-               Context & context, string const rdelim)
+               Context & context, string const rdelim)
 {
        Layout const * newlayout = 0;
        InsetLayout const * newinsetlayout = 0;
@@ -5593,7 +5593,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                if (t.cs() == "newpage" ||
                    (t.cs() == "pagebreak" && !p.hasOpt()) ||
                    t.cs() == "clearpage" ||
-                   t.cs() == "cleardoublepage") {
+                   t.cs() == "cleardoublepage" ||
+                   t.cs() == "nopagebreak") {
                        context.check_layout(os);
                        begin_inset(os, "Newpage ");
                        os << t.cs();
@@ -5709,12 +5710,19 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                                } else if (unit == "\\bigskipamount") {
                                                        unit = "bigskip";
                                                        known_vspace = true;
+                                               } else if (length == "\\baselineskip") {
+                                                       unit = "fullline";
+                                                       known_vspace = true;
                                                } else if (unit == "\\fill") {
                                                        unit = "vfill";
                                                        known_vspace = true;
                                                }
                                        }
                                }
+                               if (value == 0.5 && t.cs()[0] != 'h' && unit == "\\baselineskip") {
+                                       unit = "halfline";
+                                       known_vspace = true;
+                               }
                                if (!known_hspace && !known_vspace) {
                                        switch (unitFromString(unit)) {
                                        case Length::SP: