#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>
+using namespace std;
namespace lyx {
-using std::string;
-using std::istringstream;
-using std::ostream;
-using std::ostringstream;
-using std::endl;
-
-
namespace {
-typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
+typedef Translator<string, InsetBox::BoxType> BoxTranslator;
typedef Translator<docstring, InsetBox::BoxType> BoxTranslatorLoc;
BoxTranslator const init_boxtranslator()
} // 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");
}
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);
}
bool InsetBox::hasFixedWidth() const
{
- return params_.inner_box || params_.special != "width";
+ return params_.inner_box || params_.special != "width";
}
}
-bool InsetBox::forceDefaultParagraphs(idx_type) const
+bool InsetBox::forceEmptyLayout(idx_type) const
{
return !params_.inner_box;
}
}
-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)) {
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;
}
}
os << "\\begin{shaded}%\n";
i += 1;
- i += InsetText::latex(buf, os, runparams);
+ i += InsetText::latex(os, runparams);
if (btype == Shaded)
os << "\\end{shaded}";
// 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);
break;
}
- InsetText::plaintext(buf, os, runparams);
+ InsetText::plaintext(os, runparams);
int len = 0;
switch (btype) {
}
-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);
}