]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphParameters.C
Point fix, earlier forgotten
[lyx.git] / src / ParagraphParameters.C
index 7203254ad838df1645fa508599f3833fd5de1eef..2557a743fcddd789391d3e4748d9960be0fab422 100644 (file)
@@ -1,3 +1,17 @@
+/**
+ * \file ParagraphParameters.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Angus Leeming
+ * \author John Levon
+ * \author André Pönitz
+ * \author Jürgen Vigna
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #include <config.h>
 
 #include "ParagraphParameters.h"
 #include "tex-strings.h"
 #include "lyxlex.h"
 
+#include "buffer.h"
+#include "BufferView.h"
+#include "Lsstream.h"
+#include "gettext.h"
+#include "paragraph.h"
+#include "lyxtext.h"
+#include "Lsstream.h"
+
+#include "frontends/LyXView.h"
+
 #include "support/lstrings.h"
 
 #include <iostream>
 
+using namespace lyx::support;
+
 using std::ostream;
 
 // Initialize static member var.
@@ -407,3 +433,59 @@ void ParagraphParameters::write(ostream & os) const
                os << "\\align " << string_align[h] << ' ';
        }
 }
+
+
+
+void setParagraphParams(BufferView & bv, string const & data)
+{
+       istringstream is(STRCONV(data));
+       LyXLex lex(0,0);
+       lex.setStream(is);
+
+       ParagraphParameters params;
+       params.read(lex);
+
+       LyXText * text = bv.getLyXText();
+       text->setParagraph(params.lineTop(),
+                          params.lineBottom(),
+                          params.pagebreakTop(),
+                          params.pagebreakBottom(),
+                          params.spaceTop(),
+                          params.spaceBottom(),
+                          params.spacing(),
+                          params.align(),
+                          params.labelWidthString(),
+                          params.noindent());
+
+       bv.update();
+       bv.owner()->message(_("Paragraph layout set"));
+}
+
+
+void params2string(Paragraph const & par, string & data)
+{
+       // A local copy
+       ParagraphParameters params = par.params();
+
+       // This needs to be done separately
+       params.labelWidthString(par.getLabelWidthString());
+
+       // Alignment
+       LyXLayout_ptr const & layout = par.layout();
+       if (params.align() == LYX_ALIGN_LAYOUT)
+               params.align(layout->align);
+
+       ostringstream os;
+       params.write(os);
+
+       // Is alignment possible
+       os << '\n' << "\\alignpossible " << layout->alignpossible << '\n';
+
+       /// set default alignment
+       os << "\\aligndefault " << layout->align << '\n';
+
+       /// is paragraph in inset
+       os << "\\ininset " << (par.inInset()?1:0) << '\n';
+
+       data = STRCONV(os.str());
+}