#include "ErrorList.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
+#include "InsetCaption.h"
#include "InsetList.h"
#include "Intl.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "output_docbook.h"
#include "output_latex.h"
+#include "output_xhtml.h"
#include "OutputParams.h"
#include "output_plaintext.h"
#include "paragraph_funcs.h"
// Hand font through to contained lyxtext:
tm.font_.fontInfo() = mi.base.font;
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
+
+ // This can happen when a layout has a left and right margin,
+ // and the view is made very narrow. We can't do better than
+ // to draw it partly out of view (bug 5890).
+ if (mi.base.textwidth < 1)
+ mi.base.textwidth = 1;
+
if (hasFixedWidth())
tm.metrics(mi, dim, mi.base.textwidth);
else
if (cur.text() == &text_)
text_.dispatch(cur, cmd);
else
- //FIXME we probably also want to dispatch to Inset when
- //text_ could do nothing with the FuncRequest.
+ cur.undispatched();
+
+ if (!cur.result().dispatched())
Inset::doDispatch(cur, cmd);
}
default:
// Dispatch only to text_ if the cursor is inside
// the text_. It is not for context menus (bug 5797).
+ bool ret = false;
if (cur.text() == &text_)
- return text_.getStatus(cur, cmd, status);
- else
- return Inset::getStatus(cur, cmd, status);
+ ret = text_.getStatus(cur, cmd, status);
+
+ if (!ret)
+ ret = Inset::getStatus(cur, cmd, status);
+ return ret;
}
}
}
-void InsetText::acceptChanges(BufferParams const & bparams)
+void InsetText::acceptChanges()
{
- text_.acceptChanges(bparams);
+ text_.acceptChanges(buffer().params());
}
-void InsetText::rejectChanges(BufferParams const & bparams)
+void InsetText::rejectChanges()
{
- text_.rejectChanges(bparams);
+ text_.rejectChanges(buffer().params());
}
}
+docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
+{
+ xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
+ return docstring();
+}
+
+
void InsetText::validate(LaTeXFeatures & features) const
{
for_each(paragraphs().begin(), paragraphs().end(),
ParIterator it2 = it;
it2.forwardPos();
LASSERT(&it2.inset() == this && it2.pit() == 0, return);
- if (producesOutput()) {
+ if (producesOutput())
buffer().updateLabels(it2);
- } else {
+ else {
DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass();
Counters const savecnt = tclass.counters();
buffer().updateLabels(it2);
break;
}
}
- /// now the toc entry for the paragraph
+ // now the toc entry for the paragraph
int const toclevel = par.layout().toclevel;
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
dit.pos() = 0;
LASSERT(&insetCur.inset() == this, /**/);
// update the old paragraph's words
- insetCur.paragraph().updateWords(insetCur.top());
+ insetCur.paragraph().updateWords();
return Inset::notifyCursorLeaves(old, cur);
}
}
+InsetCaption const * InsetText::getCaptionInset() const
+{
+ ParagraphList::const_iterator pit = paragraphs().begin();
+ for (; pit != paragraphs().end(); ++pit) {
+ InsetList::const_iterator it = pit->insetList().begin();
+ for (; it != pit->insetList().end(); ++it) {
+ Inset & inset = *it->inset;
+ if (inset.lyxCode() == CAPTION_CODE) {
+ InsetCaption const * ins =
+ static_cast<InsetCaption const *>(it->inset);
+ return ins;
+ }
+ }
+ }
+ return 0;
+}
+
+
+docstring InsetText::getCaptionText(OutputParams const & runparams) const
+{
+ InsetCaption const * ins = getCaptionInset();
+ if (ins == 0)
+ return docstring();
+
+ odocstringstream ods;
+ ins->getCaptionAsPlaintext(ods, runparams);
+ return ods.str();
+}
+
+
+docstring InsetText::getCaptionHTML(OutputParams const & runparams) const
+{
+ InsetCaption const * ins = getCaptionInset();
+ if (ins == 0)
+ return docstring();
+
+ odocstringstream ods;
+ docstring def = ins->getCaptionAsHTML(ods, runparams);
+ if (!def.empty())
+ ods << def << '\n';
+ return ods.str();
+}
+
+
} // namespace lyx