Write out the markers for change ranges. There is one ugly bit related
to 0-sized paragraphs, which we do currently write out anyway, even if
it's not in free spacing paragraph.


diff -u -r1.235 paragraph.C
--- src/paragraph.C     15 Jan 2003 14:23:20 -0000      1.235
+++ src/paragraph.C     7 Feb 2003 11:31:59 -0000
@@ -28,6 +28,7 @@
 #include "encoding.h"
 #include "ParameterStruct.h"
 #include "gettext.h"
+#include "changes.h"
 
 #include "insets/insetbib.h"
 #include "insets/insetoptarg.h"
@@ -42,6 +43,7 @@
 #include <algorithm>
 #include <fstream>
 #include <csignal>
+#include <ctime>
 
 using std::ostream;
 using std::endl;
@@ -242,6 +244,9 @@
 
        LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
 
+       Change running_change = Change(Change::UNCHANGED);
+       time_t const curtime(time(0));
+ 
        int column = 0;
        for (pos_type i = 0; i < size(); ++i) {
                if (!i) {
@@ -249,6 +254,10 @@
                        column = 0;
                }
 
+               Change change = pimpl_->lookupChangeFull(i);
+               Changes::lyxMarkChange(os, column, curtime, running_change, change);
+               running_change = change;
+ 
                // Write font changes
                LyXFont font2 = getFontSettings(bparams, i);
                if (font2 != font1) {
@@ -312,6 +321,15 @@
                        break;
                }
        }
+
+       // to make reading work properly
+       if (!size()) {
+               running_change = pimpl_->lookupChange(0);
+               Changes::lyxMarkChange(os, column, curtime,
+                       Change(Change::UNCHANGED), running_change);
+       }
+       Changes::lyxMarkChange(os, column, curtime,
+               running_change, Change(Change::UNCHANGED)); 
 }
 
 
@@ -1358,6 +1382,8 @@
        // Do we have an open font change?
        bool open_font = false;
 
+       Change::Type running_change = Change::UNCHANGED;
+ 
        texrow.start(this, 0);
 
        // if the paragraph is empty, the loop will not be entered at all
@@ -1444,7 +1470,12 @@
                        running_font = font;
                        open_font = true;
                }
-
+ 
+               Change::Type change = pimpl_->lookupChange(i);
+ 
+               column += Changes::latexMarkChange(os, running_change, change);
+               running_change = change;
+ 
                if (c == Paragraph::META_NEWLINE) {
                        // newlines are handled differently here than
                        // the default in SimpleTeXSpecialChars().
@@ -1474,10 +1505,14 @@
                                                      os, texrow, moving_arg,
                                                      font, running_font,
                                                      basefont, open_font,
+                                                     running_change,
                                                      *style, i, column, c);
                }
        }
 
+       column += Changes::latexMarkChange(os,
+                       running_change, Change::UNCHANGED);
+ 
        // If we have an open font definition, we have to close it
        if (open_font) {
 #ifdef FIXED_LANGUAGE_END_DETECTION
Index: src/paragraph_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_pimpl.C,v
retrieving revision 1.46
diff -u -r1.46 paragraph_pimpl.C
--- src/paragraph_pimpl.C       8 Jan 2003 09:03:31 -0000       1.46
+++ src/paragraph_pimpl.C       7 Feb 2003 11:32:00 -0000
@@ -279,6 +494,7 @@
                                             LyXFont & running_font,
                                             LyXFont & basefont,
                                             bool & open_font,
+                                            Change::Type & running_change,
                                             LyXLayout const & style,
                                             pos_type & i,
                                             unsigned int & column,
@@ -294,17 +510,27 @@
        switch (c) {
        case Paragraph::META_INSET: {
                Inset * inset = owner_->getInset(i);
-               if (inset) {
-                       bool close = false;
-                       int const len = os.tellp();
-                       //ostream::pos_type const len = os.tellp();
-                       if ((inset->lyxCode() == Inset::GRAPHICS_CODE
-                            || inset->lyxCode() == Inset::MATH_CODE
-                            || inset->lyxCode() == Inset::URL_CODE)
-                           && running_font.isRightToLeft()) {
-                               os << "\\L{";
-                               close = true;
-                       }
+
+               // FIXME: remove this check
+               if (!inset)
+                       break;
+ 
+               if (inset->isTextInset()) {
+                       column += Changes::latexMarkChange(os, running_change,
+                               Change::UNCHANGED);
+                       running_change = Change::UNCHANGED;
+               }
+ 
+               bool close = false;
+               int const len = os.tellp();
+               //ostream::pos_type const len = os.tellp();
+               if ((inset->lyxCode() == Inset::GRAPHICS_CODE
+                    || inset->lyxCode() == Inset::MATH_CODE
+                    || inset->lyxCode() == Inset::URL_CODE)
+                   && running_font.isRightToLeft()) {
+                       os << "\\L{";
+                       close = true;
+               }
 
 #ifdef WITH_WARNINGS
 #warning Bug: we can have an empty font change here!
@@ -312,32 +538,31 @@
 // right now, which means stupid latex code like \textsf{}. AFAIK,
 // this does not harm dvi output. A minor bug, thus (JMarc)
 #endif
-                       // some insets cannot be inside a font change command
-                       if (open_font && inset->noFontChange()) {
-                               column +=running_font.
-                                       latexWriteEndChanges(os,
-                                                            basefont,
-                                                            basefont);
-                               open_font = false;
-                               basefont = owner_->getLayoutFont(bparams);
-                               running_font = basefont;
-                       }
+               // some insets cannot be inside a font change command
+               if (open_font && inset->noFontChange()) {
+                       column +=running_font.
+                               latexWriteEndChanges(os,
+                                                    basefont,
+                                                    basefont);
+                       open_font = false;
+                       basefont = owner_->getLayoutFont(bparams);
+                       running_font = basefont;
+               }
 
-                       int tmp = inset->latex(buf, os, moving_arg,
-                                              style.free_spacing);
+               int tmp = inset->latex(buf, os, moving_arg,
+                                      style.free_spacing);
 
-                       if (close)
-                               os << '}';
+               if (close)
+                       os << '}';
 
-                       if (tmp) {
-                               for (int j = 0; j < tmp; ++j) {
-                                       texrow.newline();
-                               }
-                               texrow.start(owner_, i + 1);
-                               column = 0;
-                       } else {
-                               column += int(os.tellp()) - len;
+               if (tmp) {
+                       for (int j = 0; j < tmp; ++j) {
+                               texrow.newline();
                        }
+                       texrow.start(owner_, i + 1);
+                       column = 0;
+               } else {
+                       column += int(os.tellp()) - len;
                }
        }
        break;
diff -u -r1.19 paragraph_pimpl.h
--- src/paragraph_pimpl.h       8 Jan 2003 09:03:31 -0000       1.19
+++ src/paragraph_pimpl.h       7 Feb 2003 11:32:01 -0000
@@ -130,6 +166,7 @@
                                   bool moving_arg,
                                   LyXFont & font, LyXFont & running_font,
                                   LyXFont & basefont, bool & open_font,
+                                  Change::Type & running_change,
                                   LyXLayout const & style,
                                   lyx::pos_type & i,
                                   unsigned int & column, value_type const c);

Reply via email to