Apache OpenOffice (AOO) Bugzilla – Issue 45248
Undo for enhanced Paste Special of Unformatted Text
Last modified: 2013-08-07 15:13:58 UTC
The problem was, Description of Problem: When you copy formatted text from another source (say, text displayed in a browser window) and then go into Calc and select Edit | Paste Special, and then select "Unformatted Text", once the paste operation is completed, it does not display the text. Sometimes, it displays parts of the text but often it doesn't display anything. If you flip to another application and then flip back to Calc, you see the text, so it's "there", but it's not initially. Steps to reproduce the problem: 1. Copy some formatted text from another source. 2. Create a new spreadsheet 3. Place your cursor into a cell 4. Select Edit | Paste Special 5. Select the "Unformatted Text" option 6. Accept the defaults in the "Text Import" dialog that's shown 7. Notice that some (most or all, most commonly) text is not visible. Actual Results: You can't see all of the pasted text. Expected Results: To see all of the pasted text. How often does this happen? All the time when I do the Paste Special option as described above. Patch To this problem: this problem can be solved with the following patch. it also solves the problem of undo with paste special. here is the patch : --- impex.cxx.orig 2005-03-12 16:16:33.215914400 +0530 +++ impex.cxx 2005-03-12 16:19:00.531519024 +0530 @@ -1070,6 +1072,8 @@ if (!pExtOptions) return Text2Doc( rStrm ); + StartPaste(); // Undo & others are taken care, fix for #65217 + ULONG nOldPos = rStrm.Tell(); rStrm.Seek( STREAM_SEEK_TO_END ); ScProgress aProgress( pDocSh, ScGlobal::GetRscString( STR_LOAD_DOC ), rStrm.Tell() - nOldPos ); @@ -1084,6 +1088,8 @@ SCCOL nStartCol = aRange.aStart.Col(); SCROW nStartRow = aRange.aStart.Row(); SCTAB nTab = aRange.aStart.Tab(); + SCCOL nEndCol = aRange.aEnd.Col(); // fix for #65217 + SCROW nEndRow = aRange.aEnd.Row(); // fix for #65217 BOOL bFixed = pExtOptions->IsFixedLen(); const String& rSeps = pExtOptions->GetFieldSeps(); @@ -1190,6 +1196,10 @@ bOverflow = TRUE; // beim Import Warnung ausgeben break; } + + // Find the correct End Col and End Row, fix for #65217 + if(nCol>nEndCol) nEndCol=nCol; + if(nRow>nEndRow) nEndRow=nRow; } ScColumn::bDoubleAlloc = bOld; @@ -1198,6 +1208,11 @@ delete pEnglishTransliteration; delete pEnglishCalendar;
Hi Niklas, please have a look at this one. Frank
Something is missing at the end of the patch. But i don't see how this is supposed to work, as the initial StartPaste copies only the first cell. The whole problem doesn't occur in official builds (issue 15509 is still open), so it's no urgent issue, and I'll set the target to "later".
oops sorry for the partial patch (on behalf of naveen_kv). here's a proper one:
oops, sorry for the partial patch (on behalf of naveen_kv) here's the complete one: --- sc/source/ui/docshell/impex.cxx 2005-03-12 16:16:33.215914400 +0530 +++ sc/source/ui/docshell/impex.cxx 2005-03-12 16:19:00.531519024 +0530 @@ -1070,6 +1072,8 @@ if (!pExtOptions) return Text2Doc( rStrm ); + StartPaste(); // Undo & others are taken care + ULONG nOldPos = rStrm.Tell(); rStrm.Seek( STREAM_SEEK_TO_END ); ScProgress aProgress( pDocSh, ScGlobal::GetRscString( STR_LOAD_DOC ), rStrm.Tell() - nOldPos ); @@ -1084,6 +1088,8 @@ SCCOL nStartCol = aRange.aStart.Col(); SCROW nStartRow = aRange.aStart.Row(); SCTAB nTab = aRange.aStart.Tab(); + SCCOL nEndCol = aRange.aEnd.Col(); + SCROW nEndRow = aRange.aEnd.Row(); BOOL bFixed = pExtOptions->IsFixedLen(); const String& rSeps = pExtOptions->GetFieldSeps(); @@ -1190,6 +1196,10 @@ bOverflow = TRUE; // beim Import Warnung ausgeben break; } + + // Find the correct End Col and End Row + if( nCol>nEndCol ) nEndCol = nCol; + if( nRow>nEndRow ) nEndRow = nRow; } ScColumn::bDoubleAlloc = bOld; @@ -1198,6 +1208,11 @@ delete pEnglishTransliteration; delete pEnglishCalendar; + // Set End Row and End Col so that the page is refreshed correctly + aRange.aEnd.SetCol( nEndCol ); + aRange.aEnd.SetRow( nEndRow ); + EndPaste(); // Paste was successful, refresh, etc. + return TRUE; }
Undo doesn't work if the range wasn't empty before, because StartPaste, which copies the cells for undo, is called before the range size is known (the end column and row are off by 1, too).
heres (my) updated version: this would actually iterate twice: once without actual paste, to find the range and the next time - to paste. --- sc/source/ui/docshell/impex.cxx 2005-04-14 09:50:04.000000000 +0530 +++ sc/source/ui/docshell/impex.cxx 2005-05-03 10:29:04.727361887 +0530 @@ -1084,6 +1084,8 @@ BOOL ScImportExport::ExtText2Doc( SvStre SCCOL nStartCol = aRange.aStart.Col(); SCROW nStartRow = aRange.aStart.Row(); SCTAB nTab = aRange.aStart.Tab(); + SCCOL nEndCol = aRange.aEnd.Col(); + SCROW nEndRow = aRange.aEnd.Row(); BOOL bFixed = pExtOptions->IsFixedLen(); const String& rSeps = pExtOptions->GetFieldSeps(); @@ -1127,6 +1129,14 @@ BOOL ScImportExport::ExtText2Doc( SvStre if ( rStrm.IsEof() ) break; } + + bool bGetRange = FALSE; + nOldPos = rStrm.Tell(); + + do + { + bGetRange = !bGetRange; // Toggle + for( ;; ) { rStrm.ReadCsvLine( aLine, !bFixed, rSeps, cStr); @@ -1144,9 +1154,12 @@ BOOL ScImportExport::ExtText2Doc( SvStre { xub_StrLen nStart = pColStart[i]; xub_StrLen nNext = ( i+1 < nInfoCount ) ? pColStart[i+1] : nLineLen; - aCell = lcl_GetFixed( aLine, nStart, nNext ); - bMultiLine |= lcl_PutString( pDoc, nCol, nRow, nTab, aCell, pColFormat[i], - aTransliteration, aCalendar, pEnglishTransliteration, pEnglishCalendar ); + if( !bGetRange ) + { + aCell = lcl_GetFixed( aLine, nStart, nNext ); + bMultiLine |= lcl_PutString( pDoc, nCol, nRow, nTab, aCell, pColFormat[i], + aTransliteration, aCalendar, pEnglishTransliteration, pEnglishCalendar ); + } ++nCol; } } @@ -1172,7 +1185,8 @@ BOOL ScImportExport::ExtText2Doc( SvStre } if ( nFmt != SC_COL_SKIP ) { - bMultiLine |= lcl_PutString( pDoc, nCol, nRow, nTab, aCell, nFmt, + if( !bGetRange ) + bMultiLine |= lcl_PutString( pDoc, nCol, nRow, nTab, aCell, nFmt, aTransliteration, aCalendar, pEnglishTransliteration, pEnglishCalendar ); ++nCol; } @@ -1190,7 +1204,24 @@ BOOL ScImportExport::ExtText2Doc( SvStre bOverflow = TRUE; // beim Import Warnung ausgeben break; } + + // Find the correct End Col and End Row + if( bGetRange ) + { + if(nCol>nEndCol) nEndCol=nCol; + if(nRow>nEndRow) nEndRow=nRow; + } } + if( bGetRange ) + { + aRange.aEnd.SetCol( nEndCol - 1 ); + aRange.aEnd.SetRow( nEndRow - 1 ); + StartPaste(); // Start the Paste, in the next iteration the actual paste is + // performed. + rStrm.Seek( nOldPos ); + nRow = nStartRow; + } + } while(bGetRange); ScColumn::bDoubleAlloc = bOld; pDoc->DoColResize( nTab, 0, MAXCOL, 0 ); @@ -1198,6 +1229,8 @@ BOOL ScImportExport::ExtText2Doc( SvStre delete pEnglishTransliteration; delete pEnglishCalendar; + EndPaste(); // Paste was successful, refresh, etc. + return TRUE; }
Let's reconsider the target. Niklas would you have a look at the revised patch.
Eike, you should keep this in mind (Undo) when handling issue 15509.
Accepted.
Aligning target with issue 15509.
Implemented with slight corrections with issue 15509. *** This issue has been marked as a duplicate of 15509 ***
Closing.