Proposed fix for #8001 RFC

From: Roland Kay <>
Date: Mon May 30 2005 - 13:41:24 CEST


Now that I have a little more free time than has been the
case recently, I want to try to fix bug 8001. In my general
use of abi this bug is by far the most troublesome since it
means that a simple copy/paste operation can completely
destroy the style sheet of the target document. Obviously,
if the two documents both use the same set of styles then
the problem does not manifest itself. However, when the
styles differ this bug can lead to a big mess that take ages
to sort out.

As I understand it, at the moment when the user selects some
text and hits "copy" abi wraps the selected text up as a
complete RTF document and sticks it on the clipboard.
Presumably, when the RTF importer is called during a paste
operation it processes the styles section of this RTF file
and tramples on any styles already defined in the target

In my opinion, a documents style sheet is sacred and should
not be implicitly altered like this. If the user wishes to
copy styles from one document to another I think they should
have to do this explicitly (using "import styles" for

The result of this approach would be that if the two
documents have different "Normal" styles defined then
copying "Normal" text from one document to the other would
result in the text adopting the style of the target
document. That seems like reasonable behaviour to me.

In the case, where a style exists in the source document but
not the target document we'd have a couple of options:

1, Paste it with style set to "None".
2, Implicitly import that style only.
3, Paste it with style set to "Normal" (or "None" if no normal).
4, Adopt a nearby style.

Personally, I'd be happy enough with any except no. 2.

This could more or less be achieved by asking the RTF
importer to ignore the styles section of the RTF. However, I
suspect that would be messy. I can also envisage some
serious problems. For example, in RTF documents it's
possible to specify a character encoding as part of a style
(via a font definition). If the importer just ignored such
styles and assumed the document character encoding, the
pasted text would be corrupted. Microsoft Word generated RTF
makes heavy of this feature to support multilingual RTF
documents. As far as I know abi doesn't do this at the
moment; however, if the RTF exporter were ever changed such
that it did this, copy/paste would be in trouble. Such a
chance might be necessary to fix bug 8514, for example. I
strongly suspect there would be other problems lurking in
the wings as well.

It strikes me that this problem would be much easier to fix
if abi wrote its internal format to the clipboard along
side the existing formats: RTF, XHTML, HTML, TEXT [1]. Other
applications receiving data from abi via the clipboard would
of course ignore this and use RTF or HTML instead. However,
the most common operations of copying/pasting within abi
would no longer have to go through a messy external format
like RTF. This might make #8001 easier to fix and might also
avoid the likes of #8468 and #8500 in the future.

Furthre, I propose that this extra data on the clipboard not
be a complete document. It merely need contain the commands
which define the content selected, the style names and any
additional formatting; as if we'd saved the files and copied
and pasted the corresponding sections of the .abw file. This
would remove any possibility of the global document data
(style sheet, history etc.) being altered in the target

Does anyone see a problem with this approach or have a
better idea? Feedback would be very welcome. :-)

This is basically a bug fix. In my opinion, the current
behaviour of copy/paste is a very serious issue. However, if
the modifications necessary to fix it turn out to be this
extensive then they may not be suitable for 2.4. If this is
the case I'm happy to hold off submitting a patch until 2.6.
I'd like to get started implementing this sooner rather than
later though since this problem drastically limits my
ability to use abi for serious work at the moment.

Best wishes,


[1] see AP_UnixApp::copyToClipboard in ap_UnixApp.cpp.
Received on Mon May 30 13:43:54 2005

This archive was generated by hypermail 2.1.8 : Mon May 30 2005 - 13:43:56 CEST