]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
Fix GRAPHICS_EDIT of InsetGraphics
[lyx.git] / src / insets / InsetIndex.cpp
index 11876270ce8d0b119365617bfd926ae10198e618..1c9ceda8444009b517969e514877f668155dd356 100644 (file)
 
 #include "InsetIndex.h"
 
+#include "Buffer.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 #include "sgml.h"
+#include "TocBackend.h"
 
-#include "support/std_ostream.h"
+#include "support/gettext.h"
 
+#include <ostream>
 
-namespace lyx {
-
-using std::string;
-using std::ostream;
+using namespace std;
 
+namespace lyx {
 
-InsetIndex::InsetIndex(BufferParams const & bp)
-       : InsetCollapsable(bp)
-{
-       setLayout(bp);
-}
+/////////////////////////////////////////////////////////////////////
+//
+// InsetIndex
+//
+///////////////////////////////////////////////////////////////////////
 
 
-InsetIndex::InsetIndex(InsetIndex const & in)
-       : InsetCollapsable(in)
+InsetIndex::InsetIndex(Buffer const & buf)
+       : InsetCollapsable(buf)
 {}
 
 
-int InsetIndex::docbook(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
 {
        os << "<indexterm><primary>";
-       int const i = InsetText::docbook(buf, os, runparams);
+       int const i = InsetText::docbook(os, runparams);
        os << "</primary></indexterm>";
        return i;
 }
 
 
-InsetCode InsetIndex::lyxCode() const
-{
-       return INDEX_CODE;
-}
-
-
-Inset * InsetIndex::clone() const
-{
-       return new InsetIndex(*this);
-}
-
-
-void InsetIndex::write(Buffer const & buf, std::ostream & os) const
+void InsetIndex::write(ostream & os) const
 {
        os << to_utf8(name()) << "\n";
-       InsetCollapsable::write(buf, os);
+       InsetCollapsable::write(os);
 }
 
 
-void InsetIndex::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetIndex::addToToc(ParConstIterator const & cpit) const
 {
-       Font tmpfont = mi.base.font;
-       getDrawFont(mi.base.font);
-       mi.base.font.realize(tmpfont);
-       InsetCollapsable::metrics(mi, dim);
-       mi.base.font = tmpfont;
-}
-
+       ParConstIterator pit = cpit;
+       pit.push_back(*this);
 
-void InsetIndex::draw(PainterInfo & pi, int x, int y) const
-{
-       Font tmpfont = pi.base.font;
-       getDrawFont(pi.base.font);
-       pi.base.font.realize(tmpfont);
-       InsetCollapsable::draw(pi, x, y);
-       pi.base.font = tmpfont;
-}
-
-
-void InsetIndex::getDrawFont(Font & font) const
-{
-       font = Font(Font::ALL_INHERIT);
-       font.realize(layout_.font);
-}
-
-
-bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
-       FuncStatus & status) const
-{
-       switch (cmd.action) {
-               // paragraph breaks not allowed
-               case LFUN_BREAK_PARAGRAPH:
-               case LFUN_BREAK_PARAGRAPH_SKIP:
-                       status.enabled(false);
-                       return true;
-
-               default:
-                       return InsetCollapsable::getStatus(cur, cmd, status);
-               }
+       Toc & toc = buffer().tocBackend().toc("index");
+       docstring str;
+       str = getNewLabel(str);
+       toc.push_back(TocItem(pit, 0, str));
 }
 
 
+/////////////////////////////////////////////////////////////////////
+//
+// InsetPrintIndex
+//
+///////////////////////////////////////////////////////////////////////
 
 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
        : InsetCommand(p, string())
 {}
 
 
-docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
+ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
+{
+       static ParamInfo param_info_;
+       if (param_info_.empty())
+               param_info_.add("name", ParamInfo::LATEX_REQUIRED);
+       return param_info_;
+}
+
+
+docstring InsetPrintIndex::screenLabel() const
 {
        return _("Index");
 }
@@ -135,5 +105,4 @@ InsetCode InsetPrintIndex::lyxCode() const
        return INDEX_PRINT_CODE;
 }
 
-
 } // namespace lyx