]> git.lyx.org Git - features.git/commitdiff
Introduce Inset::validate() for Inset validation purpose upon interactive creation...
authorAbdelrazak Younes <younes@lyx.org>
Sun, 2 Mar 2008 18:14:12 +0000 (18:14 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 2 Mar 2008 18:14:12 +0000 (18:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23399 a592a061-630c-0410-9148-cb99ea01b6c8

src/Cursor.cpp
src/insets/Inset.h
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h

index 0854e242ae07269116e92755df9e02efda57f782..05dfc5b9d3c45d22a2612d2e9cd0197c66459574 100644 (file)
@@ -1027,6 +1027,7 @@ void Cursor::insert(Inset * inset0)
        else
                text()->insertInset(*this, inset0);
        inset().setBuffer(bv_->buffer());
+       inset().validate();
 }
 
 
index c2d1a21b90b264f0395069c0e230fa526be3893d..949ede774e8a037e1887ef930d88f2ecfb18f7b9 100644 (file)
@@ -91,11 +91,20 @@ public:
        virtual ~Inset() {}
 
        /// change associated Buffer
+       /// FIXME this should go.
        virtual void setBuffer(Buffer & buffer);
        /// retrieve associated Buffer
        virtual Buffer & buffer();
        virtual Buffer const & buffer() const;
 
+       /// validate inset.
+       /**
+         * This is typically used after this inset is created interactively.
+         * Intented purpose is to sanitize internal state with regard to current
+         * Buffer.
+         **/
+       virtual void validate() {}
+
        /// identification as math inset
        virtual InsetMath * asInsetMath() { return 0; }
        /// true for 'math' math inset, but not for e.g. mbox
index 9a9cb31ddd59836ae328696743631992f812ce4c..5f4753b66f53fb3ec3e94fd7b72a2727e8b278de 100644 (file)
@@ -43,12 +43,15 @@ InsetLabel::InsetLabel(InsetCommandParams const & p)
 {}
 
 
+void InsetLabel::validate()
+{
+       update(getParam("name"));
+}
+
+
 void InsetLabel::update(docstring const & new_label)
 {
        docstring const old_label = getParam("name");
-       if (old_label == new_label)
-               return;
-
        docstring label = new_label;
        int i = 0;
        while (buffer().insetLabel(label)) {
index e9e2669c10d0552b252079e650927f8ab319f3b8..f051a38addc9c9eca300cf7bcdfce81fa26d88ce 100644 (file)
@@ -21,6 +21,13 @@ class InsetLabel : public InsetCommand {
 public:
        ///
        InsetLabel(InsetCommandParams const &);
+
+       /// verify label and update references.
+       /**
+         * Overloaded from Inset::validate.
+         **/
+       void validate();
+
        ///
        docstring screenLabel() const;
        ///