Issue 110217

Summary: Paste from clipboard pastes the previous contents of the clipboard
Product: Writer Reporter: john_ha <john.ha24z>
Component: editingAssignee: writerneedsconfirm <swneedsconfirm>
Status: CLOSED DUPLICATE QA Contact: issues@sw <issues>
Severity: Trivial    
Priority: P3 CC: issues, karl, t.c.black
Version: OOO320m12   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description john_ha 2010-03-18 12:14:30 UTC
I am running OOO320m12 under Windows 7 Home Premium 64 bit version.

When I paste into an OO Writer document the previous contents of the clipboard
are often pasted, instead of the current contents.  It is intermittent, but the
following often reproduces it:

1  Start Writer and create a new empty Writer document.  Write the word DOG in it
2  Create a new Notepad document.  Write the word CAT in it
3  Copy DOG in the Writer document with ctrl/c.  Paste the clipboard contents
into the Writer document with ctrl/v - it pastes OK and DOG appears.    
4  Change focus to Notepad and paste the contents of the clipboard into Notepad
with ctrl/v.  It pastes OK and DOG appears.
5  Now copy CAT from the Notepad document with ctrl/c.  Paste it in Notepad with
ctrl/v.  It pastes OK and CAT appears, showing the clipboard now contains CAT as
expected.

Now comes the problem

6  Change focus to the Writer document and press ctrl/v to paste the contents of
the clipboard to the Writer document.  I expect to see CAT appear, but DOG (the
word previously copied in Writer) appears instead.  Repeated ctrl/v keeps
pasting DOG in the Writer document.  This is wrong.

7  Change focus back to Notepad and press ctrl/v.  The word CAT appears as
expected - the last time I copied anything, I copied CAT.  This is OK.

The clipboard always seems to have the correct contents, because it pastes
correctly into Notepad.  But when I paste into Writer, Writer seems to pick up
the previous contents of the clipboard.   Could it be that Writer is not
clearing a buffer from its previous copy?    

Other points:

1  It is intermittent - sometimes it works properly, sometimes it doesn't.

2  It can also happen when copying between two Writer documents.

3  It can also happen if the first item copied (DOG in 1 above) is an image.

4  I do not have Selection Clipboard enabled in OO

5  I have uninstalled and reinstalled OO and it still happens.  Should I remove
all my profile stuff as well and do a fresh install?

6  I never saw the problem in XP - it has only appeared since changing to
Windows 7.  I do not recall which version of OO I was running in XP but it was
fully updated when my XP PC died in Nov 2009.  

7  I first reported it as
http://www.oooforum.org/forum/viewtopic.phtml?t=95978&highlight= and got very
few comments.  I first noticed it with a Master document but later testing
proved that the fault occurs with a standard odt file without a Master document
being open.  

8  It also happens as reported if I use EDIT > COPY and EDIT > PASTE instead of
ctrl/c and ctrl/v 

9  I have only noticed the error when I am pasting into Writer.  It does not
happen when pasting into other applications.  It does happen when I copy from
other applications like Thunderbird.  This does suggest it is Writer causing the
problem.

I cannot understand why I am getting it and no-one else seems to be getting it!
 My Windows 7 is a standard installation.  I have two users defined on the PC. 
It would not surprise me if it was something in Windows 7 causing the problem -
perhaps the implementation of Clipboard has changed in W7 and OO is not picking
it up properly.  I am happy to provide files and run suggested diagnostic tests.
Comment 1 john_ha 2010-03-18 13:36:08 UTC
Since submitting the report, I have come across these posts
http://user.services.openoffice.org/en/forum/viewtopic.php?f=15&t=24973 in the
OO Community Forum which describes the same problem.  Windows 7 seems to be a
common feature of the posts.

I also note that searching on clipboard here throws up a few issues including  
102232.  I do not have Clipboard Manager installed.  
Comment 2 michael.ruess 2010-03-19 08:26:35 UTC
I cannot confirm this with OOo 3.2 on Windows7 (with all updates installed).
Copy/paste between Notepad/Writer works fine in the above described way.
Comment 3 john_ha 2010-03-19 09:17:05 UTC
Let me answer your points.

1  I see that you cannot confirm this, but please note that it is an
intermittent problem. 

2  My Windows 7 is fully up to date

3  Were you testing with the 64 bit version of Windows 7?  I have not (so far)
been able to reproduce it on the 32 bit version of Windows 7 and the posts in
the Community Forum also seem to suggest that 64 bit is a common factor.

Comment 4 john_ha 2010-03-19 10:06:02 UTC
I have two different versions of clip.exe on my PC.  It appears as though one is
the 32 bit version and the other is the 64 bit version

C:\Windows\System32\clip.exe  32kB  14/7/2009
C:\Windows\SysWOW64\clip.exe  26kB  14/7/2009

When I hover over them, both say:

File description:  Clip - copies data into the clipboard
Company: Microsoft Corporation
File Version: 6.1.7600.16385
Date created: 14/7/2009  00:25 [SysWOW64 says 00:15]
Size: 31.5kB (32) [SysWOW64 says 25.5kB] 

So, Writer is presumably calling clip.exe, but could there be a subtle
difference because one is 32 bit, and works OK in 32 bit W7; while the other is
64 bit, and fails for me in 64 bit W7?  

I could not locate any exe which suggested it pasted from the clipboard -
perhaps clip.exe does all clipboard functions.
Comment 5 tcblack 2010-03-21 02:23:50 UTC
Me too!  Emphasis on the issue being intermittent.  I use Writer 90% of the
time, so I haven't noticed it in any of the other components, but this does not
mean it doesn't apply to them.  
The description which opens this bug report is very good.  Sometimes I can
happily paste again and again from different sources, other times I'm stopped
dead by this bug and there is no way for me to paste into my document.  
I am convinced that somewhere, OOo must have a cache or temporary variable or
some sort of buffer which is not being cleared.

System specs included:

Gateway GT 5058 Desktop | Overal WEI (Windows Experience Index): 4.9 
Windows 7 Professional 64bit  - all patches. 
Kaspersky Internet Security 2010 - up to date
Processor AMD Athlon(tm) 64 X2 Dual Core Processor 3800+  (WEI 4.9)
Memory (RAM) 4.00 GB (WEI 4.9)
Graphics NVIDIA GeForce 9600 GT (WEI 6.4)
Gaming graphics 2303 MB Total available graphics memory (WEI 6.4)
Dual 22" widescreen monitors at 1680x1050 - using DVI duallink cables 
Primary hard disk 343GB Free (466GB Total) (WEI 5.9)
Comment 6 john_ha 2010-03-21 08:51:23 UTC
I have been able to reproduce the problem in Writer, Calc and Impress.

I was wondering if it could depend on the number of characters which are copied.
 I used CAT and DOG as very clear examples in my report, but I get the error
with what I am actually copying.  I therefore did the following test

1  Open Notepad and create 9 lines of text as below
1
12
123
1234
12345
123456
1234567
12345678
123456789

2  Open writer and write these 9 lines into Writer

3  Start in Writer and copy 123456789.  Paste it in Notepad - OK

4  Copy 1 in Notepad, paste in Writer - pastes as 1 OK
   Copy 123456789 in Writer, copy 12 in Notepad, paste in Writer - pastes 12 OK
   Repeat for 123, 1234, 12345 etc - all paste OK in Writer

5  Move up a line, copy 123456768 in Writer and paste in Notepad - pastes OK
   Copy 1 in Notepad, paste in Writer - pastes 1 OK

6  Copy 123456768 in Writer, copy 12 in Notepad, paste in Writer - pastes 12 OK
   Copy 123456768 in Writer, copy 123 in Notepad, paste in Writer - I get the
error and 12345678 is pasted in Writer.  Immediately paste again in Writer with
ctrl/v and I get 12345678 in Writer - it should be 123.  Change focus to Notepad
and ctrl/v - 123 is pasted in Notepad, which is correct.

7  Open a Calc sheet and ctrl/v - 12345678 is pasted in Calc.  This is wrong.  I
expect 123 to be pasted, but Calc seems to be getting the previous contents
stored in Writer.

8  Open an Impress sheet and ctrl/v into a text box - 12345678 is pasted into
Impress.  This is wrong.  I expect 123 to be pasted, but Impress seems to be
getting the previous contents stored in Writer.

9  Change focus to Notepad and ctrl/v - 123 is pasted into Notepad.  This is
correct as the last time I copied anything, I copied 123. 

10 Close all OO sheets.  Reopen OO and go back to step 1 - everything is OK and
I cannot reproduce the error

11 Close Writer, open Writer, and go back to Step 1 - the error occurs
immediately the first time I copy 1 in Notepad - it is pasted as 123456789 in
Writer.

Conclusions.  

1  It appeares to occur with Windows 7 64 bit. 

2  The problem is not confined to Writer, but occurs with Writer, Calc and Impress.

It does look (to my untutored eye) like OO is picking up what it pastes from a
temporary storage areas or buffer instead of from the clipboard.  Or that the W7
64 bit clipboard is storing the previous contents, as well as the current
contents, and OO is sometimes getting the previous contents instead of the
current contents.
Comment 7 john_ha 2010-03-24 15:17:40 UTC
The post
http://user.services.openoffice.org/en/forum/viewtopic.php?f=15&t=28669&p=131709#p131709
 has a user running XP SP3 who also gets this exact problem so it does not look
like it only occurs under Windows 7 64 bit. 

He says "I'm running XP, 32Bit with SP3. Maybe this has nothing to do with the
OS since I'm having the exact same problems as stated on your own thread."
Comment 8 eric.savary 2010-05-20 11:21:37 UTC
The problem is that we cannot handle issues which only happen "sometimes".
Try to find a reproducible scenario (together with the XP SP3 user).
Find out a detailed manipulation for which the problem always appears.
Feel free to reopen then.
Comment 9 eric.savary 2010-05-20 11:21:54 UTC
Closed
Comment 10 john_ha 2010-05-20 16:03:23 UTC
I realise the difficulty in debugging intermittent problems.

This is not a Writer problem - it is an OO Interface problem as it appears in
Writer, Calc and Impress.

However, I would have hoped that someone might have been able to have a quick
look at copy / paste code in OO to see whether there is some poor or faulty
coding there.  It appears that OO is somehow

a) storing the previous contents of the clipboard somewhere!  Is it a buffer?
b) not pasting the current contents of the Windows clipboard, but pasting the
wrongly stored data - ie OO is not picking up the current contents of the
clipboard.  So how is OO picking up the stored data?

This looks like it is not a Windows problem, but an OO problem.

I have tried to find a way of guaranteeing to reproduce it, but no luck so far. 
Comment 11 john_ha 2010-05-21 00:12:41 UTC
I have found a way of making the problem reproduceable.  

You need a clipboard viewer to see what is happening.  It is reproduceable using
the text and image technique as below but my original report shows how it also
happens (less often) when I copy text.

XP used to include clipbrd.exe which was a clipboard viewer.  It is not supplied
with Vista or W7, but it does work on W7.  Alternatively, download a similar
freebie utility. (Note - the clipboard viewer is not causing the problem.  I
originally got the problem when I did not have the clipboard viewer on my PC - I
only got the clipboard viewer in order to help me analyse the problem after it
had occurred.)

1  Open clipbrd.exe - we will use it to see the contents of the clipboard

2  Open an image with an image editor (MS Paint works) and copy the image.  Look
at clipbrd.exe - it now contains the image.  (nb IrfanView is a bit better
because IrfanView allows me to past both text and images into it)

3  Open a new Writer file and PASTE - the image is pasted into the document at
the cursor position.  This is as expected.

So we have proved that OO will paste an image from the clipboard at the current
cursor position.

4  Close the document.  

5  Open a new Writer file and type the words zebra and lion. 

6  Highlight zebra, and copy it.  Paste it into the document - zebra appears

7  Look at clipbrd.exe - it now contains zebra as expected because the last
thing copied was the word zebra

8  Go back to the image editor, select the image and copy it.  Paste the image
into the image editor - it pastes the image OK.  So the clipboard now contains
the image.

9  Check clipbrd.exe - note how, as expected, it contains the image.

10  Change focus to OO Writer, and just paste or Ctrl/v.  

You would expect the contents of the clipboard to be pasted - ie the image - as
in Step 3 above, but they are not!  Instead, then previous contents of the
clipboard which were copied from Writer, namely zebra, is pasted.

This is clearly wrong.

11  Return to the image editor and paste or ctrl/v.  The image is pasted.

So the image editor pastes the CURRENT contents of the clipboard OK, but OO
pastes the PREVIOUS contents of the clipboard which Writer itself copied.   

11  In Writer, copy lion.  Paste into Writer - lion is pasted OK.  Paste into
another text app (Notepad) and lion is pasted OK.  Check clipbrd.exe - it has
lion.  This is all as expected

So the problem looks like at Step 10 Writer (and Calc and Impress) is picking up
zebra from an OO Writer buffer which has not been cleared - it is NOT picking up
the current contents of the clipboard.

I have since done a bit of digging.  This mozilla forum entry is interesting -
it seems to be the same problem and seems to have been analysed as a race
problem.  http://netbeans.org/bugzilla/show_bug.cgi?id=88161


I have reproduced this fault five times in succession by following the written
steps exactly as above.  
Comment 12 john_ha 2010-05-21 00:28:37 UTC
Sorry, I forgot to add that when I repeated the steps above using Thunderbird
email client instead of OO Writer, everything worked exactly as expected - ie at
Step 10, the image is copied into Thunderbird.

This does suggest that it is definitely an OO problem, and is not caused by any
of the sofware (MS Paint, clipbrd.exe, Notepad) which I am using to do the testing. 
Comment 13 isaac_s 2010-08-22 02:31:49 UTC
Happens on Windows XP SP3 (32bit) as well.

Windows clipboard viewer shows clipboard has been updated with new contents, but
OOo always pastes whatever used to be in the clipboard beforehand.
Comment 14 michael.ruess 2010-09-02 14:30:39 UTC
Same root cause as issue 113171.

*** This issue has been marked as a duplicate of 113171 ***
Comment 15 michael.ruess 2010-09-02 14:33:44 UTC
Closing duplicate.
Comment 16 Dr. Karl Schindler 2013-09-10 03:37:47 UTC
i got the same problem with Open Office V4.0.0
running W7 32 bit.
i copy some cells and paste them in skype -> ok
i now copy the message from skype -> content from cells i copied before are copied.
restart of OO brings nothing.
rebooting of machine is no workaround