+/**
+ * \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.
int tmpret = lex.findToken(string_align);
if (tmpret == -1)
++tmpret;
- int const tmpret2 = int(pow(2.0, tmpret));
- align(LyXAlignment(tmpret2));
+ align(LyXAlignment(1 << tmpret));
} else if (token == "\\added_space_top") {
lex.nextToken();
VSpace value = VSpace(lex.getString());
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());
+}