Page Borders Issue - Import DOC vs DOCX

Adam Co rattles2013 at gmail.com
Thu Jun 6 06:15:37 PDT 2013


Hi,

I have prepared a document in Word that has a page-border (with no shadow). 

I've saved it as a DOC and DOCX that are the same (attached).

 

The document has:

*         Page margin of 72pt                        (1440 TWIP) 

*         Page border 0.5pt thick                 (10     TWIP)

*         Border is at a distance of 5pt       (100   TWIP)    from the
text.

 



 

When I import both DOC and DOCX in LO - they look different and are exported
differently to DOCX.

When I dived into the code - I first looked at the DOCX exporter to try to
understand what is different.

I found out that in this function - DocxAttributeOutput::FormatLRSpace
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#4387>  - in line 4417
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#4417>  this happens:



 
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#nLDist> nLDist =
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#nLDist> nLDist + (
<http://opengrok.libreoffice.org/s?defs=sal_uInt16&project=core> sal_uInt16)
<http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core> rLRSpace.
<http://opengrok.libreoffice.org/s?defs=GetLeft&project=core> GetLeft();
 
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#nRDist> nRDist =
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#nRDist> nRDist + (
<http://opengrok.libreoffice.org/s?defs=sal_uInt16&project=core> sal_uInt16)
<http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core> rLRSpace.
<http://opengrok.libreoffice.org/s?defs=GetRight&project=core> GetRight();
 
 
When I debugged it I saw that
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#nLDist> nLDist and
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattribut
eoutput.cxx#nRDist> nRDist are 110 (both the same when importing DOC and
when importing DOCX). 
I guess 110 = border thickness + border distance from text.
 
However, there is a difference between DOC and DOCX that were imported on
the right hand-side parameter:
*         When I import from DOC    - the
<http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core> rLRSpace.
<http://opengrok.libreoffice.org/s?defs=GetLeft&project=core>
GetLeft()returns 1330, which is the original 1440 minus 110 (in TIPS it is
72 - 5.5)
*         When I import from DOCX - the
<http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core> rLRSpace.
<http://opengrok.libreoffice.org/s?defs=GetLeft&project=core>
GetLeft()returns 1440.
 
This lead me to think that the import process is faulted, and that:
*         When importing from DOC - the (border+border margin) are deducted
from the page margin
*         When importing from DOCX - this is not deducted
 
This leads to the fact that when I export to DOCX than:
*         When the imported file was a DOC - the exported page margin is
1440    (110 + 1330)
*         When the imported file was a DOC - the exported page margin is
1550    (110 + 1440)
 

I have located an interesting code piece in the DOC importer, that seems to
deduct the '110 TWIPs' from the '1440' when importing,

In the function SetPageBorder
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#
449>  that calls SetFlyBordersShadow
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#
SetFlyBordersShadow> .

This SetFlyBordersShadow
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#
SetFlyBordersShadow>  seems to initialize an 'aSizeArray' that is then
deducted
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#
495>  from the page margins.

 

The same logic does not appear to exist in the equivalent function
<http://opengrok.libreoffice.org/xref/core/writerfilter/source/dmapper/Prope
rtyMap.cxx#SetBorderDistance>  in the DOCX importer.

 

Simply adding the logic of SetFlyBordersShadow
<http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#
SetFlyBordersShadow>  to the DOCX importer looks very complicated to me
(requires implementing a lot of functions from ww8, not trivial for me).

 

Before I even think of doing that - I'd like to hear if anyone thinks of a
better solution to the problem (maybe I am understanding things wrong).

 

Best,

                Adam Co

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130606/522296c8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 39919 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130606/522296c8/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Page Borders - From Text 5pt no-shadow DOCX [public].docx
Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Size: 12979 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130606/522296c8/attachment.docx>


More information about the LibreOffice mailing list