-/* \file CutAndPaste.C
+/*
+ * \file CutAndPaste.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author Jurgen Vigna
+ * \author Jürgen Vigna
* \author Lars Gullik Bjønnes
+ * \author Alfredo Braunstein
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "CutAndPaste.h"
-#include "BufferView.h"
+
#include "buffer.h"
+#include "bufferparams.h"
#include "errorlist.h"
-#include "paragraph.h"
-#include "ParagraphParameters.h"
-#include "lyxtext.h"
-#include "lyxcursor.h"
+#include "gettext.h"
#include "iterators.h"
#include "lyxtextclasslist.h"
-#include "undo_funcs.h"
-#include "gettext.h"
+#include "paragraph.h"
#include "paragraph_funcs.h"
-#include "debug.h"
-#include "insets/insetinclude.h"
+#include "ParagraphParameters.h"
+
#include "insets/insettabular.h"
-#include "support/LAssert.h"
#include "support/lstrings.h"
-#include "support/limited_stack.h"
-
-using std::endl;
-using std::pair;
-using std::make_pair;
-using std::for_each;
-using std::vector;
using lyx::pos_type;
using lyx::textclass_type;
+using lyx::support::bformat;
+
+using std::for_each;
+using std::make_pair;
+using std::pair;
+using std::vector;
+using std::string;
+
typedef limited_stack<pair<ParagraphList, textclass_type> > CutStack;
} // namespace anon
-vector<string>
+
+std::vector<string> const
CutAndPaste::availableSelections(Buffer const & buffer)
{
vector<string> selList;
CutStack::const_iterator cit = cuts.begin();
CutStack::const_iterator end = cuts.end();
for (; cit != end; ++cit) {
- ParagraphList const & pars = cit->first;
+ // we do not use cit-> here because gcc 2.9x does not
+ // like it (JMarc)
+ ParagraphList const & pars = (*cit).first;
string asciiSel;
ParagraphList::const_iterator pit = pars.begin();
ParagraphList::const_iterator pend = pars.end();
for (; pit != pend; ++pit) {
- asciiSel += pit->asString(&buffer, false);
+ asciiSel += pit->asString(buffer, false);
if (asciiSel.size() > 25) {
asciiSel.replace(22, string::npos, "...");
break;
ParagraphList::iterator endpit,
int start, int end, textclass_type tc)
{
- lyx::Assert(&*startpit);
- lyx::Assert(&*endpit);
- lyx::Assert(0 <= start && start <= startpit->size());
- lyx::Assert(0 <= end && end <= endpit->size());
- lyx::Assert(startpit != endpit || start <= end);
+ BOOST_ASSERT(0 <= start && start <= startpit->size());
+ BOOST_ASSERT(0 <= end && end <= endpit->size());
+ BOOST_ASSERT(startpit != endpit || start <= end);
ParagraphList paragraphs;
if (!checkPastePossible())
return make_pair(PitPosPair(pit, pos), pit);
- lyx::Assert (pos <= pit->size());
+ BOOST_ASSERT (pos <= pit->size());
// Make a copy of the CaP paragraphs.
ParagraphList simple_cut_clone = cuts[cut_index].first;
tmpbuf->erase(i--);
}
} else {
- LyXFont f1 = tmpbuf->getFont(buffer.params, i, outerFont(pit, pars));
+ LyXFont f1 = tmpbuf->getFont(buffer.params(), i, outerFont(pit, pars));
LyXFont f2 = f1;
if (!pit->checkInsertChar(f1)) {
tmpbuf->erase(i--);
for (; lit != eit; ++lit) {
switch (lit->inset->lyxCode()) {
- case Inset::INCLUDE_CODE: {
- InsetInclude * ii = static_cast<InsetInclude*>(lit->inset);
- InsetInclude::Params ip = ii->params();
- ip.masterFilename_ = buffer.fileName();
- ii->set(ip);
- break;
- }
-
- case Inset::TABULAR_CODE: {
+ case InsetOld::TABULAR_CODE: {
InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
it->buffer(const_cast<Buffer*>(&buffer));
break;
// Open the paragraph for inserting the buf
// if necessary.
if (pit->size() > pos || boost::next(pit) == pars.end()) {
- breakParagraphConservative(buffer.params,
+ breakParagraphConservative(buffer.params(),
pars, pit, pos);
paste_the_end = true;
}
if (boost::next(pit) == last_paste)
last_paste = pit;
- mergeParagraph(buffer.params, pars, pit);
+ mergeParagraph(buffer.params(), pars, pit);
// Store the new cursor position.
pit = last_paste;
pos = last_paste->size();
// Maybe some pasting.
-#warning CHECK! Are we comparing last_paste to the wrong list here? (Lgb)
if (boost::next(last_paste) != pars.end() &&
paste_the_end) {
if (boost::next(last_paste)->hasSameLayout(*last_paste)) {
- mergeParagraph(buffer.params, pars,
+ mergeParagraph(buffer.params(), pars,
last_paste);
} else if (boost::next(last_paste)->empty()) {
boost::next(last_paste)->makeSameLayout(*last_paste);
- mergeParagraph(buffer.params, pars,
+ mergeParagraph(buffer.params(), pars,
last_paste);
} else if (last_paste->empty()) {
last_paste->makeSameLayout(*boost::next(last_paste));
- mergeParagraph(buffer.params, pars,
+ mergeParagraph(buffer.params(), pars,
last_paste);
} else
boost::next(last_paste)->stripLeadingSpaces();
ParagraphList & pars,
ErrorList & errorlist)
{
- lyx::Assert(!pars.empty());
+ BOOST_ASSERT(!pars.empty());
int ret = 0;
if (c1 == c2)