lyx_mirror/src/frontends/controllers/ControlViewSource.C
Georg Baum 8b67659646 Use UTF8 for LaTeX export.
Known problems:
- No space is output after a \hfill. I probably broke this with the
  InsetCommand patch. I'll have a look later.
- Although the encoding is now UTF8 the arguments of the inputenc package
  are still the old ones, so LaTeX will not run.
- Labels and references with non-ASCII characters are broken. This needs to
  be fixed in lyx::support::escape(), but this is a file format change.
- Something seems to be wrong with index entries, but this is probably also
  due to the InsetCommand changes.

Have fun!


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15378 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-19 16:51:30 +00:00

88 lines
1.8 KiB
C

/**
* \file ControlViewSource.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Angus Leeming
* \author Bo Peng
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "ControlViewSource.h"
#include "gettext.h"
#include "support/types.h"
#include "BufferView.h"
#include "buffer.h"
#include "cursor.h"
#include <sstream>
using std::string;
namespace lyx {
namespace frontend {
ControlViewSource::ControlViewSource(Dialog & parent)
: Dialog::Controller(parent)
{}
bool ControlViewSource::initialiseParams(string const & /*source*/)
{
return true;
}
docstring const ControlViewSource::updateContent(bool fullSource)
{
// get the *top* level paragraphs that contain the cursor,
// or the selected text
lyx::pit_type par_begin;
lyx::pit_type par_end;
BufferView * view = kernel().bufferview();
if (!view->cursor().selection()) {
par_begin = view->cursor().bottom().pit();
par_end = par_begin;
} else {
par_begin = view->cursor().selectionBegin().bottom().pit();
par_end = view->cursor().selectionEnd().bottom().pit();
}
if (par_begin > par_end)
std::swap(par_begin, par_end);
lyx::odocstringstream ostr;
view->buffer()->getSourceCode(ostr, par_begin, par_end + 1, fullSource);
return ostr.str();
}
void ControlViewSource::clearParams()
{
}
docstring const ControlViewSource::title() const
{
string source_type;
Kernel::DocType doctype = kernel().docType();
switch (doctype) {
case Kernel::LATEX:
source_type = "LaTeX";
break;
case Kernel::DOCBOOK:
source_type = "DocBook";
break;
case Kernel::LITERATE:
source_type = "Literate";
default:
BOOST_ASSERT(false);
}
return _(source_type + " Source");
}
} // namespace frontend
} // namespace lyx