attached is the previous patch for pasting externally
with better naming as pointed out by jmarc

thanks
john

p.s. are we still planning to move to binutils-style
patch applying system ? it would be lot less load if
I could apply this myself after waiting for one or two
"approved" responses

-- 
"IBM's decision to choose the Intel 80x86 processor over
the Motorola 680x0 probably set the personal computer
industry back 10 years."
        - Brian Marsden
diff -u -r1.182 ChangeLog
--- ChangeLog   2001/06/01 15:10:25     1.182
+++ ChangeLog   2001/06/01 19:57:06
@@ -1,3 +1,13 @@
+2001-06-01  John Levon  <[EMAIL PROTECTED]>
+
+       * CutAndPaste.C: fix indentation
+
+       * lyxparagraph.h:
+       * lyxtext.h:
+       * paragraph.C:
+       * text2.C: add "withlabels" parameter to prevent
+         label strings from appearing in external pastes
+ 
 2001-06-01  Juergen Vigna  <[EMAIL PROTECTED]>
 
        * lyxfunc.C (Dispatch): LFUN_PREFIX don't call the update if we're
Index: CutAndPaste.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v
retrieving revision 1.31
diff -u -r1.31 CutAndPaste.C
--- CutAndPaste.C       2001/05/30 13:53:25     1.31
+++ CutAndPaste.C       2001/06/01 19:57:06
@@ -56,17 +56,17 @@
 // Perhaps it even should take a parameter? (Lgb)
 void DeleteBuffer()
 {
-    if (!buf)
+       if (!buf)
                return;
        
-    LyXParagraph * tmppar;
+       LyXParagraph * tmppar;
        
-    while (buf) {
+       while (buf) {
                tmppar =  buf;
                buf = buf->next();
                delete tmppar;
-    }
-    buf = 0;
+       }
+       buf = 0;
 }
 
 } // namespace anon
@@ -320,11 +320,11 @@
                                             LyXTextClassList::size_type c2,
                                             LyXParagraph * par)
 {
-    int ret = 0;
-    if (!par || c1 == c2)
+       int ret = 0;
+       if (!par || c1 == c2)
                return ret;
 
-    while (par) {
+       while (par) {
                string const name = textclasslist.NameOfLayout(c1,
                                                               par->layout);
                int lay = 0;
@@ -350,14 +350,12 @@
                        par->InsertInset(0, new_inset);
                }
                par = par->next();
-    }
-    return ret;
+       }
+       return ret;
 }
 
 
 bool CutAndPaste::checkPastePossible(LyXParagraph *)
 {
-    if (!buf) return false;
-
-    return true;
+       return buf;
 }
diff -u -r1.78 lyxparagraph.h
--- lyxparagraph.h      2001/05/30 13:53:30     1.78
+++ lyxparagraph.h      2001/06/01 19:57:23
@@ -111,8 +111,9 @@
        ///
 
        string const String(Buffer const *, bool label);
-       ///
-       string const String(Buffer const *, size_type beg, size_type end);
+       /// if withlabels is false, don't include label strings
+       string const String(Buffer const *, size_type beg, size_type end,
+               bool withlabels = true);
        
        ///
        void writeFile(Buffer const *, std::ostream &, BufferParams const &,
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.67
diff -u -r1.67 lyxtext.h
--- lyxtext.h   2001/05/31 02:23:41     1.67
+++ lyxtext.h   2001/06/01 19:57:26
@@ -260,8 +260,8 @@
        void SetSelection(BufferView *);
        ///
        void ClearSelection(BufferView *) const;
-       ///
-       string const selectionAsString(Buffer const *) const;
+       /// if withlabels is false, don't add labels
+       string const selectionAsString(Buffer const *, bool withlabels = true) const;
        
        /// just selects the word the cursor is in
        void SelectWord(BufferView *);
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.140
diff -u -r1.140 paragraph.C
--- paragraph.C 2001/05/31 22:34:05     1.140
+++ paragraph.C 2001/06/01 19:57:31
@@ -2297,6 +2297,7 @@
 {
        BufferParams const & bparams = buffer->params;
        string s;
+
        if (label && !params.labelString().empty())
                s += params.labelString() + ' ';
        string::size_type const len = s.size();
@@ -2322,11 +2323,12 @@
 
 string const LyXParagraph::String(Buffer const * buffer, 
                            LyXParagraph::size_type beg,
-                           LyXParagraph::size_type end)
+                           LyXParagraph::size_type end,
+                           bool withlabels)
 {
        std::ostringstream ost;
 
-       if (beg == 0 && !params.labelString().empty())
+       if (withlabels && beg == 0 && !params.labelString().empty())
                ost << params.labelString() << ' ';
 
        for (LyXParagraph::size_type i = beg; i < end; ++i) {
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.130
diff -u -r1.130 text2.C
--- text2.C     2001/05/31 22:34:05     1.130
+++ text2.C     2001/06/01 19:57:41
@@ -1104,7 +1104,7 @@
 }
 
 
-string const LyXText::selectionAsString(Buffer const * buffer) const
+string const LyXText::selectionAsString(Buffer const * buffer, bool withlabels) const
 {
        if (!selection.set()) return string();
        string result;
@@ -1113,7 +1113,8 @@
        if (selection.start.par() == selection.end.par()) {
                result += selection.start.par()->String(buffer,
                                                         selection.start.pos(),
-                                                        selection.end.pos());
+                                                        selection.end.pos(),
+                                                        withlabels);
                return result;
        }
        
@@ -1122,19 +1123,21 @@
        // First paragraph in selection
        result += selection.start.par()->String(buffer,
                                                 selection.start.pos(),
-                                                selection.start.par()->size())
+                                                selection.start.par()->size(),
+                                                withlabels)
                + "\n\n";
        
        // The paragraphs in between (if any)
        LyXCursor tmpcur(selection.start);
        tmpcur.par(tmpcur.par()->next());
        while (tmpcur.par() != selection.end.par()) {
-               result += tmpcur.par()->String(buffer, 0, tmpcur.par()->size()) + 
"\n\n";
+               result += tmpcur.par()->String(buffer, 0, 
+                       tmpcur.par()->size(), withlabels) + "\n\n";
                tmpcur.par(tmpcur.par()->next()); // Or NextAfterFootnote??
        }
 
        // Last paragraph in selection
-       result += selection.end.par()->String(buffer, 0, selection.end.pos());
+       result += selection.end.par()->String(buffer, 0, selection.end.pos(), 
+withlabels);
        
        return result;
 }
@@ -1780,7 +1783,7 @@
        // finished. The solution used currently just works, to make it
        // faster we need to be more clever and probably also have more
        // calls to stuffClipboard. (Lgb)
-       bview->stuffClipboard(selectionAsString(bview->buffer()));
+       bview->stuffClipboard(selectionAsString(bview->buffer(), false));
 
        // This doesn't make sense, if there is no selection
        if (!selection.set())
@@ -1860,7 +1863,7 @@
        // finished. The solution used currently just works, to make it
        // faster we need to be more clever and probably also have more
        // calls to stuffClipboard. (Lgb)
-       bview->stuffClipboard(selectionAsString(bview->buffer()));
+       bview->stuffClipboard(selectionAsString(bview->buffer(), false));
 
        // this doesnt make sense, if there is no selection
        if (!selection.set())

Reply via email to