]> git.lyx.org Git - features.git/commitdiff
Extract InsetParams superclass
authorYuriy Skalko <yuriy.skalko@gmail.com>
Sun, 6 Dec 2020 09:24:01 +0000 (11:24 +0200)
committerYuriy Skalko <yuriy.skalko@gmail.com>
Fri, 15 Jan 2021 19:09:14 +0000 (21:09 +0200)
20 files changed:
src/Makefile.am
src/insets/Inset.h
src/insets/InsetBox.h
src/insets/InsetBranch.h
src/insets/InsetCommandParams.h
src/insets/InsetFloat.h
src/insets/InsetIPAMacro.h
src/insets/InsetIndex.h
src/insets/InsetListings.h
src/insets/InsetListingsParams.cpp
src/insets/InsetListingsParams.h
src/insets/InsetNewline.h
src/insets/InsetNewpage.h
src/insets/InsetNote.h
src/insets/InsetParams.h [new file with mode: 0644]
src/insets/InsetPhantom.h
src/insets/InsetScript.h
src/insets/InsetSeparator.h
src/insets/InsetSpace.h
src/insets/InsetWrap.h

index 31701f2fb154735a9f1b5fb3f19c269fc37b8468..7dec8a1a6d4e20e6da50246aa20ee21e20e5b249 100644 (file)
@@ -639,6 +639,7 @@ HEADERFILESINSETS = \
        insets/InsetNewpage.h \
        insets/InsetNomencl.h \
        insets/InsetNote.h \
+       insets/InsetParams.h \
        insets/InsetPhantom.h \
        insets/InsetQuotes.h \
        insets/InsetRef.h \
index 824ba4617295a02f8efeb30a4340da0178b3613a..e0834a0001de87be7887eb21c82a37a55a6871f7 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "ColorCode.h"
 #include "InsetCode.h"
+#include "InsetParams.h"
 #include "LayoutEnums.h"
 #include "OutputEnums.h"
 #include "OutputParams.h"
index cc80da3ecd219a8de3426f344313d2febd0b3c90..a0a2334df9bd798c32b3fd7ef1dd059c0a7e64db 100644 (file)
 
 namespace lyx {
 
-class InsetBoxParams
+class InsetBoxParams : public InsetParams
 {
 public:
        ///
        explicit InsetBoxParams(std::string const &);
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
 
        ///
        std::string type;
index 6106ce5a5c3babbd8923c8783d5e2a2d59cf9b6b..fdde0a18160ecd62f00984df5baf73d187eca6bc 100644 (file)
@@ -16,7 +16,7 @@
 
 namespace lyx {
 
-class InsetBranchParams {
+class InsetBranchParams : public InsetParams {
 public:
        ///
        explicit InsetBranchParams(docstring const & b = docstring())
@@ -24,9 +24,9 @@ public:
        InsetBranchParams(docstring const & b, bool i)
                : branch(b), inverted(i) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        docstring branch;
        ///
index 1800fb599d8998cfe974ea7513d419646a519ab4..4e417ad94d14def879cd09cb50815f52d32eaaf8 100644 (file)
@@ -15,6 +15,7 @@
 #define INSETCOMMANDPARAMS_H
 
 #include "InsetCode.h"
+#include "InsetParams.h"
 
 #include "support/docstring.h"
 
@@ -115,7 +116,7 @@ private:
 };
 
 
-class InsetCommandParams {
+class InsetCommandParams : public InsetParams {
 public:
        /// Construct parameters for inset of type \p code.
        explicit InsetCommandParams(InsetCode code);
@@ -128,11 +129,11 @@ public:
        ///
        InsetCode code() const { return insetCode_; }
        /// Parse the command
-       void read(Lexer &);
+       void read(Lexer &) override;
        ///
        void Read(Lexer &, Buffer const *);
        ///
-       void write(std::ostream &) const;
+       void write(std::ostream &) const override;
        ///
        void Write(std::ostream & os, Buffer const * buf) const;
        /// Build the complete LaTeX command
index 0fc0fba39862b126c441d98d52d72168456dd8e1..daa5b3181dafa3c54990fd38fe46218f0e685e21 100644 (file)
@@ -21,16 +21,16 @@ namespace lyx {
 struct TexString;
 
 
-class InsetFloatParams
+class InsetFloatParams : public InsetParams
 {
 public:
        ///
        InsetFloatParams() : type("senseless"), placement("document"), alignment("document"),
                wide(false), sideways(false), subfloat(false) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        std::string type;
        ///
index 3305e6bf6e0f1f282dd3e01c5d79f5d58eca7507..432bb5a897b0c1cf356c6e70ff29f9e802403bfa 100644 (file)
@@ -21,7 +21,7 @@ namespace lyx {
 
 class LaTeXFeatures;
 
-class InsetIPADecoParams
+class InsetIPADecoParams : public InsetParams
 {
 public:
        enum Type {
@@ -31,9 +31,9 @@ public:
        ///
        InsetIPADecoParams();
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Type type;
 };
index bddb8ba380edb96667fb95f3e3dd82133c7f2d73..b2038536f2e98c8236c021359112352e7a412225 100644 (file)
 
 namespace lyx {
 
-class InsetIndexParams {
+class InsetIndexParams : public InsetParams {
 public:
        ///
        explicit InsetIndexParams(docstring const & b = docstring())
                : index(b) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        docstring index;
 };
index 41be4394ceb9a8c9431946c11b993395e6dbdebc..1a8007864538c2b4cfea2f7c23145d512838ba25 100644 (file)
@@ -12,9 +12,9 @@
 #ifndef INSET_LISTINGS_H
 #define INSET_LISTINGS_H
 
+#include "InsetCaptionable.h"
 #include "InsetListingsParams.h"
 
-
 namespace lyx {
 
 class LaTeXFeatures;
index 9390d6bbe4549867005cfe5e2ed3b2c8add7cecf..8ffb4387974b8be06fd58b4275c4abbfecc2c3b6 100644 (file)
@@ -9,18 +9,18 @@
  */
 
 #include <config.h>
-#include <algorithm>
 
 #include "InsetListingsParams.h"
 
-#include "support/Length.h"
 #include "Lexer.h"
 
 #include "support/convert.h"
 #include "support/gettext.h"
+#include "support/Length.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
+#include <algorithm>
 #include <sstream>
 
 using namespace std;
index 90c5adb763fa13d1c9ab8e96cefacc863abaedef..7497110738abbbd0bd0ef450a185001e71c91963 100644 (file)
 #ifndef INSETLISTINGSPARAMS_H
 #define INSETLISTINGSPARAMS_H
 
-#include "InsetCaptionable.h"
+#include "InsetCollapsible.h"
 
 #include <map>
 
 namespace lyx {
 
-class InsetListingsParams {
+class InsetListingsParams : public InsetParams {
 public:
        ///
        InsetListingsParams();
@@ -28,10 +28,10 @@ public:
                InsetCollapsible::CollapseStatus s = InsetCollapsible::Open);
 
        /// write parameters to an ostream
-       void write(std::ostream &) const;
+       void write(std::ostream &) const override;
 
        /// read parameters from an ostream
-       void read(Lexer &);
+       void read(Lexer &) override;
 
        /// valid parameter string
        std::string params(std::string const & sep=",") const;
index 3d540a8618467bccda3074d48d092b87d18bebe0..10f894d1e67e47b6aef36a9774985ed49bf106af 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace lyx {
 
-class InsetNewlineParams
+class InsetNewlineParams : public InsetParams
 {
 public:
        /// The different kinds of spaces we support
@@ -30,9 +30,9 @@ public:
        ///
        InsetNewlineParams() : kind(NEWLINE) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Kind kind;
 };
index f02048804d43c70f975d81f813b013defa761828..633b81ffd7a547634e1cabc6b376bc4b74791485 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace lyx {
 
-class InsetNewpageParams
+class InsetNewpageParams : public InsetParams
 {
 public:
        /// The different kinds of spaces we support
@@ -36,9 +36,9 @@ public:
        ///
        InsetNewpageParams() : kind(NEWPAGE) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Kind kind;
 };
index aeab8f038b282084ec43a7636b4ffacfd500efb0..bf14e147588bd16e9160392b50c1739b8fa3dd9c 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace lyx {
 
-class InsetNoteParams
+class InsetNoteParams : public InsetParams
 {
 public:
        enum Type {
@@ -28,9 +28,9 @@ public:
        /// \c type defaults to Note
        InsetNoteParams();
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Type type;
 };
diff --git a/src/insets/InsetParams.h b/src/insets/InsetParams.h
new file mode 100644 (file)
index 0000000..0d70603
--- /dev/null
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+/**
+ * \file InsetParams.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Yuriy Skalko
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef INSETPARAMS_H
+#define INSETPARAMS_H
+
+#include <ostream>
+
+namespace lyx {
+
+class Lexer;
+
+
+class InsetParams
+{
+public:
+       ///
+       virtual ~InsetParams() = default;
+       ///
+       virtual void write(std::ostream & os) const = 0;
+       ///
+       virtual void read(Lexer & lex) = 0;
+};
+
+
+} // namespace lyx
+
+#endif // INSETPARAMS_H
index 72281df2ae26e7181c54927187275063ad9945d4..2ca9b056221625faf3b394531220e34508c70c36 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace lyx {
 
-class InsetPhantomParams
+class InsetPhantomParams : public InsetParams
 {
 public:
        enum Type {
@@ -28,9 +28,9 @@ public:
        /// \c type defaults to Phantom
        InsetPhantomParams();
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Type type;
 };
index 9eb80dbbd5032c9866366b19cf6c72082f5d79e4..e4a9da7621c223aa752d028a4b33d26d747e4c91 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace lyx {
 
-class InsetScriptParams
+class InsetScriptParams : public InsetParams
 {
 public:
        enum Type {
@@ -28,9 +28,9 @@ public:
        /// \c type defaults to Subscript
        InsetScriptParams();
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        int shift(FontInfo const & font) const;
        ///
index f7e0ab90597676db964a52f80c57aad32bf1538b..212d3894b434d23635b53ea3c9b076bd1c3cebeb 100644 (file)
@@ -17,7 +17,7 @@
 
 namespace lyx {
 
-class InsetSeparatorParams
+class InsetSeparatorParams : public InsetParams
 {
 public:
        /// The different kinds of separators we support
@@ -29,9 +29,9 @@ public:
        ///
        InsetSeparatorParams() : kind(PLAIN) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Kind kind;
 };
index 5cf7aa7303d2458065d7a8e8eec03cc1a6e2ff1b..a4fb63357fe03773e7efddf7697e58542168dd52 100644 (file)
@@ -24,7 +24,7 @@ namespace lyx {
 
 class LaTeXFeatures;
 
-struct InsetSpaceParams {
+struct InsetSpaceParams : public InsetParams {
        /// The different kinds of spaces we support
        enum Kind {
                /// Normal space ('\ ')
@@ -77,9 +77,9 @@ struct InsetSpaceParams {
        ///
        explicit InsetSpaceParams(bool m = false) : kind(NORMAL), math(m) {}
        ///
-       void write(std::ostream & os) const;
+       void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex);
+       void read(Lexer & lex) override;
        ///
        Kind kind;
        ///
index 02e0a202b61cb37d5e68ebaa5d1571b8315e0ac1..bbf4000820965a6cf4f08cbad58269fbad82932a 100644 (file)
 namespace lyx {
 
 
-class InsetWrapParams {
+class InsetWrapParams : public InsetParams {
 public:
        ///
-       void write(std::ostream &) const;
+       void write(std::ostream &) const override;
        ///
-       void read(Lexer &);
+       void read(Lexer &) override;
 
        ///
        std::string type;