]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphParameters.C
mathed uglyfication
[lyx.git] / src / ParagraphParameters.C
index b7399b31c64776763a321b887c9144d85cc1fd4c..e40c14dad98fb6bed7dc76246631cadc1d77dcd7 100644 (file)
@@ -1,27 +1,43 @@
+/**
+ * \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 "ParameterStruct.h"
-#include "tex-strings.h"
-#include "lyxlex.h"
 
 #include "buffer.h"
 #include "BufferView.h"
-#include "Lsstream.h"
 #include "gettext.h"
-#include "paragraph.h"
+#include "lyxlayout.h"
+#include "lyxlex.h"
 #include "lyxtext.h"
-#include "Lsstream.h"
+#include "paragraph.h"
+#include "ParameterStruct.h"
+#include "tex-strings.h"
 
 #include "frontends/LyXView.h"
 
 #include "support/lstrings.h"
+#include "support/std_sstream.h"
 
-#include <iostream>
-
-using namespace lyx::support;
+using lyx::support::rtrim;
 
+using std::istringstream;
 using std::ostream;
+using std::ostringstream;
+using std::string;
+
 
 // Initialize static member var.
 ShareContainer<ParameterStruct> ParagraphParameters::container;
@@ -36,12 +52,6 @@ ParagraphParameters::ParagraphParameters()
 void ParagraphParameters::clear()
 {
        ParameterStruct tmp(*param);
-       tmp.line_top = false;
-       tmp.line_bottom = false;
-       tmp.pagebreak_top = false;
-       tmp.pagebreak_bottom = false;
-       tmp.added_space_top = VSpace(VSpace::NONE);
-       tmp.added_space_bottom = VSpace(VSpace::NONE);
        tmp.spacing.set(Spacing::Default);
        tmp.align = LYX_ALIGN_LAYOUT;
        tmp.depth = 0;
@@ -53,16 +63,15 @@ 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 &&
-               param->line_bottom == pp.param->line_bottom &&
-               param->pagebreak_bottom == pp.param->pagebreak_bottom &&
-               param->added_space_bottom == pp.param->added_space_bottom &&
-
-               param->line_top == pp.param->line_top &&
-               param->pagebreak_top == pp.param->pagebreak_top &&
-               param->added_space_top == pp.param->added_space_top &&
                param->spacing == pp.param->spacing &&
                param->noindent == pp.param->noindent &&
                param->depth == pp.param->depth;
@@ -76,34 +85,6 @@ void ParagraphParameters::set_from_struct(ParameterStruct const & ps)
 }
 
 
-VSpace const & ParagraphParameters::spaceTop() const
-{
-       return param->added_space_top;
-}
-
-
-void ParagraphParameters::spaceTop(VSpace const & vs)
-{
-       ParameterStruct tmp(*param);
-       tmp.added_space_top = vs;
-       set_from_struct(tmp);
-}
-
-
-VSpace const & ParagraphParameters::spaceBottom() const
-{
-       return param->added_space_bottom;
-}
-
-
-void ParagraphParameters::spaceBottom(VSpace const & vs)
-{
-       ParameterStruct tmp(*param);
-       tmp.added_space_bottom = vs;
-       set_from_struct(tmp);
-}
-
-
 Spacing const & ParagraphParameters::spacing() const
 {
        return param->spacing;
@@ -132,62 +113,6 @@ void ParagraphParameters::noindent(bool ni)
 }
 
 
-bool ParagraphParameters::lineTop() const
-{
-       return param->line_top;
-}
-
-
-void ParagraphParameters::lineTop(bool lt)
-{
-       ParameterStruct tmp(*param);
-       tmp.line_top = lt;
-       set_from_struct(tmp);
-}
-
-
-bool ParagraphParameters::lineBottom() const
-{
-       return param->line_bottom;
-}
-
-
-void ParagraphParameters::lineBottom(bool lb)
-{
-       ParameterStruct tmp(*param);
-       tmp.line_bottom = lb;
-       set_from_struct(tmp);
-}
-
-
-bool ParagraphParameters::pagebreakTop() const
-{
-       return param->pagebreak_top;
-}
-
-
-void ParagraphParameters::pagebreakTop(bool pbt)
-{
-       ParameterStruct tmp(*param);
-       tmp.pagebreak_top = pbt;
-       set_from_struct(tmp);
-}
-
-
-bool ParagraphParameters::pagebreakBottom() const
-{
-       return param->pagebreak_bottom;
-}
-
-
-void ParagraphParameters::pagebreakBottom(bool pbb)
-{
-       ParameterStruct tmp(*param);
-       tmp.pagebreak_bottom = pbb;
-       set_from_struct(tmp);
-}
-
-
 LyXAlignment ParagraphParameters::align() const
 {
        return param->align;
@@ -300,18 +225,6 @@ void ParagraphParameters::read(LyXLex & lex)
                        lex.nextToken();
                        LyXLength value(lex.getString());
                        leftIndent(value);
-               } else if (token == "\\fill_top") {
-                       spaceTop(VSpace(VSpace::VFILL));
-               } else if (token == "\\fill_bottom") {
-                       spaceBottom(VSpace(VSpace::VFILL));
-               } else if (token == "\\line_top") {
-                       lineTop(true);
-               } else if (token == "\\line_bottom") {
-                       lineBottom(true);
-               } else if (token == "\\pagebreak_top") {
-                       pagebreakTop(true);
-               } else if (token == "\\pagebreak_bottom") {
-                       pagebreakBottom(true);
                } else if (token == "\\start_of_appendix") {
                        startOfAppendix(true);
                } else if (token == "\\paragraph_spacing") {
@@ -335,24 +248,6 @@ void ParagraphParameters::read(LyXLex & lex)
                        if (tmpret == -1)
                                ++tmpret;
                        align(LyXAlignment(1 << tmpret));
-               } else if (token == "\\added_space_top") {
-                       lex.nextToken();
-                       VSpace value = VSpace(lex.getString());
-                       // only add the length when value > 0 or
-                       // with option keep
-                       if ((value.length().len().value() != 0) ||
-                           value.keep() ||
-                           (value.kind() != VSpace::LENGTH))
-                               spaceTop(value);
-               } else if (token == "\\added_space_bottom") {
-                       lex.nextToken();
-                       VSpace value = VSpace(lex.getString());
-                       // only add the length when value > 0 or
-                       // with option keep
-                       if ((value.length().len().value() != 0) ||
-                          value.keep() ||
-                           (value.kind() != VSpace::LENGTH))
-                               spaceBottom(value);
                } else if (token == "\\labelwidthstring") {
                        lex.eatLine();
                        labelWidthString(lex.getString());
@@ -366,14 +261,6 @@ void ParagraphParameters::read(LyXLex & lex)
 
 void ParagraphParameters::write(ostream & os) const
 {
-       // Maybe some vertical spaces.
-       if (spaceTop().kind() != VSpace::NONE)
-               os << "\\added_space_top "
-                  << spaceTop().asLyXCommand() << ' ';
-       if (spaceBottom().kind() != VSpace::NONE)
-               os << "\\added_space_bottom "
-                  << spaceBottom().asLyXCommand() << ' ';
-
        // Maybe the paragraph has special spacing
        spacing().writeFile(os, true);
 
@@ -382,18 +269,6 @@ void ParagraphParameters::write(ostream & os) const
                os << "\\labelwidthstring "
                   << labelWidthString() << '\n';
 
-       // Lines above or below?
-       if (lineTop())
-               os << "\\line_top ";
-       if (lineBottom())
-               os << "\\line_bottom ";
-
-       // Pagebreaks above or below?
-       if (pagebreakTop())
-               os << "\\pagebreak_top ";
-       if (pagebreakBottom())
-               os << "\\pagebreak_bottom ";
-
        // Start of appendix?
        if (startOfAppendix())
                os << "\\start_of_appendix ";
@@ -421,10 +296,9 @@ void ParagraphParameters::write(ostream & os) const
 }
 
 
-
 void setParagraphParams(BufferView & bv, string const & data)
 {
-       istringstream is(STRCONV(data));
+       istringstream is(data);
        LyXLex lex(0,0);
        lex.setStream(is);
 
@@ -432,12 +306,7 @@ void setParagraphParams(BufferView & bv, string const & data)
        params.read(lex);
 
        LyXText * text = bv.getLyXText();
-       text->setParagraph(params.lineTop(),
-                          params.lineBottom(),
-                          params.pagebreakTop(),
-                          params.pagebreakBottom(),
-                          params.spaceTop(),
-                          params.spaceBottom(),
+       text->setParagraph(
                           params.spacing(),
                           params.align(),
                           params.labelWidthString(),
@@ -473,5 +342,5 @@ void params2string(Paragraph const & par, string & data)
        /// is paragraph in inset
        os << "\\ininset " << (par.inInset()?1:0) << '\n';
 
-       data = STRCONV(os.str());
+       data = os.str();
 }