#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>
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());
+
+ // Actually apply these settings
+ bv.update(text, BufferView::SELECT);
+
+ 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());
+}