]> git.lyx.org Git - lyx.git/commitdiff
De-serialization of the paragraph settings dialog step 1: use current paragraph directly.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 26 Sep 2007 07:34:57 +0000 (07:34 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 26 Sep 2007 07:34:57 +0000 (07:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20510 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlParagraph.cpp
src/frontends/controllers/ControlParagraph.h
src/frontends/qt4/GuiParagraph.cpp

index 4df90883d0988595a2143f246523d7733aed10f6..9480c9d1122d5d98486d2fefe6e2eaa90806f790 100644 (file)
@@ -31,106 +31,26 @@ namespace lyx {
 namespace frontend {
 
 ControlParagraph::ControlParagraph(Dialog & parent)
-       : Controller(parent), ininset_(false)
+       : Controller(parent)
 {}
 
 
-bool ControlParagraph::initialiseParams(string const & data)
+ParagraphParameters & ControlParagraph::params()
 {
-       istringstream is(data);
-       Lexer lex(0,0);
-       lex.setStream(is);
-
-       // Set tri-state flag:
-       // action == 0: show dialog
-       // action == 1: update dialog, accept changes
-       // action == 2: update dialog, do not accept changes
-       int action = 0;
-
-       if (lex.isOK()) {
-               lex.next();
-               string const token = lex.getString();
-
-               if (token == "show") {
-                       action = 0;
-               } else if (token == "update") {
-                       lex.next();
-                       bool const accept = lex.getBool();
-                       if (lex) {
-                               action = accept ? 1 : 2;
-                       } else {
-                               // Unrecognised update option
-                               return false;
-                       }
-               } else if (!token.empty()) {
-                       // Unrecognised token
-                       return false;
-               }
-       }
-
-       ParagraphParameters tmp;
-       tmp.read(lex);
-
-       // For now, only reset the params on "show".
-       // Don't bother checking if the params are different on "update"
-       if (action == 0)
-               params_ = tmp;
-
-       // Read the rest of the data irrespective of "show" or "update"
-       int nset = 0;
-       while (lex.isOK()) {
-               lex.next();
-               string const token = lex.getString();
-
-               if (token.empty())
-                       continue;
-
-               int Int = 0;
-               if (token == "\\alignpossible" ||
-                   token == "\\aligndefault" ||
-                   token == "\\ininset") {
-                       lex.next();
-                       Int = lex.getInteger();
-               } else {
-                       // Unrecognised token
-                       return false;
-               }
-
-               ++nset;
-
-               if (token == "\\alignpossible") {
-                       alignpossible_ = static_cast<LyXAlignment>(Int);
-               } else if (token == "\\aligndefault") {
-                       aligndefault_ = static_cast<LyXAlignment>(Int);
-               } else {
-                       ininset_ = Int;
-               }
-       }
-       if (nset != 3) {
-               return false;
-       }
-
-       // If "update", then set the activation status of the button controller
-       if (action > 0) {
-               bool const accept = action == 1;
-               dialog().setButtonsValid(accept);
-       }
-       return true;
+       return bufferview()->cursor().paragraph().params();
 }
 
 
-void ControlParagraph::clearParams()
+ParagraphParameters const & ControlParagraph::params() const
 {
-       params_ = ParagraphParameters();
+       return bufferview()->cursor().paragraph().params();
 }
 
 
 void ControlParagraph::dispatchParams()
 {
-       ostringstream data;
-       params().write(data);
-       FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
-       dispatch(fr);
+       bufferview()->updateMetrics(false);
+       bufferview()->buffer().changed();
 }
 
 
@@ -150,13 +70,13 @@ bool ControlParagraph::canIndent() const
 
 LyXAlignment ControlParagraph::alignPossible() const
 {
-       return alignpossible_;
+       return bufferview()->cursor().paragraph().layout()->alignpossible;
 }
 
 
 LyXAlignment ControlParagraph::alignDefault() const
 {
-       return aligndefault_;
+       return bufferview()->cursor().paragraph().layout()->align;
 }
 
 } // namespace frontend
index d396771094a5808ded9c57c7c5c0fab8682a14a5..1abf56f0e52c7d4995aa1d5ce501a0ee9a909f7f 100644 (file)
@@ -25,37 +25,25 @@ public:
        ///
        ControlParagraph(Dialog &);
        ///
-       virtual bool initialiseParams(std::string const & data);
+       virtual bool initialiseParams(std::string const & data) { return true; }
        /// clean-up on hide.
-       virtual void clearParams();
+       virtual void clearParams() {}
        ///
        virtual void dispatchParams();
        ///
        virtual bool isBufferDependent() const { return true; }
        ///
-       ParagraphParameters & params() { return params_; }
+       ParagraphParameters & params();
        ///
-       ParagraphParameters const & params() const { return params_; }
+       ParagraphParameters const & params() const;
        ///
        bool haveMulitParSelection();
        ///
-       bool inInset() const { return ininset_; }
-       ///
        bool canIndent() const;
        ///
        LyXAlignment alignPossible() const;
        ///
        LyXAlignment alignDefault() const;
-
-private:
-       ///
-       ParagraphParameters params_;
-       ///
-       bool ininset_;
-       ///
-       LyXAlignment alignpossible_;
-       ///
-       LyXAlignment aligndefault_;
 };
 
 } // namespace frontend
index 0606fca896aa97c5798646cfa4f548495882fa43..11c43934771126780323bb4bf82db1825ac44cd0 100644 (file)
@@ -166,6 +166,11 @@ LyXAlignment GuiParagraphDialog::getAlignmentFromDialog()
 
 void GuiParagraphDialog::applyView()
 {
+       // FIXME: We should not access params() at all!
+       // we should just pass the relevant GUI information
+       // and let the controller do the rest.
+       // With this architecture, only current parent paragraph will be
+       // modified when we have a multi-paragraph selection.
        ParagraphParameters & params = controller().params();
 
        params.align(getAlignmentFromDialog());