X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetBox.cpp;h=ec99e94b59ab7c24f94bd60513a549c72482d568;hb=76dc2c0d3002db400f4826e6f3b3e8bf84f830f4;hp=df1bd4778429e96a48372a79d49502d7a666cc00;hpb=3582be1441db296f29b54649f743745843e499e2;p=lyx.git diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index df1bd47784..ec99e94b59 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -15,34 +15,30 @@ #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 +using namespace std; namespace lyx { -using std::string; -using std::istringstream; -using std::ostream; -using std::ostringstream; -using std::endl; - - namespace { -typedef Translator BoxTranslator; +typedef Translator BoxTranslator; typedef Translator BoxTranslatorLoc; BoxTranslator const init_boxtranslator() @@ -89,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"); } @@ -120,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); } @@ -163,7 +151,7 @@ void InsetBox::setButtonLabel() bool InsetBox::hasFixedWidth() const { - return params_.inner_box || params_.special != "width"; + return params_.inner_box || params_.special != "width"; } @@ -179,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; } @@ -245,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)) { @@ -275,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; } } @@ -368,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}"; @@ -401,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); @@ -436,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) { @@ -471,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); }