#include "FuncStatus.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
-#include "output_xhtml.h"
+#include "xml.h"
+#include "texstream.h"
#include "TextClass.h"
#include "support/debug.h"
namespace lyx {
InsetWrap::InsetWrap(Buffer * buf, string const & type)
- : InsetCollapsable(buf)
+ : InsetCaptionable(buf)
{
- setLabel(_("wrap: ") + floatName(type));
- params_.type = type;
+ setCaptionType(type);
params_.lines = 0;
params_.placement = "o";
params_.overhang = Length(0, Length::PCW);
}
+// Enforce equality of float type and caption type.
+void InsetWrap::setCaptionType(std::string const & type)
+{
+ InsetCaptionable::setCaptionType(type);
+ params_.type = captionType();
+ setLabel(_("wrap: ") + floatName(type));
+}
+
+
docstring InsetWrap::layoutName() const
{
return "Wrap:" + from_utf8(params_.type);
docstring InsetWrap::toolTip(BufferView const & bv, int x, int y) const
{
if (isOpen(bv))
- return InsetCollapsable::toolTip(bv, x, y);
+ return InsetCaptionable::toolTip(bv, x, y);
OutputParams rp(&buffer().params().encoding());
docstring caption_tip = getCaptionText(rp);
if (!caption_tip.empty())
{
switch (cmd.action()) {
case LFUN_INSET_MODIFY: {
- cur.recordUndoInset(ATOMIC_UNDO, this);
+ cur.recordUndoInset(this);
InsetWrapParams params;
InsetWrap::string2params(to_utf8(cmd.argument()), params);
params_.lines = params.lines;
break;
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCaptionable::doDispatch(cur, cmd);
break;
}
}
return true;
default:
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCaptionable::getStatus(cur, cmd, flag);
}
}
-void InsetWrap::updateBuffer(ParIterator const & it, UpdateType utype)
+void InsetWrap::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted)
{
- setLabel(_("wrap: ") + floatName(params_.type));
- Counters & cnts =
- buffer().masterBuffer()->params().documentClass().counters();
- if (utype == OutputUpdate) {
- // counters are local to the wrap
- cnts.saveLastCounter();
- }
- string const saveflt = cnts.current_float();
-
- // Tell to captions what the current float is
- cnts.current_float(params().type);
-
- InsetCollapsable::updateBuffer(it, utype);
-
- // reset afterwards
- cnts.current_float(saveflt);
- if (utype == OutputUpdate)
- cnts.restoreLastCounter();
+ InsetCaptionable::updateBuffer(it, utype, deleted);
}
void InsetWrap::write(ostream & os) const
{
params_.write(os);
- InsetCollapsable::write(os);
+ InsetCaptionable::write(os);
}
void InsetWrap::read(Lexer & lex)
{
params_.read(lex);
- InsetCollapsable::read(lex);
+ InsetCaptionable::read(lex);
}
{
features.require("wrapfig");
features.inFloat(true);
- InsetCollapsable::validate(features);
+ InsetCaptionable::validate(features);
features.inFloat(false);
}
}
-int InsetWrap::docbook(odocstream & os, OutputParams const & runparams) const
+void InsetWrap::docbook(XMLStream & xs, OutputParams const & runparams) const
{
- // FIXME UNICODE
- os << '<' << from_ascii(params_.type) << '>';
- int const i = InsetText::docbook(os, runparams);
- os << "</" << from_ascii(params_.type) << '>';
- return i;
+ InsetLayout const & il = getLayout();
+
+ xs << xml::StartTag(il.docbooktag(), il.docbookattr()); // TODO: Detect when there is a title.
+ InsetText::docbook(xs, runparams);
+ xs << xml::EndTag(il.docbooktag());
}
-docstring InsetWrap::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetWrap::xhtml(XMLStream & xs, OutputParams const & rp) const
{
string const len = params_.width.asHTMLString();
string const width = len.empty() ? "50%" : len;
InsetLayout const & il = getLayout();
- string const tag = il.htmltag();
+ string const & tag = il.htmltag();
string const attr = il.htmlattr() + " style='width:" + width + ";'";
- xs << html::StartTag(tag, attr);
- docstring const deferred =
+ xs << xml::StartTag(tag, attr);
+ docstring const deferred =
InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag);
- xs << html::EndTag(tag);
+ xs << xml::EndTag(tag);
return deferred;
}
case MARGIN_CODE:
return false;
default:
- return InsetCollapsable::insetAllowed(code);
+ return InsetCaptionable::insetAllowed(code);
}
}