2 * \file ControlViewSource.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
15 #include "ControlViewSource.h"
17 #include "support/types.h"
18 #include "BufferView.h"
24 using std::ostringstream;
29 ControlViewSource::ControlViewSource(Dialog & parent)
30 : Dialog::Controller(parent)
34 bool ControlViewSource::initialiseParams(string const & /*source*/)
39 string const ControlViewSource::updateContent()
41 // get the *top* level paragraphs that contain the cursor,
42 // or the selected text
43 lyx::pit_type par_begin;
44 lyx::pit_type par_end;
46 BufferView * view = kernel().bufferview();
47 if (!view->cursor().selection()) {
48 par_begin = view->cursor().bottom().pit();
51 par_begin = view->cursor().selectionBegin().bottom().pit();
52 par_end = view->cursor().selectionEnd().bottom().pit();
54 if (par_begin > par_end)
55 std::swap(par_begin, par_end);
57 view->buffer()->getSourceCode(ostr, par_begin, par_end + 1);
62 void ControlViewSource::clearParams()
67 string const ControlViewSource::title() const
71 Kernel::DocType doctype = kernel().docType();
74 source_type = "LaTeX";
76 case Kernel::LINUXDOC:
77 source_type = "LinuxDoc";
80 source_type = "DocBook";
82 case Kernel::LITERATE:
83 source_type = "Literate";
87 return _(source_type + " Source");
90 } // namespace frontend