https://bugs.freedesktop.org/show_bug.cgi?id=32485

--- Comment #3 from Owen Genat <[email protected]> ---
Created attachment 79733
  --> https://bugs.freedesktop.org/attachment.cgi?id=79733&action=edit
Files (ODT/PDF/JPEG) for 4-step process outlining captioning.

I am attaching a series of working examples and providing some further detail
in order to better illustrate the point being made by the OP. This problem
still occurs under v4.0.3.3 (Build ID:
0eaa50a932c8f2199a615e1eb30f7ac74279539). In summary, as indicated by the OP,
the visual display of elements (after captioning) does not indicate the
underlying XML frame style definitions. Hopefully the detail here is helpful.

My attached example includes several files, which are relatively
self-explanatory by their names. They indicate a 4-step process of:
1_ Two text paragraphs and the "Graphics" and "Frame" styles formatted as
required (both with No Wrap, 18pt above/below for Graphics, 0pt above/below for
Frame, both with width 100%, height Auto, and position Left/Top).
2_ A single graphic inserted between the two paragraphs (JPEG is included
separately).
3_ The single graphic captioned via right-click > Caption... method i.e.,
graphic is enclosed in a text box.
4_ "Graphics" frame style is re-applied to graphic in text box.
There is a PDF of each ODT for clarity.

The following is an overview of the XML during critical stages of this process. 

Step 2 - Uncaptioned graphic
When a graphic is inserted it is placed in a <draw:frame> element and given a
corresponding <style:style> element (in content.xml), which in turn links to a
<style:style> and <style:graphic-properties> element pair for the "Graphics"
frame style (in styles.xml) where the fo:margin-top and fo:margin-bottom
attributes are set. For example in the attached file 2_inserted_graphic.odt the
XML appears thus:

content.xml:
<style:style style:name="fr1" style:family="graphic"
style:parent-style-name="Graphics">
    <style:graphic-properties style:vertical-pos="top"
style:vertical-rel="paragraph-content" style:mirror="none" fo:clip="rect(0pt,
0pt, 0pt, 0pt)" draw:luminance="0%" draw:contrast="0%" draw:red="0%"
draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false"
draw:image-opacity="100%" draw:color-mode="standard"/>
</style:style>

<draw:frame draw:style-name="fr1" draw:name="graphics1"
text:anchor-type="paragraph" svg:width="299.99pt" svg:height="150.01pt"
draw:z-index="0">
    <draw:image xlink:href="Pictures/1000000000000190000000C86E44B4CA.jpg"
xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>

styles.xml:
<style:style style:name="Graphics" style:family="graphic">
    <style:graphic-properties svg:width="481.89pt" style:rel-width="100%"
fo:min-height="1.16pt" text:anchor-type="paragraph" svg:x="0pt" svg:y="0pt"
fo:margin-top="18pt" fo:margin-bottom="18pt" style:wrap="none"
style:vertical-pos="top" style:vertical-rel="paragraph-content"
style:horizontal-pos="left" style:horizontal-rel="paragraph"/>
</style:style>

Note the initial definition for above / below margins surrounding the graphic
are handled via the "Graphics" frame style in styles.xml. This is expected and
matches that in 1_text_only_edited_frame_styles.odt.

Step 3 - Captioned graphic
When a graphic is given a caption via the right-click > Caption... method an
additional text box is added around the existing frame. The original
<draw:frame> element is enclosed in a subsequent <draw:frame> and
<draw:text-box> element pair, with the text-box linking to the "Frame" frame
style in styles.xml. For example in the attached file
3_inserted_graphic_with_caption.odt the XML appears thus:

content.xml:
<style:style style:name="fr1" style:family="graphic"
style:parent-style-name="Frame">
    <style:graphic-properties fo:margin-top="18pt" fo:margin-bottom="18pt"
style:vertical-pos="top" style:vertical-rel="paragraph-content"
style:horizontal-pos="left" style:horizontal-rel="paragraph" fo:padding="0pt"
fo:border="none"/>
</style:style>
<style:style style:name="fr2" style:family="graphic"
style:parent-style-name="Graphics">
    <style:graphic-properties fo:margin-left="0pt" fo:margin-right="0pt"
fo:margin-top="0pt" fo:margin-bottom="0pt" style:run-through="foreground"
style:wrap="none" style:vertical-pos="from-top"
style:vertical-rel="paragraph-content" style:horizontal-pos="from-left"
style:horizontal-rel="paragraph-content" fo:padding="0pt" fo:border="none"
style:shadow="none" style:mirror="none" fo:clip="rect(0pt, 0pt, 0pt, 0pt)"
draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%"
draw:blue="0%" draw:gamma="100%" draw:color-inversion="false"
draw:image-opacity="100%" draw:color-mode="standard"/>
</style:style>

<draw:frame draw:style-name="fr1" draw:name="Frame1"
text:anchor-type="paragraph" svg:width="299.99pt" draw:z-index="0">
    <draw:text-box fo:min-height="150.01pt">
        <text:p text:style-name="Figure">
            <draw:frame draw:style-name="fr2" draw:name="graphics1"
text:anchor-type="paragraph" svg:x="0.11pt" svg:y="0.06pt" svg:width="299.99pt"
style:rel-width="100%" svg:height="150.01pt" style:rel-height="scale"
draw:z-index="1">
                <draw:image
xlink:href="Pictures/1000000000000190000000C86E44B4CA.jpg" xlink:type="simple"
xlink:show="embed" xlink:actuate="onLoad"/>
            </draw:frame>Figure 
            <text:sequence text:ref-name="refFigure0" text:name="Figure"
text:formula="ooow:Figure+1" style:num-format="1">1</text:sequence>. Bar scene.
        </text:p>
    </draw:text-box>
</draw:frame>

style.xml:
<style:style style:name="Graphics" style:family="graphic">
    <style:graphic-properties svg:width="481.89pt" style:rel-width="100%"
fo:min-height="1.16pt" text:anchor-type="paragraph" svg:x="0pt" svg:y="0pt"
fo:margin-top="18pt" fo:margin-bottom="18pt" style:wrap="none"
style:vertical-pos="top" style:vertical-rel="paragraph-content"
style:horizontal-pos="left" style:horizontal-rel="paragraph"/>
</style:style>
<style:style style:name="Frame" style:family="graphic">
    <style:graphic-properties svg:width="481.89pt" style:rel-width="100%"
fo:min-height="9.75pt" text:anchor-type="paragraph" svg:x="0pt" svg:y="0pt"
fo:margin-left="0pt" fo:margin-right="0pt" fo:margin-top="0pt"
fo:margin-bottom="0pt" style:wrap="none" style:vertical-pos="top"
style:vertical-rel="paragraph-content" style:horizontal-pos="left"
style:horizontal-rel="paragraph-content" fo:padding="4.25pt" fo:border="0.06pt
solid #000000"/>
</style:style>

As can been seen the inner graphics frame (style name "fr1" originally) has
become "fr2" and the associated "Graphics" frame style in styles.xml has
maintained the fo:margin-top and fo:margin-bottom settings ("18pt" in the
example) as expected. Similarly the "Frame" frame style in styles.xml has
maintained its fo:margin-top and fo:margin-bottom settings ("0pt" in the
example). However the style:graphic-properties element for the "Frame" frame
style in content.xml now also has fo:margin-top and fo:margin-bottom set to
"18pt". As the OP mentions the spacing appears "transferred" from the graphic
to the enclosing text box.

Step 4 - Re-applied "Graphics" frame style
Re-applying the "Graphics" frame style to the enclosed graphic brings back the
space between the graphic and surrounding frame. The differences in content.xml
and style.xml between 3_inserted_graphic_with_caption.odt and
4_inserted_graphic_with_caption_with_reapplied_style.odt are:

content.xml:
The <style:graphic-properties> element for the "fr2" (graphic) frame removes
these attributes in step 4:
fo:margin-left="0pt" fo:margin-right="0pt" fo:margin-top="0pt"
fo:margin-bottom="0pt" style:run-through="foreground" style:wrap="none"
style:horizontal-pos="from-left" style:horizontal-rel="paragraph-content"
fo:padding="0pt" fo:border="none" style:shadow="none" 

The same element also has a change in attribute from
style:vertical-pos="from-top" to style:vertical-pos="top".

The <draw:frame> element for the "fr2" (graphic) frame includes these
additional attributes in step 4:
svg:x="0.11pt" svg:y="0.06pt"

styles.xml:
A new style is included: <style:style style:name="Frame_20_contents"
style:display-name="Frame contents" style:family="paragraph"
style:parent-style-name="Text_20_body" style:class="extra"/>

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to