]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetFlex.cpp
InsetIndex: revamp IndexEntry to handle both legacy and modern index insets; simplify...
[features.git] / src / insets / InsetFlex.cpp
index 61e47d4c367f1737a4e69e821937b4abf09040a9..e6076102f687ce9c428dc9c8574e68442653e307 100644 (file)
@@ -58,10 +58,10 @@ InsetLayout const & InsetFlex::getLayout() const
 }
 
 
-InsetLayout::InsetDecoration InsetFlex::decoration() const
+InsetDecoration InsetFlex::decoration() const
 {
-       InsetLayout::InsetDecoration const dec = getLayout().decoration();
-       return dec == InsetLayout::DEFAULT ? InsetLayout::CONGLOMERATE : dec;
+       InsetDecoration const dec = getLayout().decoration();
+       return dec == InsetDecoration::DEFAULT ? InsetDecoration::CONGLOMERATE : dec;
 }
 
 
@@ -94,13 +94,16 @@ bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
        switch (cmd.action()) {
+       case LFUN_INSET_SPLIT:
        case LFUN_INSET_DISSOLVE:
                if (!cmd.argument().empty()) {
                        InsetLayout const & il = getLayout();
-                       InsetLayout::InsetLyXType const type =
+                       InsetLyXType const type =
                                translateLyXType(to_utf8(cmd.argument()));
-                       if (il.lyxtype() == type) {
-                               FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
+                       if (il.lyxtype() == type
+                           || (il.name() == DocumentClass::plainInsetLayout().name()
+                                   && type == InsetLyXType::CHARSTYLE)) {
+                               FuncRequest temp_cmd(cmd.action());
                                return InsetCollapsible::getStatus(cur, temp_cmd, flag);
                        } else
                                return false;
@@ -115,14 +118,17 @@ bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
 void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action()) {
+       case LFUN_INSET_SPLIT:
        case LFUN_INSET_DISSOLVE:
                if (!cmd.argument().empty()) {
                        InsetLayout const & il = getLayout();
-                       InsetLayout::InsetLyXType const type =
+                       InsetLyXType const type =
                                translateLyXType(to_utf8(cmd.argument()));
 
-                       if (il.lyxtype() == type) {
-                               FuncRequest temp_cmd(LFUN_INSET_DISSOLVE);
+                       if (il.lyxtype() == type
+                           || (il.name() == DocumentClass::plainInsetLayout().name()
+                                   && type == InsetLyXType::CHARSTYLE)) {
+                               FuncRequest temp_cmd(cmd.action());
                                InsetCollapsible::doDispatch(cur, temp_cmd);
                        } else
                                cur.undispatched();
@@ -136,7 +142,7 @@ void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
-void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype)
+void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted)
 {
        BufferParams const & bp = buffer().masterBuffer()->params();
        InsetLayout const & il = getLayout();
@@ -146,9 +152,13 @@ void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype)
        docstring const & count = il.counter();
        bool const have_counter = cnts.hasCounter(count);
        if (have_counter) {
-               cnts.step(count, utype);
-               custom_label += ' ' +
-                       cnts.theCounter(count, it.paragraph().getParLanguage(bp)->code());
+               Paragraph const & par = it.paragraph();
+               if (!par.isDeleted(it.pos())) {
+                       cnts.step(count, utype);
+                       custom_label += ' ' +
+                               cnts.theCounter(count, it.paragraph().getParLanguage(bp)->code());
+               } else
+                       custom_label += ' ' + from_ascii("#");
        }
        setLabel(custom_label);
 
@@ -159,7 +169,7 @@ void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype)
                // need a layout flag
                cnts.saveLastCounter();
        }
-       InsetCollapsible::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype, deleted);
        if (save_counter)
                cnts.restoreLastCounter();
 }