Jürgen Spitzmüller schreef:
Vincent van Ravesteijn wrote:
Can I start backporting the fixes for the following bugs:
5998, 2034, 2213, 3706, 3918, 4177, 4509, 4952, 5390, 5435, 5458, 5944,
5948 ?
Yes. Please post the patches subsequently.
Jürgen
Patch for bug 5390.
Vincent
Index: src/Changes.cpp
===================================================================
--- src/Changes.cpp (revision 30476)
+++ src/Changes.cpp (working copy)
@@ -256,6 +256,24 @@
}
+bool Changes::isFullyDeleted(pos_type start, pos_type end) const
+{
+ ChangeTable::const_iterator it = table_.begin();
+ ChangeTable::const_iterator const itend = table_.end();
+
+ for (; it != itend; ++it) {
+ if (it->range.contains(Range(start, end))) {
+ LYXERR(Debug::CHANGES, "range ("
+ << start << ", " << end << ") fully contains ("
+ << it->range.start << ", " << it->range.end
+ << ") of type " << it->change.type);
+ return it->change.type == Change::DELETED;
+ }
+ }
+ return false;
+}
+
+
bool Changes::isChanged(pos_type const start, pos_type const end) const
{
ChangeTable::const_iterator it = table_.begin();
Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp (revision 30476)
+++ src/Paragraph.cpp (working copy)
@@ -286,6 +286,15 @@
}
+bool Paragraph::isFullyDeleted(pos_type start, pos_type end) const
+{
+ LASSERT(start >= 0 && start <= size(), /**/);
+ LASSERT(end > start && end <= size() + 1, /**/);
+
+ return d->changes_.isFullyDeleted(start, end);
+}
+
+
bool Paragraph::isChanged(pos_type start, pos_type end) const
{
LASSERT(start >= 0 && start <= size(), /**/);
Index: src/CutAndPaste.cpp
===================================================================
--- src/CutAndPaste.cpp (revision 30499)
+++ src/CutAndPaste.cpp (working copy)
@@ -435,14 +435,16 @@
// ERT paragraphs have the Language latex_language.
// This is invalid outside of ERT, so we need to change it
// to the buffer language.
- if (it->ownerCode() == ERT_CODE || it->ownerCode() ==
LISTINGS_CODE) {
+ if (it->ownerCode() == ERT_CODE || it->ownerCode() ==
LISTINGS_CODE)
it->changeLanguage(buf.params(), latex_language,
buf.language());
- }
+
it->setInsetOwner(0);
}
- // do not copy text (also nested in insets) which is marked as deleted
- acceptChanges(copy_pars, buf.params());
+ // do not copy text (also nested in insets) which is marked as deleted,
+ // unless the whole selection was deleted
+ if (!isFullyDeleted(copy_pars))
+ acceptChanges(copy_pars, buf.params());
DocumentClass * d = const_cast<DocumentClass *>(dc);
cutstack.push(make_pair(copy_pars, d));
Index: src/paragraph_funcs.h
===================================================================
--- src/paragraph_funcs.h (revision 30476)
+++ src/paragraph_funcs.h (working copy)
@@ -73,6 +73,8 @@
/// accept the changes within the complete ParagraphList
void acceptChanges(ParagraphList & pars, BufferParams const & bparams);
+/// return true if the whole ParagraphList is deleted
+bool isFullyDeleted(ParagraphList const & pars);
} // namespace lyx
Index: src/Changes.h
===================================================================
--- src/Changes.h (revision 30476)
+++ src/Changes.h (working copy)
@@ -94,6 +94,9 @@
/// return true if there is a change in the given range (excluding end)
bool isChanged(pos_type start, pos_type end) const;
+ /// return true if the whole range is deleted
+ bool isFullyDeleted(pos_type const start, pos_type const end) const;
+
/// output latex to mark a transition between two change types
/// returns length of text outputted
static int latexMarkChange(odocstream & os, BufferParams const &
bparams,
Index: src/paragraph_funcs.cpp
===================================================================
--- src/paragraph_funcs.cpp (revision 30476)
+++ src/paragraph_funcs.cpp (working copy)
@@ -305,6 +305,20 @@
}
+bool isFullyDeleted(ParagraphList const & pars)
+{
+ pit_type const pars_size = static_cast<pit_type>(pars.size());
+
+ // check all paragraphs
+ for (pit_type pit = 0; pit < pars_size; ++pit) {
+ if (!pars[pit].empty()) // prevent assertion failure
+ if (!pars[pit].isFullyDeleted(0, pars[pit].size()))
+ return false;
+ }
+ return true;
+}
+
+
void acceptChanges(ParagraphList & pars, BufferParams const & bparams)
{
pit_type pars_size = static_cast<pit_type>(pars.size());
Index: src/Paragraph.h
===================================================================
--- src/Paragraph.h (revision 30476)
+++ src/Paragraph.h (working copy)
@@ -198,6 +198,8 @@
bool isInserted(pos_type pos) const;
/// is there a deletion at the given pos ?
bool isDeleted(pos_type pos) const;
+ /// is the whole paragraph deleted ?
+ bool isFullyDeleted(pos_type start, pos_type end) const;
/// will the paragraph be physically merged with the next
/// one if the imaginary end-of-par character is logically deleted?