]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphParameters.C
hopefully fix tex2lyx linking.
[lyx.git] / src / ParagraphParameters.C
index 52c33854611d4a935dff7139ecfb5907e457d739..0ac99a7850f501428d2a71d8ce868acc8155b094 100644 (file)
@@ -17,7 +17,6 @@
 #include "ParagraphParameters.h"
 
 #include "buffer.h"
-#include "BufferView.h"
 #include "gettext.h"
 #include "lyxlayout.h"
 #include "lyxlex.h"
 #include "paragraph.h"
 #include "tex-strings.h"
 
-#include "frontends/LyXView.h"
-
 #include "support/lstrings.h"
 
 #include <sstream>
 
-using lyx::support::rtrim;
+namespace lyx {
+
+using support::rtrim;
 
 using std::istringstream;
 using std::ostream;
 using std::ostringstream;
 using std::string;
 
-// anonym namespace
-namespace {
-int findToken(char const * const str[], string const search_token)
-{
-       int i = 0;
-
-       if (search_token != "default") {
-               while (str[i][0] && str[i] != search_token) {
-                       ++i;
-               }
-               if (!str[i][0]) {
-                       i = -1;
-               }
-       }
-
-       return i;
-}
 
+static int findToken(char const * const str[], string const & search_token)
+{
+       return search_token == "default" ?
+               0 :
+               support::findToken(str, search_token);
 }
 
 
@@ -72,7 +59,7 @@ void ParagraphParameters::clear()
 }
 
 
-ParagraphParameters::depth_type ParagraphParameters::depth() const
+depth_type ParagraphParameters::depth() const
 {
        return depth_;
 }
@@ -153,25 +140,25 @@ void ParagraphParameters::appendix(bool a)
 }
 
 
-string const & ParagraphParameters::labelString() const
+docstring const & ParagraphParameters::labelString() const
 {
        return labelstring_;
 }
 
 
-void ParagraphParameters::labelString(string const & ls)
+void ParagraphParameters::labelString(docstring const & ls)
 {
        labelstring_ = ls;
 }
 
 
-string const & ParagraphParameters::labelWidthString() const
+docstring const & ParagraphParameters::labelWidthString() const
 {
        return labelwidthstring_;
 }
 
 
-void ParagraphParameters::labelWidthString(string const & lws)
+void ParagraphParameters::labelWidthString(docstring const & lws)
 {
        labelwidthstring_ = lws;
 }
@@ -223,7 +210,7 @@ void ParagraphParameters::read(LyXLex & lex)
                        } else if (tmp == "other") {
                                lex.next();
                                spacing(Spacing(Spacing::Other,
-                                                lex.getFloat()));
+                                                lex.getString()));
                        } else {
                                lex.printError("Unknown spacing token: '$$Token'");
                        }
@@ -235,7 +222,7 @@ void ParagraphParameters::read(LyXLex & lex)
                        align(LyXAlignment(1 << tmpret));
                } else if (token == "\\labelwidthstring") {
                        lex.eatLine();
-                       labelWidthString(lex.getString());
+                       labelWidthString(lex.getDocString());
                } else {
                        lex.pushToken(token);
                        break;
@@ -246,28 +233,25 @@ void ParagraphParameters::read(LyXLex & lex)
 
 void ParagraphParameters::write(ostream & os) const
 {
-       ostringstream oss;
-
        // Maybe the paragraph has special spacing
-       spacing().writeFile(oss, true);
+       spacing().writeFile(os, true);
 
        // The labelwidth string used in lists.
        if (!labelWidthString().empty())
-               oss << "\\labelwidthstring "
-                  << labelWidthString() << '\n';
+               os << "\\labelwidthstring "
+                  << to_utf8(labelWidthString()) << '\n';
 
        // Start of appendix?
        if (startOfAppendix())
-               oss << "\\start_of_appendix ";
+               os << "\\start_of_appendix\n";
 
        // Noindent?
        if (noindent())
-               oss << "\\noindent ";
+               os << "\\noindent\n";
 
        // Do we have a manual left indent?
        if (!leftIndent().zero())
-               oss << "\\leftindent " << leftIndent().asString()
-                  << ' ';
+               os << "\\leftindent " << leftIndent().asString() << '\n';
 
        // Alignment?
        if (align() != LYX_ALIGN_LAYOUT) {
@@ -278,9 +262,8 @@ void ParagraphParameters::write(ostream & os) const
                case LYX_ALIGN_CENTER: h = 3; break;
                default: h = 0; break;
                }
-               oss << "\\align " << string_align[h] << ' ';
+               os << "\\align " << string_align[h] << '\n';
        }
-       os << rtrim(oss.str());
 }
 
 
@@ -301,7 +284,7 @@ void params2string(Paragraph const & par, string & data)
        params.write(os);
 
        // Is alignment possible
-       os << '\n' << "\\alignpossible " << layout->alignpossible << '\n';
+       os << "\\alignpossible " << layout->alignpossible << '\n';
 
        /// set default alignment
        os << "\\aligndefault " << layout->align << '\n';
@@ -329,3 +312,6 @@ bool operator==(ParagraphParameeters const & ps1,
                && ps1.leftindent == ps2.leftindent;
 }
 */
+
+
+} // namespace lyx