]> git.lyx.org Git - features.git/commitdiff
fix bugs 200, 201, 196
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 19 Jan 2002 20:24:04 +0000 (20:24 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 19 Jan 2002 20:24:04 +0000 (20:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3421 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlDialog_impl.C
src/frontends/controllers/ControlDialog_impl.h
src/paragraph.C
src/paragraph.h
src/tabular.C

index 19dd09414cddbcc9a52ae7e28ca51a438efe12ba..62a9f6bfc1b87adc72c88975adb6f8959930bcd5 100644 (file)
@@ -1,5 +1,13 @@
 2002-01-19  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * tabular.C (Validate): remove broken optimization (fixes bug #201)
+
+       * paragraph.C (startTeXParParams): 
+       (endTeXParParams): new methods. The LaTeX code to
+       start/end paragraph formatting
+       (simpleTeXOnePar): call startTeXParParams also when paragraph is
+       empty (fixes bug #200)
+
        * vspace.C (inPixels): adapt to the change below
        (inPixels): [later] more cleanups (remove unused variables)
 
index e2ee6861970d85616b4b1b913c25e225ba55492b..2e09363d36f347a5be99aca7cb2045cd3aa7fbbf 100644 (file)
@@ -2545,15 +2545,15 @@ void Buffer::latexParagraphs(ostream & ofs, Paragraph * par,
                if ((in == 0) || !in->forceDefaultParagraphs(in)) {
                        LyXLayout const & layout =
                                textclasslist.Style(params.textclass, par->layout);
-           
-               if (layout.intitle) {
+                       
+                       if (layout.intitle) {
                                if (already_title) {
                                        lyxerr <<"Error in latexParagraphs: You"
                                                " should not mix title layouts"
                                                " with normal ones." << endl;
                                } else
                                        was_title = true;
-               } else if (was_title && !already_title) {
+                       } else if (was_title && !already_title) {
                                ofs << "\\maketitle\n";
                                texrow.newline();
                                already_title = true;
index f840ad476791d345329ab384c7dd4fff1eb3f14b..0061f42a16404b34862aaf75e6c546de417bff5c 100644 (file)
@@ -1,5 +1,8 @@
 2002-01-19  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * ControlDialog_impl.h (ControlConnectBI>): make ControlDialogBI
+       derive from ControlDialog<ControlConnectBI> (fixes bug #196)
+
        * helper_funcs.C (browseRelFile): forgot to pass dir2 to browseFile
 
 2002-01-17  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
index d3df442bf962cb3c11288430d61aa2c9a7c39a61..357c4d80fcc95373be2184c4eac02e5234ade669 100644 (file)
@@ -18,5 +18,5 @@ ControlDialogBD::ControlDialogBD(LyXView & lv, Dialogs & d)
 
 
 ControlDialogBI::ControlDialogBI(LyXView & lv, Dialogs & d)
-       : ControlDialog<ControlConnectBD>(lv, d)
+       : ControlDialog<ControlConnectBI>(lv, d)
 {}
index ed0b89eae5d5861bf3e19e11a41fe9a14cbf8a49..5bc16cd87f695d7f2626fae535ccc1ce822c9b7b 100644 (file)
@@ -28,7 +28,7 @@ public:
 };
 
 
-class ControlDialogBI : public ControlDialog<ControlConnectBD>
+class ControlDialogBI : public ControlDialog<ControlConnectBI>
 {
 public:
        ///
index 2e3a09feb90743f57049f9464cc9308d89bdad66..edbb0a429cc735e3027084276175e84d460c4fcd 100644 (file)
@@ -894,7 +894,7 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
                
                // copy everything behind the break-position
                // to the new paragraph
-               pos_type pos_end = pimpl_->size() - 1;
+               pos_type pos_end = size() - 1;
                pos_type i = pos;
                pos_type j = pos;
                for (; i <= pos_end; ++i) {
@@ -970,7 +970,7 @@ void Paragraph::breakParagraphConservative(BufferParams const & bparams,
        if (size() > pos) {
                // copy everything behind the break-position to the new
                // paragraph
-               pos_type pos_end = pimpl_->size() - 1;
+               pos_type pos_end = size() - 1;
 
                //pos_type i = pos;
                //pos_type j = pos;
@@ -1440,6 +1440,88 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
        return next_;
 }
 
+// This could go to ParagraphParameters if we want to
+int Paragraph::startTeXParParams(BufferParams const & bparams,
+                                ostream & os) const
+{
+       int column = 0;
+       
+       if (params().noindent()) {
+               os << "\\noindent ";
+               column += 10;
+       }
+                       
+       switch (params().align()) {
+       case LYX_ALIGN_NONE:
+       case LYX_ALIGN_BLOCK:
+       case LYX_ALIGN_LAYOUT:
+       case LYX_ALIGN_SPECIAL:
+               break;
+       case LYX_ALIGN_LEFT:
+               if (getParLanguage(bparams)->babel() != "hebrew") {
+                       os << "\\begin{flushleft}";
+                       column += 17;
+               } else {
+                       os << "\\begin{flushright}";
+                       column += 18;
+               }
+               break;
+       case LYX_ALIGN_RIGHT:
+               if (getParLanguage(bparams)->babel() != "hebrew") {
+                       os << "\\begin{flushright}";
+                       column += 18;
+               } else {
+                       os << "\\begin{flushleft}";
+                       column += 17;
+               }
+               break;
+       case LYX_ALIGN_CENTER:
+               os << "\\begin{center}";
+               column += 14;
+               break;
+       }
+       
+       return column;
+}
+
+// This could go to ParagraphParameters if we want to
+int Paragraph::endTeXParParams(BufferParams const & bparams,
+                              ostream & os) const
+{
+       int column = 0;
+       
+       switch (params().align()) {
+       case LYX_ALIGN_NONE:
+       case LYX_ALIGN_BLOCK:
+       case LYX_ALIGN_LAYOUT:
+       case LYX_ALIGN_SPECIAL:
+               break;
+       case LYX_ALIGN_LEFT:
+               if (getParLanguage(bparams)->babel() != "hebrew") {
+                       os << "\\end{flushleft}";
+                       column = 15;
+               } else {
+                       os << "\\end{flushright}";
+                       column = 16;
+               }
+               break;
+       case LYX_ALIGN_RIGHT:
+               if (getParLanguage(bparams)->babel() != "hebrew") {
+                       os << "\\end{flushright}";
+                       column+= 16;
+               } else {
+                       os << "\\end{flushleft}";
+                       column = 15;
+               }
+               break;
+       case LYX_ALIGN_CENTER:
+               os << "\\end{center}";
+               column = 12;
+               break;
+       }
+       return column;
+}
+
 
 // This one spits out the text of the paragraph
 bool Paragraph::simpleTeXOnePar(Buffer const * buf,
@@ -1485,13 +1567,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
                basefont = getLayoutFont(bparams);
        }
 
-       if (main_body >= 0 && !pimpl_->size()) {
-               if (style.isCommand()) {
-                       os << '{';
-                       ++column;
-               }
-       }
-
        moving_arg |= style.needprotect;
  
        // Which font is currently active?
@@ -1501,6 +1576,17 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
 
        texrow.start(this, 0);
 
+       // if the paragraph is empty, the loop will not be entered at all
+       if (!size()) {
+               if (style.isCommand()) {
+                       os << '{';
+                       ++column;
+               }
+               if (!asdefault)
+                       column += startTeXParParams(bparams, os);
+
+       }
+
        for (pos_type i = 0; i < size(); ++i) {
                ++column;
                // First char in paragraph or after label?
@@ -1519,45 +1605,11 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
                                os << '{';
                                ++column;
                        }
-
-                       if (!asdefault) {
-                               if (params().noindent()) {
-                                       os << "\\noindent ";
-                                       column += 10;
-                               }
                        
-                               switch (params().align()) {
-                               case LYX_ALIGN_NONE:
-                               case LYX_ALIGN_BLOCK:
-                               case LYX_ALIGN_LAYOUT:
-                               case LYX_ALIGN_SPECIAL:
-                                       break;
-                               case LYX_ALIGN_LEFT:
-                                       if (getParLanguage(bparams)->babel() != "hebrew") {
-                                               os << "\\begin{flushleft}";
-                                               column += 17;
-                                       } else {
-                                               os << "\\begin{flushright}";
-                                               column += 18;
-                                       }
-                                       break;
-                               case LYX_ALIGN_RIGHT:
-                                       if (getParLanguage(bparams)->babel() != "hebrew") {
-                                               os << "\\begin{flushright}";
-                                               column += 18;
-                                       } else {
-                                               os << "\\begin{flushleft}";
-                                               column += 17;
-                                       }
-                                       break;
-                               case LYX_ALIGN_CENTER:
-                                       os << "\\begin{center}";
-                                       column += 14;
-                                       break;
-                               }
-                       }
+                       if (!asdefault)
+                               column += startTeXParParams(bparams, os);
                }
-
+               
                value_type c = getChar(i);
 
                // Fully instantiated font
@@ -1663,35 +1715,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
        }
 
        if (!asdefault) {
-               switch (params().align()) {
-               case LYX_ALIGN_NONE:
-               case LYX_ALIGN_BLOCK:
-               case LYX_ALIGN_LAYOUT:
-               case LYX_ALIGN_SPECIAL:
-                       break;
-               case LYX_ALIGN_LEFT:
-                       if (getParLanguage(bparams)->babel() != "hebrew") {
-                               os << "\\end{flushleft}";
-                               column+= 15;
-                       } else {
-                               os << "\\end{flushright}";
-                               column+= 16;
-                       }
-                       break;
-               case LYX_ALIGN_RIGHT:
-                       if (getParLanguage(bparams)->babel() != "hebrew") {
-                               os << "\\end{flushright}";
-                               column+= 16;
-                       } else {
-                               os << "\\end{flushleft}";
-                               column+= 15;
-                       }
-                       break;
-               case LYX_ALIGN_CENTER:
-                       os << "\\end{center}";
-                       column+= 12;
-                       break;
-               }
+               column += endTeXParParams(bparams, os);
        }
 
        lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
index 2aad07ade892d36e46669128a425fcbf48e8879b..29b201d3809a2eeb2c485d6d8f4613a316a0b64d 100644 (file)
@@ -123,6 +123,14 @@ public:
        Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
                                 std::ostream &, TexRow & texrow,
                                 bool moving_arg);
+
+       /// 
+       int startTeXParParams(BufferParams const &, std::ostream &) const;
+
+       /// 
+       int endTeXParParams(BufferParams const &, std::ostream &) const;
+
+       
        ///
        bool simpleTeXOnePar(Buffer const *, BufferParams const &,
                             std::ostream &, TexRow & texrow, bool moving_arg);
index 31450391982413680239a1dd08258f62ef6fffca..6e7c13aba40f293870dca2be53e1356cf1642ae9 100644 (file)
@@ -2653,7 +2653,7 @@ void LyXTabular::Validate(LaTeXFeatures & features) const
                features.require("longtable");
        if (NeedRotating())
                features.require("rotating");
-       for (int cell = 0; !features.isRequired("array") && (cell < numberofcells); ++cell) {
+       for (int cell = 0; cell < numberofcells; ++cell) {
                if (GetVAlignment(cell) != LYX_VALIGN_TOP)
                        features.require("array");
                GetCellInset(cell)->validate(features);