From: Jean-Marc Lasgouttes Date: Fri, 2 Feb 2007 13:55:14 +0000 (+0000) Subject: * insetbase.h: add new enum PAGEBREAK_CODE X-Git-Tag: 1.6.10~10929 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8615d0a6fac5c4424ff68bb29468f185acce766b;p=lyx.git * insetbase.h: add new enum PAGEBREAK_CODE * 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 --- diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 3090fd32b2..7794811ad8 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -336,7 +336,9 @@ public: /// NOMENCL_CODE, // 45 /// - NOMENCL_PRINT_CODE + NOMENCL_PRINT_CODE, + /// + PAGEBREAK_CODE }; /** returns the Code corresponding to the \c name. diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index a2d259dfee..1814bb6022 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -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 << '{'; diff --git a/src/insets/insetcaption.h b/src/insets/insetcaption.h index 52a8bf91af..7853778598 100644 --- a/src/insets/insetcaption.h +++ b/src/insets/insetcaption.h @@ -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; } diff --git a/src/insets/insetpagebreak.h b/src/insets/insetpagebreak.h index 57bb3b35f2..33f25aba98 100644 --- a/src/insets/insetpagebreak.h +++ b/src/insets/insetpagebreak.h @@ -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;