]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBox.cpp
* make macros global. This is conceptionally much easier for the user,
[lyx.git] / src / insets / InsetBox.cpp
index f6d6f6abbf09c5b8e18124930852ae1c7ef37658..ec99e94b59ab7c24f94bd60513a549c72482d568 100644 (file)
 #include "InsetBox.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferView.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
-#include "support/debug.h"
 #include "FuncStatus.h"
 #include "FuncRequest.h"
 #include "support/gettext.h"
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
+#include "TextClass.h"
 
+#include "support/debug.h"
 #include "support/Translator.h"
 
 #include <sstream>
@@ -36,7 +38,7 @@ namespace lyx {
 
 namespace {
 
-typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
+typedef Translator<string, InsetBox::BoxType> BoxTranslator;
 typedef Translator<docstring, InsetBox::BoxType> BoxTranslatorLoc;
 
 BoxTranslator const init_boxtranslator()
@@ -83,29 +85,21 @@ BoxTranslatorLoc const & boxtranslator_loc()
 } // anon
 
 
-InsetBox::InsetBox(BufferParams const & bp, string const & label)
-       : InsetCollapsable(bp), params_(label)
-{}
-
-
-InsetBox::InsetBox(InsetBox const & in)
-       : InsetCollapsable(in), params_(in.params_)
-{}
-
-
-InsetBox::~InsetBox()
+InsetBox::InsetBox(Buffer const & buffer, string const & label)
+       : InsetCollapsable(buffer), params_(label)
 {
-       InsetBoxMailer(*this).hideDialog();
+       if (forceEmptyLayout())
+               paragraphs().back().setLayout(buffer.params().documentClass().emptyLayout());
 }
 
 
-Inset * InsetBox::clone() const
+InsetBox::~InsetBox()
 {
-       return new InsetBox(*this);
+       InsetBoxMailer(*this).hideDialog();
 }
 
 
-docstring const InsetBox::editMessage() const
+docstring InsetBox::editMessage() const
 {
        return _("Opened Box Inset");
 }
@@ -114,24 +108,24 @@ docstring const InsetBox::editMessage() const
 docstring InsetBox::name() const 
 {
        // FIXME: UNICODE
-       string name = string("Box");
+       string name = "Box";
        if (boxtranslator().find(params_.type) == Shaded)
                name += string(":Shaded");
        return from_ascii(name);
 }
 
 
-void InsetBox::write(Buffer const & buf, ostream & os) const
+void InsetBox::write(ostream & os) const
 {
        params_.write(os);
-       InsetCollapsable::write(buf, os);
+       InsetCollapsable::write(os);
 }
 
 
-void InsetBox::read(Buffer const & buf, Lexer & lex)
+void InsetBox::read(Lexer & lex)
 {
        params_.read(lex);
-       InsetCollapsable::read(buf, lex);
+       InsetCollapsable::read(lex);
 }
 
 
@@ -157,7 +151,7 @@ void InsetBox::setButtonLabel()
 
 bool InsetBox::hasFixedWidth() const
 {
-      return params_.inner_box || params_.special != "width";
+       return params_.inner_box || params_.special != "width";
 }
 
 
@@ -173,7 +167,7 @@ void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
 }
 
 
-bool InsetBox::forceDefaultParagraphs(idx_type) const
+bool InsetBox::forceEmptyLayout() const
 {
        return !params_.inner_box;
 }
@@ -239,13 +233,12 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-int InsetBox::latex(Buffer const & buf, odocstream & os,
-                   OutputParams const & runparams) const
+int InsetBox::latex(odocstream & os, OutputParams const & runparams) const
 {
        BoxType btype = boxtranslator().find(params_.type);
 
        string width_string = params_.width.asLatexString();
-       bool stdwidth(false);
+       bool stdwidth = false;
        if (params_.inner_box &&
                        (width_string.find("1.0\\columnwidth") != string::npos
                        || width_string.find("1.0\\textwidth") != string::npos)) {
@@ -269,7 +262,7 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
                        width_string += " - 2\\fboxsep - 2\\fboxrule"/* "-\\shadowsize"*/;
                        break;
                case Doublebox:
-                       width_string += " - 2\\fboxsep - 7.5\\fboxrule - 1.0pt";
+                       width_string += " - 2\\fboxsep - 7.5\\fboxrule - 1pt";
                        break;
                }
        }
@@ -362,7 +355,7 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
                os << "\\begin{shaded}%\n";
                i += 1;
 
-       i += InsetText::latex(buf, os, runparams);
+       i += InsetText::latex(os, runparams);
 
        if (btype == Shaded)
                os << "\\end{shaded}";
@@ -395,16 +388,14 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
                // already done
                break;
        }
-       os << "%\n";
 
-       i += 3;
+       i += 2;
 
        return i;
 }
 
 
-int InsetBox::plaintext(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+int InsetBox::plaintext(odocstream & os, OutputParams const & runparams) const
 {
        BoxType const btype = boxtranslator().find(params_.type);
 
@@ -430,7 +421,7 @@ int InsetBox::plaintext(Buffer const & buf, odocstream & os,
                        break;
        }
 
-       InsetText::plaintext(buf, os, runparams);
+       InsetText::plaintext(os, runparams);
 
        int len = 0;
        switch (btype) {
@@ -465,10 +456,9 @@ int InsetBox::plaintext(Buffer const & buf, odocstream & os,
 }
 
 
-int InsetBox::docbook(Buffer const & buf, odocstream & os,
-                     OutputParams const & runparams) const
+int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
 {
-       return InsetText::docbook(buf, os, runparams);
+       return InsetText::docbook(os, runparams);
 }