]> git.lyx.org Git - lyx.git/blobdiff - src/insets/Inset.cpp
Fix GRAPHICS_EDIT of InsetGraphics
[lyx.git] / src / insets / Inset.cpp
index fe5b1a7f26bbca89a724415f5765b22efca11391..cb689077e44c784f6a2e330fbfb6e9fb17daae61 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "Inset.h"
 
+#include "buffer_funcs.h"
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
@@ -25,7 +26,6 @@
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "LyX.h" // quitting
 #include "MetricsInfo.h"
 #include "Text.h"
 #include "TextClass.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
+#include "support/docstream.h"
+#include "support/ExceptionMessage.h"
 #include "support/gettext.h"
 
 #include <map>
 
 using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
@@ -90,18 +93,19 @@ static TranslatorMap const build_translator()
                InsetName("nomencl_print", NOMENCL_PRINT_CODE),
                InsetName("optarg", OPTARG_CODE),
                InsetName("environment", ENVIRONMENT_CODE),
-               InsetName("hfill", HFILL_CODE),
                InsetName("newline", NEWLINE_CODE),
                InsetName("line", LINE_CODE),
                InsetName("branch", BRANCH_CODE),
                InsetName("box", BOX_CODE),
                InsetName("flex", FLEX_CODE),
+               InsetName("space", SPACE_CODE),
                InsetName("vspace", VSPACE_CODE),
                InsetName("mathmacroarg", MATHMACROARG_CODE),
                InsetName("listings", LISTINGS_CODE),
                InsetName("info", INFO_CODE),
                InsetName("collapsable", COLLAPSABLE_CODE),
                InsetName("newpage", NEWPAGE_CODE),
+               InsetName("tablecell", CELL_CODE)
        };
 
        size_t const insetnames_size =
@@ -117,12 +121,44 @@ static TranslatorMap const build_translator()
 }
 
 
+void Inset::setBuffer(Buffer & buffer)
+{
+       buffer_ = &buffer;
+}
+
+
+Buffer & Inset::buffer()
+{
+       if (!buffer_) {
+               odocstringstream s;
+               s << "LyX Code: " << lyxCode() << " name: " << name();
+               BOOST_ASSERT(false);
+               throw ExceptionMessage(BufferException, 
+                       from_ascii("Inset::buffer_ member not initialized!"), s.str());
+       }
+       return *buffer_;
+}
+
+
+Buffer const & Inset::buffer() const
+{
+       return const_cast<Inset *>(this)->buffer();
+}
+
+
 docstring Inset::name() const
 {
        return from_ascii("unknown");
 }
 
 
+void Inset::initView()
+{
+       if (isLabeled())
+               lyx::updateLabels(buffer());
+}
+
+
 docstring Inset::toolTip(BufferView const &, int, int) const
 {
        return docstring();
@@ -246,8 +282,7 @@ bool Inset::idxUpDown(Cursor &, bool) const
 }
 
 
-int Inset::docbook(Buffer const &,
-       odocstream &, OutputParams const &) const
+int Inset::docbook(odocstream &, OutputParams const &) const
 {
        return 0;
 }
@@ -271,7 +306,7 @@ bool Inset::autoDelete() const
 }
 
 
-docstring const Inset::editMessage() const
+docstring Inset::editMessage() const
 {
        return _("Opened inset");
 }
@@ -361,14 +396,13 @@ bool Inset::covers(BufferView const & bv, int x, int y) const
 
 InsetLayout const & Inset::getLayout(BufferParams const & bp) const
 {
-       return bp.getTextClass().insetlayout(name());  
+       return bp.documentClass().insetLayout(name());  
 }
 
 
 void Inset::dump() const
 {
-       Buffer buf("foo", 1);
-       write(buf, lyxerr);
+       write(lyxerr);
 }
 
 
@@ -393,9 +427,13 @@ void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
 
 Buffer const * Inset::updateFrontend() const
 {
-       if (quitting)
-               return 0;
-       return theApp()->updateInset(this);
+       return theApp() ? theApp()->updateInset(this) : 0;
+}
+
+
+docstring Inset::completionPrefix(Cursor const &) const 
+{
+       return docstring();
 }
 
 } // namespace lyx