2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file ParagraphParameters.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-03-06 14:07:14 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "ParagraphParameters.h"
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
2003-03-13 13:56:25 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-29 18:58:28 +00:00
|
|
|
|
#include "Layout.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
2003-05-13 09:48:57 +00:00
|
|
|
|
|
2003-03-12 07:39:17 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2004-07-24 10:55:30 +00:00
|
|
|
|
|
|
|
|
|
#include <sstream>
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
2007-04-30 21:01:24 +00:00
|
|
|
|
using lyx::support::rtrim;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2003-03-12 06:53:49 +00:00
|
|
|
|
using std::ostream;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::ostringstream;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-04-30 21:01:24 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
//NOTE The order of these MUST be the same as in Layout.h.
|
2007-04-30 21:01:24 +00:00
|
|
|
|
static char const * const string_align[] = {
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
"block", "left", "right", "center", "default", ""
|
2007-04-30 21:01:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2001-03-06 14:07:14 +00:00
|
|
|
|
ParagraphParameters::ParagraphParameters()
|
2004-03-25 09:16:36 +00:00
|
|
|
|
: noindent_(false),
|
|
|
|
|
start_of_appendix_(false), appendix_(false),
|
|
|
|
|
align_(LYX_ALIGN_LAYOUT), depth_(0)
|
|
|
|
|
{}
|
2001-03-06 14:07:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::clear()
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
operator=(ParagraphParameters());
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
depth_type ParagraphParameters::depth() const
|
2003-09-06 20:32:37 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return depth_;
|
2003-09-06 20:32:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-03-06 14:07:14 +00:00
|
|
|
|
bool ParagraphParameters::sameLayout(ParagraphParameters const & pp) const
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return align_ == pp.align_
|
|
|
|
|
&& spacing_ == pp.spacing_
|
|
|
|
|
&& noindent_ == pp.noindent_
|
|
|
|
|
&& depth_ == pp.depth_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Spacing const & ParagraphParameters::spacing() const
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return spacing_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::spacing(Spacing const & s)
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
spacing_ = s;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ParagraphParameters::noindent() const
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return noindent_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::noindent(bool ni)
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
noindent_ = ni;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LyXAlignment ParagraphParameters::align() const
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return align_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::align(LyXAlignment la)
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
align_ = la;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void ParagraphParameters::depth(depth_type d)
|
2001-03-06 14:07:14 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
depth_ = d;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ParagraphParameters::startOfAppendix() const
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return start_of_appendix_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::startOfAppendix(bool soa)
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
start_of_appendix_ = soa;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ParagraphParameters::appendix() const
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return appendix_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::appendix(bool a)
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
appendix_ = a;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 19:26:23 +00:00
|
|
|
|
docstring const & ParagraphParameters::labelString() const
|
2001-03-06 14:07:14 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return labelstring_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 19:26:23 +00:00
|
|
|
|
void ParagraphParameters::labelString(docstring const & ls)
|
2001-03-06 14:07:14 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
labelstring_ = ls;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 19:26:23 +00:00
|
|
|
|
docstring const & ParagraphParameters::labelWidthString() const
|
2001-03-06 14:07:14 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return labelwidthstring_;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-20 19:26:23 +00:00
|
|
|
|
void ParagraphParameters::labelWidthString(docstring const & lws)
|
2001-03-06 14:07:14 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
labelwidthstring_ = lws;
|
2001-03-06 14:07:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-08 12:58:16 +00:00
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length const & ParagraphParameters::leftIndent() const
|
2002-05-08 12:58:16 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return leftindent_;
|
2002-05-08 12:58:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
void ParagraphParameters::leftIndent(Length const & li)
|
2002-05-08 12:58:16 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
leftindent_ = li;
|
2002-05-08 12:58:16 +00:00
|
|
|
|
}
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
|
|
|
|
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
void ParagraphParameters::read(std::string str, bool merge)
|
|
|
|
|
{
|
|
|
|
|
std::istringstream is(str);
|
|
|
|
|
Lexer lex(0, 0);
|
|
|
|
|
lex.setStream(is);
|
|
|
|
|
read(lex, merge);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParagraphParameters::read(Lexer & lex, bool merge)
|
2003-03-12 06:53:49 +00:00
|
|
|
|
{
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
if (!merge)
|
|
|
|
|
clear();
|
2003-03-12 07:39:17 +00:00
|
|
|
|
while (lex.isOK()) {
|
|
|
|
|
lex.nextToken();
|
|
|
|
|
string const token = lex.getString();
|
|
|
|
|
|
|
|
|
|
if (token.empty())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (token[0] != '\\') {
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (token == "\\noindent") {
|
|
|
|
|
noindent(true);
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
} else if (token == "\\indent") {
|
|
|
|
|
//not found in LyX files but can be used with lfuns
|
|
|
|
|
noindent(false);
|
|
|
|
|
} else if (token == "\\indent-toggle") {
|
|
|
|
|
//not found in LyX files but can be used with lfuns
|
|
|
|
|
noindent(!noindent());
|
2003-03-12 07:39:17 +00:00
|
|
|
|
} else if (token == "\\leftindent") {
|
2004-10-05 12:56:22 +00:00
|
|
|
|
lex.next();
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length value(lex.getString());
|
2003-03-12 07:39:17 +00:00
|
|
|
|
leftIndent(value);
|
|
|
|
|
} else if (token == "\\start_of_appendix") {
|
|
|
|
|
startOfAppendix(true);
|
|
|
|
|
} else if (token == "\\paragraph_spacing") {
|
|
|
|
|
lex.next();
|
|
|
|
|
string const tmp = rtrim(lex.getString());
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
if (tmp == "default") {
|
|
|
|
|
//not found in LyX files but can be used with lfuns
|
|
|
|
|
spacing(Spacing(Spacing::Default));
|
|
|
|
|
} else if (tmp == "single") {
|
2003-03-12 07:39:17 +00:00
|
|
|
|
spacing(Spacing(Spacing::Single));
|
|
|
|
|
} else if (tmp == "onehalf") {
|
|
|
|
|
spacing(Spacing(Spacing::Onehalf));
|
|
|
|
|
} else if (tmp == "double") {
|
|
|
|
|
spacing(Spacing(Spacing::Double));
|
|
|
|
|
} else if (tmp == "other") {
|
|
|
|
|
lex.next();
|
|
|
|
|
spacing(Spacing(Spacing::Other,
|
2005-01-06 13:48:13 +00:00
|
|
|
|
lex.getString()));
|
2003-03-12 07:39:17 +00:00
|
|
|
|
} else {
|
|
|
|
|
lex.printError("Unknown spacing token: '$$Token'");
|
|
|
|
|
}
|
|
|
|
|
} else if (token == "\\align") {
|
2004-08-20 13:06:33 +00:00
|
|
|
|
lex.next();
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
int tmpret = support::findToken(string_align, lex.getString());
|
2003-03-12 07:39:17 +00:00
|
|
|
|
if (tmpret == -1)
|
|
|
|
|
++tmpret;
|
2003-03-12 11:22:53 +00:00
|
|
|
|
align(LyXAlignment(1 << tmpret));
|
2003-03-12 07:39:17 +00:00
|
|
|
|
} else if (token == "\\labelwidthstring") {
|
|
|
|
|
lex.eatLine();
|
2006-10-20 19:26:23 +00:00
|
|
|
|
labelWidthString(lex.getDocString());
|
2003-03-12 07:39:17 +00:00
|
|
|
|
} else {
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-12 06:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19583 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 04:47:30 +00:00
|
|
|
|
void ParagraphParameters::apply(
|
|
|
|
|
ParagraphParameters const & p, Layout const & layout)
|
|
|
|
|
{
|
|
|
|
|
spacing(p.spacing());
|
|
|
|
|
// does the layout allow the new alignment?
|
|
|
|
|
if ((p.align() == LYX_ALIGN_LAYOUT) ||
|
|
|
|
|
(p.align() & layout.alignpossible))
|
|
|
|
|
align(p.align());
|
|
|
|
|
labelWidthString(p.labelWidthString());
|
|
|
|
|
noindent(p.noindent());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//FIXME This needs to be made a real method, so that getStatus()
|
|
|
|
|
//can return sensible information.
|
|
|
|
|
bool ParagraphParameters::canApply(
|
|
|
|
|
ParagraphParameters const & /*params*/, Layout const & /*layout*/)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-12 06:53:49 +00:00
|
|
|
|
void ParagraphParameters::write(ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
// Maybe the paragraph has special spacing
|
2005-01-06 16:52:08 +00:00
|
|
|
|
spacing().writeFile(os, true);
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
|
|
|
|
// The labelwidth string used in lists.
|
|
|
|
|
if (!labelWidthString().empty())
|
2005-01-06 16:52:08 +00:00
|
|
|
|
os << "\\labelwidthstring "
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< to_utf8(labelWidthString()) << '\n';
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
|
|
|
|
// Start of appendix?
|
|
|
|
|
if (startOfAppendix())
|
2005-01-06 16:52:08 +00:00
|
|
|
|
os << "\\start_of_appendix\n";
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
|
|
|
|
// Noindent?
|
|
|
|
|
if (noindent())
|
2005-01-06 16:52:08 +00:00
|
|
|
|
os << "\\noindent\n";
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
|
|
|
|
// Do we have a manual left indent?
|
|
|
|
|
if (!leftIndent().zero())
|
2005-01-06 16:52:08 +00:00
|
|
|
|
os << "\\leftindent " << leftIndent().asString() << '\n';
|
2003-03-12 06:53:49 +00:00
|
|
|
|
|
|
|
|
|
// Alignment?
|
|
|
|
|
if (align() != LYX_ALIGN_LAYOUT) {
|
|
|
|
|
int h = 0;
|
|
|
|
|
switch (align()) {
|
|
|
|
|
case LYX_ALIGN_LEFT: h = 1; break;
|
|
|
|
|
case LYX_ALIGN_RIGHT: h = 2; break;
|
|
|
|
|
case LYX_ALIGN_CENTER: h = 3; break;
|
|
|
|
|
default: h = 0; break;
|
|
|
|
|
}
|
2005-01-06 16:52:08 +00:00
|
|
|
|
os << "\\align " << string_align[h] << '\n';
|
2003-03-12 06:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-13 13:56:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void params2string(Paragraph const & par, string & data)
|
|
|
|
|
{
|
|
|
|
|
// A local copy
|
|
|
|
|
ParagraphParameters params = par.params();
|
|
|
|
|
|
|
|
|
|
// This needs to be done separately
|
|
|
|
|
params.labelWidthString(par.getLabelWidthString());
|
|
|
|
|
|
|
|
|
|
ostringstream os;
|
|
|
|
|
params.write(os);
|
|
|
|
|
|
2007-06-28 00:48:06 +00:00
|
|
|
|
Layout_ptr const & layout = par.layout();
|
|
|
|
|
|
2003-03-13 13:56:25 +00:00
|
|
|
|
// Is alignment possible
|
2005-01-06 16:52:08 +00:00
|
|
|
|
os << "\\alignpossible " << layout->alignpossible << '\n';
|
2003-03-13 13:56:25 +00:00
|
|
|
|
|
|
|
|
|
/// set default alignment
|
|
|
|
|
os << "\\aligndefault " << layout->align << '\n';
|
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
/// paragraph is always in inset. This is redundant.
|
|
|
|
|
os << "\\ininset " << 1 << '\n';
|
2003-03-13 13:56:25 +00:00
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
data = os.str();
|
2003-03-13 13:56:25 +00:00
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
bool operator==(ParagraphParameeters const & ps1,
|
|
|
|
|
ParagraphParameeters const & ps2)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
ps1.spacing == ps2.spacing
|
|
|
|
|
&& ps1.noindent == ps2.noindent
|
|
|
|
|
&& ps1.align == ps2.align
|
|
|
|
|
&& ps1.depth == ps2.depth
|
|
|
|
|
&& ps1.start_of_appendix == ps2.start_of_appendix
|
|
|
|
|
&& ps1.appendix == ps2.appendix
|
|
|
|
|
&& ps1.labelstring == ps2.labelstring
|
|
|
|
|
&& ps1.labelwidthstring == ps2.labelwidthstring
|
|
|
|
|
&& ps1.leftindent == ps2.leftindent;
|
|
|
|
|
}
|
|
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|