insets/InsetNewpage.cpp \
insets/InsetNomencl.cpp \
insets/InsetNote.cpp \
+ insets/InsetParams.cpp \
insets/InsetPhantom.cpp \
insets/InsetPreview.cpp \
insets/InsetQuotes.cpp \
}
-string InsetBoxParams::toString() const
-{
- ostringstream data;
- data << "box" << ' ';
- write(data);
- return data.str();
-}
-
-
void InsetBox::string2params(string const & in, InsetBoxParams & params)
{
if (in.empty())
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "box"; }
///
std::string type;
}
-string InsetBranchParams::toString() const
-{
- ostringstream data;
- write(data);
- return data.str();
-}
-
-
void InsetBranch::string2params(string const & in, InsetBranchParams & params)
{
params = InsetBranchParams();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
- ///
docstring branch;
///
bool inverted;
}
+string InsetCommandParams::name() const
+{
+ return insetName(code());
+}
+
+
bool InsetCommandParams::writeEmptyOptional(ParamInfo::const_iterator ci) const
{
LASSERT(ci->isOptional(), return false);
}
-string InsetCommandParams::toString() const
-{
- ostringstream data;
- data << insetName(code()) << ' ';
- write(data);
- data << "\\end_inset\n";
- return data.str();
-}
-
-
docstring const & InsetCommandParams::operator[](string const & name) const
{
static const docstring dummy;
///
void Write(std::ostream & os, Buffer const * buf) const;
///
- std::string toString() const override;
+ std::string name() const override;
+ bool writeEndInset() const override { return true; }
/// Build the complete LaTeX command
docstring getCommand(OutputParams const &) const;
/// Return the command name
}
-string InsetERTParams::toString() const
-{
- ostringstream data;
- data << "ert" << ' ';
- write(data);
- return data.str();
-}
-
-
docstring InsetERT::xhtml(XMLStream &, OutputParams const &) const
{
return docstring();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "ert"; }
///
CollapseStatus status_;
};
}
-string InsetExternalParams::toString() const
-{
- ostringstream data;
- data << "external" << ' ';
- write(data);
- data << "\\end_inset\n";
- return data.str();
-}
-
} // namespace lyx
void write(std::ostream &) const override;
void read(Lexer &) override;
- std::string toString() const override;
+ std::string name() const override { return "external"; }
+ bool writeEndInset() const override { return true; }
Buffer const * buffer() { return buffer_; }
void setBuffer(Buffer const * b) { buffer_ = b; }
}
-string InsetFloatParams::toString() const
-{
- ostringstream data;
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
- ///
std::string type;
///
std::string placement;
}
-string InsetGraphicsParams::toString() const
+void InsetGraphicsParams::read(Lexer & lex)
{
- ostringstream data;
- data << "graphics" << ' ';
- write(data);
- data << "\\end_inset\n";
- return data.str();
+ // TODO
}
/// This class holds all the parameters needed by insetGraphics.
-class InsetGraphicsParams
+class InsetGraphicsParams : public InsetParams
{
public:
/// Image filename.
InsetGraphicsParams & operator=(InsetGraphicsParams const &);
/// Save the parameters in the LyX format stream.
/// Buffer is needed to figure out if a figure is embedded.
- void write(std::ostream & os) const;
+ void write(std::ostream & os) const override;
/// If the token belongs to our parameters, read it.
bool read(Lexer & lex, std::string const & token, bool allowOrigin);
+ void read(Lexer & lex) override;
///
- std::string toString() const;
+ std::string name() const override { return "graphics"; }
+ ///
+ bool writeEndInset() const override { return true; }
/// convert
// Only a subset of InsetGraphicsParams is needed for display purposes.
// This function also interrogates lyxrc to ascertain whether
}
-string InsetIPADecoParams::toString() const
-{
- ostringstream data;
- data << "IPADeco" << ' ';
- write(data);
- return data.str();
-}
-
-
void InsetIPADeco::string2params(string const & in, InsetIPADecoParams & params)
{
params = InsetIPADecoParams();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "IPADeco"; }
///
Type type;
};
}
-string InsetIndexParams::toString() const
-{
- ostringstream data;
- data << "index";
- write(data);
- return data.str();
-}
-
-
void InsetIndex::string2params(string const & in, InsetIndexParams & params)
{
params = InsetIndexParams();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "index"; }
docstring index;
};
}
-string InsetListingsParams::toString() const
-{
- ostringstream data;
- data << "listings" << ' ';
- write(data);
- return data.str();
-}
-
-
string InsetListingsParams::params(string const & sep) const
{
string par;
void read(Lexer &) override;
///
- std::string toString() const override;
+ std::string name() const override { return "listings"; }
/// valid parameter string
std::string params(std::string const & sep=",") const;
}
-string InsetNewlineParams::toString() const
-{
- ostringstream data;
- data << "newline" << ' ';
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "newline"; }
///
Kind kind;
};
}
-string InsetNewpageParams::toString() const
-{
- ostringstream data;
- data << "newpage" << ' ';
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "newpage"; }
///
Kind kind;
};
}
-string InsetNoteParams::toString() const
-{
- ostringstream data;
- data << "note" << ' ';
- write(data);
- return data.str();
-}
-
-
void InsetNote::string2params(string const & in, InsetNoteParams & params)
{
params = InsetNoteParams();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "note"; }
Type type;
};
--- /dev/null
+/**
+ * \file InsetParams.cpp
+ * 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.
+ */
+
+#include <config.h>
+
+#include "InsetParams.h"
+
+#include <sstream>
+
+using namespace std;
+
+namespace lyx {
+
+
+string InsetParams::toString() const
+{
+ ostringstream data;
+ data << name() << ' ';
+ write(data);
+ if (writeEndInset())
+ data << "\\end_inset\n";
+ return data.str();
+}
+
+
+} // namespace lyx
///
virtual void read(Lexer & lex) = 0;
///
- virtual std::string toString() const = 0;
+ std::string toString() const;
+protected:
+ virtual std::string name() const { return std::string(); }
+ virtual bool writeEndInset() const { return false; }
};
}
-string InsetPhantomParams::toString() const
-{
- ostringstream data;
- data << "phantom" << ' ';
- write(data);
- return data.str();
-}
-
-
void InsetPhantom::string2params(string const & in, InsetPhantomParams & params)
{
params = InsetPhantomParams();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "phantom"; }
Type type;
};
}
-string InsetScriptParams::toString() const
-{
- ostringstream data;
- data << "script ";
- write(data);
- return data.str();
-}
-
-
void InsetScript::string2params(string const & in, InsetScriptParams & params)
{
params = InsetScriptParams();
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "script"; }
///
int shift(FontInfo const & font) const;
///
}
-string InsetSeparatorParams::toString() const
-{
- ostringstream data;
- data << "separator" << ' ';
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "separator"; }
Kind kind;
};
}
-string InsetSpaceParams::toString() const
-{
- ostringstream data;
- if (math)
- data << "math";
- data << "space" << ' ';
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return math ? "mathspace" : "space"; }
///
Kind kind;
///
}
-string InsetVSpaceParams::toString() const
-{
- ostringstream data;
- data << "vspace" << ' ';
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer & lex) override;
///
- std::string toString() const override;
+ std::string name() const override { return "vspace"; }
///
VSpace space_;
};
}
-string InsetWrapParams::toString() const
-{
- ostringstream data;
- data << "wrap" << ' ';
- write(data);
- return data.str();
-}
-
-
} // namespace lyx
///
void read(Lexer &) override;
///
- std::string toString() const override;
+ std::string name() const override { return "wrap"; }
///
std::string type;
///