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"
28 ControlViewSource::ControlViewSource(Dialog & parent)
29 : Dialog::Controller(parent)
33 bool ControlViewSource::initialiseParams(string const & /*source*/)
38 docstring const ControlViewSource::updateContent(bool fullSource)
40 // get the *top* level paragraphs that contain the cursor,
41 // or the selected text
42 lyx::pit_type par_begin;
43 lyx::pit_type par_end;
45 BufferView * view = kernel().bufferview();
46 if (!view->cursor().selection()) {
47 par_begin = view->cursor().bottom().pit();
50 par_begin = view->cursor().selectionBegin().bottom().pit();
51 par_end = view->cursor().selectionEnd().bottom().pit();
53 if (par_begin > par_end)
54 std::swap(par_begin, par_end);
55 lyx::odocstringstream ostr;
56 view->buffer()->getSourceCode(ostr, par_begin, par_end + 1, fullSource);
61 void ControlViewSource::clearParams()
66 docstring const ControlViewSource::title() const
70 Kernel::DocType doctype = kernel().docType();
73 source_type = "LaTeX";
76 source_type = "DocBook";
78 case Kernel::LITERATE:
79 source_type = "Literate";
83 return _(source_type + " Source");
86 } // namespace frontend