]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphParameters.C
Remove the inset and view member functions from PreviewedInset.
[lyx.git] / src / ParagraphParameters.C
index 7203254ad838df1645fa508599f3833fd5de1eef..cd9bd49bc0c99c76c7d426dce711a3d36f6ba7e1 100644 (file)
@@ -1,15 +1,44 @@
+/**
+ * \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;
@@ -41,6 +70,12 @@ void ParagraphParameters::clear()
 }
 
 
+ParagraphParameters::depth_type ParagraphParameters::depth() const
+{
+       return param->depth;
+}
+
+
 bool ParagraphParameters::sameLayout(ParagraphParameters const & pp) const
 {
        return param->align == pp.param->align &&
@@ -407,3 +442,59 @@ void ParagraphParameters::write(ostream & os) const
                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();
+}