Bug 56456 - line breaks replaced by new paragraph when copy/paste via clipboard
Summary: line breaks replaced by new paragraph when copy/paste via clipboard
Status: RESOLVED FIXED
Alias: None
Product: kword
Classification: Miscellaneous
Component: general (show other bugs)
Version: 1.5 or before
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Thomas Zander
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-26 22:24 UTC by Stefan Frings
Modified: 2003-03-28 15:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Frings 2003-03-26 22:24:42 UTC
Version:           1.2.1 (using KDE 3.1.0)
Installed from:    SuSE
Compiler:          gcc version 3.2
OS:          Linux (i686) release 2.4.19-4GB

When I write a paragraph with line-breaks and copy/paste it via the clipboard my new pasted line-breaks are replaced by paragraph-breaks. I think this should be made better in next version because it makes a lot of work when I copy/paste much text with line-breaks.
Comment 1 David Faure 2003-03-27 17:41:30 UTC
Subject: Re:  New: line breaks replaced by new paragraph when copy/paste via clipboard

On Wednesday 26 March 2003 22:24, you wrote:
> When I write a paragraph with line-breaks and copy/paste it via the clipboard my new pasted line-breaks are replaced by paragraph-breaks. I think this should be made better in next version because it makes a lot of work when I copy/paste much text with line-breaks.

Please specify, which application you're copying from, and which one you're pasting to?
Is this from plain text, to plain text, or "from kword to kword" ?
Thanks.

Comment 2 Stefan Frings 2003-03-27 21:54:59 UTC
I copy and paste within kword. I copy some lines and paste it at another position in  
the same kword document.  
Comment 3 David Faure 2003-03-28 15:14:01 UTC
Subject: koffice/kword

CVS commit by faure: 

Fixed pasting so that it can differenciate between linebreaks and paragraph boundaries.
CCMAIL: 56456-done@bugs.kde.org


  M +15 -18    kwcommand.cc   1.214


--- koffice/kword/kwcommand.cc  #1.213:1.214
@@ -51,7 +51,11 @@ KoTextCursor * KWPasteTextCommand::execu
     cursor.setParag( firstParag );
     cursor.setIndex( m_idx );
+    c->setParag( firstParag );
+    c->setIndex( m_idx );
     QDomDocument domDoc;
     domDoc.setContent( m_data );
     QDomElement elem = domDoc.documentElement();
+    KWTextDocument * textdoc = static_cast<KWTextDocument *>(c->parag()->document());
+    KWTextFrameSet * textFs = textdoc->textFrameSet();
     // We iterate twice over the list of paragraphs.
     // First time to gather the text,
@@ -61,5 +65,4 @@ KoTextCursor * KWPasteTextCommand::execu
     QValueList<QDomElement> listParagraphs;
     QDomElement paragraph = elem.firstChild().toElement();
-    bool first = true;
     for ( ; !paragraph.isNull() ; paragraph = paragraph.nextSibling().toElement() )
     {
@@ -67,24 +70,18 @@ KoTextCursor * KWPasteTextCommand::execu
         {
             QString s = paragraph.namedItem( "TEXT" ).toElement().text();
-            if ( !first )
-                text += '\n';
-            else
-                first = false;
-            text += s;
+            //kdDebug() << "KWPasteTextCommand::execute Inserting text: '" << s << "'" << endl;
+            c->insert( s, false /*newline=linebreak, not new parag*/ );
+
+            if ( !paragraph.nextSibling().isNull() ) // Not for last parag
+            {
+                // Create new parag
+                // Lowlevel method:
+                c->splitAndInsertEmptyParag( FALSE, TRUE );
+                // Highlevel method:
+                //c->insert( "\n", true );
+            }
             listParagraphs.append( paragraph );
         }
     }
-    kdDebug() << "KWPasteTextCommand::execute Inserting text: '" << text << "'" << endl;
-    KWTextDocument * textdoc = static_cast<KWTextDocument *>(c->parag()->document());
-    KWTextFrameSet * textFs = textdoc->textFrameSet();
-    textFs->unzoom();
-
-    cursor.insert( text, true );
-
-    // Move cursor to the end
-    c->setParag( firstParag );
-    c->setIndex( m_idx );
-    for ( int i = 0; i < (int)text.length(); ++i )
-        c->gotoNextLetter();
 
     // Redo the parag lookup because if firstParag was empty, insert() has