Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


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

JPEG image

Attachment: Page Borders - From Text 5pt no-shadow DOCX [public].docx
Description: MS-Word 2007 document


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.