Issue 85715 - Writer's RTL text rendered incorrectly when embedded via OLE in 3rd party application
Summary: Writer's RTL text rendered incorrectly when embedded via OLE in 3rd party app...
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: viewing (show other issues)
Version: OOo 2.3.1
Hardware: PC Windows, all
: P3 Trivial with 1 vote (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-30 10:13 UTC by hennerdrewes
Modified: 2013-08-07 14:43 UTC (History)
1 user (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
writer doc used for embedding (6.78 KB, application/vnd.oasis.opendocument.text)
2008-01-30 10:15 UTC, hennerdrewes
no flags Details
Screenshot (37.53 KB, image/png)
2008-01-30 10:15 UTC, hennerdrewes
no flags Details
Additional screenshot (64.71 KB, image/png)
2008-01-30 10:16 UTC, hennerdrewes
no flags Details
Screenshot from my OOo (166.01 KB, image/jpeg)
2008-02-13 12:48 UTC, michael.ruess
no flags Details
patch for svtools/source/filter.vcl/wmf/emfwr.hxx (317 bytes, text/plain)
2008-02-14 15:47 UTC, hennerdrewes
no flags Details
patch for svtools/source/filter.vcl/wmf/emfwr.cxx (2.11 KB, text/plain)
2008-02-14 15:48 UTC, hennerdrewes
no flags Details
Patch for svtools/source/filter.vcl/wmf/wmfwr.cxx (6.23 KB, text/plain)
2008-03-29 12:15 UTC, hennerdrewes
no flags Details
Patch for svtools/source/filter.vcl/wmf/wmfwr.hxx (1.09 KB, text/plain)
2008-03-29 12:32 UTC, hennerdrewes
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description hennerdrewes 2008-01-30 10:13:38 UTC
When emdedding a writer document with hebrew text into another (non OOo)
document, the text appears completely garbled. 

I am attaching a simple writer document and a screenshot of the compound
document, with this document embedded. You may notice that the hebrew word is
misaligned. The metafile used in the OLE data transfer would probably need a
SetTextAlign (..., TA_RIGHT) command before text output.

When using more complext text, words are frequently rendered one on top of
other. See second screenshot.
Comment 1 hennerdrewes 2008-01-30 10:15:07 UTC
Created attachment 51253 [details]
writer doc used for embedding
Comment 2 hennerdrewes 2008-01-30 10:15:44 UTC
Created attachment 51254 [details]
Screenshot
Comment 3 hennerdrewes 2008-01-30 10:16:36 UTC
Created attachment 51255 [details]
Additional screenshot
Comment 4 michael.ruess 2008-02-13 12:48:18 UTC
Created attachment 51492 [details]
Screenshot from my OOo
Comment 5 michael.ruess 2008-02-13 13:09:40 UTC
Cannot reproduce the problem, as you can see from my screenshot.
Are you sure, that you are working with the native build which can be downloaded
from OOo website?
Tested with OO 2.3.1 and OO 2.4 on Windows. Do you have OOo on Windows Vista?
Comment 6 michael.ruess 2008-02-13 13:11:36 UTC
Closed, not reproducible.
Comment 7 hennerdrewes 2008-02-13 13:14:19 UTC
@mru: try the same thing e.g. with MS Word, or any other OLE container
application, but not inside OOo.

You will see something else...
Comment 8 michael.ruess 2008-02-14 12:30:50 UTC
It is a problem of the Container Application in creating the metafile display of
the object. When you activate (double click) the object the formatting will be
displayed fine. 
Comment 9 hennerdrewes 2008-02-14 15:21:48 UTC
It is true that the cause of the problem is with the metafile display.

But OOo is responsible for the creation of the windows metafile, not the
container application. The container application typically draws the object by
calling OleDraw or IViewObject2.Draw. The metafile is provided by the object's
implementation of IDataObject.GetData.

If you embed the object into another OOo document, it is displayed fine, as (I
assume) OOo internal metafile format is used, which is handled correctly. If you
embed it into another container (and I tested it with a lot of containers,
results are all the same), the OOo metafile is converted to a windows metafile,
and this conversion is faulty with RTL text. And by the way, an embedded object
is only useful, if it is displayed correctly in its passive state. Usually you
want to create a proper printout. 

There actually two problems in the metafile conversion.
1. The layout mode recorded in the original OOo metafile is not read in the
conversion to the windows metafile. But the flags TEXT_LAYOUT_BIDI_RTL,
TEXT_LAYOUT_TEXTORIGIN_RIGHT and TEXT_LAYOUT_TEXTORIGIN_LEFT should be read and
converted to the appropriate TA_LEFT, TA_RIGHT and TA_RTLREADING values, that
should be applied to a META_SETTEXTALIGN record.

2. The hebrew unicode characters cannot be written to the windows metafile,
instead a polygon replacement is used, leading to a substantial quality loss. If
you determined the appropriate windows code page and windows font character set
from the unicode characters, the polygon replacement could be avoided. 

I experimented with some hacks, which unfortunately haven't lead to a complete
solution, but hopefully they will give some ideas. Adding functionality to the
metafile conversion to overcome problem 1 is straightforward. I didn't have
enough knowledge of your platform independent rtl_, font and code page support
functions to come up with a solution for problem 2, though. So I fixed problem 1
in the conversion to the enhanced metafile format. Then I hacked into the
IDataObject.QueryGetData implementation, forcing it to use the EMF instead of
the WMF format:

STDMETHODIMP EmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc )
{
...
...  else if ( pFormatetc->cfFormat == CF_METAFILEPICT )
     {
	// ugly hack
	return DV_E_FORMATETC;

I'll attach my patch to the enhanced metafile conversion. This, together with
the QueryGetData hack, fixes the described display problem. Unfortunately this
also causes other problems with saving and loading the OOo object from the
container application, so this is definitively not a solution. But it should
outline the necessary actions.

And please, reopen the issue.
Thx
Comment 10 hennerdrewes 2008-02-14 15:47:21 UTC
Created attachment 51514 [details]
patch for svtools/source/filter.vcl/wmf/emfwr.hxx
Comment 11 hennerdrewes 2008-02-14 15:48:01 UTC
Created attachment 51515 [details]
patch for svtools/source/filter.vcl/wmf/emfwr.cxx
Comment 12 michael.ruess 2008-02-14 15:55:50 UTC
Reopened.
Comment 13 michael.ruess 2008-02-14 16:01:54 UTC
MRU->SJ. could you please have a look, if the attached patch could solve the
mentioned metafile problem in third party applications?
Comment 14 hennerdrewes 2008-02-14 17:57:14 UTC
just to clarify: this patch does not solve the problem itself.

The logic of the performed changes should be also applied to wmfwr.cxx.
In addition, additional steps are required to solve the problem with the output
of unicode characters. See my comments above.
Comment 15 hennerdrewes 2008-03-29 12:15:35 UTC
Created attachment 52359 [details]
Patch for svtools/source/filter.vcl/wmf/wmfwr.cxx
Comment 16 hennerdrewes 2008-03-29 12:32:14 UTC
Created attachment 52360 [details]
Patch for svtools/source/filter.vcl/wmf/wmfwr.hxx
Comment 17 hennerdrewes 2008-03-29 12:39:10 UTC
I made the equivalent changes to wmfwr.cxx, according to my previous patch to
the enhanced metafile writer.

I addition, I took a piece of code from the msword filter to convert the unicode
string, which is not compatible to wmf, to its appropriate windows font
character set. 

It seems to work fine. 
Please evaluate and integrate.
Comment 18 sven.jacobi 2008-05-16 10:54:06 UTC
Thanks for your patch, I will evaluate and then integrate it.
Comment 19 sven.jacobi 2008-05-16 17:11:15 UTC
The patch looks very good. I only needed to add the link dependency to i18nutil
in the makefile of svtools.

The patch will be integrated with cws[impress143].
Comment 20 sven.jacobi 2008-05-30 12:21:17 UTC
this issue is ready to be verified in cws[impress143]
Comment 21 christian.guenther 2008-06-27 14:03:02 UTC
To reproduce the bug:
- Insert the oletest.odt attachment as a OLE in an application (tested with Impress)
- export the ole as a wmf graphic
- import the graphic also in the Impress
- the OLE and the imported wmf have to be identical.

CGU: Verified in cws impress143
Comment 22 michael.ruess 2008-08-19 15:01:06 UTC
Checked fix in OOO300m3.