X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fbuffer.C;h=c42098707bacd16f6a317ccef77d38358371ece2;hb=a393cfc37c978985f534f9f00bdbbcfed07b3731;hp=3b3ab688d972419c47e597c6e1aad31743c821e8;hpb=c5e978892692b2903c35c103cbbad79655352ce7;p=lyx.git
diff --git a/src/buffer.C b/src/buffer.C
index 3b3ab688d9..c42098707b 100644
--- a/src/buffer.C
+++ b/src/buffer.C
@@ -14,24 +14,6 @@
#include
-#include
-#include
-#include
";
@@ -2758,7 +2861,7 @@ void operator|=(PAR_TAG & p1, PAR_TAG const & p2)
inline
void reset(PAR_TAG & p1, PAR_TAG const & p2)
{
- p1 = static_cast( p1 & ~p2);
+ p1 = static_cast(p1 & ~p2);
}
} // namespace anon
@@ -2771,7 +2874,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
{
LyXLayout const & style = textclasslist.Style(params.textclass,
par->getLayout());
- string::size_type char_line_count = 5; // Heuristic choice ;-)
+ string::size_type char_line_count = 5; // Heuristic choice ;-)
// gets paragraph main font
LyXFont font_old;
@@ -2791,7 +2894,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
stack tag_state;
// parsing main loop
- for (Paragraph::size_type i = 0; i < par->size(); ++i) {
+ for (pos_type i = 0; i < par->size(); ++i) {
PAR_TAG tag_close = NONE;
list < PAR_TAG > tag_open;
@@ -2883,7 +2986,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
}
list < PAR_TAG > temp;
- while(!tag_state.empty() && tag_close ) {
+ while (!tag_state.empty() && tag_close) {
PAR_TAG k = tag_state.top();
tag_state.pop();
os << "" << tag_name(k) << ">";
@@ -2922,7 +3025,8 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
} else {
string sgml_string;
if (par->sgmlConvertChar(c, sgml_string)
- && !style.free_spacing) {
+ && !style.free_spacing && !par->isFreeSpacing())
+ {
// in freespacing mode, spaces are
// non-breaking characters
if (desc_on) {// if char is ' ' then...
@@ -2963,7 +3067,8 @@ void Buffer::sgmlError(Paragraph * par, int pos,
{
// insert an error marker in text
InsetError * new_inset = new InsetError(message);
- par->insertInset(pos, new_inset);
+ par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT,
+ params.language));
}
@@ -3117,10 +3222,12 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
// treat label as a special case for
// more WYSIWYM handling.
+ // This is a hack while paragraphs can't have
+ // attributes, like id in this case.
if (par->isInset(0)) {
Inset * inset = par->getInset(0);
Inset::Code lyx_code = inset->lyxCode();
- if (lyx_code == Inset::LABEL_CODE){
+ if (lyx_code == Inset::LABEL_CODE) {
command_name += " id=\"";
command_name += (static_cast(inset))->getContents();
command_name += "\"";
@@ -3144,7 +3251,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
if (environment_stack[depth] != style.latexname()) {
- if(environment_stack.size() == depth + 1) {
+ if (environment_stack.size() == depth + 1) {
environment_stack.push_back("!-- --");
environment_inner.push_back("!-- --");
}
@@ -3167,7 +3274,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (style.latextype == LATEX_ENVIRONMENT) {
if (!style.latexparam().empty()) {
- if(style.latexparam() == "CDATA")
+ if (style.latexparam() == "CDATA")
ofs << "";
else
sgmlCloseTag(ofs, depth + command_depth,
@@ -3283,8 +3390,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
// os << string(depth,' ');
// parsing main loop
- for (Paragraph::size_type i = 0;
- i < par->size(); ++i) {
+ for (pos_type i = 0; i < par->size(); ++i) {
LyXFont font = par->getFont(params, i);
// handle tag
@@ -3292,24 +3398,26 @@ void Buffer::simpleDocBookOnePar(ostream & os,
if (font.emph() == LyXFont::ON) {
os << "";
emph_flag = true;
- }else if(i) {
+ } else if (i) {
os << "";
emph_flag = false;
}
}
- char c = par->getChar(i);
- if (c == Paragraph::META_INSET) {
+ if (par->isInset(i)) {
Inset * inset = par->getInset(i);
- inset->docbook(this, os);
+ // don't print the inset in position 0 if desc_on == 3 (label)
+ if (i || desc_on != 3)
+ inset->docbook(this, os);
} else {
+ char c = par->getChar(i);
string sgml_string;
par->sgmlConvertChar(c, sgml_string);
if (style.pass_thru) {
os << c;
- } else if(style.free_spacing || c != ' ') {
+ } else if (style.free_spacing || par->isFreeSpacing() || c != ' ') {
os << sgml_string;
} else if (desc_on ==1) {
++char_line_count;
@@ -3331,7 +3439,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
// not closed...
os << "";
}
- if(style.free_spacing) os << '\n';
+ if (style.free_spacing) os << '\n';
}
@@ -3346,7 +3454,7 @@ int Buffer::runChktex()
// get LaTeX-Filename
string const name = getLatexName();
- string path = OnlyPath(filename);
+ string path = filePath();
string const org_path = path;
if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
@@ -3363,7 +3471,7 @@ int Buffer::runChktex()
makeLaTeXFile(name, org_path, false);
TeXErrors terr;
- Chktex chktex(lyxrc.chktex_command, name, filepath);
+ Chktex chktex(lyxrc.chktex_command, name, filePath());
int res = chktex.run(terr); // run chktex
if (res == -1) {
@@ -3376,7 +3484,7 @@ int Buffer::runChktex()
// if we removed error insets before we ran chktex or if we inserted
// error insets after we ran chktex, this must be run:
- if (removedErrorInsets || res){
+ if (removedErrorInsets || res) {
users->redraw();
users->fitCursor();
}
@@ -3394,7 +3502,7 @@ void Buffer::validate(LaTeXFeatures & features) const
// AMS Style is at document level
if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
- features.require("amsstyle");
+ features.require("amsmath");
while (par) {
// We don't use "lyxerr.debug" because of speed. (Asger)
@@ -3487,16 +3595,16 @@ Buffer::Lists const Buffer::getLists() const
Paragraph * par = paragraph;
#if 1
- std::pair const tmp =
+ std::pair const tmp =
textclasslist.NumberOfLayout(params.textclass, "Caption");
bool const found = tmp.first;
- LyXTextClassList::size_type const cap = tmp.second;
+ textclass_type const cap = tmp.second;
#else
// This is the prefered way to to this, but boost::tie can break
// some compilers
bool found;
- LyXTextClassList::size_type cap;
+ textclass_type cap;
boost::tie(found, cap) = textclasslist
.NumberOfLayout(params.textclass, "Caption");
#endif
@@ -3693,8 +3801,7 @@ bool Buffer::isMultiLingual()
}
-Buffer::inset_iterator::inset_iterator(Paragraph * paragraph,
- Paragraph::size_type pos)
+Buffer::inset_iterator::inset_iterator(Paragraph * paragraph, pos_type pos)
: par(paragraph)
{
it = par->InsetIterator(pos);