]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphParameters.cpp
Fix bug #12772
[lyx.git] / src / ParagraphParameters.cpp
index 1c9bf612798aaf194d81285b95c1d9cbcb0ceef4..72b2286b1284588385a5adaa924fa863dbae2f14 100644 (file)
@@ -3,11 +3,11 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author Angus Leeming
  * \author John Levon
- * \author André Pönitz
- * \author Jürgen Vigna
+ * \author André Pönitz
+ * \author Jürgen Vigna
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include "ParagraphParameters.h"
 
-#include "Buffer.h"
-#include "gettext.h"
 #include "Layout.h"
 #include "Lexer.h"
-#include "Text.h"
 #include "Paragraph.h"
 
+#include "support/debug.h"
+#include "support/docstring.h"
 #include "support/lstrings.h"
 
 #include <sstream>
 
-using lyx::support::rtrim;
-
-using std::istringstream;
-using std::ostream;
-using std::ostringstream;
-using std::string;
-
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
+
 //NOTE The order of these MUST be the same as in Layout.h.
 static char const * const string_align[] = {
        "block", "left", "right", "center", "default", ""
@@ -173,10 +168,10 @@ void ParagraphParameters::leftIndent(Length const & li)
 }
 
 
-void ParagraphParameters::read(std::string str, bool merge)
+void ParagraphParameters::read(string const & str, bool merge)
 {
-       std::istringstream is(str);
-       Lexer lex(0, 0);
+       istringstream is(str);
+       Lexer lex;
        lex.setStream(is);
        read(lex, merge);
 }
@@ -233,7 +228,7 @@ void ParagraphParameters::read(Lexer & lex, bool merge)
                        }
                } else if (token == "\\align") {
                        lex.next();
-                       int tmpret = support::findToken(string_align, lex.getString());
+                       int tmpret = findToken(string_align, lex.getString());
                        if (tmpret == -1)
                                ++tmpret;
                        align(LyXAlignment(1 << tmpret));
@@ -249,20 +244,14 @@ void ParagraphParameters::read(Lexer & lex, bool merge)
 
 
 void ParagraphParameters::apply(
-               ParagraphParameters const & p, Layout const & layout)
+               ParagraphParameters const & params, Layout const & layout)
 {
-       spacing(p.spacing());
+       spacing(params.spacing());
        // does the layout allow the new alignment?
-       if (p.align() & layout.alignpossible)
-               align(p.align());
-       labelWidthString(p.labelWidthString());
-       noindent(p.noindent());
-}
-
-
-bool canApply(ParagraphParameters const & params, Layout const & layout)
-{
-       return true;
+       if (params.align() & layout.alignpossible)
+               align(params.align());
+       labelWidthString(params.labelWidthString());
+       noindent(params.noindent());
 }
 
 
@@ -313,13 +302,13 @@ void params2string(Paragraph const & par, string & data)
        ostringstream os;
        params.write(os);
 
-       Layout_ptr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
        // Is alignment possible
-       os << "\\alignpossible " << layout->alignpossible << '\n';
+       os << "\\alignpossible " << layout.alignpossible << '\n';
 
        /// set default alignment
-       os << "\\aligndefault " << layout->align << '\n';
+       os << "\\aligndefault " << layout.align << '\n';
 
        /// paragraph is always in inset. This is redundant.
        os << "\\ininset " << 1 << '\n';
@@ -328,6 +317,12 @@ void params2string(Paragraph const & par, string & data)
 }
 
 
+LyXErr & operator<<(LyXErr & os, ParagraphParameters const & parp) {
+       parp.write(os.stream());
+       return os;
+}
+
+
 /*
 bool operator==(ParagraphParameeters const & ps1,
                ParagraphParameeters const & ps2)