+2003-05-06 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * CutAndPaste.h: Update file header.
+
+ * CutAndPaste.C: Update file header.
+ Store the parts cut out of the Document in a limited_stack.
+ (copySelection): adjust
+ (pasteSelection): new function, takes the index in the limited stack.
+ (nrOfParagraphs): adjust
+ (SwitchLayoutsBetweenClasses): Change to take a ParagraphList&,
+ simplify error inset insertion.
+ (checkPastePossible): adjust
+
2003-05-06 John Levon <levon@movementarian.org>
* text2.C: don't cast wrap inset to float
2003-05-05 André Pönitz <poenitz@gmx.net>
- * iterator.C:
+ * iterator.C:
* undo_funcs.C: use getParagraphs() instead of getFirstParagraph()
* buffer.[Ch]: new function hasParWithId() to help to get rid of a
* lyxtextclass.h:
* lyxtextclasslist.C: Handle new textclass.lst format; new method
isTeXClassAvailable()
-
+
2003-05-03 John Levon <levon@movementarian.org>
* BufferView.h:
-/* This file is part of
- * ======================================================
+/* \file CutAndPaste.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Jurgen Vigna
+ * \author Lars Gullik Bjønnes
*
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
#include <config.h>
#include "support/BoostFormat.h"
#include "support/LAssert.h"
+#include "support/limited_stack.h"
using std::endl;
using std::pair;
namespace {
-// FIXME: stupid name
-ParagraphList paragraphs;
-textclass_type textclass = 0;
+limited_stack<pair<ParagraphList, textclass_type> > cuts(10);
} // namespace anon
lyx::Assert(0 <= end && end <= endpit->size());
lyx::Assert(startpit != endpit || start <= end);
- textclass = tc;
+ ParagraphList paragraphs;
// Clone the paragraphs within the selection.
ParagraphList::iterator postend = boost::next(endpit);
Paragraph & front = paragraphs.front();
front.erase(0, start);
+ cuts.push(make_pair(paragraphs, tc));
+
return true;
}
CutAndPaste::pasteSelection(ParagraphList & pars,
ParagraphList::iterator pit, int pos,
textclass_type tc)
+{
+ return pasteSelection(pars, pit, pos, tc, 0);
+}
+
+pair<PitPosPair, ParagraphList::iterator>
+CutAndPaste::pasteSelection(ParagraphList & pars,
+ ParagraphList::iterator pit, int pos,
+ textclass_type tc, size_t cut_index)
{
if (!checkPastePossible())
return make_pair(PitPosPair(pit, pos), pit);
lyx::Assert (pos <= pit->size());
// Make a copy of the CaP paragraphs.
- ParagraphList simple_cut_clone = paragraphs;
+ ParagraphList simple_cut_clone = cuts[cut_index].first;
+ textclass_type const textclass = cuts[cut_index].second;
// Now remove all out of the pars which is NOT allowed in the
// new environment and set also another font if that is required.
+ // Make sure there is no class difference.
+ SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone);
+
ParagraphList::iterator tmpbuf = simple_cut_clone.begin();
int depth_delta = pit->params().depth() - tmpbuf->params().depth();
- // Make sure there is no class difference.
-#warning current_view used here
- SwitchLayoutsBetweenClasses(textclass, tc, &*tmpbuf,
- current_view->buffer()->params);
-
Paragraph::depth_type max_depth = pit->getMaxDepthAfter();
for (; tmpbuf != simple_cut_clone.end(); ++tmpbuf) {
int CutAndPaste::nrOfParagraphs()
{
- return paragraphs.size();
+ return cuts.empty() ? 0 : cuts[0].first.size();
}
int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
textclass_type c2,
- Paragraph * par,
- BufferParams const & /*bparams*/)
+ ParagraphList & pars)
{
- lyx::Assert(par);
+ lyx::Assert(!pars.empty());
+
+ Paragraph * par = &*pars.begin();
int ret = 0;
if (c1 == c2)
+ tclass1.name() + _(" to ")
+ tclass2.name();
#endif
- freezeUndo();
+ // To warn the user that something had to be done.
InsetError * new_inset = new InsetError(s);
- LyXText * txt = current_view->getLyXText();
- LyXCursor cur = txt->cursor;
- txt->setCursorIntern(par, 0);
- txt->insertInset(new_inset);
- txt->fullRebreak();
- txt->setCursorIntern(cur.par(), cur.pos());
- unFreezeUndo();
+ par->insertInset(0, new_inset);
}
}
return ret;
bool CutAndPaste::checkPastePossible()
{
- return !paragraphs.empty();
+ return !cuts.empty() && !cuts[0].first.empty();
}
// -*- C++ -*-
-/* This file is part of
- * ======================================================
+/* \file CutAndPaste.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Jurgen Vigna
+ * \author Lars Gullik Bjønnes
*
- * Copyright 1995-2001 the LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
#ifndef CUTANDPASTE_H
#define CUTANDPASTE_H
namespace CutAndPaste {
///
PitPosPair cutSelection(ParagraphList & pars,
- ParagraphList::iterator startpit,
+ ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, lyx::textclass_type tc,
bool doclear = false);
///
PitPosPair eraseSelection(ParagraphList & pars,
- ParagraphList::iterator startpit,
+ ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, bool doclear = false);
///
-bool copySelection(ParagraphList::iterator startpit,
+bool copySelection(ParagraphList::iterator startpit,
ParagraphList::iterator endpit,
int start, int end, lyx::textclass_type tc);
///
ParagraphList::iterator pit, int pos,
lyx::textclass_type tc);
+///
+std::pair<PitPosPair, ParagraphList::iterator>
+pasteSelection(ParagraphList & pars,
+ ParagraphList::iterator pit, int pos,
+ lyx::textclass_type tc,
+ size_t cuts_index);
+
///
int nrOfParagraphs();
-/** needed to switch between different classes this works
+/** Needed to switch between different classes this works
for a list of paragraphs beginning with the specified par
- return value is the number of wrong conversions
+ return value is the number of wrong conversions.
*/
int SwitchLayoutsBetweenClasses(lyx::textclass_type c1,
lyx::textclass_type c2,
- Paragraph * par,
- BufferParams const & bparams);
+ ParagraphList & par);
///
bool checkPastePossible();
+2003-05-06 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * ControlDocument.C (classApply): adjust call to
+ SwitchLayoutsBetweenClasses.
+
2003-04-25 Lars Gullik Bjønnes <larsbj@gullik.net>
* ControlDocument.C (setLanguage): call updateDocLang when not
Language const * newL = bp_->language;
if (oldL != newL) {
-
+
if (oldL->RightToLeft() == newL->RightToLeft()
&& !lv_.buffer()->isMultiLingual())
lv_.buffer()->changeLanguage(oldL, newL);
lv_.message(_("Converting document to new document class..."));
int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
old_class, new_class,
- &*(lv_.buffer()->paragraphs.begin()),
- lv_.buffer()->params);
+ lv_.buffer()->paragraphs);
if (!ret)
return;
+2003-05-06 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * limited_stack.h: Change some comments, simplify a couple of
+ class functions.
2003-02-21 André Pönitz <poenitz@gmx.net>
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* forkedcontr.C (timer): remove bogus continue
-
+
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* forkedcallqueue.[Ch]: added
#include <deque>
/**
- * limited_stack - a stack of limited size
+ * limited_stack - A stack of limited size.
*
* Like a normal stack, but elements falling out
* of the bottom are destructed.
limit_ = limit;
}
- /// return the top element
+ /// Return the top element.
value_type top() {
return c_.front();
}
- /// pop and throw away the top element
+ /// Pop and throw away the top element.
void pop() {
c_.pop_front();
}
- /// return true if the stack is empty
+ /// Return true if the stack is empty.
bool empty() const {
- return c_.size() == 0;
+ return c_.empty();
}
- /// clear all elements, deleting them
+ /// Clear all elements, deleting them.
void clear() {
- while (!c_.empty()) {
- c_.pop_back();
- }
+ c_.clear();
}
- /// push an item on to the stack, deleting the
+ /// Push an item on to the stack, deleting the
/// bottom item on overflow.
void push(value_type const & v) {
c_.push_front(v);
}
}
- /// direct read access to intermediate elements
+ /// Direct read access to intermediate elements.
T const & operator[](size_type pos) const {
return c_[pos];
}
- /// read access to used size
+ /// Read access to used size.
size_type size() const {
return c_.size();
}
private:
- /// internal contents
+ /// Internal contents.
container_type c_;
- /// the maximum number elements stored
+ /// The maximum number elements stored.
size_type limit_;
};
-// make pointer type an error.
+// Make pointer type an error.
template <typename T>
class limited_stack<T*>;