]> git.lyx.org Git - features.git/commitdiff
fix the switch layout bug, add some more boost.format, some additional cleanup
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 1 Dec 2002 21:10:37 +0000 (21:10 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 1 Dec 2002 21:10:37 +0000 (21:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5757 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/BufferView.h
src/ChangeLog
src/CutAndPaste.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlDocument.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormDocument.C
src/frontends/xforms/checkedwidgets.C
src/insets/ChangeLog
src/insets/insetquotes.C
src/lyxtext.h
src/text2.C

index 77478995960acacf26f2ba5a546de5ee80f037a1..04c44ce087790a004a7efbb4c24f7d2e615b7c20 100644 (file)
@@ -59,19 +59,19 @@ public:
        BufferView(LyXView * owner, int x, int y, int w, int h);
 
        ~BufferView();
+
        /// set the buffer we are viewing
        void buffer(Buffer * b);
        /// return the buffer being viewed
        Buffer * buffer() const;
+
        /// return the painter object for drawing onto the view
        Painter & painter() const;
        /// return the screen object for handling re-drawing
        LyXScreen & screen() const;
        /// return the owning main view
        LyXView * owner() const;
+
        /// resize event has happened
        void resize();
        /**
@@ -80,7 +80,7 @@ public:
         * repaint of the whole screen.
         */
        void repaint();
+
        /// fit the user cursor within the visible view
        bool fitCursor();
        /// perform pending painting updates
@@ -93,20 +93,20 @@ public:
        void updateScrollbar();
        /// FIXME
        void redoCurrentBuffer();
+
        /// FIXME
        bool available() const;
+
        /// FIXME
        void beforeChange(LyXText *);
+
        /// Save the current position as bookmark i
        void savePosition(unsigned int i);
        /// Restore the position from bookmark i
        void restorePosition(unsigned int i);
        /// does the given bookmark have a saved position ?
        bool isSavedPosition(unsigned int i);
+
        /**
         * This holds the mapping between buffer paragraphs and screen rows.
         * This should be private...but not yet. (Lgb)
@@ -114,7 +114,7 @@ public:
        LyXText * text;
        /// return the lyxtext we are using
        LyXText * getLyXText() const;
+
        /// Return the current inset we are "locked" in
        UpdatableInset * theLockingInset() const;
        /// lock the given inset FIXME: return value ?
@@ -123,10 +123,10 @@ public:
        int unlockInset(UpdatableInset * inset);
        /// unlock the currently locked inset
        void insetUnlock();
+
        /// return the parent language of the given inset
        Language const * getParentLanguage(Inset * inset) const;
+
        /// Select the "current" word
        void selectLastWord();
        /// replace the currently selected word
@@ -135,36 +135,36 @@ public:
        void endOfSpellCheck();
        /// return the next word
        WordLangTuple const nextWord(float & value);
+
        /// move cursor to the named label
        bool gotoLabel(string const & label);
+
        /// copy the environment type from current paragraph
        void copyEnvironment();
        /// set the current paragraph's environment type
        void pasteEnvironment();
+
        /// undo last action
        void undo();
        /// redo last action
        void redo();
+
        /// removes all autodeletable insets
        bool removeAutoInsets();
        /// insert all errors found when running latex
        void insertErrors(TeXErrors & terr);
        /// set the cursor based on the given TeX source row
        void setCursorFromRow(int row);
+
        /**
         * Insert an inset into the buffer.
         * Place it in a layout of lout,
         */
        bool insertInset(Inset * inset, string const & lout = string());
+
        /// Inserts a lyx file at cursor position. return false if it fails
        bool insertLyXFile(string const & file);
+
        /// show the user cursor
        void showCursor();
        /// hide the user cursor
@@ -181,7 +181,7 @@ public:
        void toggleSelection(bool = true);
        /// FIXME: my word !
        void toggleToggle();
+
        /// center the document view around the cursor
        void center();
        /// scroll document by the given number of lines of default height
@@ -203,24 +203,24 @@ public:
        bool ChangeRefsIfUnique(string const & from, string const & to);
        /// FIXME
        bool ChangeCitationsIfUnique(string const & from, string const & to);
+
        /// get the contents of the window system clipboard
        string const getClipboard() const;
        /// fill the window system clipboard
        void stuffClipboard(string const &) const;
        /// tell the window system we have a selection
        void haveSelection(bool sel);
+
        /// execute the given function
        bool dispatch(FuncRequest const & argument);
+
 private:
        /// Set the current locking inset
        void theLockingInset(UpdatableInset * inset);
+
        /// return the lyxtext containing this inset
        LyXText * getParentText(Inset * inset) const;
+
        /**
         * Change all insets with the given code's contents to a new
         * string. May only be used with InsetCommand-derived insets
@@ -228,7 +228,7 @@ private:
         */
        bool ChangeInsets(Inset::Code code, string const & from,
                          string const & to);
+
 
        struct Pimpl;
        friend struct BufferView::Pimpl;
index e1a9379bdc7f411248b561128d45e30f7efe2ddc..5e04f730ded42b0fd15364a49f742af949de9137 100644 (file)
@@ -1,3 +1,12 @@
+2002-12-01  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * text2.C (setCounter): clean up a bit, use boost.format.
+       (updateCounters): initialize par upon declaration.
+
+       * CutAndPaste.C (SwitchLayoutsBetweenClasses): set the layout also
+       if the layout exists. We do not just store the layout any more.
+       (SwitchLayoutsBetweenClasses): use boost.format
+
 2002-11-18  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * converter.C (convert): if from and to files are the same, use a
@@ -5,7 +14,7 @@
 
 2002-11-22  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
-       * commandtags.h: 
+       * commandtags.h:
        * LyXAction.C (init): remove LFUN_VECTOR (bug 662)
 
 2002-11-27  Dekel Tsur  <dekelts@tau.ac.il>
index 35fa6987dd7371083c33e3bcb4fb55d72ccba752..430927e37e7dcdb7ad5af2ff13d00dea26ad9cae 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "insets/inseterror.h"
 
+#include <boost/format.hpp>
+
 using std::pair;
 using lyx::pos_type;
 using lyx::textclass_type;
@@ -422,17 +424,32 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
                string const name = par->layout()->name();
                bool hasLayout = tclass2.hasLayout(name);
 
-               if (!hasLayout)
+               if (hasLayout)
+                       par->layout(tclass2[name]);
+               else
                        par->layout(tclass2.defaultLayout());
 
                if (!hasLayout && name != tclass1.defaultLayoutName()) {
                        ++ret;
+#if USE_BOOST_FORMAT
+                       boost::format fmt(_("Layout had to be changed from\n"
+                                           "%1$s to %2$s\n"
+                                           "because of class conversion from\n"
+                                           "%3$s to %4$s"));
+                       fmt     % name
+                               % par->layout()->name()
+                               % tclass1.name()
+                               % tclass2.name();
+
+                       string const s = fmt.str();
+#else
                        string const s = _("Layout had to be changed from\n")
                                + name + _(" to ")
                                + par->layout()->name()
                                + _("\nbecause of class conversion from\n")
                                + tclass1.name() + _(" to ")
                                + tclass2.name();
+#endif
                        freezeUndo();
                        InsetError * new_inset = new InsetError(s);
                        LyXText * txt = current_view->getLyXText();
index 0d0acd499377615979023131f69ddeae7c095ddd..bf54a2b68b6d0e13c8f74f912f08351fdb9dc162 100644 (file)
@@ -1,3 +1,7 @@
+2002-12-01  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * ControlDocument.C (classApply): use boost.format
+
 2002-11-29  Angus Leeming  <leeming@lyx.org>
 
        * ControlButtons.h (isClosing): make it public, so that the view can
@@ -11,8 +15,8 @@
        dialog isClosing(). (Ie, if the "save" button has been pressed.)
 
 2002-11-28  John Levon  <levon@movementarian.org>
-        * ControlSpellchecker.C: fix Lars' broken cleanup
+
+       * ControlSpellchecker.C: fix Lars' broken cleanup
 
 2002-11-27  Juergen Spitzmueller  <j.spitzmueller@gmx.de>
 
index b3c1c5d994d0a845825ecd4ab9ee579e97e4fe37..a8d5d90b14074e484a64976975766e43f98da912 100644 (file)
 #include "support/lstrings.h"
 #include "support/filetools.h"
 
+#include <boost/format.hpp>
+
+using std::endl;
+
 
 ControlDocument::ControlDocument(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d), bp_(0)
@@ -69,7 +73,7 @@ void ControlDocument::apply()
 
        view().apply();
        buffer()->params = *bp_;
-       
+
        lv_.view()->redoCurrentBuffer();
 
        buffer()->markDirty();
@@ -113,6 +117,7 @@ void ControlDocument::classApply()
        // successfully loaded
        view().apply();
        buffer()->params = *bp_;
+
        lv_.message(_("Converting document to new document class..."));
        int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
                old_class, new_class,
@@ -123,8 +128,14 @@ void ControlDocument::classApply()
                if (ret == 1) {
                        s = _("One paragraph couldn't be converted");
                } else {
+#if USE_BOOST_FORMAT
+                       boost::format fmt(_("%1$s paragraphs couldn't be converted"));
+                       fmt % ret;
+                       s = fmt.str();
+#else
                        s += tostr(ret);
                        s += _(" paragraphs couldn't be converted");
+#endif
                }
                Alert::alert(_("Conversion Errors!"),s,
                             _("into chosen document class"));
@@ -152,7 +163,7 @@ void ControlDocument::saveAsDefault()
                                _("for the document layout as default?"),
                                _("(they will be valid for any new document)")))
                return;
-               
+
        lv_.buffer()->params.preamble = bp_->preamble;
 
        string const fname = AddName(AddPath(user_lyxdir, "templates/"),
index e577d75b0c82c7f7d9ac84e454fc3701f0acc824..c2a0960653dff277d75135246d248f8d23bbf15c 100644 (file)
@@ -1,16 +1,21 @@
+2002-12-01  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * checkedwidgets.C (setWidget): make sure that FL_LCOL and FL_COL1
+       will be seen as FL_COLORs.
+
 2002-12-01  John Levon  <levon@movementarian.org>
 
        * FormMathsBitmap.C: fix _(_(blah))
+
 2002-11-30  John Levon  <levon@movementarian.org>
 
        * FormMathsBitmap.C: actually set dialog_->button_close
          to the added button
+
 2002-11-30  John Levon  <levon@movementarian.org>
 
        * forms/form_maths_panel.fd: small fix
+
 2002-11-29  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * lyx_gui.C (start): make "unhandled X11 event" debug message
index 0c1ad8942683715039af35f3ada56baa3e990e6e..7dbe15dc348f23d8811a7f9fe81df031754ad3c4 100644 (file)
@@ -430,7 +430,7 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
                           skip_used && length_input);
                setEnabled(class_->choice_doc_skip_units,
                           skip_used && length_input);
-       
+
                // Default unit choice is cm if metric, inches if US paper.
                // If papersize is default, check the lyxrc-settings
                int const paperchoice = fl_get_choice(paper_->choice_papersize);
index af8998f25ff0947174a3ca6afb044e3716c91ef3..34b863eeae6b0666d5f562939e628e374bacdad6 100644 (file)
@@ -46,7 +46,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label)
        // define color to mark invalid input
        FL_COLOR const alert_col = FL_RED;
 
-       FL_COLOR const lcol = valid ? FL_LCOL : alert_col;
+       FL_COLOR const lcol = valid ? FL_COLOR(FL_LCOL) : alert_col;
        if (label->lcol != lcol && isActive(label)) {
                fl_set_object_lcol(label, lcol);
        }
@@ -56,7 +56,7 @@ void setWidget(bool valid, FL_OBJECT * input, FL_OBJECT * label)
 
        // Reflect the validity of the data in the background color of the
        // input widget only when this widget is not being edited.
-       FL_COLOR const icol1 = valid ? FL_COL1 : alert_col;
+       FL_COLOR const icol1 = valid ? FL_COLOR(FL_COL1) : alert_col;
        if (input->col1 != icol1) {
                fl_set_object_color(input, icol1, FL_MCOL);
        }
index 085a5ed14674b53fc6f49453b03adac4b169aa3f..b0e73fd9e53b5605a1254dfda6e53f1a12730439 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-01  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * insetquotes.C (dispString): use string::insert for prepending a
+       char.
+
 2002-11-21  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * insetparent.C (getScreenLabel): use boost::format
index 3fb7beda0c6e1849d63c1c5eedb09c219363d8c1..2c862787e123fe52c87ccaaad687fce0e6d7d4c4 100644 (file)
@@ -178,7 +178,7 @@ string const InsetQuotes::dispString(Language const * loclang) const
                if (side_ == LeftQ)
                        disp += ' ';
                else
-                       disp = ' ' + disp;
+                       disp.insert(0, 1, ' ');
        }
 
        return disp;
index 176b9192e486ca46a6d649ae5219eff41d1e333c..e3da0556bc501a4fe67d7a720636ee653c4032b5 100644 (file)
@@ -485,7 +485,7 @@ private:
 
        ///
        void cursorLeftOneWord(LyXCursor &) const;
+
        ///
        float getCursorX(BufferView *, Row *, lyx::pos_type pos,
                                         lyx::pos_type last, bool boundary) const;
@@ -511,13 +511,13 @@ private:
        /** inserts a new row behind the specified row, increments
            the touched counters */
        void insertRow(Row * row, Paragraph * par, lyx::pos_type pos) const;
-       /// removes the row and reset the touched counters 
+       /// removes the row and reset the touched counters
        void removeRow(Row * row) const;
 
        /// remove all following rows of the paragraph of the specified row.
        void removeParagraph(Row * row) const;
 
-       /// insert the specified paragraph behind the specified row 
+       /// insert the specified paragraph behind the specified row
        void insertParagraph(BufferView *,
                             Paragraph * par, Row * row) const;
 
@@ -579,7 +579,7 @@ private:
 
        /// paint page break marker. Returns its height.
        int paintPageBreak(string const & label, int y, DrawRowParams & p);
+
        /// paint env depth bar
        void paintRowDepthBar(DrawRowParams & p);
 
@@ -613,7 +613,7 @@ public:
        /** Updates all counters starting BEHIND the row. Changed paragraphs
         * with a dynamic left margin will be rebroken. */
        void updateCounters(BufferView *) const;
-       /// 
+       ///
        void update(BufferView * bv, bool changed = true);
        /**
         * Returns an inset if inset was hit, or 0 if not.
@@ -671,7 +671,7 @@ private:
        ///
        lyx::pos_type beginningOfMainBody(Buffer const *, Paragraph const * par) const;
 
-       /** 
+       /**
         * Returns the left beginning of the text.
         * This information cannot be taken from the layout object, because
         * in LaTeX the beginning of the text fits in some cases
index 027e38bf2af9ca8f833215035302e7193fe695ed..dea60ba4481406e99e5cb6d56c6af4fc00356138 100644 (file)
@@ -45,6 +45,8 @@
 #include "support/textutils.h"
 #include "support/lstrings.h"
 
+#include <boost/format.hpp>
+
 using std::vector;
 using std::copy;
 using std::endl;
@@ -1218,30 +1220,24 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
 
        // is it a layout that has an automatic label?
        if (layout->labeltype >= LABEL_COUNTER_CHAPTER) {
+               int const i = layout->labeltype - LABEL_COUNTER_CHAPTER;
 
-               int i = layout->labeltype - LABEL_COUNTER_CHAPTER;
-               string numbertype;
-               string langtype;
                ostringstream s;
 
                if (i >= 0 && i <= buf->params.secnumdepth) {
+                       string numbertype;
+                       string langtype;
 
                        textclass.counters().step(layout->latexname());
 
                        // Is there a label? Useful for Chapter layout
                        if (!par->params().appendix()) {
-                               if (!layout->labelstring().empty())
-                                       par->params().labelString(layout->labelstring());
-                               else
-                                       par->params().labelString(string());
+                               s << layout->labelstring();
                        } else {
-                               if (!layout->labelstring_appendix().empty())
-                                       par->params().labelString(layout->labelstring_appendix());
-                               else
-                                       par->params().labelString(string());
+                               s << layout->labelstring_appendix();
                        }
 
-                       // Use if an integer is here less than elegant. For now.
+                       // Use of an integer is here less than elegant. For now.
                        int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER;
                        if (!par->params().appendix()) {
                                numbertype = "sectioning";
@@ -1257,8 +1253,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
                                .numberLabel(layout->latexname(),
                                             numbertype, langtype, head);
 
-                       par->params().labelString(par->params().labelString()
-                                                 + STRCONV(s.str()));
+                       par->params().labelString(STRCONV(s.str()));
 
                        // reset enum counters
                        textclass.counters().reset("enum");
@@ -1289,8 +1284,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
                        textclass.counters().step(enumcounter);
 
                        s << textclass.counters()
-                               .numberLabel(enumcounter,
-                                            "enumeration", langtype);
+                               .numberLabel(enumcounter, "enumeration");
                        par->params().labelString(STRCONV(s.str()));
                }
        } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
@@ -1331,15 +1325,22 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
                                textclass.counters().step(fl.type());
 
                                // Doesn't work... yet.
+#warning use boost.format
+#if USE_BOOST_FORMAT
+                               s = boost::io::str(boost::format(_("%1$s #:")) % fl.name());
+                               // s << boost::format(_("%1$s %1$d:")
+                               //        % fl.name()
+                               //        % buf->counters().value(fl.name());
+#else
                                ostringstream o;
                                //o << fl.name() << ' ' << buf->counters().value(fl.name()) << ":";
                                o << fl.name() << " #:";
                                s = STRCONV(o.str());
+#endif
                        } else {
                                // par->SetLayout(0);
                                // s = layout->labelstring;
-                               s = (par->getParLanguage(buf->params)->lang() == "hebrew")
-                                       ? " :úåòîùî øñç" : "Senseless: ";
+                               s = _("Senseless: ");
                        }
                }
                par->params().labelString(s);
@@ -1365,10 +1366,8 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
 // Updates all counters. Paragraphs with changed label string will be rebroken
 void LyXText::updateCounters(BufferView * bview) const
 {
-       Paragraph * par;
-
        Row * row = firstrow;
-       par = row->par();
+       Paragraph * par = row->par();
 
        // CHECK if this is really needed. (Lgb)
        bview->buffer()->params.getLyXTextClass().counters().reset();
@@ -1379,6 +1378,7 @@ void LyXText::updateCounters(BufferView * bview) const
 
                string const oldLabel = par->params().labelString();
 
+               // setCounter can potentially change the labelString.
                setCounter(bview->buffer(), par);
 
                string const & newLabel = par->params().labelString();