<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
line-height:150%;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:150%;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
.MsoPapDefault
{mso-style-type:export-only;
line-height:150%;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1687367924;
mso-list-type:hybrid;
mso-list-template-ids:1529381090 -1394960680 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
{mso-level-start-at:4418;
mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:Arial;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l1
{mso-list-id:1954164259;
mso-list-type:hybrid;
mso-list-template-ids:-585589136 -783248346 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l1:level1
{mso-level-start-at:4418;
mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:Arial;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>I have prepared a document in Word that has a page-border (with no shadow). <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>I've saved it as a DOC and DOCX that are the same (attached).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><u><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>The document has:<o:p></o:p></span></u></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>Page margin of<b> 72pt</b> (<b>1440 TWIP</b>) <o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>Page border<b> 0.5pt </b>thick (<b>10 TWIP</b>)<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>Border is at a distance of<b> 5pt </b> (<b>100 TWIP</b>) from the text.<o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></b></p><p class=MsoNormal><b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><img width=960 height=401 id="Picture_x0020_3" src="cid:image001.jpg@01CE62D1.1464F290"></span></b><b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></b></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When I import both DOC and DOCX in LO – they <b>look different </b>and are exported differently to DOCX.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When I dived into the code – I first looked at the DOCX exporter to try to understand what is different.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>I found out that in this function - <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#4387">DocxAttributeOutput::FormatLRSpace</a> – in <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#4417">line 4417</a> this happens:<br><br><o:p></o:p></span></p><pre style='background:white'><span style='color:black'> <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#nLDist"><span style='color:#990099'>nLDist</span></a> = <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#nLDist"><span style='color:#990099'>nLDist</span></a> + (<a href="http://opengrok.libreoffice.org/s?defs=sal_uInt16&project=core"><span style='color:#105802'>sal_uInt16</span></a>)<a href="http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core"><span style='color:#105802'>rLRSpace</span></a>.<a href="http://opengrok.libreoffice.org/s?defs=GetLeft&project=core"><span style='color:#105802'>GetLeft</span></a>();<o:p></o:p></span></pre><pre style='background:white'><span style='color:black'> <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#nRDist"><span style='color:#990099'>nRDist</span></a> = <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#nRDist"><span style='color:#990099'>nRDist</span></a> + (<a href="http://opengrok.libreoffice.org/s?defs=sal_uInt16&project=core"><span style='color:#105802'>sal_uInt16</span></a>)<a href="http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core"><span style='color:#105802'>rLRSpace</span></a>.<a href="http://opengrok.libreoffice.org/s?defs=GetRight&project=core"><span style='color:#105802'>GetRight</span></a>();<o:p></o:p></span></pre><pre style='background:white'><span style='color:black'><o:p> </o:p></span></pre><pre style='background:white'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When I debugged it I saw that </span><span style='color:black'><a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#nLDist"><span style='color:#990099'>nLDist</span></a> </span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>and </span><span style='color:black'><a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/docxattributeoutput.cxx#nRDist"><span style='color:#990099'>nRDist</span></a> </span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>are 110 (<b><u>both the same</u></b> when importing DOC and when importing DOCX). <o:p></o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>I guess 110 = border thickness + border distance from text.<o:p></o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>However, there <b><u>is</u></b> a difference between DOC and DOCX that were imported on the right hand-side parameter:<o:p></o:p></span></pre><pre style='margin-left:.5in;text-indent:-.25in;line-height:150%;mso-list:l1 level1 lfo1;background:white'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When I import from DOC – the </span><span style='color:black'><a href="http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core"><span style='color:#105802'>rLRSpace</span></a>.<a href="http://opengrok.libreoffice.org/s?defs=GetLeft&project=core"><span style='color:#105802'>GetLeft</span></a>()</span><b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>returns 1330</span></b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>, which is the original 1440 minus 110 (in TIPS it is 72 – 5.5)<o:p></o:p></span></pre><pre style='margin-left:.5in;text-indent:-.25in;line-height:150%;mso-list:l1 level1 lfo1;background:white'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When I import from DOCX – the </span><span style='color:black'><a href="http://opengrok.libreoffice.org/s?defs=rLRSpace&project=core"><span style='color:#105802'>rLRSpace</span></a>.<a href="http://opengrok.libreoffice.org/s?defs=GetLeft&project=core"><span style='color:#105802'>GetLeft</span></a>()</span><b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>returns 1440</span></b><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>.<o:p></o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>This lead me to think that the <b>import</b> process is faulted, and that:<o:p></o:p></span></pre><pre style='margin-left:.5in;text-indent:-.25in;line-height:150%;mso-list:l1 level1 lfo1;background:white'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When importing from DOC – the (border+border margin) are deducted from the page margin<o:p></o:p></span></pre><pre style='margin-left:.5in;text-indent:-.25in;line-height:150%;mso-list:l1 level1 lfo1;background:white'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When importing from DOCX – this is not deducted<o:p></o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></pre><pre style='line-height:150%;background:white'><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>This leads to the fact that when I export to DOCX than:<o:p></o:p></span></pre><pre style='margin-left:.5in;text-indent:-.25in;line-height:150%;mso-list:l1 level1 lfo1;background:white'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When the imported file was a DOC – the exported page margin is 1440 (110 + 1330)<o:p></o:p></span></pre><pre style='margin-left:.5in;text-indent:-.25in;line-height:150%;mso-list:l1 level1 lfo1;background:white'><![if !supportLists]><span style='font-size:11.0pt;line-height:150%;font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span dir=LTR></span><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>When the imported file was a DOC – the exported page margin is 1550 (110 + 1440)<o:p></o:p></span></pre><pre style='background:white'><span style='color:black'><o:p> </o:p></span></pre><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>I have located an interesting code piece in the DOC importer, that seems to deduct the '110 TWIPs' from the '1440' when importing,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>In the function <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#449">SetPageBorder</a> that calls <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#SetFlyBordersShadow">SetFlyBordersShadow</a>.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>This <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#SetFlyBordersShadow">SetFlyBordersShadow</a> seems to initialize an 'aSizeArray' that is then <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#495">deducted</a> from the page margins.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>The same logic does not appear to exist in the <a href="http://opengrok.libreoffice.org/xref/core/writerfilter/source/dmapper/PropertyMap.cxx#SetBorderDistance">equivalent function</a> in the DOCX importer.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>Simply adding the logic of <a href="http://opengrok.libreoffice.org/xref/core/sw/source/filter/ww8/ww8par6.cxx#SetFlyBordersShadow">SetFlyBordersShadow</a> to the DOCX importer looks very complicated to me (requires implementing a lot of functions from ww8, not trivial for me).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>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).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'>Best,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;line-height:150%;font-family:"Calibri","sans-serif";color:#1F497D'> Adam Co</span><o:p></o:p></p></div></body></html>