]> git.lyx.org Git - lyx.git/commitdiff
* insetbase.h: add new enum PAGEBREAK_CODE
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 2 Feb 2007 13:55:14 +0000 (13:55 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 2 Feb 2007 13:55:14 +0000 (13:55 +0000)
* insetpagebreak.h: use it

* insetcaption.C (insetAllowed): new method. Reduce the list of
forbidden insets
(dispatch): remove code handled above; re-allow some LFUNs.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17026 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/insetbase.h
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetpagebreak.h

index 3090fd32b2b50f216e16c41719284aa9cfb1d07a..7794811ad8d046c17aef5695107e64508e570527 100644 (file)
@@ -336,7 +336,9 @@ public:
                ///
                NOMENCL_CODE, // 45
                ///
-               NOMENCL_PRINT_CODE
+               NOMENCL_PRINT_CODE,
+               ///
+               PAGEBREAK_CODE
        };
 
        /** returns the Code corresponding to the \c name.
index a2d259dfee985eb867057ccfd79c3e579e5fc837..1814bb6022aea1de03bcb1ebaf67dcb8c4dce945 100644 (file)
@@ -27,6 +27,7 @@
 #include "LColor.h"
 #include "metricsinfo.h"
 #include "output_latex.h"
+#include "outputparams.h"
 #include "paragraph.h"
 #include "TocBackend.h"
 
@@ -179,38 +180,32 @@ InsetBase * InsetCaption::editXY(LCursor & cur, int x, int y)
 }
 
 
+bool InsetCaption::insetAllowed(InsetBase::Code code) const
+{
+       switch (code) {
+       case FLOAT_CODE:
+       case TABULAR_CODE:
+       case WRAP_CODE:
+       case CAPTION_CODE:
+       case PAGEBREAK_CODE:
+               return false;
+       default:
+               return InsetText::insetAllowed(code);
+       }
+}
+
+
 bool InsetCaption::getStatus(LCursor & cur, FuncRequest const & cmd,
        FuncStatus & status) const
 {
        switch (cmd.action) {
 
-       case LFUN_CAPTION_INSERT:
-       case LFUN_FLOAT_INSERT:
-       case LFUN_FLOAT_WIDE_INSERT:
-       case LFUN_WRAP_INSERT:
-       case LFUN_PARAGRAPH_MOVE_UP:
-       case LFUN_PARAGRAPH_MOVE_DOWN:
        case LFUN_BREAK_PARAGRAPH:
        case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
        case LFUN_BREAK_PARAGRAPH_SKIP:
-       case LFUN_PARAGRAPH_SPACING:
-       case LFUN_PAGEBREAK_INSERT:
-       case LFUN_TABULAR_INSERT:
                status.enabled(false);
                return true;
 
-       case LFUN_DIALOG_SHOW_NEW_INSET:
-       case LFUN_INSET_INSERT: {
-               string const name = cmd.getArg(0);
-               if (name == "float"
-                       || name == "graphics"
-                       || name == "include"
-                       || name == "wrap"
-                       ) {
-               status.enabled(false);
-               return true;
-               }
-       }
        default:
                return InsetText::getStatus(cur, cmd, status);
        }
@@ -218,13 +213,17 @@ bool InsetCaption::getStatus(LCursor & cur, FuncRequest const & cmd,
 
 
 int InsetCaption::latex(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+                       OutputParams const & runparams_in) const
 {
        // This is a bit too simplistic to take advantage of
        // caption options we must add more later. (Lgb)
        // This code is currently only able to handle the simple
        // \caption{...}, later we will make it take advantage
        // of the one of the caption packages. (Lgb)
+       OutputParams runparams = runparams_in;
+       // FIXME: actually, it is moving only when there is no
+       // optional argument.
+       runparams.moving_arg = true;
        os << "\\caption";
        int l = latexOptArgInsets(buf, paragraphs()[0], os, runparams, 1);
        os << '{';
index 52a8bf91afb23d2adfd17e340cd6e43c008b61d9..78537785980478f91a72d83f84bc971b882704dc 100644 (file)
@@ -52,6 +52,8 @@ public:
        ///
        virtual InsetBase * editXY(LCursor & cur, int x, int y);
        ///
+       bool insetAllowed(InsetBase::Code code) const;
+       ///
        virtual bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
        ///
        virtual bool wide() const { return false; }
index 57bb3b35f20d1dafce3f9d72307bc7c0c5c46b18..33f25aba9830c63ca83901c4254311d9de55eee6 100644 (file)
@@ -23,7 +23,7 @@ class InsetPagebreak : public InsetOld {
 public:
        InsetPagebreak() {}
 
-       InsetBase::Code lyxCode() const { return InsetBase::LINE_CODE; }
+       InsetBase::Code lyxCode() const { return InsetBase::PAGEBREAK_CODE; }
 
        bool metrics(MetricsInfo &, Dimension &) const;