]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Disable setting vertical lines when using a formal table
[lyx.git] / src / Buffer.cpp
index df2e00c8f3a4812a31aee8a338cce3b80ef36f82..e6096af747d328d284e3c8d13eb62744cb13c989 100644 (file)
@@ -1586,10 +1586,10 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
 {
        OutputParams runparams = runparams_in;
 
-       // This is necessary for LuaTeX/XeTeX with tex fonts.
-       // See FIXME in BufferParams::encoding()
-       if (runparams.isFullUnicode())
-               runparams.encoding = encodings.fromLyXName("utf8-plain");
+       // XeTeX with TeX fonts is only safe with ASCII encoding,
+       // See #9740 and FIXME in BufferParams::encoding()
+       if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX))
+               runparams.encoding = encodings.fromLyXName("ascii");
 
        string const encoding = runparams.encoding->iconvName();
        LYXERR(Debug::LATEX, "makeLaTeXFile encoding: " << encoding << ", fname=" << fname.realPath());
@@ -1673,10 +1673,10 @@ void Buffer::writeLaTeXSource(otexstream & os,
 
        OutputParams runparams = runparams_in;
 
-       // This is necessary for LuaTeX/XeTeX with tex fonts.
-       // See FIXME in BufferParams::encoding()
-       if (runparams.isFullUnicode())
-               runparams.encoding = encodings.fromLyXName("utf8-plain");
+       // XeTeX with TeX fonts is only safe with ASCII encoding,
+       // See #9740 and FIXME in BufferParams::encoding()
+       if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX))
+               runparams.encoding = encodings.fromLyXName("ascii");
 
        // If we are compiling a file standalone, even if this is the
        // child of some other buffer, let's cut the link here, so the
@@ -1842,14 +1842,7 @@ void Buffer::writeLaTeXSource(otexstream & os,
        }
        runparams_in.encoding = runparams.encoding;
 
-       // Just to be sure. (Asger)
-       os.texrow().newline();
-
-       //for (int i = 0; i<d->texrow.rows(); i++) {
-       // int id,pos;
-       // if (d->texrow.getIdFromRow(i+1,id,pos) && id>0)
-       //      lyxerr << i+1 << ":" << id << ":" << getParFromID(id).paragraph().asString()<<"\n";
-       //}
+       os.texrow().finalize();
 
        LYXERR(Debug::INFO, "Finished making LaTeX file.");
        LYXERR(Debug::INFO, "Row count was " << os.texrow().rows() - 1 << '.');
@@ -1886,7 +1879,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
        LaTeXFeatures features(*this, params(), runparams);
        validate(features);
 
-       d->texrow.reset();
+       d->texrow.reset(false);
 
        DocumentClass const & tclass = params().documentClass();
        string const & top_element = tclass.latexname();
@@ -2163,9 +2156,9 @@ void Buffer::getLabelList(vector<docstring> & list) const
        }
 
        list.clear();
-       Toc & toc = d->toc_backend.toc("label");
-       TocIterator toc_it = toc.begin();
-       TocIterator end = toc.end();
+       shared_ptr<Toc> toc = d->toc_backend.toc("label");
+       TocIterator toc_it = toc->begin();
+       TocIterator end = toc->end();
        for (; toc_it != end; ++toc_it) {
                if (toc_it->depth() == 0)
                        list.push_back(toc_it->str());
@@ -2447,7 +2440,7 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
 
        case LFUN_BUFFER_VIEW_CACHE:
                (d->preview_file_).refresh();
-               enable = (d->preview_file_).exists();
+               enable = (d->preview_file_).exists() && !(d->preview_file_).isFileEmpty();
                break;
 
        default:
@@ -3510,11 +3503,12 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
        }
 }
 
-
-void Buffer::getSourceCode(odocstream & os, string const & format,
+// returns NULL if id-to-row conversion is unsupported
+auto_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
                           pit_type par_begin, pit_type par_end,
                           OutputWhat output, bool master) const
 {
+       auto_ptr<TexRow> texrow(NULL);
        OutputParams runparams(&params().encoding());
        runparams.nice = true;
        runparams.flavor = params().getOutputFlavor(format);
@@ -3568,15 +3562,15 @@ void Buffer::getSourceCode(odocstream & os, string const & format,
                        LaTeXFeatures features(*this, params(), runparams);
                        params().validate(features);
                        runparams.use_polyglossia = features.usePolyglossia();
-                       TexRow texrow;
-                       texrow.reset();
-                       texrow.newline();
-                       texrow.newline();
+                       texrow.reset(new TexRow());
+                       texrow->newline();
+                       texrow->newline();
                        // latex or literate
-                       otexstream ots(os, texrow);
+                       otexstream ots(os, *texrow);
 
                        // the real stuff
                        latexParagraphs(*this, text(), ots, runparams);
+                       texrow->finalize();
 
                        // Restore the parenthood
                        if (!master)
@@ -3611,15 +3605,17 @@ void Buffer::getSourceCode(odocstream & os, string const & format,
                                writeDocBookSource(os, absFileName(), runparams, output);
                } else {
                        // latex or literate
-                       d->texrow.reset();
-                       d->texrow.newline();
-                       d->texrow.newline();
-                       otexstream ots(os, d->texrow);
+                       texrow.reset(new TexRow());
+                       texrow->newline();
+                       texrow->newline();
+                       otexstream ots(os, *texrow);
                        if (master)
                                runparams.is_child = true;
                        writeLaTeXSource(ots, string(), runparams, output);
+                       texrow->finalize();
                }
        }
+       return texrow;
 }
 
 
@@ -4458,7 +4454,8 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
 
        d->bibinfo_cache_valid_ = true;
        d->cite_labels_valid_ = true;
-       cbuf.tocBackend().update(utype == OutputUpdate);
+       /// FIXME: Perf
+       cbuf.tocBackend().update(true, utype);
        if (scope == UpdateMaster)
                cbuf.structureChanged();
 }