From 2b2d71d8e2ae8a56321561933e86fbd23109d2f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 7 Aug 2003 11:59:09 +0000 Subject: [PATCH] merge parts of InsetText and LyXText::dispatch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7518 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 +++ src/insets/ChangeLog | 7 +++ src/insets/inset.C | 25 +++++++++ src/insets/inset.h | 24 ++------- src/insets/insettext.C | 112 ++++++----------------------------------- src/paragraph.C | 4 +- src/text3.C | 3 -- 7 files changed, 58 insertions(+), 123 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b4fa9dd946..819a60d3f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ + +2003-08-07 André Pönitz + + * paragraph.C: + * text3.C: merge some LFUN handlers, remove dead code + 2003-08-06 Jean-Marc Lasgouttes * .cvsignore: add lyx-xforms, lyx-qt, version.C-tmp and stamp-version diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 42e80a98bf..cbcf20d5cc 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,4 +1,11 @@ +2003-08-07 André Pönitz + + * inset.[Ch]: move non-crucial functions out-of-line + + * insettext.C: rely on LyXText's LFUN handlers in some more cases, + remove duplicated code. + 2003-08-05 André Pönitz * insetbibitem.C: diff --git a/src/insets/inset.C b/src/insets/inset.C index 07fe683d1e..3605985180 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -159,3 +159,28 @@ int InsetOld::width() const { return dim_.wid; } + + +bool InsetOld::insetAllowed(InsetOld * in) const +{ + return insetAllowed(in->lyxCode()); +} + + +bool InsetOld::checkInsertChar(LyXFont &) +{ + return false; +} + + +bool isEditableInset(InsetOld const * i) +{ + return i && i->editable(); +} + + +bool isHighlyEditableInset(InsetOld const * i) +{ + return i && i->editable() == InsetOld::HIGHLY_EDITABLE; +} + diff --git a/src/insets/inset.h b/src/insets/inset.h index 8acdb59699..f25590b2be 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -347,35 +347,17 @@ private: }; -inline -bool InsetOld::insetAllowed(InsetOld * in) const -{ - return insetAllowed(in->lyxCode()); -} - - -inline -bool InsetOld::checkInsertChar(LyXFont &) -{ - return false; -} - /** * returns true if pointer argument is valid * and points to an editable inset */ -inline bool isEditableInset(InsetOld const * i) -{ - return i && i->editable(); -} +bool isEditableInset(InsetOld const * i); + /** * returns true if pointer argument is valid * and points to a highly editable inset */ -inline bool isHighlyEditableInset(InsetOld const * i) -{ - return i && i->editable() == InsetOld::HIGHLY_EDITABLE; -} +bool isHighlyEditableInset(InsetOld const * i); #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 1a1d971f2b..d2b4e257ef 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -776,10 +776,9 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) break; } - bool was_empty = (paragraphs.begin()->empty() && - paragraphs.size() == 1); - + bool was_empty = paragraphs.begin()->empty() && paragraphs.size() == 1; no_selection = false; + RESULT result = UpdatableInset::localDispatch(cmd); if (result != UNDISPATCHED) return DISPATCHED; @@ -848,16 +847,14 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) recordUndo(bv, Undo::INSERT, text_.cursor.par()); #endif bv->switchKeyMap(); - if (lyxrc.auto_region_delete) { - if (text_.selection.set()) { - text_.cutSelection(false, false); - } - } + + if (lyxrc.auto_region_delete && text_.selection.set()) + text_.cutSelection(false, false); text_.clearSelection(); - for (string::size_type i = 0; i < cmd.argument.length(); ++i) { + + for (string::size_type i = 0; i < cmd.argument.length(); ++i) bv->owner()->getIntl().getTransManager(). TranslateAndInsert(cmd.argument[i], &text_); - } } text_.selection.cursor = text_.cursor; updflag = true; @@ -903,53 +900,21 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) } break; - case LFUN_BACKSPACE: { + case LFUN_BACKSPACE: if (text_.selection.set()) text_.cutSelection(true, false); else text_.backspace(); updflag = true; break; - } - case LFUN_DELETE: { - if (text_.selection.set()) { + case LFUN_DELETE: + if (text_.selection.set()) text_.cutSelection(true, false); - } else { + else text_.Delete(); - } - updflag = true; - break; - } - - case LFUN_CUT: { - text_.cutSelection(true, true); - updflag = true; - break; - } - - case LFUN_COPY: - finishUndo(); - text_.copySelection(); - break; - - case LFUN_PASTESELECTION: - { - string const clip(bv->getClipboard()); - - if (clip.empty()) - break; - if (cmd.argument == "paragraph") { - text_.insertStringAsParagraphs(clip); - } else { - text_.insertStringAsLines(clip); - } - // bug 393 - text_.clearSelection(); - updflag = true; break; - } case LFUN_PASTE: { if (!autoBreakRows) { @@ -1015,7 +980,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) string cur_layout = cpar()->layout()->name(); // Derive layout number from given argument (string) - // and current buffer's textclass (number). */ + // and current buffer's textclass (number). LyXTextClass const & tclass = bv->buffer()->params.getLyXTextClass(); string layout = cmd.argument; @@ -1023,8 +988,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) // If the entry is obsolete, use the new one instead. if (hasLayout) { - string const & obs = - tclass[layout]->obsoleted_by(); + string const & obs = tclass[layout]->obsoleted_by(); if (!obs.empty()) layout = obs; } @@ -1047,52 +1011,6 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) bv->owner()->setLayout(cpar()->layout()->name()); } break; - case LFUN_PARAGRAPH_SPACING: - // This one is absolutely not working. When fiddling with this - // it also seems to me that the paragraphs inside the insettext - // inherit bufferparams/paragraphparams in a strange way. (Lgb) - // FIXME: how old is this comment ? ... - { - ParagraphList::iterator pit = text_.cursor.par(); - Spacing::Space cur_spacing = pit->params().spacing().getSpace(); - float cur_value = 1.0; - if (cur_spacing == Spacing::Other) { - cur_value = pit->params().spacing().getValue(); - } - - istringstream istr(STRCONV(cmd.argument)); - string tmp; - istr >> tmp; - Spacing::Space new_spacing = cur_spacing; - float new_value = cur_value; - if (tmp.empty()) { - lyxerr << "Missing argument to `paragraph-spacing'" - << endl; - } else if (tmp == "single") { - new_spacing = Spacing::Single; - } else if (tmp == "onehalf") { - new_spacing = Spacing::Onehalf; - } else if (tmp == "double") { - new_spacing = Spacing::Double; - } else if (tmp == "other") { - new_spacing = Spacing::Other; - float tmpval = 0.0; - istr >> tmpval; - lyxerr << "new_value = " << tmpval << endl; - if (tmpval != 0.0) - new_value = tmpval; - } else if (tmp == "default") { - new_spacing = Spacing::Default; - } else { - lyxerr << _("Unknown spacing argument: ") - << cmd.argument << endl; - } - if (cur_spacing != new_spacing || cur_value != new_value) { - pit->params().spacing(Spacing(new_spacing, new_value)); - updflag = true; - } - } - break; default: if (!bv->dispatch(cmd)) @@ -1182,7 +1100,6 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const ParagraphList::iterator pend = const_cast(paragraphs).end(); for (; pit != pend; ++pit) { - string sgmlparam; int desc_on = 0; // description mode LyXLayout_ptr const & style = pit->layout(); @@ -1289,7 +1206,8 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const } break; case LATEX_ITEM_ENVIRONMENT: - if (desc_on == 1) break; + if (desc_on == 1) + break; end_tag= "para"; lines += sgml::closeTag(os, depth + 1 + command_depth, mixcont, end_tag); break; diff --git a/src/paragraph.C b/src/paragraph.C index c5d0fa4a91..23ac05dda2 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -349,8 +349,8 @@ lyx::pos_type Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const return cit->pos(); // This should not happen, but if so, we take no chances. - lyxerr << "Pararaph::getEndPosOfFontSpan: This should not happen!" - << endl; + //lyxerr << "Paragraph::getEndPosOfFontSpan: This should not happen!" + // << endl; return pos; } diff --git a/src/text3.C b/src/text3.C index fc2c2e6127..0cdf9f9b45 100644 --- a/src/text3.C +++ b/src/text3.C @@ -1116,7 +1116,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd) if (change_layout) { current_layout = layout; - update(); setLayout(layout); bv->owner()->setLayout(layout); update(); @@ -1126,8 +1125,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd) } case LFUN_PASTESELECTION: { - if (!bv->buffer()) - break; // this was originally a beforeChange(bv->text), i.e // the outermost LyXText! bv->beforeChange(this); -- 2.39.2