- InsetBase::Code code = InsetBase::REF_CODE;
-
- ParIterator it = par_iterator_begin();
- ParIterator end = par_iterator_end();
- for ( ; it != end; ++it) {
- bool changed_inset = false;
- for (InsetList::iterator it2 = it->insetlist.begin();
- it2 != it->insetlist.end(); ++it2) {
- if (it2->inset->lyxCode() == code) {
- InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
- if (inset->getContents() == from) {
- inset->setContents(to);
- //inset->setButtonLabel();
- changed_inset = true;
- }
- }
+ for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
+ if (it->lyxCode() == code) {
+ InsetCommand & inset = dynamic_cast<InsetCommand &>(*it);
+ inset.replaceContents(to_utf8(from), to_utf8(to));
+ }
+ }
+}
+
+
+void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
+ pit_type par_end, bool full_source)
+{
+ OutputParams runparams;
+ runparams.nice = true;
+ runparams.flavor = OutputParams::LATEX;
+ runparams.linelen = lyxrc.ascii_linelen;
+ // No side effect of file copying and image conversion
+ runparams.dryrun = true;
+
+ /* Support for docbook temprarily commented out. */
+ if (full_source) {
+ os << "% Preview source code\n\n";
+ if (isLatex())
+ writeLaTeXSource(os, filePath(), runparams, true, true);
+ else {
+ writeDocBookSource(os, fileName(), runparams, false);
+ }
+ } else {
+ runparams.par_begin = par_begin;
+ runparams.par_end = par_end;
+ if (par_begin + 1 == par_end)
+ os << "% Preview source code for paragraph " << par_begin << "\n\n";
+ else
+ os << "% Preview source code from paragraph " << par_begin
+ << " to " << par_end - 1 << "\n\n";
+ // output paragraphs
+ if (isLatex()) {
+ texrow().reset();
+ latexParagraphs(*this, paragraphs(), os, texrow(), runparams);
+ } else {
+ // DocBook
+ docbookParagraphs(paragraphs(), *this, os, runparams);