Issue 86769 - WW8: Drawing objects wrongly imported and exported in vertical writing
Summary: WW8: Drawing objects wrongly imported and exported in vertical writing
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: ui (show other issues)
Version: OOo 2.3.1
Hardware: All Windows XP
: P3 Trivial (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-06 14:25 UTC by bluedwarf
Modified: 2013-08-07 14:38 UTC (History)
7 users (show)

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


Attachments
An example Word document which cause the rendering problem (23.50 KB, application/msword)
2008-03-06 14:28 UTC, bluedwarf
no flags Details
A patch and its .dll file (4.05 MB, application/x-compressed)
2008-07-23 08:05 UTC, tora3
no flags Details
A bugdoc prepared with Word 2003. (69.00 KB, application/msword)
2009-04-24 00:59 UTC, tora3
no flags Details
Snapshots of the bugdoc. (150.89 KB, image/png)
2009-04-24 01:00 UTC, tora3
no flags Details
An experimental patch to DEV300_m41 (3.63 KB, patch)
2009-04-24 01:01 UTC, tora3
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description bluedwarf 2008-03-06 14:25:47 UTC
When I opened a Word document which includes WordArt object, OpenOffice.org
Writer placed the object in wrong position. I will attach an example Word
document later. Please open it by Word and OpenOffice.org Writer and compare the
two rendered result.
Comment 1 bluedwarf 2008-03-06 14:28:05 UTC
Created attachment 51937 [details]
An example Word document which cause the rendering problem
Comment 2 bluedwarf 2008-03-06 14:39:12 UTC
I have already investigated the cause of this problem from the view point of users.

This problem occurs if the direction of body text is vertical. When I opened a
Word document whose body text direction was horizontal (default), OpenOffice.org
Writer showed WordArt objects in correct location. However, when I changed the
direction vertical by Word and opened it by OpenOffice.org Writer,
OpenOffice.org Writer displayed a different result.

Moreover, when I checked out the values of the wrong position by OpenOffice.org
Writer, Position X and Position Y were negative values.

Therefore, I think the Word import filter has some bugs.
Comment 3 bluedwarf 2008-03-06 14:48:10 UTC
Sorry for the incorrect information. The values of the horizontal position was
not negative. Only the value of the vertical position was negative.
Comment 4 michael.ruess 2008-03-06 15:27:52 UTC
MRU->HB: see attached document, when there is an object on vertical page layout,
the position is wrong when imported in OOo.
Comment 5 tora3 2008-06-26 08:55:35 UTC
Through an experiment aiming to look into the cause of this issue, the 
following facts have been found:

 - The measurement system of WordArt is altered in case of vertical writing.

 - That of Writer is NOT changed in case of vertical writing.

 - Measurement conversion from Word in vertical writing to Writer can be 
   implemented in the following way:

Index: ww8graf.cxx
===================================================================
RCS file: /cvs/sw/sw/source/filter/ww8/ww8graf.cxx,v
retrieving revision 1.151
diff -U 63 -r1.151 ww8graf.cxx
--- ww8graf.cxx	10 Apr 2008 17:23:45 -0000	1.151
+++ ww8graf.cxx	26 Jun 2008 07:33:14 -0000
@@ -2435,126 +2435,142 @@
 
 SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
 {

...(omitted)...
 
     WW8_FSPA_SHADOW* pFS = (WW8_FSPA_SHADOW*)pF0;
     WW8_FSPA*        pF;
 #ifdef __WW8_NEEDS_COPY
     WW8_FSPA aFSFA;
     pF = &aFSFA;
     WW8FSPAShadowToReal( pFS, pF );
 #else
     pF = (WW8_FSPA*)pFS;
 #endif // defined __WW8_NEEDS_COPY
     if( !pF->nSpId )
     {
         ASSERT( !this, "+Wo ist die Grafik (3) ?" );
         return 0;
     }
 
     if (!pMSDffManager->GetModel())
          pMSDffManager->SetModel(pDrawModel, 1440);
 
+    // --> #i86769#
+    fprintf(stderr, "  nXaLeft = %ld,  nYaTop = %ld, nXaRight = %ld, nYaBottom
= %ld\n", pF->nXaLeft,  pF->nYaTop, pF->nXaRight, pF->nYaBottom);
+    if (1) // Todo: need to determine if the TextFlow is in vertical writing.
+    {
+        // In case of vertical writing, the mesurment system of Word should be
converted into that of Writer.
+        sal_Int32 nLeft   = pF->nXaLeft;
+        sal_Int32 nTop    = pF->nYaTop;
+        sal_Int32 nRight  = pF->nXaRight;
+        sal_Int32 nBottom = pF->nYaBottom;
+        pF->nXaLeft   = nTop;
+        pF->nYaTop    = 0 - nRight;
+        pF->nXaRight  = nRight - nLeft + nTop;
+        pF->nYaBottom = nBottom - nTop - nRight;
+    }
+    fprintf(stderr, "  nXaLeft = %ld,  nYaTop = %ld, nXaRight = %ld, nYaBottom
= %ld\n", pF->nXaLeft,  pF->nYaTop, pF->nXaRight, pF->nYaBottom);
+    // <-- #i86769#
 
     Rectangle aRect(pF->nXaLeft,  pF->nYaTop, pF->nXaRight, pF->nYaBottom);
     SvxMSDffImportData aData( aRect );
 
...(omitted)...

Questions:

(a) Is there any practical way to know if the document is in vertical writing 
    within the method SwWW8ImplReader::Read_GrafLayer()?

(b) Are there any comments to solve this issue?
Comment 6 tora3 2008-07-16 06:25:01 UTC
Thanks to everybody. Eventually, I have got it. 
It seems that this issue could be fixed by the following code fragments. 

In the method 
SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )

===================================================================
RCS file: /cvs/sw/sw/source/filter/ww8/ww8graf.cxx,v
retrieving revision 1.151
diff -U 4 -r1.151 ww8graf.cxx
--- ww8graf.cxx	10 Apr 2008 17:23:45 -0000	1.151
+++ ww8graf.cxx	16 Jul 2008 05:04:59 -0000
@@ -2494,8 +2494,23 @@
 
     if (!pMSDffManager->GetModel())
          pMSDffManager->SetModel(pDrawModel, 1440);
 
+    // --> #i86769#
+    if ( maSectionManager.CurrentSectionIsVertical() )
+    {
+        // In case of vertical writing, the coordinate system of Word for 
+        // vertical text flow should be converted into that of Writer.
+        sal_Int32 nLeft   = pF->nXaLeft;
+        sal_Int32 nTop    = pF->nYaTop;
+        sal_Int32 nRight  = pF->nXaRight;
+        sal_Int32 nBottom = pF->nYaBottom;
+        pF->nXaLeft   = nTop;
+        pF->nYaTop    = 0 - nRight;
+        pF->nXaRight  = nRight - nLeft + nTop;
+        pF->nYaBottom = nBottom - nTop - nRight;
+    }
+    // <-- #i86769#
 
     Rectangle aRect(pF->nXaLeft,  pF->nYaTop, pF->nXaRight, pF->nYaBottom);
     SvxMSDffImportData aData( aRect );


I am also trying to accomplish the similar one for exporting a document into 
Word file format. 
Comment 7 tora3 2008-07-23 08:02:46 UTC
Here is a patch to attempt of fixing this issue.
Cited from README.txt in the attachment 86769 [details]_patch_2008-07-23.zip

This package includes the following files:

Structure 
  86769_patch_2008-07-23
    |-- README.txt
    |
    |-- src
    |   `-- 86769_patch_2008-07-23.diff
    |
    `-- windows
        `-- _PROGRAMFILES_
            `-- OpenOffice.org_2.4
                `-- program
                    `-- sw680mi.dll

Files
 - 86769_patch_2008-07-23.diff 
    A patch that is prepared based on DEV300_m14

 - sw680mi.dll 
    A .dll file for OpenOffice.org 2.4 Windows, 
    which is built with the followings:
     - Source files of OpenOffice.org 2.4 [1]
     - solver of OpenOffice.org 2.4 [2]
     - The patch above

    This .dll file is primarily intended for experiment 
    use to confirm the patch.

References
 [1] (mirror_network)/stable/2.4.0/OOo_2.4.0_src_*.tar.bz2
 [2] (mirror_network)/extended/2.4.0rc6/OOo_2.4.0_WindowsIntel_solver.zip
 [3] http://www.openoffice.org/issues/show_bug.cgi?id=86769
 [4] http://openoffice-ja.org/wiki/issue/86769 (Japanese)
Comment 8 tora3 2008-07-23 08:05:36 UTC
Created attachment 55319 [details]
A patch and its .dll file
Comment 9 tora3 2009-03-05 10:28:01 UTC
.
Comment 10 tora3 2009-04-24 00:57:21 UTC
A bugdoc, its snapshots, and experimental patch are being attached. 

 - bugdoc: 86769_wordarts_01.doc
 - snapshots: i86769_wordarts_01_doc_snapshots.png (Word, DEV300_m41, and patch)
 - patch: i86769_patch_for_DEV300_m41_2009-04-24.diff

It seems that the patch could be also applied to DEV300_m44.
Comment 11 tora3 2009-04-24 00:59:25 UTC
Created attachment 61765 [details]
A bugdoc prepared with Word 2003.
Comment 12 tora3 2009-04-24 01:00:53 UTC
Created attachment 61766 [details]
Snapshots of the bugdoc.
Comment 13 tora3 2009-04-24 01:01:45 UTC
Created attachment 61767 [details]
An experimental patch to DEV300_m41
Comment 14 tora3 2009-04-24 01:26:37 UTC
Even though the snapshots above solely illustrates a phenomenon upon loading 
a Word file, the patch above also covers a fix upon saving a Writer document 
into Word file. 
Comment 15 openoffice 2009-04-30 16:24:24 UTC
I put this on my list of patches to check for OOo3.2. 

Experimental => decision about target after evaluation
Comment 16 tora3 2011-02-11 16:57:06 UTC
assigned to tora
Comment 17 tora3 2011-02-11 16:57:40 UTC
cws tora01 has been created.
Comment 18 tora3 2011-02-11 17:00:35 UTC
fixed in the cws tora01

hbrinkm: what do you think of the fix?
http://hg.services.openoffice.org/cws/tora01/rev/9eef1e4474af
Comment 19 openoffice 2011-02-14 10:09:03 UTC
tora: The fix looks good to me.
Comment 20 tora3 2011-02-14 18:02:21 UTC
hbrinkm: thank you!
Comment 21 tora3 2011-02-17 20:52:00 UTC
re-synchronized with DEV300_m100.

changeset:  275238:ee188f881518

mru: Could you test this?
Comment 22 Du Jing 2012-10-23 06:34:57 UTC
verified on the build AOO3.5_r1400796