Commit Graph

218 Commits

Author SHA1 Message Date
Juergen Spitzmueller
00417a1c80 Make openbtUnit raunparam mutable instead of using a copy of runparams
in latexParagraphs()

The latter results in output stream encoding errors.
2017-02-12 18:12:38 +01:00
Juergen Spitzmueller
bedebfc45a Support for multiple bibliographies setting "per child"
This adds support for the chapterbib package, but also adds ways to
produce this sort of multibib with biblatex and bibtopic (which are
both incompatible with chapterbib).

File format change.
2017-02-04 19:23:45 +01:00
Juergen Spitzmueller
401961d087 Only close btUnit at the end of the master. 2017-02-04 16:07:58 +01:00
Juergen Spitzmueller
7ca20b292c Support for multiple bibliographies
Using refsection=unit in biblatex, or bibtopic's btUnit environments
in BibTeX.

File format change.
2017-02-04 12:02:00 +01:00
Enrico Forestieri
7e3494c293 Also track local language switches
Until now this was not done for essentially two reasons. The first
one is that local switches are used for short text insertions, so that
they are unlikely crossing environment boundaries. The second one
is that if we have to close a language at the end of an environment
we would be missing the right termination command. As this last
issue can be overcome by simply storing in the stack the current
nest level with a sign denoting the kind of switch, there is no
reason anymore not to track also local languages switches.
Also factor out some commonly used constructs in order to improve
readability.
2016-09-27 23:00:29 +02:00
Enrico Forestieri
e40fa86a97 Do not unnecessarily open the document language
If the document language is opened outside of any environement, we risk
not closing it if no other language switch occurs. Indeed, the stack is
emptied only at the end of an enviroment. We could of course also empty
it at the end of the document, but we would have an unnecessary language
switch.
2016-09-27 21:41:13 +02:00
Enrico Forestieri
f476d9c85a Shut up compiler warning 2016-09-27 21:32:40 +02:00
Enrico Forestieri
4508a7f855 No need to clutter runparams... 2016-09-25 08:56:12 +02:00
Enrico Forestieri
8c14d9e041 Correctly track opened polyglossia languages
A language switch may also occur outside of output_latex.cpp, apparently.
2016-09-25 08:20:34 +02:00
Enrico Forestieri
3bc08a76c4 Sort the language nesting mess with polyglossia
When using polyglossia, lyx was making a real mess when changing
language inside nested insets. The \begin{language} and
\end{language} commands were not well paired such that they could
easily occur just before and after the start or end of an
environment. Of course this was causing latex errors such that
"\begin{otherlanguage} ended by \end{environment}".
There may still be some cases I did not take into account.
2016-09-24 03:15:02 +02:00
Scott Kostyshak
0b1cf1330d Warn in GUI when mixing Title and InTitle layouts
Since we process layouts sequentially, we export LaTeX code for the
title once we arrive to a layout that has InTitle false. If the
document then later has a layout with InTitle true, we do not
(currently) go back to add it to the title and just output it
in-place. We previously warned with LYXERR0, but since this can
cause missing or unexpected output we now warn in the GUI.

For more information, see the following lyx-devel thread:
https://www.mail-archive.com/search?l=mid&q=a65ae226-d3bd-8fc5-a93b-7bb23f1cda82%40lyx.org
2016-08-18 18:06:04 -04:00
Scott Kostyshak
c949268da7 Improve a layout LYXERR0 message
The name of the layout is now included in an error message about
layouts. This will help with finding the root issue of several
documents we have.
2016-08-08 23:44:27 -04:00
Guillaume Munch
670efa8f64 Rationalise includes
Modifying TexRow.h or texstream.h no longer triggers the recompilation of the
complete source tree.
2016-07-04 02:42:17 +02:00
Stephan Witt
7e72c1d0d3 Call lyx::next and lyx::prev explicitely. In case libc++ provides
std::next even when not in C++11 mode this is necessary. E.g. with
clang from Xcode7 on Mac OS X.
2016-01-10 18:06:15 +01:00
Günter Milde
0eb9477be7 Fix 480937a103708a651/lyxgit, second attempt.
Prevent encoding changes whenever the TeX engine is XeTeX or LuaTeX,
as XeTeX/LuaTeX use only one encoding per document:

* with useNonTeXFonts: "utf8plain",
* with XeTeX and TeX fonts: "ascii" (inputenc fails),
* with LuaTeX and TeX fonts: only one encoding accepted by luainputenc.

+1 no needless encoding switches
+1 runparams.encoding matches the correct encoding at any time
+1 less complicated code.

-1 there may still be problems with CJK (possibly impossible to
   solve for Xe/LuaTeX with TeX fonts).

For LuaTeX & TeX fonts, the complete document uses the encoding
of the global document language.

See also #9740.
2015-11-12 16:55:04 +01:00
Günter Milde
9894e0be23 Fix 480937a103708a651/lyxgit. See also #9740.
Actually, the changed tests were used to prevent overwriting the encoding
changed in Buffer::writeLaTeX with a language-default encoding.
This is still required for XeTeX with TeX-fonts unless a proper solution is found.

Documents with more than one encoding and TeX-fonts fail with LuaTeX,
as "luainputenc" can only handle one encoding.
2015-11-11 00:11:06 +01:00
Günter Milde
480937a103 Reset encoding after insets and environments also for LuaTeX with TeX fonts.
With inputenc == "auto" or "default", the encoding changes with
the language and must be reset after an eventual language switch in insets
or environments (see #6216).

However, whether we need to do this does not depend on 8-bit TeX vs. LuaTeX
but on the possible use of more than one encoding for the document.
With "nonTeXFonts", the encoding is utf8,
LuaTeX with TeX fonts requires encoding handling similar to 8-bit TeX.

(Additionally, the value of "params.inputenc" could be tested: if it is
not "auto" or "default", we have just one common encoding and could skip
the reset as well.) Not sure how much time this saves, though.
2015-11-09 12:42:48 +01:00
Georg Baum
1eaa2366bf Make language nesting code more readable
This is a tiny simplification that makes understanding the code more easy and
will help in fixing the remaining regressions. The logic remains the same, no
export test result is changed.
2015-10-27 22:36:52 +01:00
Günter Milde
1523fc6023 Partial fix for #9740 "XeTeX/LuaTeX with TeX fonts problems".
Fixes output for 3 of the 4 test lyx-files.

Includes "FIXME"s at places where further action is required to get the XeTeX
export right but I don't know how.
2015-10-20 19:16:25 +02:00
Georg Baum
be3e470068 Fix language nesting regression
b1c68dccf8 and 46aed6d2b9 fixed some language nesting issues, but introduced
a regression for the case that there is a standard paragraph in a foreign
language, followed by a list (e.g. itemize) in the same language, followed
by the end of the document, as e.g. in lib/doc/de/Additional.lyx. The reason
for this was that not all language ending commands did reset
state->open_polyglossia_lang_ correctly.
I am sure that one can still construct broken corner cases, and I am also sure
that this was already possible before b1c68dccf8 and 46aed6d2b9. However,
this fix seems to fix the most important issues, and to get nesting completely
correct we would probably need some stack-like structure, for languages and
encodings, also for the CJK part (which is not touched at all by this commit).
2015-10-19 21:08:01 +02:00
Georg Baum
86325e50d0 Fix language end command
The code that sets open_polyglossia_lang_ is not only executed for polyglossia,
but also for babel, so we have to use the correct language end command.
2015-10-18 20:57:21 +02:00
Guillaume Munch
afed7d06fa Improvements to cursor highlighting in the source panel
* TexRow now computes rows from a DocIterator. In practice, the cursor
  highlighting is now correct inside insets, it is no longer restricted to the
  topmost level. It certainly also makes forward-search more precise.

* Added the option to disable a texrow when not needed, for perf.

* Fixed a bug where the last paragraph was not properly highlighted.

Limitations:

* TexRow still does not handle: math (e.g. multi-cell), sub-captions, inset
  arguments.
2015-10-01 21:51:08 +01:00
Georg Baum
b24664b0ac Remove unused variables found by cppcheck
There are still a few warnings of the kind
(style) Variable 'x' is assigned a value that is never used.
since I did not touch code where I was not sure whether there might be a real
bug, and I kept some for symmetry reasons as well.
2015-09-20 21:39:59 +02:00
Juergen Spitzmueller
46aed6d2b9 Refine lang nesting fix 2015-06-19 19:03:11 +02:00
Juergen Spitzmueller
b1c68dccf8 Fix language nesting problem with polyglossia
Part (?) of #9633
2015-06-19 09:25:11 +02:00
Juergen Spitzmueller
4feec2ef4b Properly fix bug #9598
Do not output \\par at the end of environments with size change if the
environment cosinsts of only one par.
2015-06-09 08:18:19 +02:00
Juergen Spitzmueller
8e671a5cdc Revert "No \\par after greyedout notes (bug #9598)"
This reverts commit f929f21228.

It is not as easy as this. See ticket.
2015-06-09 07:57:19 +02:00
Juergen Spitzmueller
f929f21228 No \\par after greyedout notes (bug #9598) 2015-06-09 07:44:03 +02:00
Georg Baum
b596330093 Fix compilation with boost 1.58
Newer boost versions use complicated type traits for boost::next and
boost::prior, which do not work with the RandomAccessList iterators.
The long term solution is to use std::next and std::prev, for now supply
simple replacements for compilers that do not support C++11 yet.
2015-05-16 00:05:23 +02:00
Juergen Spitzmueller
b9573096f7 Factor out polyglossia language begin command construction and apply forcelocalfontswitch to polyglossia as well. 2015-05-03 16:08:14 +02:00
Juergen Spitzmueller
efb4a26512 Make ParBreakIsNewline work in inset layout without PassThru
Fixes: #9513
2015-04-21 19:43:41 +02:00
Juergen Spitzmueller
8c1a484cd2 Use local babel language switch in fixed width cells in order to prevent unwanted whitespace
Fixes: #9455
2015-04-04 11:59:01 +02:00
Juergen Spitzmueller
d9b87d651a Fix bug with wrong baseline calculation in last paragraph (2nd attempt)
This time, we consider the cases where a \par is not wanted (single-par insets, tabular cells).

Fixes: #9231
2014-09-01 09:14:26 +02:00
Juergen Spitzmueller
9c05f221f9 Revert "Fix bug with wrong baseline calculation in last paragraph"
This reverts commit b555f31a34.
2014-08-28 08:38:27 +02:00
Richard Heck
b9fe1dd10b Use a const ref here. Guess it was a thinko when I did it. 2014-08-12 12:32:58 -04:00
Juergen Spitzmueller
b555f31a34 Fix bug with wrong baseline calculation in last paragraph
Fixes: #9231
2014-08-03 11:26:16 +02:00
Georg Baum
5a8b8ba8e1 Make LaTeX export threadsafe.
This is one of the more important threadsafety issues because of export in
thread and simultanous view source. The solution is ugly, but a better one
(see FIXME) would require major rework. These static variables should not
have been used in the first place IMHO.
2014-07-05 14:23:43 +02:00
Enrico Forestieri
c85dbfea98 Fix indentation of paragraphs after an environment.
When deciding whether a paragraph should be indented or not, LyX
only takes into account default layouts. This is wrong, because
an environment could be nested into another one and thus a following
paragraph would not be "default". With this patch all paragraphs
after an environment are correctly indented, independently of
whether their layouts are "default" or not.
The latex output (which was modeled following the previous wrong
assumption) is also correspondingly adapted.
2014-05-28 01:07:47 +02:00
Enrico Forestieri
27e0bf54f5 Add a required paragraph break.
This is necessary, for example, if a standard paragraph is nested
in an environment and the environment does not end immediately after.
To be strictly correct, the layout of the following paragraph should
be compared to the layout of the nesting environment, otherwise, if
they are not the same, an empty line is nevertheless output. However,
this is harmless because an "\end{layout}" tag immediately follows.
2014-05-21 21:08:11 +02:00
Juergen Spitzmueller
58db7c34f9 Output arguments required by arguments with default or preset arg
Fixes: #9128
2014-05-21 13:12:14 +02:00
Enrico Forestieri
8d8d8e9df6 Small reorganization.
I am not sure I fully understand the pending_newline/unskip_newline
logic (which seems mainly related to rtl writing), so I prefer to
leave it alone, in the sense that now things go again as in 2.1
until the point where those booleans are used for producing output.
If it turns out that a spurious (and unwanted) empty line comes
from the previous code, it can be easily corrected later.

I am also reintroducing the check about a separator inset at the end
of the paragraph, because that is necessary for the plain version.
2014-05-21 00:59:36 +02:00
Enrico Forestieri
7145863466 Generalize control on double blank lines.
We can now tell whether a blank line was just output and so can
avoid outputting another one.
2014-05-20 21:52:29 +02:00
Juergen Spitzmueller
8226453684 Fix crash due to invalid pos 2014-05-20 11:14:13 +02:00
Enrico Forestieri
936773c4f7 Adapt output to the on-screen representation.
LyX assumes that a standard paragraph following an aligned one or
a layout with NextNoIndent==false has to be indented on screen.
This means that in the latex output a blank line has to follow.
In this case there should be no problem as regards extra vertical
space and it simpler and more elegant to simply uncheck "Indent
Paragraph" in the Paragraph settings pane rather than changing
the current logic and allowing to insert a parbreak separator.
2014-05-16 15:39:33 +02:00
Enrico Forestieri
7d5b1fb840 Output a parbreak after a command.
This is what LyX was previously doing. It has no effect on vertical
spacing but, for example, sectioning commands stand out on the output.
The parbreak is not output if an environment follows or the alignment
of the current or next paragraph is changed.
Also remove some superfluous code.
2014-05-14 22:25:15 +02:00
Enrico Forestieri
c668ebf611 Fix bugs #8546 and #9055, and introduce new separator inset.
The algorithm used for breaking a paragraph in LaTeX export is changed
for avoiding spurious blank lines causing too much vertical space.
This change is tied to the introduction of a new inset (with two
different specializations) helping in either outputing LaTeX paragraph
breaks or separating environments in LyX. Both of the above goals were
previously achieved by the ---Separator--- layout and can now be
accomplished by the new inset in a more natural way. As an example,
after leaving an environment by hitting the Return key for two times,
a third return automatically inserts a parbreak inset, which is
equivalent to the old separator layout, i.e., it also introduces a
blank line in the output. If this blank line is not wanted, the
parbreak separator can be changed to a plain separator by a right
click of the mouse. Of course, an environment can still be separated
by the following one by using the Alt+P+Return shortcut (or the
corresponding menu key), but now the plain separator inset is used
instead of the old separator layout, such that no blank line occurs in
the LaTeX output.

Old documents are converted such that the LaTeX output remains unchanged.
As a result of this conversion, the old separator layout is replaced by
the new parbreak inset, which may also appear in places where the old
algorithm was introducing blank lines while the new one is not.
Note that not all blank lines were actually affecting the LaTeX output,
because a blank line is simply ignored by the TeX engine when it occurs
in the so called "vertical mode" (e.g., after an alignment environment).
The old ---Separator--- layout is now gone and old layout files using it
are also automatically converted.

Round trip conversions between old and new format should leave a document
unchanged. This means that the new behavior about paragraph breaking is
not "carried back" to the old format. Indeed, this would need introducing
special LaTeX commands in ERT that would accumulate in roundtrip
conversions, horribly cluttering the document. So, when converting a
modified document to old formats, the LaTeX output may slightly differ in
vertical spacing if the document is processed by an old version of LyX.
In other words, forward compatibility is guaranteed, but not backwards.
2014-05-10 23:25:11 +02:00
Richard Heck
fdbe775b9f This is the result of an audit of all static variables, looking
for possible thread conflicts, of the sort Georg resolved at
6a30211f. I have made static variables const where possible,
and marked cases that looked potentially problematic with the
comment:
	// FIXME THREAD
Many of these definitely are vulnerable to concurrent access, such
as the static variables declared at the start of output_latex.cpp.
Suppose, e.g., we were outputting latex and also displaying the
source of a different document.

I'd appreciate it if others could grep for "FIXME THREAD" and see
if some of these are harmless, or what.
2014-04-21 11:51:57 -04:00
Juergen Spitzmueller
7c1fc6ea75 Include child's own authors when using BufferParams from master. 2014-03-13 06:43:38 +01:00
Juergen Spitzmueller
50bcd6ed7b Use the master buffer's param when compiling as a child (#8893) 2013-11-18 08:46:50 +01:00
Juergen Spitzmueller
a8a2bd463c Force encoding switch when switching from/to CJK, even if we use a customized encoding (#8558) 2013-05-20 13:40:40 +02:00