Download it now!
Bug 32485 - Settings on the image frame style lost when caption is applied
Summary: Settings on the image frame style lost when caption is applied
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 73385 (view as bug list)
Depends on:
Blocks: Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2010-12-17 16:44 UTC by RGB
Modified: 2019-10-01 09:35 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Files (ODT/PDF/JPEG) for 4-step process outlining captioning. (294.56 KB, application/zip)
2013-05-24 05:48 UTC, Owen Genat (retired)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description RGB 2010-12-17 16:44:57 UTC
When applying a caption, frame styles are not honoured.

Steps to reproduce the issue:
In a new Writer document, edit the "Graphics" frame style in order to add space
below any inserted image.
Insert two dummy paragraphs and between them insert an image. When the image is inserted, the spacing works as expected.
Now, right click over the image and select "caption". Type any text and press
enter.

Expected behavior: 
The space set in the Graphics frame style keep a distance between the image and the caption.

Result: 
The space below the image is "transferred" to the new external frame and
no space is left between the image and the caption. Below the external frame a
space NOT set by the user is inserted while the configured space below the image
get lost.

Notice: By re-applying the Graphics frame style to the image only, the space is
recreated.
Everything behave as if direct formatting were applied to both, Graphics and
"external" frame style reverting the spacing settings introduced by the user. In
fact, the frame that contains both image and caption is a "variation" of he
"Frame" frame style, but with "direct formatting" applied on it: There is no way
to control the default properties for that frame.
This behavior goes against the whole idea of frame styles.
Comment 1 Björn Michaelsen 2011-12-23 11:33:44 UTC Comment hidden (obsolete)
Comment 2 RGB 2011-12-23 16:43:21 UTC
The problem is present on 3.5 beta2.
Comment 3 Owen Genat (retired) 2013-05-24 05:48:42 UTC
Created attachment 79733 [details]
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"/>
Comment 4 QA Administrators 2014-10-23 17:31:45 UTC Comment hidden (obsolete)
Comment 5 Owen Genat (retired) 2015-03-14 13:11:23 UTC
Tested under GNU/Linux using 4.2.8.2, 4.3.5.2, and 4.4.1.2. All versions exhibit the problem.
Comment 6 tommy27 2016-04-16 07:26:04 UTC Comment hidden (obsolete)
Comment 7 RGB 2016-04-16 09:59:02 UTC
Still a problem on v5.1.2.2 on Linux 64bits (openSUSE 13.2)
Comment 8 Cor Nouws 2016-09-28 08:06:23 UTC
*** Bug 73385 has been marked as a duplicate of this bug. ***
Comment 9 Xisco Faulí 2017-09-29 08:48:26 UTC Comment hidden (obsolete)
Comment 10 RGB 2017-09-29 10:26:22 UTC
Still a problem on Version 5.4.1.2
Comment 11 QA Administrators 2018-09-30 02:48:00 UTC Comment hidden (obsolete)
Comment 12 RGB 2018-09-30 08:06:25 UTC
Problem still present in 6.1.2.1
Comment 13 QA Administrators 2019-10-01 03:02:58 UTC Comment hidden (obsolete)
Comment 14 RGB 2019-10-01 09:35:29 UTC
Problem still present in LibreOffice 6.3.2