+/**
+ * \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 "buffer.h"
+#include "BufferView.h"
+#include "gettext.h"
+#include "lyxlayout.h"
+#include "lyxlex.h"
+#include "lyxtext.h"
+#include "paragraph.h"
#include "ParameterStruct.h"
#include "tex-strings.h"
-#include "lyxlex.h"
+
+#include "frontends/LyXView.h"
#include "support/lstrings.h"
-#include <iostream>
+#include "support/std_sstream.h"
+
+using lyx::support::rtrim;
+using std::istringstream;
using std::ostream;
+using std::ostringstream;
+using std::string;
+
// Initialize static member var.
ShareContainer<ParameterStruct> ParagraphParameters::container;
}
+ParagraphParameters::depth_type ParagraphParameters::depth() const
+{
+ return param->depth;
+}
+
+
bool ParagraphParameters::sameLayout(ParagraphParameters const & pp) const
{
return param->align == pp.param->align &&
os << "\\align " << string_align[h] << ' ';
}
}
+
+
+
+void setParagraphParams(BufferView & bv, string const & data)
+{
+ istringstream is(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 = os.str();
+}