#include "insets/insetcharstyle.h"
#include "insets/insettabular.h"
-#include "mathed/math_data.h"
-#include "mathed/math_inset.h"
-#include "mathed/math_support.h"
+#include "mathed/MathData.h"
+#include "mathed/InsetMath.h"
+#include "mathed/MathSupport.h"
#include "support/lstrings.h"
// to the buffer language.
if (p.ownerCode() == InsetBase::ERT_CODE) {
p.changeLanguage(buffer_.params(), latex_language,
- buffer_.getLanguage());
+ buffer_.getLanguage());
}
p.setInsetOwner(0);
}
it->layout(tclass2.defaultLayout());
if (!hasLayout && name != tclass1.defaultLayoutName()) {
- string const s = bformat(
- _("Layout had to be changed from\n%1$s to %2$s\n"
- "because of class conversion from\n%3$s to %4$s"),
- name, it->layout()->name(), tclass1.name(), tclass2.name());
+ docstring const s = bformat(
+ _("Layout had to be changed from\n%1$s to %2$s\n"
+ "because of class conversion from\n%3$s to %4$s"),
+ lyx::from_utf8(name), lyx::from_utf8(it->layout()->name()),
+ lyx::from_utf8(tclass1.name()), lyx::from_utf8(tclass2.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(_("Changed Layout"), s,
it->id(), 0,
if (found_cs == tclass2.charstyles().end()) {
// The character style is undefined in tclass2
inset.setUndefined();
- string const s = bformat(_(
+ docstring const s = bformat(_(
"Character style %1$s is "
"undefined because of class "
"conversion from\n%2$s to %3$s"),
- name, tclass1.name(), tclass2.name());
+ lyx::from_utf8(name), lyx::from_utf8(tclass1.name()),
+ lyx::from_utf8(tclass2.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(
- _("Undefined character style"),
- s, it.paragraph().id(),
- it.pos(), it.pos() + 1));
+ _("Undefined character style"),
+ s, it.paragraph().id(), it.pos(), it.pos() + 1));
} else if (inset.undefined()) {
// The character style is undefined in
// tclass1 and is defined in tclass2
// faster we need to be more clever and probably also have more
// calls to cur.bv().owner()->gui().selection().put. (Lgb)
// cur.bv().owner()->gui().selection().put(cur.selectionAsString(true));
-
+
// make sure that the depth behind the selection are restored, too
recordUndoSelection(cur);
}
if (cur.inMathed()) {
- lyxerr << "copySelection in mathed" << endl;
+ //lyxerr << "copySelection in mathed" << endl;
ParagraphList pars;
pars.push_back(Paragraph());
BufferParams const & bp = cur.buffer().params();
void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
- textclass_type textclass)
+ textclass_type textclass, ErrorList & errorList)
{
if (cur.inTexted()) {
LyXText * text = cur.text();
pit_type endpit;
PitPosPair ppp;
- ErrorList el;
boost::tie(ppp, endpit) =
pasteSelectionHelper(cur.buffer(),
text->paragraphs(),
cur.pit(), cur.pos(),
parlist, textclass,
- el);
- bufferErrors(cur.buffer(), el);
+ errorList);
updateLabels(cur.buffer());
cur.clearSelection();
text->setCursor(cur, ppp.first, ppp.second);
}
- // mathed is handled in MathNestInset/MathGridInset
+ // mathed is handled in InsetMathNest/InsetMathGrid
BOOST_ASSERT(!cur.inMathed());
}
-void pasteSelection(LCursor & cur, size_t sel_index)
+void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
{
// this does not make sense, if there is nothing to paste
if (!checkPastePossible(sel_index))
return;
pasteParagraphList(cur, theCuts[sel_index].first,
- theCuts[sel_index].second);
- cur.bv().owner()->showErrorList(_("Paste"));
- cur.setSelection();
-}
-
-
-void setSelectionRange(LCursor & cur, pos_type length)
-{
- LyXText * text = cur.text();
- BOOST_ASSERT(text);
- if (!length)
- return;
- cur.resetAnchor();
- while (length--)
- text->cursorRight(cur);
+ theCuts[sel_index].second, errorList);
cur.setSelection();
}
// simple replacing. The font of the first selected character is used
-void replaceSelectionWithString(LCursor & cur, string const & str)
+void replaceSelectionWithString(LCursor & cur, string const & str, bool backwards)
{
- LyXText * text = cur.text();
- BOOST_ASSERT(text);
recordUndo(cur);
+ DocIterator selbeg = cur.selectionBegin();
// Get font setting before we cut
- pos_type pos = cur.selEnd().pos();
- Paragraph & par = text->getPar(cur.selEnd().pit());
LyXFont const font =
- par.getFontSettings(cur.buffer().params(), cur.selBegin().pos());
+ selbeg.paragraph().getFontSettings(cur.buffer().params(), selbeg.pos());
// Insert the new string
+ pos_type pos = cur.selEnd().pos();
+ Paragraph & par = cur.selEnd().paragraph();
string::const_iterator cit = str.begin();
string::const_iterator end = str.end();
for (; cit != end; ++cit, ++pos)
// Cut the selection
cutSelection(cur, true, false);
+
+ // select the replacement
+ if (backwards) {
+ selbeg.pos() += str.length();
+ cur.setSelection(selbeg, -str.length());
+ } else
+ cur.setSelection(selbeg, str.length());
}
}
-// only used by the spellchecker
-void replaceWord(LCursor & cur, string const & replacestring)
-{
- LyXText * text = cur.text();
- BOOST_ASSERT(text);
-
- replaceSelectionWithString(cur, replacestring);
- setSelectionRange(cur, replacestring.length());
-
- // Go back so that replacement string is also spellchecked
- for (string::size_type i = 0; i < replacestring.length() + 1; ++i)
- text->cursorLeft(cur);
-}
-
-
void eraseSelection(LCursor & cur)
{
//lyxerr << "LCursor::eraseSelection begin: " << cur << endl;
CursorSlice const & i1 = cur.selBegin();
CursorSlice const & i2 = cur.selEnd();
- if (i1.inset().asMathInset()) {
+ if (i1.inset().asInsetMath()) {
cur.top() = i1;
if (i1.idx() == i2.idx()) {
i1.cell().erase(i1.pos(), i2.pos());
if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos();
} else {
- MathInset * p = i1.asMathInset();
+ InsetMath * p = i1.asInsetMath();
InsetBase::row_type r1, r2;
InsetBase::col_type c1, c2;
region(i1, i2, r1, r2, c1, c2);
CursorSlice i2 = cur.selEnd();
if (i1.idx() == i2.idx()) {
- if (i1.inset().asMathInset()) {
+ if (i1.inset().asInsetMath()) {
MathArray::const_iterator it = i1.cell().begin();
return asString(MathArray(it + i1.pos(), it + i2.pos()));
} else {
region(i1, i2, r1, r2, c1, c2);
string data;
- if (i1.inset().asMathInset()) {
+ if (i1.inset().asInsetMath()) {
for (InsetBase::row_type row = r1; row <= r2; ++row) {
if (row > r1)
data += "\\\\";
for (InsetBase::col_type col = c1; col <= c2; ++col) {
if (col > c1)
data += '&';
- data += asString(i1.asMathInset()->
- cell(i1.asMathInset()->index(row, col)));
+ data += asString(i1.asInsetMath()->
+ cell(i1.asInsetMath()->index(row, col)));
}
}
} else {